-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Pass min and max to Inputs.text Addresses Issue # 158 Creating a text type=date input ignores the min and max parameters making writing a ranged date input difficult * restore yarn.lock This was updated when I did a yarn update. It should not be changed as part of this pull request. * tweaking yarn.lock * Update yarn.lock * Update yarn.lock * Fixing Scratch.html fixing typo * fixed formatting * Adding min and max to readme * Update test/scratch.html Co-authored-by: Philippe Rivière <fil@rezo.net> * Update test/text-test.js Co-authored-by: Philippe Rivière <fil@rezo.net> * Update src/text.js Co-authored-by: Philippe Rivière <fil@rezo.net> * changed min max descriptions * Update src/text.js Co-authored-by: Philippe Rivière <fil@rezo.net> * added export textDate to test inputs index * Update README.md Co-authored-by: Philippe Rivière <fil@rezo.net> Co-authored-by: Philippe Rivière <fil@rezo.net>
- Loading branch information
Showing
7 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,7 @@ export { | |
|
||
export { | ||
text, | ||
textDate, | ||
textLabel, | ||
textLabelHtml, | ||
textValue, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<form class="__ns__"> | ||
<div class="__ns__-input"> | ||
<input type="date" name="text"> | ||
</div> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as Inputs from "@observablehq/inputs"; | ||
import tape from "./jsdom.js"; | ||
|
||
tape("Inputs.text() test initial value is set to ''", test => { | ||
const t = Inputs.text(); | ||
test.equal(t.value, ""); | ||
}); | ||
|
||
tape("Inputs.text() test setting various text properties ", test => { | ||
const t = Inputs.text({type: "password", label: "Name", placeholder: "Enter your name", value: "Anonymous"}); | ||
test.equal(t.value, "Anonymous"); | ||
test.equal(t.textContent.trim(), "Name"); | ||
test.equal(t.elements.text.placeholder, "Enter your name"); | ||
test.equal(t.elements.text.type, "password"); | ||
}); | ||
|
||
tape("Inputs.text() test type=date settings ", test => { | ||
const t = Inputs.text({type: "date", label: "Date", value: "1970-01-01"}); | ||
test.equal(t.value, "1970-01-01"); | ||
test.equal(t.textContent.trim(), "Date"); | ||
test.equal(t.elements.text.type, "date"); | ||
}); | ||
|
||
tape("Inputs.text() test type=date setting initial value ", test => { | ||
const t = Inputs.text({type: "date", label: "Date", value: "1970-01-01", min: "1970-01-01", max: "2021-07-11"}); | ||
test.equal(t.value, "1970-01-01"); | ||
test.equal(t.textContent.trim(), "Date"); | ||
test.equal(t.elements.text.type, "date"); | ||
test.equal(t.elements.text.min, "1970-01-01"); | ||
test.equal(t.elements.text.max, "2021-07-11"); | ||
}); | ||
|
||
tape("Inputs.text() test type=date settings for min and max", test => { | ||
const t = Inputs.text({type: "date", label: "Date", value: "2010-01-01", min: "2000-01-01", max: "2021-07-11"}); | ||
test.equal(t.value, "2010-01-01"); | ||
t.value = "2015-01-01"; | ||
test.equal(t.value, "2015-01-01"); | ||
t.value = "1999-01-01"; | ||
// We should not be able to the date to a value outside of the [min, max] range | ||
test.notEqual(t.value, "1999-01-01"); | ||
// verify that trying to set an invalid date does not change the existing value | ||
test.equal(t.value, "2015-01-01"); | ||
}); |