UNPKG

1.04 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var _errors = _interopRequireDefault(require("./_errors"));
6function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
7function generateSelectors(template, state) {
8 var stateSuffix = state ? ":" + state : '';
9 return template(stateSuffix);
10}
11
12/**
13 * Function helper that adds an array of states to a template of selectors. Used in textInputs and buttons.
14 * @private
15 */
16function statefulSelectors(states, template, stateMap) {
17 if (!template) throw new _errors["default"](67);
18 if (states.length === 0) return generateSelectors(template, null);
19 var selectors = [];
20 for (var i = 0; i < states.length; i += 1) {
21 if (stateMap && stateMap.indexOf(states[i]) < 0) {
22 throw new _errors["default"](68);
23 }
24 selectors.push(generateSelectors(template, states[i]));
25 }
26 selectors = selectors.join(',');
27 return selectors;
28}
29var _default = exports["default"] = statefulSelectors;
30module.exports = exports.default;
\No newline at end of file