cynx-lib 1.3.28 → 1.3.30
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/package.json +1 -1
- package/ui/components/Select.jsx +26 -5
- package/ui/components/TabBar.jsx +1 -1
package/package.json
CHANGED
package/ui/components/Select.jsx
CHANGED
|
@@ -38,6 +38,8 @@ export default function Select({
|
|
|
38
38
|
style = {},
|
|
39
39
|
rounded = false,
|
|
40
40
|
showCount = false,
|
|
41
|
+
searchMode = 'includes',
|
|
42
|
+
filterOption,
|
|
41
43
|
}) {
|
|
42
44
|
const [open, setOpen] = useState(false);
|
|
43
45
|
const [query, setQuery] = useState('');
|
|
@@ -120,16 +122,35 @@ export default function Select({
|
|
|
120
122
|
const filtered = useMemo(() => {
|
|
121
123
|
if (!query) return options;
|
|
122
124
|
const q = query.toLowerCase().trim();
|
|
125
|
+
if (typeof filterOption === 'function') {
|
|
126
|
+
return options.filter(o => filterOption(o, q));
|
|
127
|
+
}
|
|
128
|
+
const isStartsWith = searchMode === 'starts_with' || searchMode === 'word_start';
|
|
123
129
|
return options.filter(o => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
130
|
+
const targets = [];
|
|
131
|
+
if (o.label != null) targets.push(String(o.label));
|
|
132
|
+
if (o.name != null && o.name !== o.label) targets.push(String(o.name));
|
|
133
|
+
if (o.search != null) targets.push(String(o.search));
|
|
134
|
+
if (o.employee_id != null) targets.push(String(o.employee_id));
|
|
135
|
+
if (o.code != null) targets.push(String(o.code));
|
|
136
|
+
if (o.title != null) targets.push(String(o.title));
|
|
137
|
+
if (targets.length === 0 && o.value != null) {
|
|
138
|
+
targets.push(String(o.value));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
for (const t of targets) {
|
|
142
|
+
const str = t.toLowerCase().trim();
|
|
143
|
+
if (isStartsWith) {
|
|
144
|
+
if (str.startsWith(q)) return true;
|
|
145
|
+
const words = str.split(/[\s\-.,()\/_:]+/);
|
|
146
|
+
if (words.some(w => w.startsWith(q))) return true;
|
|
147
|
+
} else {
|
|
148
|
+
if (str.includes(q)) return true;
|
|
128
149
|
}
|
|
129
150
|
}
|
|
130
151
|
return false;
|
|
131
152
|
});
|
|
132
|
-
}, [options, query]);
|
|
153
|
+
}, [options, query, searchMode, filterOption]);
|
|
133
154
|
|
|
134
155
|
function handleOpen() {
|
|
135
156
|
if (disabled) return;
|
package/ui/components/TabBar.jsx
CHANGED
|
@@ -160,7 +160,7 @@ export default function TabBar({ tabs, active, onChange, capitalize = false, pad
|
|
|
160
160
|
borderRadius: 'var(--radxs, 6px)',
|
|
161
161
|
background: isActive ? 'var(--surface,#fff)' : isOpen ? 'var(--grey-2, #e5e7eb)' : 'transparent',
|
|
162
162
|
boxShadow: isActive ? '0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06)' : 'none',
|
|
163
|
-
fontSize: '.75rem', fontWeight: isActive ? 600 :
|
|
163
|
+
fontSize: '.75rem', fontWeight: isActive ? 600 : 600,
|
|
164
164
|
color: isActive ? 'var(--primary-text, #0f111c)' : 'var(--muted, #9b9daa)',
|
|
165
165
|
cursor: t.disabled ? 'not-allowed' : 'pointer',
|
|
166
166
|
opacity: t.disabled ? 0.38 : 1,
|