@decisiv/ui-components 2.0.1-alpha.221 → 2.0.1-alpha.223
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 +245 -37
- package/lib/atoms/OptionsList/index.test.js +139 -30
- 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 +28 -1
- package/lib/atoms/OptionsList/types.d.ts.map +1 -1
- package/lib/atoms/OptionsList/utils.d.ts +3 -1
- package/lib/atoms/OptionsList/utils.d.ts.map +1 -1
- package/lib/atoms/OptionsList/utils.js +79 -2
- package/lib/components/Combobox/index.d.ts.map +1 -1
- package/lib/components/Combobox/index.js +4 -2
- package/lib/components/Combobox/index.test.js +10 -6
- package/lib/components/Combobox/types.d.ts +1 -0
- package/lib/components/Combobox/types.d.ts.map +1 -1
- 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/lib/components/Wizard/index.d.ts +8 -1
- package/lib/components/Wizard/index.d.ts.map +1 -1
- package/lib/components/Wizard/index.js +31 -19
- package/lib/components/Wizard/index.test.js +117 -28
- package/lib/components/Wizard/schema.d.ts.map +1 -1
- package/lib/components/Wizard/schema.js +4 -3
- package/package.json +3 -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;AAqBf,OAAO,EAEL,gBAAgB,EAMjB,MAAM,SAAS,CAAC;AAqBjB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AA8iBrC,QAAA,MAAM,2BAA2B,2FAA0B,CAAC;AAmC5D,eAAe,2BAA2B,CAAC"}
|
|
@@ -3,18 +3,24 @@
|
|
|
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 _styles2.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
|
|
|
22
|
+
var _reactWindow = require("react-window");
|
|
23
|
+
|
|
18
24
|
var _Button = require("../../components/Button");
|
|
19
25
|
|
|
20
26
|
var _Grid = _interopRequireDefault(require("../../components/Grid"));
|
|
@@ -27,12 +33,18 @@ var _assignRef = _interopRequireDefault(require("../../utils/assignRef"));
|
|
|
27
33
|
|
|
28
34
|
var _isCtrlCmd = _interopRequireDefault(require("../../utils/isCtrlCmd"));
|
|
29
35
|
|
|
36
|
+
var _ConfigProvider = require("../../providers/ConfigProvider");
|
|
37
|
+
|
|
30
38
|
var _Option = _interopRequireDefault(require("./Option"));
|
|
31
39
|
|
|
32
40
|
var _Category = _interopRequireDefault(require("./Category"));
|
|
33
41
|
|
|
42
|
+
var _styles = require("./Category/styles");
|
|
43
|
+
|
|
34
44
|
var _Footer = _interopRequireDefault(require("./Footer"));
|
|
35
45
|
|
|
46
|
+
var _styles2 = require("./styles");
|
|
47
|
+
|
|
36
48
|
var _context = require("./context");
|
|
37
49
|
|
|
38
50
|
var _utils = require("./utils");
|
|
@@ -51,8 +63,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
51
63
|
|
|
52
64
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
53
65
|
|
|
54
|
-
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); }
|
|
55
|
-
|
|
56
66
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
|
57
67
|
|
|
58
68
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
|
@@ -69,6 +79,8 @@ function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d =
|
|
|
69
79
|
|
|
70
80
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
71
81
|
|
|
82
|
+
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); }
|
|
83
|
+
|
|
72
84
|
var Row = _Grid.default.Row;
|
|
73
85
|
var isUsingKeyboard = false;
|
|
74
86
|
|
|
@@ -80,28 +92,48 @@ if (_canUseDOM.default) {
|
|
|
80
92
|
isUsingKeyboard = false;
|
|
81
93
|
});
|
|
82
94
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
/**
|
|
96
|
+
* VirtualRow component for VariableSizeList (react-window)
|
|
97
|
+
* Renders a single item (either a Category header or an Option)
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
/* eslint-disable react/prop-types */
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
var VirtualRow = _react.default.memo(function (_ref) {
|
|
104
|
+
var index = _ref.index,
|
|
105
|
+
style = _ref.style,
|
|
106
|
+
data = _ref.data;
|
|
107
|
+
var flattenedItems = data.flattenedItems,
|
|
108
|
+
borderRadius = data.borderRadius,
|
|
109
|
+
showCheckbox = data.showCheckbox,
|
|
110
|
+
size = data.size;
|
|
111
|
+
var flattenedItem = flattenedItems[index];
|
|
112
|
+
var item = flattenedItem.item,
|
|
113
|
+
type = flattenedItem.type;
|
|
114
|
+
var id = (0, _utils.getId)(item);
|
|
115
|
+
return _react.default.createElement("div", {
|
|
116
|
+
style: style
|
|
117
|
+
}, type === 'category-header' ? _react.default.createElement(_styles.StyledCategory, {
|
|
118
|
+
size: size
|
|
119
|
+
}, item.label) : _react.default.createElement(_Option.default, _extends({}, item, {
|
|
120
|
+
key: id,
|
|
121
|
+
borderRadius: borderRadius,
|
|
122
|
+
showCheckbox: showCheckbox,
|
|
123
|
+
size: size
|
|
124
|
+
})));
|
|
96
125
|
});
|
|
126
|
+
/* eslint-enable react/prop-types */
|
|
127
|
+
|
|
97
128
|
|
|
98
|
-
|
|
129
|
+
VirtualRow.displayName = 'VirtualRow';
|
|
99
130
|
|
|
100
131
|
function OptionsList(props, forwardedRef) {
|
|
101
132
|
var actions = props.actions,
|
|
102
133
|
items = props.items,
|
|
103
134
|
multiple = props.multiple,
|
|
104
135
|
onChange = props.onChange,
|
|
136
|
+
onDragEndProp = props.onDragEnd,
|
|
105
137
|
name = props.name,
|
|
106
138
|
selectedIdsProp = props.selected,
|
|
107
139
|
renderOptionLabel = props.renderOptionLabel,
|
|
@@ -121,7 +153,8 @@ function OptionsList(props, forwardedRef) {
|
|
|
121
153
|
minWidth = props.minWidth,
|
|
122
154
|
maxWidth = props.maxWidth,
|
|
123
155
|
maxHeight = props.maxHeight,
|
|
124
|
-
pointerEvents = props.pointerEvents
|
|
156
|
+
pointerEvents = props.pointerEvents,
|
|
157
|
+
enableVirtualization = props.enableVirtualization;
|
|
125
158
|
var initialIds = selectedIdsProp || defaultSelected;
|
|
126
159
|
|
|
127
160
|
var _useState = (0, _react.useState)(null),
|
|
@@ -134,6 +167,40 @@ function OptionsList(props, forwardedRef) {
|
|
|
134
167
|
selectedIds = _useState4[0],
|
|
135
168
|
setSelectedIds = _useState4[1];
|
|
136
169
|
|
|
170
|
+
var isDragEnabled = !!onDragEndProp;
|
|
171
|
+
var useVirtualization = enableVirtualization && !isDragEnabled; // Flatten items for virtualization
|
|
172
|
+
|
|
173
|
+
var flattenedItems = (0, _react.useMemo)(function () {
|
|
174
|
+
if (!useVirtualization) return [];
|
|
175
|
+
return (0, _utils.flattenItems)(items);
|
|
176
|
+
}, [items, useVirtualization]); // Get item size for VariableSizeList
|
|
177
|
+
|
|
178
|
+
var getItemSize = (0, _react.useCallback)(function (index) {
|
|
179
|
+
return (0, _utils.getItemHeight)(flattenedItems[index], size);
|
|
180
|
+
}, [flattenedItems, size]); // Calculate total height for the list
|
|
181
|
+
|
|
182
|
+
var totalHeight = (0, _react.useMemo)(function () {
|
|
183
|
+
if (!useVirtualization) return 0;
|
|
184
|
+
var calculated = flattenedItems.reduce(function (acc, item) {
|
|
185
|
+
return acc + (0, _utils.getItemHeight)(item, size);
|
|
186
|
+
}, 0); // If maxHeight is explicitly provided, use it
|
|
187
|
+
|
|
188
|
+
if (maxHeight && typeof maxHeight === 'string') {
|
|
189
|
+
var max = parseInt(maxHeight, 10);
|
|
190
|
+
return Math.min(calculated, max);
|
|
191
|
+
} // Default behavior: use 310px max, but if calculated is less, use calculated
|
|
192
|
+
// This ensures small lists render all items (important for tests)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
var defaultMax = 310; // If the list is small enough to fit all items, use calculated height
|
|
196
|
+
// This is important for tests and small lists
|
|
197
|
+
|
|
198
|
+
if (calculated <= defaultMax) {
|
|
199
|
+
return calculated;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return defaultMax;
|
|
203
|
+
}, [flattenedItems, size, maxHeight, useVirtualization]);
|
|
137
204
|
var updateSelectionAndTriggerChange = (0, _react.useCallback)(function (ids) {
|
|
138
205
|
// Only toggle if we are "uncontrolled"
|
|
139
206
|
selectedIdsProp === undefined && selectable && setSelectedIds(ids);
|
|
@@ -168,8 +235,8 @@ function OptionsList(props, forwardedRef) {
|
|
|
168
235
|
|
|
169
236
|
var selectableIds = (0, _react.useMemo)(function () {
|
|
170
237
|
return items.reduce(function (acc, item) {
|
|
171
|
-
return [].concat(_toConsumableArray(acc), _toConsumableArray(((0, _utils.isCategory)(item) ? item.items.filter(function (
|
|
172
|
-
var disabled =
|
|
238
|
+
return [].concat(_toConsumableArray(acc), _toConsumableArray(((0, _utils.isCategory)(item) ? item.items.filter(function (_ref2) {
|
|
239
|
+
var disabled = _ref2.disabled;
|
|
173
240
|
return !disabled;
|
|
174
241
|
}) : [item.disabled ? undefined : item]).filter(Boolean)));
|
|
175
242
|
}, []).map(_utils.getId);
|
|
@@ -266,6 +333,90 @@ function OptionsList(props, forwardedRef) {
|
|
|
266
333
|
updateActiveId('');
|
|
267
334
|
handleFocusToggle(event);
|
|
268
335
|
}, [handleFocusToggle, updateActiveId]);
|
|
336
|
+
var positions = [];
|
|
337
|
+
var onDragEnd = (0, _react.useCallback)(function (_ref3) {
|
|
338
|
+
var source = _ref3.source,
|
|
339
|
+
destination = _ref3.destination;
|
|
340
|
+
if (!onDragEndProp || !destination) return;
|
|
341
|
+
|
|
342
|
+
var _positions$source$ind = _slicedToArray(positions[source.index], 2),
|
|
343
|
+
fromGroup = _positions$source$ind[0],
|
|
344
|
+
fromIndex = _positions$source$ind[1];
|
|
345
|
+
|
|
346
|
+
var _positions$destinatio = _slicedToArray(positions[destination.index], 2),
|
|
347
|
+
toGroup = _positions$destinatio[0],
|
|
348
|
+
toIndex = _positions$destinatio[1];
|
|
349
|
+
|
|
350
|
+
var hasGroups = fromIndex !== undefined || toIndex !== undefined;
|
|
351
|
+
var fixedGroup = toGroup;
|
|
352
|
+
var fixedIndex = toIndex;
|
|
353
|
+
|
|
354
|
+
if (!hasGroups) {
|
|
355
|
+
onDragEndProp(fromGroup, toGroup);
|
|
356
|
+
return;
|
|
357
|
+
} // when dropping in a header place
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
if (toIndex === undefined) {
|
|
361
|
+
if (toGroup === 0) return;
|
|
362
|
+
|
|
363
|
+
if (fromGroup >= toGroup) {
|
|
364
|
+
// it is actually aiming to the last position of previous group
|
|
365
|
+
var _positions = _slicedToArray(positions[destination.index - 1], 2);
|
|
366
|
+
|
|
367
|
+
fixedGroup = _positions[0];
|
|
368
|
+
fixedIndex = _positions[1];
|
|
369
|
+
fixedIndex += 1;
|
|
370
|
+
} else {
|
|
371
|
+
// aiming for the first position of the group
|
|
372
|
+
fixedIndex = 0;
|
|
373
|
+
}
|
|
374
|
+
} else if (fromGroup < toGroup) fixedIndex += 1;
|
|
375
|
+
|
|
376
|
+
onDragEndProp([fromGroup, fromIndex], [fixedGroup, fixedIndex]);
|
|
377
|
+
}, [onDragEndProp, positions]);
|
|
378
|
+
|
|
379
|
+
var _useConfig = (0, _ConfigProvider.useConfig)(),
|
|
380
|
+
createPortal = _useConfig.createPortal; // Warn developers if they try to use both features
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
(0, _react.useEffect)(function () {
|
|
384
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
385
|
+
if (enableVirtualization && isDragEnabled) {
|
|
386
|
+
// eslint-disable-next-line no-console
|
|
387
|
+
console.warn('OptionsList: enableVirtualization is ignored when onDragEnd is provided. ' + 'Virtualization and drag-and-drop are incompatible.');
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}, [enableVirtualization, isDragEnabled]);
|
|
391
|
+
|
|
392
|
+
var renderDraggable = function renderDraggable(item, index) {
|
|
393
|
+
var id = (0, _utils.getId)(item);
|
|
394
|
+
return _react.default.createElement(_reactBeautifulDnd.Draggable, {
|
|
395
|
+
key: id,
|
|
396
|
+
draggableId: id,
|
|
397
|
+
index: index,
|
|
398
|
+
isDragDisabled: !isDragEnabled
|
|
399
|
+
}, function (provided, snapshot) {
|
|
400
|
+
var draggableElement = _react.default.createElement(_Option.default, _extends({}, item, {
|
|
401
|
+
id: id,
|
|
402
|
+
borderRadius: borderRadius,
|
|
403
|
+
showCheckbox: showCheckbox,
|
|
404
|
+
size: size,
|
|
405
|
+
isDragEnabled: isDragEnabled,
|
|
406
|
+
providerRef: provided.innerRef,
|
|
407
|
+
draggableProps: provided.draggableProps,
|
|
408
|
+
dragHandleProps: provided.dragHandleProps
|
|
409
|
+
}));
|
|
410
|
+
|
|
411
|
+
if (snapshot.isDragging) {
|
|
412
|
+
return createPortal(draggableElement);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return draggableElement;
|
|
416
|
+
});
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
var dndIndex = 0;
|
|
269
420
|
return _react.default.createElement(_context.OptionsListContextProvider, {
|
|
270
421
|
value: {
|
|
271
422
|
toggleItemSelection: toggleItemSelection,
|
|
@@ -281,7 +432,9 @@ function OptionsList(props, forwardedRef) {
|
|
|
281
432
|
itemRole: itemRole,
|
|
282
433
|
pointerEvents: pointerEvents
|
|
283
434
|
}
|
|
284
|
-
}, _react.default.createElement(_Grid.default.Container, null, _react.default.createElement(Row, null, _react.default.createElement(
|
|
435
|
+
}, _react.default.createElement(_Grid.default.Container, null, _react.default.createElement(Row, null, _react.default.createElement(_reactBeautifulDnd.DragDropContext, {
|
|
436
|
+
onDragEnd: onDragEnd
|
|
437
|
+
}, useVirtualization ? _react.default.createElement(_styles2.Container, {
|
|
285
438
|
"aria-activedescendant": activeId,
|
|
286
439
|
"aria-multiselectable": !!multiple,
|
|
287
440
|
ref: setContainerRefFunc,
|
|
@@ -296,24 +449,79 @@ function OptionsList(props, forwardedRef) {
|
|
|
296
449
|
minWidth: minWidth,
|
|
297
450
|
maxWidth: maxWidth,
|
|
298
451
|
maxHeight: maxHeight
|
|
299
|
-
},
|
|
300
|
-
|
|
452
|
+
}, _react.default.createElement(_reactWindow.VariableSizeList, {
|
|
453
|
+
height: totalHeight,
|
|
454
|
+
itemCount: flattenedItems.length,
|
|
455
|
+
itemSize: getItemSize,
|
|
456
|
+
width: "100%",
|
|
457
|
+
itemData: {
|
|
458
|
+
flattenedItems: flattenedItems,
|
|
459
|
+
borderRadius: borderRadius,
|
|
460
|
+
showCheckbox: showCheckbox || false,
|
|
461
|
+
size: size
|
|
462
|
+
}
|
|
463
|
+
}, VirtualRow)) : _react.default.createElement(_reactBeautifulDnd.Droppable, {
|
|
464
|
+
droppableId: "droppable-options-list"
|
|
465
|
+
}, function (droppableProvided) {
|
|
466
|
+
return _react.default.createElement(_styles2.Container, _extends({
|
|
467
|
+
"aria-activedescendant": activeId,
|
|
468
|
+
"aria-multiselectable": !!multiple,
|
|
469
|
+
ref: function ref(el) {
|
|
470
|
+
setContainerRefFunc(el);
|
|
471
|
+
droppableProvided.innerRef(el);
|
|
472
|
+
},
|
|
473
|
+
onKeyDown: onKeyDown,
|
|
474
|
+
onFocus: onFocus,
|
|
475
|
+
onBlur: onBlur,
|
|
476
|
+
onMouseLeave: function onMouseLeave() {
|
|
477
|
+
return updateActiveId('');
|
|
478
|
+
},
|
|
479
|
+
role: role,
|
|
480
|
+
tabIndex: tabIndex,
|
|
481
|
+
minWidth: minWidth,
|
|
482
|
+
maxWidth: maxWidth,
|
|
483
|
+
maxHeight: maxHeight
|
|
484
|
+
}, droppableProvided.droppableProps), isDragEnabled ? items.map(function (item, index) {
|
|
485
|
+
var id = (0, _utils.getId)(item);
|
|
486
|
+
var indexOffset = positions.length;
|
|
487
|
+
positions[dndIndex] = [index];
|
|
488
|
+
dndIndex += 1;
|
|
489
|
+
|
|
490
|
+
if ((0, _utils.isCategory)(item)) {
|
|
491
|
+
item.items.forEach(function (_, subIndex) {
|
|
492
|
+
positions[dndIndex] = [index, subIndex];
|
|
493
|
+
dndIndex += 1;
|
|
494
|
+
});
|
|
495
|
+
return _react.default.createElement(_Category.default, _extends({}, item, {
|
|
496
|
+
key: id,
|
|
497
|
+
borderRadius: borderRadius,
|
|
498
|
+
showCheckbox: showCheckbox,
|
|
499
|
+
size: size,
|
|
500
|
+
indexOffset: indexOffset,
|
|
501
|
+
isDragEnabled: isDragEnabled
|
|
502
|
+
}));
|
|
503
|
+
}
|
|
301
504
|
|
|
302
|
-
|
|
303
|
-
|
|
505
|
+
return renderDraggable(item, dndIndex - 1);
|
|
506
|
+
}) : items.map(function (item) {
|
|
507
|
+
var id = (0, _utils.getId)(item);
|
|
508
|
+
|
|
509
|
+
if ((0, _utils.isCategory)(item)) {
|
|
510
|
+
return _react.default.createElement(_Category.default, _extends({}, item, {
|
|
511
|
+
key: id,
|
|
512
|
+
borderRadius: borderRadius,
|
|
513
|
+
showCheckbox: showCheckbox,
|
|
514
|
+
size: size
|
|
515
|
+
}));
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
return _react.default.createElement(_Option.default, _extends({}, item, {
|
|
304
519
|
key: id,
|
|
305
520
|
borderRadius: borderRadius,
|
|
306
521
|
showCheckbox: showCheckbox,
|
|
307
522
|
size: size
|
|
308
523
|
}));
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
return _react.default.createElement(_Option.default, _extends({}, item, {
|
|
312
|
-
key: id,
|
|
313
|
-
borderRadius: borderRadius,
|
|
314
|
-
showCheckbox: showCheckbox,
|
|
315
|
-
size: size
|
|
316
|
-
}));
|
|
524
|
+
}), droppableProvided.placeholder);
|
|
317
525
|
}))), actions && _react.default.createElement(Row, null, _react.default.createElement(_Footer.default, {
|
|
318
526
|
actions: actions
|
|
319
527
|
}))));
|