@longline/aqua-ui 1.0.111 → 1.0.113
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/controls/Chip/Chip.js +1 -1
- package/controls/FilterButton/FilterButton.d.ts +36 -0
- package/controls/FilterButton/FilterButton.js +63 -0
- package/controls/FilterButton/index.d.ts +1 -0
- package/controls/FilterButton/index.js +1 -0
- package/modules/Filter/Filter.d.ts +16 -0
- package/modules/Filter/Filter.js +79 -0
- package/modules/Filter/index.d.ts +1 -0
- package/modules/Filter/index.js +1 -0
- package/package.json +1 -1
package/controls/Chip/Chip.js
CHANGED
|
@@ -60,7 +60,7 @@ var ChipStyled = styled(ChipBase)(templateObject_2 || (templateObject_2 = __make
|
|
|
60
60
|
* is not a string but JSX. If `verticalAlign` is enabled, the Chip
|
|
61
61
|
* content is no longer ellipsized.
|
|
62
62
|
*/
|
|
63
|
-
])), function (p) { return p.theme.colors.
|
|
63
|
+
])), function (p) { return p.theme.colors.neutral[10]; }, function (p) { return p.theme.colors.neutral[100]; }, function (p) { return p.theme.font.labelSmall; }, function (p) { return p.theme.animation.duration; }, function (p) { return p.theme.animation.duration; }, function (p) { return p.theme.colors.neutral[50]; }, function (p) { return p.theme.colors.primary[1]; }, function (p) { return p.theme.colors.primary[2]; }, function (p) { return p.theme.colors.neutral[100]; }, function (p) { return p.theme.colors.primary[1]; }, function (p) { return p.theme.colors.neutral[100]; }, function (p) { return p.disabled && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n pointer-events: none;\n cursor: auto;\n background-color: ", ";\n color: ", ";\n & > svg {\n fill: ", ";\n }\n "], ["\n pointer-events: none;\n cursor: auto;\n background-color: ", ";\n color: ", ";\n & > svg {\n fill: ", ";\n }\n "])), function (p) { return p.theme.colors.neutral[50]; }, function (p) { return p.theme.colors.primary[3]; }, function (p) { return p.theme.colors.primary[3]; }); });
|
|
64
64
|
/**
|
|
65
65
|
* A set of `Chip` instances show consecutive user inputs and are individually
|
|
66
66
|
* deselected. The "X" on a `Chip` is clickable. A `Chip` can have keyboard focus:
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface IProps {
|
|
3
|
+
/** @ignore */
|
|
4
|
+
className?: string;
|
|
5
|
+
/**
|
|
6
|
+
* A disabled button cannot be interacted with. This is implemented using
|
|
7
|
+
* `pointer-events: none`.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Optional browser tooltip to show when the button is hovered.
|
|
13
|
+
*/
|
|
14
|
+
title?: string;
|
|
15
|
+
/**
|
|
16
|
+
* A button in an `active` state is highlighted.
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
active?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* A button in an `open` state is shown as depressed.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
open?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Fired when the button is clicked.
|
|
27
|
+
*/
|
|
28
|
+
onClick: (e?: React.MouseEvent) => void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A `FilterButton` is a button that can be in a depressed state, in order
|
|
32
|
+
* to show that a filter is currently active. It should be combined with
|
|
33
|
+
* a pane to select filter options.
|
|
34
|
+
*/
|
|
35
|
+
declare const FilterButton: React.ForwardRefExoticComponent<IProps & React.RefAttributes<HTMLButtonElement>>;
|
|
36
|
+
export { FilterButton, IProps };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
+
var t = {};
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
+
t[p[i]] = s[p[i]];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
import * as React from 'react';
|
|
28
|
+
import styled, { css } from 'styled-components';
|
|
29
|
+
import { Icon } from '../Icon';
|
|
30
|
+
import { SVG } from '../../svg';
|
|
31
|
+
var FilterButtonBase = React.forwardRef(function (props, ref) {
|
|
32
|
+
var handleClick = function (e) {
|
|
33
|
+
if (props.disabled)
|
|
34
|
+
return;
|
|
35
|
+
if (props.onClick)
|
|
36
|
+
props.onClick(e);
|
|
37
|
+
};
|
|
38
|
+
return (React.createElement("button", { ref: ref, tabIndex: props.disabled ? -1 : 0, className: props.className, onClick: handleClick, title: props.title },
|
|
39
|
+
React.createElement(Icon, { url: SVG.Icons.Filter })));
|
|
40
|
+
});
|
|
41
|
+
var FilterButtonStyled = styled(FilterButtonBase).attrs(function (p) {
|
|
42
|
+
return {
|
|
43
|
+
iconColor: p.disabled ? p.theme.colors.primary[2]
|
|
44
|
+
: p.theme.colors.neutral[100]
|
|
45
|
+
};
|
|
46
|
+
})(templateObject_4 || (templateObject_4 = __makeTemplateObject([" \n position: relative;\n // Size:\n height: 34px;\n\n // Presentation:\n background-color: ", ";\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 &:hover {\n box-shadow: ", ";\n }\n &:active {\n background-color: ", " !important;\n box-shadow: ", ", ", ";\n }\n\n &:focus {\n outline: solid 2px ", ";\n }\n\n // Content alignment:\n display: flex;\n flex-direction: row;\n justify-content: start;\n align-items: center;\n\n svg {\n fill: ", ";\n width: 24px !important;\n max-width: 24px;\n height: 24px !important;\n max-height: 24px;\n } \n\n // Special active state overrides other states:\n ", "\n\n // Special open state overrides other states:\n ", " \n\n ", "\n"], [" \n position: relative;\n // Size:\n height: 34px;\n\n // Presentation:\n background-color: ", ";\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 &:hover {\n box-shadow: ", ";\n }\n &:active {\n background-color: ", " !important;\n box-shadow: ", ", ", ";\n }\n\n &:focus {\n outline: solid 2px ", ";\n }\n\n // Content alignment:\n display: flex;\n flex-direction: row;\n justify-content: start;\n align-items: center;\n\n svg {\n fill: ", ";\n width: 24px !important;\n max-width: 24px;\n height: 24px !important;\n max-height: 24px;\n } \n\n // Special active state overrides other states:\n ", "\n\n // Special open state overrides other states:\n ", " \n\n ", "\n"
|
|
47
|
+
/**
|
|
48
|
+
* A `FilterButton` is a button that can be in a depressed state, in order
|
|
49
|
+
* to show that a filter is currently active. It should be combined with
|
|
50
|
+
* a pane to select filter options.
|
|
51
|
+
*/
|
|
52
|
+
])), function (p) { return p.theme.colors.primary[1]; }, 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.large; }, function (p) { return p.theme.shadows.medium; }, function (p) { return p.theme.colors.primary[4]; }, function (p) { return function (p) { return p.theme.shadows.inner; }; }, function (p) { return p.theme.shadows.medium; }, function (p) { return p.theme.colors.neutral[100]; }, function (p) { return p.iconColor; }, function (p) { return p.active && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background-color: ", ";\n svg { fill: ", "; }\n "], ["\n background-color: ", ";\n svg { fill: ", "; }\n "])), p.theme.colors.accent, p.theme.colors.neutral[100]); }, function (p) { return p.open && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", " !important;\n box-shadow: ", ";\n &:hover {\n box-shadow: ", ";\n }\n "], ["\n background-color: ", " !important;\n box-shadow: ", ";\n &:hover {\n box-shadow: ", ";\n }\n "])), function (p) { return p.theme.colors.primary[4]; }, function (p) { return p.theme.shadows.inner; }, function (p) { return p.theme.shadows.inner; }); }, function (p) { return p.disabled && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n cursor: auto;\n pointer-events: none;\n background-color: ", ";\n box-shadow: none;\n svg {\n fill: ", ";\n }\n "], ["\n cursor: auto;\n pointer-events: none;\n background-color: ", ";\n box-shadow: none;\n svg {\n fill: ", ";\n }\n "])), p.theme.colors.neutral[50], p.theme.colors.primary[3]); });
|
|
53
|
+
/**
|
|
54
|
+
* A `FilterButton` is a button that can be in a depressed state, in order
|
|
55
|
+
* to show that a filter is currently active. It should be combined with
|
|
56
|
+
* a pane to select filter options.
|
|
57
|
+
*/
|
|
58
|
+
var FilterButton = React.forwardRef(function (_a, ref) {
|
|
59
|
+
var _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.active, active = _c === void 0 ? false : _c, props = __rest(_a, ["disabled", "active"]);
|
|
60
|
+
return React.createElement(FilterButtonStyled, __assign({ ref: ref, disabled: disabled, active: active }, props));
|
|
61
|
+
});
|
|
62
|
+
export { FilterButton };
|
|
63
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FilterButton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FilterButton';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface IProps {
|
|
3
|
+
/** @ignore */
|
|
4
|
+
className?: string;
|
|
5
|
+
/** @ignore */
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
/** Is filter in an active state? Is any filtering current active? */
|
|
8
|
+
active?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A `Filter` is a combination of a filter button and a panel. The panel is
|
|
12
|
+
* shown as a React portal in order to rise above all other content and not
|
|
13
|
+
* be clipped.
|
|
14
|
+
*/
|
|
15
|
+
declare const Filter: (props: IProps) => React.JSX.Element;
|
|
16
|
+
export { Filter };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import * as React from 'react';
|
|
17
|
+
import styled from 'styled-components';
|
|
18
|
+
import { createPortal } from 'react-dom';
|
|
19
|
+
import { usePopper } from 'react-popper';
|
|
20
|
+
import { FilterButton } from '../../controls/FilterButton';
|
|
21
|
+
import { GlassPane } from '../../containers/GlassPane';
|
|
22
|
+
var FilterBase = function (props) {
|
|
23
|
+
var buttonRef = React.useRef(null);
|
|
24
|
+
var paneRef = React.useRef(null);
|
|
25
|
+
var _a = React.useState(false), open = _a[0], setOpen = _a[1];
|
|
26
|
+
React.useEffect(function () {
|
|
27
|
+
// Listen for document-wide mousedown/keydown events when panel mounts.
|
|
28
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
29
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
30
|
+
return function () {
|
|
31
|
+
// Clean up document-wide mousedown/keydown events when panel unmounts.
|
|
32
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
33
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
var handleClickOutside = function (e) {
|
|
37
|
+
var elem = e.target;
|
|
38
|
+
if (buttonRef.current && paneRef.current && !buttonRef.current.contains(elem) && !paneRef.current.contains(elem)) {
|
|
39
|
+
setOpen(false);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var handleKeyDown = function (e) {
|
|
43
|
+
if (e.key == 'Escape')
|
|
44
|
+
setOpen(false);
|
|
45
|
+
};
|
|
46
|
+
var _b = usePopper(buttonRef.current, paneRef.current, {
|
|
47
|
+
placement: 'bottom-end',
|
|
48
|
+
modifiers: [
|
|
49
|
+
{
|
|
50
|
+
name: 'offset',
|
|
51
|
+
options: {
|
|
52
|
+
offset: [0, 8],
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}), styles = _b.styles, attributes = _b.attributes;
|
|
57
|
+
var toggleOpen = function () {
|
|
58
|
+
setOpen(!open);
|
|
59
|
+
};
|
|
60
|
+
return (React.createElement("div", { className: props.className },
|
|
61
|
+
React.createElement(FilterButton, { ref: buttonRef, active: props.active, open: open, onClick: toggleOpen }),
|
|
62
|
+
createPortal(React.createElement(Pane, __assign({ "$open": open, style: styles.popper }, attributes.popper, { ref: paneRef }),
|
|
63
|
+
React.createElement(GlassPane, { padded: true, bordered: true }, props.children)), document.body)));
|
|
64
|
+
};
|
|
65
|
+
var Pane = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: ", ";\n min-width: 200px;\n z-index: 2500;\n"], ["\n display: ", ";\n min-width: 200px;\n z-index: 2500;\n"
|
|
66
|
+
/**
|
|
67
|
+
* A `Filter` is a combination of a filter button and a panel. The panel is
|
|
68
|
+
* shown as a React portal in order to rise above all other content and not
|
|
69
|
+
* be clipped.
|
|
70
|
+
*/
|
|
71
|
+
])), function (p) { return p.$open ? 'block' : 'none'; });
|
|
72
|
+
/**
|
|
73
|
+
* A `Filter` is a combination of a filter button and a panel. The panel is
|
|
74
|
+
* shown as a React portal in order to rise above all other content and not
|
|
75
|
+
* be clipped.
|
|
76
|
+
*/
|
|
77
|
+
var Filter = function (props) { return React.createElement(FilterBase, __assign({}, props)); };
|
|
78
|
+
export { Filter };
|
|
79
|
+
var templateObject_1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Filter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Filter';
|