Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.5.21

- `InputConfig`:
- Added field `precision`.
- Added support for type `decimal`.

## 2.5.20

- `UIComponent`:
Expand Down
2 changes: 1 addition & 1 deletion lib/src/bones_ui.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class BonesUI {
static const String version = '2.5.20';
static const String version = '2.5.21';
}
34 changes: 34 additions & 0 deletions lib/src/component/input_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class InputConfig {
final String _type;
String? value;
final bool? checked;
final int? precision;
final String? _placeholder;
final Map<String, String>? _attributes;
final Map<String, String>? _options;
Expand Down Expand Up @@ -75,6 +76,7 @@ class InputConfig {
var type = parseString(findKeyValue(config, ['type'], true), 'text');
var value = parseString(findKeyValue(config, ['value'], true), '');
var checked = parseBool(findKeyValue(config, ['checked'], true));
var precision = parseInt(findKeyValue(config, ['precision'], true));
var attributes = findKeyValue(config, ['attributes'], true);
var classes = findKeyValue(config, ['class', 'classes'], true);
var labelStyle = findKeyValue(config, ['labelStyle'], true);
Expand All @@ -96,6 +98,7 @@ class InputConfig {
type: type,
value: value,
checked: checked,
precision: precision,
attributes: attributes,
options: options,
optional: optional,
Expand All @@ -114,6 +117,7 @@ class InputConfig {
String? type = 'text',
String? value = '',
this.checked,
this.precision,
String? placeholder = '',
Map<String, String>? attributes,
Map<String, String>? options,
Expand Down Expand Up @@ -259,6 +263,8 @@ class InputConfig {
}
} else if (inputType == 'textarea') {
inputElement = _renderTextArea(inputValue);
} else if (inputType == 'decimal') {
inputElement = _renderDecimal(inputValue);
} else if (inputType == 'select') {
inputElement = _renderSelect(inputValue);
} else if (inputType == 'image') {
Expand Down Expand Up @@ -405,6 +411,34 @@ class InputConfig {
return textArea;
}

InputElement _renderDecimal(Object? inputValue) {
var valText = _resolveValueText(inputValue);

var input = InputElement()
..type = 'number'
..value = valText ?? ''
..style.width = '100%';

var precision = this.precision;
if (precision != null) {
String step;

if (precision == 0) {
step = '1';
} else if (precision == 1) {
step = '0.1';
} else if (precision >= 2) {
step = '0.${'0' * (precision - 1)}1';
} else {
step = 'any';
}

input.step = step;
}

return input;
}

Element _renderGenericInput(String? inputType, Object? inputValue) {
var valText = _resolveValueText(inputValue);

Expand Down
2 changes: 1 addition & 1 deletion 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.20
version: 2.5.21
homepage: https://github.com/Colossus-Services/bones_ui

environment:
Expand Down