Skip to content

Commit

Permalink
manage autonumeric.js with packer
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Sep 9, 2022
1 parent 6a41dcf commit fd23d25
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: shinyWidgets
Title: Custom Inputs Widgets for Shiny
Version: 0.7.3.9000
Version: 0.7.3.9100
Authors@R: c(
person("Victor", "Perrier", email = "[email protected]", role = c("aut", "cre", "cph")),
person("Fanny", "Meyer", role = "aut"),
Expand Down
5 changes: 2 additions & 3 deletions R/dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,8 @@ html_dependency_autonumeric <- function() {
htmlDependency(
name = "autonumeric",
version = "4.6.0",
package = "shinyWidgets",
src = c(href = "shinyWidgets/autonumeric", file = "assets/autonumeric"),
script = "autoNumeric.min.js"
src = c(file = system.file("packer", package = "shinyWidgets")),
script = "autonumeric.js"
)
}

Expand Down
2 changes: 0 additions & 2 deletions R/input-autonumeric.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ currencyInput <- function(inputId, label, value, format = "euro",
json_verbatim = TRUE
)
),
html_dependency_shinyWidgets(),
html_dependency_autonumeric()
)
}
Expand Down Expand Up @@ -511,7 +510,6 @@ autonumericInput <- function(inputId, label, value,
`data-for` = inputId,
data
),
html_dependency_shinyWidgets(),
html_dependency_autonumeric()
)
}
Expand Down
7 changes: 0 additions & 7 deletions inst/assets/autonumeric/autoNumeric.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion inst/assets/shinyWidgets-bindings.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions inst/packer/autonumeric.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"homepage": "https://github.com/dreamRs/shinyWidgets#readme",
"devDependencies": {
"air-datepicker": "^3.2.1",
"autonumeric": "^4.6.0",
"css-loader": "^6.5.1",
"dayjs": "^1.11.4",
"dayjs-plugin-utc": "^0.1.2",
Expand Down
3 changes: 2 additions & 1 deletion srcjs/config/entry_points.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"virtual-select": "./srcjs/inputs/virtual-select.js",
"air-datepicker": "./srcjs/inputs/air-datepicker.js",
"multi": "./srcjs/inputs/multi.js"
"multi": "./srcjs/inputs/multi.js",
"autonumeric": "./srcjs/inputs/autonumeric.js"
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/*jshint
jquery:true
*/
/*global AutoNumeric, Shiny */
import $ from "jquery";
import "shiny";
import AutoNumeric from "autonumeric";

// Autonumeric Input Binding
Shiny.InputBinding.prototype.store = [];
Shiny.InputBinding.prototype.updateStore = function(el, instance) {
this.store[el.id] = instance;
Expand Down
8 changes: 2 additions & 6 deletions tests/testthat/test-autonumeric.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ test_that("default", {
)

expect_is(tagauto, "shiny.tag")
expect_length(htmltools::findDependencies(tagauto), 2)
expect_identical(htmltools::findDependencies(tagauto)[[2]]$script, "autoNumeric.min.js")
expect_length(htmltools::findDependencies(tagauto), 1)
expect_true(htmltools::tagHasAttribute(tagauto$children[[2]], "id"))
expect_identical(htmltools::tagGetAttribute(tagauto$children[[2]], "id"), "id1")
expect_identical(tagauto$children[[5]]$name, "autonumeric")
})


Expand Down Expand Up @@ -75,11 +73,9 @@ test_that("default", {
)

expect_is(tagauto, "shiny.tag")
expect_length(htmltools::findDependencies(tagauto), 2)
expect_identical(htmltools::findDependencies(tagauto)[[2]]$script, "autoNumeric.min.js")
expect_length(htmltools::findDependencies(tagauto), 1)
expect_true(htmltools::tagHasAttribute(tagauto$children[[2]], "id"))
expect_identical(htmltools::tagGetAttribute(tagauto$children[[2]], "id"), "id1")
expect_identical(tagauto$children[[5]]$name, "autonumeric")
})


Expand Down

0 comments on commit fd23d25

Please sign in to comment.