dtable-ui-component 6.0.110-mxj.1 → 6.0.110-mxj.2

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.
@@ -10,8 +10,8 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
10
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
11
11
  var _react = _interopRequireDefault(require("react"));
12
12
  var _reactSelect = _interopRequireWildcard(require("react-select"));
13
+ var _selectStyle = require("./select-style");
13
14
  var _selectDropdownIndicator = _interopRequireDefault(require("./select-dropdown-indicator"));
14
- var _DTableIcon = _interopRequireDefault(require("../DTableIcon"));
15
15
  var _jsxRuntime = require("react/jsx-runtime");
16
16
  const _excluded = ["innerProps"],
17
17
  _excluded2 = ["children"];
@@ -39,8 +39,8 @@ const ClearIndicator = _ref => {
39
39
  marginLeft: '-2px'
40
40
  },
41
41
  "aria-hidden": "true",
42
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableIcon.default, {
43
- symbol: "close",
42
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
43
+ className: "dtable-font dtable-icon-fork-number",
44
44
  style: {
45
45
  width: '12px',
46
46
  height: '12px'
@@ -79,25 +79,44 @@ const ValueContainer = _ref2 => {
79
79
  }));
80
80
  };
81
81
  class DTableSelect extends _react.default.Component {
82
+ constructor() {
83
+ super(...arguments);
84
+ this.getMenuPortalTarget = () => {
85
+ const {
86
+ menuPortalTarget = '.modal'
87
+ } = this.props;
88
+ return document.querySelector(menuPortalTarget);
89
+ };
90
+ this.handleSelectChange = val => {
91
+ const {
92
+ onChange
93
+ } = this.props;
94
+ if (!val.value) {
95
+ onChange('');
96
+ return;
97
+ }
98
+ onChange(val);
99
+ };
100
+ }
82
101
  render() {
83
102
  const {
84
- options,
85
- onChange,
86
- value,
87
- isSearchable,
88
- placeholder,
89
- isMulti,
103
+ options = [],
104
+ value = {},
105
+ isSearchable = false,
106
+ placeholder = '',
107
+ isMulti = false,
90
108
  menuPosition,
91
- isClearable,
92
- noOptionsMessage,
109
+ isClearable = true,
110
+ noOptionsMessage = () => {
111
+ return null;
112
+ },
93
113
  classNamePrefix,
94
- style,
95
114
  innerRef,
96
- isDisabled,
115
+ isDisabled = false,
97
116
  form,
117
+ className = '',
98
118
  customFilterOption,
99
- autoFocus,
100
- className
119
+ autoFocus
101
120
  } = this.props;
102
121
  if (isClearable) {
103
122
  if (value && value.label !== '--' && options[0].label !== '--') {
@@ -115,8 +134,11 @@ class DTableSelect extends _react.default.Component {
115
134
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, option), {}, {
116
135
  label: /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
117
136
  className: "d-flex align-items-center justify-content-between",
118
- children: [option.label, isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableIcon.default, {
119
- symbol: "check",
137
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
138
+ className: "select-option-label",
139
+ children: option.label
140
+ }), isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
141
+ className: "dtable-font dtable-icon-check",
120
142
  style: {
121
143
  width: '12px',
122
144
  height: '12px'
@@ -129,12 +151,12 @@ class DTableSelect extends _react.default.Component {
129
151
  value: value,
130
152
  isDisabled: isDisabled,
131
153
  ref: innerRef,
132
- onChange: onChange,
154
+ onChange: this.handleSelectChange,
133
155
  options: optionsWithCheck,
134
156
  isMulti: isMulti,
135
157
  className: className,
136
158
  classNamePrefix: classNamePrefix,
137
- styles: style,
159
+ styles: _selectStyle.MenuSelectStyle,
138
160
  components: {
139
161
  Option,
140
162
  DropdownIndicator,
@@ -148,7 +170,7 @@ class DTableSelect extends _react.default.Component {
148
170
  menuPosition: menuPosition || 'fixed' // when use default menuPosition(absolute), menuPortalTarget is unnecessary.
149
171
  ,
150
172
  menuShouldScrollIntoView: true,
151
- menuPortalTarget: document.querySelector(this.props.menuPortalTarget),
173
+ menuPortalTarget: this.getMenuPortalTarget(),
152
174
  captureMenuScroll: false,
153
175
  hideSelectedOptions: false,
154
176
  noOptionsMessage: noOptionsMessage,
@@ -158,18 +180,4 @@ class DTableSelect extends _react.default.Component {
158
180
  });
159
181
  }
160
182
  }
161
- exports.default = DTableSelect;
162
- DTableSelect.defaultProps = {
163
- options: [],
164
- value: {},
165
- isDisabled: false,
166
- isSearchable: false,
167
- isClearable: false,
168
- placeholder: '',
169
- isMulti: false,
170
- autoFocus: false,
171
- menuPortalTarget: '.modal',
172
- noOptionsMessage: () => {
173
- return null;
174
- }
175
- };
183
+ exports.default = DTableSelect;
@@ -6,15 +6,14 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
- var _DTableIcon = _interopRequireDefault(require("../../DTableIcon"));
10
9
  require("./index.css");
11
10
  var _jsxRuntime = require("react/jsx-runtime");
12
11
  const SelectDropdownIndicator = () => {
13
12
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
14
13
  className: "select-dropdown-indicator d-flex align-items-center",
15
14
  "aria-hidden": "true",
16
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableIcon.default, {
17
- symbol: "down"
15
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
16
+ className: "dtable-font dtable-icon-down3"
18
17
  })
19
18
  });
20
19
  };
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.MenuSelectStyle = void 0;
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
9
+ // Seahub select is based on seafile-ui.css, so use the following content to override the default react-select style
10
+ const DEFAULT_CONTROL_STYLE = {
11
+ fontSize: '14px',
12
+ padding: '0 4px',
13
+ border: '1px solid var(--bs-border-color) !important',
14
+ boxShadow: 'none',
15
+ backgroundColor: 'var(--bs-popover-bg)',
16
+ borderRadius: '4px',
17
+ outline: '0'
18
+ };
19
+ const FOCUS_CONTROL_STYLE = {
20
+ fontSize: '14px',
21
+ padding: '0 4px',
22
+ border: '1px solid #3e84f7',
23
+ boxShadow: 'none',
24
+ backgroundColor: 'var(--bs-popover-bg)',
25
+ borderRadius: '4px',
26
+ outline: '0'
27
+ };
28
+ const controlCallback = (provided, state) => {
29
+ const {
30
+ isDisabled,
31
+ isFocused
32
+ } = state;
33
+ if (isDisabled) {
34
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, provided), DEFAULT_CONTROL_STYLE), {}, {
35
+ cursor: 'default',
36
+ backgroundColor: '#f5f5f5',
37
+ opacity: 0.65
38
+ });
39
+ }
40
+ if (isFocused) {
41
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, provided), FOCUS_CONTROL_STYLE), {}, {
42
+ '&:hover': (0, _objectSpread2.default)((0, _objectSpread2.default)({}, provided), FOCUS_CONTROL_STYLE)
43
+ });
44
+ }
45
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, provided), {}, {
46
+ fontSize: '14px',
47
+ lineHeight: '1.5',
48
+ cursor: 'pointer'
49
+ }, DEFAULT_CONTROL_STYLE), {}, {
50
+ '&:hover': (0, _objectSpread2.default)({}, DEFAULT_CONTROL_STYLE)
51
+ });
52
+ };
53
+ const MenuSelectStyle = exports.MenuSelectStyle = {
54
+ // .react-select__menu / react-select-2-listbox
55
+ menu: base => {
56
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, base), {}, {
57
+ padding: '4px 0 4px 8px',
58
+ backgroundColor: 'var(--bs-popover-bg)',
59
+ border: '1px solid var(--bs-border-secondary-color)',
60
+ borderRadius: '4px',
61
+ boxShadow: '0px 6px 14px rgba(0, 0, 0, 0.1)',
62
+ marginTop: '4px'
63
+ });
64
+ },
65
+ // .react-select__menu-list)
66
+ menuList: provided => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, provided), {}, {
67
+ paddingRight: '8px'
68
+ }),
69
+ option: (provided, state) => {
70
+ const {
71
+ isDisabled,
72
+ isFocused,
73
+ isActive,
74
+ isVisited
75
+ } = state;
76
+ let bgColor;
77
+ if (isActive || isVisited) {
78
+ bgColor = 'rgba(0, 0, 0, 0.06)';
79
+ } else if (isFocused) {
80
+ bgColor = 'var(--bs-bg-color)';
81
+ } else {
82
+ bgColor = 'var(--bs-popover-bg)';
83
+ }
84
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, provided), {}, {
85
+ color: 'var(--bs-body-color)',
86
+ borderRadius: '4px',
87
+ minHeight: '32px',
88
+ padding: '6px 12px 6px 8px',
89
+ cursor: isDisabled ? 'default' : 'pointer',
90
+ backgroundColor: "".concat(bgColor, " !important")
91
+ });
92
+ },
93
+ control: controlCallback,
94
+ menuPortal: base => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, base), {}, {
95
+ zIndex: 9999,
96
+ backgroundColor: 'var(--bs-popover-bg)',
97
+ color: 'var(--bs-body-color)',
98
+ borderColor: 'var(--bs-border-secondary-color)'
99
+ }),
100
+ singleValue: provided => {
101
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, provided), {}, {
102
+ color: 'var(--bs-body-color)'
103
+ });
104
+ },
105
+ multiValue: provided => {
106
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, provided), {}, {
107
+ color: 'var(--bs-body-color)'
108
+ });
109
+ },
110
+ multiValueRemove: styles => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, styles), {}, {
111
+ color: '#909090',
112
+ ':hover': {
113
+ backgroundColor: 'transparent',
114
+ color: 'var(--bs-icon-color)'
115
+ }
116
+ }),
117
+ input: styles => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, styles), {}, {
118
+ color: 'var(--bs-body-color)'
119
+ }),
120
+ placeholder: (provided, state) => {
121
+ const {
122
+ isDisabled
123
+ } = state;
124
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, provided), {}, {
125
+ color: '#868e96',
126
+ opacity: isDisabled ? 0.65 : 1
127
+ });
128
+ },
129
+ indicatorSeparator: (styles, state) => {
130
+ return {
131
+ 'display': 'none'
132
+ };
133
+ }
134
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "6.0.110mxj.1",
3
+ "version": "6.0.110mxj.2",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "^5.0.4",