@longline/aqua-ui 1.0.251 → 1.0.252
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.
|
@@ -7,7 +7,7 @@ interface IColumnProps {
|
|
|
7
7
|
/**
|
|
8
8
|
* Optional label. `name` will be used if not specified.
|
|
9
9
|
*/
|
|
10
|
-
label?: string;
|
|
10
|
+
label?: string | React.ReactNode;
|
|
11
11
|
/**
|
|
12
12
|
* Column width. If a number, e.g. `1`, then it is the column's weight,
|
|
13
13
|
* relative to other columns. If it is a string, e.g. `50px`, then it is
|
|
@@ -30,8 +30,28 @@ var SourceColumnsBase = function (props) {
|
|
|
30
30
|
var handleQ = function (value) {
|
|
31
31
|
setQ(value);
|
|
32
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Convert a React node into a plain text string.
|
|
35
|
+
* Handles strings, numbers, arrays, and nested React elements recursively.
|
|
36
|
+
*/
|
|
37
|
+
var reactNodeToString = function (node) {
|
|
38
|
+
if (node === null || node === undefined || typeof node === 'boolean')
|
|
39
|
+
return null;
|
|
40
|
+
if (typeof node === 'string' || typeof node === 'number')
|
|
41
|
+
return String(node);
|
|
42
|
+
// If it's an array of nodes, recursively join them
|
|
43
|
+
if (Array.isArray(node)) {
|
|
44
|
+
return node.map(reactNodeToString).join('');
|
|
45
|
+
}
|
|
46
|
+
// If it's a React element, recurse into its children
|
|
47
|
+
if (React.isValidElement(node)) {
|
|
48
|
+
return reactNodeToString(node.props.children);
|
|
49
|
+
}
|
|
50
|
+
// Fallback
|
|
51
|
+
return '';
|
|
52
|
+
};
|
|
33
53
|
return (React.createElement("div", { className: props.className },
|
|
34
|
-
React.createElement(List, { maxItems: 6, search: q, placeholder: "Search...", onSearch: handleQ }, props.columns.filter(function (c) { return !q || (c.label || c.name).toLowerCase().includes(q); }).sort(function (a, b) { return (a.label || a.name).localeCompare(b.label || b.name); }).map(function (c) {
|
|
54
|
+
React.createElement(List, { maxItems: 6, search: q, placeholder: "Search...", onSearch: handleQ }, props.columns.filter(function (c) { return !q || (reactNodeToString(c.label) || c.name).toLowerCase().includes(q); }).sort(function (a, b) { return (reactNodeToString(a.label) || a.name).localeCompare(reactNodeToString(b.label) || b.name); }).map(function (c) {
|
|
35
55
|
return React.createElement(Entry, { key: c.name },
|
|
36
56
|
React.createElement(Selector, { disabled: c.fixed, checked: !!c.active, onChange: function () { return handleChange(c.name); } }),
|
|
37
57
|
c.label || c.name);
|