etudes 0.26.0 → 0.30.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.
@@ -0,0 +1,25 @@
1
+ import { CSSProperties, PureComponent } from 'react';
2
+ export interface Props {
3
+ className?: string;
4
+ style?: CSSProperties;
5
+ isTogglable?: boolean;
6
+ shouldStaySelected?: boolean;
7
+ defaultSelectedIndex?: number;
8
+ onDeselectAt?: (index: number) => void;
9
+ onSelectAt?: (index: number) => void;
10
+ }
11
+ export interface State {
12
+ selectedIndex?: number;
13
+ }
14
+ export default class AbstractSelectableCollection<P extends Props = Props, S extends State = State> extends PureComponent<P, S> {
15
+ constructor(props: P);
16
+ componentDidMount(): void;
17
+ componentDidUpdate(prevProps: P, prevState: S): void;
18
+ render(): JSX.Element;
19
+ isIndexOutOfRange(index: number): boolean;
20
+ isSelectedAt(index: number): boolean;
21
+ toggleAt(index: number): void;
22
+ selectAt(index: number): void;
23
+ deselectAt(index: number): void;
24
+ deselectCurrent(): void;
25
+ }
@@ -58,7 +58,7 @@ var AbstractSelectableCollection = (function (_super) {
58
58
  var prevSelectedIndex = (_a = prevState.selectedIndex) !== null && _a !== void 0 ? _a : -1;
59
59
  var selectedIndex = (_b = this.state.selectedIndex) !== null && _b !== void 0 ? _b : -1;
60
60
  if (prevState.selectedIndex !== selectedIndex) {
61
- debug("Selected index changed: " + selectedIndex);
61
+ debug("Selected index changed: ".concat(selectedIndex));
62
62
  if (shouldStaySelected === true) {
63
63
  if (!this.isIndexOutOfRange(prevSelectedIndex))
64
64
  onDeselectAt === null || onDeselectAt === void 0 ? void 0 : onDeselectAt(prevSelectedIndex);
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractSelectableCollection.js","sourceRoot":"/","sources":["AbstractSelectableCollection.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAqE;AAErE,IAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC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;QACE,IAAI,CAAC,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;IACtC,CAAC;IACH,mCAAC;AAAD,CAAC,AAtGD,CAA4G,qBAAa,GAsGxH","sourcesContent":["import React, { CSSProperties, Fragment, PureComponent } from 'react'\n\nconst debug = process.env.NODE_ENV === 'development' ? require('debug')('etudes:asc') : () => {}\n\nexport interface Props {\n /**\n * Class attribute of the root element.\n */\n className?: string\n\n /**\n * Inline style attribute of the root element.\n */\n style?: CSSProperties\n\n /**\n * Indicates whether selections can be toggled. For example, in the case of\n * a vertical list of selectable rows, being able to toggle a row means it\n * gets deselected when selected again. Being unable to toggle the row means\n * it does not get deselected when selected again.\n */\n isTogglable?: boolean\n\n /**\n * Indicates whether selections are retained. For example, in the case of\n * a vertical list of clickable rows, being able to retain a selection means\n * when the row is clicked, it becomes and stays selected. Being unable to\n * retain a selection means when the row is clicked, it does not become\n * selected. It is simply clicked and the subsequent event is dispatched.\n */\n shouldStaySelected?: boolean\n\n /**\n * The default selected index. Any value below 0 indicates that nothing is\n * selected.\n */\n defaultSelectedIndex?: number\n\n /**\n * Handler invoked when an index is deselected.\n */\n onDeselectAt?: (index: number) => void\n\n /**\n * Handler invoked when an index is selected.\n */\n onSelectAt?: (index: number) => void\n}\n\nexport interface State {\n /**\n * The current selected index. Any value less than 0 indicates that no index\n * is selected.\n */\n selectedIndex?: number\n}\n\n/**\n * An abstract component that mimics and handles index selection in an abstract\n * collection.\n */\nexport default class AbstractSelectableCollection<P extends Props = Props, S extends State = State> extends PureComponent<P, S> {\n constructor(props: P) {\n super(props)\n\n this.state = {\n selectedIndex: this.props.defaultSelectedIndex ?? -1,\n } as any\n }\n\n componentDidMount() {\n if (this.state.selectedIndex !== undefined && this.state.selectedIndex > -1) {\n this.props.onSelectAt?.(this.state.selectedIndex ?? -1)\n }\n }\n\n componentDidUpdate(prevProps: P, prevState: S) {\n const { shouldStaySelected, onSelectAt, onDeselectAt } = this.props\n const prevSelectedIndex = prevState.selectedIndex ?? -1\n const selectedIndex = this.state.selectedIndex ?? -1\n\n if (prevState.selectedIndex !== selectedIndex) {\n debug(`Selected index changed: ${selectedIndex}`)\n\n if (shouldStaySelected === true) {\n if (!this.isIndexOutOfRange(prevSelectedIndex)) onDeselectAt?.(prevSelectedIndex)\n if (!this.isIndexOutOfRange(selectedIndex)) onSelectAt?.(selectedIndex)\n }\n }\n }\n\n render() {\n return <Fragment/>\n }\n\n /**\n * Checks if an index is out of range.\n *\n * @param index - The index to check.\n *\n * @returns `true` if the index is out of range, `false` otherwise.\n */\n isIndexOutOfRange(index: number): boolean {\n if (index < 0) return true\n return false\n }\n\n /**\n * Checks if an index is selected.\n *\n * @param index - The index to check.\n *\n * @returns `true` if the index is selected, `false` otherwise.\n */\n isSelectedAt(index: number): boolean {\n return (this.state.selectedIndex === index)\n }\n\n /**\n * Toggles an index, i.e. reverses its selected state.\n *\n * @param index - The index to toggle.\n */\n toggleAt(index: number) {\n if (this.props.isTogglable === true && this.isSelectedAt(index)) {\n this.deselectAt(index)\n }\n else {\n this.selectAt(index)\n }\n }\n\n /**\n * Selects an index.\n *\n * @param index - The index to select.\n */\n selectAt(index: number) {\n if (this.props.shouldStaySelected === true) {\n if (this.isSelectedAt(index)) return\n this.setState({ selectedIndex: index })\n }\n else if (this.props.onSelectAt) {\n this.props.onSelectAt(index)\n }\n }\n\n /**\n * Deselects an index if it is currently selected.\n *\n * @param index - The index to deselect.\n */\n deselectAt(index: number) {\n if (!this.isSelectedAt(index)) return\n this.setState({ selectedIndex: -1 })\n }\n\n /**\n * Deselects the currently selected index.\n */\n deselectCurrent() {\n this.setState({ selectedIndex: -1 })\n }\n}\n"]}
1
+ {"version":3,"file":"AbstractSelectableCollection.js","sourceRoot":"/","sources":["AbstractSelectableCollection.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAqE;AAErE,IAAM,KAAK,GAAG,OAAO,CAAC,GAA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,sDAAe,GAAf;QACE,IAAI,CAAC,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;IACtC,CAAC;IACH,mCAAC;AAAD,CAAC,AAtGD,CAA4G,qBAAa,GAsGxH","sourcesContent":["import React, { CSSProperties, Fragment, PureComponent } from 'react'\n\nconst debug = process.env.NODE_ENV === 'development' ? require('debug')('etudes:asc') : () => {}\n\nexport interface Props {\n /**\n * Class attribute of the root element.\n */\n className?: string\n\n /**\n * Inline style attribute of the root element.\n */\n style?: CSSProperties\n\n /**\n * Indicates whether selections can be toggled. For example, in the case of\n * a vertical list of selectable rows, being able to toggle a row means it\n * gets deselected when selected again. Being unable to toggle the row means\n * it does not get deselected when selected again.\n */\n isTogglable?: boolean\n\n /**\n * Indicates whether selections are retained. For example, in the case of\n * a vertical list of clickable rows, being able to retain a selection means\n * when the row is clicked, it becomes and stays selected. Being unable to\n * retain a selection means when the row is clicked, it does not become\n * selected. It is simply clicked and the subsequent event is dispatched.\n */\n shouldStaySelected?: boolean\n\n /**\n * The default selected index. Any value below 0 indicates that nothing is\n * selected.\n */\n defaultSelectedIndex?: number\n\n /**\n * Handler invoked when an index is deselected.\n */\n onDeselectAt?: (index: number) => void\n\n /**\n * Handler invoked when an index is selected.\n */\n onSelectAt?: (index: number) => void\n}\n\nexport interface State {\n /**\n * The current selected index. Any value less than 0 indicates that no index\n * is selected.\n */\n selectedIndex?: number\n}\n\n/**\n * An abstract component that mimics and handles index selection in an abstract\n * collection.\n */\nexport default class AbstractSelectableCollection<P extends Props = Props, S extends State = State> extends PureComponent<P, S> {\n constructor(props: P) {\n super(props)\n\n this.state = {\n selectedIndex: this.props.defaultSelectedIndex ?? -1,\n } as any\n }\n\n componentDidMount() {\n if (this.state.selectedIndex !== undefined && this.state.selectedIndex > -1) {\n this.props.onSelectAt?.(this.state.selectedIndex ?? -1)\n }\n }\n\n componentDidUpdate(prevProps: P, prevState: S) {\n const { shouldStaySelected, onSelectAt, onDeselectAt } = this.props\n const prevSelectedIndex = prevState.selectedIndex ?? -1\n const selectedIndex = this.state.selectedIndex ?? -1\n\n if (prevState.selectedIndex !== selectedIndex) {\n debug(`Selected index changed: ${selectedIndex}`)\n\n if (shouldStaySelected === true) {\n if (!this.isIndexOutOfRange(prevSelectedIndex)) onDeselectAt?.(prevSelectedIndex)\n if (!this.isIndexOutOfRange(selectedIndex)) onSelectAt?.(selectedIndex)\n }\n }\n }\n\n render() {\n return <Fragment/>\n }\n\n /**\n * Checks if an index is out of range.\n *\n * @param index - The index to check.\n *\n * @returns `true` if the index is out of range, `false` otherwise.\n */\n isIndexOutOfRange(index: number): boolean {\n if (index < 0) return true\n return false\n }\n\n /**\n * Checks if an index is selected.\n *\n * @param index - The index to check.\n *\n * @returns `true` if the index is selected, `false` otherwise.\n */\n isSelectedAt(index: number): boolean {\n return (this.state.selectedIndex === index)\n }\n\n /**\n * Toggles an index, i.e. reverses its selected state.\n *\n * @param index - The index to toggle.\n */\n toggleAt(index: number) {\n if (this.props.isTogglable === true && this.isSelectedAt(index)) {\n this.deselectAt(index)\n }\n else {\n this.selectAt(index)\n }\n }\n\n /**\n * Selects an index.\n *\n * @param index - The index to select.\n */\n selectAt(index: number) {\n if (this.props.shouldStaySelected === true) {\n if (this.isSelectedAt(index)) return\n this.setState({ selectedIndex: index })\n }\n else if (this.props.onSelectAt) {\n this.props.onSelectAt(index)\n }\n }\n\n /**\n * Deselects an index if it is currently selected.\n *\n * @param index - The index to deselect.\n */\n deselectAt(index: number) {\n if (!this.isSelectedAt(index)) return\n this.setState({ selectedIndex: -1 })\n }\n\n /**\n * Deselects the currently selected index.\n */\n deselectCurrent() {\n this.setState({ selectedIndex: -1 })\n }\n}\n"]}
@@ -0,0 +1,59 @@
1
+ import React, { ComponentType, CSSProperties, PureComponent } from 'react';
2
+ import List, { ItemComponentProps as ListItemComponentProps } from './List';
3
+ import { ExtendedCSSFunction, Orientation } from './types';
4
+ export declare type ItemComponentProps<T = Record<string, never>> = ListItemComponentProps<T>;
5
+ export declare type SectionHeaderCSSProps = Readonly<{
6
+ borderColor: string;
7
+ borderThickness: number;
8
+ isCollapsed: boolean;
9
+ orientation: Orientation;
10
+ }>;
11
+ export declare type SectionCSSProps = Readonly<{
12
+ isCollapsed: boolean;
13
+ orientation: Orientation;
14
+ }>;
15
+ export interface SectionProps<T = Record<string, never>> {
16
+ label: string;
17
+ items: T[];
18
+ }
19
+ export interface Props<T = Record<string, never>> {
20
+ className?: string;
21
+ style?: CSSProperties;
22
+ data: SectionProps<T>[];
23
+ isTogglable?: boolean;
24
+ defaultSelectedSectionIndex?: number;
25
+ itemLength?: number;
26
+ itemPadding?: number;
27
+ sectionPadding?: number;
28
+ maxVisibleItems?: number;
29
+ orientation?: Orientation;
30
+ borderColor?: string;
31
+ borderThickness?: number;
32
+ expandIconSvg?: string;
33
+ itemComponentType: ComponentType<ItemComponentProps<T>>;
34
+ onItemIndexChange?: (index: number) => void;
35
+ onSectionIndexChange?: (index: number) => void;
36
+ sectionCSS?: ExtendedCSSFunction<SectionCSSProps>;
37
+ sectionHeaderCSS?: ExtendedCSSFunction<SectionHeaderCSSProps>;
38
+ }
39
+ export interface State {
40
+ selectedSectionIndex: number;
41
+ selectedItemIndex: number;
42
+ }
43
+ export default class Accordion<T = Record<string, never>> extends PureComponent<Props<T>, State> {
44
+ nodeRefs: {
45
+ lists: React.RefObject<List<T>>[];
46
+ };
47
+ constructor(props: Props<T>);
48
+ componentDidMount(): void;
49
+ componentDidUpdate(prevProps: Props<T>, prevState: State): void;
50
+ render(): JSX.Element;
51
+ private isSectionSelectedAt;
52
+ private toggleSectionAt;
53
+ private selectSectionAt;
54
+ private deselectSectionAt;
55
+ private isItemSelectedAt;
56
+ private toggleItemAt;
57
+ private selectItemAt;
58
+ private deselectItemAt;
59
+ }
package/lib/Accordion.js CHANGED
@@ -89,11 +89,11 @@ var Accordion = (function (_super) {
89
89
  Accordion.prototype.componentDidUpdate = function (prevProps, prevState) {
90
90
  var _a, _b, _c, _d;
91
91
  if (prevState.selectedSectionIndex !== this.state.selectedSectionIndex) {
92
- debug("Changing section index to " + this.state.selectedSectionIndex + "... OK");
92
+ debug("Changing section index to ".concat(this.state.selectedSectionIndex, "... OK"));
93
93
  (_b = (_a = this.props).onSectionIndexChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.state.selectedSectionIndex);
94
94
  }
95
95
  if (prevState.selectedItemIndex !== this.state.selectedItemIndex) {
96
- debug("Changing item index to " + this.state.selectedItemIndex + "... OK");
96
+ debug("Changing item index to ".concat(this.state.selectedItemIndex, "... OK"));
97
97
  (_d = (_c = this.props).onItemIndexChange) === null || _d === void 0 ? void 0 : _d.call(_c, this.state.selectedItemIndex);
98
98
  }
99
99
  };
@@ -121,26 +121,26 @@ var Accordion = (function (_super) {
121
121
  var isCollapsed = !_this.isSectionSelectedAt(i);
122
122
  var ref = (0, react_1.createRef)();
123
123
  _this.nodeRefs.lists.push(ref);
124
- return (react_1.default.createElement(StyledSection, { key: "section-" + i, isCollapsed: isCollapsed, orientation: orientation, extendedCSS: (_a = _this.props.sectionCSS) !== null && _a !== void 0 ? _a : (function () { return (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))); }), style: orientation === 'vertical' ? {
125
- marginTop: i === 0 ? '0px' : sectionPadding - borderThickness + "px",
124
+ return (react_1.default.createElement(StyledSection, { key: "section-".concat(i), isCollapsed: isCollapsed, orientation: orientation, extendedCSS: (_a = _this.props.sectionCSS) !== null && _a !== void 0 ? _a : (function () { return (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""]))); }), style: orientation === 'vertical' ? {
125
+ marginTop: i === 0 ? '0px' : "".concat(sectionPadding - borderThickness, "px"),
126
126
  } : {
127
- marginLeft: i === 0 ? '0px' : sectionPadding - borderThickness + "px",
127
+ marginLeft: i === 0 ? '0px' : "".concat(sectionPadding - borderThickness, "px"),
128
128
  } },
129
129
  react_1.default.createElement(StyledSectionHeader, { borderColor: borderColor, borderThickness: borderThickness, orientation: orientation, isCollapsed: isCollapsed, onClick: function () { return _this.toggleSectionAt(i); }, extendedCSS: (_b = _this.props.sectionHeaderCSS) !== null && _b !== void 0 ? _b : (function () { return (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""]))); }) },
130
130
  react_1.default.createElement("label", null, section.label),
131
131
  _this.props.expandIconSvg && react_1.default.createElement("span", { dangerouslySetInnerHTML: { __html: _this.props.expandIconSvg } })),
132
132
  react_1.default.createElement(StyledItemList, { ref: ref, borderColor: borderColor, borderThickness: borderThickness, data: section.items, defaultSelectedIndex: -1, isTogglable: isTogglable, itemComponentType: _this.props.itemComponentType, itemPadding: itemPadding, onDeselectAt: function (idx) { return _this.deselectItemAt(idx); }, onSelectAt: function (idx) { return _this.selectItemAt(idx); }, orientation: orientation, shouldStaySelected: true, itemStyle: orientation === 'vertical' ? {
133
- height: itemLength + "px",
133
+ height: "".concat(itemLength, "px"),
134
134
  } : {
135
- width: itemLength + "px",
135
+ width: "".concat(itemLength, "px"),
136
136
  }, style: orientation === 'vertical' ? {
137
- height: isCollapsed ? '0px' : menuLength + "px",
138
- marginTop: isCollapsed ? '0px' : itemPadding - borderThickness + "px",
137
+ height: isCollapsed ? '0px' : "".concat(menuLength, "px"),
138
+ marginTop: isCollapsed ? '0px' : "".concat(itemPadding - borderThickness, "px"),
139
139
  overflowY: (maxVisibleItems === -1) ? 'hidden' : (maxVisibleItems < numItems ? 'scroll' : 'hidden'),
140
140
  } : {
141
- marginLeft: isCollapsed ? '0px' : itemPadding - borderThickness + "px",
141
+ marginLeft: isCollapsed ? '0px' : "".concat(itemPadding - borderThickness, "px"),
142
142
  overflowX: (maxVisibleItems === -1) ? 'hidden' : (maxVisibleItems < numItems ? 'scroll' : 'hidden'),
143
- width: isCollapsed ? '0px' : menuLength + "px",
143
+ width: isCollapsed ? '0px' : "".concat(menuLength, "px"),
144
144
  } })));
145
145
  })));
146
146
  };
@@ -1 +1 @@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AAC,uBAAG,2HAAA,uDAG9C,KAAC,CAAC,KAAC,uBAAG,yHAAA,mDAGR,IAAA,EANU,CAMV,EAEC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,EAAxB,CAAwB,CACpC,CAAA;AAED,IAAM,UAAU,GAAG,2BAAM,CAAC,GAAG,iPAE3B,sKASE,EAID,IACF,KALG,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,WAAW,KAAK,UAAU,CAAC,CAAC,KAAC,uBAAG,2GAAA,qCAE9C,KAAC,CAAC,KAAC,uBAAG,sGAAA,gCAER,IAAA,EAJU,CAIV,CACF,CAAA","sourcesContent":["import React, { ComponentType, createRef, CSSProperties, PureComponent, RefObject } from 'react'\nimport styled, { css } from 'styled-components'\nimport List, { ItemComponentProps as ListItemComponentProps } from './List'\nimport { ExtendedCSSFunction, ExtendedCSSProps, Orientation } from './types'\n\nconst debug = process.env.NODE_ENV === 'development' ? require('debug')('etudes:accordion') : () => {}\n\n/**\n * Interface defining the props of the item component type to be provided to the\n * component. The data type is generic.\n */\nexport type ItemComponentProps<T = Record<string, never>> = ListItemComponentProps<T>\n\nexport type SectionHeaderCSSProps = Readonly<{\n borderColor: string\n borderThickness: number\n isCollapsed: boolean\n orientation: Orientation\n}>\n\nexport type SectionCSSProps = Readonly<{\n isCollapsed: boolean\n orientation: Orientation\n}>\n\nexport interface SectionProps<T = Record<string, never>> {\n label: string\n items: T[]\n}\n\nexport interface Props<T = Record<string, never>> {\n /**\n * Class attribute to the root element.\n */\n className?: string\n\n /**\n * Inline style attribute to the element.\n */\n style?: CSSProperties\n\n /**\n * Data provided to each section.\n */\n data: SectionProps<T>[]\n\n /**\n * Indicates if sections can be toggled, as in, once a section is expanded,\n * it collapses when being selected again.\n */\n isTogglable?: boolean\n\n /**\n * Index of the section that is selected by default. Any value less than 0\n * indicates that no section is selected by default.\n */\n defaultSelectedSectionIndex?: number\n\n /**\n * Length (in pixels) of each item. This does not apply to the section hedaer\n * itself. Length refers to the height in vertical orientation and width in\n * horizontal orientation.\n */\n itemLength?: number\n\n /**\n * Padding (in pixels) between each item.\n */\n itemPadding?: number\n\n /**\n * Padding (in pixels) between each section.\n */\n sectionPadding?: number\n\n /**\n * Maximum number of items that are viside when a section expands. When a\n * value greater than or equal to 0 is specified, only that number of items\n * will be visible at a time, and a scrollbar will appear to scroll to\n * remaining items. Any value less than 0 indicates that all items will be\n * visible when a section expands.\n */\n maxVisibleItems?: number\n\n /**\n * Orientation of the component.\n */\n orientation?: Orientation\n\n /**\n * Color of the border of every item and the section header itself.\n */\n borderColor?: string\n\n /**\n * Thickness of the border (in pixels) of every item and the section header\n * itself. 0 indicates no borders.\n */\n borderThickness?: number\n\n /**\n * SVG markup to be put in the section header as the expand icon.\n */\n expandIconSvg?: string\n\n /**\n * React component type to be used for generating items inside the component.\n */\n itemComponentType: ComponentType<ItemComponentProps<T>>\n\n /**\n * Handler invoked when the selected item index of any section changes.\n */\n onItemIndexChange?: (index: number) => void\n\n /**\n * Handler invoked when the selected section index changes.\n */\n onSectionIndexChange?: (index: number) => void\n\n /**\n * Additional CSS to be provided to each section element.\n */\n sectionCSS?: ExtendedCSSFunction<SectionCSSProps>\n\n /**\n * Additional CSS to be provided to each section header element.\n */\n sectionHeaderCSS?: ExtendedCSSFunction<SectionHeaderCSSProps>\n}\n\nexport interface State {\n /**\n * Current selected section index.\n */\n selectedSectionIndex: number\n\n /**\n * Current selected item index of the expanded section.\n */\n selectedItemIndex: number\n}\n\nexport default class Accordion<T = Record<string, never>> extends PureComponent<Props<T>, State> {\n nodeRefs = {\n lists: [] as RefObject<List<T>>[],\n }\n\n constructor(props: Props<T>) {\n super(props)\n\n this.state = {\n selectedSectionIndex: props.defaultSelectedSectionIndex ?? -1,\n selectedItemIndex: -1,\n }\n }\n\n componentDidMount() {\n this.props.onSectionIndexChange?.(this.state.selectedSectionIndex)\n this.props.onItemIndexChange?.(this.state.selectedItemIndex)\n }\n\n componentDidUpdate(prevProps: Props<T>, prevState: State) {\n if (prevState.selectedSectionIndex !== this.state.selectedSectionIndex) {\n debug(`Changing section index to ${this.state.selectedSectionIndex}... OK`)\n this.props.onSectionIndexChange?.(this.state.selectedSectionIndex)\n }\n\n if (prevState.selectedItemIndex !== this.state.selectedItemIndex) {\n debug(`Changing item index to ${this.state.selectedItemIndex}... OK`)\n this.props.onItemIndexChange?.(this.state.selectedItemIndex)\n }\n }\n\n render() {\n const borderColor = this.props.borderColor ?? '#000'\n const borderThickness = this.props.borderThickness ?? 0\n const isTogglable = this.props.isTogglable ?? true\n const itemLength = this.props.itemLength ?? 50\n const itemPadding = this.props.itemPadding ?? 0\n const sectionPadding = this.props.sectionPadding ?? 0\n const maxVisibleItems = this.props.maxVisibleItems ?? -1\n const orientation = this.props.orientation ?? 'vertical'\n\n this.nodeRefs.lists = []\n\n return (\n <StyledRoot\n className={this.props.className}\n orientation={orientation}\n style={{\n ...this.props.style ?? {},\n ...(orientation === 'vertical' ? {\n height: 'auto',\n } : {\n width: 'auto',\n }),\n }}\n >\n {this.props.data.map((section, i) => {\n const numItems = section.items.length\n const numVisibleItems = maxVisibleItems < 0 ? numItems : Math.min(numItems, maxVisibleItems)\n const menuLength = (itemLength - borderThickness) * numVisibleItems + itemPadding * (numVisibleItems - 1) + borderThickness\n const isCollapsed = !this.isSectionSelectedAt(i)\n const ref = createRef<List<T>>()\n\n this.nodeRefs.lists.push(ref)\n\n return (\n <StyledSection\n key={`section-${i}`}\n isCollapsed={isCollapsed}\n orientation={orientation}\n extendedCSS={this.props.sectionCSS ?? (() => css``)}\n style={orientation === 'vertical' ? {\n marginTop: i === 0 ? '0px' : `${sectionPadding - borderThickness}px`,\n } : {\n marginLeft: i === 0 ? '0px' : `${sectionPadding - borderThickness}px`,\n }}\n >\n <StyledSectionHeader\n borderColor={borderColor}\n borderThickness={borderThickness}\n orientation={orientation}\n isCollapsed={isCollapsed}\n onClick={() => this.toggleSectionAt(i) }\n extendedCSS={this.props.sectionHeaderCSS ?? (() => css``)}\n >\n <label>{section.label}</label>\n {this.props.expandIconSvg && <span dangerouslySetInnerHTML={{ __html: this.props.expandIconSvg }}/>}\n </StyledSectionHeader>\n <StyledItemList\n ref={ref as any}\n borderColor={borderColor}\n borderThickness={borderThickness}\n data={section.items}\n defaultSelectedIndex={-1}\n isTogglable={isTogglable}\n itemComponentType={this.props.itemComponentType as any}\n itemPadding={itemPadding}\n onDeselectAt={idx => this.deselectItemAt(idx)}\n onSelectAt={idx => this.selectItemAt(idx)}\n orientation={orientation}\n shouldStaySelected={true}\n itemStyle={orientation === 'vertical' ? {\n height: `${itemLength}px`,\n } : {\n width: `${itemLength}px`,\n }}\n style={orientation === 'vertical' ? {\n height: isCollapsed ? '0px' : `${menuLength}px`,\n marginTop: isCollapsed ? '0px' : `${itemPadding - borderThickness}px`,\n overflowY: (maxVisibleItems === -1) ? 'hidden' : (maxVisibleItems < numItems ? 'scroll' : 'hidden'),\n } : {\n marginLeft: isCollapsed ? '0px' : `${itemPadding - borderThickness}px`,\n overflowX: (maxVisibleItems === -1) ? 'hidden' : (maxVisibleItems < numItems ? 'scroll' : 'hidden'),\n width: isCollapsed ? '0px' : `${menuLength}px`,\n }}\n />\n </StyledSection>\n )\n })}\n </StyledRoot>\n )\n }\n\n private isSectionSelectedAt(index: number): boolean {\n return this.state.selectedSectionIndex === index\n }\n\n private toggleSectionAt(index: number) {\n if ((this.props.isTogglable ?? true) && this.isSectionSelectedAt(index)) {\n this.deselectSectionAt(index)\n }\n else {\n this.selectSectionAt(index)\n }\n }\n\n private selectSectionAt(index: number) {\n if (this.isSectionSelectedAt(index)) return\n\n for (const ref of this.nodeRefs.lists) {\n ref.current?.setState({ selectedIndex: -1 })\n }\n\n this.setState({\n selectedSectionIndex: index,\n })\n }\n\n private deselectSectionAt(index: number) {\n if (!this.isSectionSelectedAt(index)) return\n\n for (const ref of this.nodeRefs.lists) {\n ref.current?.setState({ selectedIndex: -1 })\n }\n\n this.setState({\n selectedSectionIndex: -1,\n })\n }\n\n private isItemSelectedAt(index: number): boolean {\n return (this.state.selectedItemIndex === index)\n }\n\n private toggleItemAt(index: number) {\n if ((this.props.isTogglable ?? true) && this.isItemSelectedAt(index)) {\n this.deselectItemAt(index)\n }\n else {\n this.selectItemAt(index)\n }\n }\n\n private selectItemAt(index: number) {\n if (this.isItemSelectedAt(index)) return\n\n this.setState({\n selectedItemIndex: index,\n })\n }\n\n private deselectItemAt(index: number) {\n if (!this.isItemSelectedAt(index)) return\n\n this.setState({\n selectedItemIndex: -1,\n })\n }\n}\n\nconst StyledItemList = styled(List)<{\n itemPadding: number\n borderThickness: number\n orientation: Orientation\n}>`\n transition-duration: 100ms;\n transition-timing-function: ease-out;\n\n ${props => props.orientation === 'vertical' ? css`\n width: 100%;\n transition-property: height, margin;\n will-change: height, margin;\n top: 100%;\n ` : css`\n height: 100%;\n transition-property: width, margin;\n will-change: width, margin;\n left: 100%;\n `}\n`\n\nconst StyledSectionHeader = styled.button<SectionHeaderCSSProps & ExtendedCSSProps<SectionHeaderCSSProps>>`\n align-items: center;\n background: #fff;\n border-color: ${props => props.borderColor};\n border-style: solid;\n border-width: ${props => props.borderThickness};\n box-sizing: border-box;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n margin: 0;\n padding: 0 10px;\n transition-duration: 100ms;\n transition-property: transform, opacity, background, color;\n transition-timing-function: ease-out;\n will-change: transform, opacity, background, color;\n\n label {\n color: #000;\n transition-duration: 100ms;\n transition-property: color;\n transition-timing-function: ease-out;\n will-change: color;\n }\n\n span {\n box-sizing: border-box;\n display: block;\n fill: #000;\n height: 15px;\n transform-origin: center;\n transition-duration: 100ms;\n transition-property: transform;\n transition-timing-function: ease-out;\n width: 15px;\n will-change: transform;\n\n svg {\n width: 100%;\n height: 100%;\n fill: inherit;\n\n * {\n fill: inherit;\n transition-duration: 100ms;\n transition-property: fill;\n transition-timing-function: ease-out;\n }\n }\n }\n\n ${props => props.orientation === 'vertical' ? css`\n height: 50px;\n width: 100%;\n ` : css`\n height: 100%;\n width: 50px;\n `}\n\n ${props => props.extendedCSS(props)}\n`\n\nconst StyledSection = styled.section<SectionCSSProps & ExtendedCSSProps<SectionCSSProps>>`\n align-items: flex-start;\n box-sizing: border-box;\n display: flex;\n flex: 0 0 auto;\n justify-content: flex-start;\n margin: 0;\n padding: 0;\n position: relative;\n\n ${props => props.orientation === 'vertical' ? css`\n width: 100%;\n flex-direction: column;\n ` : css`\n height: 100%;\n flex-direction: row;\n `}\n\n ${props => props.extendedCSS(props)}\n`\n\nconst StyledRoot = styled.div<{\n orientation: Orientation\n}>`\n align-items: center;\n box-sizing: border-box;\n display: flex;\n flex: 0 0 auto;\n justify-content: flex-start;\n padding: 0;\n position: relative;\n\n ${props => props.orientation === 'vertical' ? css`\n flex-direction: column;\n ` : css`\n flex-direction: row;\n `}\n`\n"]}
1
+ {"version":3,"file":"Accordion.js","sourceRoot":"/","sources":["Accordion.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAgG;AAChG,qEAA+C;AAC/C,gDAA2E;AAG3E,IAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,cAAO,CAAC,CAAA;AA0ItG;IAAkE,6BAA8B;IAK9F,mBAAY,KAAe;;QAA3B,YACE,kBAAM,KAAK,CAAC,SAMb;QAXD,cAAQ,GAAG;YACT,KAAK,EAAE,EAA0B;SAClC,CAAA;QAKC,KAAI,CAAC,KAAK,GAAG;YACX,oBAAoB,EAAE,MAAA,KAAK,CAAC,2BAA2B,mCAAI,CAAC,CAAC;YAC7D,iBAAiB,EAAE,CAAC,CAAC;SACtB,CAAA;;IACH,CAAC;IAED,qCAAiB,GAAjB;;QACE,MAAA,MAAA,IAAI,CAAC,KAAK,EAAC,oBA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,0hCA8C5C,EAMD,QAEC,EAAiC,IACpC,KAzDiB,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,WAAW,EAAjB,CAAiB,EAE1B,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,eAAe,EAArB,CAAqB,EA8C5C,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,WAAW,KAAK,UAAU,CAAC,CAAC,KAAC,uBAAG,iHAAA,6CAG9C,KAAC,CAAC,KAAC,uBAAG,+GAAA,2CAGR,IAAA,EANU,CAMV,EAEC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,EAAxB,CAAwB,CACpC,CAAA;AAED,IAAM,aAAa,GAAG,2BAAM,CAAC,OAAO,6QAAqD,wLAUrF,EAMD,QAEC,EAAiC,IACpC,KATG,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,WAAW,KAAK,UAAU,CAAC,CAAC,KAAC,uBAAG,2HAAA,uDAG9C,KAAC,CAAC,KAAC,uBAAG,yHAAA,mDAGR,IAAA,EANU,CAMV,EAEC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,EAAxB,CAAwB,CACpC,CAAA;AAED,IAAM,UAAU,GAAG,2BAAM,CAAC,GAAG,iPAE3B,sKASE,EAID,IACF,KALG,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,WAAW,KAAK,UAAU,CAAC,CAAC,KAAC,uBAAG,2GAAA,qCAE9C,KAAC,CAAC,KAAC,uBAAG,sGAAA,gCAER,IAAA,EAJU,CAIV,CACF,CAAA","sourcesContent":["import React, { ComponentType, createRef, CSSProperties, PureComponent, RefObject } from 'react'\nimport styled, { css } from 'styled-components'\nimport List, { ItemComponentProps as ListItemComponentProps } from './List'\nimport { ExtendedCSSFunction, ExtendedCSSProps, Orientation } from './types'\n\nconst debug = process.env.NODE_ENV === 'development' ? require('debug')('etudes:accordion') : () => {}\n\n/**\n * Interface defining the props of the item component type to be provided to the\n * component. The data type is generic.\n */\nexport type ItemComponentProps<T = Record<string, never>> = ListItemComponentProps<T>\n\nexport type SectionHeaderCSSProps = Readonly<{\n borderColor: string\n borderThickness: number\n isCollapsed: boolean\n orientation: Orientation\n}>\n\nexport type SectionCSSProps = Readonly<{\n isCollapsed: boolean\n orientation: Orientation\n}>\n\nexport interface SectionProps<T = Record<string, never>> {\n label: string\n items: T[]\n}\n\nexport interface Props<T = Record<string, never>> {\n /**\n * Class attribute to the root element.\n */\n className?: string\n\n /**\n * Inline style attribute to the element.\n */\n style?: CSSProperties\n\n /**\n * Data provided to each section.\n */\n data: SectionProps<T>[]\n\n /**\n * Indicates if sections can be toggled, as in, once a section is expanded,\n * it collapses when being selected again.\n */\n isTogglable?: boolean\n\n /**\n * Index of the section that is selected by default. Any value less than 0\n * indicates that no section is selected by default.\n */\n defaultSelectedSectionIndex?: number\n\n /**\n * Length (in pixels) of each item. This does not apply to the section hedaer\n * itself. Length refers to the height in vertical orientation and width in\n * horizontal orientation.\n */\n itemLength?: number\n\n /**\n * Padding (in pixels) between each item.\n */\n itemPadding?: number\n\n /**\n * Padding (in pixels) between each section.\n */\n sectionPadding?: number\n\n /**\n * Maximum number of items that are viside when a section expands. When a\n * value greater than or equal to 0 is specified, only that number of items\n * will be visible at a time, and a scrollbar will appear to scroll to\n * remaining items. Any value less than 0 indicates that all items will be\n * visible when a section expands.\n */\n maxVisibleItems?: number\n\n /**\n * Orientation of the component.\n */\n orientation?: Orientation\n\n /**\n * Color of the border of every item and the section header itself.\n */\n borderColor?: string\n\n /**\n * Thickness of the border (in pixels) of every item and the section header\n * itself. 0 indicates no borders.\n */\n borderThickness?: number\n\n /**\n * SVG markup to be put in the section header as the expand icon.\n */\n expandIconSvg?: string\n\n /**\n * React component type to be used for generating items inside the component.\n */\n itemComponentType: ComponentType<ItemComponentProps<T>>\n\n /**\n * Handler invoked when the selected item index of any section changes.\n */\n onItemIndexChange?: (index: number) => void\n\n /**\n * Handler invoked when the selected section index changes.\n */\n onSectionIndexChange?: (index: number) => void\n\n /**\n * Additional CSS to be provided to each section element.\n */\n sectionCSS?: ExtendedCSSFunction<SectionCSSProps>\n\n /**\n * Additional CSS to be provided to each section header element.\n */\n sectionHeaderCSS?: ExtendedCSSFunction<SectionHeaderCSSProps>\n}\n\nexport interface State {\n /**\n * Current selected section index.\n */\n selectedSectionIndex: number\n\n /**\n * Current selected item index of the expanded section.\n */\n selectedItemIndex: number\n}\n\nexport default class Accordion<T = Record<string, never>> extends PureComponent<Props<T>, State> {\n nodeRefs = {\n lists: [] as RefObject<List<T>>[],\n }\n\n constructor(props: Props<T>) {\n super(props)\n\n this.state = {\n selectedSectionIndex: props.defaultSelectedSectionIndex ?? -1,\n selectedItemIndex: -1,\n }\n }\n\n componentDidMount() {\n this.props.onSectionIndexChange?.(this.state.selectedSectionIndex)\n this.props.onItemIndexChange?.(this.state.selectedItemIndex)\n }\n\n componentDidUpdate(prevProps: Props<T>, prevState: State) {\n if (prevState.selectedSectionIndex !== this.state.selectedSectionIndex) {\n debug(`Changing section index to ${this.state.selectedSectionIndex}... OK`)\n this.props.onSectionIndexChange?.(this.state.selectedSectionIndex)\n }\n\n if (prevState.selectedItemIndex !== this.state.selectedItemIndex) {\n debug(`Changing item index to ${this.state.selectedItemIndex}... OK`)\n this.props.onItemIndexChange?.(this.state.selectedItemIndex)\n }\n }\n\n render() {\n const borderColor = this.props.borderColor ?? '#000'\n const borderThickness = this.props.borderThickness ?? 0\n const isTogglable = this.props.isTogglable ?? true\n const itemLength = this.props.itemLength ?? 50\n const itemPadding = this.props.itemPadding ?? 0\n const sectionPadding = this.props.sectionPadding ?? 0\n const maxVisibleItems = this.props.maxVisibleItems ?? -1\n const orientation = this.props.orientation ?? 'vertical'\n\n this.nodeRefs.lists = []\n\n return (\n <StyledRoot\n className={this.props.className}\n orientation={orientation}\n style={{\n ...this.props.style ?? {},\n ...(orientation === 'vertical' ? {\n height: 'auto',\n } : {\n width: 'auto',\n }),\n }}\n >\n {this.props.data.map((section, i) => {\n const numItems = section.items.length\n const numVisibleItems = maxVisibleItems < 0 ? numItems : Math.min(numItems, maxVisibleItems)\n const menuLength = (itemLength - borderThickness) * numVisibleItems + itemPadding * (numVisibleItems - 1) + borderThickness\n const isCollapsed = !this.isSectionSelectedAt(i)\n const ref = createRef<List<T>>()\n\n this.nodeRefs.lists.push(ref)\n\n return (\n <StyledSection\n key={`section-${i}`}\n isCollapsed={isCollapsed}\n orientation={orientation}\n extendedCSS={this.props.sectionCSS ?? (() => css``)}\n style={orientation === 'vertical' ? {\n marginTop: i === 0 ? '0px' : `${sectionPadding - borderThickness}px`,\n } : {\n marginLeft: i === 0 ? '0px' : `${sectionPadding - borderThickness}px`,\n }}\n >\n <StyledSectionHeader\n borderColor={borderColor}\n borderThickness={borderThickness}\n orientation={orientation}\n isCollapsed={isCollapsed}\n onClick={() => this.toggleSectionAt(i) }\n extendedCSS={this.props.sectionHeaderCSS ?? (() => css``)}\n >\n <label>{section.label}</label>\n {this.props.expandIconSvg && <span dangerouslySetInnerHTML={{ __html: this.props.expandIconSvg }}/>}\n </StyledSectionHeader>\n <StyledItemList\n ref={ref as any}\n borderColor={borderColor}\n borderThickness={borderThickness}\n data={section.items}\n defaultSelectedIndex={-1}\n isTogglable={isTogglable}\n itemComponentType={this.props.itemComponentType as any}\n itemPadding={itemPadding}\n onDeselectAt={idx => this.deselectItemAt(idx)}\n onSelectAt={idx => this.selectItemAt(idx)}\n orientation={orientation}\n shouldStaySelected={true}\n itemStyle={orientation === 'vertical' ? {\n height: `${itemLength}px`,\n } : {\n width: `${itemLength}px`,\n }}\n style={orientation === 'vertical' ? {\n height: isCollapsed ? '0px' : `${menuLength}px`,\n marginTop: isCollapsed ? '0px' : `${itemPadding - borderThickness}px`,\n overflowY: (maxVisibleItems === -1) ? 'hidden' : (maxVisibleItems < numItems ? 'scroll' : 'hidden'),\n } : {\n marginLeft: isCollapsed ? '0px' : `${itemPadding - borderThickness}px`,\n overflowX: (maxVisibleItems === -1) ? 'hidden' : (maxVisibleItems < numItems ? 'scroll' : 'hidden'),\n width: isCollapsed ? '0px' : `${menuLength}px`,\n }}\n />\n </StyledSection>\n )\n })}\n </StyledRoot>\n )\n }\n\n private isSectionSelectedAt(index: number): boolean {\n return this.state.selectedSectionIndex === index\n }\n\n private toggleSectionAt(index: number) {\n if ((this.props.isTogglable ?? true) && this.isSectionSelectedAt(index)) {\n this.deselectSectionAt(index)\n }\n else {\n this.selectSectionAt(index)\n }\n }\n\n private selectSectionAt(index: number) {\n if (this.isSectionSelectedAt(index)) return\n\n for (const ref of this.nodeRefs.lists) {\n ref.current?.setState({ selectedIndex: -1 })\n }\n\n this.setState({\n selectedSectionIndex: index,\n })\n }\n\n private deselectSectionAt(index: number) {\n if (!this.isSectionSelectedAt(index)) return\n\n for (const ref of this.nodeRefs.lists) {\n ref.current?.setState({ selectedIndex: -1 })\n }\n\n this.setState({\n selectedSectionIndex: -1,\n })\n }\n\n private isItemSelectedAt(index: number): boolean {\n return (this.state.selectedItemIndex === index)\n }\n\n private toggleItemAt(index: number) {\n if ((this.props.isTogglable ?? true) && this.isItemSelectedAt(index)) {\n this.deselectItemAt(index)\n }\n else {\n this.selectItemAt(index)\n }\n }\n\n private selectItemAt(index: number) {\n if (this.isItemSelectedAt(index)) return\n\n this.setState({\n selectedItemIndex: index,\n })\n }\n\n private deselectItemAt(index: number) {\n if (!this.isItemSelectedAt(index)) return\n\n this.setState({\n selectedItemIndex: -1,\n })\n }\n}\n\nconst StyledItemList = styled(List)<{\n itemPadding: number\n borderThickness: number\n orientation: Orientation\n}>`\n transition-duration: 100ms;\n transition-timing-function: ease-out;\n\n ${props => props.orientation === 'vertical' ? css`\n width: 100%;\n transition-property: height, margin;\n will-change: height, margin;\n top: 100%;\n ` : css`\n height: 100%;\n transition-property: width, margin;\n will-change: width, margin;\n left: 100%;\n `}\n`\n\nconst StyledSectionHeader = styled.button<SectionHeaderCSSProps & ExtendedCSSProps<SectionHeaderCSSProps>>`\n align-items: center;\n background: #fff;\n border-color: ${props => props.borderColor};\n border-style: solid;\n border-width: ${props => props.borderThickness};\n box-sizing: border-box;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n margin: 0;\n padding: 0 10px;\n transition-duration: 100ms;\n transition-property: transform, opacity, background, color;\n transition-timing-function: ease-out;\n will-change: transform, opacity, background, color;\n\n label {\n color: #000;\n transition-duration: 100ms;\n transition-property: color;\n transition-timing-function: ease-out;\n will-change: color;\n }\n\n span {\n box-sizing: border-box;\n display: block;\n fill: #000;\n height: 15px;\n transform-origin: center;\n transition-duration: 100ms;\n transition-property: transform;\n transition-timing-function: ease-out;\n width: 15px;\n will-change: transform;\n\n svg {\n width: 100%;\n height: 100%;\n fill: inherit;\n\n * {\n fill: inherit;\n transition-duration: 100ms;\n transition-property: fill;\n transition-timing-function: ease-out;\n }\n }\n }\n\n ${props => props.orientation === 'vertical' ? css`\n height: 50px;\n width: 100%;\n ` : css`\n height: 100%;\n width: 50px;\n `}\n\n ${props => props.extendedCSS(props)}\n`\n\nconst StyledSection = styled.section<SectionCSSProps & ExtendedCSSProps<SectionCSSProps>>`\n align-items: flex-start;\n box-sizing: border-box;\n display: flex;\n flex: 0 0 auto;\n justify-content: flex-start;\n margin: 0;\n padding: 0;\n position: relative;\n\n ${props => props.orientation === 'vertical' ? css`\n width: 100%;\n flex-direction: column;\n ` : css`\n height: 100%;\n flex-direction: row;\n `}\n\n ${props => props.extendedCSS(props)}\n`\n\nconst StyledRoot = styled.div<{\n orientation: Orientation\n}>`\n align-items: center;\n box-sizing: border-box;\n display: flex;\n flex: 0 0 auto;\n justify-content: flex-start;\n padding: 0;\n position: relative;\n\n ${props => props.orientation === 'vertical' ? css`\n flex-direction: column;\n ` : css`\n flex-direction: row;\n `}\n`\n"]}
@@ -0,0 +1,37 @@
1
+ import { CSSProperties, PureComponent } from 'react';
2
+ export interface Props {
3
+ className?: string;
4
+ style: CSSProperties;
5
+ isActiveByDefault: boolean;
6
+ isDoubleJointed: boolean;
7
+ isFunky: boolean;
8
+ height: number;
9
+ thickness: number;
10
+ width: number;
11
+ tintColor: string;
12
+ transitionDuration: number;
13
+ onActivate?: () => void;
14
+ onDeactivate?: () => void;
15
+ }
16
+ export interface State {
17
+ isActive: boolean;
18
+ }
19
+ declare class BurgerButton extends PureComponent<Props, State> {
20
+ static defaultProps: {
21
+ height: number;
22
+ isActiveByDefault: boolean;
23
+ isDoubleJointed: boolean;
24
+ isFunky: boolean;
25
+ style: {};
26
+ thickness: number;
27
+ tintColor: string;
28
+ transitionDuration: number;
29
+ width: number;
30
+ };
31
+ constructor(props: Props);
32
+ toggle(): void;
33
+ activate(): void;
34
+ deactivate(): void;
35
+ render(): JSX.Element;
36
+ }
37
+ export default BurgerButton;
@@ -107,7 +107,7 @@ var BurgerButton = (function (_super) {
107
107
  var d = 45;
108
108
  var r = d * Math.PI / 180;
109
109
  var n = this.props.isDoubleJointed ? 2 : 1;
110
- return (react_1.default.createElement(StyledRoot, { className: this.props.className, height: this.props.height, isActive: this.state.isActive, isDoubleJointed: this.props.isDoubleJointed, isFunky: this.props.isFunky, onClick: function () { return _this.toggle(); }, style: this.props.style, thickness: this.props.thickness, tintColor: this.props.tintColor, transitionDuration: this.props.transitionDuration, width: this.props.width, w: w, h: h, t: t, d: d, r: r }, this.props.isDoubleJointed && (react_1.default.createElement(react_1.Fragment, null, __spreadArray([], __read(new Array(n)), false).map(function (v, i) { return (react_1.default.createElement("div", { key: "joint-" + i },
110
+ return (react_1.default.createElement(StyledRoot, { className: this.props.className, height: this.props.height, isActive: this.state.isActive, isDoubleJointed: this.props.isDoubleJointed, isFunky: this.props.isFunky, onClick: function () { return _this.toggle(); }, style: this.props.style, thickness: this.props.thickness, tintColor: this.props.tintColor, transitionDuration: this.props.transitionDuration, width: this.props.width, w: w, h: h, t: t, d: d, r: r }, this.props.isDoubleJointed && (react_1.default.createElement(react_1.Fragment, null, __spreadArray([], __read(new Array(n)), false).map(function (v, i) { return (react_1.default.createElement("div", { key: "joint-".concat(i) },
111
111
  react_1.default.createElement("span", null),
112
112
  react_1.default.createElement("span", null),
113
113
  react_1.default.createElement("span", null))); })))));
@@ -126,6 +126,6 @@ var BurgerButton = (function (_super) {
126
126
  return BurgerButton;
127
127
  }(react_1.PureComponent));
128
128
  exports.default = BurgerButton;
129
- var StyledRoot = styled_components_1.default.button(templateObject_1 || (templateObject_1 = __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 > div:only-of-type {\n width: 100%;\n height: 100%;\n\n span:nth-child(1) {\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n transform: ", ";\n }\n\n span:nth-child(2) {\n left: 0;\n position: absolute;\n top: ", "px;\n transform-origin: center;\n transform: ", ";\n }\n\n span:nth-child(3) {\n top: ", ";\n left: 0;\n position: absolute;\n transform-origin: center;\n transform: ", ";\n width: ", ";\n }\n }\n\n > div:not(:only-of-type) {\n height: 100%;\n width: 50%;\n\n &:nth-of-type(1) {\n left: 0;\n top: 0;\n position: absolute;\n\n span:nth-child(1) {\n top: 0;\n left: 0;\n transform-origin: right center;\n transform: ", ";\n }\n\n span:nth-child(2) {\n left: 0;\n top: ", "px;\n transform: ", ";\n transform-origin: right center;\n }\n\n span:nth-child(3) {\n top: ", "px;\n left: 0;\n width: 100%;\n transform-origin: right center;\n transform: ", ";\n }\n }\n\n &:nth-of-type(2) {\n right: 0;\n top: 0;\n position: absolute;\n\n span:nth-child(1) {\n top: 0;\n left: 0;\n transform-origin: left center;\n transform: ", ";\n }\n\n span:nth-child(2) {\n left: 0;\n top: ", "px;\n transform: ", ";\n transform-origin: left center;\n }\n\n span:nth-child(3) {\n transform-origin: left center;\n transform: ", ";\n width: ", ";\n left: 0;\n top: ", "px;\n }\n }\n }\n\n span {\n background: ", ";\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n position: absolute;\n width: 100%;\n height: ", "px;\n transition-duration: ", "ms;\n transition-property: width, height, transform, opacity, background;\n transition-timing-function: ease-out;\n }\n\n &:hover {\n div:not(:only-of-type):nth-of-type(2)::after {\n height: ", "px;\n width: ", "px;\n }\n\n div:only-of-type span:nth-child(3) {\n height: ", "px;\n width: ", "px;\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 > div:only-of-type {\n width: 100%;\n height: 100%;\n\n span:nth-child(1) {\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n transform: ", ";\n }\n\n span:nth-child(2) {\n left: 0;\n position: absolute;\n top: ", "px;\n transform-origin: center;\n transform: ", ";\n }\n\n span:nth-child(3) {\n top: ", ";\n left: 0;\n position: absolute;\n transform-origin: center;\n transform: ", ";\n width: ", ";\n }\n }\n\n > div:not(:only-of-type) {\n height: 100%;\n width: 50%;\n\n &:nth-of-type(1) {\n left: 0;\n top: 0;\n position: absolute;\n\n span:nth-child(1) {\n top: 0;\n left: 0;\n transform-origin: right center;\n transform: ", ";\n }\n\n span:nth-child(2) {\n left: 0;\n top: ", "px;\n transform: ", ";\n transform-origin: right center;\n }\n\n span:nth-child(3) {\n top: ", "px;\n left: 0;\n width: 100%;\n transform-origin: right center;\n transform: ", ";\n }\n }\n\n &:nth-of-type(2) {\n right: 0;\n top: 0;\n position: absolute;\n\n span:nth-child(1) {\n top: 0;\n left: 0;\n transform-origin: left center;\n transform: ", ";\n }\n\n span:nth-child(2) {\n left: 0;\n top: ", "px;\n transform: ", ";\n transform-origin: left center;\n }\n\n span:nth-child(3) {\n transform-origin: left center;\n transform: ", ";\n width: ", ";\n left: 0;\n top: ", "px;\n }\n }\n }\n\n span {\n background: ", ";\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n position: absolute;\n width: 100%;\n height: ", "px;\n transition-duration: ", "ms;\n transition-property: width, height, transform, opacity, background;\n transition-timing-function: ease-out;\n }\n\n &:hover {\n div:not(:only-of-type):nth-of-type(2)::after {\n height: ", "px;\n width: ", "px;\n }\n\n div:only-of-type span:nth-child(3) {\n height: ", "px;\n width: ", "px;\n }\n }\n"])), function (props) { return props.height; }, function (props) { return props.height; }, function (props) { return props.width; }, function (props) { return props.width; }, function (props) { return props.isActive ? "translate3d(0, " + (props.h - props.t) + "px, 0) rotate(" + props.d + "deg)" : 'translate3d(0, 0, 0) rotate(0deg)'; }, function (props) { return props.h - props.t; }, function (props) { return props.isActive ? 'translate3d(0, 0, 0) scale(0)' : 'translate3d(0, 0, 0) scale(1)'; }, function (props) { return props.height - props.thickness; }, function (props) { return props.isActive ? "translate3d(0, " + (props.t - props.h) + "px, 0) rotate(" + -props.d + "deg)" : 'translate3d(0, 0, 0) rotate(0deg)'; }, function (props) { return props.isActive ? '100%' : (props.isFunky ? '50%' : '100%'); }, function (props) { return props.isActive ? "translate3d(0, " + (props.h - props.t) + "px, 0) rotate(" + props.d + "deg)" : 'translate3d(0, 0, 0) rotate(0deg)'; }, function (props) { return props.h - props.t; }, function (props) { return props.isActive ? 'translate3d(0, 0, 0) scale(0)' : 'translate3d(0, 0, 0) scale(1)'; }, function (props) { return props.height - props.thickness; }, function (props) { return props.isActive ? "translate3d(0, " + (props.t - props.h) + "px, 0) rotate(" + -props.d + "deg)" : 'translate3d(0, 0, 0) rotate(0deg)'; }, function (props) { return props.isActive ? "translate3d(" + 0 + "px, " + (props.h - props.t) + "px, 0) rotate(" + -props.d + "deg)" : 'translate3d(0, 0, 0) rotate(0deg)'; }, function (props) { return props.h - props.t; }, function (props) { return props.isActive ? 'translate3d(0, 0, 0) scale(0)' : 'translate3d(0, 0, 0) scale(1)'; }, function (props) { return props.isActive ? "translate3d(0, " + (props.t - props.h) + "px, 0) rotate(" + props.d + "deg)" : 'translate3d(0, 0, 0) rotate(0deg)'; }, function (props) { return props.isActive ? '100%' : (props.isFunky ? 0 : '100%'); }, function (props) { return props.height - props.thickness; }, function (props) { return props.tintColor; }, function (props) { return props.thickness; }, function (props) { return props.transitionDuration; }, function (props) { return props.thickness; }, function (props) { return props.w; }, function (props) { return props.thickness; }, function (props) { return props.width; });
129
+ var StyledRoot = styled_components_1.default.button(templateObject_1 || (templateObject_1 = __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 > div:only-of-type {\n width: 100%;\n height: 100%;\n\n span:nth-child(1) {\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n transform: ", ";\n }\n\n span:nth-child(2) {\n left: 0;\n position: absolute;\n top: ", "px;\n transform-origin: center;\n transform: ", ";\n }\n\n span:nth-child(3) {\n top: ", ";\n left: 0;\n position: absolute;\n transform-origin: center;\n transform: ", ";\n width: ", ";\n }\n }\n\n > div:not(:only-of-type) {\n height: 100%;\n width: 50%;\n\n &:nth-of-type(1) {\n left: 0;\n top: 0;\n position: absolute;\n\n span:nth-child(1) {\n top: 0;\n left: 0;\n transform-origin: right center;\n transform: ", ";\n }\n\n span:nth-child(2) {\n left: 0;\n top: ", "px;\n transform: ", ";\n transform-origin: right center;\n }\n\n span:nth-child(3) {\n top: ", "px;\n left: 0;\n width: 100%;\n transform-origin: right center;\n transform: ", ";\n }\n }\n\n &:nth-of-type(2) {\n right: 0;\n top: 0;\n position: absolute;\n\n span:nth-child(1) {\n top: 0;\n left: 0;\n transform-origin: left center;\n transform: ", ";\n }\n\n span:nth-child(2) {\n left: 0;\n top: ", "px;\n transform: ", ";\n transform-origin: left center;\n }\n\n span:nth-child(3) {\n transform-origin: left center;\n transform: ", ";\n width: ", ";\n left: 0;\n top: ", "px;\n }\n }\n }\n\n span {\n background: ", ";\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n position: absolute;\n width: 100%;\n height: ", "px;\n transition-duration: ", "ms;\n transition-property: width, height, transform, opacity, background;\n transition-timing-function: ease-out;\n }\n\n &:hover {\n div:not(:only-of-type):nth-of-type(2)::after {\n height: ", "px;\n width: ", "px;\n }\n\n div:only-of-type span:nth-child(3) {\n height: ", "px;\n width: ", "px;\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 > div:only-of-type {\n width: 100%;\n height: 100%;\n\n span:nth-child(1) {\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n transform: ", ";\n }\n\n span:nth-child(2) {\n left: 0;\n position: absolute;\n top: ", "px;\n transform-origin: center;\n transform: ", ";\n }\n\n span:nth-child(3) {\n top: ", ";\n left: 0;\n position: absolute;\n transform-origin: center;\n transform: ", ";\n width: ", ";\n }\n }\n\n > div:not(:only-of-type) {\n height: 100%;\n width: 50%;\n\n &:nth-of-type(1) {\n left: 0;\n top: 0;\n position: absolute;\n\n span:nth-child(1) {\n top: 0;\n left: 0;\n transform-origin: right center;\n transform: ", ";\n }\n\n span:nth-child(2) {\n left: 0;\n top: ", "px;\n transform: ", ";\n transform-origin: right center;\n }\n\n span:nth-child(3) {\n top: ", "px;\n left: 0;\n width: 100%;\n transform-origin: right center;\n transform: ", ";\n }\n }\n\n &:nth-of-type(2) {\n right: 0;\n top: 0;\n position: absolute;\n\n span:nth-child(1) {\n top: 0;\n left: 0;\n transform-origin: left center;\n transform: ", ";\n }\n\n span:nth-child(2) {\n left: 0;\n top: ", "px;\n transform: ", ";\n transform-origin: left center;\n }\n\n span:nth-child(3) {\n transform-origin: left center;\n transform: ", ";\n width: ", ";\n left: 0;\n top: ", "px;\n }\n }\n }\n\n span {\n background: ", ";\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n position: absolute;\n width: 100%;\n height: ", "px;\n transition-duration: ", "ms;\n transition-property: width, height, transform, opacity, background;\n transition-timing-function: ease-out;\n }\n\n &:hover {\n div:not(:only-of-type):nth-of-type(2)::after {\n height: ", "px;\n width: ", "px;\n }\n\n div:only-of-type span:nth-child(3) {\n height: ", "px;\n width: ", "px;\n }\n }\n"])), function (props) { return props.height; }, function (props) { return props.height; }, function (props) { return props.width; }, function (props) { return props.width; }, function (props) { return props.isActive ? "translate3d(0, ".concat(props.h - props.t, "px, 0) rotate(").concat(props.d, "deg)") : 'translate3d(0, 0, 0) rotate(0deg)'; }, function (props) { return props.h - props.t; }, function (props) { return props.isActive ? 'translate3d(0, 0, 0) scale(0)' : 'translate3d(0, 0, 0) scale(1)'; }, function (props) { return props.height - props.thickness; }, function (props) { return props.isActive ? "translate3d(0, ".concat(props.t - props.h, "px, 0) rotate(").concat(-props.d, "deg)") : 'translate3d(0, 0, 0) rotate(0deg)'; }, function (props) { return props.isActive ? '100%' : (props.isFunky ? '50%' : '100%'); }, function (props) { return props.isActive ? "translate3d(0, ".concat(props.h - props.t, "px, 0) rotate(").concat(props.d, "deg)") : 'translate3d(0, 0, 0) rotate(0deg)'; }, function (props) { return props.h - props.t; }, function (props) { return props.isActive ? 'translate3d(0, 0, 0) scale(0)' : 'translate3d(0, 0, 0) scale(1)'; }, function (props) { return props.height - props.thickness; }, function (props) { return props.isActive ? "translate3d(0, ".concat(props.t - props.h, "px, 0) rotate(").concat(-props.d, "deg)") : 'translate3d(0, 0, 0) rotate(0deg)'; }, function (props) { return props.isActive ? "translate3d(".concat(0, "px, ").concat(props.h - props.t, "px, 0) rotate(").concat(-props.d, "deg)") : 'translate3d(0, 0, 0) rotate(0deg)'; }, function (props) { return props.h - props.t; }, function (props) { return props.isActive ? 'translate3d(0, 0, 0) scale(0)' : 'translate3d(0, 0, 0) scale(1)'; }, function (props) { return props.isActive ? "translate3d(0, ".concat(props.t - props.h, "px, 0) rotate(").concat(props.d, "deg)") : 'translate3d(0, 0, 0) rotate(0deg)'; }, function (props) { return props.isActive ? '100%' : (props.isFunky ? 0 : '100%'); }, function (props) { return props.height - props.thickness; }, function (props) { return props.tintColor; }, function (props) { return props.thickness; }, function (props) { return props.transitionDuration; }, function (props) { return props.thickness; }, function (props) { return props.w; }, function (props) { return props.thickness; }, function (props) { return props.width; });
130
130
  var templateObject_1;
131
131
  //# sourceMappingURL=BurgerButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BurgerButton.js","sourceRoot":"/","sources":["BurgerButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAqE;AACrE,wEAAsC;AAqBtC;IAA2B,gCAA2B;IAapD,sBAAY,KAAY;QAAxB,YACE,kBAAM,KAAK,CAAC,SAKb;QAHC,KAAI,CAAC,KAAK,GAAG;YACX,QAAQ,EAAE,KAAI,CAAC,KAAK,CAAC,iBAAiB;SACvC,CAAA;;IACH,CAAC;IAED,6BAAM,GAAN;QACE,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACvB,IAAI,CAAC,UAAU,EAAE,CAAA;SAClB;aACI;YACH,IAAI,CAAC,QAAQ,EAAE,CAAA;SAChB;IACH,CAAC;IAED,+BAAQ,GAAR;QACE,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ;YAAE,OAAM;QAC/B,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;QACjC,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU;YAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAA;IACpD,CAAC;IAED,iCAAU,GAAV;QACE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ;YAAE,OAAM;QAChC,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;QAClC,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY;YAAE,IAAI,CAAC,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AEjE,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,EAA9B,CAA8B,EAMpC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,SAAS,EAAf,CAAe,EAM5B,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,SAAS,EAAf,CAAe,EACX,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,kBAAkB,EAAxB,CAAwB,EAO5C,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,SAAS,EAAf,CAAe,EACzB,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,CAAC,EAAP,CAAO,EAIf,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,SAAS,EAAf,CAAe,EACzB,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,KAAK,EAAX,CAAW,CAGlC,CAAA","sourcesContent":["import React, { CSSProperties, Fragment, PureComponent } from 'react'\nimport styled from 'styled-components'\n\nexport interface Props {\n className?: string\n style: CSSProperties\n isActiveByDefault: boolean\n isDoubleJointed: boolean\n isFunky: boolean\n height: number\n thickness: number\n width: number\n tintColor: string\n transitionDuration: number\n onActivate?: () => void\n onDeactivate?: () => void\n}\n\nexport interface State {\n isActive: boolean\n}\n\nclass BurgerButton extends PureComponent<Props, State> {\n static defaultProps = {\n height: 20,\n isActiveByDefault: false,\n isDoubleJointed: true,\n isFunky: false,\n style: {},\n thickness: 2,\n tintColor: '#000',\n transitionDuration: 200,\n width: 20,\n }\n\n constructor(props: Props) {\n super(props)\n\n this.state = {\n isActive: this.props.isActiveByDefault,\n }\n }\n\n toggle() {\n if (this.state.isActive) {\n this.deactivate()\n }\n else {\n this.activate()\n }\n }\n\n activate() {\n if (this.state.isActive) return\n this.setState({ isActive: true })\n if (this.props.onActivate) this.props.onActivate()\n }\n\n deactivate() {\n if (!this.state.isActive) return\n this.setState({ isActive: false })\n if (this.props.onDeactivate) this.props.onDeactivate()\n }\n\n render() {\n const w = this.props.width * 0.5\n const h = this.props.height * 0.5\n const t = this.props.thickness * 0.5\n const d = 45\n const r = d * Math.PI / 180\n const n = this.props.isDoubleJointed ? 2 : 1\n\n return (\n <StyledRoot\n className={this.props.className}\n height={this.props.height}\n isActive={this.state.isActive}\n isDoubleJointed={this.props.isDoubleJointed}\n isFunky={this.props.isFunky}\n onClick={() => this.toggle()}\n style={this.props.style}\n thickness={this.props.thickness}\n tintColor={this.props.tintColor}\n transitionDuration={this.props.transitionDuration}\n width={this.props.width}\n w={w}\n h={h}\n t={t}\n d={d}\n r={r}\n >\n {this.props.isDoubleJointed && (\n <Fragment>\n {[...new Array(n)].map((v, i) => (\n <div key={`joint-${i}`}>\n <span/>\n <span/>\n <span/>\n </div>\n ))}\n </Fragment>\n )}\n </StyledRoot>\n )\n }\n}\n\nexport default BurgerButton\n\nconst StyledRoot = styled.button<{\n isActive: boolean\n width: number\n height: number\n thickness: number\n tintColor: string\n isDoubleJointed: boolean\n isFunky: boolean\n transitionDuration: number\n w: number\n h: number\n t: number\n d: number\n r: 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 > div:only-of-type {\n width: 100%;\n height: 100%;\n\n span:nth-child(1) {\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n transform: ${props => props.isActive ? `translate3d(0, ${props.h - props.t}px, 0) rotate(${props.d}deg)` : 'translate3d(0, 0, 0) rotate(0deg)'};\n }\n\n span:nth-child(2) {\n left: 0;\n position: absolute;\n top: ${props => props.h - props.t}px;\n transform-origin: center;\n transform: ${props => props.isActive ? 'translate3d(0, 0, 0) scale(0)' : 'translate3d(0, 0, 0) scale(1)'};\n }\n\n span:nth-child(3) {\n top: ${props => props.height - props.thickness};\n left: 0;\n position: absolute;\n transform-origin: center;\n transform: ${props => props.isActive ? `translate3d(0, ${props.t - props.h}px, 0) rotate(${-props.d}deg)` : 'translate3d(0, 0, 0) rotate(0deg)'};\n width: ${props => props.isActive ? '100%' : (props.isFunky ? '50%' : '100%')};\n }\n }\n\n > div:not(:only-of-type) {\n height: 100%;\n width: 50%;\n\n &:nth-of-type(1) {\n left: 0;\n top: 0;\n position: absolute;\n\n span:nth-child(1) {\n top: 0;\n left: 0;\n transform-origin: right center;\n transform: ${props => props.isActive ? `translate3d(0, ${props.h - props.t}px, 0) rotate(${props.d}deg)` : 'translate3d(0, 0, 0) rotate(0deg)'};\n }\n\n span:nth-child(2) {\n left: 0;\n top: ${props => props.h - props.t}px;\n transform: ${props => props.isActive ? 'translate3d(0, 0, 0) scale(0)' : 'translate3d(0, 0, 0) scale(1)'};\n transform-origin: right center;\n }\n\n span:nth-child(3) {\n top: ${props => props.height - props.thickness}px;\n left: 0;\n width: 100%;\n transform-origin: right center;\n transform: ${props => props.isActive ? `translate3d(0, ${props.t - props.h}px, 0) rotate(${-props.d}deg)` : 'translate3d(0, 0, 0) rotate(0deg)'};\n }\n }\n\n &:nth-of-type(2) {\n right: 0;\n top: 0;\n position: absolute;\n\n span:nth-child(1) {\n top: 0;\n left: 0;\n transform-origin: left center;\n transform: ${props => props.isActive ? `translate3d(${0}px, ${props.h - props.t}px, 0) rotate(${-props.d}deg)` : 'translate3d(0, 0, 0) rotate(0deg)'};\n }\n\n span:nth-child(2) {\n left: 0;\n top: ${props => props.h - props.t}px;\n transform: ${props => props.isActive ? 'translate3d(0, 0, 0) scale(0)' : 'translate3d(0, 0, 0) scale(1)'};\n transform-origin: left center;\n }\n\n span:nth-child(3) {\n transform-origin: left center;\n transform: ${props => props.isActive ? `translate3d(0, ${props.t - props.h}px, 0) rotate(${props.d}deg)` : 'translate3d(0, 0, 0) rotate(0deg)'};\n width: ${props => props.isActive ? '100%' : (props.isFunky ? 0 : '100%')};\n left: 0;\n top: ${props => props.height - props.thickness}px;\n }\n }\n }\n\n span {\n background: ${props => props.tintColor};\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n position: absolute;\n width: 100%;\n height: ${props => props.thickness}px;\n transition-duration: ${props => props.transitionDuration}ms;\n transition-property: width, height, transform, opacity, background;\n transition-timing-function: ease-out;\n }\n\n &:hover {\n div:not(:only-of-type):nth-of-type(2)::after {\n height: ${props => props.thickness}px;\n width: ${props => props.w}px;\n }\n\n div:only-of-type span:nth-child(3) {\n height: ${props => props.thickness}px;\n width: ${props => props.width}px;\n }\n }\n`\n"]}
1
+ {"version":3,"file":"BurgerButton.js","sourceRoot":"/","sources":["BurgerButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAqE;AACrE,wEAAsC;AAqBtC;IAA2B,gCAA2B;IAapD,sBAAY,KAAY;QAAxB,YACE,kBAAM,KAAK,CAAC,SAKb;QAHC,KAAI,CAAC,KAAK,GAAG;YACX,QAAQ,EAAE,KAAI,CAAC,KAAK,CAAC,iBAAiB;SACvC,CAAA;;IACH,CAAC;IAED,6BAAM,GAAN;QACE,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACvB,IAAI,CAAC,UAAU,EAAE,CAAA;SAClB;aACI;YACH,IAAI,CAAC,QAAQ,EAAE,CAAA;SAChB;IACH,CAAC;IAED,+BAAQ,GAAR;QACE,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ;YAAE,OAAM;QAC/B,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;QACjC,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU;YAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAA;IACpD,CAAC;IAED,iCAAU,GAAV;QACE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ;YAAE,OAAM;QAChC,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CA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O,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAtD,CAAsD,EAEjE,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,EAA9B,CAA8B,EAMpC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,SAAS,EAAf,CAAe,EAM5B,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,SAAS,EAAf,CAAe,EACX,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,kBAAkB,EAAxB,CAAwB,EAO5C,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,SAAS,EAAf,CAAe,EACzB,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,CAAC,EAAP,CAAO,EAIf,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,SAAS,EAAf,CAAe,EACzB,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,KAAK,EAAX,CAAW,CAGlC,CAAA","sourcesContent":["import React, { CSSProperties, Fragment, PureComponent } from 'react'\nimport styled from 'styled-components'\n\nexport interface Props {\n className?: string\n style: CSSProperties\n isActiveByDefault: boolean\n isDoubleJointed: boolean\n isFunky: boolean\n height: number\n thickness: number\n width: number\n tintColor: string\n transitionDuration: number\n onActivate?: () => void\n onDeactivate?: () => void\n}\n\nexport interface State {\n isActive: boolean\n}\n\nclass BurgerButton extends PureComponent<Props, State> {\n static defaultProps = {\n height: 20,\n isActiveByDefault: false,\n isDoubleJointed: true,\n isFunky: false,\n style: {},\n thickness: 2,\n tintColor: '#000',\n transitionDuration: 200,\n width: 20,\n }\n\n constructor(props: Props) {\n super(props)\n\n this.state = {\n isActive: this.props.isActiveByDefault,\n }\n }\n\n toggle() {\n if (this.state.isActive) {\n this.deactivate()\n }\n else {\n this.activate()\n }\n }\n\n activate() {\n if (this.state.isActive) return\n this.setState({ isActive: true })\n if (this.props.onActivate) this.props.onActivate()\n }\n\n deactivate() {\n if (!this.state.isActive) return\n this.setState({ isActive: false })\n if (this.props.onDeactivate) this.props.onDeactivate()\n }\n\n render() {\n const w = this.props.width * 0.5\n const h = this.props.height * 0.5\n const t = this.props.thickness * 0.5\n const d = 45\n const r = d * Math.PI / 180\n const n = this.props.isDoubleJointed ? 2 : 1\n\n return (\n <StyledRoot\n className={this.props.className}\n height={this.props.height}\n isActive={this.state.isActive}\n isDoubleJointed={this.props.isDoubleJointed}\n isFunky={this.props.isFunky}\n onClick={() => this.toggle()}\n style={this.props.style}\n thickness={this.props.thickness}\n tintColor={this.props.tintColor}\n transitionDuration={this.props.transitionDuration}\n width={this.props.width}\n w={w}\n h={h}\n t={t}\n d={d}\n r={r}\n >\n {this.props.isDoubleJointed && (\n <Fragment>\n {[...new Array(n)].map((v, i) => (\n <div key={`joint-${i}`}>\n <span/>\n <span/>\n <span/>\n </div>\n ))}\n </Fragment>\n )}\n </StyledRoot>\n )\n }\n}\n\nexport default BurgerButton\n\nconst StyledRoot = styled.button<{\n isActive: boolean\n width: number\n height: number\n thickness: number\n tintColor: string\n isDoubleJointed: boolean\n isFunky: boolean\n transitionDuration: number\n w: number\n h: number\n t: number\n d: number\n r: 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 > div:only-of-type {\n width: 100%;\n height: 100%;\n\n span:nth-child(1) {\n left: 0;\n position: absolute;\n top: 0;\n transform-origin: center;\n transform: ${props => props.isActive ? `translate3d(0, ${props.h - props.t}px, 0) rotate(${props.d}deg)` : 'translate3d(0, 0, 0) rotate(0deg)'};\n }\n\n span:nth-child(2) {\n left: 0;\n position: absolute;\n top: ${props => props.h - props.t}px;\n transform-origin: center;\n transform: ${props => props.isActive ? 'translate3d(0, 0, 0) scale(0)' : 'translate3d(0, 0, 0) scale(1)'};\n }\n\n span:nth-child(3) {\n top: ${props => props.height - props.thickness};\n left: 0;\n position: absolute;\n transform-origin: center;\n transform: ${props => props.isActive ? `translate3d(0, ${props.t - props.h}px, 0) rotate(${-props.d}deg)` : 'translate3d(0, 0, 0) rotate(0deg)'};\n width: ${props => props.isActive ? '100%' : (props.isFunky ? '50%' : '100%')};\n }\n }\n\n > div:not(:only-of-type) {\n height: 100%;\n width: 50%;\n\n &:nth-of-type(1) {\n left: 0;\n top: 0;\n position: absolute;\n\n span:nth-child(1) {\n top: 0;\n left: 0;\n transform-origin: right center;\n transform: ${props => props.isActive ? `translate3d(0, ${props.h - props.t}px, 0) rotate(${props.d}deg)` : 'translate3d(0, 0, 0) rotate(0deg)'};\n }\n\n span:nth-child(2) {\n left: 0;\n top: ${props => props.h - props.t}px;\n transform: ${props => props.isActive ? 'translate3d(0, 0, 0) scale(0)' : 'translate3d(0, 0, 0) scale(1)'};\n transform-origin: right center;\n }\n\n span:nth-child(3) {\n top: ${props => props.height - props.thickness}px;\n left: 0;\n width: 100%;\n transform-origin: right center;\n transform: ${props => props.isActive ? `translate3d(0, ${props.t - props.h}px, 0) rotate(${-props.d}deg)` : 'translate3d(0, 0, 0) rotate(0deg)'};\n }\n }\n\n &:nth-of-type(2) {\n right: 0;\n top: 0;\n position: absolute;\n\n span:nth-child(1) {\n top: 0;\n left: 0;\n transform-origin: left center;\n transform: ${props => props.isActive ? `translate3d(${0}px, ${props.h - props.t}px, 0) rotate(${-props.d}deg)` : 'translate3d(0, 0, 0) rotate(0deg)'};\n }\n\n span:nth-child(2) {\n left: 0;\n top: ${props => props.h - props.t}px;\n transform: ${props => props.isActive ? 'translate3d(0, 0, 0) scale(0)' : 'translate3d(0, 0, 0) scale(1)'};\n transform-origin: left center;\n }\n\n span:nth-child(3) {\n transform-origin: left center;\n transform: ${props => props.isActive ? `translate3d(0, ${props.t - props.h}px, 0) rotate(${props.d}deg)` : 'translate3d(0, 0, 0) rotate(0deg)'};\n width: ${props => props.isActive ? '100%' : (props.isFunky ? 0 : '100%')};\n left: 0;\n top: ${props => props.height - props.thickness}px;\n }\n }\n }\n\n span {\n background: ${props => props.tintColor};\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n position: absolute;\n width: 100%;\n height: ${props => props.thickness}px;\n transition-duration: ${props => props.transitionDuration}ms;\n transition-property: width, height, transform, opacity, background;\n transition-timing-function: ease-out;\n }\n\n &:hover {\n div:not(:only-of-type):nth-of-type(2)::after {\n height: ${props => props.thickness}px;\n width: ${props => props.w}px;\n }\n\n div:only-of-type span:nth-child(3) {\n height: ${props => props.thickness}px;\n width: ${props => props.width}px;\n }\n }\n`\n"]}
@@ -0,0 +1,20 @@
1
+ import { PureComponent } from 'react';
2
+ import { CSSProperties } from 'styled-components';
3
+ export interface Props {
4
+ className?: string;
5
+ style: CSSProperties;
6
+ angle: number;
7
+ fov: number;
8
+ radius: number;
9
+ highlightThickness: number;
10
+ highlightColor: string;
11
+ trackColor: string;
12
+ trackDasharray: string;
13
+ trackThickness: number;
14
+ }
15
+ export default class Compass extends PureComponent<Props> {
16
+ static defaultProps: Partial<Props>;
17
+ render(): JSX.Element;
18
+ private polarToCartesian;
19
+ private describeArc;
20
+ }
package/lib/Compass.js CHANGED
@@ -62,14 +62,14 @@ var Compass = (function (_super) {
62
62
  Compass.prototype.render = function () {
63
63
  var _a = this.props, className = _a.className, highlightColor = _a.highlightColor, highlightThickness = _a.highlightThickness, radius = _a.radius, trackColor = _a.trackColor, trackDasharray = _a.trackDasharray, trackThickness = _a.trackThickness, style = _a.style;
64
64
  var diameter = radius * 2;
65
- return (react_1.default.createElement(StyledRoot, { className: className, style: __assign(__assign({}, style), { width: diameter + "px", height: diameter + "px" }) },
65
+ return (react_1.default.createElement(StyledRoot, { className: className, style: __assign(__assign({}, style), { width: "".concat(diameter, "px"), height: "".concat(diameter, "px") }) },
66
66
  react_1.default.createElement(StyledCircle, null,
67
- react_1.default.createElement("svg", { xmlns: 'http://www.w3.org/2000/svg', width: diameter, height: diameter, viewBox: "0 0 " + diameter + " " + diameter },
67
+ react_1.default.createElement("svg", { xmlns: 'http://www.w3.org/2000/svg', width: diameter, height: diameter, viewBox: "0 0 ".concat(diameter, " ").concat(diameter) },
68
68
  react_1.default.createElement("circle", { cx: radius, cy: radius, r: radius - trackThickness / 2, fill: 'none', stroke: trackColor, strokeWidth: trackThickness, strokeDasharray: trackDasharray }))),
69
69
  react_1.default.createElement(StyledHighlight, { style: {
70
- transform: "rotate(" + (this.props.angle + 360) % 360 + "deg)",
70
+ transform: "rotate(".concat((this.props.angle + 360) % 360, "deg)"),
71
71
  } },
72
- react_1.default.createElement("svg", { xmlns: 'http://www.w3.org/2000/svg', width: diameter, height: diameter, viewBox: "0 0 " + diameter + " " + diameter },
72
+ react_1.default.createElement("svg", { xmlns: 'http://www.w3.org/2000/svg', width: diameter, height: diameter, viewBox: "0 0 ".concat(diameter, " ").concat(diameter) },
73
73
  react_1.default.createElement("path", { fill: 'none', stroke: highlightColor, strokeWidth: highlightThickness, d: this.describeArc(radius, radius, radius - highlightThickness / 2 - (trackThickness - highlightThickness) / 2, -this.props.fov / 2, this.props.fov / 2) })))));
74
74
  };
75
75
  Compass.prototype.polarToCartesian = function (centerX, centerY, radius, angleInDegrees) {
@@ -1 +1 @@
1
- {"version":3,"file":"Compass.js","sourceRoot":"/","sources":["Compass.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA4C;AAC5C,wEAAyD;AAmEzD;IAAqC,2BAAoB;IAAzD;;IAqFA,CAAC;IA1EC,wBAAM,GAAN;QACQ,IAAA,KAA+G,IAAI,CAAC,KAAK,EAAvH,SAAS,eAAA,EAAE,cAAc,oBAAA,EAAE,kBAAkB,wBAAA,EAAE,MAAM,YAAA,EAAE,UAAU,gBAAA,EAAE,cAAc,oBAAA,EAAE,cAAc,oBAAA,EAAE,KAAK,WAAe,CAAA;QAC/H,IAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,CAAA;QAE3B,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jD;kBArFoB,OAAO;AAuF5B,IAAM,YAAY,GAAG,2BAAM,CAAC,GAAG,mLAAA,gHAO9B,IAAA,CAAA;AAED,IAAM,eAAe,GAAG,2BAAM,CAAC,GAAG,2WAAA,wSAiBjC,IAAA,CAAA;AAED,IAAM,UAAU,GAAG,2BAAM,CAAC,GAAG,qHAAA,kDAG5B,IAAA,CAAA","sourcesContent":["import React, { PureComponent } from 'react'\nimport styled, { CSSProperties } from 'styled-components'\n\nexport interface Props {\n /**\n * Class attribute of the component.\n * @optional\n */\n className?: string\n\n /**\n * Inline style attribute of the root element.\n * @optional\n */\n style: CSSProperties\n\n /**\n * Current angle reading of the compass, between 0 - 360 (degrees), inclusive.\n */\n angle: number\n\n /**\n * Field of view expressed in angles, must be between 0 and 360, exclusive.\n *\n * @example Suppose the compass were to be used to control a photosphere of\n * an image that is 1000 x 500, and the window size is 500 x 500,\n * that would mean the FOV is 500 / 1000 * 360 = 180 degrees.\n */\n fov: number\n\n /**\n * Radius of the component.\n * @optional\n */\n radius: number\n\n /**\n * The thickness of the highlight indicator.\n * @optional\n */\n highlightThickness: number\n\n /**\n * Color of the highlight indicator.\n * @optional\n */\n highlightColor: string\n\n /**\n * The color of the circular compass track.\n * @optional\n */\n trackColor: string\n\n /**\n * The `stroke-dasharray` attribute provided to the circular compass track.\n * @optional\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray}\n */\n trackDasharray: string\n\n /**\n * The thickness of the circular compass track.\n * @optional\n */\n trackThickness: number\n}\n\nexport default class Compass extends PureComponent<Props> {\n static defaultProps: Partial<Props> = {\n highlightColor: '#fff',\n highlightThickness: 10,\n radius: 50,\n style: {},\n trackColor: '#fff',\n trackDasharray: '4',\n trackThickness: 2,\n }\n\n render() {\n const { className, highlightColor, highlightThickness, radius, trackColor, trackDasharray, trackThickness, style } = this.props\n const diameter = radius * 2\n\n return (\n <StyledRoot\n className={className}\n style={{\n ...style,\n width: `${diameter}px`,\n height: `${diameter}px`,\n }}\n >\n <StyledCircle>\n <svg\n xmlns='http://www.w3.org/2000/svg'\n width={diameter}\n height={diameter}\n viewBox={`0 0 ${diameter} ${diameter}`}\n >\n <circle\n cx={radius}\n cy={radius}\n r={radius - trackThickness / 2}\n fill='none'\n stroke={trackColor}\n strokeWidth={trackThickness}\n strokeDasharray={trackDasharray}\n />\n </svg>\n </StyledCircle>\n <StyledHighlight\n style={{\n transform: `rotate(${(this.props.angle + 360) % 360}deg)`,\n }}\n >\n <svg\n xmlns='http://www.w3.org/2000/svg'\n width={diameter}\n height={diameter}\n viewBox={`0 0 ${diameter} ${diameter}`}\n >\n <path\n fill='none'\n stroke={highlightColor}\n strokeWidth={highlightThickness}\n d={this.describeArc(radius, radius, radius - highlightThickness / 2 - (trackThickness - highlightThickness) / 2, -this.props.fov / 2, this.props.fov / 2)}\n />\n </svg>\n </StyledHighlight>\n </StyledRoot>\n )\n }\n\n private 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\n private describeArc(x: number, y: number, radius: number, startAngle: number, endAngle: number) {\n const start = this.polarToCartesian(x, y, radius, endAngle)\n const end = this.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\nconst StyledCircle = styled.div`\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n position: absolute;\n transform-origin: center;\n`\n\nconst StyledHighlight = styled.div`\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n position: absolute;\n background-position: center;\n background-repeat: no-repeat;\n background-size: 100%;\n transform-origin: center;\n\n svg {\n top: 0;\n right: 0;\n overflow: visible;\n position: absolute;\n }\n`\n\nconst StyledRoot = styled.div`\n box-sizing: border-box;\n display: block;\n`\n"]}
1
+ {"version":3,"file":"Compass.js","sourceRoot":"/","sources":["Compass.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA4C;AAC5C,wEAAyD;AAmEzD;IAAqC,2BAAoB;IAAzD;;IAqFA,CAAC;IA1EC,wBAAM,GAAN;QACQ,IAAA,KAA+G,IAAI,CAAC,KAAK,EAAvH,SAAS,eAAA,EAAE,cAAc,oBAAA,EAAE,kBAAkB,wBAAA,EAAE,MAAM,YAAA,EAAE,UAAU,gBAAA,EAAE,cAAc,oBAAA,EAAE,cAAc,oBAAA,EAAE,KAAK,WAAe,CAAA;QAC/H,IAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,CAAA;QAE3B,OAAO,CACL,8BAAC,UAAU,IACT,SAAS,EAAE,SAAS,EACpB,KAAK,wBACA,KAAK,KACR,KAAK,EAAE,UAAG,QAAQ,OAAI,EACtB,MAAM,EAAE,UAAG,QAAQ,OAAI;YAGzB,8BAAC,YAAY;gBACX,uCACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,cAAO,QAAQ,cAAI,QAAQ,CAAE;oBAEtC,0CACE,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,CAAC,EAC9B,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,UAAU,EAClB,WAAW,EAAE,cAAc,EAC3B,eAAe,EAAE,cAAc,GAC/B,CACE,CACO;YACf,8BAAC,eAAe,IACd,KAAK,EAAE;oBACL,SAAS,EAAE,iBAAU,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,SAAM;iBAC1D;gBAED,uCACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EA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CAAC,CAAC,CAAC,GAAG,CAAA;QAC7D,IAAM,CAAC,GAAG;YACR,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YACrB,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SACtD,CAAA;QAED,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC;IAnFM,oBAAY,GAAmB;QACpC,cAAc,EAAE,MAAM;QACtB,kBAAkB,EAAE,EAAE;QACtB,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,EAAE;QACT,UAAU,EAAE,MAAM;QAClB,cAAc,EAAE,GAAG;QACnB,cAAc,EAAE,CAAC;KAClB,CAAA;IA4EH,cAAC;CAAA,AArFD,CAAqC,qBAAa,GAqFjD;kBArFoB,OAAO;AAuF5B,IAAM,YAAY,GAAG,2BAAM,CAAC,GAAG,mLAAA,gHAO9B,IAAA,CAAA;AAED,IAAM,eAAe,GAAG,2BAAM,CAAC,GAAG,2WAAA,wSAiBjC,IAAA,CAAA;AAED,IAAM,UAAU,GAAG,2BAAM,CAAC,GAAG,qHAAA,kDAG5B,IAAA,CAAA","sourcesContent":["import React, { PureComponent } from 'react'\nimport styled, { CSSProperties } from 'styled-components'\n\nexport interface Props {\n /**\n * Class attribute of the component.\n * @optional\n */\n className?: string\n\n /**\n * Inline style attribute of the root element.\n * @optional\n */\n style: CSSProperties\n\n /**\n * Current angle reading of the compass, between 0 - 360 (degrees), inclusive.\n */\n angle: number\n\n /**\n * Field of view expressed in angles, must be between 0 and 360, exclusive.\n *\n * @example Suppose the compass were to be used to control a photosphere of\n * an image that is 1000 x 500, and the window size is 500 x 500,\n * that would mean the FOV is 500 / 1000 * 360 = 180 degrees.\n */\n fov: number\n\n /**\n * Radius of the component.\n * @optional\n */\n radius: number\n\n /**\n * The thickness of the highlight indicator.\n * @optional\n */\n highlightThickness: number\n\n /**\n * Color of the highlight indicator.\n * @optional\n */\n highlightColor: string\n\n /**\n * The color of the circular compass track.\n * @optional\n */\n trackColor: string\n\n /**\n * The `stroke-dasharray` attribute provided to the circular compass track.\n * @optional\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray}\n */\n trackDasharray: string\n\n /**\n * The thickness of the circular compass track.\n * @optional\n */\n trackThickness: number\n}\n\nexport default class Compass extends PureComponent<Props> {\n static defaultProps: Partial<Props> = {\n highlightColor: '#fff',\n highlightThickness: 10,\n radius: 50,\n style: {},\n trackColor: '#fff',\n trackDasharray: '4',\n trackThickness: 2,\n }\n\n render() {\n const { className, highlightColor, highlightThickness, radius, trackColor, trackDasharray, trackThickness, style } = this.props\n const diameter = radius * 2\n\n return (\n <StyledRoot\n className={className}\n style={{\n ...style,\n width: `${diameter}px`,\n height: `${diameter}px`,\n }}\n >\n <StyledCircle>\n <svg\n xmlns='http://www.w3.org/2000/svg'\n width={diameter}\n height={diameter}\n viewBox={`0 0 ${diameter} ${diameter}`}\n >\n <circle\n cx={radius}\n cy={radius}\n r={radius - trackThickness / 2}\n fill='none'\n stroke={trackColor}\n strokeWidth={trackThickness}\n strokeDasharray={trackDasharray}\n />\n </svg>\n </StyledCircle>\n <StyledHighlight\n style={{\n transform: `rotate(${(this.props.angle + 360) % 360}deg)`,\n }}\n >\n <svg\n xmlns='http://www.w3.org/2000/svg'\n width={diameter}\n height={diameter}\n viewBox={`0 0 ${diameter} ${diameter}`}\n >\n <path\n fill='none'\n stroke={highlightColor}\n strokeWidth={highlightThickness}\n d={this.describeArc(radius, radius, radius - highlightThickness / 2 - (trackThickness - highlightThickness) / 2, -this.props.fov / 2, this.props.fov / 2)}\n />\n </svg>\n </StyledHighlight>\n </StyledRoot>\n )\n }\n\n private 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\n private describeArc(x: number, y: number, radius: number, startAngle: number, endAngle: number) {\n const start = this.polarToCartesian(x, y, radius, endAngle)\n const end = this.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\nconst StyledCircle = styled.div`\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n position: absolute;\n transform-origin: center;\n`\n\nconst StyledHighlight = styled.div`\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n position: absolute;\n background-position: center;\n background-repeat: no-repeat;\n background-size: 100%;\n transform-origin: center;\n\n svg {\n top: 0;\n right: 0;\n overflow: visible;\n position: absolute;\n }\n`\n\nconst StyledRoot = styled.div`\n box-sizing: border-box;\n display: block;\n`\n"]}
@@ -0,0 +1,25 @@
1
+ import React, { CSSProperties, PureComponent } from 'react';
2
+ export interface Props {
3
+ className?: string;
4
+ style: CSSProperties;
5
+ margin: number;
6
+ maxEntries: number;
7
+ align: 'tl' | 'tc' | 'tr' | 'cl' | 'cc' | 'cr' | 'bl' | 'bc' | 'br';
8
+ message?: string;
9
+ title?: string;
10
+ }
11
+ export interface State {
12
+ messages: string[];
13
+ }
14
+ export default class DebugConsole extends PureComponent<Props, State> {
15
+ static defaultProps: Partial<Props>;
16
+ nodeRefs: {
17
+ messages: React.RefObject<HTMLDivElement>;
18
+ };
19
+ constructor(props: Props);
20
+ componentDidUpdate(prevProps: Props, prevState: State): void;
21
+ push(message: string): void;
22
+ clear(): void;
23
+ render(): JSX.Element;
24
+ private getStyleByAlignment;
25
+ }
@@ -123,19 +123,19 @@ var DebugConsole = (function (_super) {
123
123
  var _a;
124
124
  return (react_1.default.createElement(StyledRoot, { className: this.props.className, style: __assign(__assign(__assign({}, this.props.style), { margin: 0, position: 'fixed' }), this.getStyleByAlignment(this.props.align)) },
125
125
  react_1.default.createElement("h6", null, (_a = this.props.title) !== null && _a !== void 0 ? _a : 'Untitled'),
126
- react_1.default.createElement("div", { ref: this.nodeRefs.messages }, this.state.messages.map(function (v, i) { return (react_1.default.createElement("span", { key: "item-" + i, dangerouslySetInnerHTML: { __html: v } })); }))));
126
+ react_1.default.createElement("div", { ref: this.nodeRefs.messages }, this.state.messages.map(function (v, i) { return (react_1.default.createElement("span", { key: "item-".concat(i), dangerouslySetInnerHTML: { __html: v } })); }))));
127
127
  };
128
128
  DebugConsole.prototype.getStyleByAlignment = function (align) {
129
129
  switch (align) {
130
- case 'tl': return { top: this.props.margin + "px", left: this.props.margin + "px" };
131
- case 'tc': return { top: this.props.margin + "px", left: 0, right: 0, margin: '0 auto' };
132
- case 'tr': return { top: this.props.margin + "px", right: this.props.margin + "px" };
133
- case 'cl': return { top: 0, left: this.props.margin + "px", bottom: 0, margin: 'auto 0' };
130
+ case 'tl': return { top: "".concat(this.props.margin, "px"), left: "".concat(this.props.margin, "px") };
131
+ case 'tc': return { top: "".concat(this.props.margin, "px"), left: 0, right: 0, margin: '0 auto' };
132
+ case 'tr': return { top: "".concat(this.props.margin, "px"), right: "".concat(this.props.margin, "px") };
133
+ case 'cl': return { top: 0, left: "".concat(this.props.margin, "px"), bottom: 0, margin: 'auto 0' };
134
134
  case 'cc': return { top: 0, left: 0, right: 0, bottom: 0, margin: 'auto' };
135
- case 'cr': return { top: 0, bottom: 0, right: this.props.margin + "px", margin: 'auto 0' };
136
- case 'bl': return { bottom: this.props.margin + "px", left: this.props.margin + "px" };
137
- case 'bc': return { bottom: this.props.margin + "px", left: 0, right: 0, margin: '0 auto' };
138
- default: return { bottom: this.props.margin + "px", right: this.props.margin + "px" };
135
+ case 'cr': return { top: 0, bottom: 0, right: "".concat(this.props.margin, "px"), margin: 'auto 0' };
136
+ case 'bl': return { bottom: "".concat(this.props.margin, "px"), left: "".concat(this.props.margin, "px") };
137
+ case 'bc': return { bottom: "".concat(this.props.margin, "px"), left: 0, right: 0, margin: '0 auto' };
138
+ default: return { bottom: "".concat(this.props.margin, "px"), right: "".concat(this.props.margin, "px") };
139
139
  }
140
140
  };
141
141
  DebugConsole.defaultProps = {