@longline/aqua-ui 1.0.110 → 1.0.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,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;
@@ -40,61 +40,39 @@ var ItemBase = function (props) {
40
40
  var _b = useSpring(function () { return ({
41
41
  from: { maxWidth: BUTTON_SIZE }
42
42
  }); }), springs = _b[0], api = _b[1];
43
- // If active is set to on, we must disable animation and collaps the button.
44
- React.useEffect(function () {
45
- if (props.active == true) {
46
- api.start({
47
- from: {
48
- maxWidth: BUTTON_SIZE,
49
- },
50
- to: {
51
- maxWidth: BUTTON_SIZE,
52
- },
53
- config: {
54
- mass: 1,
55
- tension: 170,
56
- friction: 26,
57
- damping: 1,
58
- precision: 0.01
59
- }
60
- });
61
- }
62
- }, [props.active]);
63
43
  var handleMouseEnter = function () {
64
- if (!props.active)
65
- api.start({
66
- from: {
67
- maxWidth: BUTTON_SIZE,
68
- },
69
- to: {
70
- maxWidth: content.current.scrollWidth + 24 + 13,
71
- },
72
- config: {
73
- mass: 1,
74
- tension: 400,
75
- friction: 20,
76
- damping: 1,
77
- precision: 0.01
78
- }
79
- });
44
+ api.start({
45
+ from: {
46
+ maxWidth: BUTTON_SIZE,
47
+ },
48
+ to: {
49
+ maxWidth: content.current.scrollWidth + 24 + 13,
50
+ },
51
+ config: {
52
+ mass: 1,
53
+ tension: 400,
54
+ friction: 20,
55
+ damping: 1,
56
+ precision: 0.01
57
+ }
58
+ });
80
59
  };
81
60
  var handleMouseLeave = function () {
82
- if (!props.active)
83
- api.start({
84
- from: {
85
- maxWidth: content.current.scrollWidth + 24 + 13,
86
- },
87
- to: {
88
- maxWidth: BUTTON_SIZE,
89
- },
90
- config: {
91
- mass: 1,
92
- tension: 170,
93
- friction: 26,
94
- damping: 1,
95
- precision: 0.01
96
- }
97
- });
61
+ api.start({
62
+ from: {
63
+ maxWidth: content.current.scrollWidth + 24 + 13,
64
+ },
65
+ to: {
66
+ maxWidth: BUTTON_SIZE,
67
+ },
68
+ config: {
69
+ mass: 1,
70
+ tension: 170,
71
+ friction: 26,
72
+ damping: 1,
73
+ precision: 0.01
74
+ }
75
+ });
98
76
  };
99
77
  return (React.createElement("div", { tabIndex: -1, className: props.className, onMouseEnter: !props.noExpand ? handleMouseEnter : null, onMouseLeave: !props.noExpand ? handleMouseLeave : null, onClick: (_a = props.onClick) !== null && _a !== void 0 ? _a : null },
100
78
  React.createElement(Animatable, { style: __assign({}, springs) },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longline/aqua-ui",
3
- "version": "1.0.110",
3
+ "version": "1.0.112",
4
4
  "description": "AquaUI",
5
5
  "author": "Alexander van Oostenrijk / Longline Environment",
6
6
  "license": "Commercial",