@rainbow-oh/yee-c 0.6.2 → 0.6.3
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/dist/cjs/Select/demo/orphan.d.ts +3 -0
- package/dist/cjs/Select/demo/orphan.js +78 -0
- package/dist/cjs/Select/interface.d.ts +11 -0
- package/dist/cjs/Select/select.js +18 -5
- package/dist/cjs/Selector/interface.d.ts +11 -0
- package/dist/cjs/Selector/selector.js +51 -16
- package/dist/cjs/Table/tbody/index.js +2 -2
- package/dist/cjs/Tag/style/index.less +9 -9
- package/dist/cjs/style/themes.css +1 -1
- package/dist/cjs/style/variables.css +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Select/demo/orphan.d.ts +3 -0
- package/dist/esm/Select/demo/orphan.js +77 -0
- package/dist/esm/Select/interface.d.ts +11 -0
- package/dist/esm/Select/select.js +22 -6
- package/dist/esm/Selector/interface.d.ts +11 -0
- package/dist/esm/Selector/selector.js +34 -10
- package/dist/esm/Table/tbody/index.js +3 -2
- package/dist/esm/Tag/style/index.less +9 -9
- package/dist/esm/style/themes.css +1 -1
- package/dist/esm/style/variables.css +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.css +1 -1
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +1 -1
- package/src/Select/demo/orphan.tsx +61 -0
- package/src/Select/index.en-US.md +3 -0
- package/src/Select/index.zh-CN.md +3 -0
- package/src/Select/interface.ts +11 -0
- package/src/Select/select.tsx +19 -3
- package/src/Selector/interface.ts +11 -0
- package/src/Selector/selector.tsx +56 -25
- package/src/Table/tbody/index.tsx +5 -3
- package/src/Tag/style/index.less +9 -9
- package/src/version.ts +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/Select/demo/orphan.tsx
|
|
30
|
+
var orphan_exports = {};
|
|
31
|
+
__export(orphan_exports, {
|
|
32
|
+
default: () => orphan_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(orphan_exports);
|
|
35
|
+
var import_yee_c = require("../..");
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var options = [
|
|
38
|
+
{ label: "Apple", value: "apple" },
|
|
39
|
+
{ label: "Banana", value: "banana" },
|
|
40
|
+
{ label: "Orange", value: "orange" },
|
|
41
|
+
{ label: "Pineapple", value: "pineapple" }
|
|
42
|
+
];
|
|
43
|
+
var orphanStyle = {
|
|
44
|
+
color: "#fa8c16",
|
|
45
|
+
fontStyle: "italic",
|
|
46
|
+
textDecoration: "underline dotted"
|
|
47
|
+
};
|
|
48
|
+
var orphan_default = () => {
|
|
49
|
+
const [single, setSingle] = (0, import_react.useState)("mangox");
|
|
50
|
+
const [multi, setMulti] = (0, import_react.useState)(["apple", "durian", "banana"]);
|
|
51
|
+
return /* @__PURE__ */ import_react.default.createElement(import_yee_c.Space, { direction: "vertical", style: { width: "100%" } }, /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", { style: { marginBottom: 8 } }, "Single — orphan value styled via ", /* @__PURE__ */ import_react.default.createElement("code", null, "orphanStyle")), /* @__PURE__ */ import_react.default.createElement(
|
|
52
|
+
import_yee_c.Select,
|
|
53
|
+
{
|
|
54
|
+
value: single,
|
|
55
|
+
onChange: (val) => setSingle(val),
|
|
56
|
+
options,
|
|
57
|
+
orphanStyle,
|
|
58
|
+
style: { width: 300 },
|
|
59
|
+
placeholder: "Please select"
|
|
60
|
+
}
|
|
61
|
+
)), /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", { style: { marginBottom: 8 } }, "Multiple — orphan tag styled via ", /* @__PURE__ */ import_react.default.createElement("code", null, "orphanClassName")), /* @__PURE__ */ import_react.default.createElement(
|
|
62
|
+
import_yee_c.Select,
|
|
63
|
+
{
|
|
64
|
+
mode: "multiple",
|
|
65
|
+
value: multi,
|
|
66
|
+
onChange: (val) => setMulti(val),
|
|
67
|
+
options,
|
|
68
|
+
orphanClassName: "demo-orphan-tag",
|
|
69
|
+
style: { width: 300 },
|
|
70
|
+
placeholder: "Please select"
|
|
71
|
+
}
|
|
72
|
+
)), /* @__PURE__ */ import_react.default.createElement("style", null, `
|
|
73
|
+
.demo-orphan-tag {
|
|
74
|
+
color: #fa541c;
|
|
75
|
+
font-style: italic;
|
|
76
|
+
}
|
|
77
|
+
`));
|
|
78
|
+
};
|
|
@@ -87,6 +87,17 @@ export interface SelectProps extends DataAttributeProps, Pick<SelectorProps, 'si
|
|
|
87
87
|
* Property to backfill into the select box
|
|
88
88
|
*/
|
|
89
89
|
optionLabelProp?: 'string' | (() => string);
|
|
90
|
+
/**
|
|
91
|
+
* Extra class name applied to the displayed value when it is not found
|
|
92
|
+
* in `options` (an "orphan" value). An orphan value is shown as the raw
|
|
93
|
+
* value itself; this lets you style it differently (e.g. to flag stale data).
|
|
94
|
+
*/
|
|
95
|
+
orphanClassName?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Extra inline style applied to the displayed value when it is not found
|
|
98
|
+
* in `options` (an "orphan" value).
|
|
99
|
+
*/
|
|
100
|
+
orphanStyle?: React.CSSProperties;
|
|
90
101
|
/**
|
|
91
102
|
* Callback when value changes
|
|
92
103
|
*/
|
|
@@ -86,7 +86,9 @@ var Select = (baseprops) => {
|
|
|
86
86
|
onFilter,
|
|
87
87
|
virtual,
|
|
88
88
|
itemHeight,
|
|
89
|
-
listHeight
|
|
89
|
+
listHeight,
|
|
90
|
+
orphanClassName,
|
|
91
|
+
orphanStyle
|
|
90
92
|
} = _a, rest = __objRest(_a, [
|
|
91
93
|
"prefixCls",
|
|
92
94
|
"options",
|
|
@@ -100,7 +102,9 @@ var Select = (baseprops) => {
|
|
|
100
102
|
"onFilter",
|
|
101
103
|
"virtual",
|
|
102
104
|
"itemHeight",
|
|
103
|
-
"listHeight"
|
|
105
|
+
"listHeight",
|
|
106
|
+
"orphanClassName",
|
|
107
|
+
"orphanStyle"
|
|
104
108
|
]);
|
|
105
109
|
const single = mode !== "multiple" && mode !== "tags" ? true : false;
|
|
106
110
|
const handleState = (value2) => {
|
|
@@ -126,6 +130,7 @@ var Select = (baseprops) => {
|
|
|
126
130
|
(_a2 = virtualApiRef.current) == null ? void 0 : _a2.scrollToIndex(index);
|
|
127
131
|
}, []);
|
|
128
132
|
const getOptions = (keys) => {
|
|
133
|
+
var _a2;
|
|
129
134
|
if (keys === "" || keys === null) {
|
|
130
135
|
return void 0;
|
|
131
136
|
}
|
|
@@ -133,9 +138,15 @@ var Select = (baseprops) => {
|
|
|
133
138
|
if (keys.length === 0) {
|
|
134
139
|
return [];
|
|
135
140
|
}
|
|
136
|
-
return
|
|
141
|
+
return keys.map((key) => {
|
|
142
|
+
const opt = options.find((o) => o.value === key);
|
|
143
|
+
return opt != null ? opt : { value: key, label: String(key) };
|
|
144
|
+
});
|
|
137
145
|
}
|
|
138
|
-
return options.find((opt) => opt.value === keys)
|
|
146
|
+
return (_a2 = options.find((opt) => opt.value === keys)) != null ? _a2 : {
|
|
147
|
+
value: keys,
|
|
148
|
+
label: String(keys)
|
|
149
|
+
};
|
|
139
150
|
};
|
|
140
151
|
const handleSelect = (key, e) => {
|
|
141
152
|
let keys;
|
|
@@ -236,7 +247,9 @@ var Select = (baseprops) => {
|
|
|
236
247
|
onClear: handleClear,
|
|
237
248
|
onRemove: handleRemove,
|
|
238
249
|
onSearch: handleSearch,
|
|
239
|
-
onKeyDown
|
|
250
|
+
onKeyDown,
|
|
251
|
+
orphanClassName,
|
|
252
|
+
orphanStyle
|
|
240
253
|
})
|
|
241
254
|
)
|
|
242
255
|
);
|
|
@@ -78,6 +78,17 @@ export interface PureSelectorProps {
|
|
|
78
78
|
* Custom text displayed in the input
|
|
79
79
|
*/
|
|
80
80
|
optionLabelProp?: string | ((option: TagType) => string);
|
|
81
|
+
/**
|
|
82
|
+
* Extra class name applied to the displayed value/tag when its key is not
|
|
83
|
+
* found in `options` (an "orphan" value). The orphan value is shown as the
|
|
84
|
+
* raw key itself; this lets you style it differently (e.g. to flag stale data).
|
|
85
|
+
*/
|
|
86
|
+
orphanClassName?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Extra inline style applied to the displayed value/tag when its key is not
|
|
89
|
+
* found in `options` (an "orphan" value).
|
|
90
|
+
*/
|
|
91
|
+
orphanStyle?: React.CSSProperties;
|
|
81
92
|
/**
|
|
82
93
|
* Control the open state
|
|
83
94
|
* */
|
|
@@ -98,6 +98,8 @@ var Selector = import_react.default.forwardRef(
|
|
|
98
98
|
disabled,
|
|
99
99
|
options = [],
|
|
100
100
|
selectedKeys,
|
|
101
|
+
orphanClassName,
|
|
102
|
+
orphanStyle,
|
|
101
103
|
allowClear = true,
|
|
102
104
|
placeholder,
|
|
103
105
|
closable = true,
|
|
@@ -121,6 +123,8 @@ var Selector = import_react.default.forwardRef(
|
|
|
121
123
|
"disabled",
|
|
122
124
|
"options",
|
|
123
125
|
"selectedKeys",
|
|
126
|
+
"orphanClassName",
|
|
127
|
+
"orphanStyle",
|
|
124
128
|
"allowClear",
|
|
125
129
|
"placeholder",
|
|
126
130
|
"closable",
|
|
@@ -141,9 +145,24 @@ var Selector = import_react.default.forwardRef(
|
|
|
141
145
|
value
|
|
142
146
|
});
|
|
143
147
|
const tags = (0, import_react.useMemo)(() => {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
148
|
+
if (!Array.isArray(options)) {
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
return selectedKeys.map((key) => {
|
|
152
|
+
const opt = options.find((o) => o.value === key);
|
|
153
|
+
if (opt) {
|
|
154
|
+
return __spreadProps(__spreadValues({}, opt), {
|
|
155
|
+
children: typeof optionLabelProp === "function" ? optionLabelProp(opt) : opt[optionLabelProp],
|
|
156
|
+
_orphan: false
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
value: key,
|
|
161
|
+
label: String(key),
|
|
162
|
+
children: String(key),
|
|
163
|
+
_orphan: true
|
|
164
|
+
};
|
|
165
|
+
});
|
|
147
166
|
}, [options, selectedKeys, optionLabelProp]);
|
|
148
167
|
const handleClick = () => {
|
|
149
168
|
if (inputRef.current && !disabled) {
|
|
@@ -210,22 +229,38 @@ var Selector = import_react.default.forwardRef(
|
|
|
210
229
|
};
|
|
211
230
|
const renderContent = () => {
|
|
212
231
|
if (multi) {
|
|
213
|
-
return tags.map(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
232
|
+
return tags.map(
|
|
233
|
+
(item, index) => {
|
|
234
|
+
const _a2 = item, { _orphan } = _a2, tagRest = __objRest(_a2, ["_orphan"]);
|
|
235
|
+
const _closable = typeof closable === "function" ? closable(item) : closable;
|
|
236
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
237
|
+
import_Tag.default,
|
|
238
|
+
__spreadProps(__spreadValues({}, tagRest), {
|
|
239
|
+
className: _orphan ? orphanClassName : void 0,
|
|
240
|
+
style: _orphan ? orphanStyle : void 0,
|
|
241
|
+
closable: _closable,
|
|
242
|
+
onClose: (e) => handleRemove(item, e),
|
|
243
|
+
key: item.value || index
|
|
244
|
+
})
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
);
|
|
224
248
|
}
|
|
225
249
|
const key = selectedKeys.length ? selectedKeys[0] : "";
|
|
226
250
|
const opt = Array.isArray(options) ? options.find((opt2) => opt2.value === key) : null;
|
|
227
|
-
const
|
|
228
|
-
|
|
251
|
+
const isOrphan = !opt && key !== "";
|
|
252
|
+
const label = opt ? typeof optionLabelProp === "function" ? optionLabelProp(opt) : opt[optionLabelProp] : isOrphan ? String(key) : null;
|
|
253
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, renderSearch(), label && /* @__PURE__ */ import_react.default.createElement(
|
|
254
|
+
"div",
|
|
255
|
+
{
|
|
256
|
+
className: (0, import_clsx.default)(
|
|
257
|
+
`${prefixCls}-selection-item`,
|
|
258
|
+
isOrphan && orphanClassName
|
|
259
|
+
),
|
|
260
|
+
style: isOrphan ? orphanStyle : void 0
|
|
261
|
+
},
|
|
262
|
+
label
|
|
263
|
+
));
|
|
229
264
|
};
|
|
230
265
|
const renderSuffix = () => {
|
|
231
266
|
return /* @__PURE__ */ import_react.default.createElement("span", { className: `${prefixCls}-arrow` }, loading ? /* @__PURE__ */ import_react.default.createElement(import_Spin.default, { size: "small" }) : suffix ? typeof suffix === "function" ? suffix() : suffix : /* @__PURE__ */ import_react.default.createElement(import_lucide_react.ChevronDown, { size: 16, strokeWidth: 1.5 }));
|
|
@@ -68,11 +68,11 @@ var import_lazy_row = __toESM(require("./lazy-row"));
|
|
|
68
68
|
var import_row = __toESM(require("./row"));
|
|
69
69
|
var TableBody = (props) => {
|
|
70
70
|
var _b, _c, _d;
|
|
71
|
-
const _a = props, { columns, pageData, lazyLoad } = _a, rest = __objRest(_a, ["columns", "pageData", "lazyLoad"]);
|
|
71
|
+
const _a = props, { columns, pageData, lazyLoad, noData } = _a, rest = __objRest(_a, ["columns", "pageData", "lazyLoad", "noData"]);
|
|
72
72
|
const { prefixCls, components, rowKey } = import_react.default.useContext(import_table.TableCtx);
|
|
73
73
|
const { locale } = (0, import_locale.useLocale)();
|
|
74
74
|
const { table: tableLocale } = locale;
|
|
75
|
-
const empty = /* @__PURE__ */ import_react.default.createElement("tbody", { className: `${prefixCls}-tbody` }, /* @__PURE__ */ import_react.default.createElement("tr", { className: `${prefixCls}-no-record` }, /* @__PURE__ */ import_react.default.createElement("td", { colSpan: 999 }, tableLocale.emptyText)));
|
|
75
|
+
const empty = /* @__PURE__ */ import_react.default.createElement("tbody", { className: `${prefixCls}-tbody` }, /* @__PURE__ */ import_react.default.createElement("tr", { className: `${prefixCls}-no-record` }, /* @__PURE__ */ import_react.default.createElement("td", { colSpan: 999 }, noData != null ? noData : tableLocale.emptyText)));
|
|
76
76
|
const dataLength = pageData.length;
|
|
77
77
|
if (dataLength === 0)
|
|
78
78
|
return empty;
|
|
@@ -149,15 +149,6 @@
|
|
|
149
149
|
line-height: var(--yee-tag-large-height);
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
&-close {
|
|
153
|
-
display: inline-flex;
|
|
154
|
-
padding: 0;
|
|
155
|
-
width: 16px;
|
|
156
|
-
height: 16px;
|
|
157
|
-
margin-left: var(--yee-tag-close-margin-left);
|
|
158
|
-
cursor: pointer;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
152
|
&-checkable {
|
|
162
153
|
margin: var(--yee-tag-checkable-margin);
|
|
163
154
|
color: var(--yee-tag-item-not-check-color);
|
|
@@ -177,4 +168,13 @@
|
|
|
177
168
|
background-color: var(--yee-tag-item-check-active-bg-color);
|
|
178
169
|
border-color: var(--yee-tag-item-check-active-border-color);
|
|
179
170
|
}
|
|
171
|
+
|
|
172
|
+
& &-close {
|
|
173
|
+
display: inline-flex;
|
|
174
|
+
padding: 0;
|
|
175
|
+
width: 16px;
|
|
176
|
+
height: 16px;
|
|
177
|
+
margin-left: var(--yee-tag-close-margin-left);
|
|
178
|
+
cursor: pointer;
|
|
179
|
+
}
|
|
180
180
|
}
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { Select, Space } from "../..";
|
|
8
|
+
import React, { useState } from 'react';
|
|
9
|
+
var options = [{
|
|
10
|
+
label: 'Apple',
|
|
11
|
+
value: 'apple'
|
|
12
|
+
}, {
|
|
13
|
+
label: 'Banana',
|
|
14
|
+
value: 'banana'
|
|
15
|
+
}, {
|
|
16
|
+
label: 'Orange',
|
|
17
|
+
value: 'orange'
|
|
18
|
+
}, {
|
|
19
|
+
label: 'Pineapple',
|
|
20
|
+
value: 'pineapple'
|
|
21
|
+
}];
|
|
22
|
+
|
|
23
|
+
// Inline style applied to an orphan value (a value not present in options)
|
|
24
|
+
var orphanStyle = {
|
|
25
|
+
color: '#fa8c16',
|
|
26
|
+
fontStyle: 'italic',
|
|
27
|
+
textDecoration: 'underline dotted'
|
|
28
|
+
};
|
|
29
|
+
export default (function () {
|
|
30
|
+
// 'mangox' is not in options → rendered as an orphan value
|
|
31
|
+
var _useState = useState('mangox'),
|
|
32
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
33
|
+
single = _useState2[0],
|
|
34
|
+
setSingle = _useState2[1];
|
|
35
|
+
// 'durian' is not in options → rendered as an orphan tag alongside normal ones
|
|
36
|
+
var _useState3 = useState(['apple', 'durian', 'banana']),
|
|
37
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
38
|
+
multi = _useState4[0],
|
|
39
|
+
setMulti = _useState4[1];
|
|
40
|
+
return /*#__PURE__*/React.createElement(Space, {
|
|
41
|
+
direction: "vertical",
|
|
42
|
+
style: {
|
|
43
|
+
width: '100%'
|
|
44
|
+
}
|
|
45
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
style: {
|
|
47
|
+
marginBottom: 8
|
|
48
|
+
}
|
|
49
|
+
}, "Single \u2014 orphan value styled via ", /*#__PURE__*/React.createElement("code", null, "orphanStyle")), /*#__PURE__*/React.createElement(Select, {
|
|
50
|
+
value: single,
|
|
51
|
+
onChange: function onChange(val) {
|
|
52
|
+
return setSingle(val);
|
|
53
|
+
},
|
|
54
|
+
options: options,
|
|
55
|
+
orphanStyle: orphanStyle,
|
|
56
|
+
style: {
|
|
57
|
+
width: 300
|
|
58
|
+
},
|
|
59
|
+
placeholder: "Please select"
|
|
60
|
+
})), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
style: {
|
|
62
|
+
marginBottom: 8
|
|
63
|
+
}
|
|
64
|
+
}, "Multiple \u2014 orphan tag styled via ", /*#__PURE__*/React.createElement("code", null, "orphanClassName")), /*#__PURE__*/React.createElement(Select, {
|
|
65
|
+
mode: "multiple",
|
|
66
|
+
value: multi,
|
|
67
|
+
onChange: function onChange(val) {
|
|
68
|
+
return setMulti(val);
|
|
69
|
+
},
|
|
70
|
+
options: options,
|
|
71
|
+
orphanClassName: "demo-orphan-tag",
|
|
72
|
+
style: {
|
|
73
|
+
width: 300
|
|
74
|
+
},
|
|
75
|
+
placeholder: "Please select"
|
|
76
|
+
})), /*#__PURE__*/React.createElement("style", null, "\n .demo-orphan-tag {\n color: #fa541c;\n font-style: italic;\n }\n "));
|
|
77
|
+
});
|
|
@@ -87,6 +87,17 @@ export interface SelectProps extends DataAttributeProps, Pick<SelectorProps, 'si
|
|
|
87
87
|
* Property to backfill into the select box
|
|
88
88
|
*/
|
|
89
89
|
optionLabelProp?: 'string' | (() => string);
|
|
90
|
+
/**
|
|
91
|
+
* Extra class name applied to the displayed value when it is not found
|
|
92
|
+
* in `options` (an "orphan" value). An orphan value is shown as the raw
|
|
93
|
+
* value itself; this lets you style it differently (e.g. to flag stale data).
|
|
94
|
+
*/
|
|
95
|
+
orphanClassName?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Extra inline style applied to the displayed value when it is not found
|
|
98
|
+
* in `options` (an "orphan" value).
|
|
99
|
+
*/
|
|
100
|
+
orphanStyle?: React.CSSProperties;
|
|
90
101
|
/**
|
|
91
102
|
* Callback when value changes
|
|
92
103
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["prefixCls", "options", "placement", "mode", "value", "defaultValue", "optionFilterProp", "disabled", "onChange", "onFilter", "virtual", "itemHeight", "listHeight"];
|
|
1
|
+
var _excluded = ["prefixCls", "options", "placement", "mode", "value", "defaultValue", "optionFilterProp", "disabled", "onChange", "onFilter", "virtual", "itemHeight", "listHeight", "orphanClassName", "orphanStyle"];
|
|
2
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
3
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
4
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -43,6 +43,8 @@ var Select = function Select(baseprops) {
|
|
|
43
43
|
virtual = props.virtual,
|
|
44
44
|
itemHeight = props.itemHeight,
|
|
45
45
|
listHeight = props.listHeight,
|
|
46
|
+
orphanClassName = props.orphanClassName,
|
|
47
|
+
orphanStyle = props.orphanStyle,
|
|
46
48
|
rest = _objectWithoutProperties(props, _excluded);
|
|
47
49
|
var single = mode !== 'multiple' && mode !== 'tags' ? true : false;
|
|
48
50
|
var handleState = function handleState(value) {
|
|
@@ -79,6 +81,7 @@ var Select = function Select(baseprops) {
|
|
|
79
81
|
(_virtualApiRef$curren = virtualApiRef.current) === null || _virtualApiRef$curren === void 0 || _virtualApiRef$curren.scrollToIndex(index);
|
|
80
82
|
}, []);
|
|
81
83
|
var getOptions = function getOptions(keys) {
|
|
84
|
+
var _options$find;
|
|
82
85
|
if (keys === '' || keys === null) {
|
|
83
86
|
return undefined;
|
|
84
87
|
}
|
|
@@ -86,13 +89,24 @@ var Select = function Select(baseprops) {
|
|
|
86
89
|
if (keys.length === 0) {
|
|
87
90
|
return [];
|
|
88
91
|
}
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
// 按 keys 顺序回填,找不到的 key 构造 label=value 的兜底项(孤儿值),
|
|
93
|
+
// 与 Selector 的显示保持一致,避免 onChange 第二参数丢值。
|
|
94
|
+
return keys.map(function (key) {
|
|
95
|
+
var opt = options.find(function (o) {
|
|
96
|
+
return o.value === key;
|
|
97
|
+
});
|
|
98
|
+
return opt !== null && opt !== void 0 ? opt : {
|
|
99
|
+
value: key,
|
|
100
|
+
label: String(key)
|
|
101
|
+
};
|
|
91
102
|
});
|
|
92
103
|
}
|
|
93
|
-
return options.find(function (opt) {
|
|
104
|
+
return (_options$find = options.find(function (opt) {
|
|
94
105
|
return opt.value === keys;
|
|
95
|
-
})
|
|
106
|
+
})) !== null && _options$find !== void 0 ? _options$find : {
|
|
107
|
+
value: keys,
|
|
108
|
+
label: String(keys)
|
|
109
|
+
};
|
|
96
110
|
};
|
|
97
111
|
var handleSelect = function handleSelect(key, e) {
|
|
98
112
|
var keys;
|
|
@@ -195,7 +209,9 @@ var Select = function Select(baseprops) {
|
|
|
195
209
|
onClear: handleClear,
|
|
196
210
|
onRemove: handleRemove,
|
|
197
211
|
onSearch: handleSearch,
|
|
198
|
-
onKeyDown: onKeyDown
|
|
212
|
+
onKeyDown: onKeyDown,
|
|
213
|
+
orphanClassName: orphanClassName,
|
|
214
|
+
orphanStyle: orphanStyle
|
|
199
215
|
})));
|
|
200
216
|
};
|
|
201
217
|
export default Select;
|
|
@@ -78,6 +78,17 @@ export interface PureSelectorProps {
|
|
|
78
78
|
* Custom text displayed in the input
|
|
79
79
|
*/
|
|
80
80
|
optionLabelProp?: string | ((option: TagType) => string);
|
|
81
|
+
/**
|
|
82
|
+
* Extra class name applied to the displayed value/tag when its key is not
|
|
83
|
+
* found in `options` (an "orphan" value). The orphan value is shown as the
|
|
84
|
+
* raw key itself; this lets you style it differently (e.g. to flag stale data).
|
|
85
|
+
*/
|
|
86
|
+
orphanClassName?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Extra inline style applied to the displayed value/tag when its key is not
|
|
89
|
+
* found in `options` (an "orphan" value).
|
|
90
|
+
*/
|
|
91
|
+
orphanStyle?: React.CSSProperties;
|
|
81
92
|
/**
|
|
82
93
|
* Control the open state
|
|
83
94
|
* */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["prefixCls", "mode", "className", "style", "optionLabelProp", "searchable", "disabled", "options", "selectedKeys", "allowClear", "placeholder", "closable", "suffix", "value", "open", "loading", "size", "onSearch", "onRemove", "onClear", "onOpenChange", "onKeyDown"]
|
|
2
|
+
var _excluded = ["prefixCls", "mode", "className", "style", "optionLabelProp", "searchable", "disabled", "options", "selectedKeys", "orphanClassName", "orphanStyle", "allowClear", "placeholder", "closable", "suffix", "value", "open", "loading", "size", "onSearch", "onRemove", "onClear", "onOpenChange", "onKeyDown"],
|
|
3
|
+
_excluded2 = ["_orphan"];
|
|
3
4
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
4
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -37,6 +38,8 @@ var Selector = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
37
38
|
_props$options = props.options,
|
|
38
39
|
options = _props$options === void 0 ? [] : _props$options,
|
|
39
40
|
selectedKeys = props.selectedKeys,
|
|
41
|
+
orphanClassName = props.orphanClassName,
|
|
42
|
+
orphanStyle = props.orphanStyle,
|
|
40
43
|
_props$allowClear = props.allowClear,
|
|
41
44
|
allowClear = _props$allowClear === void 0 ? true : _props$allowClear,
|
|
42
45
|
placeholder = props.placeholder,
|
|
@@ -63,13 +66,27 @@ var Selector = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
63
66
|
searchValue = _useMergedState2[0],
|
|
64
67
|
setSearchValue = _useMergedState2[1];
|
|
65
68
|
var tags = useMemo(function () {
|
|
66
|
-
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
if (!Array.isArray(options)) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
// 按 selectedKeys 顺序渲染;找不到的 key 作为孤儿值回退显示 value 本身
|
|
73
|
+
return selectedKeys.map(function (key) {
|
|
74
|
+
var opt = options.find(function (o) {
|
|
75
|
+
return o.value === key;
|
|
71
76
|
});
|
|
72
|
-
|
|
77
|
+
if (opt) {
|
|
78
|
+
return _objectSpread(_objectSpread({}, opt), {}, {
|
|
79
|
+
children: typeof optionLabelProp === 'function' ? optionLabelProp(opt) : opt[optionLabelProp],
|
|
80
|
+
_orphan: false
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
value: key,
|
|
85
|
+
label: String(key),
|
|
86
|
+
children: String(key),
|
|
87
|
+
_orphan: true
|
|
88
|
+
};
|
|
89
|
+
});
|
|
73
90
|
}, [options, selectedKeys, optionLabelProp]);
|
|
74
91
|
var handleClick = function handleClick() {
|
|
75
92
|
if (inputRef.current && !disabled) {
|
|
@@ -124,8 +141,12 @@ var Selector = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
124
141
|
var renderContent = function renderContent() {
|
|
125
142
|
if (multi) {
|
|
126
143
|
return tags.map(function (item, index) {
|
|
144
|
+
var _orphan = item._orphan,
|
|
145
|
+
tagRest = _objectWithoutProperties(item, _excluded2);
|
|
127
146
|
var _closable = typeof closable === 'function' ? closable(item) : closable;
|
|
128
|
-
return /*#__PURE__*/React.createElement(Tag, _extends({},
|
|
147
|
+
return /*#__PURE__*/React.createElement(Tag, _extends({}, tagRest, {
|
|
148
|
+
className: _orphan ? orphanClassName : undefined,
|
|
149
|
+
style: _orphan ? orphanStyle : undefined,
|
|
129
150
|
closable: _closable,
|
|
130
151
|
onClose: function onClose(e) {
|
|
131
152
|
return handleRemove(item, e);
|
|
@@ -138,9 +159,12 @@ var Selector = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
138
159
|
var opt = Array.isArray(options) ? options.find(function (opt) {
|
|
139
160
|
return opt.value === key;
|
|
140
161
|
}) : null;
|
|
141
|
-
|
|
162
|
+
// 孤儿值:key 非空但在 options 中找不到时,回退显示 value 本身
|
|
163
|
+
var isOrphan = !opt && key !== '';
|
|
164
|
+
var label = opt ? typeof optionLabelProp === 'function' ? optionLabelProp(opt) : opt[optionLabelProp] : isOrphan ? String(key) : null;
|
|
142
165
|
return /*#__PURE__*/React.createElement(React.Fragment, null, renderSearch(), label && /*#__PURE__*/React.createElement("div", {
|
|
143
|
-
className: "".concat(prefixCls, "-selection-item")
|
|
166
|
+
className: clsx("".concat(prefixCls, "-selection-item"), isOrphan && orphanClassName),
|
|
167
|
+
style: isOrphan ? orphanStyle : undefined
|
|
144
168
|
}, label));
|
|
145
169
|
};
|
|
146
170
|
var renderSuffix = function renderSuffix() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["columns", "pageData", "lazyLoad"];
|
|
1
|
+
var _excluded = ["columns", "pageData", "lazyLoad", "noData"];
|
|
2
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
3
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -12,6 +12,7 @@ var TableBody = function TableBody(props) {
|
|
|
12
12
|
var columns = props.columns,
|
|
13
13
|
pageData = props.pageData,
|
|
14
14
|
lazyLoad = props.lazyLoad,
|
|
15
|
+
noData = props.noData,
|
|
15
16
|
rest = _objectWithoutProperties(props, _excluded);
|
|
16
17
|
var _React$useContext = React.useContext(TableCtx),
|
|
17
18
|
prefixCls = _React$useContext.prefixCls,
|
|
@@ -26,7 +27,7 @@ var TableBody = function TableBody(props) {
|
|
|
26
27
|
className: "".concat(prefixCls, "-no-record")
|
|
27
28
|
}, /*#__PURE__*/React.createElement("td", {
|
|
28
29
|
colSpan: 999
|
|
29
|
-
}, tableLocale.emptyText)));
|
|
30
|
+
}, noData !== null && noData !== void 0 ? noData : tableLocale.emptyText)));
|
|
30
31
|
var dataLength = pageData.length;
|
|
31
32
|
if (dataLength === 0) return empty;
|
|
32
33
|
var BodyWrapper = (_components$body$tbod = components === null || components === void 0 || (_components$body = components.body) === null || _components$body === void 0 ? void 0 : _components$body.tbody) !== null && _components$body$tbod !== void 0 ? _components$body$tbod : 'tbody';
|