@stylexjs/shared
Advanced tools
Comparing version 0.2.0-beta.27 to 0.3.0
@@ -40,5 +40,4 @@ /** | ||
test: boolean; | ||
moduleSystem?: 'haste' | 'commonjs'; | ||
rootDir?: string | void; | ||
stylexSheetName?: string | void; | ||
useRemForFontSize: boolean; | ||
runtimeInjection: boolean; | ||
classNamePrefix: string; | ||
@@ -45,0 +44,0 @@ definedStylexCSSVariables?: { [key: string]: unknown }; |
@@ -15,3 +15,3 @@ /** | ||
atRules: ReadonlyArray<string>, | ||
$$PARAM_3$$: StyleXOptions, | ||
options: StyleXOptions, | ||
): StyleRule; |
@@ -15,9 +15,9 @@ "use strict"; | ||
function convertStyleToClassName(objEntry, pseudos, atRules) { | ||
let { | ||
stylexSheetName = '<>', | ||
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _defaultOptions.defaultOptions; | ||
const { | ||
classNamePrefix = 'x' | ||
} = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _defaultOptions.defaultOptions; | ||
} = options; | ||
const [key, rawValue] = objEntry; | ||
const dashedKey = (0, _dashify.default)(key); | ||
const value = Array.isArray(rawValue) ? rawValue.map(eachValue => (0, _transformValue.default)(key, eachValue)) : (0, _transformValue.default)(key, rawValue); | ||
const value = Array.isArray(rawValue) ? rawValue.map(eachValue => (0, _transformValue.default)(key, eachValue, options)) : (0, _transformValue.default)(key, rawValue, options); | ||
const sortedPseudos = (0, _objectUtils.arraySort)(pseudos ?? []); | ||
@@ -29,5 +29,5 @@ const sortedAtRules = (0, _objectUtils.arraySort)(atRules ?? []); | ||
const stringToHash = Array.isArray(value) ? dashedKey + value.join(', ') + modifierHashString : dashedKey + value + modifierHashString; | ||
const className = classNamePrefix + (0, _hash.default)(stylexSheetName + stringToHash); | ||
const className = classNamePrefix + (0, _hash.default)('<>' + stringToHash); | ||
const cssRules = (0, _generateCssRule.generateRule)(className, dashedKey, value, pseudos, atRules); | ||
return [key, className, cssRules]; | ||
} |
@@ -7,2 +7,3 @@ /** | ||
* | ||
* | ||
*/ | ||
@@ -9,0 +10,0 @@ |
@@ -8,3 +8,2 @@ /** | ||
* | ||
* | ||
*/ | ||
@@ -11,0 +10,0 @@ |
@@ -17,4 +17,5 @@ "use strict"; | ||
const flattened = []; | ||
for (const key in style) { | ||
const value = style[key]; | ||
for (const _key in style) { | ||
const value = style[_key]; | ||
const key = _key.match(/var\(--[a-z0-9]+\)/) ? _key.slice(4, -1) : _key; | ||
if (typeof value === 'object' && value instanceof _stylexInclude.IncludedStyles) { | ||
@@ -21,0 +22,0 @@ flattened.push([key, new _PreRule.PreIncludedStylesRule(value)]); |
@@ -8,3 +8,2 @@ /** | ||
* | ||
* | ||
*/ | ||
@@ -11,0 +10,0 @@ |
@@ -8,3 +8,2 @@ /** | ||
* | ||
* | ||
*/ | ||
@@ -11,0 +10,0 @@ |
@@ -19,6 +19,5 @@ "use strict"; | ||
const { | ||
stylexSheetName = '<>', | ||
classNamePrefix = 'x' | ||
} = options; | ||
const expandedObject = (0, _objectUtils.objMap)(frames, frame => _objectUtils.Pipe.create(frame).pipe(frame => expandFrameShorthands(frame, options)).pipe(x => (0, _objectUtils.objMapKeys)(x, _dashify.default)).pipe(x => (0, _objectUtils.objMap)(x, (value, key) => (0, _transformValue.default)(key, value))).done()); | ||
const expandedObject = (0, _objectUtils.objMap)(frames, frame => _objectUtils.Pipe.create(frame).pipe(frame => expandFrameShorthands(frame, options)).pipe(x => (0, _objectUtils.objMapKeys)(x, _dashify.default)).pipe(x => (0, _objectUtils.objMap)(x, (value, key) => (0, _transformValue.default)(key, value, options))).done()); | ||
const ltrStyles = (0, _objectUtils.objMap)(expandedObject, frame => (0, _objectUtils.objMapEntry)(frame, _generateLtr.default)); | ||
@@ -28,3 +27,3 @@ const rtlStyles = (0, _objectUtils.objMap)(expandedObject, frame => (0, _objectUtils.objMapEntry)(frame, entry => (0, _generateRtl.default)(entry) ?? entry)); | ||
const rtlString = constructKeyframesObj(rtlStyles); | ||
const animationName = classNamePrefix + (0, _hash.default)(stylexSheetName + ltrString) + '-B'; | ||
const animationName = classNamePrefix + (0, _hash.default)('<>' + ltrString) + '-B'; | ||
const ltr = `@keyframes ${animationName}{${ltrString}}`; | ||
@@ -31,0 +30,0 @@ const rtl = ltrString === rtlString ? null : `@keyframes ${animationName}{${rtlString}}`; |
@@ -7,8 +7,14 @@ /** | ||
* | ||
* | ||
*/ | ||
import type { StyleXOptions } from './common-types'; | ||
/** | ||
* Convert a CSS value in JS to the final CSS string value | ||
*/ | ||
declare function transformValue(key: string, rawValue: string | number): string; | ||
declare function transformValue( | ||
key: string, | ||
rawValue: string | number, | ||
options: StyleXOptions, | ||
): string; | ||
export default transformValue; | ||
@@ -15,0 +21,0 @@ export declare function getNumberSuffix(key: string): string; |
@@ -11,3 +11,3 @@ "use strict"; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function transformValue(key, rawValue) { | ||
function transformValue(key, rawValue, options) { | ||
const value = typeof rawValue === 'number' ? String(Math.round(rawValue * 10000) / 10000) + getNumberSuffix(key) : rawValue; | ||
@@ -23,3 +23,3 @@ if ((key === 'content' || key === 'hyphenateCharacter' || key === 'hyphenate-character') && typeof value === 'string') { | ||
} | ||
return (0, _normalizeValue.default)(value, key); | ||
return (0, _normalizeValue.default)(value, key, options); | ||
} | ||
@@ -26,0 +26,0 @@ function getNumberSuffix(key) { |
@@ -7,2 +7,3 @@ /** | ||
* | ||
* | ||
*/ | ||
@@ -9,0 +10,0 @@ |
@@ -7,2 +7,3 @@ /** | ||
* | ||
* | ||
*/ | ||
@@ -9,0 +10,0 @@ |
@@ -9,2 +9,4 @@ "use strict"; | ||
dev: false, | ||
runtimeInjection: false, | ||
useRemForFontSize: true, | ||
test: false, | ||
@@ -11,0 +13,0 @@ classNamePrefix: 'x', |
@@ -7,2 +7,3 @@ /** | ||
* | ||
* | ||
*/ | ||
@@ -9,0 +10,0 @@ |
@@ -8,3 +8,2 @@ /** | ||
* | ||
* | ||
*/ | ||
@@ -11,0 +10,0 @@ |
@@ -8,6 +8,10 @@ /** | ||
* | ||
* | ||
*/ | ||
declare function normalizeValue(value: string, key: string): string; | ||
import type { StyleXOptions } from '../common-types'; | ||
declare function normalizeValue( | ||
value: string, | ||
key: string, | ||
$$PARAM_2$$: StyleXOptions, | ||
): string; | ||
export default normalizeValue; |
@@ -17,4 +17,7 @@ 'use strict'; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const normalizers = [_detectUnclosedFns.default, _whitespace.default, _timings.default, _zeroDimensions.default, _leadingZero.default, _quotes.default, _fontSizePxToRem.default, _convertCamelCaseValues.default]; | ||
function normalizeValue(value, key) { | ||
const normalizers = [_detectUnclosedFns.default, _whitespace.default, _timings.default, _zeroDimensions.default, _leadingZero.default, _quotes.default, _convertCamelCaseValues.default]; | ||
function normalizeValue(value, key, _ref) { | ||
let { | ||
useRemForFontSize | ||
} = _ref; | ||
if (value == null) { | ||
@@ -24,3 +27,4 @@ return value; | ||
const parsedAST = (0, _postcssValueParser.default)(value); | ||
return normalizers.reduce((ast, fn) => fn(ast, key), parsedAST).toString(); | ||
const relevantNormalizers = useRemForFontSize ? [...normalizers, _fontSizePxToRem.default] : normalizers; | ||
return relevantNormalizers.reduce((ast, fn) => fn(ast, key), parsedAST).toString(); | ||
} |
@@ -8,3 +8,2 @@ /** | ||
* | ||
* | ||
*/ | ||
@@ -11,0 +10,0 @@ |
@@ -8,3 +8,2 @@ /** | ||
* | ||
* | ||
*/ | ||
@@ -11,0 +10,0 @@ |
@@ -8,3 +8,2 @@ /** | ||
* | ||
* | ||
*/ | ||
@@ -11,0 +10,0 @@ |
@@ -8,3 +8,2 @@ /** | ||
* | ||
* | ||
*/ | ||
@@ -11,0 +10,0 @@ |
{ | ||
"name": "@stylexjs/shared", | ||
"version": "0.2.0-beta.27", | ||
"version": "0.3.0", | ||
"main": "lib/index.js", | ||
@@ -16,3 +16,3 @@ "repository": "https://www.github.com/facebook/stylex", | ||
"devDependencies": { | ||
"@stylexjs/scripts": "0.2.0-beta.27" | ||
"@stylexjs/scripts": "0.3.0" | ||
}, | ||
@@ -22,4 +22,3 @@ "jest": { | ||
"printBasicPrototype": false | ||
}, | ||
"prettierPath": null | ||
} | ||
}, | ||
@@ -26,0 +25,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
851961
25902