@aesthetic/core
Version:
Aesthetic is a powerful type-safe, framework agnostic, CSS-in-JS library for styling components.
132 lines (113 loc) • 3.76 kB
JavaScript
// Bundled with Packemon: https://packemon.dev
// Platform: browser, Support: stable, Format: lib
;
Object.defineProperty(exports, '__esModule', {
value: true
});
const test = require('@aesthetic/system/test');
const utils = require('@aesthetic/utils');
/* eslint-disable no-param-reassign */
function resetAestheticState(aesthetic) {
// @ts-expect-error Allow access
aesthetic.activeDirection = undefined; // @ts-expect-error Allow access
aesthetic.activeTheme = undefined; // @ts-expect-error Allow access
aesthetic.listeners.clear(); // @ts-expect-error Allow access
aesthetic.globalSheetRegistry.clear(); // @ts-expect-error Allow access
aesthetic.themeRegistry.reset();
aesthetic.configure({
customProperties: {},
defaultUnit: 'px',
deterministicClasses: false,
directionConverter: null,
rootVariables: false,
vendorPrefixer: null
});
}
function getAestheticState(aesthetic) {
return {
// @ts-expect-error Allow access
activeDirection: aesthetic.activeDirection,
// @ts-expect-error Allow access
activeTheme: aesthetic.activeTheme,
// @ts-expect-error Allow access
globalSheetRegistry: aesthetic.globalSheetRegistry,
// @ts-expect-error Allow access
listeners: aesthetic.listeners,
// @ts-expect-error Allow access
options: aesthetic.options,
// @ts-expect-error Allow access
themeRegistry: aesthetic.themeRegistry
};
}
function setupAesthetic(aesthetic) {
aesthetic.registerTheme('day', test.lightTheme);
aesthetic.registerTheme('night', test.darkTheme);
}
function teardownAesthetic(aesthetic) {
test.lightTheme.name = '';
test.darkTheme.name = '';
resetAestheticState(aesthetic);
}
function createTestEngine() {
const noop = () => {};
const renderVariable = name => `variable:${utils.hyphenate(name)}`;
const renderRule = (rule, options = {}) => {
var _options$debugName, _rule$Variants;
let result = String((_options$debugName = options.debugName) !== null && _options$debugName !== void 0 ? _options$debugName : 'class');
utils.objectLoop(rule['@variables'], (value, name) => {
result += ` ${renderVariable(name)}`;
});
return {
result,
variants: Object.keys((_rule$Variants = rule['@variants']) !== null && _rule$Variants !== void 0 ? _rule$Variants : {}).map(variant => {
const types = variant.split('+').map(v => v.trim());
return {
result: types.map(v => `variant:${v}`).join(' '),
types
};
})
};
};
const engine = {
direction: 'ltr',
name: 'test',
prefersColorScheme: () => false,
prefersContrastLevel: () => false,
renderDeclaration: prop => `property:${utils.hyphenate(prop)}`,
renderFontFace: () => 'font-face',
renderImport: () => 'import',
renderKeyframes: (keyframes, name) => `keyframes:${utils.hyphenate(name !== null && name !== void 0 ? name : 'unknown')}`,
renderRule,
renderRuleGrouped: renderRule,
renderVariable,
ruleCount: 0,
setDirection: noop,
setRootVariables: noop,
setTheme: noop
};
return engine;
}
Object.defineProperty(exports, 'darkTheme', {
enumerable: true,
get: function () {
return test.darkTheme;
}
});
Object.defineProperty(exports, 'design', {
enumerable: true,
get: function () {
return test.design;
}
});
Object.defineProperty(exports, 'lightTheme', {
enumerable: true,
get: function () {
return test.lightTheme;
}
});
exports.createTestEngine = createTestEngine;
exports.getAestheticState = getAestheticState;
exports.resetAestheticState = resetAestheticState;
exports.setupAesthetic = setupAesthetic;
exports.teardownAesthetic = teardownAesthetic;
//# sourceMappingURL=test.js.map