@longline/aqua-ui 1.0.269 → 1.0.271

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.
@@ -29,7 +29,7 @@ import styled, { css } from 'styled-components';
29
29
  import { SVG } from '../../svg';
30
30
  var ChipBase = function (props) {
31
31
  var handleKeyDown = function (e) {
32
- // A disable chip doesn't listen to the keyboard.
32
+ // A disabled chip doesn't listen to the keyboard.
33
33
  if (props.disabled)
34
34
  return;
35
35
  // Pressing Delete or Backspace fires the onClick event.
@@ -44,7 +44,7 @@ var ChipBase = function (props) {
44
44
  React.createElement("svg", null,
45
45
  React.createElement("use", { xlinkHref: SVG.Icons.Cross })))));
46
46
  };
47
- var ChipStyled = styled(ChipBase)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n // Dimensions:\n min-width: 80px;\n max-width: 150px;\n width: auto;\n height: 24px;\n padding: 0 3px 0 12px;\n\n // Appearance:\n background-color: ", ";\n border: none;\n color: ", ";\n border-radius: 12px;\n user-select: none;\n outline: none;\n\n display: inline-flex;\n align-items: center;\n gap: 4px; // Gap between content and \"X\".\n margin-right: 2px; \n\n // Spacing from previous Chip.\n & + & {\n margin-left: 2px;\n }\n\n font: ", ";\n\n span.inner {\n flex: 1;\n overflow-x: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n pointer-events: none;\n }\n\n & > button {\n border: none;\n background: transparent;\n outline: none;\n padding: none;\n margin: none;\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n }\n\n & > button {\n svg {\n transition: fill ", "ms ease-in-out,\n background-color ", "ms ease-in-out;\n fill: ", ";\n box-sizing: border-box;\n width: 18px;\n height: 18px;\n padding: 2px;\n border-radius: 50%;\n cursor: pointer;\n }\n }\n\n &:focus {\n outline: solid 2px ", ";;\n }\n\n // When Chip is hovered, svg is colored.\n &:hover {\n & button > svg {\n background-color: ", ";\n fill: ", ";\n }\n }\n\n & > button svg:active {\n background-color: ", ";\n fill: ", ";\n }\n\n ", "\n"], ["\n // Dimensions:\n min-width: 80px;\n max-width: 150px;\n width: auto;\n height: 24px;\n padding: 0 3px 0 12px;\n\n // Appearance:\n background-color: ", ";\n border: none;\n color: ", ";\n border-radius: 12px;\n user-select: none;\n outline: none;\n\n display: inline-flex;\n align-items: center;\n gap: 4px; // Gap between content and \"X\".\n margin-right: 2px; \n\n // Spacing from previous Chip.\n & + & {\n margin-left: 2px;\n }\n\n font: ", ";\n\n span.inner {\n flex: 1;\n overflow-x: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n pointer-events: none;\n }\n\n & > button {\n border: none;\n background: transparent;\n outline: none;\n padding: none;\n margin: none;\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n }\n\n & > button {\n svg {\n transition: fill ", "ms ease-in-out,\n background-color ", "ms ease-in-out;\n fill: ", ";\n box-sizing: border-box;\n width: 18px;\n height: 18px;\n padding: 2px;\n border-radius: 50%;\n cursor: pointer;\n }\n }\n\n &:focus {\n outline: solid 2px ", ";;\n }\n\n // When Chip is hovered, svg is colored.\n &:hover {\n & button > svg {\n background-color: ", ";\n fill: ", ";\n }\n }\n\n & > button svg:active {\n background-color: ", ";\n fill: ", ";\n }\n\n ", "\n"
47
+ var ChipStyled = styled(ChipBase)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n // Dimensions:\n min-width: 80px;\n max-width: 150px;\n width: auto;\n height: 24px;\n padding: 0 3px 0 12px;\n\n // Appearance:\n background-color: ", ";\n border: none;\n color: ", ";\n border-radius: 12px;\n user-select: none;\n outline: none;\n\n display: inline-flex;\n align-items: center;\n gap: 4px; // Gap between content and \"X\".\n margin-right: 2px; \n\n // Spacing from previous Chip.\n & + & {\n margin-left: 2px;\n }\n\n font: ", ";\n\n span.inner {\n flex: 1;\n overflow-x: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n pointer-events: none;\n }\n\n & > button {\n border: none;\n background: transparent;\n outline: none;\n padding: none;\n margin: none;\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n }\n\n & > button {\n svg {\n transition: fill ", "ms ease-in-out,\n background-color ", "ms ease-in-out;\n fill: ", ";\n box-sizing: border-box;\n width: 18px;\n height: 18px;\n padding: 2px;\n border-radius: 50%;\n cursor: pointer;\n }\n }\n\n &:focus {\n outline: solid 2px ", ";\n }\n\n // When Chip is hovered, svg is colored.\n &:hover {\n & button > svg {\n background-color: ", ";\n fill: ", ";\n }\n }\n\n & > button svg:active {\n background-color: ", ";\n fill: ", ";\n }\n\n ", "\n"], ["\n // Dimensions:\n min-width: 80px;\n max-width: 150px;\n width: auto;\n height: 24px;\n padding: 0 3px 0 12px;\n\n // Appearance:\n background-color: ", ";\n border: none;\n color: ", ";\n border-radius: 12px;\n user-select: none;\n outline: none;\n\n display: inline-flex;\n align-items: center;\n gap: 4px; // Gap between content and \"X\".\n margin-right: 2px; \n\n // Spacing from previous Chip.\n & + & {\n margin-left: 2px;\n }\n\n font: ", ";\n\n span.inner {\n flex: 1;\n overflow-x: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n pointer-events: none;\n }\n\n & > button {\n border: none;\n background: transparent;\n outline: none;\n padding: none;\n margin: none;\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n }\n\n & > button {\n svg {\n transition: fill ", "ms ease-in-out,\n background-color ", "ms ease-in-out;\n fill: ", ";\n box-sizing: border-box;\n width: 18px;\n height: 18px;\n padding: 2px;\n border-radius: 50%;\n cursor: pointer;\n }\n }\n\n &:focus {\n outline: solid 2px ", ";\n }\n\n // When Chip is hovered, svg is colored.\n &:hover {\n & button > svg {\n background-color: ", ";\n fill: ", ";\n }\n }\n\n & > button svg:active {\n background-color: ", ";\n fill: ", ";\n }\n\n ", "\n"
48
48
  /**
49
49
  * A set of `Chip` instances show consecutive user inputs and are individually
50
50
  * deselected. The "X" on a `Chip` is clickable. A `Chip` can have keyboard focus:
@@ -77,11 +77,12 @@ import { usePopper } from 'react-popper';
77
77
  // Other controls
78
78
  import { Column } from './Column';
79
79
  import { Body } from './Body';
80
- import { Selector } from './Selector';
80
+ import { Selection } from './Selection';
81
81
  import { Pill } from './Pill';
82
82
  import { ListRow } from '../../containers/List/ListRow';
83
83
  import { ListCell } from '../../containers/List';
84
84
  import { useOutsideClose } from '../../hooks/useOutsideClose';
85
+ import { Selector } from '../Selector';
85
86
  var sameWidth = {
86
87
  name: "sameWidth",
87
88
  enabled: true,
@@ -284,21 +285,17 @@ var DropdownBase = function (props) {
284
285
  e.stopPropagation();
285
286
  // Is this a multiple-selection dropdown?
286
287
  if (props.multiple) {
287
- var array = value;
288
- if (array == null)
289
- array = [];
288
+ var array = Array.isArray(value) ? value : [];
290
289
  // Compare the new item with the existing selection items
291
290
  // using deep comparision.
292
291
  var newItem_1 = JSON.stringify(item);
293
292
  if (array.find(function (x) { return JSON.stringify(x) == newItem_1; })) {
294
- // Item already in selection. Just re-set the
295
- // existing selection.
296
- updateValueAndClose(array);
293
+ // Item already in selection. Remove it from the selection.
294
+ updateValue(__spreadArray([], array.filter(function (x) { return x !== item; }), true));
297
295
  }
298
296
  else {
299
297
  // Item not in selection. Add it.
300
- array.push(item);
301
- updateValueAndClose(array);
298
+ updateValue(__spreadArray(__spreadArray([], array, true), [item], false));
302
299
  }
303
300
  }
304
301
  // Not a multiple-selection dropdown. Simply
@@ -345,9 +342,11 @@ var DropdownBase = function (props) {
345
342
  });
346
343
  var activeIndex = (props.data || []).indexOf(value);
347
344
  return (props.data || []).map(function (row, index) {
348
- return (React.createElement(ListRow, { active: index == activeIndex, key: index + 1, gap: props.gap, onClick: function (e) { return handleClick(e, row); } }, columns.map(function (child, index) {
349
- return (React.createElement(ListCell, { key: index, width: child.props.width, align: child.props.align }, row !== null && child.props.children(row)));
350
- })));
345
+ return (React.createElement(ListRow, { active: index == activeIndex, key: index + 1, gap: props.gap, onClick: function (e) { return handleClick(e, row); } },
346
+ props.multiple && React.createElement(Selector, { locked: true, checked: Array.isArray(value) && value.find(function (x) { return JSON.stringify(x) == JSON.stringify(row); }) }),
347
+ columns.map(function (child, index) {
348
+ return (React.createElement(ListCell, { key: index, width: child.props.width, align: child.props.align }, row !== null && child.props.children(row)));
349
+ })));
351
350
  });
352
351
  };
353
352
  // Determine label:
@@ -395,7 +394,7 @@ var DropdownBase = function (props) {
395
394
  ]
396
395
  }), styles = _d.styles, attributes = _d.attributes, update = _d.update;
397
396
  return (React.createElement("div", { className: props.className, tabIndex: props.disabled ? -1 : 0, ref: wrapperRef, onKeyDown: handleKeyDown, onClick: handleClickDropdown },
398
- React.createElement(Selector, { open: open, error: props.error, disabled: props.disabled, transparent: props.transparent, ghost: props.ghost, multiple: props.multiple, onClick: handleSelectorClicked, onClear: (props.clearable && !showPlaceholder) ? handleClear : null, placeholder: showPlaceholder }, label),
397
+ React.createElement(Selection, { open: open, error: props.error, disabled: props.disabled, transparent: props.transparent, ghost: props.ghost, multiple: props.multiple, onClick: handleSelectorClicked, onClear: (props.clearable && !showPlaceholder) ? handleClear : null, placeholder: showPlaceholder }, label),
399
398
  createPortal(React.createElement(Body, { ref: bodyRef, open: open, transparent: props.transparent, maxItems: props.maxItems, onSearch: props.onSearch ? handleSearch : null, search: search, tall: props.tall, minBodyWidth: props.minBodyWidth, styles: styles, attributes: attributes }, children), document.body)));
400
399
  };
401
400
  var DropdownStyled = styled(DropdownBase)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n // Dropdown has a minimum width. \n width: 250px;\n // A fluid Dropdown occupies full horizontal width. \n ", " \n outline: none;\n user-select: none;\n font: ", ";\n color: ", ";\n"], ["\n position: relative;\n // Dropdown has a minimum width. \n width: 250px;\n // A fluid Dropdown occupies full horizontal width. \n ", " \n outline: none;\n user-select: none;\n font: ", ";\n color: ", ";\n"
@@ -23,5 +23,5 @@ interface IProps {
23
23
  /** Fired when clear icon is clicked. */
24
24
  onClear?: () => void;
25
25
  }
26
- declare const Selector: (props: IProps) => React.JSX.Element;
27
- export { Selector };
26
+ declare const Selection: (props: IProps) => React.JSX.Element;
27
+ export { Selection };
@@ -0,0 +1,16 @@
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
+ import * as React from 'react';
6
+ import styled, { css } from 'styled-components';
7
+ // Helpers
8
+ import { SVG } from '../../svg';
9
+ import { InputWrapper } from '../Input/InputWrapper';
10
+ var Selection = function (props) {
11
+ return (React.createElement(InputWrapper, { fluid: true, ghost: props.ghost, error: props.error, disabled: props.disabled, transparent: props.transparent, onClick: props.onClick, onClear: props.onClear, icon: props.onClear ? null : SVG.Icons.Caret, iconPosition: 'right' },
12
+ React.createElement(Inner, { tabIndex: -1, "$multiple": props.multiple, "$placeholder": props.placeholder }, props.children)));
13
+ };
14
+ var Inner = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 100%;\n outline: none;\n overflow-x: hidden;\n overflow-y: hidden;\n white-space: nowrap;\n ", " \n // Multiple selections use a flexbox for individual overflows: \n ", "\n // Add ellipsis to selection text:\n ", " \n"], ["\n width: 100%;\n outline: none;\n overflow-x: hidden;\n overflow-y: hidden;\n white-space: nowrap;\n ", " \n // Multiple selections use a flexbox for individual overflows: \n ", "\n // Add ellipsis to selection text:\n ", " \n"])), function (p) { return p.$placeholder && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: rgb(from ", " r g b / 50%);\n "], ["\n color: rgb(from ", " r g b / 50%);\n "])), function (p) { return p.theme.colors.primary[3]; }); }, function (p) { return p.$multiple && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n "], ["\n display: flex;\n "]))); }, function (p) { return !p.$multiple && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["text-overflow: ellipsis;"], ["text-overflow: ellipsis;"]))); });
15
+ export { Selection };
16
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
@@ -11,6 +11,11 @@ interface ISelectorProps {
11
11
  * Is this a radio button?
12
12
  */
13
13
  radio?: boolean;
14
+ /**
15
+ * A locked `Selector` cannot be interacted with. This is similar do
16
+ * `disabled`, but a `locked` Selector doesn't change its appearance.
17
+ */
18
+ locked?: boolean;
14
19
  /**
15
20
  * A disabled `Selector` cannot be interacted with.
16
21
  * @default false
@@ -68,7 +68,7 @@ var SelectorStyled = styled(SelectorBase)(templateObject_2 || (templateObject_2
68
68
  /**
69
69
  * A Selector can be used to create either a HTML checkbox or a HTML radio button.
70
70
  */
71
- ])), function (p) { return p.disabled ? 'none' : 'all'; }, function (p) { return p.disabled ? 'auto' : 'pointer'; }, function (p) { return p.theme.colors.neutral[100]; }, function (p) { return p.disabled && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: #aaa;\n "], ["\n color: #aaa;\n "]))); });
71
+ ])), function (p) { return (p.disabled || p.locked) ? 'none' : 'all'; }, function (p) { return p.disabled ? 'auto' : 'pointer'; }, function (p) { return p.theme.colors.neutral[100]; }, function (p) { return p.disabled && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: #aaa;\n "], ["\n color: #aaa;\n "]))); });
72
72
  /**
73
73
  * A Selector can be used to create either a HTML checkbox or a HTML radio button.
74
74
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longline/aqua-ui",
3
- "version": "1.0.269",
3
+ "version": "1.0.271",
4
4
  "description": "AquaUI",
5
5
  "author": "Alexander van Oostenrijk / Longline Environment",
6
6
  "license": "Commercial",
@@ -1,16 +0,0 @@
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
- import * as React from 'react';
6
- import styled, { css } from 'styled-components';
7
- // Helpers
8
- import { SVG } from '../../svg';
9
- import { InputWrapper } from '../Input/InputWrapper';
10
- var Selector = function (props) {
11
- return (React.createElement(InputWrapper, { fluid: true, ghost: props.ghost, error: props.error, disabled: props.disabled, transparent: props.transparent, onClick: props.onClick, onClear: props.onClear, icon: props.onClear ? null : SVG.Icons.Caret, iconPosition: 'right' },
12
- React.createElement(Selection, { tabIndex: -1, "$multiple": props.multiple, "$placeholder": props.placeholder }, props.children)));
13
- };
14
- var Selection = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 100%;\n outline: none;\n overflow-x: hidden;\n overflow-y: hidden;\n white-space: nowrap;\n ", " \n // Multiple selections use a flexbox for individual overflows: \n ", "\n // Add ellipsis to selection text:\n ", " \n"], ["\n width: 100%;\n outline: none;\n overflow-x: hidden;\n overflow-y: hidden;\n white-space: nowrap;\n ", " \n // Multiple selections use a flexbox for individual overflows: \n ", "\n // Add ellipsis to selection text:\n ", " \n"])), function (p) { return p.$placeholder && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: rgb(from ", " r g b / 50%);\n "], ["\n color: rgb(from ", " r g b / 50%);\n "])), function (p) { return p.theme.colors.primary[3]; }); }, function (p) { return p.$multiple && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n "], ["\n display: flex;\n "]))); }, function (p) { return !p.$multiple && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["text-overflow: ellipsis;"], ["text-overflow: ellipsis;"]))); });
15
- export { Selector };
16
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4;