dtable-ui-component 0.1.78 → 0.1.79
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/DtableSelect/index.js +140 -0
- package/lib/index.js +3 -1
- package/package.json +2 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import Select, { components } from 'react-select';
|
|
8
|
+
var MenuSelectStyle = {
|
|
9
|
+
option: function option(provided, state) {
|
|
10
|
+
var isDisabled = state.isDisabled,
|
|
11
|
+
isSelected = state.isSelected,
|
|
12
|
+
isFocused = state.isFocused;
|
|
13
|
+
return _objectSpread(_objectSpread({}, provided), {}, {
|
|
14
|
+
cursor: isDisabled ? 'default' : 'pointer',
|
|
15
|
+
backgroundColor: isSelected ? '#5A98F8' : isFocused ? '#f5f5f5' : '#fff',
|
|
16
|
+
'.header-icon .dtable-font': {
|
|
17
|
+
color: isSelected ? '#fff' : '#aaa'
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
control: function control(provided) {
|
|
22
|
+
return _objectSpread(_objectSpread({}, provided), {}, {
|
|
23
|
+
fontSize: '14px',
|
|
24
|
+
cursor: 'pointer',
|
|
25
|
+
lineHeight: '1.5'
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
menuPortal: function menuPortal(base) {
|
|
29
|
+
return _objectSpread(_objectSpread({}, base), {}, {
|
|
30
|
+
zIndex: 9999
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
indicatorSeparator: function indicatorSeparator() {}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var DropdownIndicator = function DropdownIndicator(props) {
|
|
37
|
+
return components.DropdownIndicator && /*#__PURE__*/React.createElement(components.DropdownIndicator, props, /*#__PURE__*/React.createElement("span", {
|
|
38
|
+
className: "dtable-font dtable-icon-drop-down",
|
|
39
|
+
style: {
|
|
40
|
+
fontSize: '12px'
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var MenuList = function MenuList(props) {
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
onClick: function onClick(e) {
|
|
48
|
+
return e.nativeEvent.stopImmediatePropagation();
|
|
49
|
+
},
|
|
50
|
+
onMouseDown: function onMouseDown(e) {
|
|
51
|
+
return e.nativeEvent.stopImmediatePropagation();
|
|
52
|
+
}
|
|
53
|
+
}, /*#__PURE__*/React.createElement(components.MenuList, props, props.children));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
var Option = function Option(props) {
|
|
57
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
style: props.data.style
|
|
59
|
+
}, /*#__PURE__*/React.createElement(components.Option, props));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
var DTableSelect = /*#__PURE__*/function (_React$Component) {
|
|
63
|
+
_inherits(DTableSelect, _React$Component);
|
|
64
|
+
|
|
65
|
+
var _super = _createSuper(DTableSelect);
|
|
66
|
+
|
|
67
|
+
function DTableSelect() {
|
|
68
|
+
var _this;
|
|
69
|
+
|
|
70
|
+
_classCallCheck(this, DTableSelect);
|
|
71
|
+
|
|
72
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
73
|
+
args[_key] = arguments[_key];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
77
|
+
|
|
78
|
+
_this.getMenuPortalTarget = function () {
|
|
79
|
+
var menuPortalTarget = _this.props.menuPortalTarget;
|
|
80
|
+
return document.querySelector(menuPortalTarget);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return _this;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
_createClass(DTableSelect, [{
|
|
87
|
+
key: "render",
|
|
88
|
+
value: function render() {
|
|
89
|
+
var _this$props = this.props,
|
|
90
|
+
options = _this$props.options,
|
|
91
|
+
onChange = _this$props.onChange,
|
|
92
|
+
value = _this$props.value,
|
|
93
|
+
isSearchable = _this$props.isSearchable,
|
|
94
|
+
placeholder = _this$props.placeholder,
|
|
95
|
+
isMulti = _this$props.isMulti,
|
|
96
|
+
menuPosition = _this$props.menuPosition,
|
|
97
|
+
isClearable = _this$props.isClearable,
|
|
98
|
+
noOptionsMessage = _this$props.noOptionsMessage,
|
|
99
|
+
classNamePrefix = _this$props.classNamePrefix;
|
|
100
|
+
return /*#__PURE__*/React.createElement(Select, {
|
|
101
|
+
value: value,
|
|
102
|
+
onChange: onChange,
|
|
103
|
+
options: options,
|
|
104
|
+
isMulti: isMulti,
|
|
105
|
+
classNamePrefix: classNamePrefix,
|
|
106
|
+
styles: MenuSelectStyle,
|
|
107
|
+
components: {
|
|
108
|
+
Option: Option,
|
|
109
|
+
DropdownIndicator: DropdownIndicator,
|
|
110
|
+
MenuList: MenuList
|
|
111
|
+
},
|
|
112
|
+
placeholder: placeholder,
|
|
113
|
+
isSearchable: isSearchable,
|
|
114
|
+
isClearable: isClearable,
|
|
115
|
+
menuPosition: menuPosition || 'fixed' // when use default menuPosition(absolute), menuPortalTarget is unnecessary.
|
|
116
|
+
,
|
|
117
|
+
menuShouldScrollIntoView: true,
|
|
118
|
+
menuPortalTarget: this.getMenuPortalTarget(),
|
|
119
|
+
captureMenuScroll: false,
|
|
120
|
+
noOptionsMessage: noOptionsMessage
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}]);
|
|
124
|
+
|
|
125
|
+
return DTableSelect;
|
|
126
|
+
}(React.Component);
|
|
127
|
+
|
|
128
|
+
DTableSelect.defaultProps = {
|
|
129
|
+
options: [],
|
|
130
|
+
value: {},
|
|
131
|
+
isSearchable: false,
|
|
132
|
+
isClearable: false,
|
|
133
|
+
placeholder: '',
|
|
134
|
+
isMulti: false,
|
|
135
|
+
menuPortalTarget: '.modal',
|
|
136
|
+
noOptionsMessage: function noOptionsMessage() {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
export default DTableSelect;
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
export { default as toaster } from './toaster'; // Loading
|
|
3
3
|
|
|
4
4
|
export { default as Loading } from './Loading';
|
|
5
|
-
export { setLocale } from './lang'; //
|
|
5
|
+
export { setLocale } from './lang'; // dtable select
|
|
6
|
+
|
|
7
|
+
export { default as DtableSelect } from './DtableSelect'; // utils
|
|
6
8
|
|
|
7
9
|
export { getDateDisplayString, getNumberDisplayString, formatStringToNumber, formatNumberString } from './utils/value-format-utils'; // formatter
|
|
8
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-ui-component",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.79",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@seafile/react-image-lightbox": "0.0.9",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"react-app-polyfill": "^1.0.6",
|
|
21
21
|
"react-dom": "16.14.0",
|
|
22
22
|
"react-responsive": "^8.0.3",
|
|
23
|
+
"react-select": "^3.1.0",
|
|
23
24
|
"react-transition-group": "^4.4.1",
|
|
24
25
|
"reactstrap": "^8.4.1",
|
|
25
26
|
"rehype-format": "^2.2.0",
|