Skip to content

Commit

Permalink
v2.5.7
Browse files Browse the repository at this point in the history
- `UIElementExtension`:
  - `setValue`: handle `SelectElement`.

- dom_tools: ^2.3.1
- archive: ^3.6.1
- test: ^1.25.8
- test_api: ^0.7.3
- test_core: ^0.6.5
  • Loading branch information
gmpassos committed Jul 12, 2024
1 parent da09019 commit a64dfa3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 2.5.7

- `UIElementExtension`:
- `setValue`: handle `SelectElement`.

- dom_tools: ^2.3.1
- archive: ^3.6.1
- test: ^1.25.8
- test_api: ^0.7.3
- test_core: ^0.6.5

## 2.5.6

- `ElementExtension`:
Expand Down
20 changes: 20 additions & 0 deletions lib/src/bones_ui_web.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:html' as web;
import 'package:collection/collection.dart';
import 'package:dom_tools/dom_tools.dart';
import 'package:swiss_knife/swiss_knife.dart';

Expand Down Expand Up @@ -49,6 +50,25 @@ extension UIElementExtension on UIElement {
} else {
element.value = value;
}
} else if (element is web.SelectElement) {
if (value == null) {
element.selectedIndex = -1;
} else {
var options = element.options;

var opt = options.firstWhereOrNull((op) => op.value == value);

opt ??= options.firstWhereOrNull(
(op) => equalsIgnoreAsciiCase(op.value.trim(), value.trim()));

opt ??= options.firstWhereOrNull((op) {
var label = op.label;
return label != null &&
equalsIgnoreAsciiCase(label.trim(), value.trim());
});

element.selectedIndex = opt?.index ?? -1;
}
} else {
element.text = value;
}
Expand Down
12 changes: 6 additions & 6 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: bones_ui
description: Bones_UI - An intuitive and user-friendly Web User Interface framework for Dart.
version: 2.5.6
version: 2.5.7
homepage: https://github.com/Colossus-Services/bones_ui

environment:
Expand All @@ -12,7 +12,7 @@ executables:

dependencies:
intl_messages: ^2.3.0
dom_tools: ^2.3.0
dom_tools: ^2.3.1
dom_builder: ^2.2.5
json_render: ^2.1.0
json_object_mapper: ^2.0.1
Expand All @@ -28,14 +28,14 @@ dependencies:
intl: ^0.19.0
enum_to_string: ^2.0.1
yaml: ^3.1.2
archive: ^3.5.1
archive: ^3.6.1
collection: ^1.18.0
args: ^2.5.0
logging: ^1.2.0
path: ^1.9.0
test: ^1.25.7
test_api: ^0.7.2
test_core: ^0.6.4
test: ^1.25.8
test_api: ^0.7.3
test_core: ^0.6.5
stream_channel: ^2.1.2
stack_trace: ^1.11.1

Expand Down

0 comments on commit a64dfa3

Please sign in to comment.