[2/3] Prettify shared, build, and teleport packages (#955)

* Update prettier ignore
This commit is contained in:
Lisa Kim 2022-07-06 07:57:40 -07:00 committed by GitHub
parent 631aa2f6e2
commit b86c9bcdfe
40 changed files with 2382 additions and 2106 deletions

View file

@ -1,2 +1,7 @@
# assets contains pre-generated files like iconmoon, fonts, svgs. # assets contains pre-generated files like iconmoon, fonts, svgs.
packages/design/src/assets/* packages/design/src/assets/*
# Ignore file types:
packages/**/*.css
packages/**/*.json
packages/**/*.yaml

View file

@ -17,7 +17,7 @@ limitations under the License.
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
testEnvironment: "jsdom", testEnvironment: 'jsdom',
moduleNameMapper: { moduleNameMapper: {
// mock all imports to asset files // mock all imports to asset files
'\\.(css|scss|stylesheet)$': path.join(__dirname, 'mockStyles.js'), '\\.(css|scss|stylesheet)$': path.join(__dirname, 'mockStyles.js'),

View file

@ -152,5 +152,4 @@ function createDefaultConfig() {
}; };
} }
module.exports = configFactory;
module.exports = configFactory;

View file

@ -31,9 +31,7 @@ module.exports = {
}, },
devtool: false, devtool: false,
mode: 'development', mode: 'development',
plugins: [ plugins: [configFactory.plugins.reactRefresh()],
configFactory.plugins.reactRefresh(),
],
module: { module: {
strictExportPresence: true, strictExportPresence: true,
rules: [ rules: [

View file

@ -10,4 +10,4 @@ Add `@gravitational/shared` to your package.json file.
"devDependencies": { "devDependencies": {
"@gravitational/shared": "^1.0.0", "@gravitational/shared": "^1.0.0",
}, },
``` ```

View file

@ -96,7 +96,7 @@ const StyledTextEditor = styled.div`
.ace-monokai .ace_marker-layer .ace_active-line { .ace-monokai .ace_marker-layer .ace_active-line {
//background: #928787; //background: #928787;
} }
//.ace-monokai .ace_gutter, //.ace-monokai .ace_gutter,
//.ace-monokai .ace_gutter-cell { //.ace-monokai .ace_gutter-cell {

View file

@ -31,14 +31,15 @@ ace.define(
const oop = acequire('../lib/oop'); const oop = acequire('../lib/oop');
const TextMode = acequire('./text').Mode; const TextMode = acequire('./text').Mode;
const FoldMode = acequire('./folding/coffee').FoldMode; const FoldMode = acequire('./folding/coffee').FoldMode;
const MatchingBraceOutdent = acequire('./matching_brace_outdent') const MatchingBraceOutdent = acequire(
.MatchingBraceOutdent; './matching_brace_outdent'
).MatchingBraceOutdent;
const GravitationalHighlightRules = acequire( const GravitationalHighlightRules = acequire(
'ace/mode/grv_bpf_highlight_rules' 'ace/mode/grv_bpf_highlight_rules'
).GravitationalHighlightRules; ).GravitationalHighlightRules;
const Mode = function() { const Mode = function () {
this.$outdent = new MatchingBraceOutdent(); this.$outdent = new MatchingBraceOutdent();
this.foldingRules = new FoldMode(); this.foldingRules = new FoldMode();
this.HighlightRules = GravitationalHighlightRules; this.HighlightRules = GravitationalHighlightRules;
@ -55,8 +56,9 @@ ace.define(
['require', 'exports', 'ace/lib/oop', 'ace/mode/text_highlight_rules'], ['require', 'exports', 'ace/lib/oop', 'ace/mode/text_highlight_rules'],
(acequire, exports) => { (acequire, exports) => {
const oop = acequire('ace/lib/oop'); const oop = acequire('ace/lib/oop');
const TextHighlightRules = acequire('ace/mode/text_highlight_rules') const TextHighlightRules = acequire(
.TextHighlightRules; 'ace/mode/text_highlight_rules'
).TextHighlightRules;
function GravitationalHighlightRules() { function GravitationalHighlightRules() {
this.$rules = new TextHighlightRules().getRules(); // Use Text's rules as a base this.$rules = new TextHighlightRules().getRules(); // Use Text's rules as a base
@ -88,7 +90,7 @@ ace.define(
{ {
token: 'string', // multi line string start token: 'string', // multi line string start
regex: /[|>][-+\d]*(?:$|\s+(?:$|#))/, regex: /[|>][-+\d]*(?:$|\s+(?:$|#))/,
onMatch: function(val, state, stack, line) { onMatch: function (val, state, stack, line) {
line = line.replace(/ #.*/, ''); line = line.replace(/ #.*/, '');
var indent = /^ *((:\s*)?-(\s*[^|>])?)?/ var indent = /^ *((:\s*)?-(\s*[^|>])?)?/
.exec(line)[0] .exec(line)[0]
@ -122,7 +124,7 @@ ace.define(
{ {
token: 'indent', token: 'indent',
regex: /^ */, regex: /^ */,
onMatch: function(val, state, stack) { onMatch: function (val, state, stack) {
var curIndent = stack[1]; var curIndent = stack[1];
if (curIndent >= val.length) { if (curIndent >= val.length) {
@ -150,7 +152,7 @@ ace.define(
{ {
token: 'indent', token: 'indent',
regex: /^ */, regex: /^ */,
onMatch: function(val, state, stack) { onMatch: function (val, state, stack) {
var curIndent = stack[1]; var curIndent = stack[1];
if (curIndent >= val.length) { if (curIndent >= val.length) {

View file

@ -60,14 +60,8 @@ const Pane = styled(Flex)`
`; `;
export function PaneSide(props) { export function PaneSide(props) {
const { const { children, position, isDragging, split, defaultSize, hasTwoSides } =
children, props;
position,
isDragging,
split,
defaultSize,
hasTwoSides,
} = props;
const compRef = React.useRef(); const compRef = React.useRef();

View file

@ -14,27 +14,23 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import {useEffect} from "react"; import { useEffect } from 'react';
function useClickOutside(ref, handler) { function useClickOutside(ref, handler) {
useEffect(() => {
useEffect( const listener = (e: MouseEvent) => {
() => { if (!ref.current || ref.current.contains(e.target)) {
const listener = (e: MouseEvent) => { return;
if (!ref.current || ref.current.contains(e.target)) { }
return; handler(e);
} };
handler(e); document.addEventListener('mousedown', listener);
}; document.addEventListener('touchstart', listener);
document.addEventListener("mousedown", listener); return () => {
document.addEventListener("touchstart", listener); document.removeEventListener('mousedown', listener);
return () => { document.removeEventListener('touchstart', listener);
document.removeEventListener("mousedown", listener); };
document.removeEventListener("touchstart", listener); }, [ref, handler]);
};
},
[ref, handler]
);
} }
export {useClickOutside}; export { useClickOutside };

View file

@ -19,7 +19,7 @@ import { useEffect } from 'react';
function useEscape(handler) { function useEscape(handler) {
useEffect(() => { useEffect(() => {
const listener = (e: KeyboardEvent) => { const listener = (e: KeyboardEvent) => {
if (e.key === "Escape") { if (e.key === 'Escape') {
handler(e); handler(e);
} }
}; };

View file

@ -25,7 +25,7 @@ if (typeof Promise !== 'function') {
} }
if (typeof Promise.prototype.finally !== 'function') { if (typeof Promise.prototype.finally !== 'function') {
var speciesConstructor = function(O, defaultConstructor) { var speciesConstructor = function (O, defaultConstructor) {
if (!O || (typeof O !== 'object' && typeof O !== 'function')) { if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
throw new TypeError('Assertion failed: Type(O) is not Object'); throw new TypeError('Assertion failed: Type(O) is not Object');
} }

View file

@ -29,8 +29,5 @@ export function bufferToBase64url(buffer: ArrayBuffer): string {
const base64str = arrayBufferToBase64(buffer); const base64str = arrayBufferToBase64(buffer);
// Assuming the base64str is a well-formed url. // Assuming the base64str is a well-formed url.
return base64str return base64str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
} }

View file

@ -9,4 +9,4 @@ then you can start your local development server:
``` ```
$ yarn run start --target=https://example.com:3080/web $ yarn run start --target=https://example.com:3080/web
``` ```

View file

@ -1,5 +1,5 @@
const baseCfg = require('@gravitational/build/.babelrc'); const baseCfg = require('@gravitational/build/.babelrc');
module.exports = function (api) { module.exports = function (api) {
api.cache(true); api.cache(true);
return baseCfg return baseCfg;
} };

View file

@ -15,4 +15,4 @@ limitations under the License.
*/ */
import EventDialog from './EventDialog'; import EventDialog from './EventDialog';
export default EventDialog; export default EventDialog;

View file

@ -34,11 +34,9 @@ storiesOf('Teleport/Console', module).add('Console', () => {
}); });
export function TestLayout(props: PropType) { export function TestLayout(props: PropType) {
const [context] = React.useState( const [context] = React.useState((): ConsoleContext => {
(): ConsoleContext => { return props.ctx || new ConsoleContext();
return props.ctx || new ConsoleContext(); });
}
);
const [history] = React.useState((): any => { const [history] = React.useState((): any => {
const history = const history =

View file

@ -16,4 +16,4 @@ limitations under the License.
import Terminal from './Terminal'; import Terminal from './Terminal';
export default Terminal; export default Terminal;

View file

@ -15,4 +15,4 @@ limitations under the License.
*/ */
import DownloadForm from './DownloadForm'; import DownloadForm from './DownloadForm';
export default DownloadForm; export default DownloadForm;

View file

@ -15,4 +15,4 @@ limitations under the License.
*/ */
import FileList from './FileList'; import FileList from './FileList';
export default FileList; export default FileList;

View file

@ -105,7 +105,6 @@ const defaultFile = {
location: '~test', location: '~test',
id: '1547581437406~/test', id: '1547581437406~/test',
url: '/v1/webapi/sites/one/nodes/', url: '/v1/webapi/sites/one/nodes/',
name: name: '~/test~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf',
'~/test~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf',
blob: [], blob: [],
}; };

View file

@ -15,4 +15,4 @@ limitations under the License.
*/ */
import UploadForm from './UploadForm'; import UploadForm from './UploadForm';
export default UploadForm; export default UploadForm;

View file

@ -15,4 +15,4 @@ limitations under the License.
*/ */
import StyledXterm from './StyledXterm'; import StyledXterm from './StyledXterm';
export default StyledXterm; export default StyledXterm;

View file

@ -46,10 +46,7 @@ export default function JoinedUsers(props) {
const $users = users.map((u, index) => { const $users = users.map((u, index) => {
const name = u.user || ''; const name = u.user || '';
const initial = name const initial = name.trim().charAt(0).toUpperCase();
.trim()
.charAt(0)
.toUpperCase();
return ( return (
<UserItem key={`${index}${u.user}`}> <UserItem key={`${index}${u.user}`}>
<StyledAvatar>{initial}</StyledAvatar> <StyledAvatar>{initial}</StyledAvatar>

View file

@ -66,7 +66,10 @@ export default function ConnectDialog({
Step 2 Step 2
</Text> </Text>
{' - Retrieve credentials for the database'} {' - Retrieve credentials for the database'}
<TextSelectCopy mt="2" text={`tsh db login [--db-user=<user>] [--db-name=<name>] ${dbName}`} /> <TextSelectCopy
mt="2"
text={`tsh db login [--db-user=<user>] [--db-name=<name>] ${dbName}`}
/>
</Box> </Box>
<Box mb={4}> <Box mb={4}>
<Text bold as="span"> <Text bold as="span">

View file

@ -19,7 +19,4 @@ import LoginFailed from './LoginFailed';
import LoginSuccess from './LoginSuccess'; import LoginSuccess from './LoginSuccess';
export default Login; export default Login;
export { export { LoginFailed, LoginSuccess };
LoginFailed,
LoginSuccess
}

View file

@ -15,4 +15,4 @@ limitations under the License.
*/ */
import Nodes from './Nodes'; import Nodes from './Nodes';
export default Nodes; export default Nodes;

View file

@ -43,14 +43,21 @@ THE SOFTWARE.
(function (root, factory) { (function (root, factory) {
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
define(['react','prop-types','create-react-class'], factory); define(['react', 'prop-types', 'create-react-class'], factory);
} else if (typeof exports === 'object') { } else if (typeof exports === 'object') {
module.exports = factory(require('react'),require('prop-types'),require('create-react-class')); module.exports = factory(
require('react'),
require('prop-types'),
require('create-react-class')
);
} else { } else {
root.ReactSlider = factory(root.React,root.PropTypes,root.createReactClass); root.ReactSlider = factory(
root.React,
root.PropTypes,
root.createReactClass
);
} }
}(this, function (React, PropTypes, createReactClass) { })(this, function (React, PropTypes, createReactClass) {
/** /**
* To prevent text selection while dragging. * To prevent text selection while dragging.
* http://stackoverflow.com/questions/5429827/how-can-i-prevent-text-element-selection-with-cursor-drag * http://stackoverflow.com/questions/5429827/how-can-i-prevent-text-element-selection-with-cursor-drag
@ -85,9 +92,11 @@ THE SOFTWARE.
return x != null && x.length === 1 ? x[0] : x; return x != null && x.length === 1 ? x[0] : x;
} }
var isArray = Array.isArray || function(x) { var isArray =
return Object.prototype.toString.call(x) === '[object Array]'; Array.isArray ||
}; function (x) {
return Object.prototype.toString.call(x) === '[object Array]';
};
// undoEnsureArray(ensureArray(x)) === x // undoEnsureArray(ensureArray(x)) === x
@ -95,7 +104,6 @@ THE SOFTWARE.
displayName: 'ReactSlider', displayName: 'ReactSlider',
propTypes: { propTypes: {
/** /**
* The minimum value of the slider. * The minimum value of the slider.
*/ */
@ -129,7 +137,7 @@ THE SOFTWARE.
*/ */
defaultValue: PropTypes.oneOfType([ defaultValue: PropTypes.oneOfType([
PropTypes.number, PropTypes.number,
PropTypes.arrayOf(PropTypes.number) PropTypes.arrayOf(PropTypes.number),
]), ]),
/** /**
@ -137,7 +145,7 @@ THE SOFTWARE.
*/ */
value: PropTypes.oneOfType([ value: PropTypes.oneOfType([
PropTypes.number, PropTypes.number,
PropTypes.arrayOf(PropTypes.number) PropTypes.arrayOf(PropTypes.number),
]), ]),
/** /**
@ -215,7 +223,7 @@ THE SOFTWARE.
* Callback called when the the slider is clicked (handle or bars). * Callback called when the the slider is clicked (handle or bars).
* Receives the value at the clicked position as argument. * Receives the value at the clicked position as argument.
*/ */
onSliderClick: PropTypes.func onSliderClick: PropTypes.func,
}, },
getDefaultProps: function () { getDefaultProps: function () {
@ -234,12 +242,15 @@ THE SOFTWARE.
pearling: false, pearling: false,
disabled: false, disabled: false,
snapDragDisabled: false, snapDragDisabled: false,
invert: false invert: false,
}; };
}, },
getInitialState: function () { getInitialState: function () {
var value = this._or(ensureArray(this.props.value), ensureArray(this.props.defaultValue)); var value = this._or(
ensureArray(this.props.value),
ensureArray(this.props.defaultValue)
);
// reused throughout the component to store results of iterations over `value` // reused throughout the component to store results of iterations over `value`
this.tempArray = value.slice(); this.tempArray = value.slice();
@ -258,7 +269,7 @@ THE SOFTWARE.
upperBound: 0, upperBound: 0,
sliderLength: 0, sliderLength: 0,
value: value, value: value,
zIndices: zIndices zIndices: zIndices,
}; };
}, },
@ -299,7 +310,10 @@ THE SOFTWARE.
return defaultValue; return defaultValue;
default: default:
if (value.length !== count || defaultValue.length !== count) { if (value.length !== count || defaultValue.length !== count) {
window.console.warn(this.constructor.displayName + ": Number of values does not match number of children."); window.console.warn(
this.constructor.displayName +
': Number of values does not match number of children.'
);
} }
return linspace(this.props.min, this.props.max, count); return linspace(this.props.min, this.props.max, count);
} }
@ -333,23 +347,26 @@ THE SOFTWARE.
upperBound: slider[size] - handle[size], upperBound: slider[size] - handle[size],
sliderLength: Math.abs(sliderMax - sliderMin), sliderLength: Math.abs(sliderMax - sliderMin),
handleSize: handle[size], handleSize: handle[size],
sliderStart: this.props.invert ? sliderMax : sliderMin sliderStart: this.props.invert ? sliderMax : sliderMin,
}); });
}, },
_handleResize: function () { _handleResize: function () {
// setTimeout of 0 gives element enough time to have assumed its new size if it is being resized // setTimeout of 0 gives element enough time to have assumed its new size if it is being resized
var resizeTimeout = window.setTimeout(function() { var resizeTimeout = window.setTimeout(
// drop this timeout from pendingResizeTimeouts to reduce memory usage function () {
this.pendingResizeTimeouts.shift(); // drop this timeout from pendingResizeTimeouts to reduce memory usage
this._resize(); this.pendingResizeTimeouts.shift();
}.bind(this), 0); this._resize();
}.bind(this),
0
);
this.pendingResizeTimeouts.push(resizeTimeout); this.pendingResizeTimeouts.push(resizeTimeout);
}, },
// clear all pending timeouts to avoid error messages after unmounting // clear all pending timeouts to avoid error messages after unmounting
_clearPendingResizeTimeouts: function() { _clearPendingResizeTimeouts: function () {
do { do {
var nextTimeout = this.pendingResizeTimeouts.shift(); var nextTimeout = this.pendingResizeTimeouts.shift();
@ -377,7 +394,7 @@ THE SOFTWARE.
var style = { var style = {
position: 'absolute', position: 'absolute',
willChange: this.state.index >= 0 ? this._posMinKey() : '', willChange: this.state.index >= 0 ? this._posMinKey() : '',
zIndex: this.state.zIndices.indexOf(i) + 1 zIndex: this.state.zIndices.indexOf(i) + 1,
}; };
style[this._posMinKey()] = offset + 'px'; style[this._posMinKey()] = offset + 'px';
return style; return style;
@ -386,7 +403,10 @@ THE SOFTWARE.
_buildBarStyle: function (min, max) { _buildBarStyle: function (min, max) {
var obj = { var obj = {
position: 'absolute', position: 'absolute',
willChange: this.state.index >= 0 ? this._posMinKey() + ',' + this._posMaxKey() : '' willChange:
this.state.index >= 0
? this._posMinKey() + ',' + this._posMaxKey()
: '',
}; };
obj[this._posMinKey()] = min; obj[this._posMinKey()] = min;
obj[this._posMaxKey()] = max; obj[this._posMaxKey()] = max;
@ -414,8 +434,9 @@ THE SOFTWARE.
_calcOffsetFromPosition: function (position) { _calcOffsetFromPosition: function (position) {
var pixelOffset = position - this.state.sliderStart; var pixelOffset = position - this.state.sliderStart;
if (this.props.invert) pixelOffset = this.state.sliderLength - pixelOffset; if (this.props.invert)
pixelOffset -= (this.state.handleSize / 2); pixelOffset = this.state.sliderLength - pixelOffset;
pixelOffset -= this.state.handleSize / 2;
return pixelOffset; return pixelOffset;
}, },
@ -433,13 +454,13 @@ THE SOFTWARE.
if (value[i + 1] - value[i] < this.props.minDistance) return; if (value[i + 1] - value[i] < this.props.minDistance) return;
} }
this.setState({value: value}, callback.bind(this, closestIndex)); this.setState({ value: value }, callback.bind(this, closestIndex));
}, },
_getMousePosition: function (e) { _getMousePosition: function (e) {
return [ return [
e['page' + this._axisKey()], e['page' + this._axisKey()],
e['page' + this._orthogonalAxisKey()] e['page' + this._orthogonalAxisKey()],
]; ];
}, },
@ -447,29 +468,29 @@ THE SOFTWARE.
var touch = e.touches[0]; var touch = e.touches[0];
return [ return [
touch['page' + this._axisKey()], touch['page' + this._axisKey()],
touch['page' + this._orthogonalAxisKey()] touch['page' + this._orthogonalAxisKey()],
]; ];
}, },
_getKeyDownEventMap: function () { _getKeyDownEventMap: function () {
return { return {
'keydown': this._onKeyDown, keydown: this._onKeyDown,
'focusout': this._onBlur focusout: this._onBlur,
} };
}, },
_getMouseEventMap: function () { _getMouseEventMap: function () {
return { return {
'mousemove': this._onMouseMove, mousemove: this._onMouseMove,
'mouseup': this._onMouseUp mouseup: this._onMouseUp,
} };
}, },
_getTouchEventMap: function () { _getTouchEventMap: function () {
return { return {
'touchmove': this._onTouchMove, touchmove: this._onTouchMove,
'touchend': this._onTouchEnd touchend: this._onTouchEnd,
} };
}, },
// create the `keydown` handler for the i-th handle // create the `keydown` handler for the i-th handle
@ -537,9 +558,10 @@ THE SOFTWARE.
this.setState(function (prevState) { this.setState(function (prevState) {
return { return {
startValue: this.state.value[i], startValue: this.state.value[i],
startPosition: position !== undefined ? position : prevState.startPosition, startPosition:
position !== undefined ? position : prevState.startPosition,
index: i, index: i,
zIndices: zIndices zIndices: zIndices,
}; };
}); });
}, },
@ -558,7 +580,10 @@ THE SOFTWARE.
_onEnd: function (eventMap) { _onEnd: function (eventMap) {
this._removeHandlers(eventMap); this._removeHandlers(eventMap);
this.setState({index: -1}, this._fireChangeEvent.bind(this, 'onAfterChange')); this.setState(
{ index: -1 },
this._fireChangeEvent.bind(this, 'onAfterChange')
);
}, },
_onMouseMove: function (e) { _onMouseMove: function (e) {
@ -580,7 +605,7 @@ THE SOFTWARE.
} }
if (this.isScrolling) { if (this.isScrolling) {
this.setState({index: -1}); this.setState({ index: -1 });
return; return;
} }
@ -595,17 +620,17 @@ THE SOFTWARE.
_onKeyDown: function (e) { _onKeyDown: function (e) {
if (e.ctrlKey || e.shiftKey || e.altKey) return; if (e.ctrlKey || e.shiftKey || e.altKey) return;
switch (e.key) { switch (e.key) {
case "ArrowLeft": case 'ArrowLeft':
case "ArrowUp": case 'ArrowUp':
e.preventDefault(); e.preventDefault();
return this._moveDownOneStep(); return this._moveDownOneStep();
case "ArrowRight": case 'ArrowRight':
case "ArrowDown": case 'ArrowDown':
e.preventDefault(); e.preventDefault();
return this._moveUpOneStep(); return this._moveUpOneStep();
case "Home": case 'Home':
return this._move(this.props.min); return this._move(this.props.min);
case "End": case 'End':
return this._move(this.props.max); return this._move(this.props.max);
default: default:
return; return;
@ -625,7 +650,9 @@ THE SOFTWARE.
}, },
_getValueFromPosition: function (position) { _getValueFromPosition: function (position) {
var diffValue = position / (this.state.sliderLength - this.state.handleSize) * (this.props.max - this.props.min); var diffValue =
(position / (this.state.sliderLength - this.state.handleSize)) *
(this.props.max - this.props.min);
return this._trimAlignValue(this.state.startValue + diffValue); return this._trimAlignValue(this.state.startValue + diffValue);
}, },
@ -673,8 +700,7 @@ THE SOFTWARE.
if (newValue > oldValue) { if (newValue > oldValue) {
this._pushSucceeding(value, minDistance, index); this._pushSucceeding(value, minDistance, index);
this._trimSucceeding(length, value, minDistance, props.max); this._trimSucceeding(length, value, minDistance, props.max);
} } else if (newValue < oldValue) {
else if (newValue < oldValue) {
this._pushPreceding(value, minDistance, index); this._pushPreceding(value, minDistance, index);
this._trimPreceding(length, value, minDistance, props.min); this._trimPreceding(length, value, minDistance, props.min);
} }
@ -683,15 +709,20 @@ THE SOFTWARE.
// Normally you would use `shouldComponentUpdate`, but since the slider is a low-level component, // Normally you would use `shouldComponentUpdate`, but since the slider is a low-level component,
// the extra complexity might be worth the extra performance. // the extra complexity might be worth the extra performance.
if (newValue !== oldValue) { if (newValue !== oldValue) {
this.setState({value: value}, this._fireChangeEvent.bind(this, 'onChange')); this.setState(
{ value: value },
this._fireChangeEvent.bind(this, 'onChange')
);
} }
}, },
_pushSucceeding: function (value, minDistance, index) { _pushSucceeding: function (value, minDistance, index) {
var i, padding; var i, padding;
for (i = index, padding = value[i] + minDistance; for (
value[i + 1] != null && padding > value[i + 1]; i = index, padding = value[i] + minDistance;
i++, padding = value[i] + minDistance) { value[i + 1] != null && padding > value[i + 1];
i++, padding = value[i] + minDistance
) {
value[i + 1] = this._alignValue(padding); value[i + 1] = this._alignValue(padding);
} }
}, },
@ -707,9 +738,11 @@ THE SOFTWARE.
_pushPreceding: function (value, minDistance, index) { _pushPreceding: function (value, minDistance, index) {
var i, padding; var i, padding;
for (i = index, padding = value[i] - minDistance; for (
value[i - 1] != null && padding < value[i - 1]; i = index, padding = value[i] - minDistance;
i--, padding = value[i] - minDistance) { value[i - 1] != null && padding < value[i - 1];
i--, padding = value[i] - minDistance
) {
value[i - 1] = this._alignValue(padding); value[i - 1] = this._alignValue(padding);
} }
}, },
@ -737,14 +770,18 @@ THE SOFTWARE.
_posMinKey: function () { _posMinKey: function () {
var orientation = this.props.orientation; var orientation = this.props.orientation;
if (orientation === 'horizontal') return this.props.invert ? 'right' : 'left'; if (orientation === 'horizontal')
if (orientation === 'vertical') return this.props.invert ? 'bottom' : 'top'; return this.props.invert ? 'right' : 'left';
if (orientation === 'vertical')
return this.props.invert ? 'bottom' : 'top';
}, },
_posMaxKey: function () { _posMaxKey: function () {
var orientation = this.props.orientation; var orientation = this.props.orientation;
if (orientation === 'horizontal') return this.props.invert ? 'left' : 'right'; if (orientation === 'horizontal')
if (orientation === 'vertical') return this.props.invert ? 'top' : 'bottom'; return this.props.invert ? 'left' : 'right';
if (orientation === 'vertical')
return this.props.invert ? 'top' : 'bottom';
}, },
_sizeKey: function () { _sizeKey: function () {
@ -773,7 +810,7 @@ THE SOFTWARE.
var alignValue = val - valModStep; var alignValue = val - valModStep;
if (Math.abs(valModStep) * 2 >= props.step) { if (Math.abs(valModStep) * 2 >= props.step) {
alignValue += (valModStep > 0) ? props.step : (-props.step); alignValue += valModStep > 0 ? props.step : -props.step;
} }
return parseFloat(alignValue.toFixed(5)); return parseFloat(alignValue.toFixed(5));
@ -781,31 +818,36 @@ THE SOFTWARE.
_renderHandle: function (style, child, i) { _renderHandle: function (style, child, i) {
var self = this; var self = this;
var className = this.props.handleClassName + ' ' + var className =
(this.props.handleClassName + '-' + i) + ' ' + this.props.handleClassName +
' ' +
(this.props.handleClassName + '-' + i) +
' ' +
(this.state.index === i ? this.props.handleActiveClassName : ''); (this.state.index === i ? this.props.handleActiveClassName : '');
return ( return React.createElement(
React.createElement('div', { 'div',
ref: function (r) { {
self['handle' + i] = r; ref: function (r) {
}, self['handle' + i] = r;
key: 'handle' + i,
className: className,
style: style,
onMouseDown: this._createOnMouseDown(i),
onTouchStart: this._createOnTouchStart(i),
onFocus: this._createOnKeyDown(i),
tabIndex: 0,
role: "slider",
"aria-valuenow": this.state.value[i],
"aria-valuemin": this.props.min,
"aria-valuemax": this.props.max,
"aria-label": isArray(this.props.ariaLabel) ? this.props.ariaLabel[i] : this.props.ariaLabel,
"aria-valuetext": this.props.ariaValuetext,
}, },
child key: 'handle' + i,
) className: className,
style: style,
onMouseDown: this._createOnMouseDown(i),
onTouchStart: this._createOnTouchStart(i),
onFocus: this._createOnKeyDown(i),
tabIndex: 0,
role: 'slider',
'aria-valuenow': this.state.value[i],
'aria-valuemin': this.props.min,
'aria-valuemax': this.props.max,
'aria-label': isArray(this.props.ariaLabel)
? this.props.ariaLabel[i]
: this.props.ariaLabel,
'aria-valuetext': this.props.ariaValuetext,
},
child
); );
}, },
@ -833,16 +875,18 @@ THE SOFTWARE.
_renderBar: function (i, offsetFrom, offsetTo) { _renderBar: function (i, offsetFrom, offsetTo) {
var self = this; var self = this;
return ( return React.createElement('div', {
React.createElement('div', { key: 'bar' + i,
key: 'bar' + i, ref: function (r) {
ref: function (r) { self['bar' + i] = r;
self['bar' + i] = r; },
}, className:
className: this.props.barClassName + ' ' + this.props.barClassName + '-' + i, this.props.barClassName + ' ' + this.props.barClassName + '-' + i,
style: this._buildBarStyle(offsetFrom, this.state.upperBound - offsetTo) style: this._buildBarStyle(
}) offsetFrom,
); this.state.upperBound - offsetTo
),
});
}, },
_renderBars: function (offset) { _renderBars: function (offset) {
@ -855,7 +899,9 @@ THE SOFTWARE.
bars.push(this._renderBar(i + 1, offset[i], offset[i + 1])); bars.push(this._renderBar(i + 1, offset[i], offset[i + 1]));
} }
bars.push(this._renderBar(lastIndex + 1, offset[lastIndex], this.state.upperBound)); bars.push(
this._renderBar(lastIndex + 1, offset[lastIndex], this.state.upperBound)
);
return bars; return bars;
}, },
@ -865,11 +911,14 @@ THE SOFTWARE.
this.hasMoved = false; this.hasMoved = false;
if (!this.props.snapDragDisabled) { if (!this.props.snapDragDisabled) {
var position = this._getMousePosition(e); var position = this._getMousePosition(e);
this._forceValueFromPosition(position[0], function (i) { this._forceValueFromPosition(
this._start(i, position[0]); position[0],
this._fireChangeEvent('onChange'); function (i) {
this._addHandlers(this._getMouseEventMap()); this._start(i, position[0]);
}.bind(this)); this._fireChangeEvent('onChange');
this._addHandlers(this._getMouseEventMap());
}.bind(this)
);
} }
pauseEvent(e); pauseEvent(e);
@ -880,7 +929,9 @@ THE SOFTWARE.
if (this.props.onSliderClick && !this.hasMoved) { if (this.props.onSliderClick && !this.hasMoved) {
var position = this._getMousePosition(e); var position = this._getMousePosition(e);
var valueAtPos = this._trimAlignValue(this._calcValue(this._calcOffsetFromPosition(position[0]))); var valueAtPos = this._trimAlignValue(
this._calcValue(this._calcOffsetFromPosition(position[0]))
);
this.props.onSliderClick(valueAtPos); this.props.onSliderClick(valueAtPos);
} }
}, },
@ -906,22 +957,22 @@ THE SOFTWARE.
var bars = props.withBars ? this._renderBars(offset) : null; var bars = props.withBars ? this._renderBars(offset) : null;
var handles = this._renderHandles(offset); var handles = this._renderHandles(offset);
return ( return React.createElement(
React.createElement('div', { 'div',
ref: function (r) { {
self.slider = r; ref: function (r) {
}, self.slider = r;
style: {position: 'relative'},
className: props.className + (props.disabled ? ' disabled' : ''),
onMouseDown: this._onSliderMouseDown,
onClick: this._onSliderClick
}, },
bars, style: { position: 'relative' },
handles className: props.className + (props.disabled ? ' disabled' : ''),
) onMouseDown: this._onSliderMouseDown,
onClick: this._onSliderClick,
},
bars,
handles
); );
} },
}); });
return ReactSlider; return ReactSlider;
})); });

View file

@ -15,4 +15,4 @@ limitations under the License.
*/ */
import Slider from './Slider'; import Slider from './Slider';
export default Slider; export default Slider;

View file

@ -16,4 +16,4 @@ limitations under the License.
import Xterm from './Xterm'; import Xterm from './Xterm';
export default Xterm; export default Xterm;

File diff suppressed because one or more lines are too long

View file

@ -16,4 +16,3 @@ limitations under the License.
import SideNav from './SideNav'; import SideNav from './SideNav';
export default SideNav; export default SideNav;

View file

@ -15,4 +15,4 @@ limitations under the License.
*/ */
import CatchError from './CatchError'; import CatchError from './CatchError';
export default CatchError; export default CatchError;

View file

@ -15,4 +15,4 @@ limitations under the License.
*/ */
import CustomRange from './Custom'; import CustomRange from './Custom';
export default CustomRange; export default CustomRange;

View file

@ -15,4 +15,4 @@ limitations under the License.
*/ */
import InputSearch from './InputSearch'; import InputSearch from './InputSearch';
export default InputSearch; export default InputSearch;

View file

@ -18,16 +18,16 @@ import React from 'react';
import Image from 'design/Image'; import Image from 'design/Image';
import defaultLogoSvg from 'design/assets/images/teleport-medallion.svg'; import defaultLogoSvg from 'design/assets/images/teleport-medallion.svg';
const LogoHero = ({...rest}) => { const LogoHero = ({ ...rest }) => {
return <Image {...rest}/> return <Image {...rest} />;
} };
LogoHero.defaultProps = { LogoHero.defaultProps = {
src: defaultLogoSvg, src: defaultLogoSvg,
maxHeight: "120px", maxHeight: '120px',
maxWidth: "200px", maxWidth: '200px',
my: 6, my: 6,
mx: "auto" mx: 'auto',
} };
export default LogoHero; export default LogoHero;

View file

@ -15,4 +15,4 @@ limitations under the License.
*/ */
import LogoHero from './LogoHero'; import LogoHero from './LogoHero';
export default LogoHero; export default LogoHero;

View file

@ -41,9 +41,8 @@ export default function ResourceEditor(props) {
isNew, isNew,
} = props; } = props;
const { attempt, attemptActions, content, isDirty, setContent } = useEditor( const { attempt, attemptActions, content, isDirty, setContent } =
text useEditor(text);
);
const onSave = () => { const onSave = () => {
attemptActions.do(() => props.onSave(content)).then(() => onClose()); attemptActions.do(() => props.onSave(content)).then(() => onClose());

File diff suppressed because one or more lines are too long

View file

@ -17,23 +17,23 @@ limitations under the License.
export default class AddressResolver { export default class AddressResolver {
_cfg = { _cfg = {
ttyUrl: null, ttyUrl: null,
ttyParams: {} ttyParams: {},
} };
constructor(cfg){ constructor(cfg) {
this._cfg = { this._cfg = {
...cfg, ...cfg,
} };
} }
getConnStr(w, h){ getConnStr(w, h) {
const { ttyParams, ttyUrl } = this._cfg; const { ttyParams, ttyUrl } = this._cfg;
const params = JSON.stringify({ const params = JSON.stringify({
...ttyParams, ...ttyParams,
term: { h, w } term: { h, w },
}); });
const encoded = window.encodeURI(params); const encoded = window.encodeURI(params);
return ttyUrl.replace(':params', encoded); return ttyUrl.replace(':params', encoded);
} }
} }

View file

@ -14,8 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import service, { getUrlParameter } from './history'; import service, { getUrlParameter } from './history';
export default service; export default service;
export { export { getUrlParameter };
getUrlParameter
}