Merge pull request #497 from NoRedInk/av/upgrade-text-input

Upgrade to elm-format 0.8.3, and update TextInput upgrade script
This commit is contained in:
Aaron VonderHaar 2020-04-16 17:28:52 -07:00 committed by GitHub
commit 70d14f5429
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 311 additions and 64 deletions

View File

@ -1,9 +1,186 @@
module Main exposing (upgrade_Nri_Ui_TextInput_V5_view)
module Main exposing (..)
{-| NOTE: requires elm-refactor alpha-220-g24db2f5 or later.
-}
import ElmFix
import Nri.Ui.TextInput.V6 as TextInput
--
-- Nri.Ui.TextInput.V3 to V6
--
upgrade_Nri_Ui_TextInput_V3_view config =
TextInput.view
config.label
(config.type_ config.onInput)
(List.filterMap identity
[ case config.isInError of
False ->
Nothing
_ ->
Just (TextInput.errorIf config.isInError)
, if config.placeholder == config.label then
Nothing
else
Just (TextInput.placeholder config.placeholder)
, if config.autofocus then
Just TextInput.autofocus
else
Nothing
, if config.showLabel then
Nothing
else
Just TextInput.hiddenLabel
]
)
config.value
upgrade_Nri_Ui_TextInput_V3_writing config =
TextInput.view
config.label
(config.type_ config.onInput)
(List.filterMap identity
[ Just TextInput.writing
, Just (TextInput.errorIf config.isInError)
, if config.placeholder == config.label then
Nothing
else
Just (TextInput.placeholder config.placeholder)
, if config.autofocus then
Just TextInput.autofocus
else
Nothing
, if config.showLabel then
Nothing
else
Just TextInput.hiddenLabel
]
)
config.value
upgrade_Nri_Ui_TextInput_V3_number =
TextInput.number
upgrade_Nri_Ui_TextInput_V3_text =
TextInput.text
--
-- Nri.Ui.TextInput.V4 to V6
--
upgrade_Nri_Ui_TextInput_V4_view config =
TextInput.view
config.label
(config.type_ config.onInput)
(List.filterMap identity
[ case config.isInError of
False ->
Nothing
_ ->
Just (TextInput.errorIf config.isInError)
, case config.onBlur of
Nothing ->
Nothing
Just onBlur ->
Just (TextInput.onBlur onBlur)
, if config.placeholder == config.label then
Nothing
else
Just (TextInput.placeholder config.placeholder)
, case config.autofocus of
False ->
Nothing
True ->
Just TextInput.autofocus
, case config.showLabel of
True ->
Nothing
False ->
Just TextInput.hiddenLabel
]
)
config.value
upgrade_Nri_Ui_TextInput_V4_writing config =
TextInput.view
config.label
(config.type_ config.onInput)
(List.filterMap identity
[ Just TextInput.writing
, case config.isInError of
False ->
Nothing
_ ->
Just (TextInput.errorIf config.isInError)
, case config.onBlur of
Nothing ->
Nothing
Just onBlur ->
Just (TextInput.onBlur onBlur)
, if config.placeholder == config.label then
Nothing
else
Just (TextInput.placeholder config.placeholder)
, case config.autofocus of
False ->
Nothing
True ->
Just TextInput.autofocus
, case config.showLabel of
True ->
Nothing
False ->
Just TextInput.hiddenLabel
]
)
config.value
upgrade_Nri_Ui_TextInput_V4_generateId =
TextInput.generateId
upgrade_Nri_Ui_TextInput_V4_number =
TextInput.number
upgrade_Nri_Ui_TextInput_V4_text =
TextInput.text
--
-- Nri.Ui.TextInput.V5 to V6
--
upgrade_Nri_Ui_TextInput_V5_text =
TextInput.text
@ -27,73 +204,67 @@ upgrade_Nri_Ui_TextInput_V5_email =
upgrade_Nri_Ui_TextInput_V5_view model =
TextInput.view model.label
(model.type_ model.onInput)
[ case model.isInError of
False ->
ElmFix.remove
(List.filterMap identity
[ case model.isInError of
False ->
Nothing
_ ->
TextInput.errorIf model.isInError
, case model.showLabel of
True ->
ElmFix.remove
_ ->
Just (TextInput.errorIf model.isInError)
, case model.showLabel of
True ->
Nothing
False ->
TextInput.hiddenLabel
, if model.placeholder == model.label then
ElmFix.remove
False ->
Just TextInput.hiddenLabel
, if model.placeholder == model.label then
Nothing
else
TextInput.placeholder model.placeholder
, case model.onBlur of
Nothing ->
ElmFix.remove
else
Just (TextInput.placeholder model.placeholder)
, Maybe.map TextInput.onBlur model.onBlur
, case model.autofocus of
True ->
Just TextInput.autofocus
Just msg ->
TextInput.onBlur msg
, case model.autofocus of
True ->
TextInput.autofocus
False ->
ElmFix.remove
]
False ->
Nothing
]
)
model.value
upgrade_Nri_Ui_TextInput_V5_writing model =
TextInput.view model.label
(model.type_ model.onInput)
[ TextInput.writing
, case model.isInError of
False ->
ElmFix.remove
(List.filterMap identity
[ Just TextInput.writing
, case model.isInError of
False ->
Nothing
_ ->
TextInput.errorIf model.isInError
, case model.showLabel of
True ->
ElmFix.remove
_ ->
Just (TextInput.errorIf model.isInError)
, case model.showLabel of
True ->
Nothing
False ->
TextInput.hiddenLabel
, if model.placeholder == model.label then
ElmFix.remove
False ->
Just TextInput.hiddenLabel
, if model.placeholder == model.label then
Nothing
else
TextInput.placeholder model.placeholder
, case model.onBlur of
Nothing ->
ElmFix.remove
else
Just (TextInput.placeholder model.placeholder)
, Maybe.map TextInput.onBlur model.onBlur
, case model.autofocus of
True ->
Just TextInput.autofocus
Just msg ->
TextInput.onBlur msg
, case model.autofocus of
True ->
TextInput.autofocus
False ->
ElmFix.remove
]
False ->
Nothing
]
)
model.value

92
package-lock.json generated
View File

@ -1947,8 +1947,7 @@
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.2.tgz",
"integrity": "sha512-GkfeAQh+QNy3wquu9oIZr6SS5x7wGdSgNQvD10X3r+AZr1Oys22HW8kAmDMvNg2+Dm0TeGaEuO8gFwdBXxwO8A==",
"dev": true,
"optional": true
"dev": true
},
"cipher-base": {
"version": "1.0.4",
@ -2604,12 +2603,91 @@
"dev": true
},
"elm-format": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/elm-format/-/elm-format-0.8.1.tgz",
"integrity": "sha512-uLcDICdmEoRBaCp3PobcvHtUej2RJFHRYfMd7i3CSH+RsajJYTdiPkviKIq823Kd4gfjQMpNajEyM1lLFez7+A==",
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/elm-format/-/elm-format-0.8.3.tgz",
"integrity": "sha512-shXOgfg8F5hDJagP91zJ3QT0PoMbusPfhgEeu3uRofTaN843cFpjZ8qlQip6pFQxtWyQE/P+NMg3vP6lyWI5Mg==",
"dev": true,
"requires": {
"binwrap": "^0.2.0"
"binwrap": "^0.2.2"
},
"dependencies": {
"binwrap": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/binwrap/-/binwrap-0.2.2.tgz",
"integrity": "sha512-Y+Wvypk3JhH5GPZAvlwJAWOVH/OsOhQMSj37vySuWHwQivoALplPxfBA8b973rFJI7OS+O+1YmmYXIiEXVMAcw==",
"dev": true,
"requires": {
"mustache": "^3.0.1",
"request": "^2.88.0",
"request-promise": "^4.2.4",
"tar": "^4.4.10",
"unzip-stream": "^0.3.0"
}
},
"lodash": {
"version": "4.17.15",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==",
"dev": true
},
"minipass": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz",
"integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==",
"dev": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
}
},
"mustache": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/mustache/-/mustache-3.2.1.tgz",
"integrity": "sha512-RERvMFdLpaFfSRIEe632yDm5nsd0SDKn8hGmcUwswnyiE5mtdZLDybtHAz6hjJhawokF0hXvGLtx9mrQfm6FkA==",
"dev": true
},
"request-promise": {
"version": "4.2.5",
"resolved": "https://registry.npmjs.org/request-promise/-/request-promise-4.2.5.tgz",
"integrity": "sha512-ZgnepCykFdmpq86fKGwqntyTiUrHycALuGggpyCZwMvGaZWgxW6yagT0FHkgo5LzYvOaCNvxYwWYIjevSH1EDg==",
"dev": true,
"requires": {
"bluebird": "^3.5.0",
"request-promise-core": "1.1.3",
"stealthy-require": "^1.1.1",
"tough-cookie": "^2.3.3"
}
},
"request-promise-core": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.3.tgz",
"integrity": "sha512-QIs2+ArIGQVp5ZYbWD5ZLCY29D5CfWizP8eWnm8FoGD1TX61veauETVQbrV60662V0oFBkrDOuaBI8XgtuyYAQ==",
"dev": true,
"requires": {
"lodash": "^4.17.15"
}
},
"tar": {
"version": "4.4.13",
"resolved": "https://registry.npmjs.org/tar/-/tar-4.4.13.tgz",
"integrity": "sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA==",
"dev": true,
"requires": {
"chownr": "^1.1.1",
"fs-minipass": "^1.2.5",
"minipass": "^2.8.6",
"minizlib": "^1.2.1",
"mkdirp": "^0.5.0",
"safe-buffer": "^5.1.2",
"yallist": "^3.0.3"
}
},
"yallist": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
"dev": true
}
}
},
"elm-test": {
@ -3341,7 +3419,6 @@
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz",
"integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==",
"dev": true,
"optional": true,
"requires": {
"minipass": "^2.2.1"
}
@ -4888,7 +4965,6 @@
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz",
"integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==",
"dev": true,
"optional": true,
"requires": {
"minipass": "^2.2.1"
}

View File

@ -29,7 +29,7 @@
"@percy/script": "^1.0.2",
"browserify": "16.2.3",
"elm": "^0.19.0-no-deps",
"elm-format": "0.8.1",
"elm-format": "0.8.3",
"elm-test": "0.19.0-rev6",
"elm-verify-examples": "^4.0.0",
"request": "^2.88.0"