baseui 12.1.2 → 12.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/button-timed/button-timed.d.ts +4 -0
- package/button-timed/button-timed.js +124 -0
- package/button-timed/index.d.ts +5 -0
- package/button-timed/index.js +78 -0
- package/button-timed/index.js.flow +57 -0
- package/button-timed/package.json +4 -0
- package/button-timed/styled-components.d.ts +5 -0
- package/button-timed/styled-components.js +57 -0
- package/button-timed/types.d.ts +12 -0
- package/button-timed/types.js +5 -0
- package/button-timed/utils.d.ts +1 -0
- package/button-timed/utils.js +30 -0
- package/card/card.js.flow +1 -1
- package/card/types.d.ts +1 -1
- package/card/types.js.flow +1 -1
- package/data-table/data-table.js +16 -12
- package/data-table/data-table.js.flow +2 -2
- package/data-table/stateful-container.js +41 -35
- package/data-table/stateful-data-table.js +2 -0
- package/data-table/types.d.ts +3 -0
- package/data-table/types.js.flow +2 -0
- package/es/button-timed/button-timed.js +82 -0
- package/es/button-timed/index.js +11 -0
- package/es/button-timed/styled-components.js +47 -0
- package/es/button-timed/types.js +1 -0
- package/es/button-timed/utils.js +21 -0
- package/es/data-table/data-table.js +10 -8
- package/es/data-table/stateful-container.js +30 -18
- package/es/data-table/stateful-data-table.js +2 -0
- package/es/input/base-input.js +1 -3
- package/es/layer/tether.js +1 -1
- package/es/popover/popover.js +2 -2
- package/es/themes/dark-theme/color-component-tokens.js +1 -1
- package/esm/button-timed/button-timed.js +112 -0
- package/esm/button-timed/index.js +11 -0
- package/esm/button-timed/styled-components.js +51 -0
- package/esm/button-timed/types.js +1 -0
- package/esm/button-timed/utils.js +21 -0
- package/esm/data-table/data-table.js +16 -12
- package/esm/data-table/stateful-container.js +41 -35
- package/esm/data-table/stateful-data-table.js +2 -0
- package/esm/input/base-input.js +6 -9
- package/esm/layer/tether.js +1 -1
- package/esm/popover/popover.js +2 -2
- package/esm/themes/dark-theme/color-component-tokens.js +1 -1
- package/header-navigation/types.d.ts +3 -2
- package/header-navigation/types.js.flow +2 -0
- package/input/base-input.js +6 -9
- package/layer/tether.js +1 -1
- package/layer/tether.js.flow +1 -1
- package/layout-grid/types.d.ts +1 -1
- package/package.json +1 -1
- package/popover/popover.js +2 -2
- package/popover/popover.js.flow +3 -3
- package/popover/types.d.ts +4 -4
- package/popover/types.js.flow +4 -4
- package/skeleton/skeleton.js.flow +1 -1
- package/skeleton/types.d.ts +1 -1
- package/skeleton/types.js.flow +1 -1
- package/themes/dark-theme/color-component-tokens.js +1 -1
- package/themes/dark-theme/color-component-tokens.js.flow +1 -1
- package/themes/types.d.ts +5 -5
- package/tree-view/tree-label-interactable.d.ts +3 -3
- package/tree-view/tree-label-interactable.js.flow +2 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _button = require("../button");
|
|
13
|
+
|
|
14
|
+
var _styledComponents = require("./styled-components");
|
|
15
|
+
|
|
16
|
+
var _utils = require("./utils");
|
|
17
|
+
|
|
18
|
+
var _overrides = require("../helpers/overrides");
|
|
19
|
+
|
|
20
|
+
var _excluded = ["initialTime", "paused", "onClick", "disabled", "children", "overrides"],
|
|
21
|
+
_excluded2 = ["TimerContainer"];
|
|
22
|
+
|
|
23
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
|
+
|
|
25
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
26
|
+
|
|
27
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
28
|
+
|
|
29
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
30
|
+
|
|
31
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
32
|
+
|
|
33
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
34
|
+
|
|
35
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
36
|
+
|
|
37
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
38
|
+
|
|
39
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
40
|
+
|
|
41
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
42
|
+
|
|
43
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
44
|
+
|
|
45
|
+
var ButtonTimed = function ButtonTimed(props) {
|
|
46
|
+
var initialTime = props.initialTime,
|
|
47
|
+
_props$paused = props.paused,
|
|
48
|
+
paused = _props$paused === void 0 ? false : _props$paused,
|
|
49
|
+
onClickProp = props.onClick,
|
|
50
|
+
disabled = props.disabled,
|
|
51
|
+
children = props.children,
|
|
52
|
+
_props$overrides = props.overrides,
|
|
53
|
+
overrides = _props$overrides === void 0 ? {} : _props$overrides,
|
|
54
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
55
|
+
|
|
56
|
+
var _React$useState = React.useState(initialTime * 1000),
|
|
57
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
58
|
+
timeRemaining = _React$useState2[0],
|
|
59
|
+
setTimeRemaining = _React$useState2[1];
|
|
60
|
+
|
|
61
|
+
React.useEffect(function () {
|
|
62
|
+
var timerId = setTimeout(function () {
|
|
63
|
+
if (timeRemaining > 0 && !paused) {
|
|
64
|
+
setTimeRemaining(function (seconds) {
|
|
65
|
+
return seconds - 100;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}, 100);
|
|
69
|
+
|
|
70
|
+
if (timeRemaining === 0) {
|
|
71
|
+
onClickProp();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return function () {
|
|
75
|
+
return clearTimeout(timerId);
|
|
76
|
+
};
|
|
77
|
+
}, [timeRemaining, paused]);
|
|
78
|
+
|
|
79
|
+
var onClick = function onClick() {
|
|
80
|
+
setTimeRemaining(0);
|
|
81
|
+
onClickProp();
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
var TimerContainerOverride = overrides.TimerContainer,
|
|
85
|
+
buttonOverrides = _objectWithoutProperties(overrides, _excluded2);
|
|
86
|
+
|
|
87
|
+
var _getOverrides = (0, _overrides.getOverrides)(TimerContainerOverride, _styledComponents.TimerContainer),
|
|
88
|
+
_getOverrides2 = _slicedToArray(_getOverrides, 2),
|
|
89
|
+
TimerContainer = _getOverrides2[0],
|
|
90
|
+
timerContainerProps = _getOverrides2[1];
|
|
91
|
+
|
|
92
|
+
var buttonMergedOverrides = (0, _overrides.mergeOverrides)({
|
|
93
|
+
BaseButton: {
|
|
94
|
+
component: _styledComponents.BaseButtonTimed,
|
|
95
|
+
props: {
|
|
96
|
+
$initialTime: initialTime,
|
|
97
|
+
$timeElapsed: (initialTime * 1000 - timeRemaining) / 1000
|
|
98
|
+
},
|
|
99
|
+
style: {
|
|
100
|
+
':after': {
|
|
101
|
+
animationPlayState: paused ? 'paused' : 'running'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
Root: buttonOverrides.Root || {},
|
|
107
|
+
BaseButton: buttonOverrides.BaseButton,
|
|
108
|
+
StartEnhancer: buttonOverrides.StartEnhancer || {},
|
|
109
|
+
EndEnhancer: buttonOverrides.EndEnhancer || {},
|
|
110
|
+
LoadingSpinnerContainer: buttonOverrides.LoadingSpinnerContainer || {},
|
|
111
|
+
LoadingSpinner: buttonOverrides.LoadingSpinner || {}
|
|
112
|
+
});
|
|
113
|
+
return /*#__PURE__*/React.createElement(_button.Button, _extends({}, restProps, {
|
|
114
|
+
overrides: buttonMergedOverrides,
|
|
115
|
+
onClick: onClick,
|
|
116
|
+
size: _button.SIZE.large,
|
|
117
|
+
kind: _button.KIND.primary,
|
|
118
|
+
shape: _button.SHAPE.default,
|
|
119
|
+
disabled: disabled || timeRemaining === 0
|
|
120
|
+
}), children, /*#__PURE__*/React.createElement(TimerContainer, timerContainerProps, "(".concat((0, _utils.formatTime)(timeRemaining), ")")));
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
var _default = ButtonTimed;
|
|
124
|
+
exports.default = _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { StyledStartEnhancer, StyledEndEnhancer, StyledLoadingSpinner, StyledLoadingSpinnerContainer } from '../button';
|
|
2
|
+
import { BaseButtonTimed as StyledBaseButtonTimed, TimerContainer as StyledTimercontainer } from './styled-components';
|
|
3
|
+
export { StyledBaseButtonTimed, StyledTimercontainer, StyledStartEnhancer, StyledEndEnhancer, StyledLoadingSpinner, StyledLoadingSpinnerContainer, };
|
|
4
|
+
export * from './types';
|
|
5
|
+
export { default as ButtonTimed } from './button-timed';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
StyledStartEnhancer: true,
|
|
8
|
+
StyledEndEnhancer: true,
|
|
9
|
+
StyledLoadingSpinner: true,
|
|
10
|
+
StyledLoadingSpinnerContainer: true,
|
|
11
|
+
StyledBaseButtonTimed: true,
|
|
12
|
+
StyledTimercontainer: true,
|
|
13
|
+
ButtonTimed: true
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "ButtonTimed", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function get() {
|
|
18
|
+
return _buttonTimed.default;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "StyledBaseButtonTimed", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function get() {
|
|
24
|
+
return _styledComponents.BaseButtonTimed;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "StyledEndEnhancer", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function get() {
|
|
30
|
+
return _button.StyledEndEnhancer;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports, "StyledLoadingSpinner", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function get() {
|
|
36
|
+
return _button.StyledLoadingSpinner;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "StyledLoadingSpinnerContainer", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function get() {
|
|
42
|
+
return _button.StyledLoadingSpinnerContainer;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(exports, "StyledStartEnhancer", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function get() {
|
|
48
|
+
return _button.StyledStartEnhancer;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports, "StyledTimercontainer", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function get() {
|
|
54
|
+
return _styledComponents.TimerContainer;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
var _button = require("../button");
|
|
59
|
+
|
|
60
|
+
var _styledComponents = require("./styled-components");
|
|
61
|
+
|
|
62
|
+
var _types = require("./types");
|
|
63
|
+
|
|
64
|
+
Object.keys(_types).forEach(function (key) {
|
|
65
|
+
if (key === "default" || key === "__esModule") return;
|
|
66
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
67
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
68
|
+
Object.defineProperty(exports, key, {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function get() {
|
|
71
|
+
return _types[key];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
var _buttonTimed = _interopRequireDefault(require("./button-timed"));
|
|
77
|
+
|
|
78
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) Uber Technologies, Inc.
|
|
3
|
+
|
|
4
|
+
This source code is licensed under the MIT license found in the
|
|
5
|
+
LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
// @flow
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import type { OverrideT } from '../helpers/overrides.js';
|
|
10
|
+
import { type StyletronComponent } from 'styletron-react';
|
|
11
|
+
import type { CustomColorsT } from '../button';
|
|
12
|
+
|
|
13
|
+
export type OverridesT = {
|
|
14
|
+
BaseButtonTimed?: OverrideT,
|
|
15
|
+
TimerContainer?: OverrideT,
|
|
16
|
+
Root?: OverrideT,
|
|
17
|
+
StartEnhancer?: OverrideT,
|
|
18
|
+
EndEnhancer?: OverrideT,
|
|
19
|
+
LoadingSpinnerContainer?: OverrideT,
|
|
20
|
+
LoadingSpinner?: OverrideT,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type ButtonTimedPropsT = {
|
|
24
|
+
initialTime: number,
|
|
25
|
+
onClick: (a?: SyntheticEvent<HTMLButtonElement>) => mixed,
|
|
26
|
+
overrides?: OverridesT,
|
|
27
|
+
paused?: boolean,
|
|
28
|
+
children?: React$Node,
|
|
29
|
+
colors?: CustomColorsT,
|
|
30
|
+
disabled?: boolean,
|
|
31
|
+
/** A helper rendered at the end of the button. */
|
|
32
|
+
// flowlint-next-line unclear-type:off
|
|
33
|
+
endEnhancer?: React.Node | React.AbstractComponent<any>,
|
|
34
|
+
/** Show loading button style and spinner. */
|
|
35
|
+
isLoading?: boolean,
|
|
36
|
+
/** Indicates that the button is selected */
|
|
37
|
+
isSelected?: boolean,
|
|
38
|
+
/** A helper rendered at the start of the button. */
|
|
39
|
+
// flowlint-next-line unclear-type:off
|
|
40
|
+
startEnhancer?: React.Node | React.AbstractComponent<any>,
|
|
41
|
+
type?: 'submit' | 'reset' | 'button',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
StyledStartEnhancer,
|
|
46
|
+
StyledEndEnhancer,
|
|
47
|
+
StyledLoadingSpinner,
|
|
48
|
+
StyledLoadingSpinnerContainer,
|
|
49
|
+
} from '../button';
|
|
50
|
+
declare export var StyledBaseButtonTimed: StyletronComponent<'div', {}>;
|
|
51
|
+
declare export var StyledTimerContainer: StyletronComponent<'div', {}>;
|
|
52
|
+
|
|
53
|
+
declare export var ButtonTimed: React.ComponentType<ButtonTimedPropsT>;
|
|
54
|
+
|
|
55
|
+
declare var __DEV__: boolean;
|
|
56
|
+
declare var __NODE__: boolean;
|
|
57
|
+
declare var __BROWSER__: boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const BaseButtonTimed: import("styletron-react").StyletronComponent<"button", {
|
|
2
|
+
$initialTime: number;
|
|
3
|
+
$timeElapsed: number;
|
|
4
|
+
} & import("../button").SharedStyleProps>;
|
|
5
|
+
export declare const TimerContainer: import("styletron-react").StyletronComponent<"span", {}>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TimerContainer = exports.BaseButtonTimed = void 0;
|
|
7
|
+
|
|
8
|
+
var _index = require("../styles/index");
|
|
9
|
+
|
|
10
|
+
var _button = require("../button");
|
|
11
|
+
|
|
12
|
+
var _util = require("../styles/util");
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
|
|
18
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
+
|
|
20
|
+
var BaseButtonTimed = (0, _index.withStyle)(_button.StyledBaseButton, function (_ref) {
|
|
21
|
+
var $theme = _ref.$theme,
|
|
22
|
+
$initialTime = _ref.$initialTime,
|
|
23
|
+
$timeElapsed = _ref.$timeElapsed;
|
|
24
|
+
var completionPercentage = $timeElapsed / $initialTime * 100;
|
|
25
|
+
var timeLeft = $initialTime - $timeElapsed;
|
|
26
|
+
return _objectSpread({
|
|
27
|
+
position: 'relative'
|
|
28
|
+
}, $initialTime > 0 ? {
|
|
29
|
+
':after': {
|
|
30
|
+
animationDuration: "".concat(timeLeft, "s"),
|
|
31
|
+
animationName: {
|
|
32
|
+
from: {
|
|
33
|
+
transform: "translateX(".concat(completionPercentage, "%)")
|
|
34
|
+
},
|
|
35
|
+
to: {
|
|
36
|
+
transform: 'translateX(100%)'
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
animationTimingFunction: 'linear',
|
|
40
|
+
display: 'inline-block',
|
|
41
|
+
content: '""',
|
|
42
|
+
width: '100%',
|
|
43
|
+
height: '100%',
|
|
44
|
+
zIndex: '1',
|
|
45
|
+
position: 'absolute',
|
|
46
|
+
backgroundColor: (0, _util.hexToRgb)($theme.colors.backgroundPrimary, '0.2')
|
|
47
|
+
}
|
|
48
|
+
} : {});
|
|
49
|
+
});
|
|
50
|
+
exports.BaseButtonTimed = BaseButtonTimed;
|
|
51
|
+
BaseButtonTimed.displayName = "BaseButtonTimed";
|
|
52
|
+
var TimerContainer = (0, _index.styled)('span', {
|
|
53
|
+
// minWidth to ensure button width stays consistent as timeRemaining changes
|
|
54
|
+
minWidth: '53px'
|
|
55
|
+
});
|
|
56
|
+
exports.TimerContainer = TimerContainer;
|
|
57
|
+
TimerContainer.displayName = "TimerContainer";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ButtonProps, ButtonOverrides } from '../button';
|
|
3
|
+
import type { Override } from '../helpers/overrides';
|
|
4
|
+
export declare type ButtonTimedOverrides = ButtonOverrides & {
|
|
5
|
+
TimerContainer?: Override;
|
|
6
|
+
};
|
|
7
|
+
export declare type ButtonTimedProps = Omit<ButtonProps, 'kind' | 'shape' | 'size' | 'onClick' | 'overrides'> & {
|
|
8
|
+
initialTime: number;
|
|
9
|
+
paused?: boolean;
|
|
10
|
+
onClick: (a?: React.SyntheticEvent<HTMLButtonElement>) => unknown;
|
|
11
|
+
overrides?: ButtonTimedOverrides;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatTime: (totalMilliseconds: number) => string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatTime = void 0;
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
Copyright (c) Uber Technologies, Inc.
|
|
10
|
+
|
|
11
|
+
This source code is licensed under the MIT license found in the
|
|
12
|
+
LICENSE file in the root directory of this source tree.
|
|
13
|
+
*/
|
|
14
|
+
function roundUpToNearestInt(num) {
|
|
15
|
+
var cleanedNum = Math.trunc(num * 10) / 10;
|
|
16
|
+
return Math.ceil(cleanedNum);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function padTo2Digits(num) {
|
|
20
|
+
return num.toString().padStart(2, '0');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var formatTime = function formatTime(totalMilliseconds) {
|
|
24
|
+
var totalSeconds = totalMilliseconds / 1000;
|
|
25
|
+
var minutes = Math.floor(totalSeconds / 60);
|
|
26
|
+
var seconds = roundUpToNearestInt(totalSeconds % 60);
|
|
27
|
+
return "".concat(minutes, ":").concat(padTo2Digits(seconds));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.formatTime = formatTime;
|
package/card/card.js.flow
CHANGED
package/card/types.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare type CardProps = {
|
|
|
31
31
|
/** Content to be rendered within the Card body. */
|
|
32
32
|
readonly children?: ReactNode;
|
|
33
33
|
/** Function that takes Card props and returns a boolean that represents if a thumbnail will be rendered. */
|
|
34
|
-
readonly hasThumbnail
|
|
34
|
+
readonly hasThumbnail?: (a: {
|
|
35
35
|
readonly thumbnail?: string;
|
|
36
36
|
}) => boolean;
|
|
37
37
|
/** Image to be positioned at the top of the Card. Can be a string representing the img src or an object with img attrs */
|
package/card/types.js.flow
CHANGED
|
@@ -41,7 +41,7 @@ export type CardsPropsT = {
|
|
|
41
41
|
/** Content to be rendered within the Card body. */
|
|
42
42
|
+children?: Node,
|
|
43
43
|
/** Function that takes Card props and returns a boolean that represents if a thumbnail will be rendered. */
|
|
44
|
-
+hasThumbnail
|
|
44
|
+
+hasThumbnail?: ({ +thumbnail?: string }) => boolean,
|
|
45
45
|
/** Image to be positioned at the top of the Card. Can be a string representing the img src or an object with img attrs */
|
|
46
46
|
+headerImage?: string | ImagePropsT,
|
|
47
47
|
+overrides: CardComponentsT,
|
package/data-table/data-table.js
CHANGED
|
@@ -476,9 +476,7 @@ var InnerTableElement = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
476
476
|
}
|
|
477
477
|
|
|
478
478
|
var RowActionIcon = rowAction.renderIcon;
|
|
479
|
-
return /*#__PURE__*/React.createElement(_button.Button
|
|
480
|
-
, {
|
|
481
|
-
alt: rowAction.label,
|
|
479
|
+
return /*#__PURE__*/React.createElement(_button.Button, {
|
|
482
480
|
key: rowAction.label,
|
|
483
481
|
onClick: function onClick(event) {
|
|
484
482
|
return rowAction.onClick({
|
|
@@ -489,6 +487,7 @@ var InnerTableElement = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
489
487
|
size: _button.SIZE.compact,
|
|
490
488
|
kind: _button.KIND.tertiary,
|
|
491
489
|
shape: _button.SHAPE.round,
|
|
490
|
+
title: rowAction.label,
|
|
492
491
|
overrides: {
|
|
493
492
|
BaseButton: {
|
|
494
493
|
style: {
|
|
@@ -756,13 +755,6 @@ function DataTable(_ref2) {
|
|
|
756
755
|
|
|
757
756
|
return result;
|
|
758
757
|
}, [sortedIndices, filteredIndices, onIncludedRowsChange, allRows]);
|
|
759
|
-
React.useImperativeHandle(controlRef, function () {
|
|
760
|
-
return {
|
|
761
|
-
getRows: function getRows() {
|
|
762
|
-
return rows;
|
|
763
|
-
}
|
|
764
|
-
};
|
|
765
|
-
}, [rows]);
|
|
766
758
|
|
|
767
759
|
var _React$useState19 = React.useState(0),
|
|
768
760
|
_React$useState20 = _slicedToArray(_React$useState19, 2),
|
|
@@ -806,13 +798,15 @@ function DataTable(_ref2) {
|
|
|
806
798
|
}
|
|
807
799
|
|
|
808
800
|
result.push(gridProps.width - sum(result) - scrollbarWidth);
|
|
809
|
-
resetAfterColumnIndex(0);
|
|
810
801
|
return result;
|
|
811
802
|
}
|
|
812
803
|
}
|
|
813
804
|
|
|
814
805
|
return resizedWidths;
|
|
815
806
|
}, [gridRef, measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
807
|
+
React.useEffect(function () {
|
|
808
|
+
resetAfterColumnIndex(0);
|
|
809
|
+
}, [normalizedWidths]);
|
|
816
810
|
var isSelectable = batchActions ? !!batchActions.length : false;
|
|
817
811
|
var isSelectedAll = React.useMemo(function () {
|
|
818
812
|
if (!selectedRowIds) {
|
|
@@ -855,6 +849,14 @@ function DataTable(_ref2) {
|
|
|
855
849
|
onSort(columnIndex);
|
|
856
850
|
}
|
|
857
851
|
}, [onSort]);
|
|
852
|
+
React.useImperativeHandle(controlRef, function () {
|
|
853
|
+
return {
|
|
854
|
+
clearSelection: handleSelectNone,
|
|
855
|
+
getRows: function getRows() {
|
|
856
|
+
return rows;
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
}, [handleSelectNone, rows]);
|
|
858
860
|
|
|
859
861
|
var _React$useState21 = React.useState(-1),
|
|
860
862
|
_React$useState22 = _slicedToArray(_React$useState21, 2),
|
|
@@ -962,7 +964,9 @@ function DataTable(_ref2) {
|
|
|
962
964
|
}
|
|
963
965
|
}, /*#__PURE__*/React.createElement(_reactWindow.VariableSizeGrid // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
964
966
|
, {
|
|
965
|
-
ref:
|
|
967
|
+
ref: function ref(node) {
|
|
968
|
+
return setGridRef(node);
|
|
969
|
+
},
|
|
966
970
|
overscanRowCount: 10,
|
|
967
971
|
overscanColumnCount: 5,
|
|
968
972
|
innerElementType: InnerTableElement,
|
|
@@ -810,8 +810,6 @@ export function DataTable({
|
|
|
810
810
|
return result;
|
|
811
811
|
}, [sortedIndices, filteredIndices, onIncludedRowsChange, allRows]);
|
|
812
812
|
|
|
813
|
-
React.useImperativeHandle(controlRef, () => ({ getRows: () => rows }), [rows]);
|
|
814
|
-
|
|
815
813
|
const [browserScrollbarWidth, setBrowserScrollbarWidth] = React.useState(0);
|
|
816
814
|
const normalizedWidths = React.useMemo(() => {
|
|
817
815
|
const resizedWidths = measuredWidths.map((w, i) => Math.floor(w) + Math.floor(resizeDeltas[i]));
|
|
@@ -902,6 +900,8 @@ export function DataTable({
|
|
|
902
900
|
[onSort]
|
|
903
901
|
);
|
|
904
902
|
|
|
903
|
+
React.useImperativeHandle(controlRef, () => ({ getRows: () => rows, clearSelection: handleSelectNone }), [handleSelectNone, rows]);
|
|
904
|
+
|
|
905
905
|
const [columnHighlightIndex, setColumnHighlightIndex] = React.useState(-1);
|
|
906
906
|
const [rowHighlightIndex, setRowHighlightIndex] = React.useState(-1);
|
|
907
907
|
|
|
@@ -49,55 +49,66 @@ function useDuplicateColumnTitleWarning(columns) {
|
|
|
49
49
|
}, [columns]);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
var initialSortDirection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
52
|
+
var StatefulContainer = function StatefulContainer(props) {
|
|
53
|
+
useDuplicateColumnTitleWarning(props.columns);
|
|
55
54
|
|
|
56
|
-
var _React$useState = React.useState(initialSortIndex),
|
|
55
|
+
var _React$useState = React.useState(typeof props.initialSortIndex === 'number' ? props.initialSortIndex : -1),
|
|
57
56
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
58
57
|
sortIndex = _React$useState2[0],
|
|
59
58
|
setSortIndex = _React$useState2[1];
|
|
60
59
|
|
|
61
|
-
var _React$useState3 = React.useState(initialSortDirection),
|
|
60
|
+
var _React$useState3 = React.useState(props.initialSortDirection),
|
|
62
61
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
63
62
|
sortDirection = _React$useState4[0],
|
|
64
63
|
setSortDirection = _React$useState4[1];
|
|
65
64
|
|
|
65
|
+
var _React$useState5 = React.useState(props.initialFilters || new Map()),
|
|
66
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
67
|
+
filters = _React$useState6[0],
|
|
68
|
+
setFilters = _React$useState6[1];
|
|
69
|
+
|
|
70
|
+
var _React$useState7 = React.useState(''),
|
|
71
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
72
|
+
textQuery = _React$useState8[0],
|
|
73
|
+
setTextQuery = _React$useState8[1];
|
|
74
|
+
|
|
75
|
+
var _React$useState9 = React.useState(props.initialSelectedRowIds || new Set()),
|
|
76
|
+
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
77
|
+
selectedRowIds = _React$useState10[0],
|
|
78
|
+
setSelectedRowIds = _React$useState10[1];
|
|
79
|
+
|
|
66
80
|
function handleSort(columnIndex) {
|
|
81
|
+
var nextSortIndex;
|
|
82
|
+
var nextSortDirection;
|
|
83
|
+
|
|
67
84
|
if (columnIndex === sortIndex) {
|
|
68
85
|
if (sortDirection === _constants.SORT_DIRECTIONS.DESC) {
|
|
69
|
-
|
|
70
|
-
|
|
86
|
+
nextSortIndex = -1;
|
|
87
|
+
nextSortDirection = _constants.SORT_DIRECTIONS.ASC;
|
|
71
88
|
} else {
|
|
72
|
-
|
|
89
|
+
nextSortIndex = columnIndex;
|
|
90
|
+
nextSortDirection = _constants.SORT_DIRECTIONS.DESC;
|
|
73
91
|
}
|
|
74
92
|
} else {
|
|
75
|
-
|
|
76
|
-
|
|
93
|
+
nextSortIndex = columnIndex;
|
|
94
|
+
nextSortDirection = _constants.SORT_DIRECTIONS.ASC;
|
|
77
95
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return [sortIndex, sortDirection, handleSort];
|
|
81
|
-
}
|
|
82
96
|
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
setSortIndex(nextSortIndex);
|
|
98
|
+
setSortDirection(nextSortDirection);
|
|
85
99
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
handleSort = _useSortParameters2[2];
|
|
100
|
+
if (props.onSort) {
|
|
101
|
+
props.onSort(nextSortIndex, nextSortDirection);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
91
104
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
filters = _React$useState6[0],
|
|
95
|
-
setFilters = _React$useState6[1];
|
|
105
|
+
function handleTextQueryChange(nextTextQuery) {
|
|
106
|
+
setTextQuery(nextTextQuery);
|
|
96
107
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
if (props.onTextQueryChange) {
|
|
109
|
+
props.onTextQueryChange(nextTextQuery);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
101
112
|
|
|
102
113
|
function handleFilterAdd(title, filterParams) {
|
|
103
114
|
filters.set(title, filterParams);
|
|
@@ -119,11 +130,6 @@ var StatefulContainer = function StatefulContainer(props) {
|
|
|
119
130
|
setFilters(new Map(filters));
|
|
120
131
|
}
|
|
121
132
|
|
|
122
|
-
var _React$useState9 = React.useState(props.initialSelectedRowIds || new Set()),
|
|
123
|
-
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
124
|
-
selectedRowIds = _React$useState10[0],
|
|
125
|
-
setSelectedRowIds = _React$useState10[1];
|
|
126
|
-
|
|
127
133
|
function handleSelectChange(next) {
|
|
128
134
|
setSelectedRowIds(next);
|
|
129
135
|
var selectionCallback = props.onSelectionChange;
|
|
@@ -176,7 +182,7 @@ var StatefulContainer = function StatefulContainer(props) {
|
|
|
176
182
|
onSelectNone: handleSelectNone,
|
|
177
183
|
onSelectOne: handleSelectOne,
|
|
178
184
|
onSort: handleSort,
|
|
179
|
-
onTextQueryChange:
|
|
185
|
+
onTextQueryChange: handleTextQueryChange,
|
|
180
186
|
resizableColumnWidths: Boolean(props.resizableColumnWidths),
|
|
181
187
|
rowHighlightIndex: props.rowHighlightIndex,
|
|
182
188
|
selectedRowIds: selectedRowIds,
|
|
@@ -221,6 +221,8 @@ function StatefulDataTable(props) {
|
|
|
221
221
|
onIncludedRowsChange: props.onIncludedRowsChange,
|
|
222
222
|
onRowHighlightChange: props.onRowHighlightChange,
|
|
223
223
|
onSelectionChange: props.onSelectionChange,
|
|
224
|
+
onSort: props.onSort,
|
|
225
|
+
onTextQueryChange: props.onTextQueryChange,
|
|
224
226
|
resizableColumnWidths: props.resizableColumnWidths,
|
|
225
227
|
rows: props.rows,
|
|
226
228
|
rowActions: props.rowActions,
|
package/data-table/types.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ export declare type RowAction = {
|
|
|
64
64
|
};
|
|
65
65
|
export declare type ImperativeMethods = {
|
|
66
66
|
getRows: () => Row[];
|
|
67
|
+
clearSelection: () => void;
|
|
67
68
|
};
|
|
68
69
|
export declare type ControlRef = {
|
|
69
70
|
current: ImperativeMethods | null;
|
|
@@ -88,6 +89,8 @@ export declare type StatefulDataTableProps = {
|
|
|
88
89
|
onIncludedRowsChange?: (rows: Row[]) => void;
|
|
89
90
|
onRowHighlightChange?: (rowIndex: number, row: Row) => void;
|
|
90
91
|
onSelectionChange?: (a: Row[]) => unknown;
|
|
92
|
+
onSort?: (columnIndex: number, sortDirection: SortDirections) => void;
|
|
93
|
+
onTextQueryChange?: (textQuery: string) => void;
|
|
91
94
|
resizableColumnWidths?: boolean;
|
|
92
95
|
rows: Row[];
|
|
93
96
|
rowActions?: RowAction[] | ((a: Row) => RowAction[]);
|