foobara-typescript-react-command-form-generator 0.0.9 → 0.0.11
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/src/typescript_react_command_form_generator.rb +14 -1
- data/templates/CommandForm.tsx.erb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6287ed71992254c4af41c07e09d8fd63730b1190be2ac89d832fa8cb63e5bb48
|
4
|
+
data.tar.gz: 31c99cdc88b428c3e99ba324f54284963d7064b9df86aa66e342dea679211eef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b39488793ea4a5bbf50ecc072fe5a6a577367102c75b5d424fc7784567afd1141c58bd087da5fcfbbbb35ccca2f7d487a93d140d95be423a8bd84b06f4e10c73
|
7
|
+
data.tar.gz: 6cdbb375621c9b24c236082377844442b5611a72775b6f292685bf66e8e0e12134073a65ee0a70f199e3d0e305c93d66d58d3335065506a76e299ca2fb8e4dd6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## [0.0.11] - 2025-04-08
|
2
|
+
|
3
|
+
- Print out stringified errors for unexpected errors
|
4
|
+
- Cast e.target.value with parseInt/parseFloat when appropriate
|
5
|
+
|
6
|
+
## [0.0.10] - 2025-04-08
|
7
|
+
|
8
|
+
- Do not double up hashes on Outcome import
|
9
|
+
|
1
10
|
## [0.0.9] - 2025-04-08
|
2
11
|
|
3
12
|
- Don't make use of inputs for commands that don't have inputs
|
@@ -242,10 +242,23 @@ module Foobara
|
|
242
242
|
#{one_of.map { |value| "<option value=\"#{value}\">#{value}</option>" }.join}
|
243
243
|
</select>"
|
244
244
|
else
|
245
|
+
type = type_declaration.to_type
|
246
|
+
|
247
|
+
cast_value = if type.name.to_s == "integer" || type.extends_symbol?(:integer)
|
248
|
+
"parseInt(e.target.value)"
|
249
|
+
elsif type.name.to_s == "float" || type.extends_symbol?(:float)
|
250
|
+
# TODO: test this path
|
251
|
+
# :nocov:
|
252
|
+
"parseFloat(e.target.value)"
|
253
|
+
# :nocov:
|
254
|
+
else
|
255
|
+
"e.target.value"
|
256
|
+
end
|
257
|
+
|
245
258
|
"<input
|
246
259
|
#{"type=\"password\"" if sensitive?}
|
247
260
|
value={#{name} ?? \"\"}
|
248
|
-
onChange={(e) => { set#{name_upcase}(
|
261
|
+
onChange={(e) => { set#{name_upcase}(#{cast_value}) }}
|
249
262
|
placeholder=\"#{name_english}\"
|
250
263
|
/>"
|
251
264
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useState, JSX } from 'react'
|
2
2
|
|
3
|
-
import { Outcome } from "<%= path_to_root
|
3
|
+
import { Outcome } from "<%= path_to_root %>base/Outcome"
|
4
4
|
|
5
5
|
import { <%= command_name %> } from "<%= path_to_root %><%= command_generator.import_path %>"
|
6
6
|
<% unless empty_inputs? %>
|
@@ -60,7 +60,7 @@ export default function <%= command_name %>Form (): JSX.Element {
|
|
60
60
|
setResult(null)
|
61
61
|
}
|
62
62
|
} catch (error) {
|
63
|
-
setError(
|
63
|
+
setError(`Error executing command: ${JSON.stringify(error)}`)
|
64
64
|
setResult(null)
|
65
65
|
}
|
66
66
|
})
|