@longline/aqua-ui 1.0.183 → 1.0.186
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/containers/Dock/Dock.d.ts +7 -4
- package/containers/Dock/Dock.js +2 -1
- package/containers/Dock/Dockable.d.ts +14 -3
- package/containers/Dock/Dockable.js +45 -14
- package/containers/DragBar/DragBar.d.ts +4 -1
- package/containers/DragBar/DragBar.js +1 -0
- package/containers/GlassPane/GlassPane.d.ts +16 -4
- package/containers/GlassPane/GlassPane.js +41 -8
- package/containers/InfoBox/InfoBox.d.ts +23 -2
- package/containers/InfoBox/InfoBox.js +40 -2
- package/containers/InfoBox/elements/Content.d.ts +4 -1
- package/containers/InfoBox/elements/Content.js +1 -0
- package/containers/InfoBox/elements/Footer.d.ts +4 -1
- package/containers/InfoBox/elements/Footer.js +1 -0
- package/containers/InfoBox/elements/Header.d.ts +4 -1
- package/containers/InfoBox/elements/Header.js +2 -1
- package/containers/List/ListCell.d.ts +4 -1
- package/containers/List/ListCell.js +2 -1
- package/containers/List/ListRow.d.ts +4 -1
- package/containers/List/ListRow.js +2 -1
- package/containers/Message/Error.d.ts +4 -1
- package/containers/Message/Error.js +1 -0
- package/containers/Message/Message.d.ts +13 -3
- package/containers/Message/Message.js +2 -1
- package/containers/Message/NoData.d.ts +4 -1
- package/containers/Message/NoData.js +1 -0
- package/containers/Message/NoFilteredData.d.ts +4 -1
- package/containers/Message/NoFilteredData.js +1 -0
- package/controls/Chip/Chip.d.ts +7 -4
- package/controls/Chip/Chip.js +12 -12
- package/controls/Dropzone/Dropzone.d.ts +14 -10
- package/controls/Dropzone/Dropzone.js +88 -20
- package/controls/Fab/Fab.d.ts +7 -5
- package/controls/Fab/Fab.js +19 -18
- package/controls/FilterButton/FilterButton.d.ts +4 -5
- package/controls/FilterButton/FilterButton.js +11 -16
- package/controls/Gradient/Gradient.d.ts +8 -2
- package/controls/Gradient/Gradient.js +32 -6
- package/controls/Gradient/PresetGradients.d.ts +11 -4
- package/controls/Gradient/PresetGradients.js +7 -0
- package/controls/Icon/Icon.d.ts +7 -4
- package/controls/Icon/Icon.js +6 -5
- package/controls/Key/Key.d.ts +5 -2
- package/controls/Key/Key.js +36 -35
- package/controls/LinearChart/LinearChart.d.ts +4 -1
- package/controls/LinearChart/LinearChart.js +3 -2
- package/controls/ListView/ColumnsManager/ColumnsManager.js +1 -1
- package/controls/ListView/ListView.d.ts +2 -1
- package/controls/ListView/ListView.js +6 -5
- package/controls/ListView/NoData.d.ts +4 -1
- package/controls/ListView/NoData.js +1 -0
- package/controls/ListView/{Body.d.ts → elements/Body.d.ts} +2 -2
- package/controls/ListView/{Body.js → elements/Body.js} +1 -1
- package/controls/ListView/elements/Ghost.d.ts +12 -0
- package/controls/ListView/{Ghost.js → elements/Ghost.js} +4 -3
- package/controls/ListView/{Header.d.ts → elements/Header.d.ts} +2 -2
- package/controls/ListView/{Header.js → elements/Header.js} +3 -14
- package/controls/ListView/{HeaderButton.d.ts → elements/HeaderButton.d.ts} +4 -1
- package/controls/ListView/{HeaderButton.js → elements/HeaderButton.js} +1 -1
- package/controls/ListView/{HeaderCell.d.ts → elements/HeaderCell.d.ts} +7 -4
- package/controls/ListView/{HeaderCell.js → elements/HeaderCell.js} +5 -3
- package/controls/ListView/{SortButton.d.ts → elements/SortButton.d.ts} +1 -1
- package/controls/ListView/elements/SortButton.js +27 -0
- package/controls/ListView/{Table.d.ts → elements/Table.d.ts} +6 -3
- package/controls/ListView/{Table.js → elements/Table.js} +5 -4
- package/controls/ListView/{Total.d.ts → elements/Total.d.ts} +5 -1
- package/controls/ListView/{Total.js → elements/Total.js} +2 -1
- package/controls/Mouse/Mouse.d.ts +8 -3
- package/controls/Mouse/Mouse.js +21 -7
- package/controls/PrimaryButton/PrimaryButton.d.ts +6 -2
- package/controls/PrimaryButton/PrimaryButton.js +14 -9
- package/controls/Progress/Progress.d.ts +22 -6
- package/controls/Progress/Progress.js +38 -7
- package/controls/SecondaryButton/SecondaryButton.d.ts +12 -5
- package/controls/SecondaryButton/SecondaryButton.js +29 -19
- package/controls/TabBar/Tab.js +1 -1
- package/controls/TabBar/TabBar.d.ts +15 -4
- package/controls/TabBar/TabBar.js +105 -10
- package/controls/TabBar/Underliner.js +2 -1
- package/controls/TertiaryButton/TertiaryButton.d.ts +4 -1
- package/controls/TertiaryButton/TertiaryButton.js +3 -8
- package/controls/View/EllipsizedContent.d.ts +4 -1
- package/controls/View/EllipsizedContent.js +14 -1
- package/controls/View/ScrollingContent.d.ts +4 -1
- package/controls/View/ScrollingContent.js +14 -1
- package/controls/View/View.d.ts +6 -1
- package/controls/View/View.js +5 -4
- package/formatters/DateTime/DateTime.d.ts +46 -8
- package/formatters/DateTime/DateTime.js +14 -10
- package/formatters/DateTime/elements/Custom.d.ts +6 -17
- package/formatters/DateTime/elements/Custom.js +1 -0
- package/formatters/DateTime/elements/DistanceDate.d.ts +14 -0
- package/formatters/DateTime/elements/{Distance.js → DistanceDate.js} +1 -0
- package/formatters/DateTime/elements/LongDate.d.ts +23 -13
- package/formatters/DateTime/elements/LongDate.js +31 -5
- package/formatters/DateTime/elements/LongDateTime.d.ts +29 -13
- package/formatters/DateTime/elements/LongDateTime.js +28 -1
- package/formatters/DateTime/elements/LongTime.d.ts +25 -13
- package/formatters/DateTime/elements/LongTime.js +23 -1
- package/formatters/DateTime/elements/ShortDate.d.ts +27 -13
- package/formatters/DateTime/elements/ShortDate.js +28 -1
- package/formatters/DateTime/elements/ShortDateTime.d.ts +27 -13
- package/formatters/DateTime/elements/ShortDateTime.js +28 -1
- package/formatters/DateTime/elements/ShortTime.d.ts +13 -12
- package/formatters/DateTime/elements/ShortTime.js +19 -5
- package/formatters/DateTime/elements/index.d.ts +8 -0
- package/formatters/DateTime/elements/index.js +8 -0
- package/formatters/Filesize/Filesize.d.ts +23 -14
- package/formatters/Filesize/Filesize.js +33 -42
- package/formatters/GIS/Latitude.d.ts +11 -5
- package/formatters/GIS/Latitude.js +26 -3
- package/formatters/GIS/Longitude.d.ts +9 -5
- package/formatters/GIS/Longitude.js +24 -3
- package/formatters/Highlight/Highlight.d.ts +21 -6
- package/formatters/Highlight/Highlight.js +37 -19
- package/formatters/Human/Human.d.ts +18 -7
- package/formatters/Human/Human.js +17 -25
- package/formatters/Number/Number.d.ts +10 -2
- package/formatters/Number/Number.js +13 -7
- package/helper/DMS.d.ts +44 -6
- package/helper/DMS.js +86 -24
- package/package.json +1 -1
- package/controls/Dropzone/Dropbox.d.ts +0 -19
- package/controls/Dropzone/Dropbox.js +0 -47
- package/controls/ListView/Ghost.d.ts +0 -9
- package/controls/ListView/SortButton.js +0 -26
- package/formatters/DateTime/elements/Distance.d.ts +0 -24
- package/formatters/GIS/toDMS.d.ts +0 -2
- package/formatters/GIS/toDMS.js +0 -16
- /package/controls/ListView/{sortItems.d.ts → elements/sortItems.d.ts} +0 -0
- /package/controls/ListView/{sortItems.js → elements/sortItems.js} +0 -0
package/controls/Mouse/Mouse.js
CHANGED
|
@@ -27,7 +27,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
27
27
|
import * as React from 'react';
|
|
28
28
|
import styled, { css } from 'styled-components';
|
|
29
29
|
var MouseBase = function (props) {
|
|
30
|
-
return (React.createElement("svg", { className: props.className, viewBox: "3 0 22 29", xmlns: "http://www.w3.org/2000/svg"
|
|
30
|
+
return (React.createElement("svg", { className: props.className, viewBox: "3 0 22 29", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true" // Hide from assistive tech (for non-interactive icons)
|
|
31
|
+
, focusable: "false" },
|
|
31
32
|
React.createElement("path", { d: "M14 1.75623C8.69307 1.75623 4.375 6.07429 4.375 11.3812V18.3812C4.375 23.6882 8.69307 28.0062 14 28.0062C19.3069 28.0062 23.625 23.6882 23.625 18.3812V11.3812C23.625 6.07429 19.3069 1.75623 14 1.75623ZM21.875 11.3812V12.2562H16.625V10.5062C16.625 9.36653 15.8911 8.40403 14.875 8.04199V3.55756C18.806 3.99506 21.875 7.33546 21.875 11.3812ZM14 9.63123C14.4834 9.63123 14.875 10.0239 14.875 10.5062V13.1312C14.875 13.6136 14.4834 14.0062 14 14.0062C13.5166 14.0062 13.125 13.6136 13.125 13.1312V10.5062C13.125 10.0239 13.5166 9.63123 14 9.63123ZM6.125 11.3812C6.125 7.33546 9.19403 3.99389 13.125 3.55779V8.04223C12.1089 8.40427 11.375 9.36677 11.375 10.5065V12.2565H6.125V11.3812ZM14 26.2562C9.65767 26.2562 6.125 22.7236 6.125 18.3812V14.0062H11.5358C11.8978 15.0223 12.8603 15.7562 14 15.7562C15.1397 15.7562 16.1022 15.0223 16.4642 14.0062H21.875V18.3812C21.875 22.7236 18.3423 26.2562 14 26.2562Z", fill: props.color }),
|
|
32
33
|
props.left && React.createElement("path", { className: "left", d: "M13.125 3.55798C9.19403 3.99408 6.125 7.33565 6.125 11.3814V12.2567H11.375V10.5067C11.375 9.36696 12.1089 8.40446 13.125 8.04242V3.55798Z" }),
|
|
33
34
|
props.right && React.createElement("path", { className: "right", d: "M21.875 12.2562V11.3812C21.875 7.33539 18.806 3.995 14.875 3.5575V8.04193C15.8911 8.40397 16.625 9.36647 16.625 10.5062V12.2562H21.875Z" }),
|
|
@@ -35,17 +36,30 @@ var MouseBase = function (props) {
|
|
|
35
36
|
};
|
|
36
37
|
var MouseStyled = styled(MouseBase)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n max-height: 100px;\n fill: ", ";\n .left { fill: ", "; }\n .right { fill: ", "; }\n .wheel { fill: ", "; }\n"], ["\n ", "\n max-height: 100px;\n fill: ", ";\n .left { fill: ", "; }\n .right { fill: ", "; }\n .wheel { fill: ", "; }\n"
|
|
37
38
|
/**
|
|
38
|
-
* `Mouse`
|
|
39
|
-
*
|
|
39
|
+
* `Mouse` Renders an SVG mouse shape with optional highlighting of the
|
|
40
|
+
* left, right, and wheel buttons.
|
|
41
|
+
*
|
|
42
|
+
* - `left`, `right`, `wheel`: Whether each button appears "pressed"
|
|
43
|
+
* - `color`: Main mouse fill color (defaults to theme neutral color)
|
|
44
|
+
* - `accent`: Fill color of the wheel (defaults to primary theme color)
|
|
45
|
+
* - `size`: Scales the mouse height in pixels
|
|
40
46
|
*/
|
|
41
47
|
])), function (p) { return p.size && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: ", "px;\n "], ["\n height: ", "px;\n "])), p.size); }, function (p) { var _a; return (_a = p.color) !== null && _a !== void 0 ? _a : p.theme.colors.neutral[100]; }, function (p) { var _a; return (_a = p.color) !== null && _a !== void 0 ? _a : p.theme.colors.neutral[100]; }, function (p) { var _a; return (_a = p.color) !== null && _a !== void 0 ? _a : p.theme.colors.neutral[100]; }, function (p) { var _a; return (_a = p.accent) !== null && _a !== void 0 ? _a : p.theme.colors.primary[1]; });
|
|
42
48
|
/**
|
|
43
|
-
* `Mouse`
|
|
44
|
-
*
|
|
49
|
+
* `Mouse` Renders an SVG mouse shape with optional highlighting of the
|
|
50
|
+
* left, right, and wheel buttons.
|
|
51
|
+
*
|
|
52
|
+
* - `left`, `right`, `wheel`: Whether each button appears "pressed"
|
|
53
|
+
* - `color`: Main mouse fill color (defaults to theme neutral color)
|
|
54
|
+
* - `accent`: Fill color of the wheel (defaults to primary theme color)
|
|
55
|
+
* - `size`: Scales the mouse height in pixels
|
|
45
56
|
*/
|
|
46
|
-
var Mouse = function (_a) {
|
|
57
|
+
var Mouse = React.memo(function (_a) {
|
|
47
58
|
var _b = _a.left, left = _b === void 0 ? false : _b, _c = _a.right, right = _c === void 0 ? false : _c, _d = _a.wheel, wheel = _d === void 0 ? false : _d, props = __rest(_a, ["left", "right", "wheel"]);
|
|
59
|
+
// Component is pure and based solely on props. Wrapping it with React.memo
|
|
60
|
+
// helps avoid unnecessary re-renders:
|
|
48
61
|
return React.createElement(MouseStyled, __assign({ left: left, right: right, wheel: wheel }, props));
|
|
49
|
-
};
|
|
62
|
+
});
|
|
63
|
+
Mouse.displayName = "Mouse";
|
|
50
64
|
export { Mouse };
|
|
51
65
|
var templateObject_1, templateObject_2;
|
|
@@ -39,7 +39,8 @@ interface IProps {
|
|
|
39
39
|
*/
|
|
40
40
|
icon?: string | IIconProps;
|
|
41
41
|
/**
|
|
42
|
-
* Fired when the button is clicked.
|
|
42
|
+
* Fired when the button is clicked. The React MouseEvent is passed in,
|
|
43
|
+
* in case the calling code wants to stop event propagation.
|
|
43
44
|
*/
|
|
44
45
|
onClick: (e?: React.MouseEvent) => void;
|
|
45
46
|
}
|
|
@@ -55,5 +56,8 @@ interface IProps {
|
|
|
55
56
|
* with `positive`, `negative` or `color`. The button can be in a `disabled`
|
|
56
57
|
* state where it cannot be clicked.
|
|
57
58
|
*/
|
|
58
|
-
declare const PrimaryButton:
|
|
59
|
+
declare const PrimaryButton: {
|
|
60
|
+
({ disabled, positive, negative, ...props }: IProps): React.JSX.Element;
|
|
61
|
+
displayName: string;
|
|
62
|
+
};
|
|
59
63
|
export { PrimaryButton, IProps };
|
|
@@ -25,19 +25,23 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
25
25
|
return t;
|
|
26
26
|
};
|
|
27
27
|
import * as React from 'react';
|
|
28
|
-
import styled, { css } from 'styled-components';
|
|
28
|
+
import styled, { css, useTheme } from 'styled-components';
|
|
29
29
|
import { darken } from '../../helper/darken';
|
|
30
30
|
import { Icon } from '../Icon';
|
|
31
31
|
var PrimaryButtonBase = function (props) {
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (props.
|
|
36
|
-
|
|
32
|
+
var theme = useTheme();
|
|
33
|
+
var icon = function () {
|
|
34
|
+
// No icon?
|
|
35
|
+
if (!props.icon)
|
|
36
|
+
return null;
|
|
37
|
+
// If a string was provided, use it as the URL for the icon.
|
|
38
|
+
if (typeof props.icon === "string")
|
|
39
|
+
return React.createElement(Icon, { color: theme.colors.neutral[100], url: props.icon });
|
|
40
|
+
// An IIconProps was provided. Use it as the props for the icon.
|
|
41
|
+
return React.createElement(Icon, __assign({ color: theme.colors.neutral[100] }, props.icon));
|
|
37
42
|
};
|
|
38
|
-
return (React.createElement("button", {
|
|
39
|
-
|
|
40
|
-
props.icon && typeof props.icon != "string" && React.createElement(Icon, __assign({}, props.icon)),
|
|
43
|
+
return (React.createElement("button", { className: props.className, type: "button", onClick: props.onClick, title: props.title, "aria-disabled": props.disabled, disabled: props.disabled },
|
|
44
|
+
icon(),
|
|
41
45
|
props.children));
|
|
42
46
|
};
|
|
43
47
|
var PrimaryButtonStyled = styled(PrimaryButtonBase).attrs(function (p) {
|
|
@@ -80,5 +84,6 @@ var PrimaryButton = function (_a) {
|
|
|
80
84
|
var _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.positive, positive = _c === void 0 ? false : _c, _d = _a.negative, negative = _d === void 0 ? false : _d, props = __rest(_a, ["disabled", "positive", "negative"]);
|
|
81
85
|
return React.createElement(PrimaryButtonStyled, __assign({ disabled: disabled, positive: positive, negative: negative }, props));
|
|
82
86
|
};
|
|
87
|
+
PrimaryButton.displayName = "PrimaryButton";
|
|
83
88
|
export { PrimaryButton };
|
|
84
89
|
var templateObject_1, templateObject_2;
|
|
@@ -3,21 +3,25 @@ interface IProps {
|
|
|
3
3
|
/** @ignore */
|
|
4
4
|
className?: string;
|
|
5
5
|
/**
|
|
6
|
-
* Progress value
|
|
6
|
+
* Progress value to display, clamped between `0` and `100`.
|
|
7
|
+
* Determines how much of the bar is filled.
|
|
7
8
|
*/
|
|
8
9
|
value: number;
|
|
9
10
|
/**
|
|
10
|
-
* If
|
|
11
|
+
* If `true`, displays the numeric percentage value centered over the
|
|
12
|
+
* progress bar. Useful for accessible or visually informative UIs.
|
|
11
13
|
* @default false
|
|
12
14
|
*/
|
|
13
15
|
numbered?: boolean;
|
|
14
16
|
/**
|
|
15
|
-
*
|
|
17
|
+
* If `true`, adds a 10px margin around the progress bar.
|
|
18
|
+
* Helpful when spacing is needed between multiple bars or surrounding content.
|
|
16
19
|
* @default false
|
|
17
20
|
*/
|
|
18
21
|
padded?: boolean;
|
|
19
22
|
/**
|
|
20
|
-
*
|
|
23
|
+
* Thickness of the progress bar in pixels.
|
|
24
|
+
* Adjusts both the container height and corner radius.
|
|
21
25
|
* @default 5
|
|
22
26
|
*/
|
|
23
27
|
thickness?: number;
|
|
@@ -28,8 +32,20 @@ interface IProps {
|
|
|
28
32
|
color?: string;
|
|
29
33
|
}
|
|
30
34
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
35
|
+
* A visual progress bar component that shows completion of a task, range, or
|
|
36
|
+
* metric.
|
|
37
|
+
*
|
|
38
|
+
* - Automatically clamps `value` between `0` and `100`.
|
|
39
|
+
* - Fully responsive and stretches to available width.
|
|
40
|
+
* - Animated bar fill when `value` changes.
|
|
41
|
+
* - Optionally displays percentage value text.
|
|
42
|
+
*
|
|
43
|
+
* The bar always stretches to fill all horizontal space available to it.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <Progress value={45} numbered color="#00c2a8" thickness={8} />
|
|
48
|
+
* ```
|
|
33
49
|
*/
|
|
34
50
|
declare const Progress: ({ thickness, numbered, padded, ...props }: IProps) => React.JSX.Element;
|
|
35
51
|
export { Progress, IProps };
|
|
@@ -26,20 +26,51 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
26
26
|
};
|
|
27
27
|
import * as React from 'react';
|
|
28
28
|
import styled, { css } from 'styled-components';
|
|
29
|
+
/**
|
|
30
|
+
* Input value may be less than 0 or more than 100.
|
|
31
|
+
* Clamp it.
|
|
32
|
+
*/
|
|
33
|
+
var getClampedValue = function (value) {
|
|
34
|
+
return Math.round(Math.min(100, Math.max(0, value)));
|
|
35
|
+
};
|
|
29
36
|
var ProgressBase = function (props) {
|
|
30
|
-
return React.createElement("div", { className: props.className });
|
|
37
|
+
return React.createElement("div", { className: props.className, role: "progressbar", "area-valuenow": getClampedValue(props.value), "area-valuemin": 0, "area-valuemax": 100 });
|
|
31
38
|
};
|
|
32
39
|
var ProgressStyled = styled(ProgressBase).attrs(function (p) { return ({
|
|
33
|
-
percentageStr:
|
|
40
|
+
percentageStr: getClampedValue(p.value).toString() + '%'
|
|
34
41
|
}); })(templateObject_3 || (templateObject_3 = __makeTemplateObject([" \n position: relative; \n box-sizing: border-box;\n height: ", "px;\n min-width: 100px;\n margin: 4px 0 4px 0;\n\n ", "\n background-color: ", ";\n border-radius: ", "px;\n \n &:before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: ", ";\n height: 100%;\n box-sizing: border-box;\n transition: width ", "ms ease;\n background-color: ", ";\n border-radius: ", "px;\n }\n\n ", "\n"], [" \n position: relative; \n box-sizing: border-box;\n height: ", "px;\n min-width: 100px;\n margin: 4px 0 4px 0;\n\n ", "\n background-color: ", ";\n border-radius: ", "px;\n \n &:before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: ", ";\n height: 100%;\n box-sizing: border-box;\n transition: width ", "ms ease;\n background-color: ", ";\n border-radius: ", "px;\n }\n\n ", "\n"
|
|
35
42
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
43
|
+
* A visual progress bar component that shows completion of a task, range, or
|
|
44
|
+
* metric.
|
|
45
|
+
*
|
|
46
|
+
* - Automatically clamps `value` between `0` and `100`.
|
|
47
|
+
* - Fully responsive and stretches to available width.
|
|
48
|
+
* - Animated bar fill when `value` changes.
|
|
49
|
+
* - Optionally displays percentage value text.
|
|
50
|
+
*
|
|
51
|
+
* The bar always stretches to fill all horizontal space available to it.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* <Progress value={45} numbered color="#00c2a8" thickness={8} />
|
|
56
|
+
* ```
|
|
38
57
|
*/
|
|
39
|
-
])), function (p) { return p.thickness; }, function (p) { return p.padded && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["margin: 10px;"], ["margin: 10px;"]))); }, function (p) { return p.theme.colors.neutral[50]; }, function (p) { return p.thickness / 2; }, function (p) { return p.value
|
|
58
|
+
])), function (p) { return p.thickness; }, function (p) { return p.padded && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["margin: 10px;"], ["margin: 10px;"]))); }, function (p) { return p.theme.colors.neutral[50]; }, function (p) { return p.thickness / 2; }, function (p) { return "".concat(p.value, "%"); }, function (p) { return p.theme.animation.duration * 2; }, function (p) { var _a; return (_a = p.color) !== null && _a !== void 0 ? _a : p.theme.colors.primary[1]; }, function (p) { return p.thickness / 2; }, function (p) { return p.numbered && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:after {\n content: '", "';\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n font-size: 8px;\n line-height: 0;\n color: ", ";\n text-shadow: 0px 0px 4px #000;\n }\n "], ["\n &:after {\n content: '", "';\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n font-size: 8px;\n line-height: 0;\n color: ", ";\n text-shadow: 0px 0px 4px #000;\n }\n "])), p.percentageStr, function (p) { return p.theme.colors.neutral[100]; }); });
|
|
40
59
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
60
|
+
* A visual progress bar component that shows completion of a task, range, or
|
|
61
|
+
* metric.
|
|
62
|
+
*
|
|
63
|
+
* - Automatically clamps `value` between `0` and `100`.
|
|
64
|
+
* - Fully responsive and stretches to available width.
|
|
65
|
+
* - Animated bar fill when `value` changes.
|
|
66
|
+
* - Optionally displays percentage value text.
|
|
67
|
+
*
|
|
68
|
+
* The bar always stretches to fill all horizontal space available to it.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```tsx
|
|
72
|
+
* <Progress value={45} numbered color="#00c2a8" thickness={8} />
|
|
73
|
+
* ```
|
|
43
74
|
*/
|
|
44
75
|
var Progress = function (_a) {
|
|
45
76
|
var _b = _a.thickness, thickness = _b === void 0 ? 5 : _b, _c = _a.numbered, numbered = _c === void 0 ? false : _c, _d = _a.padded, padded = _d === void 0 ? false : _d, props = __rest(_a, ["thickness", "numbered", "padded"]);
|
|
@@ -33,22 +33,29 @@ interface IProps {
|
|
|
33
33
|
color?: string;
|
|
34
34
|
/**
|
|
35
35
|
* Optional browser tooltip to show when the button is hovered. This may
|
|
36
|
-
* be relevant since this type of button has no text.
|
|
36
|
+
* be relevant since this type of button has no text. This is also used
|
|
37
|
+
* as an aria-label, so it is mandatory (since the button has no icon).
|
|
37
38
|
*/
|
|
38
|
-
title
|
|
39
|
+
title: string;
|
|
39
40
|
/**
|
|
40
|
-
* Fired when the button is clicked.
|
|
41
|
+
* Fired when the button is clicked. The synthetic React click event
|
|
42
|
+
* is passed along so that callers may stop event propagation.
|
|
41
43
|
*/
|
|
42
44
|
onClick: (e?: React.MouseEvent) => void;
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
45
47
|
* The `SecondaryButton` is a small button that holds only an icon. It has no
|
|
46
|
-
* other content. It renders as a `<button>` element.
|
|
48
|
+
* other content. It renders as a `<button>` element. Although the button
|
|
49
|
+
* shows only an icon, its `title` attribute is mandatory, and used as
|
|
50
|
+
* a `aria-label`, so screenreaders can understand the button's purpose.
|
|
47
51
|
*
|
|
48
52
|
* The color of the button defaults to a neutral theme color, unless overridden
|
|
49
53
|
* with `positive`, `negative` or `color`.
|
|
50
54
|
*
|
|
51
55
|
* A `disabled` button cannot be clicked at all.
|
|
52
56
|
*/
|
|
53
|
-
declare const SecondaryButton:
|
|
57
|
+
declare const SecondaryButton: {
|
|
58
|
+
({ disabled, positive, negative, ...props }: IProps): React.JSX.Element;
|
|
59
|
+
displayName: string;
|
|
60
|
+
};
|
|
54
61
|
export { SecondaryButton, IProps };
|
|
@@ -25,41 +25,50 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
25
25
|
return t;
|
|
26
26
|
};
|
|
27
27
|
import * as React from 'react';
|
|
28
|
-
import styled, { css } from 'styled-components';
|
|
28
|
+
import styled, { css, useTheme } from 'styled-components';
|
|
29
29
|
import { Icon } from '../Icon';
|
|
30
30
|
var SecondaryButtonBase = function (props) {
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
var theme = useTheme();
|
|
32
|
+
return (React.createElement("button", { type: "button", className: props.className, disabled: props.disabled, onClick: props.onClick, title: props.title, "aria-label": props.title },
|
|
33
|
+
React.createElement(Icon, __assign({ color: theme.colors.neutral[100] }, (typeof props.icon === 'string' ? { url: props.icon } : props.icon)))));
|
|
34
|
+
};
|
|
35
|
+
//
|
|
36
|
+
// Determine button background color.
|
|
37
|
+
//
|
|
38
|
+
var getBackgroundColor = function (props) {
|
|
39
|
+
var disabled = props.disabled, positive = props.positive, negative = props.negative, color = props.color, theme = props.theme;
|
|
40
|
+
if (disabled)
|
|
41
|
+
return theme.colors.neutral[50];
|
|
42
|
+
if (positive)
|
|
43
|
+
return theme.colors.positive;
|
|
44
|
+
if (negative)
|
|
45
|
+
return theme.colors.negative;
|
|
46
|
+
if (color)
|
|
47
|
+
return color;
|
|
48
|
+
return theme.colors.neutral[10];
|
|
40
49
|
};
|
|
41
50
|
var SecondaryButtonStyled = styled(SecondaryButtonBase).attrs(function (p) {
|
|
42
51
|
return {
|
|
43
|
-
backgroundColor: p
|
|
44
|
-
: p.positive ? p.theme.colors.positive
|
|
45
|
-
: p.negative ? p.theme.colors.negative
|
|
46
|
-
: p.color ? p.color
|
|
47
|
-
: p.theme.colors.neutral[10]
|
|
52
|
+
$backgroundColor: getBackgroundColor(p)
|
|
48
53
|
};
|
|
49
|
-
})(templateObject_3 || (templateObject_3 = __makeTemplateObject([" \n // Size:\n height: 32px;\n width: 32px;\n\n // Presentation:\n background-color: ", ";\n // (Note that there is no hover state.)\n transition: \n background-color ease-in-out ", "ms, \n box-shadow ease-in-out ", "ms;\n border-radius: ", "px;\n border: none;\n cursor: pointer;\n user-select: none;\n outline: none;\n box-shadow: ", ";\n\n // Content alignment:\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n white-space: nowrap;\n\n &:hover {\n box-shadow: ", ";\n }\n\n &:focus {\n outline: solid 2px ", ";\n }\n\n // Button changes background &
|
|
54
|
+
})(templateObject_3 || (templateObject_3 = __makeTemplateObject([" \n // Size:\n height: 32px;\n width: 32px;\n\n // Presentation:\n background-color: ", ";\n // (Note that there is no hover state.)\n transition: \n background-color ease-in-out ", "ms, \n box-shadow ease-in-out ", "ms;\n border-radius: ", "px;\n border: none;\n cursor: pointer;\n user-select: none;\n outline: none;\n box-shadow: ", ";\n\n // Content alignment:\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n white-space: nowrap;\n\n &:hover {\n box-shadow: ", ";\n }\n\n &:focus {\n outline: solid 2px ", ";\n }\n\n // Button changes background & removes dropshadow when pressed:\n &:active {\n // Button background stays the same in case of color buttons:\n ", "\n box-shadow: none;\n }\n\n svg {\n width: 13px;\n height: 13px;\n } \n\n ", "\n"], [" \n // Size:\n height: 32px;\n width: 32px;\n\n // Presentation:\n background-color: ", ";\n // (Note that there is no hover state.)\n transition: \n background-color ease-in-out ", "ms, \n box-shadow ease-in-out ", "ms;\n border-radius: ", "px;\n border: none;\n cursor: pointer;\n user-select: none;\n outline: none;\n box-shadow: ", ";\n\n // Content alignment:\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n white-space: nowrap;\n\n &:hover {\n box-shadow: ", ";\n }\n\n &:focus {\n outline: solid 2px ", ";\n }\n\n // Button changes background & removes dropshadow when pressed:\n &:active {\n // Button background stays the same in case of color buttons:\n ", "\n box-shadow: none;\n }\n\n svg {\n width: 13px;\n height: 13px;\n } \n\n ", "\n"
|
|
50
55
|
/**
|
|
51
56
|
* The `SecondaryButton` is a small button that holds only an icon. It has no
|
|
52
|
-
* other content. It renders as a `<button>` element.
|
|
57
|
+
* other content. It renders as a `<button>` element. Although the button
|
|
58
|
+
* shows only an icon, its `title` attribute is mandatory, and used as
|
|
59
|
+
* a `aria-label`, so screenreaders can understand the button's purpose.
|
|
53
60
|
*
|
|
54
61
|
* The color of the button defaults to a neutral theme color, unless overridden
|
|
55
62
|
* with `positive`, `negative` or `color`.
|
|
56
63
|
*
|
|
57
64
|
* A `disabled` button cannot be clicked at all.
|
|
58
65
|
*/
|
|
59
|
-
])), function (p) { return p
|
|
66
|
+
])), function (p) { return p.$backgroundColor; }, function (p) { return p.theme.animation.duration; }, function (p) { return p.theme.animation.duration; }, function (p) { return p.theme.radius.normal; }, function (p) { return p.theme.shadows.small; }, function (p) { return p.theme.shadows.medium; }, function (p) { return p.theme.colors.primary[1]; }, function (p) { return !p.positive && !p.negative && !p.color && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["background-color: ", ";"], ["background-color: ", ";"])), p.theme.colors.neutral[10]); }, function (p) { return p.disabled && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n cursor: auto;\n pointer-events: none;\n box-shadow: none;\n svg {\n fill: ", ";\n }\n "], ["\n cursor: auto;\n pointer-events: none;\n box-shadow: none;\n svg {\n fill: ", ";\n }\n "])), p.theme.colors.primary[3]); });
|
|
60
67
|
/**
|
|
61
68
|
* The `SecondaryButton` is a small button that holds only an icon. It has no
|
|
62
|
-
* other content. It renders as a `<button>` element.
|
|
69
|
+
* other content. It renders as a `<button>` element. Although the button
|
|
70
|
+
* shows only an icon, its `title` attribute is mandatory, and used as
|
|
71
|
+
* a `aria-label`, so screenreaders can understand the button's purpose.
|
|
63
72
|
*
|
|
64
73
|
* The color of the button defaults to a neutral theme color, unless overridden
|
|
65
74
|
* with `positive`, `negative` or `color`.
|
|
@@ -70,5 +79,6 @@ var SecondaryButton = function (_a) {
|
|
|
70
79
|
var _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.positive, positive = _c === void 0 ? false : _c, _d = _a.negative, negative = _d === void 0 ? false : _d, props = __rest(_a, ["disabled", "positive", "negative"]);
|
|
71
80
|
return React.createElement(SecondaryButtonStyled, __assign({ disabled: disabled, positive: positive, negative: negative }, props));
|
|
72
81
|
};
|
|
82
|
+
SecondaryButton.displayName = "SecondaryButton";
|
|
73
83
|
export { SecondaryButton };
|
|
74
84
|
var templateObject_1, templateObject_2, templateObject_3;
|
package/controls/TabBar/Tab.js
CHANGED
|
@@ -16,7 +16,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
16
16
|
import * as React from 'react';
|
|
17
17
|
import styled, { css } from 'styled-components';
|
|
18
18
|
var TabBase = React.forwardRef(function (props, ref) {
|
|
19
|
-
return React.createElement("div", { className: props.className, ref: ref, onClick: props.onClick }, props.children);
|
|
19
|
+
return React.createElement("div", { role: "tab", "aria-selected": props.active, className: props.className, ref: ref, onClick: props.onClick }, props.children);
|
|
20
20
|
});
|
|
21
21
|
var TabStyled = styled(TabBase)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: table-cell;\n vertical-align: middle;\n text-align: center;\n white-space: nowrap;\n padding: 0 20px;\n\n font: ", ";\n box-sizing: border-box;\n ", "\n height: 40px;\n z-index: 1;\n cursor: pointer;\n color: ", ";\n transition: color ", "ms ease-in-out;\n\n /* User cannot select header text.\n * This prevents accidental selection when clicking the tab.\n */\n user-select: none; \n\n ", " \n &:hover {\n color: ", ";\n }\n"], ["\n display: table-cell;\n vertical-align: middle;\n text-align: center;\n white-space: nowrap;\n padding: 0 20px;\n\n font: ", ";\n box-sizing: border-box;\n ", "\n height: 40px;\n z-index: 1;\n cursor: pointer;\n color: ", ";\n transition: color ", "ms ease-in-out;\n\n /* User cannot select header text.\n * This prevents accidental selection when clicking the tab.\n */\n user-select: none; \n\n ", " \n &:hover {\n color: ", ";\n }\n"])), function (p) { return p.theme.font.labelLarge; }, function (p) { return p.tabWidth && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["min-width: ", "px;"], ["min-width: ", "px;"])), p.tabWidth); }, function (p) { return p.theme.colors.neutral[80]; }, function (p) { return p.theme.animation.duration; }, function (p) { return p.active && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), function (p) { return p.theme.colors.neutral[100]; }); }, function (p) { return p.theme.colors.neutral[100]; });
|
|
22
22
|
var Tab = React.forwardRef(function (props, ref) { return React.createElement(TabStyled, __assign({ ref: ref }, props)); });
|
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { Tab } from './Tab';
|
|
2
3
|
interface IProps {
|
|
3
4
|
/** @ignore */
|
|
4
5
|
className?: string;
|
|
5
6
|
/**
|
|
6
7
|
* Children must be of type `TabBar.Tab`.
|
|
8
|
+
* @ignore
|
|
7
9
|
*/
|
|
8
|
-
children?: React.
|
|
10
|
+
children?: React.ReactElement<typeof Tab> | React.ReactElement<typeof Tab>[];
|
|
9
11
|
/**
|
|
10
|
-
*
|
|
12
|
+
* The zero-based index of the currently active tab.
|
|
13
|
+
* When not provided, the first tab (index 0) is active by default.
|
|
14
|
+
*
|
|
15
|
+
* Changing this prop will update the active tab.
|
|
16
|
+
*
|
|
11
17
|
* @default 0
|
|
12
18
|
*/
|
|
13
19
|
active?: number;
|
|
14
20
|
/**
|
|
15
|
-
*
|
|
21
|
+
* Optional fixed width (in pixels) to assign each tab.
|
|
22
|
+
* If omitted, tabs use fluid widths.
|
|
16
23
|
*/
|
|
17
24
|
tabWidth?: number;
|
|
18
25
|
/**
|
|
19
|
-
*
|
|
26
|
+
* Callback fired when the active tab changes due to user interaction.
|
|
27
|
+
* The argument is the zero-based index of the newly activated tab.
|
|
28
|
+
*
|
|
29
|
+
* @param idx - The index of the new active tab.
|
|
20
30
|
*/
|
|
21
31
|
onChange?: (idx: number) => void;
|
|
22
32
|
}
|
|
@@ -30,5 +40,6 @@ interface IProps {
|
|
|
30
40
|
declare const TabBar: {
|
|
31
41
|
({ active, ...props }: IProps): React.JSX.Element;
|
|
32
42
|
Tab: React.ForwardRefExoticComponent<import("./Tab").IProps & React.RefAttributes<HTMLDivElement>>;
|
|
43
|
+
displayName: string;
|
|
33
44
|
};
|
|
34
45
|
export { TabBar };
|
|
@@ -29,16 +29,33 @@ import styled from 'styled-components';
|
|
|
29
29
|
import { Tab } from './Tab';
|
|
30
30
|
import { Underliner } from './Underliner';
|
|
31
31
|
var TabBarBase = function (props) {
|
|
32
|
+
var _a;
|
|
32
33
|
// TabBar keeps its own internal "active" index state.
|
|
33
|
-
var
|
|
34
|
+
var _b = React.useState((_a = props.active) !== null && _a !== void 0 ? _a : 0), active = _b[0], setActive = _b[1];
|
|
34
35
|
var underlinerRef = React.useRef(null);
|
|
35
36
|
var barRef = React.useRef(null);
|
|
36
37
|
var sliderRef = React.useRef(null);
|
|
38
|
+
var wasDragging = React.useRef(false);
|
|
37
39
|
var dragging = React.useRef(false);
|
|
40
|
+
/**
|
|
41
|
+
* References to all the individual tab elements.
|
|
42
|
+
* Used to measure tab dimensions and positions for layout calculations
|
|
43
|
+
* and to control scroll and underliner positioning.
|
|
44
|
+
*/
|
|
45
|
+
var tabRefs = React.useRef([]);
|
|
46
|
+
/**
|
|
47
|
+
* Stores the last horizontal mouse position on screen during drag start.
|
|
48
|
+
* Used to calculate drag displacement.
|
|
49
|
+
*/
|
|
38
50
|
var mouseX = React.useRef(0);
|
|
51
|
+
/**
|
|
52
|
+
* Stores the starting left offset position of the slider at drag start.
|
|
53
|
+
* Used as baseline for calculating new slider position during dragging.
|
|
54
|
+
*/
|
|
39
55
|
var startX = React.useRef(0);
|
|
40
56
|
var handleMouseDown = function (e) {
|
|
41
57
|
dragging.current = true;
|
|
58
|
+
wasDragging.current = false; // Reset flag on fresh mouse down
|
|
42
59
|
// We store the current mouse position on the screen,
|
|
43
60
|
// as well as the current scroll position of the slider.
|
|
44
61
|
mouseX.current = e.screenX;
|
|
@@ -50,6 +67,9 @@ var TabBarBase = function (props) {
|
|
|
50
67
|
// Use the current mouse position to determine the
|
|
51
68
|
// new scroll position of the slider.
|
|
52
69
|
var dMouse = event.screenX - mouseX.current;
|
|
70
|
+
if (Math.abs(dMouse) > 5) {
|
|
71
|
+
wasDragging.current = true;
|
|
72
|
+
}
|
|
53
73
|
var x = startX.current + dMouse; // x is always a negative offset.
|
|
54
74
|
// Check scroll bounds:
|
|
55
75
|
if (x > 0)
|
|
@@ -62,6 +82,7 @@ var TabBarBase = function (props) {
|
|
|
62
82
|
};
|
|
63
83
|
var handleMouseUp = function (event) {
|
|
64
84
|
dragging.current = false;
|
|
85
|
+
setTimeout(function () { wasDragging.current = false; }, 100); // Slight delay to allow click cancel
|
|
65
86
|
};
|
|
66
87
|
React.useEffect(function () {
|
|
67
88
|
// Listen for document-wide mouseup/mousemove events when TabBar mounts.
|
|
@@ -75,33 +96,106 @@ var TabBarBase = function (props) {
|
|
|
75
96
|
document.removeEventListener('mouseup', handleMouseUp);
|
|
76
97
|
};
|
|
77
98
|
}, []);
|
|
99
|
+
//
|
|
100
|
+
// When internal active index changes, move underliner.
|
|
101
|
+
//
|
|
78
102
|
React.useEffect(function () {
|
|
79
103
|
moveUnderliner();
|
|
80
104
|
}, [active]);
|
|
105
|
+
//
|
|
106
|
+
// If active prop changes, update internal active tab index.
|
|
107
|
+
//
|
|
81
108
|
React.useEffect(function () {
|
|
82
109
|
setActive(props.active);
|
|
83
110
|
}, [props.active]);
|
|
111
|
+
//
|
|
84
112
|
// Use refs to move underliner under active tab.
|
|
113
|
+
//
|
|
85
114
|
var moveUnderliner = function () {
|
|
86
|
-
var _a
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
115
|
+
var _a;
|
|
116
|
+
var tabElements = (_a = sliderRef.current) === null || _a === void 0 ? void 0 : _a.children;
|
|
117
|
+
var target = tabElements === null || tabElements === void 0 ? void 0 : tabElements[active];
|
|
118
|
+
if (target && underlinerRef.current) {
|
|
119
|
+
underlinerRef.current.style.transform = "translateX(".concat(target.offsetLeft, "px)");
|
|
120
|
+
underlinerRef.current.style.width = "".concat(target.offsetWidth, "px");
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Ensures the tab at the specified index is fully visible inside the
|
|
125
|
+
* tab bar viewport by adjusting the slider's horizontal position.
|
|
126
|
+
*
|
|
127
|
+
* This function manually calculates whether the tab is fully in view.
|
|
128
|
+
* If the tab is partially or fully outside the visible area on either
|
|
129
|
+
* side, the slider is moved to bring the entire tab into view.
|
|
130
|
+
*
|
|
131
|
+
* The scroll animation is smooth and lasts 300ms.
|
|
132
|
+
*
|
|
133
|
+
* @param {number} index - The index of the tab to ensure visibility for.
|
|
134
|
+
*/
|
|
135
|
+
var ensureTabFullyVisible = function (index) {
|
|
136
|
+
var tabEl = tabRefs.current[index];
|
|
137
|
+
var sliderEl = sliderRef.current;
|
|
138
|
+
var barEl = barRef.current;
|
|
139
|
+
if (!tabEl || !sliderEl || !barEl)
|
|
140
|
+
return;
|
|
141
|
+
var tabLeft = tabEl.offsetLeft;
|
|
142
|
+
var tabRight = tabLeft + tabEl.offsetWidth;
|
|
143
|
+
var currentOffset = parseFloat(sliderEl.style.left) || 0;
|
|
144
|
+
var visibleLeft = -currentOffset;
|
|
145
|
+
var visibleRight = visibleLeft + barEl.offsetWidth;
|
|
146
|
+
var newOffset = currentOffset;
|
|
147
|
+
if (tabLeft < visibleLeft) {
|
|
148
|
+
// Tab is too far left
|
|
149
|
+
newOffset = -tabLeft;
|
|
150
|
+
}
|
|
151
|
+
else if (tabRight > visibleRight) {
|
|
152
|
+
// Tab is too far right
|
|
153
|
+
newOffset = -(tabRight - barEl.offsetWidth);
|
|
90
154
|
}
|
|
155
|
+
// Clamp value to slider bounds
|
|
156
|
+
var maxScroll = sliderEl.offsetWidth - barEl.offsetWidth;
|
|
157
|
+
newOffset = Math.max(Math.min(newOffset, 0), -maxScroll);
|
|
158
|
+
// Smoothly animate the scroll
|
|
159
|
+
sliderEl.style.transition = 'left 0.3s ease';
|
|
160
|
+
sliderEl.style.left = "".concat(newOffset, "px");
|
|
161
|
+
// Remove transition after animation to prevent interference with dragging
|
|
162
|
+
setTimeout(function () {
|
|
163
|
+
if (sliderEl)
|
|
164
|
+
sliderEl.style.transition = '';
|
|
165
|
+
}, 300);
|
|
91
166
|
};
|
|
167
|
+
/**
|
|
168
|
+
* Handles the tab click event.
|
|
169
|
+
*
|
|
170
|
+
* If the tab clicked is already active, this function does nothing.
|
|
171
|
+
* If a drag interaction was detected immediately before the click (to avoid
|
|
172
|
+
* confusing accidental clicks during drag), this function ignores the event.
|
|
173
|
+
*
|
|
174
|
+
* Otherwise, this function:
|
|
175
|
+
* - Adjusts the scroll position so the clicked tab is fully visible.
|
|
176
|
+
* - Updates the active tab state.
|
|
177
|
+
* - Calls the `onChange` callback with the new active index.
|
|
178
|
+
*
|
|
179
|
+
* @param {number} idx - The index of the tab clicked.
|
|
180
|
+
*/
|
|
92
181
|
var handleTabClick = function (idx) {
|
|
182
|
+
var _a;
|
|
183
|
+
// 🛑 Ignore click if it was part of a drag:
|
|
184
|
+
if (wasDragging.current)
|
|
185
|
+
return;
|
|
93
186
|
// Only of interest if active tab changes.
|
|
94
|
-
if (idx
|
|
187
|
+
if (idx === active)
|
|
95
188
|
return;
|
|
189
|
+
ensureTabFullyVisible(idx);
|
|
96
190
|
setActive(idx);
|
|
97
|
-
|
|
98
|
-
props.onChange(idx);
|
|
191
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, idx);
|
|
99
192
|
};
|
|
100
|
-
return (React.createElement("div", { className: props.className, ref: barRef },
|
|
193
|
+
return (React.createElement("div", { className: props.className, ref: barRef, "aria-orientation": "horizontal" },
|
|
101
194
|
React.createElement(Slider, { ref: sliderRef, onMouseDown: handleMouseDown },
|
|
102
195
|
React.Children.map(props.children, function (child, idx) {
|
|
103
196
|
return React.cloneElement(child, {
|
|
104
|
-
|
|
197
|
+
ref: function (el) { return tabRefs.current[idx] = el; },
|
|
198
|
+
active: active === idx,
|
|
105
199
|
tabWidth: props.tabWidth,
|
|
106
200
|
onClick: function () { return handleTabClick(idx); }
|
|
107
201
|
});
|
|
@@ -130,5 +224,6 @@ var TabBar = function (_a) {
|
|
|
130
224
|
return React.createElement(TabBarStyled, __assign({ active: active }, props));
|
|
131
225
|
};
|
|
132
226
|
TabBar.Tab = Tab;
|
|
227
|
+
TabBar.displayName = "TabBar";
|
|
133
228
|
export { TabBar };
|
|
134
229
|
var templateObject_1, templateObject_2;
|
|
@@ -21,7 +21,8 @@ var UnderlinerBase = React.forwardRef(function (props, ref) {
|
|
|
21
21
|
/**
|
|
22
22
|
* Underliner passes a reference to itself back to its parent.
|
|
23
23
|
*/
|
|
24
|
-
var UnderlinerStyled = styled(UnderlinerBase)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n left: 0;\n top: 38px;\n width: 0px;\n height: 0px;\n border-top: solid 4px ", ";\n box-sizing: border-box;\n transition:
|
|
24
|
+
var UnderlinerStyled = styled(UnderlinerBase)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n // Position and size:\n position: absolute;\n left: 0;\n top: 38px;\n width: 0px;\n height: 0px;\n // Appearance:\n border-top: solid 4px ", ";\n box-sizing: border-box;\n transition: transform ease .3s, width ease .3s;\n"], ["\n // Position and size:\n position: absolute;\n left: 0;\n top: 38px;\n width: 0px;\n height: 0px;\n // Appearance:\n border-top: solid 4px ", ";\n box-sizing: border-box;\n transition: transform ease .3s, width ease .3s;\n"])), function (p) { return p.theme.colors.primary[1]; });
|
|
25
25
|
var Underliner = React.forwardRef(function (props, ref) { return React.createElement(UnderlinerStyled, __assign({ ref: ref }, props)); });
|
|
26
|
+
Underliner.displayName = "Underliner";
|
|
26
27
|
export { Underliner };
|
|
27
28
|
var templateObject_1;
|
|
@@ -24,5 +24,8 @@ interface IProps {
|
|
|
24
24
|
* There is no support for icons (although the React children of the component
|
|
25
25
|
* could force one in).
|
|
26
26
|
*/
|
|
27
|
-
declare const TertiaryButton:
|
|
27
|
+
declare const TertiaryButton: {
|
|
28
|
+
({ disabled, ...props }: IProps): React.JSX.Element;
|
|
29
|
+
displayName: string;
|
|
30
|
+
};
|
|
28
31
|
export { TertiaryButton, IProps };
|