Skip to content

Commit f250a30

Browse files
committed
[*] Select: typed interface, hybrid search, displays.
- Added AdaptiveKeyboard system supporting universal language matching - Implemented 4-tier hybrid matching strategy with priority ordering - Added support for non-Latin scripts (Cyrillic, Arabic, CJK, Indic, Greek) - Enhanced with smart features including automatic keyboard layout detection - Implemented self-improving system through adaptive learning - Added typo tolerance with keyboard-aware substitution costs - Enabled mixed-script matching capabilities Matching strategy priority: 1. Learned patterns (user corrections, highest priority) 2. Physical key distance (layout-independent proximity) 3. Unicode similarity (codepoint-based matching) 4. Phonetic groups (cross-script phonetic similarity) - Fixed select button to show proper capitalized display text - Enhanced separation between machine-readable values and human-readable display - Added proper display text preservation between selections - Implemented clean fallback to formatted value when display not provided Before: Selects "Apple" → Button shows "apple" After: Selects "Apple" → Button shows "Apple" - Fixed type inference errors with explicit generic annotations - Added required on_display_change callback to demo examples - Improved documentation with clear value vs display usage examples - Enhanced all SelectOption components with proper display props - Updated all code examples to show best practices - Moved tests from dedicated files into modules where they belong - Added comprehensive multi-language test coverage (17 tests total) - Added test scenarios for adaptive learning and user corrections - Added physical key distance and unicode similarity tests - Added cross-script phonetic matching test cases - Verified all existing functionality preserved with full regression testing
1 parent 28a82eb commit f250a30

File tree

7 files changed

+1727
-1327
lines changed

7 files changed

+1727
-1327
lines changed

preview/src/components/select/variants/main/mod.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ pub fn Demo() -> Element {
1010
rel: "stylesheet",
1111
href: asset!("/src/components/select/variants/main/style.css"),
1212
}
13-
Select {
13+
Select::<String> {
1414
class: "select",
1515
placeholder: "Select a fruit...",
16-
SelectTrigger {
16+
on_display_change: |_| {},
17+
SelectTrigger::<String> {
1718
class: "select-trigger",
1819
aria_label: "Select Trigger",
1920
width: "12rem",
@@ -24,19 +25,20 @@ pub fn Demo() -> Element {
2425
polyline { points: "6 9 12 15 18 9" }
2526
}
2627
}
27-
SelectList {
28+
SelectList::<String> {
2829
class: "select-list",
2930
aria_label: "Select Demo",
30-
SelectGroup {
31+
SelectGroup::<String> {
3132
class: "select-group",
3233
SelectGroupLabel {
3334
class: "select-group-label",
3435
"Fruits"
3536
}
36-
SelectOption {
37+
SelectOption::<String> {
3738
index: 0usize,
3839
class: "select-option",
3940
value: "apple".to_string(),
41+
display: "Apple".to_string(),
4042
"Apple"
4143
SelectItemIndicator {
4244
svg {
@@ -47,10 +49,11 @@ pub fn Demo() -> Element {
4749
}
4850
}
4951
}
50-
SelectOption {
52+
SelectOption::<String> {
5153
index: 1usize,
5254
class: "select-option",
5355
value: "banana".to_string(),
56+
display: "Banana".to_string(),
5457
"Banana"
5558
SelectItemIndicator {
5659
svg {
@@ -61,10 +64,11 @@ pub fn Demo() -> Element {
6164
}
6265
}
6366
}
64-
SelectOption {
67+
SelectOption::<String> {
6568
index: 2usize,
6669
class: "select-option",
6770
value: "orange".to_string(),
71+
display: "Orange".to_string(),
6872
"Orange"
6973
SelectItemIndicator {
7074
svg {
@@ -75,10 +79,11 @@ pub fn Demo() -> Element {
7579
}
7680
}
7781
}
78-
SelectOption {
82+
SelectOption::<String> {
7983
index: 3usize,
8084
class: "select-option",
8185
value: "strawberry".to_string(),
86+
display: "Strawberry".to_string(),
8287
"Strawberry"
8388
SelectItemIndicator {
8489
svg {
@@ -89,10 +94,11 @@ pub fn Demo() -> Element {
8994
}
9095
}
9196
}
92-
SelectOption {
97+
SelectOption::<String> {
9398
index: 4usize,
9499
class: "select-option",
95100
value: "watermelon".to_string(),
101+
display: "Watermelon".to_string(),
96102
"Watermelon"
97103
SelectItemIndicator {
98104
svg {
@@ -104,16 +110,17 @@ pub fn Demo() -> Element {
104110
}
105111
}
106112
}
107-
SelectGroup {
113+
SelectGroup::<String> {
108114
class: "select-group",
109115
SelectGroupLabel {
110116
class: "select-group-label",
111117
"Other"
112118
}
113-
SelectOption {
119+
SelectOption::<String> {
114120
index: 5usize,
115121
class: "select-option",
116122
value: "other".to_string(),
123+
display: "Other".to_string(),
117124
"Other"
118125
SelectItemIndicator {
119126
svg {

primitives/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ fn use_unique_id() -> Signal<String> {
6161
}
6262

6363
// Elements can only have one id so if the user provides their own, we must use it as the aria id.
64-
fn use_id_or<T: Clone + PartialEq + 'static>(mut gen_id: Signal<T>, user_id: ReadOnlySignal<Option<T>>) -> Memo<T> {
64+
fn use_id_or<T: Clone + PartialEq + 'static>(
65+
mut gen_id: Signal<T>,
66+
user_id: ReadOnlySignal<Option<T>>,
67+
) -> Memo<T> {
6568
// First, check if we have a user-provided ID
6669
let has_user_id = use_memo(move || user_id().is_some());
6770

0 commit comments

Comments
 (0)