@longline/aqua-ui 1.0.119 → 1.0.121
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/Form/Field.js +1 -1
- package/inputs/Dropdown/Dropdown.js +14 -4
- package/inputs/Dropdown/Pill.d.ts +11 -0
- package/inputs/Dropdown/Pill.js +23 -0
- package/inputs/Dropdown/Selector.js +2 -2
- package/package.json +1 -1
- package/inputs/Dropdown/Selection.d.ts +0 -11
- package/inputs/Dropdown/Selection.js +0 -23
package/containers/Form/Field.js
CHANGED
|
@@ -149,7 +149,7 @@ var Field = function (props) {
|
|
|
149
149
|
if (hasError && validation)
|
|
150
150
|
return React.createElement(Hint, { ghost: ghost, error: true }, validation);
|
|
151
151
|
if (props.hint)
|
|
152
|
-
return React.createElement(Hint, { optional:
|
|
152
|
+
return React.createElement(Hint, { optional: !!props.rules || !props.rules.required, ghost: ghost }, props.hint);
|
|
153
153
|
return null;
|
|
154
154
|
};
|
|
155
155
|
var dirty = form ? form.dirty : !pristine;
|
|
@@ -78,7 +78,7 @@ import { usePopper } from 'react-popper';
|
|
|
78
78
|
import { Column } from './Column';
|
|
79
79
|
import { Body } from './Body';
|
|
80
80
|
import { Selector } from './Selector';
|
|
81
|
-
import {
|
|
81
|
+
import { Pill } from './Pill';
|
|
82
82
|
import { ListRow } from '../../containers/List/ListRow';
|
|
83
83
|
import { ListCell } from '../../containers/List';
|
|
84
84
|
var sameWidth = {
|
|
@@ -210,7 +210,12 @@ var DropdownBase = function (props) {
|
|
|
210
210
|
prevIndex = 0;
|
|
211
211
|
if (props.data.length <= prevIndex)
|
|
212
212
|
return;
|
|
213
|
-
|
|
213
|
+
if (props.multiple) { // Multiple replaces entire selection with one-element array
|
|
214
|
+
updateValue([props.data[prevIndex]]);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
updateValue(props.data[prevIndex]);
|
|
218
|
+
}
|
|
214
219
|
bodyRef.current.children[0].children[0].children[prevIndex].scrollIntoView({ block: 'start', inline: 'nearest' });
|
|
215
220
|
};
|
|
216
221
|
var selectNextItem = function () {
|
|
@@ -219,7 +224,12 @@ var DropdownBase = function (props) {
|
|
|
219
224
|
var nextIndex = props.data.indexOf(value) + 1;
|
|
220
225
|
if (props.data.length <= nextIndex)
|
|
221
226
|
return;
|
|
222
|
-
|
|
227
|
+
if (props.multiple) { // Multiple replaces entire selection with one-element array
|
|
228
|
+
updateValue([props.data[nextIndex]]);
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
updateValue(props.data[nextIndex]);
|
|
232
|
+
}
|
|
223
233
|
bodyRef.current.children[0].children[0].children[nextIndex].scrollIntoView({ block: 'end', inline: 'nearest' });
|
|
224
234
|
};
|
|
225
235
|
//
|
|
@@ -372,7 +382,7 @@ var DropdownBase = function (props) {
|
|
|
372
382
|
showPlaceholder = false;
|
|
373
383
|
// Turn value elements into Selections.
|
|
374
384
|
label = value.map(function (item, index) {
|
|
375
|
-
return React.createElement(
|
|
385
|
+
return React.createElement(Pill, { key: index, onClick: function () { return handleDelete(item); } }, props.label(item));
|
|
376
386
|
});
|
|
377
387
|
}
|
|
378
388
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface IProps {
|
|
3
|
+
/** @ignore */
|
|
4
|
+
className?: string;
|
|
5
|
+
/** @ignore */
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
/** Fired when selection is clicked. */
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
}
|
|
10
|
+
declare const Pill: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<IProps, never>> & string & Omit<(props: IProps) => React.JSX.Element, keyof React.Component<any, {}, any>>;
|
|
11
|
+
export { Pill };
|
|
@@ -0,0 +1,23 @@
|
|
|
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 from 'styled-components';
|
|
7
|
+
import { SVG } from '../../svg';
|
|
8
|
+
var PillBase = function (props) {
|
|
9
|
+
// Handle clicks locally so that they don't propagate
|
|
10
|
+
// to the Selector, then send them on to the subscriber.
|
|
11
|
+
var handleClick = function (e) {
|
|
12
|
+
e.stopPropagation();
|
|
13
|
+
props.onClick();
|
|
14
|
+
};
|
|
15
|
+
return (React.createElement("div", { className: props.className, onClick: handleClick },
|
|
16
|
+
React.createElement(Text, null, props.children),
|
|
17
|
+
React.createElement("svg", null,
|
|
18
|
+
React.createElement("use", { xlinkHref: SVG.Icons.Cross }))));
|
|
19
|
+
};
|
|
20
|
+
var Text = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n overflow: hidden;\n text-overflow: ellipsis; \n"], ["\n overflow: hidden;\n text-overflow: ellipsis; \n"])));
|
|
21
|
+
var Pill = styled(PillBase)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n // Position:\n position: relative;\n margin-right: 4px;\n flex: flex-shrink;\n min-width: 60px;\n overflow: hidden;\n \n // Layout:\n display: inline-flex;\n height: 20px;\n gap: 2px;\n align-items: center;\n box-sizing: border-box;\n padding: 0 3px 0 8px;\n\n // Appearance:\n border-radius: ", "px;\n background-color: ", ";\n color: ", ";\n white-space: nowrap;\n user-select: none;\n\n &>svg {\n width: 14px;\n height: 14px; \n min-width: 14px;\n fill: ", ";\n transition: \n fill ", "ms ease,\n background-color ", "ms ease;\n border-radius: 50%;\n }\n\n transition: background-color ", "ms ease;\n &:hover {\n background-color: ", ";\n outline-offset: -1px;\n &>svg {\n fill: #fff;\n background-color: ", ";\n }\n }\n"], ["\n // Position:\n position: relative;\n margin-right: 4px;\n flex: flex-shrink;\n min-width: 60px;\n overflow: hidden;\n \n // Layout:\n display: inline-flex;\n height: 20px;\n gap: 2px;\n align-items: center;\n box-sizing: border-box;\n padding: 0 3px 0 8px;\n\n // Appearance:\n border-radius: ", "px;\n background-color: ", ";\n color: ", ";\n white-space: nowrap;\n user-select: none;\n\n &>svg {\n width: 14px;\n height: 14px; \n min-width: 14px;\n fill: ", ";\n transition: \n fill ", "ms ease,\n background-color ", "ms ease;\n border-radius: 50%;\n }\n\n transition: background-color ", "ms ease;\n &:hover {\n background-color: ", ";\n outline-offset: -1px;\n &>svg {\n fill: #fff;\n background-color: ", ";\n }\n }\n"])), function (p) { return p.theme.radius.normal; }, function (p) { return p.theme.colors.primary[2]; }, function (p) { return p.theme.colors.font; }, function (p) { return p.theme.colors.font; }, function (p) { return p.theme.animation.duration; }, function (p) { return p.theme.animation.duration; }, function (p) { return p.theme.animation.duration; }, function (p) { return p.theme.colors.negative; }, function (p) { return p.theme.colors.neutral[10]; });
|
|
22
|
+
export { Pill };
|
|
23
|
+
var templateObject_1, templateObject_2;
|
|
@@ -11,6 +11,6 @@ var Selector = function (props) {
|
|
|
11
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
12
|
React.createElement(Selection, { tabIndex: -1, "$multiple": props.multiple, "$placeholder": props.placeholder }, props.children)));
|
|
13
13
|
};
|
|
14
|
-
var Selection = styled.div(
|
|
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
15
|
export { Selector };
|
|
16
|
-
var templateObject_1, templateObject_2, templateObject_3;
|
|
16
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
interface IProps {
|
|
3
|
-
/** @ignore */
|
|
4
|
-
className?: string;
|
|
5
|
-
/** @ignore */
|
|
6
|
-
children?: React.ReactNode;
|
|
7
|
-
/** Fired when selection is clicked. */
|
|
8
|
-
onClick: () => void;
|
|
9
|
-
}
|
|
10
|
-
declare const Selection: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<IProps, never>> & string & Omit<(props: IProps) => React.JSX.Element, keyof React.Component<any, {}, any>>;
|
|
11
|
-
export { Selection };
|
|
@@ -1,23 +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 from 'styled-components';
|
|
7
|
-
import { SVG } from '../../svg';
|
|
8
|
-
var SelectionBase = function (props) {
|
|
9
|
-
// Handle clicks locally so that they don't propagate
|
|
10
|
-
// to the Selector, then send them on to the subscriber.
|
|
11
|
-
var handleClick = function (e) {
|
|
12
|
-
e.stopPropagation();
|
|
13
|
-
props.onClick();
|
|
14
|
-
};
|
|
15
|
-
// Item function is only called when item is not null.
|
|
16
|
-
return (React.createElement("div", { className: props.className, onClick: handleClick },
|
|
17
|
-
props.children,
|
|
18
|
-
React.createElement("svg", null,
|
|
19
|
-
React.createElement("use", { xlinkHref: SVG.Icons.Cross }))));
|
|
20
|
-
};
|
|
21
|
-
var Selection = styled(SelectionBase)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n display: inline-block;\n align-items: center;\n box-sizing: border-box;\n border-radius: ", "px;\n background-color: ", ";\n color: ", ";\n padding: 2px 20px 2px 8px;\n margin-right: 4px;\n white-space: nowrap;\n user-select: none;\n\n &>svg {\n position: absolute;\n right: 5px;\n top: 4px;\n width: 14px;\n height: 14px; \n fill: ", ";\n transition: fill ", "ms ease;\n }\n\n transition: background-color ", "ms ease;\n &:hover {\n background-color: ", ";\n &>svg {\n fill: #fff;\n }\n }\n\n &.item-enter {\n opacity: 0;\n }\n &.item-enter-active {\n opacity: 1;\n transition: opacity 300ms ease-in;\n }\n &.item-exit {\n opacity: 1;\n }\n &.item-exit-active {\n opacity: 0;\n transition: opacity 300ms ease-in;\n } \n"], ["\n position: relative;\n display: inline-block;\n align-items: center;\n box-sizing: border-box;\n border-radius: ", "px;\n background-color: ", ";\n color: ", ";\n padding: 2px 20px 2px 8px;\n margin-right: 4px;\n white-space: nowrap;\n user-select: none;\n\n &>svg {\n position: absolute;\n right: 5px;\n top: 4px;\n width: 14px;\n height: 14px; \n fill: ", ";\n transition: fill ", "ms ease;\n }\n\n transition: background-color ", "ms ease;\n &:hover {\n background-color: ", ";\n &>svg {\n fill: #fff;\n }\n }\n\n &.item-enter {\n opacity: 0;\n }\n &.item-enter-active {\n opacity: 1;\n transition: opacity 300ms ease-in;\n }\n &.item-exit {\n opacity: 1;\n }\n &.item-exit-active {\n opacity: 0;\n transition: opacity 300ms ease-in;\n } \n"])), function (p) { return p.theme.radius.normal; }, function (p) { return p.theme.colors.primary[2]; }, function (p) { return p.theme.colors.font; }, function (p) { return p.theme.colors.font; }, function (p) { return p.theme.animation.duration; }, function (p) { return p.theme.animation.duration; }, function (p) { return p.theme.colors.primary[1]; });
|
|
22
|
-
export { Selection };
|
|
23
|
-
var templateObject_1;
|