@decisiv/ui-components 2.0.1-alpha.221 → 2.0.1-alpha.222
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/lib/atoms/OptionsList/Category/index.d.ts +1 -1
- package/lib/atoms/OptionsList/Category/index.d.ts.map +1 -1
- package/lib/atoms/OptionsList/Category/index.js +55 -13
- package/lib/atoms/OptionsList/Category/styles.d.ts +1 -2
- package/lib/atoms/OptionsList/Category/styles.d.ts.map +1 -1
- package/lib/atoms/OptionsList/Category/styles.js +0 -1
- package/lib/atoms/OptionsList/Option/index.d.ts.map +1 -1
- package/lib/atoms/OptionsList/Option/index.js +15 -5
- package/lib/atoms/OptionsList/Option/styles.d.ts.map +1 -1
- package/lib/atoms/OptionsList/Option/styles.js +1 -1
- package/lib/atoms/OptionsList/index.d.ts +1 -44
- package/lib/atoms/OptionsList/index.d.ts.map +1 -1
- package/lib/atoms/OptionsList/index.js +137 -55
- package/lib/atoms/OptionsList/index.test.js +56 -0
- package/lib/atoms/OptionsList/schema.d.ts.map +1 -1
- package/lib/atoms/OptionsList/schema.js +2 -1
- package/lib/atoms/OptionsList/styles.d.ts +45 -0
- package/lib/atoms/OptionsList/styles.d.ts.map +1 -0
- package/lib/atoms/OptionsList/styles.js +29 -0
- package/lib/atoms/OptionsList/types.d.ts +12 -1
- package/lib/atoms/OptionsList/types.d.ts.map +1 -1
- package/lib/components/Combobox/index.test.js +10 -6
- package/lib/components/Table/Grip.d.ts +6 -2
- package/lib/components/Table/Grip.d.ts.map +1 -1
- package/lib/components/Table/Grip.js +9 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare const Category: ({ borderRadius, label, items, showCheckbox, size, }: import("../types").Category) => JSX.Element;
|
|
2
|
+
declare const Category: ({ borderRadius, label, items, indexOffset, showCheckbox, isDragEnabled, size, }: import("../types").Category) => JSX.Element;
|
|
3
3
|
export default Category;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/atoms/OptionsList/Category/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/atoms/OptionsList/Category/index.tsx"],"names":[],"mappings":";AAUA,QAAA,MAAM,QAAQ,+HA4Eb,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -5,7 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactBeautifulDnd = require("react-beautiful-dnd");
|
|
11
|
+
|
|
12
|
+
var _ConfigProvider = require("../../../providers/ConfigProvider");
|
|
9
13
|
|
|
10
14
|
var _Option = _interopRequireDefault(require("../Option"));
|
|
11
15
|
|
|
@@ -15,27 +19,65 @@ var _styles = require("./styles");
|
|
|
15
19
|
|
|
16
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
21
|
|
|
18
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
19
|
-
|
|
20
22
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
23
|
|
|
22
24
|
var Category = function Category(_ref) {
|
|
23
25
|
var borderRadius = _ref.borderRadius,
|
|
24
26
|
label = _ref.label,
|
|
25
27
|
items = _ref.items,
|
|
28
|
+
_ref$indexOffset = _ref.indexOffset,
|
|
29
|
+
indexOffset = _ref$indexOffset === void 0 ? 0 : _ref$indexOffset,
|
|
26
30
|
showCheckbox = _ref.showCheckbox,
|
|
31
|
+
isDragEnabled = _ref.isDragEnabled,
|
|
27
32
|
size = _ref.size;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
|
|
34
|
+
var _useConfig = (0, _ConfigProvider.useConfig)(),
|
|
35
|
+
createPortal = _useConfig.createPortal; // Render a draggable item, using a portal if it's being dragged
|
|
36
|
+
// to avoid issues with parent containers having transform: *.
|
|
37
|
+
// See; https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/guides/reparenting.md
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
var renderDraggable = function renderDraggable(item, index) {
|
|
41
|
+
var id = (0, _utils.getId)(item);
|
|
42
|
+
return _react.default.createElement(_reactBeautifulDnd.Draggable, {
|
|
33
43
|
key: id,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
draggableId: id,
|
|
45
|
+
index: index,
|
|
46
|
+
isDragDisabled: !isDragEnabled
|
|
47
|
+
}, function (provided, snapshot) {
|
|
48
|
+
var draggableElement = _react.default.createElement(_Option.default, _extends({}, item, {
|
|
49
|
+
id: id,
|
|
50
|
+
borderRadius: borderRadius,
|
|
51
|
+
showCheckbox: showCheckbox,
|
|
52
|
+
size: size,
|
|
53
|
+
providerRef: provided.innerRef,
|
|
54
|
+
isDragEnabled: isDragEnabled,
|
|
55
|
+
draggableProps: provided.draggableProps,
|
|
56
|
+
dragHandleProps: provided.dragHandleProps
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
if (snapshot.isDragging) {
|
|
60
|
+
return createPortal(draggableElement);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return draggableElement;
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_reactBeautifulDnd.Draggable, {
|
|
68
|
+
key: "category-".concat(label),
|
|
69
|
+
draggableId: "category-".concat(label),
|
|
70
|
+
index: indexOffset,
|
|
71
|
+
isDragDisabled: true
|
|
72
|
+
}, function (provided) {
|
|
73
|
+
return _react.default.createElement(_styles.StyledCategory, _extends({
|
|
74
|
+
size: size,
|
|
75
|
+
ref: provided.innerRef
|
|
76
|
+
}, provided.draggableProps, provided.dragHandleProps, {
|
|
77
|
+
role: "option"
|
|
78
|
+
}), label);
|
|
79
|
+
}), items.map(function (subItem, index) {
|
|
80
|
+
return renderDraggable(subItem, indexOffset + index + 1);
|
|
39
81
|
}));
|
|
40
82
|
};
|
|
41
83
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { StyledCategoryProps } from '../types';
|
|
2
2
|
export declare const StyledCategory: import("styled-components").StyledComponent<"li", any, {
|
|
3
|
-
role: "option";
|
|
4
3
|
'aria-disabled': true;
|
|
5
|
-
} & StyledCategoryProps, "
|
|
4
|
+
} & StyledCategoryProps, "aria-disabled">;
|
|
6
5
|
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/atoms/OptionsList/Category/styles.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAmB/C,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/atoms/OptionsList/Category/styles.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAmB/C,eAAO,MAAM,cAAc;;yCAY1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/atoms/OptionsList/Option/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAC/D,OAAO,EACL,WAAW,EAKZ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/atoms/OptionsList/Option/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAC/D,OAAO,EACL,WAAW,EAKZ,MAAM,UAAU,CAAC;AA6DlB,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAkI/C;;AAED,wBAAkC"}
|
|
@@ -21,6 +21,8 @@ var _utils = require("../utils");
|
|
|
21
21
|
|
|
22
22
|
var _styles = require("./styles");
|
|
23
23
|
|
|
24
|
+
var _Grip = _interopRequireDefault(require("../../../components/Table/Grip"));
|
|
25
|
+
|
|
24
26
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
25
27
|
|
|
26
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -81,7 +83,11 @@ function Option(props) {
|
|
|
81
83
|
_props$showCheckbox = props.showCheckbox,
|
|
82
84
|
showCheckbox = _props$showCheckbox === void 0 ? true : _props$showCheckbox,
|
|
83
85
|
_props$size = props.size,
|
|
84
|
-
size = _props$size === void 0 ? 'small' : _props$size
|
|
86
|
+
size = _props$size === void 0 ? 'small' : _props$size,
|
|
87
|
+
providerRef = props.providerRef,
|
|
88
|
+
draggableProps = props.draggableProps,
|
|
89
|
+
dragHandleProps = props.dragHandleProps,
|
|
90
|
+
isDragEnabled = props.isDragEnabled;
|
|
85
91
|
var decorationType = (0, _get.default)(decoration, 'type');
|
|
86
92
|
|
|
87
93
|
var _useOptionsList = (0, _context.useOptionsList)(),
|
|
@@ -123,7 +129,7 @@ function Option(props) {
|
|
|
123
129
|
}, children);
|
|
124
130
|
};
|
|
125
131
|
}, [selectable]);
|
|
126
|
-
return _react.default.createElement(_styles.Container, {
|
|
132
|
+
return _react.default.createElement(_styles.Container, _extends({
|
|
127
133
|
"aria-disabled": !!disabled,
|
|
128
134
|
"aria-selected": checked,
|
|
129
135
|
borderRadius: borderRadius,
|
|
@@ -137,14 +143,18 @@ function Option(props) {
|
|
|
137
143
|
inputMethod: inputMethod,
|
|
138
144
|
role: itemRole,
|
|
139
145
|
size: size,
|
|
140
|
-
pointerEvents: pointerEvents
|
|
141
|
-
|
|
146
|
+
pointerEvents: pointerEvents,
|
|
147
|
+
ref: providerRef
|
|
148
|
+
}, draggableProps, dragHandleProps), (0, _utils.isLink)(props) ? _react.default.createElement(_styles.StyledLink, {
|
|
142
149
|
tabIndex: -1,
|
|
143
150
|
to: props.linkTo,
|
|
144
151
|
text: label,
|
|
145
152
|
icon: isDecoration(decoration) && decoration.type === 'Icon' ? decoration.icon : undefined,
|
|
146
153
|
disabled: !!disabled
|
|
147
|
-
}) : _react.default.createElement(LabelWrapper, null,
|
|
154
|
+
}) : _react.default.createElement(LabelWrapper, null, isDragEnabled && _react.default.createElement(_Grip.default, {
|
|
155
|
+
marginRight: "10px",
|
|
156
|
+
selected: checked
|
|
157
|
+
}), selectable && (multiple && !!showCheckbox ? _react.default.createElement(_Checkbox.default, _extends({}, commonProps, {
|
|
148
158
|
disabled: !!disabled,
|
|
149
159
|
size: sizeMapping[size],
|
|
150
160
|
value: props.value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/atoms/OptionsList/Option/styles.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAK3D,eAAO,MAAM,UAAU,mLAgBtB,CAAC;AAuBF,eAAO,MAAM,SAAS,+
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/atoms/OptionsList/Option/styles.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAK3D,eAAO,MAAM,UAAU,mLAgBtB,CAAC;AAuBF,eAAO,MAAM,SAAS,+EA8GrB,CAAC;AAEF,eAAO,MAAM,iBAAiB,oEAI7B,CAAC;AAEF,eAAO,MAAM,4BAA4B;;SAUxC,CAAC;AAEF,eAAO,MAAM,WAAW;;;kBAEvB,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;kBAG3B,CAAC"}
|
|
@@ -48,7 +48,7 @@ function getBorderRadius(_ref) {
|
|
|
48
48
|
var Container = _styledComponents.default.li.withConfig({
|
|
49
49
|
displayName: "styles__Container",
|
|
50
50
|
componentId: "sc-1vr9h8x-1"
|
|
51
|
-
})(["text-align:left;&:focus{outline:none;}> .label,> ", "{align-items:center;border:1px solid transparent;color:", ";display:flex;pointer-events:", ";width:100%;white-space:nowrap;", " > *{margin-right:", ";}}> ", "{pointer-events:auto;background-color:transparent;text-decoration:none;}&:first-child > .label,&:first-child > ", "{border-top-left-radius:", ";border-top-right-radius:", ";}&:last-child > .label,&:last-child > ", "{border-bottom-left-radius:", ";border-bottom-right-radius:", ";}&:hover:not([aria-disabled='true']):not([aria-selected='true']) > .label,&:hover:not([aria-disabled='true']):not([aria-selected='true']) > ", "{color:", ";text-decoration:none;.label > *{border-color:", ";}}&[aria-selected='true'] > .label{background:", ";color:", ";}&[aria-selected='true'] > .label > div > #optionLabelDetails{background:", ";color:", ";}", ";", " &[aria-disabled='true']{cursor:not-allowed;", "{pointer-events:none;}}&[aria-disabled='true'] > .label,&[aria-disabled='true'] > ", "{background:", ";color:", ";}"], StyledLink, (0, _toColorString.default)(_designTokens.color.interaction.pacificOcean), function (_ref2) {
|
|
51
|
+
})(["text-align:left;list-style:none;&:focus{outline:none;}> .label,> ", "{align-items:center;border:1px solid transparent;color:", ";display:flex;pointer-events:", ";width:100%;white-space:nowrap;", " > *{margin-right:", ";}}> ", "{pointer-events:auto;background-color:transparent;text-decoration:none;}&:first-child > .label,&:first-child > ", "{border-top-left-radius:", ";border-top-right-radius:", ";}&:last-child > .label,&:last-child > ", "{border-bottom-left-radius:", ";border-bottom-right-radius:", ";}&:hover:not([aria-disabled='true']):not([aria-selected='true']) > .label,&:hover:not([aria-disabled='true']):not([aria-selected='true']) > ", "{color:", ";text-decoration:none;.label > *{border-color:", ";}}&[aria-selected='true'] > .label{background:", ";color:", ";}&[aria-selected='true'] > .label > div > #optionLabelDetails{background:", ";color:", ";}", ";", " &[aria-disabled='true']{cursor:not-allowed;", "{pointer-events:none;}}&[aria-disabled='true'] > .label,&[aria-disabled='true'] > ", "{background:", ";color:", ";}"], StyledLink, (0, _toColorString.default)(_designTokens.color.interaction.pacificOcean), function (_ref2) {
|
|
52
52
|
var pointerEvents = _ref2.pointerEvents;
|
|
53
53
|
return pointerEvents;
|
|
54
54
|
}, withSizeModifiers, (0, _rem.default)(10), StyledLink, StyledLink, getBorderRadius, getBorderRadius, StyledLink, getBorderRadius, getBorderRadius, StyledLink, (0, _toColorString.default)(_designTokens.color.interaction.pacificOcean), (0, _toColorString.default)(_designTokens.color.interaction.indianOcean), (0, _toColorString.default)(_designTokens.color.interaction.pacificOcean), (0, _toColorString.default)(_designTokens.color.base.snowWhite), (0, _toColorString.default)(_designTokens.color.interaction.pacificOcean), (0, _toColorString.default)(_designTokens.color.base.snowWhite), (0, _styleModifiers.when)('isActive', (0, _styledComponents.css)(["color:", ";background:", ";.label > *{border-color:", ";}"], (0, _toColorString.default)(_designTokens.color.interaction.pacificOcean), (0, _toColorString.default)(_designTokens.color.interaction.pacificOcean15), (0, _toColorString.default)(_designTokens.color.interaction.indianOcean))), (0, _styleModifiers.when)([['isActive'], ['inputMethod', 'keyboard']], (0, _styledComponents.css)(["background:none;> .label,> ", "{border-color:", ";", "}&[aria-selected='true'] > .label,&[aria-selected='true'] > ", "{color:", ";", "}"], StyledLink, (0, _toColorString.default)(_designTokens.color.interaction.pacificOcean), (0, _focusRingWithColor.default)(_designTokens.color.interaction.pacificOcean40), StyledLink, (0, _toColorString.default)(_designTokens.color.base.snowWhite), (0, _focusRingWithColor.default)(_designTokens.color.opacity.fullMoon50))), StyledLink, StyledLink, (0, _toColorString.default)(_designTokens.color.base.snowWhite), (0, _toColorString.default)(_designTokens.color.opacity.charcoal40));
|
|
@@ -1,49 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { OptionsListProps } from './types';
|
|
3
|
-
export
|
|
4
|
-
height?: string | import("../../utils/dynamicModifiers").DynamicResponsiveModifiersProp<string, {
|
|
5
|
-
readonly XS: "XS";
|
|
6
|
-
readonly SM: "SM";
|
|
7
|
-
readonly MD: "MD";
|
|
8
|
-
readonly LG: "LG";
|
|
9
|
-
readonly XL: "XL";
|
|
10
|
-
}> | undefined;
|
|
11
|
-
maxHeight?: string | import("../../utils/dynamicModifiers").DynamicResponsiveModifiersProp<string, {
|
|
12
|
-
readonly XS: "XS";
|
|
13
|
-
readonly SM: "SM";
|
|
14
|
-
readonly MD: "MD";
|
|
15
|
-
readonly LG: "LG";
|
|
16
|
-
readonly XL: "XL";
|
|
17
|
-
}> | undefined;
|
|
18
|
-
maxWidth?: string | import("../../utils/dynamicModifiers").DynamicResponsiveModifiersProp<string, {
|
|
19
|
-
readonly XS: "XS";
|
|
20
|
-
readonly SM: "SM";
|
|
21
|
-
readonly MD: "MD";
|
|
22
|
-
readonly LG: "LG";
|
|
23
|
-
readonly XL: "XL";
|
|
24
|
-
}> | undefined;
|
|
25
|
-
minHeight?: string | import("../../utils/dynamicModifiers").DynamicResponsiveModifiersProp<string, {
|
|
26
|
-
readonly XS: "XS";
|
|
27
|
-
readonly SM: "SM";
|
|
28
|
-
readonly MD: "MD";
|
|
29
|
-
readonly LG: "LG";
|
|
30
|
-
readonly XL: "XL";
|
|
31
|
-
}> | undefined;
|
|
32
|
-
minWidth?: string | import("../../utils/dynamicModifiers").DynamicResponsiveModifiersProp<string, {
|
|
33
|
-
readonly XS: "XS";
|
|
34
|
-
readonly SM: "SM";
|
|
35
|
-
readonly MD: "MD";
|
|
36
|
-
readonly LG: "LG";
|
|
37
|
-
readonly XL: "XL";
|
|
38
|
-
}> | undefined;
|
|
39
|
-
width?: string | import("../../utils/dynamicModifiers").DynamicResponsiveModifiersProp<string, {
|
|
40
|
-
readonly XS: "XS";
|
|
41
|
-
readonly SM: "SM";
|
|
42
|
-
readonly MD: "MD";
|
|
43
|
-
readonly LG: "LG";
|
|
44
|
-
readonly XL: "XL";
|
|
45
|
-
}> | undefined;
|
|
46
|
-
}>, "maxHeight" | "maxWidth" | "minWidth">, never>;
|
|
3
|
+
export { Container } from './styles';
|
|
47
4
|
declare const OptionsListWithContainerRef: React.ForwardRefExoticComponent<OptionsListProps & React.RefAttributes<HTMLUListElement>>;
|
|
48
5
|
export default OptionsListWithContainerRef;
|
|
49
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atoms/OptionsList/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KASN,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atoms/OptionsList/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KASN,MAAM,OAAO,CAAC;AAoBf,OAAO,EAGL,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AAajB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAqZrC,QAAA,MAAM,2BAA2B,2FAA0B,CAAC;AAmC5D,eAAe,2BAA2B,CAAC"}
|
|
@@ -3,15 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
Object.defineProperty(exports, "Container", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _styles.Container;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.default = void 0;
|
|
7
13
|
|
|
8
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
15
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
16
|
+
var _reactBeautifulDnd = require("react-beautiful-dnd");
|
|
13
17
|
|
|
14
|
-
var
|
|
18
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
19
|
|
|
16
20
|
var _isArray = _interopRequireDefault(require("lodash/isArray"));
|
|
17
21
|
|
|
@@ -27,12 +31,16 @@ var _assignRef = _interopRequireDefault(require("../../utils/assignRef"));
|
|
|
27
31
|
|
|
28
32
|
var _isCtrlCmd = _interopRequireDefault(require("../../utils/isCtrlCmd"));
|
|
29
33
|
|
|
34
|
+
var _ConfigProvider = require("../../providers/ConfigProvider");
|
|
35
|
+
|
|
30
36
|
var _Option = _interopRequireDefault(require("./Option"));
|
|
31
37
|
|
|
32
38
|
var _Category = _interopRequireDefault(require("./Category"));
|
|
33
39
|
|
|
34
40
|
var _Footer = _interopRequireDefault(require("./Footer"));
|
|
35
41
|
|
|
42
|
+
var _styles = require("./styles");
|
|
43
|
+
|
|
36
44
|
var _context = require("./context");
|
|
37
45
|
|
|
38
46
|
var _utils = require("./utils");
|
|
@@ -81,27 +89,12 @@ if (_canUseDOM.default) {
|
|
|
81
89
|
});
|
|
82
90
|
}
|
|
83
91
|
|
|
84
|
-
var Container = _styledComponents.default.ul.withConfig({
|
|
85
|
-
displayName: "OptionsList__Container",
|
|
86
|
-
componentId: "sc-107p8d5-0"
|
|
87
|
-
})(["list-style:none;margin:0;width:100%;height:auto;max-height:", ";max-width:", ";padding:0;overflow:auto;position:relative;", " ", " ", " &:focus{outline:none;}"], (0, _rem.default)(310), (0, _rem.default)(340), function (_ref) {
|
|
88
|
-
var minWidth = _ref.minWidth;
|
|
89
|
-
return minWidth ? "\nmin-width: ".concat(minWidth, ";\n") : '';
|
|
90
|
-
}, function (_ref2) {
|
|
91
|
-
var maxWidth = _ref2.maxWidth;
|
|
92
|
-
return maxWidth ? "\nmax-width: ".concat(maxWidth, ";\n") : '';
|
|
93
|
-
}, function (_ref3) {
|
|
94
|
-
var maxHeight = _ref3.maxHeight;
|
|
95
|
-
return maxHeight ? "\nmax-height: ".concat(maxHeight, ";\n") : '';
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
exports.Container = Container;
|
|
99
|
-
|
|
100
92
|
function OptionsList(props, forwardedRef) {
|
|
101
93
|
var actions = props.actions,
|
|
102
94
|
items = props.items,
|
|
103
95
|
multiple = props.multiple,
|
|
104
96
|
onChange = props.onChange,
|
|
97
|
+
onDragEndProp = props.onDragEnd,
|
|
105
98
|
name = props.name,
|
|
106
99
|
selectedIdsProp = props.selected,
|
|
107
100
|
renderOptionLabel = props.renderOptionLabel,
|
|
@@ -168,8 +161,8 @@ function OptionsList(props, forwardedRef) {
|
|
|
168
161
|
|
|
169
162
|
var selectableIds = (0, _react.useMemo)(function () {
|
|
170
163
|
return items.reduce(function (acc, item) {
|
|
171
|
-
return [].concat(_toConsumableArray(acc), _toConsumableArray(((0, _utils.isCategory)(item) ? item.items.filter(function (
|
|
172
|
-
var disabled =
|
|
164
|
+
return [].concat(_toConsumableArray(acc), _toConsumableArray(((0, _utils.isCategory)(item) ? item.items.filter(function (_ref) {
|
|
165
|
+
var disabled = _ref.disabled;
|
|
173
166
|
return !disabled;
|
|
174
167
|
}) : [item.disabled ? undefined : item]).filter(Boolean)));
|
|
175
168
|
}, []).map(_utils.getId);
|
|
@@ -266,6 +259,82 @@ function OptionsList(props, forwardedRef) {
|
|
|
266
259
|
updateActiveId('');
|
|
267
260
|
handleFocusToggle(event);
|
|
268
261
|
}, [handleFocusToggle, updateActiveId]);
|
|
262
|
+
var positions = [];
|
|
263
|
+
var onDragEnd = (0, _react.useCallback)(function (_ref2) {
|
|
264
|
+
var source = _ref2.source,
|
|
265
|
+
destination = _ref2.destination;
|
|
266
|
+
if (!onDragEndProp || !destination) return;
|
|
267
|
+
|
|
268
|
+
var _positions$source$ind = _slicedToArray(positions[source.index], 2),
|
|
269
|
+
fromGroup = _positions$source$ind[0],
|
|
270
|
+
fromIndex = _positions$source$ind[1];
|
|
271
|
+
|
|
272
|
+
var _positions$destinatio = _slicedToArray(positions[destination.index], 2),
|
|
273
|
+
toGroup = _positions$destinatio[0],
|
|
274
|
+
toIndex = _positions$destinatio[1];
|
|
275
|
+
|
|
276
|
+
var hasGroups = fromIndex !== undefined || toIndex !== undefined;
|
|
277
|
+
var fixedGroup = toGroup;
|
|
278
|
+
var fixedIndex = toIndex;
|
|
279
|
+
|
|
280
|
+
if (!hasGroups) {
|
|
281
|
+
onDragEndProp(fromGroup, toGroup);
|
|
282
|
+
return;
|
|
283
|
+
} // when dropping in a header place
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
if (toIndex === undefined) {
|
|
287
|
+
if (toGroup === 0) return;
|
|
288
|
+
|
|
289
|
+
if (fromGroup >= toGroup) {
|
|
290
|
+
// it is actually aiming to the last position of previous group
|
|
291
|
+
var _positions = _slicedToArray(positions[destination.index - 1], 2);
|
|
292
|
+
|
|
293
|
+
fixedGroup = _positions[0];
|
|
294
|
+
fixedIndex = _positions[1];
|
|
295
|
+
fixedIndex += 1;
|
|
296
|
+
} else {
|
|
297
|
+
// aiming for the first position of the group
|
|
298
|
+
fixedIndex = 0;
|
|
299
|
+
}
|
|
300
|
+
} else if (fromGroup < toGroup) fixedIndex += 1;
|
|
301
|
+
|
|
302
|
+
onDragEndProp([fromGroup, fromIndex], [fixedGroup, fixedIndex]);
|
|
303
|
+
}, [onDragEndProp, positions]);
|
|
304
|
+
|
|
305
|
+
var _useConfig = (0, _ConfigProvider.useConfig)(),
|
|
306
|
+
createPortal = _useConfig.createPortal;
|
|
307
|
+
|
|
308
|
+
var isDragEnabled = !!onDragEndProp;
|
|
309
|
+
|
|
310
|
+
var renderDraggable = function renderDraggable(item, index) {
|
|
311
|
+
var id = (0, _utils.getId)(item);
|
|
312
|
+
return _react.default.createElement(_reactBeautifulDnd.Draggable, {
|
|
313
|
+
key: id,
|
|
314
|
+
draggableId: id,
|
|
315
|
+
index: index,
|
|
316
|
+
isDragDisabled: !isDragEnabled
|
|
317
|
+
}, function (provided, snapshot) {
|
|
318
|
+
var draggableElement = _react.default.createElement(_Option.default, _extends({}, item, {
|
|
319
|
+
id: id,
|
|
320
|
+
borderRadius: borderRadius,
|
|
321
|
+
showCheckbox: showCheckbox,
|
|
322
|
+
size: size,
|
|
323
|
+
isDragEnabled: isDragEnabled,
|
|
324
|
+
providerRef: provided.innerRef,
|
|
325
|
+
draggableProps: provided.draggableProps,
|
|
326
|
+
dragHandleProps: provided.dragHandleProps
|
|
327
|
+
}));
|
|
328
|
+
|
|
329
|
+
if (snapshot.isDragging) {
|
|
330
|
+
return createPortal(draggableElement);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return draggableElement;
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
var dndIndex = 0;
|
|
269
338
|
return _react.default.createElement(_context.OptionsListContextProvider, {
|
|
270
339
|
value: {
|
|
271
340
|
toggleItemSelection: toggleItemSelection,
|
|
@@ -281,39 +350,52 @@ function OptionsList(props, forwardedRef) {
|
|
|
281
350
|
itemRole: itemRole,
|
|
282
351
|
pointerEvents: pointerEvents
|
|
283
352
|
}
|
|
284
|
-
}, _react.default.createElement(_Grid.default.Container, null, _react.default.createElement(Row, null, _react.default.createElement(
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
353
|
+
}, _react.default.createElement(_Grid.default.Container, null, _react.default.createElement(Row, null, _react.default.createElement(_reactBeautifulDnd.DragDropContext, {
|
|
354
|
+
onDragEnd: onDragEnd
|
|
355
|
+
}, _react.default.createElement(_reactBeautifulDnd.Droppable, {
|
|
356
|
+
droppableId: "droppable-options-list"
|
|
357
|
+
}, function (droppableProvided) {
|
|
358
|
+
return _react.default.createElement(_styles.Container, _extends({
|
|
359
|
+
"aria-activedescendant": activeId,
|
|
360
|
+
"aria-multiselectable": !!multiple,
|
|
361
|
+
ref: function ref(el) {
|
|
362
|
+
setContainerRefFunc(el);
|
|
363
|
+
droppableProvided.innerRef(el);
|
|
364
|
+
},
|
|
365
|
+
onKeyDown: onKeyDown,
|
|
366
|
+
onFocus: onFocus,
|
|
367
|
+
onBlur: onBlur,
|
|
368
|
+
onMouseLeave: function onMouseLeave() {
|
|
369
|
+
return updateActiveId('');
|
|
370
|
+
},
|
|
371
|
+
role: role,
|
|
372
|
+
tabIndex: tabIndex,
|
|
373
|
+
minWidth: minWidth,
|
|
374
|
+
maxWidth: maxWidth,
|
|
375
|
+
maxHeight: maxHeight
|
|
376
|
+
}, droppableProvided.droppableProps), items.map(function (item, index) {
|
|
377
|
+
var id = (0, _utils.getId)(item);
|
|
378
|
+
var indexOffset = positions.length;
|
|
379
|
+
positions[dndIndex] = [index];
|
|
380
|
+
dndIndex += 1;
|
|
381
|
+
|
|
382
|
+
if ((0, _utils.isCategory)(item)) {
|
|
383
|
+
item.items.forEach(function (_, subIndex) {
|
|
384
|
+
positions[dndIndex] = [index, subIndex];
|
|
385
|
+
dndIndex += 1;
|
|
386
|
+
});
|
|
387
|
+
return _react.default.createElement(_Category.default, _extends({}, item, {
|
|
388
|
+
key: id,
|
|
389
|
+
borderRadius: borderRadius,
|
|
390
|
+
showCheckbox: showCheckbox,
|
|
391
|
+
size: size,
|
|
392
|
+
indexOffset: indexOffset,
|
|
393
|
+
isDragEnabled: isDragEnabled
|
|
394
|
+
}));
|
|
395
|
+
}
|
|
310
396
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
borderRadius: borderRadius,
|
|
314
|
-
showCheckbox: showCheckbox,
|
|
315
|
-
size: size
|
|
316
|
-
}));
|
|
397
|
+
return renderDraggable(item, dndIndex - 1);
|
|
398
|
+
}), droppableProvided.placeholder);
|
|
317
399
|
}))), actions && _react.default.createElement(Row, null, _react.default.createElement(_Footer.default, {
|
|
318
400
|
actions: actions
|
|
319
401
|
}))));
|
|
@@ -385,5 +385,61 @@ describe('OptionsList', function () {
|
|
|
385
385
|
expect(baseElement).toMatchSnapshot();
|
|
386
386
|
});
|
|
387
387
|
});
|
|
388
|
+
describe('drag and drop', function () {
|
|
389
|
+
it('has draggable attributes', function () {
|
|
390
|
+
var mockedFn = jest.fn();
|
|
391
|
+
|
|
392
|
+
var _render12 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
393
|
+
size: size,
|
|
394
|
+
onDragEnd: mockedFn
|
|
395
|
+
}))),
|
|
396
|
+
getByText = _render12.getByText;
|
|
397
|
+
|
|
398
|
+
var item = items[0];
|
|
399
|
+
expect(getByText(item.label).closest('li')).toHaveAttribute('draggable');
|
|
400
|
+
var category = items[2];
|
|
401
|
+
category.items.forEach(function (subItem) {
|
|
402
|
+
expect(getByText(subItem.label).closest('li')).toHaveAttribute('draggable');
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
it('does not have draggable attributes when onDragEnd is not provided', function () {
|
|
406
|
+
var _render13 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
407
|
+
size: size
|
|
408
|
+
}))),
|
|
409
|
+
getByText = _render13.getByText;
|
|
410
|
+
|
|
411
|
+
var item = items[0];
|
|
412
|
+
expect(getByText(item.label).closest('li')).not.toHaveAttribute('draggable');
|
|
413
|
+
var category = items[2];
|
|
414
|
+
category.items.forEach(function (subItem) {
|
|
415
|
+
expect(getByText(subItem.label).closest('li')).not.toHaveAttribute('draggable');
|
|
416
|
+
});
|
|
417
|
+
}); // TODO: re-enable once migrated to pragmatic-drag-and-drop
|
|
418
|
+
|
|
419
|
+
it.skip('calls onDragEnd when drag ends', function () {
|
|
420
|
+
var mockedFn = jest.fn();
|
|
421
|
+
|
|
422
|
+
var _render14 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
423
|
+
size: size,
|
|
424
|
+
onDragEnd: mockedFn
|
|
425
|
+
}))),
|
|
426
|
+
getByText = _render14.getByText;
|
|
427
|
+
|
|
428
|
+
var draggableElement = getByText(items[0].label).closest('li');
|
|
429
|
+
var dropTarget = getByText('Option 2').closest('li');
|
|
430
|
+
|
|
431
|
+
_react2.fireEvent.dragStart(draggableElement);
|
|
432
|
+
|
|
433
|
+
_react2.fireEvent.dragEnter(dropTarget);
|
|
434
|
+
|
|
435
|
+
_react2.fireEvent.dragOver(dropTarget);
|
|
436
|
+
|
|
437
|
+
_react2.fireEvent.drop(dropTarget);
|
|
438
|
+
|
|
439
|
+
_react2.fireEvent.dragEnd(draggableElement);
|
|
440
|
+
|
|
441
|
+
expect(mockedFn).toHaveBeenCalled();
|
|
442
|
+
});
|
|
443
|
+
});
|
|
388
444
|
});
|
|
389
445
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/atoms/OptionsList/schema.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,KAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/atoms/OptionsList/schema.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,KAA2C,CAAC;AAgFxD,eAAe,MAAM,CAAC"}
|
|
@@ -41,7 +41,8 @@ schema.makePropTypes = function () {
|
|
|
41
41
|
selectable: _reactDesc.PropTypes.bool.description('Enables selection in the options list.').defaultValue(true),
|
|
42
42
|
role: _reactDesc.PropTypes.string.description('The role assigned to the list.').defaultValue('listbox'),
|
|
43
43
|
itemRole: _reactDesc.PropTypes.string.description('The role assigned to each item in the list.').defaultValue('option'),
|
|
44
|
-
size: _reactDesc.PropTypes.oneOf(['small', 'medium']).description('Defines the size of the OptionList').defaultValue('small')
|
|
44
|
+
size: _reactDesc.PropTypes.oneOf(['small', 'medium']).description('Defines the size of the OptionList').defaultValue('small'),
|
|
45
|
+
onDragEnd: _reactDesc.PropTypes.func.description("If present, enables Drag-and-Drop sorting. This function will be called after the order of rows changes when a row is dragged and dropped. It is called with 2 arguments: the index from where it's dragged, and the index to where it's dropped. If there are grouped rows then each argument is an array where the first element is the group index and the second the row index inside the group. See below for function signature.")
|
|
45
46
|
};
|
|
46
47
|
};
|
|
47
48
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export declare const Container: import("styled-components").StyledComponent<"ul", any, Pick<Partial<{
|
|
2
|
+
height?: string | import("../../utils/dynamicModifiers").DynamicResponsiveModifiersProp<string, {
|
|
3
|
+
readonly XS: "XS";
|
|
4
|
+
readonly SM: "SM";
|
|
5
|
+
readonly MD: "MD";
|
|
6
|
+
readonly LG: "LG";
|
|
7
|
+
readonly XL: "XL";
|
|
8
|
+
}> | undefined;
|
|
9
|
+
maxHeight?: string | import("../../utils/dynamicModifiers").DynamicResponsiveModifiersProp<string, {
|
|
10
|
+
readonly XS: "XS";
|
|
11
|
+
readonly SM: "SM";
|
|
12
|
+
readonly MD: "MD";
|
|
13
|
+
readonly LG: "LG";
|
|
14
|
+
readonly XL: "XL";
|
|
15
|
+
}> | undefined;
|
|
16
|
+
maxWidth?: string | import("../../utils/dynamicModifiers").DynamicResponsiveModifiersProp<string, {
|
|
17
|
+
readonly XS: "XS";
|
|
18
|
+
readonly SM: "SM";
|
|
19
|
+
readonly MD: "MD";
|
|
20
|
+
readonly LG: "LG";
|
|
21
|
+
readonly XL: "XL";
|
|
22
|
+
}> | undefined;
|
|
23
|
+
minHeight?: string | import("../../utils/dynamicModifiers").DynamicResponsiveModifiersProp<string, {
|
|
24
|
+
readonly XS: "XS";
|
|
25
|
+
readonly SM: "SM";
|
|
26
|
+
readonly MD: "MD";
|
|
27
|
+
readonly LG: "LG";
|
|
28
|
+
readonly XL: "XL";
|
|
29
|
+
}> | undefined;
|
|
30
|
+
minWidth?: string | import("../../utils/dynamicModifiers").DynamicResponsiveModifiersProp<string, {
|
|
31
|
+
readonly XS: "XS";
|
|
32
|
+
readonly SM: "SM";
|
|
33
|
+
readonly MD: "MD";
|
|
34
|
+
readonly LG: "LG";
|
|
35
|
+
readonly XL: "XL";
|
|
36
|
+
}> | undefined;
|
|
37
|
+
width?: string | import("../../utils/dynamicModifiers").DynamicResponsiveModifiersProp<string, {
|
|
38
|
+
readonly XS: "XS";
|
|
39
|
+
readonly SM: "SM";
|
|
40
|
+
readonly MD: "MD";
|
|
41
|
+
readonly LG: "LG";
|
|
42
|
+
readonly XL: "XL";
|
|
43
|
+
}> | undefined;
|
|
44
|
+
}>, "maxHeight" | "maxWidth" | "minWidth">, never>;
|
|
45
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/atoms/OptionsList/styles.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAmCrB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Container = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
+
|
|
10
|
+
var _rem = _interopRequireDefault(require("polished/lib/helpers/rem"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
15
|
+
var Container = _styledComponents.default.ul.withConfig({
|
|
16
|
+
displayName: "styles__Container",
|
|
17
|
+
componentId: "sc-1rytot8-0"
|
|
18
|
+
})(["list-style:none;margin:0;width:100%;height:auto;max-height:", ";max-width:", ";padding:0;overflow:auto;position:relative;", " ", " ", " &:focus{outline:none;}"], (0, _rem.default)(310), (0, _rem.default)(340), function (_ref) {
|
|
19
|
+
var minWidth = _ref.minWidth;
|
|
20
|
+
return minWidth ? "\n min-width: ".concat(minWidth, ";\n") : '';
|
|
21
|
+
}, function (_ref2) {
|
|
22
|
+
var maxWidth = _ref2.maxWidth;
|
|
23
|
+
return maxWidth ? "\n max-width: ".concat(maxWidth, ";\n") : '';
|
|
24
|
+
}, function (_ref3) {
|
|
25
|
+
var maxHeight = _ref3.maxHeight;
|
|
26
|
+
return maxHeight ? "\n max-height: ".concat(maxHeight, ";\n") : '';
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
exports.Container = Container;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BorderRadiusProperty } from 'csstype';
|
|
2
2
|
import { KeyboardEvent } from 'react';
|
|
3
3
|
import { IconProps } from '@decisiv/iconix';
|
|
4
|
+
import { DraggableProvidedDragHandleProps, DraggableProvidedDraggableProps } from 'react-beautiful-dnd';
|
|
4
5
|
import { AvatarProps } from '../../components/Avatar';
|
|
5
6
|
import { BadgeProps } from '../../components/Badge';
|
|
6
7
|
import { DimensionsProps } from '../../modifiers/dimensions';
|
|
@@ -41,6 +42,8 @@ export interface Category {
|
|
|
41
42
|
label: string;
|
|
42
43
|
showCheckbox?: boolean;
|
|
43
44
|
size?: Size;
|
|
45
|
+
indexOffset?: number;
|
|
46
|
+
isDragEnabled?: boolean;
|
|
44
47
|
}
|
|
45
48
|
export declare type CategoryProps = Category;
|
|
46
49
|
export declare type IconComponent = (props: IconProps) => JSX.Element;
|
|
@@ -54,6 +57,10 @@ interface BaseOption {
|
|
|
54
57
|
showCheckbox?: boolean;
|
|
55
58
|
meta?: Record<any, unknown>;
|
|
56
59
|
size?: Size;
|
|
60
|
+
providerRef?: React.Ref<HTMLLIElement>;
|
|
61
|
+
draggableProps?: DraggableProvidedDraggableProps;
|
|
62
|
+
dragHandleProps?: DraggableProvidedDragHandleProps;
|
|
63
|
+
isDragEnabled?: boolean;
|
|
57
64
|
}
|
|
58
65
|
export interface ItemOption extends BaseOption {
|
|
59
66
|
value?: string;
|
|
@@ -85,10 +92,14 @@ export interface OptionsListProps extends OptionsListDimensions {
|
|
|
85
92
|
role?: string;
|
|
86
93
|
itemRole?: string;
|
|
87
94
|
pointerEvents?: string;
|
|
95
|
+
onDragEnd?: (from: number | number[], to: number | number[]) => void;
|
|
88
96
|
}
|
|
89
97
|
export declare type OptionsListContainerRef = HTMLUListElement;
|
|
90
|
-
export interface StyledCategoryProps
|
|
98
|
+
export interface StyledCategoryProps {
|
|
91
99
|
size: Size;
|
|
100
|
+
ref?: React.Ref<HTMLLIElement>;
|
|
101
|
+
ariaDisabled?: boolean;
|
|
102
|
+
role?: string;
|
|
92
103
|
}
|
|
93
104
|
export interface ContainerProps {
|
|
94
105
|
borderRadius?: BorderRadiusProperty<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/atoms/OptionsList/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,W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('Combobox', function () {
|
|
|
854
854
|
_react2.fireEvent.click(queryByLabelText('test'));
|
|
855
855
|
|
|
856
856
|
expect((0, _react2.queryByText)(baseElement, defaultOptions[0].label)).toBeInTheDocument();
|
|
857
|
-
|
|
857
|
+
var li = (0, _react2.queryByText)(baseElement, defaultOptions[1].label).parentElement.parentElement.parentElement;
|
|
858
|
+
expect(li).toHaveAttribute('aria-selected', 'true');
|
|
858
859
|
});
|
|
859
860
|
describe('when typing', function () {
|
|
860
861
|
it('does NOT update the selection automatically', function () {
|
|
@@ -887,7 +888,8 @@ describe('Combobox', function () {
|
|
|
887
888
|
});
|
|
888
889
|
|
|
889
890
|
expect(onChangeValue).toHaveBeenCalledTimes(1);
|
|
890
|
-
|
|
891
|
+
var li = (0, _react2.queryByText)(baseElement, defaultOptions[1].label).parentElement.parentElement.parentElement;
|
|
892
|
+
expect(li).toHaveAttribute('aria-selected', 'true');
|
|
891
893
|
});
|
|
892
894
|
});
|
|
893
895
|
describe('when clicking the clear button', function () {
|
|
@@ -958,7 +960,7 @@ describe('Combobox', function () {
|
|
|
958
960
|
});
|
|
959
961
|
describe('when a controlled component', function () {
|
|
960
962
|
it('initializes with and prefers prop values', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
961
|
-
var newInputValue, onChangeInputValue, onChangeValue, _render32, baseElement, queryByLabelText, rerender;
|
|
963
|
+
var newInputValue, onChangeInputValue, onChangeValue, _render32, baseElement, queryByLabelText, rerender, li, li2;
|
|
962
964
|
|
|
963
965
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
964
966
|
while (1) {
|
|
@@ -1019,10 +1021,12 @@ describe('Combobox', function () {
|
|
|
1019
1021
|
|
|
1020
1022
|
_react2.fireEvent.click(queryByLabelText('test'));
|
|
1021
1023
|
|
|
1022
|
-
|
|
1023
|
-
expect(
|
|
1024
|
+
li = (0, _react2.queryByText)(baseElement, defaultOptions[0].label).parentElement.parentElement.parentElement;
|
|
1025
|
+
expect(li).toHaveAttribute('aria-selected', 'true');
|
|
1026
|
+
li2 = (0, _react2.queryByText)(baseElement, defaultOptions[1].label).parentElement.parentElement.parentElement;
|
|
1027
|
+
expect(li2).toHaveAttribute('aria-selected', 'false');
|
|
1024
1028
|
|
|
1025
|
-
case
|
|
1029
|
+
case 25:
|
|
1026
1030
|
case "end":
|
|
1027
1031
|
return _context.stop();
|
|
1028
1032
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
interface GripProps {
|
|
3
|
+
marginRight?: string | number;
|
|
4
|
+
selected?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const Grip: ({ marginRight, selected }: GripProps) => JSX.Element;
|
|
7
|
+
export default Grip;
|
|
4
8
|
//# sourceMappingURL=Grip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grip.d.ts","sourceRoot":"","sources":["../../../src/components/Table/Grip.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Grip.d.ts","sourceRoot":"","sources":["../../../src/components/Table/Grip.tsx"],"names":[],"mappings":";AAEA,UAAU,SAAS;IACjB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,IAAI,uDAmBT,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -9,10 +9,15 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var Grip = function Grip(_ref) {
|
|
13
|
+
var marginRight = _ref.marginRight,
|
|
14
|
+
_ref$selected = _ref.selected,
|
|
15
|
+
selected = _ref$selected === void 0 ? false : _ref$selected;
|
|
16
|
+
var fillColor = selected ? '#fff' : '#1C6EE6';
|
|
13
17
|
return _react.default.createElement("svg", {
|
|
14
18
|
style: {
|
|
15
|
-
margin: '0 5px'
|
|
19
|
+
margin: '0 5px',
|
|
20
|
+
marginRight: marginRight
|
|
16
21
|
},
|
|
17
22
|
xmlns: "http://www.w3.org/2000/svg",
|
|
18
23
|
width: "8",
|
|
@@ -23,8 +28,9 @@ var _default = function _default() {
|
|
|
23
28
|
fillRule: "evenodd",
|
|
24
29
|
clipRule: "evenodd",
|
|
25
30
|
d: "M2 0.75C1.30964 0.75 0.75 1.30964 0.75 2C0.75 2.69036 1.30964 3.25 2 3.25C2.69036 3.25 3.25 2.69036 3.25 2C3.25 1.30964 2.69036 0.75 2 0.75ZM2 4.75C1.30964 4.75 0.75 5.30964 0.75 6C0.75 6.69036 1.30964 7.25 2 7.25C2.69036 7.25 3.25 6.69036 3.25 6C3.25 5.30964 2.69036 4.75 2 4.75ZM0.75 10C0.75 9.30964 1.30964 8.75 2 8.75C2.69036 8.75 3.25 9.30964 3.25 10C3.25 10.6904 2.69036 11.25 2 11.25C1.30964 11.25 0.75 10.6904 0.75 10ZM6 4.75C5.30964 4.75 4.75 5.30964 4.75 6C4.75 6.69036 5.30964 7.25 6 7.25C6.69036 7.25 7.25 6.69036 7.25 6C7.25 5.30964 6.69036 4.75 6 4.75ZM4.75 2C4.75 1.30964 5.30964 0.75 6 0.75C6.69036 0.75 7.25 1.30964 7.25 2C7.25 2.69036 6.69036 3.25 6 3.25C5.30964 3.25 4.75 2.69036 4.75 2ZM6 8.75C5.30964 8.75 4.75 9.30964 4.75 10C4.75 10.6904 5.30964 11.25 6 11.25C6.69036 11.25 7.25 10.6904 7.25 10C7.25 9.30964 6.69036 8.75 6 8.75ZM0.75 14C0.75 13.3096 1.30964 12.75 2 12.75C2.69036 12.75 3.25 13.3096 3.25 14C3.25 14.6904 2.69036 15.25 2 15.25C1.30964 15.25 0.75 14.6904 0.75 14ZM6 12.75C5.30964 12.75 4.75 13.3096 4.75 14C4.75 14.6904 5.30964 15.25 6 15.25C6.69036 15.25 7.25 14.6904 7.25 14C7.25 13.3096 6.69036 12.75 6 12.75Z",
|
|
26
|
-
fill:
|
|
31
|
+
fill: fillColor
|
|
27
32
|
}));
|
|
28
33
|
};
|
|
29
34
|
|
|
35
|
+
var _default = Grip;
|
|
30
36
|
exports.default = _default;
|