UNPKG

2.22 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports["default"] = textInputs;
5var _statefulSelectors = _interopRequireDefault(require("../internalHelpers/_statefulSelectors"));
6function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
7var stateMap = [undefined, null, 'active', 'focus', 'hover'];
8function template(state) {
9 return "input[type=\"color\"]" + state + ",\n input[type=\"date\"]" + state + ",\n input[type=\"datetime\"]" + state + ",\n input[type=\"datetime-local\"]" + state + ",\n input[type=\"email\"]" + state + ",\n input[type=\"month\"]" + state + ",\n input[type=\"number\"]" + state + ",\n input[type=\"password\"]" + state + ",\n input[type=\"search\"]" + state + ",\n input[type=\"tel\"]" + state + ",\n input[type=\"text\"]" + state + ",\n input[type=\"time\"]" + state + ",\n input[type=\"url\"]" + state + ",\n input[type=\"week\"]" + state + ",\n input:not([type])" + state + ",\n textarea" + state;
10}
11
12/**
13 * Populates selectors that target all text inputs. You can pass optional states to append to the selectors.
14 * @example
15 * // Styles as object usage
16 * const styles = {
17 * [textInputs('active')]: {
18 * 'border': 'none'
19 * }
20 * }
21 *
22 * // styled-components usage
23 * const div = styled.div`
24 * > ${textInputs('active')} {
25 * border: none;
26 * }
27 * `
28 *
29 * // CSS in JS Output
30 *
31 * 'input[type="color"]:active,
32 * input[type="date"]:active,
33 * input[type="datetime"]:active,
34 * input[type="datetime-local"]:active,
35 * input[type="email"]:active,
36 * input[type="month"]:active,
37 * input[type="number"]:active,
38 * input[type="password"]:active,
39 * input[type="search"]:active,
40 * input[type="tel"]:active,
41 * input[type="text"]:active,
42 * input[type="time"]:active,
43 * input[type="url"]:active,
44 * input[type="week"]:active,
45 * input:not([type]):active,
46 * textarea:active': {
47 * 'border': 'none'
48 * }
49 */
50function textInputs() {
51 for (var _len = arguments.length, states = new Array(_len), _key = 0; _key < _len; _key++) {
52 states[_key] = arguments[_key];
53 }
54 return (0, _statefulSelectors["default"])(states, template, stateMap);
55}
56module.exports = exports.default;
\No newline at end of file