@greenberry/use-label-prefix
Advanced tools
Comparing version 0.1.2 to 1.0.0
@@ -21,2 +21,7 @@ "use strict"; | ||
var allChars = (0, _ramda.split)('', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789'); | ||
var serializeLabel = function serializeLabel(str) { | ||
return str.replace(/\s/gi, '__'); | ||
}; | ||
var shuffler = (0, _ramda.curry)(function (random, list) { | ||
@@ -50,3 +55,3 @@ var idx = -1; | ||
var _useState = (0, _react.useState)("".concat(prefix, "_").concat(label)), | ||
var _useState = (0, _react.useState)("p_".concat(prefix, "_").concat(serializeLabel(label))), | ||
_useState2 = _slicedToArray(_useState, 1), | ||
@@ -53,0 +58,0 @@ prefixed = _useState2[0]; |
{ | ||
"name": "@greenberry/use-label-prefix", | ||
"version": "0.1.2", | ||
"version": "1.0.0", | ||
"description": "Custom React Hook to prefix labels on Input fields", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,2 +6,8 @@ # `@greenberry/use-label-prefix` | ||
## Why? | ||
When generating a lot of input groups on one page it can get tedious to create a unique label/id for each input group. | ||
However this is required when you want to keep semantics and accessibility functionalities. | ||
This hook generates a prefix for your labels which persist over multiple updates and are unique per instance of the component. | ||
## Installation | ||
@@ -41,2 +47,1 @@ | ||
``` | ||
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4906
48
1
46