From ffc6e92be160b6177be8ca9a78fbf0dbdabbea48 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 21 Aug 2018 15:55:55 +0200 Subject: [PATCH] Unlessified --- material-ui.iml | 9 +++ packages/material-ui-icons/package.json | 4 +- packages/material-ui/package.json | 4 +- .../src/styles/createGenerateClassName.js | 64 ++----------------- 4 files changed, 20 insertions(+), 61 deletions(-) create mode 100644 material-ui.iml diff --git a/material-ui.iml b/material-ui.iml new file mode 100644 index 00000000000000..8021953ed9f8cc --- /dev/null +++ b/material-ui.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/packages/material-ui-icons/package.json b/packages/material-ui-icons/package.json index f51ff6c6cd2e78..567ad895bfcc18 100644 --- a/packages/material-ui-icons/package.json +++ b/packages/material-ui-icons/package.json @@ -1,6 +1,6 @@ { - "name": "@material-ui/icons", - "private": true, + "name": "@unless.com/material-ui-icons", + "private": false, "author": "Material-UI Team", "version": "3.0.1", "description": "Material Design Svg Icons converted to Material-UI React components.", diff --git a/packages/material-ui/package.json b/packages/material-ui/package.json index b85ce25799d550..81c74d64092b8d 100644 --- a/packages/material-ui/package.json +++ b/packages/material-ui/package.json @@ -1,6 +1,6 @@ { - "name": "@material-ui/core", - "private": true, + "name": "@unless.com/material-ui-core", + "private": false, "author": "Material-UI Team", "version": "3.1.2", "description": "React components that implement Google's Material Design.", diff --git a/packages/material-ui/src/styles/createGenerateClassName.js b/packages/material-ui/src/styles/createGenerateClassName.js index c6a05a3eea032b..b8b0fa0c21a3eb 100644 --- a/packages/material-ui/src/styles/createGenerateClassName.js +++ b/packages/material-ui/src/styles/createGenerateClassName.js @@ -1,66 +1,16 @@ /* eslint-disable no-underscore-dangle */ - -import warning from 'warning'; - -const escapeRegex = /([[\].#*$><+~=|^:(),"'`\s])/g; - -function safePrefix(classNamePrefix) { - const prefix = String(classNamePrefix); - warning(prefix.length < 256, `Material-UI: the class name prefix is too long: ${prefix}.`); - // Sanitize the string as will be used to prefix the generated class name. - return prefix.replace(escapeRegex, '-'); -} - -// Returns a function which generates unique class names based on counters. -// When new generator function is created, rule counter is reset. -// We need to reset the rule counter for SSR for each request. -// -// It's inspired by -// https://github.com/cssinjs/jss/blob/4e6a05dd3f7b6572fdd3ab216861d9e446c20331/src/utils/createGenerateClassName.js export default function createGenerateClassName(options = {}) { - const { dangerouslyUseGlobalCSS = false, productionPrefix = 'jss', seed = '' } = options; let ruleCounter = 0; return (rule, styleSheet) => { - ruleCounter += 1; - warning( - ruleCounter < 1e10, - [ - 'Material-UI: you might have a memory leak.', - 'The ruleCounter is not supposed to grow that much.', - ].join(''), - ); - - // Code branch the whole block at the expense of more code. - if (dangerouslyUseGlobalCSS) { - if (styleSheet) { - if (styleSheet.options.name) { - return `${styleSheet.options.name}-${rule.key}`; - } - - if (styleSheet.options.classNamePrefix && process.env.NODE_ENV !== 'production') { - const prefix = safePrefix(styleSheet.options.classNamePrefix); - return `${prefix}-${rule.key}-${seed}${ruleCounter}`; - } - } - - if (process.env.NODE_ENV === 'production') { - return `${productionPrefix}${seed}${ruleCounter}`; - } - - return `${rule.key}-${seed}${ruleCounter}`; - } - - if (process.env.NODE_ENV === 'production') { - return `${productionPrefix}${seed}${ruleCounter}`; + if (styleSheet.options.classNamePrefix) { + return `${styleSheet.options.classNamePrefix}-${rule.key}` } - - if (styleSheet && styleSheet.options.classNamePrefix) { - const prefix = safePrefix(styleSheet.options.classNamePrefix); - - return `${prefix}-${rule.key}-${seed}${ruleCounter}`; + if (styleSheet.options.name) { + return `${styleSheet.options.name}-${rule.key}` } - - return `${rule.key}-${seed}${ruleCounter}`; + ruleCounter += 1; + return `txt-${rule.key}-${ruleCounter}` }; } +