Security upgrades
This commit is contained in:
8
node_modules/jss-plugin-nested/LICENSE
generated
vendored
Normal file
8
node_modules/jss-plugin-nested/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2014-present Oleg Isonen (Slobodskoi) & contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
144
node_modules/jss-plugin-nested/dist/jss-plugin-nested.bundle.js
generated
vendored
Normal file
144
node_modules/jss-plugin-nested/dist/jss-plugin-nested.bundle.js
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
function _extends() {
|
||||
_extends = Object.assign || function (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
|
||||
for (var key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
return _extends.apply(this, arguments);
|
||||
}
|
||||
|
||||
function warning(condition, message) {
|
||||
{
|
||||
if (condition) {
|
||||
return;
|
||||
}
|
||||
|
||||
var text = "Warning: " + message;
|
||||
|
||||
if (typeof console !== 'undefined') {
|
||||
console.warn(text);
|
||||
}
|
||||
|
||||
try {
|
||||
throw Error(text);
|
||||
} catch (x) {}
|
||||
}
|
||||
}
|
||||
|
||||
var separatorRegExp = /\s*,\s*/g;
|
||||
var parentRegExp = /&/g;
|
||||
var refRegExp = /\$([\w-]+)/g;
|
||||
/**
|
||||
* Convert nested rules to separate, remove them from original styles.
|
||||
*
|
||||
* @param {Rule} rule
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function jssNested() {
|
||||
// Get a function to be used for $ref replacement.
|
||||
function getReplaceRef(container, sheet) {
|
||||
return function (match, key) {
|
||||
var rule = container.getRule(key) || sheet && sheet.getRule(key);
|
||||
|
||||
if (rule) {
|
||||
rule = rule;
|
||||
return rule.selector;
|
||||
}
|
||||
|
||||
warning(false, "[JSS] Could not find the referenced rule \"" + key + "\" in \"" + (container.options.meta || container.toString()) + "\".") ;
|
||||
return key;
|
||||
};
|
||||
}
|
||||
|
||||
function replaceParentRefs(nestedProp, parentProp) {
|
||||
var parentSelectors = parentProp.split(separatorRegExp);
|
||||
var nestedSelectors = nestedProp.split(separatorRegExp);
|
||||
var result = '';
|
||||
|
||||
for (var i = 0; i < parentSelectors.length; i++) {
|
||||
var parent = parentSelectors[i];
|
||||
|
||||
for (var j = 0; j < nestedSelectors.length; j++) {
|
||||
var nested = nestedSelectors[j];
|
||||
if (result) result += ', '; // Replace all & by the parent or prefix & with the parent.
|
||||
|
||||
result += nested.indexOf('&') !== -1 ? nested.replace(parentRegExp, parent) : parent + " " + nested;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function getOptions(rule, container, prevOptions) {
|
||||
// Options has been already created, now we only increase index.
|
||||
if (prevOptions) return _extends({}, prevOptions, {
|
||||
index: prevOptions.index + 1
|
||||
});
|
||||
var nestingLevel = rule.options.nestingLevel;
|
||||
nestingLevel = nestingLevel === undefined ? 1 : nestingLevel + 1;
|
||||
|
||||
var options = _extends({}, rule.options, {
|
||||
nestingLevel: nestingLevel,
|
||||
index: container.indexOf(rule) + 1 // We don't need the parent name to be set options for chlid.
|
||||
|
||||
});
|
||||
|
||||
delete options.name;
|
||||
return options;
|
||||
}
|
||||
|
||||
function onProcessStyle(style, rule, sheet) {
|
||||
if (rule.type !== 'style') return style;
|
||||
var styleRule = rule;
|
||||
var container = styleRule.options.parent;
|
||||
var options;
|
||||
var replaceRef;
|
||||
|
||||
for (var prop in style) {
|
||||
var isNested = prop.indexOf('&') !== -1;
|
||||
var isNestedConditional = prop[0] === '@';
|
||||
if (!isNested && !isNestedConditional) continue;
|
||||
options = getOptions(styleRule, container, options);
|
||||
|
||||
if (isNested) {
|
||||
var selector = replaceParentRefs(prop, styleRule.selector); // Lazily create the ref replacer function just once for
|
||||
// all nested rules within the sheet.
|
||||
|
||||
if (!replaceRef) replaceRef = getReplaceRef(container, sheet); // Replace all $refs.
|
||||
|
||||
selector = selector.replace(refRegExp, replaceRef);
|
||||
container.addRule(selector, style[prop], _extends({}, options, {
|
||||
selector: selector
|
||||
}));
|
||||
} else if (isNestedConditional) {
|
||||
// Place conditional right after the parent rule to ensure right ordering.
|
||||
container.addRule(prop, {}, options) // Flow expects more options but they aren't required
|
||||
// And flow doesn't know this will always be a StyleRule which has the addRule method
|
||||
// $FlowFixMe
|
||||
.addRule(styleRule.key, style[prop], {
|
||||
selector: styleRule.selector
|
||||
});
|
||||
}
|
||||
|
||||
delete style[prop];
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
return {
|
||||
onProcessStyle: onProcessStyle
|
||||
};
|
||||
}
|
||||
|
||||
export default jssNested;
|
||||
117
node_modules/jss-plugin-nested/dist/jss-plugin-nested.cjs.js
generated
vendored
Normal file
117
node_modules/jss-plugin-nested/dist/jss-plugin-nested.cjs.js
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var _extends = _interopDefault(require('@babel/runtime/helpers/extends'));
|
||||
var warning = _interopDefault(require('tiny-warning'));
|
||||
|
||||
var separatorRegExp = /\s*,\s*/g;
|
||||
var parentRegExp = /&/g;
|
||||
var refRegExp = /\$([\w-]+)/g;
|
||||
/**
|
||||
* Convert nested rules to separate, remove them from original styles.
|
||||
*
|
||||
* @param {Rule} rule
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function jssNested() {
|
||||
// Get a function to be used for $ref replacement.
|
||||
function getReplaceRef(container, sheet) {
|
||||
return function (match, key) {
|
||||
var rule = container.getRule(key) || sheet && sheet.getRule(key);
|
||||
|
||||
if (rule) {
|
||||
rule = rule;
|
||||
return rule.selector;
|
||||
}
|
||||
|
||||
process.env.NODE_ENV !== "production" ? warning(false, "[JSS] Could not find the referenced rule \"" + key + "\" in \"" + (container.options.meta || container.toString()) + "\".") : void 0;
|
||||
return key;
|
||||
};
|
||||
}
|
||||
|
||||
function replaceParentRefs(nestedProp, parentProp) {
|
||||
var parentSelectors = parentProp.split(separatorRegExp);
|
||||
var nestedSelectors = nestedProp.split(separatorRegExp);
|
||||
var result = '';
|
||||
|
||||
for (var i = 0; i < parentSelectors.length; i++) {
|
||||
var parent = parentSelectors[i];
|
||||
|
||||
for (var j = 0; j < nestedSelectors.length; j++) {
|
||||
var nested = nestedSelectors[j];
|
||||
if (result) result += ', '; // Replace all & by the parent or prefix & with the parent.
|
||||
|
||||
result += nested.indexOf('&') !== -1 ? nested.replace(parentRegExp, parent) : parent + " " + nested;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function getOptions(rule, container, prevOptions) {
|
||||
// Options has been already created, now we only increase index.
|
||||
if (prevOptions) return _extends({}, prevOptions, {
|
||||
index: prevOptions.index + 1
|
||||
});
|
||||
var nestingLevel = rule.options.nestingLevel;
|
||||
nestingLevel = nestingLevel === undefined ? 1 : nestingLevel + 1;
|
||||
|
||||
var options = _extends({}, rule.options, {
|
||||
nestingLevel: nestingLevel,
|
||||
index: container.indexOf(rule) + 1 // We don't need the parent name to be set options for chlid.
|
||||
|
||||
});
|
||||
|
||||
delete options.name;
|
||||
return options;
|
||||
}
|
||||
|
||||
function onProcessStyle(style, rule, sheet) {
|
||||
if (rule.type !== 'style') return style;
|
||||
var styleRule = rule;
|
||||
var container = styleRule.options.parent;
|
||||
var options;
|
||||
var replaceRef;
|
||||
|
||||
for (var prop in style) {
|
||||
var isNested = prop.indexOf('&') !== -1;
|
||||
var isNestedConditional = prop[0] === '@';
|
||||
if (!isNested && !isNestedConditional) continue;
|
||||
options = getOptions(styleRule, container, options);
|
||||
|
||||
if (isNested) {
|
||||
var selector = replaceParentRefs(prop, styleRule.selector); // Lazily create the ref replacer function just once for
|
||||
// all nested rules within the sheet.
|
||||
|
||||
if (!replaceRef) replaceRef = getReplaceRef(container, sheet); // Replace all $refs.
|
||||
|
||||
selector = selector.replace(refRegExp, replaceRef);
|
||||
container.addRule(selector, style[prop], _extends({}, options, {
|
||||
selector: selector
|
||||
}));
|
||||
} else if (isNestedConditional) {
|
||||
// Place conditional right after the parent rule to ensure right ordering.
|
||||
container.addRule(prop, {}, options) // Flow expects more options but they aren't required
|
||||
// And flow doesn't know this will always be a StyleRule which has the addRule method
|
||||
// $FlowFixMe
|
||||
.addRule(styleRule.key, style[prop], {
|
||||
selector: styleRule.selector
|
||||
});
|
||||
}
|
||||
|
||||
delete style[prop];
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
return {
|
||||
onProcessStyle: onProcessStyle
|
||||
};
|
||||
}
|
||||
|
||||
exports.default = jssNested;
|
||||
3
node_modules/jss-plugin-nested/dist/jss-plugin-nested.cjs.js.flow
generated
vendored
Normal file
3
node_modules/jss-plugin-nested/dist/jss-plugin-nested.cjs.js.flow
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// @flow
|
||||
|
||||
export * from '../src';
|
||||
111
node_modules/jss-plugin-nested/dist/jss-plugin-nested.esm.js
generated
vendored
Normal file
111
node_modules/jss-plugin-nested/dist/jss-plugin-nested.esm.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
import _extends from '@babel/runtime/helpers/esm/extends';
|
||||
import warning from 'tiny-warning';
|
||||
|
||||
var separatorRegExp = /\s*,\s*/g;
|
||||
var parentRegExp = /&/g;
|
||||
var refRegExp = /\$([\w-]+)/g;
|
||||
/**
|
||||
* Convert nested rules to separate, remove them from original styles.
|
||||
*
|
||||
* @param {Rule} rule
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function jssNested() {
|
||||
// Get a function to be used for $ref replacement.
|
||||
function getReplaceRef(container, sheet) {
|
||||
return function (match, key) {
|
||||
var rule = container.getRule(key) || sheet && sheet.getRule(key);
|
||||
|
||||
if (rule) {
|
||||
rule = rule;
|
||||
return rule.selector;
|
||||
}
|
||||
|
||||
process.env.NODE_ENV !== "production" ? warning(false, "[JSS] Could not find the referenced rule \"" + key + "\" in \"" + (container.options.meta || container.toString()) + "\".") : void 0;
|
||||
return key;
|
||||
};
|
||||
}
|
||||
|
||||
function replaceParentRefs(nestedProp, parentProp) {
|
||||
var parentSelectors = parentProp.split(separatorRegExp);
|
||||
var nestedSelectors = nestedProp.split(separatorRegExp);
|
||||
var result = '';
|
||||
|
||||
for (var i = 0; i < parentSelectors.length; i++) {
|
||||
var parent = parentSelectors[i];
|
||||
|
||||
for (var j = 0; j < nestedSelectors.length; j++) {
|
||||
var nested = nestedSelectors[j];
|
||||
if (result) result += ', '; // Replace all & by the parent or prefix & with the parent.
|
||||
|
||||
result += nested.indexOf('&') !== -1 ? nested.replace(parentRegExp, parent) : parent + " " + nested;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function getOptions(rule, container, prevOptions) {
|
||||
// Options has been already created, now we only increase index.
|
||||
if (prevOptions) return _extends({}, prevOptions, {
|
||||
index: prevOptions.index + 1
|
||||
});
|
||||
var nestingLevel = rule.options.nestingLevel;
|
||||
nestingLevel = nestingLevel === undefined ? 1 : nestingLevel + 1;
|
||||
|
||||
var options = _extends({}, rule.options, {
|
||||
nestingLevel: nestingLevel,
|
||||
index: container.indexOf(rule) + 1 // We don't need the parent name to be set options for chlid.
|
||||
|
||||
});
|
||||
|
||||
delete options.name;
|
||||
return options;
|
||||
}
|
||||
|
||||
function onProcessStyle(style, rule, sheet) {
|
||||
if (rule.type !== 'style') return style;
|
||||
var styleRule = rule;
|
||||
var container = styleRule.options.parent;
|
||||
var options;
|
||||
var replaceRef;
|
||||
|
||||
for (var prop in style) {
|
||||
var isNested = prop.indexOf('&') !== -1;
|
||||
var isNestedConditional = prop[0] === '@';
|
||||
if (!isNested && !isNestedConditional) continue;
|
||||
options = getOptions(styleRule, container, options);
|
||||
|
||||
if (isNested) {
|
||||
var selector = replaceParentRefs(prop, styleRule.selector); // Lazily create the ref replacer function just once for
|
||||
// all nested rules within the sheet.
|
||||
|
||||
if (!replaceRef) replaceRef = getReplaceRef(container, sheet); // Replace all $refs.
|
||||
|
||||
selector = selector.replace(refRegExp, replaceRef);
|
||||
container.addRule(selector, style[prop], _extends({}, options, {
|
||||
selector: selector
|
||||
}));
|
||||
} else if (isNestedConditional) {
|
||||
// Place conditional right after the parent rule to ensure right ordering.
|
||||
container.addRule(prop, {}, options) // Flow expects more options but they aren't required
|
||||
// And flow doesn't know this will always be a StyleRule which has the addRule method
|
||||
// $FlowFixMe
|
||||
.addRule(styleRule.key, style[prop], {
|
||||
selector: styleRule.selector
|
||||
});
|
||||
}
|
||||
|
||||
delete style[prop];
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
return {
|
||||
onProcessStyle: onProcessStyle
|
||||
};
|
||||
}
|
||||
|
||||
export default jssNested;
|
||||
155
node_modules/jss-plugin-nested/dist/jss-plugin-nested.js
generated
vendored
Normal file
155
node_modules/jss-plugin-nested/dist/jss-plugin-nested.js
generated
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = global || self, factory(global.jssPluginNested = {}));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
function _extends() {
|
||||
_extends = Object.assign || function (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
|
||||
for (var key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
return _extends.apply(this, arguments);
|
||||
}
|
||||
|
||||
function warning(condition, message) {
|
||||
{
|
||||
if (condition) {
|
||||
return;
|
||||
}
|
||||
|
||||
var text = "Warning: " + message;
|
||||
|
||||
if (typeof console !== 'undefined') {
|
||||
console.warn(text);
|
||||
}
|
||||
|
||||
try {
|
||||
throw Error(text);
|
||||
} catch (x) {}
|
||||
}
|
||||
}
|
||||
|
||||
var separatorRegExp = /\s*,\s*/g;
|
||||
var parentRegExp = /&/g;
|
||||
var refRegExp = /\$([\w-]+)/g;
|
||||
/**
|
||||
* Convert nested rules to separate, remove them from original styles.
|
||||
*
|
||||
* @param {Rule} rule
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function jssNested() {
|
||||
// Get a function to be used for $ref replacement.
|
||||
function getReplaceRef(container, sheet) {
|
||||
return function (match, key) {
|
||||
var rule = container.getRule(key) || sheet && sheet.getRule(key);
|
||||
|
||||
if (rule) {
|
||||
rule = rule;
|
||||
return rule.selector;
|
||||
}
|
||||
|
||||
warning(false, "[JSS] Could not find the referenced rule \"" + key + "\" in \"" + (container.options.meta || container.toString()) + "\".") ;
|
||||
return key;
|
||||
};
|
||||
}
|
||||
|
||||
function replaceParentRefs(nestedProp, parentProp) {
|
||||
var parentSelectors = parentProp.split(separatorRegExp);
|
||||
var nestedSelectors = nestedProp.split(separatorRegExp);
|
||||
var result = '';
|
||||
|
||||
for (var i = 0; i < parentSelectors.length; i++) {
|
||||
var parent = parentSelectors[i];
|
||||
|
||||
for (var j = 0; j < nestedSelectors.length; j++) {
|
||||
var nested = nestedSelectors[j];
|
||||
if (result) result += ', '; // Replace all & by the parent or prefix & with the parent.
|
||||
|
||||
result += nested.indexOf('&') !== -1 ? nested.replace(parentRegExp, parent) : parent + " " + nested;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function getOptions(rule, container, prevOptions) {
|
||||
// Options has been already created, now we only increase index.
|
||||
if (prevOptions) return _extends({}, prevOptions, {
|
||||
index: prevOptions.index + 1
|
||||
});
|
||||
var nestingLevel = rule.options.nestingLevel;
|
||||
nestingLevel = nestingLevel === undefined ? 1 : nestingLevel + 1;
|
||||
|
||||
var options = _extends({}, rule.options, {
|
||||
nestingLevel: nestingLevel,
|
||||
index: container.indexOf(rule) + 1 // We don't need the parent name to be set options for chlid.
|
||||
|
||||
});
|
||||
|
||||
delete options.name;
|
||||
return options;
|
||||
}
|
||||
|
||||
function onProcessStyle(style, rule, sheet) {
|
||||
if (rule.type !== 'style') return style;
|
||||
var styleRule = rule;
|
||||
var container = styleRule.options.parent;
|
||||
var options;
|
||||
var replaceRef;
|
||||
|
||||
for (var prop in style) {
|
||||
var isNested = prop.indexOf('&') !== -1;
|
||||
var isNestedConditional = prop[0] === '@';
|
||||
if (!isNested && !isNestedConditional) continue;
|
||||
options = getOptions(styleRule, container, options);
|
||||
|
||||
if (isNested) {
|
||||
var selector = replaceParentRefs(prop, styleRule.selector); // Lazily create the ref replacer function just once for
|
||||
// all nested rules within the sheet.
|
||||
|
||||
if (!replaceRef) replaceRef = getReplaceRef(container, sheet); // Replace all $refs.
|
||||
|
||||
selector = selector.replace(refRegExp, replaceRef);
|
||||
container.addRule(selector, style[prop], _extends({}, options, {
|
||||
selector: selector
|
||||
}));
|
||||
} else if (isNestedConditional) {
|
||||
// Place conditional right after the parent rule to ensure right ordering.
|
||||
container.addRule(prop, {}, options) // Flow expects more options but they aren't required
|
||||
// And flow doesn't know this will always be a StyleRule which has the addRule method
|
||||
// $FlowFixMe
|
||||
.addRule(styleRule.key, style[prop], {
|
||||
selector: styleRule.selector
|
||||
});
|
||||
}
|
||||
|
||||
delete style[prop];
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
return {
|
||||
onProcessStyle: onProcessStyle
|
||||
};
|
||||
}
|
||||
|
||||
exports.default = jssNested;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
//# sourceMappingURL=jss-plugin-nested.js.map
|
||||
1
node_modules/jss-plugin-nested/dist/jss-plugin-nested.js.map
generated
vendored
Normal file
1
node_modules/jss-plugin-nested/dist/jss-plugin-nested.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/jss-plugin-nested/dist/jss-plugin-nested.min.js
generated
vendored
Normal file
1
node_modules/jss-plugin-nested/dist/jss-plugin-nested.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).jssPluginNested={})}(this,function(e){"use strict";function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var n=/\s*,\s*/g,r=/&/g,o=/\$([\w-]+)/g;e.default=function(){function e(e,t){return function(n,r){var o=e.getRule(r)||t&&t.getRule(r);return o?(o=o).selector:r}}function i(e,t){for(var o=t.split(n),i=e.split(n),f="",l=0;l<o.length;l++)for(var s=o[l],u=0;u<i.length;u++){var a=i[u];f&&(f+=", "),f+=-1!==a.indexOf("&")?a.replace(r,s):s+" "+a}return f}function f(e,n,r){if(r)return t({},r,{index:r.index+1});var o=e.options.nestingLevel;o=void 0===o?1:o+1;var i=t({},e.options,{nestingLevel:o,index:n.indexOf(e)+1});return delete i.name,i}return{onProcessStyle:function(n,r,l){if("style"!==r.type)return n;var s,u,a=r,d=a.options.parent;for(var c in n){var p=-1!==c.indexOf("&"),v="@"===c[0];if(p||v){if(s=f(a,d,s),p){var g=i(c,a.selector);u||(u=e(d,l)),g=g.replace(o,u),d.addRule(g,n[c],t({},s,{selector:g}))}else v&&d.addRule(c,{},s).addRule(a.key,n[c],{selector:a.selector});delete n[c]}}return n}}},Object.defineProperty(e,"__esModule",{value:!0})});
|
||||
73
node_modules/jss-plugin-nested/package.json
generated
vendored
Normal file
73
node_modules/jss-plugin-nested/package.json
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"_from": "jss-plugin-nested@^10.0.3",
|
||||
"_id": "jss-plugin-nested@10.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-qWiEkoXNEkkZ+FZrWmUGpf+zBsnEOmKXhkjNX85/ZfWhH9dfGxUCKuJFuOWFM+rjQfxV4csfesq4hY0jk8Qt0w==",
|
||||
"_location": "/jss-plugin-nested",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "jss-plugin-nested@^10.0.3",
|
||||
"name": "jss-plugin-nested",
|
||||
"escapedName": "jss-plugin-nested",
|
||||
"rawSpec": "^10.0.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^10.0.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@material-ui/styles"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/jss-plugin-nested/-/jss-plugin-nested-10.3.0.tgz",
|
||||
"_shasum": "ae8aceac95e09c3d40c991ea32403fb647d9e0a8",
|
||||
"_spec": "jss-plugin-nested@^10.0.3",
|
||||
"_where": "D:\\WORK\\Menui\\menui_backend\\node_modules\\@material-ui\\styles",
|
||||
"author": {
|
||||
"name": "JSS Team"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/cssinjs/jss/issues/new?title=[jss-plugin-nested]"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"jss": "^10.3.0",
|
||||
"tiny-warning": "^1.0.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "JSS plugin that enables support for nested selectors",
|
||||
"devDependencies": {
|
||||
"jss-plugin-rule-value-function": "^10.3.0"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"LICENSE"
|
||||
],
|
||||
"gitHead": "4094410d82dfdae772e1c09f0cd187cb48fa1cdc",
|
||||
"homepage": "https://cssinjs.org/jss-nested",
|
||||
"keywords": [
|
||||
"cssinjs",
|
||||
"css-in-js",
|
||||
"css in js",
|
||||
"jss",
|
||||
"plugin",
|
||||
"nested",
|
||||
"nesting"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "dist/jss-plugin-nested.cjs.js",
|
||||
"module": "dist/jss-plugin-nested.esm.js",
|
||||
"name": "jss-plugin-nested",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/cssinjs/jss.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node ../../scripts/build.js",
|
||||
"check-snapshot": "node ../../scripts/match-snapshot.js"
|
||||
},
|
||||
"typings": "./src/index.d.ts",
|
||||
"unpkg": "dist/jss-plugin-nested.bundle.js",
|
||||
"version": "10.3.0"
|
||||
}
|
||||
26
node_modules/jss-plugin-nested/readme.md
generated
vendored
Normal file
26
node_modules/jss-plugin-nested/readme.md
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
# jss-plugin-nested
|
||||
|
||||
[](https://npmjs.org/package/jss-plugin-nested)
|
||||
[](https://github.com/cssinjs/jss/blob/master/LICENSE)
|
||||
[](https://npmjs.org/package/jss-plugin-nested)
|
||||
[](https://npmjs.org/package/jss-plugin-nested)
|
||||
[](https://npmjs.org/package/jss-plugin-nested)
|
||||
[](https://gitter.im/cssinjs/lobby)
|
||||
|
||||
> JSS plugin that enables support for nested selectors
|
||||
|
||||
See our website [jss-plugin-nested](https://cssinjs.org/jss-plugin-nested?v=v10.3.0) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install jss-plugin-nested
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add jss-plugin-nested
|
||||
```
|
||||
3
node_modules/jss-plugin-nested/src/index.d.ts
generated
vendored
Normal file
3
node_modules/jss-plugin-nested/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import {Plugin} from 'jss'
|
||||
|
||||
export default function jssPluginSyntaxNested(): Plugin
|
||||
115
node_modules/jss-plugin-nested/src/index.js
generated
vendored
Normal file
115
node_modules/jss-plugin-nested/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
// @flow
|
||||
import warning from 'tiny-warning'
|
||||
import type {Plugin, StyleRule, StyleSheet} from 'jss'
|
||||
|
||||
const separatorRegExp = /\s*,\s*/g
|
||||
const parentRegExp = /&/g
|
||||
const refRegExp = /\$([\w-]+)/g
|
||||
|
||||
/**
|
||||
* Convert nested rules to separate, remove them from original styles.
|
||||
*
|
||||
* @param {Rule} rule
|
||||
* @api public
|
||||
*/
|
||||
export default function jssNested(): Plugin {
|
||||
// Get a function to be used for $ref replacement.
|
||||
function getReplaceRef(container, sheet?: StyleSheet) {
|
||||
return (match, key) => {
|
||||
let rule = container.getRule(key) || (sheet && sheet.getRule(key))
|
||||
if (rule) {
|
||||
rule = ((rule: any): StyleRule)
|
||||
|
||||
return rule.selector
|
||||
}
|
||||
|
||||
warning(
|
||||
false,
|
||||
`[JSS] Could not find the referenced rule "${key}" in "${container.options.meta ||
|
||||
container.toString()}".`
|
||||
)
|
||||
return key
|
||||
}
|
||||
}
|
||||
|
||||
function replaceParentRefs(nestedProp, parentProp) {
|
||||
const parentSelectors = parentProp.split(separatorRegExp)
|
||||
const nestedSelectors = nestedProp.split(separatorRegExp)
|
||||
|
||||
let result = ''
|
||||
|
||||
for (let i = 0; i < parentSelectors.length; i++) {
|
||||
const parent = parentSelectors[i]
|
||||
|
||||
for (let j = 0; j < nestedSelectors.length; j++) {
|
||||
const nested = nestedSelectors[j]
|
||||
if (result) result += ', '
|
||||
// Replace all & by the parent or prefix & with the parent.
|
||||
result +=
|
||||
nested.indexOf('&') !== -1 ? nested.replace(parentRegExp, parent) : `${parent} ${nested}`
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
function getOptions(rule, container, prevOptions) {
|
||||
// Options has been already created, now we only increase index.
|
||||
if (prevOptions) return {...prevOptions, index: prevOptions.index + 1}
|
||||
|
||||
let {nestingLevel} = rule.options
|
||||
nestingLevel = nestingLevel === undefined ? 1 : nestingLevel + 1
|
||||
|
||||
const options = {
|
||||
...rule.options,
|
||||
nestingLevel,
|
||||
index: container.indexOf(rule) + 1
|
||||
}
|
||||
// We don't need the parent name to be set options for chlid.
|
||||
delete options.name
|
||||
return options
|
||||
}
|
||||
|
||||
function onProcessStyle(style, rule, sheet?: StyleSheet) {
|
||||
if (rule.type !== 'style') return style
|
||||
|
||||
const styleRule: StyleRule = (rule: any)
|
||||
|
||||
const container: StyleSheet = (styleRule.options.parent: any)
|
||||
let options
|
||||
let replaceRef
|
||||
for (const prop in style) {
|
||||
const isNested = prop.indexOf('&') !== -1
|
||||
const isNestedConditional = prop[0] === '@'
|
||||
|
||||
if (!isNested && !isNestedConditional) continue
|
||||
|
||||
options = getOptions(styleRule, container, options)
|
||||
|
||||
if (isNested) {
|
||||
let selector = replaceParentRefs(prop, styleRule.selector)
|
||||
// Lazily create the ref replacer function just once for
|
||||
// all nested rules within the sheet.
|
||||
if (!replaceRef) replaceRef = getReplaceRef(container, sheet)
|
||||
// Replace all $refs.
|
||||
selector = selector.replace(refRegExp, replaceRef)
|
||||
|
||||
container.addRule(selector, style[prop], {...options, selector})
|
||||
} else if (isNestedConditional) {
|
||||
// Place conditional right after the parent rule to ensure right ordering.
|
||||
container
|
||||
.addRule(prop, {}, options)
|
||||
// Flow expects more options but they aren't required
|
||||
// And flow doesn't know this will always be a StyleRule which has the addRule method
|
||||
// $FlowFixMe
|
||||
.addRule(styleRule.key, style[prop], {selector: styleRule.selector})
|
||||
}
|
||||
|
||||
delete style[prop]
|
||||
}
|
||||
|
||||
return style
|
||||
}
|
||||
|
||||
return {onProcessStyle}
|
||||
}
|
||||
669
node_modules/jss-plugin-nested/src/index.test.js
generated
vendored
Normal file
669
node_modules/jss-plugin-nested/src/index.test.js
generated
vendored
Normal file
@@ -0,0 +1,669 @@
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
|
||||
import expect from 'expect.js'
|
||||
import {stripIndent} from 'common-tags'
|
||||
import jssExtend from 'jss-plugin-extend'
|
||||
import {create} from 'jss'
|
||||
import sinon from 'sinon'
|
||||
import functionPlugin from 'jss-plugin-rule-value-function'
|
||||
import nested from '.'
|
||||
|
||||
const settings = {
|
||||
createGenerateId: () => rule => `${rule.key}-id`
|
||||
}
|
||||
|
||||
describe('jss-plugin-nested', () => {
|
||||
let jss
|
||||
let spy
|
||||
|
||||
beforeEach(() => {
|
||||
spy = sinon.spy(console, 'warn')
|
||||
jss = create(settings).use(nested())
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
console.warn.restore()
|
||||
})
|
||||
|
||||
describe('nesting with space', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
a: {
|
||||
float: 'left',
|
||||
'& b': {float: 'left'}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should add rules', () => {
|
||||
expect(sheet.getRule('a')).to.not.be(undefined)
|
||||
expect(sheet.getRule('.a-id b')).to.not.be(undefined)
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be('.a-id {\n float: left;\n}\n.a-id b {\n float: left;\n}')
|
||||
})
|
||||
})
|
||||
|
||||
describe('nesting without space', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
a: {
|
||||
float: 'left',
|
||||
'&b': {float: 'left'}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should add rules', () => {
|
||||
expect(sheet.getRule('a')).to.not.be(undefined)
|
||||
expect(sheet.getRule('.a-idb')).to.not.be(undefined)
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be('.a-id {\n float: left;\n}\n.a-idb {\n float: left;\n}')
|
||||
})
|
||||
})
|
||||
|
||||
describe('multi nesting', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
a: {
|
||||
float: 'left',
|
||||
'&b': {float: 'left'},
|
||||
'& c': {float: 'left'}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should add rules', () => {
|
||||
expect(sheet.getRule('a')).to.not.be(undefined)
|
||||
expect(sheet.getRule('.a-idb')).to.not.be(undefined)
|
||||
expect(sheet.getRule('.a-id c')).to.not.be(undefined)
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be(
|
||||
'.a-id {\n' +
|
||||
' float: left;\n' +
|
||||
'}\n' +
|
||||
'.a-idb {\n' +
|
||||
' float: left;\n' +
|
||||
'}\n' +
|
||||
'.a-id c {\n' +
|
||||
' float: left;\n' +
|
||||
'}'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('multi nesting in one selector', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
a: {
|
||||
float: 'left',
|
||||
'&b, &c': {float: 'left'}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should add rules', () => {
|
||||
expect(sheet.getRule('a')).to.not.be(undefined)
|
||||
expect(sheet.getRule('.a-idb, .a-idc')).to.not.be(undefined)
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be(
|
||||
'.a-id {\n float: left;\n}\n.a-idb, .a-idc {\n float: left;\n}'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('.addRules()', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
a: {
|
||||
height: '1px'
|
||||
}
|
||||
})
|
||||
|
||||
sheet.addRules({
|
||||
b: {
|
||||
height: '2px',
|
||||
'& c': {
|
||||
height: '3px'
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be(
|
||||
'.a-id {\n' +
|
||||
' height: 1px;\n' +
|
||||
'}\n' +
|
||||
'.b-id {\n' +
|
||||
' height: 2px;\n' +
|
||||
'}\n' +
|
||||
'.b-id c {\n' +
|
||||
' height: 3px;\n' +
|
||||
'}'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('nesting in a conditional', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
a: {
|
||||
color: 'green'
|
||||
},
|
||||
'@media': {
|
||||
a: {
|
||||
'&:hover': {color: 'red'}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should add rules', () => {
|
||||
expect(sheet.getRule('a')).to.not.be(undefined)
|
||||
expect(sheet.getRule('@media')).to.not.be(undefined)
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be(
|
||||
'.a-id {\n' +
|
||||
' color: green;\n' +
|
||||
'}\n' +
|
||||
'@media {\n' +
|
||||
' .a-id:hover {\n' +
|
||||
' color: red;\n' +
|
||||
' }\n' +
|
||||
'}'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('nesting a conditional rule inside a regular rule', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
a: {
|
||||
color: 'green',
|
||||
'@media': {
|
||||
width: '200px'
|
||||
}
|
||||
},
|
||||
b: {
|
||||
color: 'red'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should add rules', () => {
|
||||
expect(sheet.getRule('a')).to.not.be(undefined)
|
||||
expect(sheet.getRule('@media')).to.not.be(undefined)
|
||||
expect(sheet.getRule('b')).to.not.be(undefined)
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be(
|
||||
'.a-id {\n' +
|
||||
' color: green;\n' +
|
||||
'}\n' +
|
||||
'@media {\n' +
|
||||
' .a-id {\n' +
|
||||
' width: 200px;\n' +
|
||||
' }\n' +
|
||||
'}\n' +
|
||||
'.b-id {\n' +
|
||||
' color: red;\n' +
|
||||
'}'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('nesting a conditional rule inside of a nested rule', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
a: {
|
||||
'&:hover': {
|
||||
color: 'red',
|
||||
'@media': {
|
||||
color: 'green'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be(stripIndent`
|
||||
.a-id:hover {
|
||||
color: red;
|
||||
}
|
||||
@media {
|
||||
.a-id:hover {
|
||||
color: green;
|
||||
}
|
||||
}
|
||||
`)
|
||||
})
|
||||
})
|
||||
|
||||
describe('order of nested conditionals', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
a: {
|
||||
'@media a': {
|
||||
color: 'red'
|
||||
},
|
||||
'@media b': {
|
||||
color: 'green'
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should add rules', () => {
|
||||
expect(sheet.getRule('@media a')).to.not.be(undefined)
|
||||
expect(sheet.getRule('@media b')).to.not.be(undefined)
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be(
|
||||
'@media a {\n' +
|
||||
' .a-id {\n' +
|
||||
' color: red;\n' +
|
||||
' }\n' +
|
||||
'}\n' +
|
||||
'@media b {\n' +
|
||||
' .a-id {\n' +
|
||||
' color: green;\n' +
|
||||
' }\n' +
|
||||
'}'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('adding a rule with a conditional rule', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet()
|
||||
sheet.addRule('a', {
|
||||
color: 'green',
|
||||
'@media': {
|
||||
width: '200px'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should add rules', () => {
|
||||
expect(sheet.getRule('a')).to.not.be(undefined)
|
||||
expect(sheet.getRule('@media')).to.not.be(undefined)
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be(
|
||||
'.a-id {\n' +
|
||||
' color: green;\n' +
|
||||
'}\n' +
|
||||
'@media {\n' +
|
||||
' .a-id {\n' +
|
||||
' width: 200px;\n' +
|
||||
' }\n' +
|
||||
'}'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('do not merge nested conditional to container conditional with existing rule', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
a: {
|
||||
color: 'green',
|
||||
'@media': {
|
||||
width: '200px'
|
||||
},
|
||||
'@media large': {
|
||||
width: '300px'
|
||||
}
|
||||
},
|
||||
'@media': {
|
||||
b: {
|
||||
color: 'blue'
|
||||
}
|
||||
},
|
||||
c: {
|
||||
color: 'red'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should add rules', () => {
|
||||
expect(sheet.getRule('a')).to.not.be(undefined)
|
||||
expect(sheet.getRule('@media')).to.not.be(undefined)
|
||||
expect(sheet.getRule('c')).to.not.be(undefined)
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be(
|
||||
'.a-id {\n' +
|
||||
' color: green;\n' +
|
||||
'}\n' +
|
||||
'@media {\n' +
|
||||
' .a-id {\n' +
|
||||
' width: 200px;\n' +
|
||||
' }\n' +
|
||||
'}\n' +
|
||||
'@media large {\n' +
|
||||
' .a-id {\n' +
|
||||
' width: 300px;\n' +
|
||||
' }\n' +
|
||||
'}\n' +
|
||||
'@media {\n' +
|
||||
' .b-id {\n' +
|
||||
' color: blue;\n' +
|
||||
' }\n' +
|
||||
'}\n' +
|
||||
'.c-id {\n' +
|
||||
' color: red;\n' +
|
||||
'}'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('warnings', () => {
|
||||
it('should warn when referenced rule is not found', () => {
|
||||
jss.createStyleSheet({
|
||||
a: {
|
||||
'& $b': {float: 'left'}
|
||||
}
|
||||
})
|
||||
|
||||
expect(spy.callCount).to.be(1)
|
||||
expect(
|
||||
spy.calledWithExactly(
|
||||
'Warning: [JSS] Could not find the referenced rule "b" in ".a-id {\n & $b: [object Object];\n}".'
|
||||
)
|
||||
).to.be(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('local refs', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
a: {
|
||||
float: 'left',
|
||||
'& $b': {float: 'left'},
|
||||
'& $b-warn': {float: 'right'}
|
||||
},
|
||||
b: {
|
||||
color: 'red'
|
||||
},
|
||||
'b-warn': {
|
||||
color: 'orange'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be(
|
||||
'.a-id {\n' +
|
||||
' float: left;\n' +
|
||||
'}\n' +
|
||||
'.a-id .b-id {\n' +
|
||||
' float: left;\n' +
|
||||
'}\n' +
|
||||
'.a-id .b-warn-id {\n' +
|
||||
' float: right;\n' +
|
||||
'}\n' +
|
||||
'.b-id {\n' +
|
||||
' color: red;\n' +
|
||||
'}\n' +
|
||||
'.b-warn-id {\n' +
|
||||
' color: orange;\n' +
|
||||
'}'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe.skip('nesting conditionals in combination with extend plugin', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
const localJss = create(settings).use(jssExtend(), nested())
|
||||
sheet = localJss.createStyleSheet({
|
||||
button: {
|
||||
color: 'green',
|
||||
'background-color': 'aqua',
|
||||
'@media': {
|
||||
width: '200px'
|
||||
}
|
||||
},
|
||||
redButton: {
|
||||
extend: 'button',
|
||||
color: 'red'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should add rules', () => {
|
||||
expect(sheet.getRule('button')).to.not.be(undefined)
|
||||
expect(sheet.getRule('@media')).to.not.be(undefined)
|
||||
expect(sheet.getRule('redButton')).to.not.be(undefined)
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be(
|
||||
'.button-id {\n' +
|
||||
' color: green;\n' +
|
||||
' background-color: aqua;\n' +
|
||||
'}\n' +
|
||||
'@media {\n' +
|
||||
' .button-id {\n' +
|
||||
' width: 200px;\n' +
|
||||
' }\n' +
|
||||
'}\n' +
|
||||
'.redButton-id {\n' +
|
||||
' color: red;\n' +
|
||||
' background-color: aqua;\n' +
|
||||
'}\n' +
|
||||
'@media {\n' +
|
||||
' .redButton-id {\n' +
|
||||
' width: 200px;\n' +
|
||||
' }\n' +
|
||||
'}'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('deep nesting', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
button: {
|
||||
color: 'black',
|
||||
'& .a': {
|
||||
color: 'red',
|
||||
'& .c': {
|
||||
color: 'gold'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should add rules', () => {
|
||||
expect(sheet.getRule('button')).to.not.be(undefined)
|
||||
expect(sheet.getRule('.button-id .a')).to.not.be(undefined)
|
||||
expect(sheet.getRule('.button-id .a .c')).to.not.be(undefined)
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be(
|
||||
'.button-id {\n' +
|
||||
' color: black;\n' +
|
||||
'}\n' +
|
||||
'.button-id .a {\n' +
|
||||
' color: red;\n' +
|
||||
'}\n' +
|
||||
'.button-id .a .c {\n' +
|
||||
' color: gold;\n' +
|
||||
'}'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('deep nesting with multiple nestings in one selector', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
button: {
|
||||
color: 'black',
|
||||
'& .a, .b': {
|
||||
color: 'red',
|
||||
'& .c, &:hover': {
|
||||
color: 'gold'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should add rules', () => {
|
||||
expect(sheet.getRule('button')).to.not.be(undefined)
|
||||
expect(sheet.getRule('.button-id .a, .button-id .b')).to.not.be(undefined)
|
||||
expect(
|
||||
sheet.getRule(
|
||||
'.button-id .a .c, .button-id .a:hover, .button-id .b .c, .button-id .b:hover'
|
||||
)
|
||||
).to.not.be(undefined)
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be(
|
||||
'.button-id {\n' +
|
||||
' color: black;\n' +
|
||||
'}\n' +
|
||||
'.button-id .a, .button-id .b {\n' +
|
||||
' color: red;\n' +
|
||||
'}\n' +
|
||||
'.button-id .a .c, .button-id .a:hover, ' +
|
||||
'.button-id .b .c, .button-id .b:hover {\n' +
|
||||
' color: gold;\n' +
|
||||
'}'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('support & at any position', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
a: {
|
||||
'input:focus + &': {
|
||||
color: 'red'
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should generate correct CSS', () => {
|
||||
expect(sheet.toString()).to.be('input:focus + .a-id {\n color: red;\n}')
|
||||
})
|
||||
})
|
||||
|
||||
describe('function values', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
const localJss = create(settings).use(nested(), functionPlugin())
|
||||
sheet = localJss.createStyleSheet({
|
||||
a: {
|
||||
color: ({color}) => color,
|
||||
'&:hover': {
|
||||
color: ({color}) => color
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should generate color red', () => {
|
||||
sheet.update({color: 'red'})
|
||||
expect(sheet.toString()).to.be(stripIndent`
|
||||
.a-id {
|
||||
color: red;
|
||||
}
|
||||
.a-id:hover {
|
||||
color: red;
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
it('should generate color green', () => {
|
||||
sheet.update({color: 'green'})
|
||||
expect(sheet.toString()).to.be(stripIndent`
|
||||
.a-id {
|
||||
color: green;
|
||||
}
|
||||
.a-id:hover {
|
||||
color: green;
|
||||
}
|
||||
`)
|
||||
})
|
||||
})
|
||||
|
||||
describe('nest rules inside media query', () => {
|
||||
let sheet
|
||||
|
||||
beforeEach(() => {
|
||||
sheet = jss.createStyleSheet({
|
||||
a: {},
|
||||
b: {
|
||||
'@media (min-width: 576px)': {
|
||||
'& $a': {
|
||||
margin: '15px'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should generate nested rules inside media queries', () => {
|
||||
expect(sheet.toString()).to.be(stripIndent`
|
||||
@media (min-width: 576px) {
|
||||
.b-id .a-id {
|
||||
margin: 15px;
|
||||
}
|
||||
}
|
||||
`)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user