Socket
Socket
Sign inDemoInstall

@fower/core

Package Overview
Dependencies
Maintainers
2
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fower/core - npm Package Compare versions

Comparing version 1.72.0 to 1.73.0

503

dist/core.cjs.development.js

@@ -23,3 +23,2 @@ 'use strict';

}
function _createClass(Constructor, protoProps, staticProps) {

@@ -33,8 +32,6 @@ if (protoProps) _defineProperties(Constructor.prototype, protoProps);

}
function _extends() {
_extends = Object.assign || function (target) {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {

@@ -46,9 +43,6 @@ if (Object.prototype.hasOwnProperty.call(source, key)) {

}
return target;
};
return _extends.apply(this, arguments);
}
function _objectWithoutPropertiesLoose(source, excluded) {

@@ -59,3 +53,2 @@ if (source == null) return {};

var key, i;
for (i = 0; i < sourceKeys.length; i++) {

@@ -66,6 +59,4 @@ key = sourceKeys[i];

}
return target;
}
function _unsupportedIterableToArray(o, minLen) {

@@ -79,15 +70,10 @@ if (!o) return;

}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (it) return (it = it.call(o)).next.bind(it);
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {

@@ -106,3 +92,2 @@ if (it) o = it;

}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");

@@ -115,3 +100,2 @@ }

var _this = this;
this.config = {

@@ -154,15 +138,11 @@ unit: 'px',

this.atomCache = new Map();
this.getAtomIds = function () {
return Array.from(_this.atomCache.keys());
}; // composed atomic props
};
// composed atomic props
this.compositions = new Map();
this.getConfig = function () {
return _this.config;
}; // user config
};
// user config
this.setConfig = function (config, strategy) {

@@ -172,3 +152,2 @@ if (strategy === void 0) {

}
if (strategy === 'replace') {

@@ -179,4 +158,4 @@ _this.config = config;

} else {
_this.config = deepmerge(_this.config, config); // TODO: need improve, 这个是特殊的
_this.config = deepmerge(_this.config, config);
// TODO: need improve, 这个是特殊的
if (config.objectPropKeys) {

@@ -187,31 +166,22 @@ _this.config.objectPropKeys = config.objectPropKeys;

};
this.getTheme = function () {
return _this.config.theme;
};
this.setTheme = function (partialThemeConfig) {
_this.config.theme = deepmerge(_this.config.theme || {}, partialThemeConfig);
};
this.getMode = function () {
var _this$config$mode;
return ((_this$config$mode = _this.config.mode) == null ? void 0 : _this$config$mode.currentMode) || '';
};
this.setMode = function (mode) {
if (!utils.isBrowser) return;
var currentMode = _this.config.mode.currentMode;
if (currentMode) {
document.documentElement.classList.remove(currentMode);
}
if (mode) {
document.documentElement.classList.add(mode);
}
localStorage.setItem(modeCacheKey, mode);
_this.setConfig({

@@ -223,9 +193,6 @@ mode: {

};
this.use = function () {
var _this$config$plugins;
(_this$config$plugins = _this.config.plugins).push.apply(_this$config$plugins, arguments);
};
this.addAtom = function (matcher, handleAtomOrStyleObject) {

@@ -243,8 +210,5 @@ var plugin = {

};
_this.use(plugin);
return plugin;
};
this.composeAtom = function (atomName, cssObject) {

@@ -254,3 +218,2 @@ _this.compositions.set(atomName, cssObject);

}
_createClass(Store, [{

@@ -262,3 +225,2 @@ key: "theme",

}]);
return Store;

@@ -269,3 +231,3 @@ }();

var _excluded = ["pseudoPrefix", "childSelector", "important"],
_excluded2 = ["colorPostfix"];
_excluded2 = ["colorPostfix"];
var invalidProps = ['excludedProps'];

@@ -276,3 +238,2 @@ /**

*/
var digitReg = /^(m[xytrbl]?-?|p[xytrbl]?|space[xy]?|top-?|right-?|bottom-?|left-?|[wh]|square|circle|min[hw]|max[hw]|opacity|delay|duration|translate[xyz]|scale[xy]?|rotate[xy]?|skew[xy]?|text|zIndex-?|leading|stroke|fontWeight|outlineOffset|order|flex(Grow|Shrink|Basis)?|(row|column)?Gap|gridTemplateColumns|border(Top|Right|Bottom|Left)?|rounded(Top(Left|Right)?|Right|Bottom(Left|Right)?|Left)?)(-?\d+[a-z]*?|-auto)$/i;

@@ -287,7 +248,5 @@ var Atom = /*#__PURE__*/function () {

var _this = this;
if (autoSetId === void 0) {
autoSetId = true;
}
this.options = options;

@@ -298,3 +257,2 @@ this.autoSetId = autoSetId;

*/
this.propKeys = [];

@@ -309,3 +267,2 @@ /**

*/
this.value = '';

@@ -315,18 +272,14 @@ /**

*/
this.id = '';
this.type = '';
this.setId = function () {
var meta = _this.meta,
key = _this.key,
value = _this.value;
key = _this.key,
value = _this.value;
var important = meta.important,
rest = _objectWithoutPropertiesLoose(meta, _excluded);
rest = _objectWithoutPropertiesLoose(meta, _excluded);
var values = Object.values(rest).sort();
if (important) values.push('i');
var id; // is global style
var id;
// is global style
if (meta.global) {

@@ -337,3 +290,2 @@ id = hash(JSON.stringify(value)).toString();

}
if (typeof value === 'boolean' && value === true) {

@@ -343,3 +295,4 @@ id = key;

var valueStr = value.join('-');
id = key + "-" + valueStr; // } else if (typeof value === 'function') {
id = key + "-" + valueStr;
// } else if (typeof value === 'function') {
// const valueStr = hash(value.toString())

@@ -350,12 +303,9 @@ // id = `${key}-${valueStr}`

}
if (values.length) id = id + '--' + values.join('--'); // handle special character
if (values.length) id = id + '--' + values.join('--');
// handle special character
id = id.replace(/[#()"']/g, '').replace('.', '_').replace(/\%/g, 'p').replace(/\s+/g, '-');
if (_this.isFalsyPropValue) id = id + '--false';
if (meta.childSelector) {
id = meta.childSelector + '-' + id;
}
var isValid = /^[a-zA-Z0-9-_]+$/.test(id);

@@ -366,3 +316,2 @@ id = isValid ? id : "css-" + hash(id);

};
this.propKey = options.propKey;

@@ -376,4 +325,4 @@ this.propValue = options.propValue;

this.isValid = this.getIsValid();
this.inserted = false; // shallow clone it
this.inserted = false;
// shallow clone it
this.meta = _extends({}, options.meta) || {};

@@ -387,6 +336,3 @@ this.preprocessAtom();

*/
var _proto = Atom.prototype;
/**

@@ -402,3 +348,2 @@ *

};
_proto.postfixPreprocessor = function postfixPreprocessor() {

@@ -408,10 +353,10 @@ var connector = '--';

var _store$config = store.config,
_store$config$pseudos = _store$config.pseudos,
pseudos = _store$config$pseudos === void 0 ? [] : _store$config$pseudos,
theme = _store$config.theme,
mode = _store$config.mode;
_store$config$pseudos = _store$config.pseudos,
pseudos = _store$config$pseudos === void 0 ? [] : _store$config$pseudos,
theme = _store$config.theme,
mode = _store$config.mode;
var modeList = mode.modeList;
var breakpoints = theme.breakpoints;
var propKey = this.propKey,
propValue = this.propValue;
propValue = this.propValue;
var breakpointKeys = Object.keys(breakpoints);

@@ -430,12 +375,9 @@ var modeKeys = modeList || [];

/** handle value like: red500--T40, #666--O30 */
if (regColorPostfix.test(propValue)) {
var _propValue$split = propValue.split('--'),
colorName = _propValue$split[0],
postfix = _propValue$split[1];
colorName = _propValue$split[0],
postfix = _propValue$split[1];
this.value = colorName;
this.meta.colorPostfix = postfix;
}
var isMode = regMode.test(propKey);

@@ -451,3 +393,2 @@ var isPseudo = regPseudo.test(propKey);

this.key = result[0]; // key that already removed postfix
if (isMode) {

@@ -458,3 +399,2 @@ this.meta.mode = result.find(function (i) {

}
if (isPseudo) {

@@ -467,3 +407,2 @@ var pseudo = result.find(function (i) {

}
if (isResponsive) {

@@ -475,3 +414,2 @@ var breakpointType = result.find(function (i) {

}
if (isImportant) {

@@ -482,3 +420,2 @@ this.meta.important = !!result.find(function (i) {

}
if (isColorPostfix) {

@@ -489,20 +426,16 @@ this.meta.colorPostfix = result.find(function (i) {

}
if (isParentSelector) {
var _result$find;
this.meta.parentClass = (_result$find = result.find(function (i) {
return i.startsWith('$');
})) == null ? void 0 : _result$find.replace(/^\$/, '');
} // check is theme space key, if yes, preprocess it
}
// check is theme space key, if yes, preprocess it
this.digitPreprocessor();
return this;
};
_proto.digitPreprocessor = function digitPreprocessor() {
if (!digitReg.test(this.key)) return this;
var spacings = store.config.theme.spacings; // is theme space key
var spacings = store.config.theme.spacings;
// is theme space key
var isSpace = /^([a-z]+)(\d+)$/i.test(this.key);

@@ -515,3 +448,2 @@ /**

*/
var keyStr = this.key.toString();

@@ -521,3 +453,3 @@ var result = keyStr.match(/^([a-z]+)(\d+)$/i) || keyStr.match(/^([a-z]*)-(-?\d+[a-z]*?)$/i) || keyStr.match(/^([a-z]+)-(auto)$/i);

var newKey = result[1],
newPropValue = result[2];
newPropValue = result[2];
this.key = newKey;

@@ -527,3 +459,2 @@ this.value = isSpace ? spacings["" + newPropValue.toLowerCase()] : newPropValue;

};
_proto.getInitialHandled = function getInitialHandled() {

@@ -535,3 +466,2 @@ if (this.options.handled) return this.options.handled;

};
_proto.getIsValid = function getIsValid() {

@@ -542,3 +472,2 @@ if (this.isFalsyPropValue) return false;

};
_createClass(Atom, [{

@@ -557,3 +486,2 @@ key: "isValueProp",

*/
}, {

@@ -572,3 +500,2 @@ key: "styleKeys",

*/
}, {

@@ -578,5 +505,3 @@ key: "styleKeysHash",

var _this$meta = this.meta,
rest = _objectWithoutPropertiesLoose(_this$meta, _excluded2); // omit colorPostfix
rest = _objectWithoutPropertiesLoose(_this$meta, _excluded2); // omit colorPostfix
return Object.keys(this.style || {}).join('-') + JSON.stringify(rest);

@@ -596,3 +521,2 @@ }

}]);
return Atom;

@@ -606,12 +530,8 @@ }();

this.ssrAtomIds = null;
if (utils.isBrowser) {
var _globalThis$document;
this.$style = (_globalThis$document = globalThis.document) == null ? void 0 : _globalThis$document.querySelector == null ? void 0 : _globalThis$document.querySelector('[data-fower]');
}
}
var _proto = StyleSheet.prototype;
_proto.createStyleElement = function createStyleElement() {

@@ -623,6 +543,4 @@ var $style = document.createElement('style');

};
_proto.getSsrAtomIds = function getSsrAtomIds() {
var _this$$style, _this$$style$dataset$;
if (!this.$style) return [];

@@ -632,16 +550,12 @@ if (this.ssrAtomIds) return this.ssrAtomIds;

};
_proto.insertStyleToHtml = function insertStyleToHtml(rules) {
if (!utils.isBrowser) return;
if (!this.$style) {
this.$style = this.createStyleElement();
} // const str = rules.join('\n')
}
// const str = rules.join('\n')
// this.$style.innerHTML += str
// return
for (var _iterator = _createForOfIteratorHelperLoose(rules), _step; !(_step = _iterator()).done;) {
var rule = _step.value;
try {

@@ -654,3 +568,2 @@ this.$style.sheet.insertRule(rule);

};
_proto.insertStyles = function insertStyles(rules) {

@@ -660,3 +573,2 @@ if (rules === void 0) {

}
if (!rules.length) return;

@@ -666,10 +578,7 @@ if (utils.isBrowser) return this.insertStyleToHtml(rules);

};
_proto.getStyle = function getStyle() {
return this.cssString;
};
return StyleSheet;
}();
var styleSheet = /*#__PURE__*/new StyleSheet();

@@ -684,3 +593,2 @@

*/
function isUnitProp(cssKey) {

@@ -691,3 +599,3 @@ return reg.test(cssKey);

var colorKeys = ['color', 'backgroundColor', 'borderColor'];
// high-frequency used props in react
var reactProps = ['children', 'onClick', 'onChange', 'onBlur', 'id', 'className', 'style', 'title', 'tabIndex', 'placeholder', 'href', 'src', 'contentEditable', 'defaultChecked', 'defaultValue'];

@@ -697,11 +605,8 @@ /**

*/
var Parser = /*#__PURE__*/function () {
function Parser(props) {
var _store$config$mode, _store$config$mode$au;
if (props === void 0) {
props = {};
}
this.props = props;

@@ -711,3 +616,2 @@ /**

*/
this.atoms = [];

@@ -717,11 +621,7 @@ /**

*/
this.data = {};
this.getClassNameById = function (id) {
return store.config.prefix + id;
};
this.traverseProps(props);
if ((_store$config$mode = store.config.mode) != null && (_store$config$mode$au = _store$config$mode.autoDarkMode) != null && _store$config$mode$au.enabled) {

@@ -731,5 +631,3 @@ this.autoDarkMode();

}
var _proto = Parser.prototype;
/**

@@ -741,6 +639,6 @@ * traverse Props to init atoms

var _this$config = this.config,
_this$config$pseudos = _this$config.pseudos,
pseudos = _this$config$pseudos === void 0 ? [] : _this$config$pseudos,
theme = _this$config.theme,
mode = _this$config.mode;
_this$config$pseudos = _this$config.pseudos,
pseudos = _this$config$pseudos === void 0 ? [] : _this$config$pseudos,
theme = _this$config.theme,
mode = _this$config.mode;
var modeList = mode.modeList;

@@ -752,8 +650,6 @@ var breakpoints = theme.breakpoints || {};

var _props$excludedProps = props.excludedProps,
excludedProps = _props$excludedProps === void 0 ? [] : _props$excludedProps;
excludedProps = _props$excludedProps === void 0 ? [] : _props$excludedProps;
var entries = Object.entries(props);
for (var _iterator = _createForOfIteratorHelperLoose(this.plugins), _step; !(_step = _iterator()).done;) {
var plugin = _step.value;
if (plugin.init) {

@@ -763,3 +659,2 @@ plugin.init(props);

}
if (props != null && props.className) {

@@ -770,16 +665,14 @@ for (var _iterator2 = _createForOfIteratorHelperLoose(props.className.split(/\s+/)), _step2; !(_step2 = _iterator2()).done;) {

}
} // traverse Props
}
// traverse Props
for (var _i = 0, _entries = entries; _i < _entries.length; _i++) {
var _this$config$objectPr;
var _entries$_i = _entries[_i],
propKey = _entries$_i[0],
propValue = _entries$_i[1];
propKey = _entries$_i[0],
propValue = _entries$_i[1];
// the prop should be excluded by user setting
if (excludedProps.includes(propKey)) continue;
if (reactProps.includes(propKey)) continue;
if (!this.isValidProp(propKey, propValue)) continue; // parse object prop
if (!this.isValidProp(propKey, propValue)) continue;
// parse object prop
if ((_this$config$objectPr = this.config.objectPropKeys) != null && _this$config$objectPr.includes(propKey)) {

@@ -790,4 +683,2 @@ this.parseObjectProp(propValue, {});

/** handle _hover, _sm, _dark... */
if (propKey.startsWith('_')) {

@@ -797,6 +688,4 @@ var postfix = propKey.replace(/^_/, '');

var _extends2;
return _extends({}, r, (_extends2 = {}, _extends2[cur] = true, _extends2));
}, {}) : propValue;
if (modeKeys.includes(postfix)) {

@@ -808,3 +697,2 @@ this.parseObjectProp(obj, {

}
if (breakpointKeys.includes(postfix)) {

@@ -816,3 +704,2 @@ this.parseObjectProp(obj, {

}
if (pseudoKeys.includes(postfix)) {

@@ -826,3 +713,2 @@ this.parseObjectProp(obj, {

}
if (Array.isArray(propValue)) {

@@ -835,8 +721,5 @@ // TODO: hack for bgGradientX, bgGradientY

}
var composition = store.compositions.get(propKey);
if (composition) {
this.parseObjectProp(composition, {});
var _atom = new Atom({

@@ -846,3 +729,2 @@ propKey: propKey,

});
_atom.handled = true;

@@ -852,5 +734,4 @@ _atom.style = {};

continue;
} // common props
}
// common props
var atom = new Atom({

@@ -860,3 +741,2 @@ propKey: propKey,

}, false);
try {

@@ -869,6 +749,4 @@ this.mutateAtom(atom);

}
for (var _iterator3 = _createForOfIteratorHelperLoose(this.plugins), _step3; !(_step3 = _iterator3()).done;) {
var _plugin = _step3.value;
if (_plugin.afterAtomStyleCreate) {

@@ -879,6 +757,4 @@ _plugin.afterAtomStyleCreate(this);

};
_proto.getAutoDarkModeAtom = function getAutoDarkModeAtom(atom) {
var _options$style;
if (atom.meta.mode) return null;

@@ -894,15 +770,13 @@ if (!atom.style) return null;

var _entries$ = entries[0],
colorKey = _entries$[0],
colorName = _entries$[1]; // check is valid color key
if (!colorKeys.includes(colorKey)) return null; // only color in theme is valid
if (!colors[colorName]) return null; // if scale is existed, scale should be 100,200,300,400...
colorKey = _entries$[0],
colorName = _entries$[1];
// check is valid color key
if (!colorKeys.includes(colorKey)) return null;
// only color in theme is valid
if (!colors[colorName]) return null;
// if scale is existed, scale should be 100,200,300,400...
var _ref = colorName.match(/^([a-z]+)(\d+)$/i) || [],
scale = _ref[2]; // is disable, eg: { red200: false}
scale = _ref[2];
// is disable, eg: { red200: false}
if (mappings[colorName] === false) return null;
if (mappings[colorName]) {

@@ -913,7 +787,5 @@ darkColor = mappings[colorName];

}
var isColor = colorKey === 'color';
var isBgColor = colorKey === 'backgroundColor';
var isBorderColor = colorKey === 'borderColor';
if (colors[darkColor]) {

@@ -927,3 +799,2 @@ if (isColor) {

}
options.propValue = true;

@@ -942,3 +813,2 @@ } else {

}
options.style = (_options$style = {}, _options$style[colorKey] = darkColor, _options$style);

@@ -951,3 +821,2 @@ return new Atom(_extends({}, options, {

};
_proto.autoDarkMode = function autoDarkMode() {

@@ -963,3 +832,2 @@ for (var _iterator4 = _createForOfIteratorHelperLoose(this.atoms), _step4; !(_step4 = _iterator4()).done;) {

var cachedAtom = store.atomCache.get(darkAtom.id);
if (cachedAtom) {

@@ -977,23 +845,18 @@ this.addAtom(cachedAtom);

* @returns
*/
;
*/;
_proto.formatCssValue = function formatCssValue(key, value) {
// no need unit
if (!isUnitProp(key)) return value;
var numValue = value; // 80p -> 80%, 50p-> -50%
var numValue = value;
// 80p -> 80%, 50p-> -50%
if (utils.isPercentNumber(String(value))) {
return String(value).replace('p', '%');
}
if (!utils.isNumber(value)) return value;
numValue = Number(value); // if num is between 0 and 1, convert it to percent number.
numValue = Number(value);
// if num is between 0 and 1, convert it to percent number.
if (numValue < 1 && numValue > 0) {
return numValue * 100 + '%';
}
var config = store.config;
if (config.unit !== 'none') {

@@ -1006,3 +869,2 @@ if (config.transformUnit) {

}
return numValue;

@@ -1018,17 +880,13 @@ }

* @returns
*/
;
*/;
_proto.styleToString = function styleToString(style, meta) {
var _this = this;
var important = meta.important,
colorPostfix = meta.colorPostfix;
colorPostfix = meta.colorPostfix;
return Object.entries(style).reduce(function (r, _ref2) {
var key = _ref2[0],
value = _ref2[1];
value = _ref2[1];
var cssKey = utils.jsKeyToCssKey(key);
var postfix = important ? ' !important' : '';
var colors = store.theme.colors;
try {

@@ -1040,3 +898,2 @@ if (colorPostfix) {

}
return r + (cssKey + ": " + value + postfix + ";");

@@ -1048,38 +905,29 @@ } catch (error) {

};
_proto.addAtom = function addAtom(atom) {
var _this$config$theme;
if (!atom.id) atom.setId(); // if not cached, let's cache it
if (!atom.id) atom.setId();
// if not cached, let's cache it
if (!store.atomCache.get(atom.id)) {
store.atomCache.set(atom.id, atom);
}
var ssrAtomIds = styleSheet.getSsrAtomIds();
var _ref3 = ((_this$config$theme = this.config.theme) == null ? void 0 : _this$config$theme.colors) || {},
_ref3$modes = _ref3.modes,
modes = _ref3$modes === void 0 ? {} : _ref3$modes;
_ref3$modes = _ref3.modes,
modes = _ref3$modes === void 0 ? {} : _ref3$modes;
var entries = Object.entries(modes);
/** for color mode */
for (var _i2 = 0, _entries2 = entries; _i2 < _entries2.length; _i2++) {
var _entries2$_i = _entries2[_i2],
mode = _entries2$_i[0],
colors = _entries2$_i[1];
mode = _entries2$_i[0],
colors = _entries2$_i[1];
if (!atom.style) continue;
var _entries3 = Object.entries(atom.style);
if (!_entries3.length) continue;
var _entries3$ = _entries3[0],
styleKey = _entries3$[0],
styleValue = _entries3$[1];
styleKey = _entries3$[0],
styleValue = _entries3$[1];
var colorValue = colors[styleValue];
if (colorValue) {
var postfix = '--' + mode; // TODO: improve clone
var postfix = '--' + mode;
// TODO: improve clone
var modeAtom = JSON.parse(JSON.stringify(atom));

@@ -1096,3 +944,2 @@ modeAtom.key = atom.key + postfix;

}
if (ssrAtomIds.includes(atom.id)) atom.inserted = true;

@@ -1106,11 +953,8 @@ this.atoms.push(atom);

* @returns
*/
;
*/;
_proto.isValidProp = function isValidProp(propKey, propValue) {
var _this$config$objectPr2;
var validTypes = ['string', 'boolean', 'number', 'undefined', 'function'];
if ((_this$config$objectPr2 = this.config.objectPropKeys) != null && _this$config$objectPr2.includes(propKey)) return true; // for _hover,_sm,_dark...
if ((_this$config$objectPr2 = this.config.objectPropKeys) != null && _this$config$objectPr2.includes(propKey)) return true;
// for _hover,_sm,_dark...
if (propKey.startsWith('_')) return true;

@@ -1125,26 +969,20 @@ if (Array.isArray(propValue)) return true;

* @param atom
*/
;
*/;
_proto.mutateAtom = function mutateAtom(atom) {
for (var _iterator5 = _createForOfIteratorHelperLoose(this.plugins), _step5; !(_step5 = _iterator5()).done;) {
var plugin = _step5.value;
if (!(plugin.isMatch != null && plugin.isMatch(atom.key, this))) continue; // why set id here? because of function prop Value
if (!atom.id) atom.setId(); // 处理函数 props
if (!(plugin.isMatch != null && plugin.isMatch(atom.key, this))) continue;
// why set id here? because of function prop Value
if (!atom.id) atom.setId();
// 处理函数 props
if (typeof atom.value === 'function') atom.value = atom.value();
if (plugin.beforeHandleAtom) {
atom = plugin.beforeHandleAtom(atom, this);
}
} // for nested style, like css props
}
// for nested style, like css props
if (Object.values(atom.meta || {}).length || Object.values(atom.style || {}).length) {
if (!atom.id) atom.setId();
}
var cachedAtom = store.atomCache.get(atom.id);
if (cachedAtom) {

@@ -1154,5 +992,4 @@ cachedAtom.propKeys.push(atom.propKey);

throw new Error('atom is cached, add to this.atoms directly, no need to mutate');
} // if handled, push to this.atoms and skip it
}
// if handled, push to this.atoms and skip it
if (atom.handled) {

@@ -1162,11 +999,8 @@ this.addAtom(atom);

}
for (var _iterator6 = _createForOfIteratorHelperLoose(this.plugins), _step6; !(_step6 = _iterator6()).done;) {
var _plugin2 = _step6.value;
if (!(_plugin2.isMatch != null && _plugin2.isMatch(atom.key, this))) continue;
if (_plugin2.handleAtom) {
atom = _plugin2.handleAtom == null ? void 0 : _plugin2.handleAtom(atom, this);
}
atom.handled = true;

@@ -1176,3 +1010,2 @@ break; // break from this plugin

};
_proto.parseResponsiveValue = function parseResponsiveValue(propKey, propValue) {

@@ -1183,3 +1016,2 @@ var breakpoints = this.config.theme.breakpoints;

var _extends3;
var prop = "" + propKey + (i === 0 ? '' : '--' + keys[i - 1]);

@@ -1190,3 +1022,2 @@ return _extends({}, result, (_extends3 = {}, _extends3[prop] = cur, _extends3));

};
_proto.parseObjectProp = function parseObjectProp(propValue, meta) {

@@ -1196,16 +1027,14 @@ if (meta === void 0) {

}
var parsed = cssObjectProcessor.parse(propValue);
for (var _iterator7 = _createForOfIteratorHelperLoose(parsed), _step7; !(_step7 = _iterator7()).done;) {
var _step7$value = _step7.value,
selector = _step7$value.selector,
selectorType = _step7$value.selectorType,
style = _step7$value.style;
selector = _step7$value.selector,
selectorType = _step7$value.selectorType,
style = _step7$value.style;
var entries = Object.entries(style);
if (!entries.length) continue; // entries.length is 1
if (!entries.length) continue;
// entries.length is 1
var _entries$2 = entries[0],
propKey = _entries$2[0],
_propValue = _entries$2[1];
propKey = _entries$2[0],
_propValue = _entries$2[1];
var option = {

@@ -1215,27 +1044,21 @@ propKey: propKey,

meta: _extends({}, meta)
}; // 对于正常的css属性,例如 vertical-align,设置 style
};
// 对于正常的css属性,例如 vertical-align,设置 style
if (style && Object.keys(style).length) {
option.style = style;
}
if (selectorType === 'pseudo' && option.meta) {
var _ref4 = selector.match(/(:+)(.+)/) || [],
pseudoPrefix = _ref4[1],
pseudo = _ref4[2];
pseudoPrefix = _ref4[1],
pseudo = _ref4[2];
option.meta.pseudoPrefix = pseudoPrefix;
option.meta.pseudo = pseudo;
}
if (selectorType === 'child' && option.meta) {
option.meta.childSelector = selector;
}
if (selectorType === 'sibling' && option.meta) {
option.meta.siblingSelector = selector;
}
var atom = new Atom(option, false);
try {

@@ -1245,11 +1068,8 @@ this.mutateAtom(atom);

continue;
} // not match atomic props rule, 说明是非原子属性
}
// not match atomic props rule, 说明是非原子属性
if (!atom.style || !Object.keys(atom.style).length) {
atom.handled = true;
}
var cachedAtom = store.atomCache.get(atom.id);
if (cachedAtom) {

@@ -1262,3 +1082,2 @@ this.addAtom(cachedAtom);

};
_proto.makeResponsiveStyle = function makeResponsiveStyle(breakpoint, rule) {

@@ -1270,8 +1089,5 @@ var breakpoints = this.config.theme.breakpoints;

* get component classNames
*/
;
*/;
_proto.getClassNames = function getClassNames() {
var _this2 = this;
/**

@@ -1290,5 +1106,3 @@ * handle override style

if (!cur.isValid) return result;
var className = _this2.getClassNameById(cur.id);
if (index === -1) {

@@ -1301,7 +1115,6 @@ classNames.push(className);

}
return result;
}, []);
var _this$props$className = this.props.className,
className = _this$props$className === void 0 ? '' : _this$props$className;
className = _this$props$className === void 0 ? '' : _this$props$className;
var filteredClassNames = className.split(/\s+/).filter(function (i) {

@@ -1311,8 +1124,5 @@ return !classNames.includes(i) && !!i;

classNames = classNames.concat(filteredClassNames);
if (this.hasResponsive) {
var _classNames;
var breakpoints = this.config.theme.breakpoints;
(_classNames = classNames).push.apply(_classNames, Object.keys(breakpoints).map(function (i) {

@@ -1322,3 +1132,2 @@ return "r-" + i;

}
return classNames;

@@ -1328,20 +1137,13 @@ }

* get style object
*/
;
*/;
_proto.toStyle = function toStyle() {
var _this3 = this;
var style = this.atoms.reduce(function (result, atom) {
if (!atom.isValid) return result; // not style type
var colors = store.theme.colors;
var style = Object.entries(atom.style).reduce(function (c, _ref5) {
var _extends4;
var key = _ref5[0],
value = _ref5[1];
value = _ref5[1];
var cssValue = _this3.formatCssValue(utils.jsKeyToCssKey(key), colors[value] || value);
return _extends({}, c, (_extends4 = {}, _extends4[key] = cssValue, _extends4));

@@ -1356,5 +1158,3 @@ }, {});

* @returns
*/
;
*/;
_proto.toRules = function toRules(enableInserted) {

@@ -1364,9 +1164,7 @@ if (enableInserted === void 0) {

}
var _this$config$mode$cla = this.config.mode.classPrefix,
classPrefix = _this$config$mode$cla === void 0 ? '' : _this$config$mode$cla;
classPrefix = _this$config$mode$cla === void 0 ? '' : _this$config$mode$cla;
var rules = [];
var breakpoints = this.config.theme.breakpoints;
var breakpointKeys = Object.keys(breakpoints);
for (var _iterator8 = _createForOfIteratorHelperLoose(this.atoms), _step8; !(_step8 = _iterator8()).done;) {

@@ -1376,23 +1174,21 @@ var atom = _step8.value;

var id = atom.id,
isValid = atom.isValid,
_atom$style = atom.style,
style = _atom$style === void 0 ? {} : _atom$style,
meta = atom.meta; // no style in falsy prop
if (!isValid) continue; // empty style
isValid = atom.isValid,
_atom$style = atom.style,
style = _atom$style === void 0 ? {} : _atom$style,
meta = atom.meta;
// no style in falsy prop
if (!isValid) continue;
// empty style
if (utils.isEmptyObj(style)) continue;
var pseudo = meta.pseudo,
pseudoPrefix = meta.pseudoPrefix,
mode = meta.mode,
_meta$breakpoint = meta.breakpoint,
breakpoint = _meta$breakpoint === void 0 ? '' : _meta$breakpoint,
childSelector = meta.childSelector,
siblingSelector = meta.siblingSelector,
parentClass = meta.parentClass;
pseudoPrefix = meta.pseudoPrefix,
mode = meta.mode,
_meta$breakpoint = meta.breakpoint,
breakpoint = _meta$breakpoint === void 0 ? '' : _meta$breakpoint,
childSelector = meta.childSelector,
siblingSelector = meta.siblingSelector,
parentClass = meta.parentClass;
if (!enableInserted) {
if (atom.inserted) continue;
}
atom.inserted = true;

@@ -1403,10 +1199,7 @@ var className = this.getClassNameById(id);

if (childSelector) selector = selector + " " + childSelector;
if (siblingSelector) {
selector = "" + selector + siblingSelector;
}
if (pseudo) {
var pseudoSelector = pseudoPrefix + pseudo;
if (parentClass) {

@@ -1417,5 +1210,4 @@ selector = "." + parentClass + pseudoSelector + " " + selector;

}
} // TODO: need refactor
}
// TODO: need refactor
if (breakpoint) {

@@ -1427,24 +1219,19 @@ var keys = breakpointKeys.slice(0, breakpointKeys.indexOf(breakpoint) + 1);

}
rule = selector + " { " + this.styleToString(style, atom.meta) + " }";
if (breakpoint) rule = this.makeResponsiveStyle(breakpoint, rule);
rules.push(rule);
} // console.log('this.atoms---', this.atoms)
}
// console.log('this.atoms---', this.atoms)
return rules;
};
_proto.getParsedProps = function getParsedProps() {
var _this4 = this;
var props = this.props,
atoms = this.atoms;
atoms = this.atoms;
if (utils.isEmptyObj(props)) return {};
var entries = Object.entries(props);
/** ignore atomic prop */
var parsedProps = entries.reduce(function (result, _ref6) {
var key = _ref6[0],
value = _ref6[1];
value = _ref6[1];
// ignore prop with postfix

@@ -1460,3 +1247,2 @@ if (/.*--(\d+)?[a-z]+$/i.test(key)) return result;

};
_proto.insertRules = function insertRules() {

@@ -1466,3 +1252,2 @@ var rules = this.toRules();

};
_createClass(Parser, [{

@@ -1496,3 +1281,2 @@ key: "uniqueClassName",

}]);
return Parser;

@@ -1519,10 +1303,7 @@ }();

*/
function css() {
var _store$config, _store$config$objectP;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (!args.length) return '';

@@ -1545,8 +1326,6 @@ var parser = new Parser(utils.argsToProps(args, (_store$config = store.config) == null ? void 0 : (_store$config$objectP = _store$config.objectPropKeys) == null ? void 0 : _store$config$objectP[0]));

}
var props = args.reduce(function (result, cur) {
var _extends2;
if (typeof cur === 'string') return _extends({}, result, (_extends2 = {}, _extends2[cur] = true, _extends2)); // not string, is object
if (typeof cur === 'string') return _extends({}, result, (_extends2 = {}, _extends2[cur] = true, _extends2));
// not string, is object
return _extends({}, result, {

@@ -1566,10 +1345,9 @@ css: cur

*/
function keyframes(input, name) {
var content = Object.entries(input).reduce(function (result, _ref) {
var key = _ref[0],
value = _ref[1];
value = _ref[1];
var str = Object.entries(value).reduce(function (r, _ref2) {
var k = _ref2[0],
v = _ref2[1];
v = _ref2[1];
return r + (utils.jsKeyToCssKey(k) + ": " + v + ";");

@@ -1602,11 +1380,9 @@ }, '');

*/
function injectGlobalStyle(cssObj) {
var entries = Object.entries(cssObj);
var parser = new Parser({});
for (var _i = 0, _entries = entries; _i < _entries.length; _i++) {
var _entries$_i = _entries[_i],
key = _entries$_i[0],
value = _entries$_i[1];
key = _entries$_i[0],
value = _entries$_i[1];
var atom = new Atom({

@@ -1623,3 +1399,2 @@ propKey: key,

}
parser.insertRules();

@@ -1637,9 +1412,9 @@ }

var setConfig = store.setConfig,
getConfig = store.getConfig,
setTheme = store.setTheme,
getTheme = store.getTheme,
setMode = store.setMode,
getMode = store.getMode,
addAtom = store.addAtom,
composeAtom = store.composeAtom;
getConfig = store.getConfig,
setTheme = store.setTheme,
getTheme = store.getTheme,
setMode = store.setMode,
getMode = store.getMode,
addAtom = store.addAtom,
composeAtom = store.composeAtom;

@@ -1646,0 +1421,0 @@ exports.Atom = Atom;

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("deepmerge")),r=require("@fower/utils"),i=e(require("string-hash")),o=require("@fower/color-helper"),n=require("@fower/css-object-processor");function s(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function a(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(){return(l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}function u(e,t){if(null==e)return{};var r,i,o={},n=Object.keys(e);for(i=0;i<n.length;i++)t.indexOf(r=n[i])>=0||(o[r]=e[r]);return o}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function d(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return c(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}require("@fower/atomic-props");var p=function(){function e(){var e=this;this.config={unit:"px",objectPropKeys:["css"],inline:!1,important:!1,mode:{currentMode:"light",autoDarkMode:{enabled:!1,mappings:{white:"black",black:"white",50:"900",100:"800",200:"700",300:"600",400:"500",500:"400",600:"300",700:"200",800:"100",900:"50"}},modeList:["light","dark"],classPrefix:""},prefix:"",pseudos:["active","checked","disabled","enabled","default","empty","focus","focus-within","invalid","hover","link","visited","first-child","last-child","after","before","placeholder","selection"],theme:{breakpoints:{},colors:{},spacings:{}},plugins:[]},this.atomCache=new Map,this.getAtomIds=function(){return Array.from(e.atomCache.keys())},this.compositions=new Map,this.getConfig=function(){return e.config},this.setConfig=function(r,i){void 0===i&&(i="deepmerge"),"replace"===i?e.config=r:"merge"===i?e.config=l({},e.config,r):(e.config=t(e.config,r),r.objectPropKeys&&(e.config.objectPropKeys=r.objectPropKeys))},this.getTheme=function(){return e.config.theme},this.setTheme=function(r){e.config.theme=t(e.config.theme||{},r)},this.getMode=function(){var t;return(null==(t=e.config.mode)?void 0:t.currentMode)||""},this.setMode=function(t){if(r.isBrowser){var i=e.config.mode.currentMode;i&&document.documentElement.classList.remove(i),t&&document.documentElement.classList.add(t),localStorage.setItem("fower-mode",t),e.setConfig({mode:{currentMode:t}})}},this.use=function(){var t;(t=e.config.plugins).push.apply(t,arguments)},this.addAtom=function(t,r){var i={isMatch:function(e){return"string"==typeof t?e===t:t instanceof RegExp&&t.test(e)},handleAtom:"function"==typeof r?r:function(e){return e.style=r,e}};return e.use(i),i},this.composeAtom=function(t,r){e.compositions.set(t,r)}}return a(e,[{key:"theme",get:function(){return this.config.theme}}]),e}(),f=new p,h=["pseudoPrefix","childSelector","important"],m=["colorPostfix"],y=["excludedProps"],g=/^(m[xytrbl]?-?|p[xytrbl]?|space[xy]?|top-?|right-?|bottom-?|left-?|[wh]|square|circle|min[hw]|max[hw]|opacity|delay|duration|translate[xyz]|scale[xy]?|rotate[xy]?|skew[xy]?|text|zIndex-?|leading|stroke|fontWeight|outlineOffset|order|flex(Grow|Shrink|Basis)?|(row|column)?Gap|gridTemplateColumns|border(Top|Right|Bottom|Left)?|rounded(Top(Left|Right)?|Right|Bottom(Left|Right)?|Left)?)(-?\d+[a-z]*?|-auto)$/i,v=function(){function e(e,t){var r=this;void 0===t&&(t=!0),this.options=e,this.autoSetId=t,this.propKeys=[],this.value="",this.id="",this.type="",this.setId=function(){var e,t=r.meta,o=r.key,n=r.value,s=t.important,a=u(t,h),l=Object.values(a).sort();return s&&l.push("i"),t.global?(e=i(JSON.stringify(n)).toString(),r.id=e,e):(e="boolean"==typeof n&&!0===n?o:Array.isArray(n)?o+"-"+n.join("-"):o+"-"+String(n),l.length&&(e=e+"--"+l.join("--")),e=e.replace(/[#()"']/g,"").replace(".","_").replace(/\%/g,"p").replace(/\s+/g,"-"),r.isFalsyPropValue&&(e+="--false"),t.childSelector&&(e=t.childSelector+"-"+e),e=/^[a-zA-Z0-9-_]+$/.test(e)?e:"css-"+i(e),r.id=e,e)},this.propKey=e.propKey,this.propValue=e.propValue,this.propKeys=[this.propKey],this.key=e.key||this.propKey,this.value=e.value||this.propValue,this.style=e.style||{},this.handled=this.getInitialHandled(),this.isValid=this.getIsValid(),this.inserted=!1,this.meta=l({},e.meta)||{},this.preprocessAtom()}var t=e.prototype;return t.preprocessAtom=function(){var e=this.postfixPreprocessor();return this.autoSetId&&this.setId(),e},t.postfixPreprocessor=function(){var e=f.config,t=e.pseudos,r=void 0===t?[]:t,i=e.mode.modeList,o=this.propKey,n=this.propValue,s=Object.keys(e.theme.breakpoints),a=i||[],l=r,u="--("+s.join("|")+")",c="--("+a.join("|")+")",d="--("+l.join("|")+")",p=new RegExp(c),h=new RegExp(d),m=new RegExp(u),y=/--[told](\d{1,2}|100)($|--)/i;if(y.test(n)){var g=n.split("--"),v=g[1];this.value=g[0],this.meta.colorPostfix=v}var b=p.test(o),k=h.test(o),j=m.test(o),x=/--i/i.test(o),A=y.test(o),S=/--\$\w+/i.test(o);if(!(b||k||j||x||A))return this.digitPreprocessor();var w,P=o.split("--");if(this.key=P[0],b&&(this.meta.mode=P.find((function(e){return a.includes(e)}))),k){var O=P.find((function(e){return l.includes(e)}));this.meta.pseudoPrefix=["after","before","placeholder","selection"].includes(O)?"::":":",this.meta.pseudo=O}if(j){var C=P.find((function(e){return s.includes(e)}));this.meta.breakpoint=C}return x&&(this.meta.important=!!P.find((function(e){return"i"===e}))),A&&(this.meta.colorPostfix=P.find((function(e){return y.test("--"+e)}))),S&&(this.meta.parentClass=null==(w=P.find((function(e){return e.startsWith("$")})))?void 0:w.replace(/^\$/,"")),this.digitPreprocessor(),this},t.digitPreprocessor=function(){if(!g.test(this.key))return this;var e=f.config.theme.spacings,t=/^([a-z]+)(\d+)$/i.test(this.key),r=this.key.toString(),i=r.match(/^([a-z]+)(\d+)$/i)||r.match(/^([a-z]*)-(-?\d+[a-z]*?)$/i)||r.match(/^([a-z]+)-(auto)$/i);if(!i)return this;var o=i[2];return this.key=i[1],this.value=t?e[""+o.toLowerCase()]:o,this},t.getInitialHandled=function(){return this.options.handled?this.options.handled:!!this.isFalsyPropValue||!!y.includes(this.propKey)},t.getIsValid=function(){return!this.isFalsyPropValue&&!y.includes(this.propKey)},a(e,[{key:"isValueProp",get:function(){return"string"==typeof this.propValue||"number"==typeof this.propValue}},{key:"styleKeys",get:function(){return Object.keys(this.style||{}).join("-")}},{key:"styleKeysHash",get:function(){var e=u(this.meta,m);return Object.keys(this.style||{}).join("-")+JSON.stringify(e)}},{key:"isFalsyPropValue",get:function(){return null==this.propValue||"boolean"==typeof this.propValue&&!this.propValue}},{key:"isTruePropValue",get:function(){return"boolean"==typeof this.propValue&&this.propValue}}]),e}(),b=new(function(){function e(){var e;this.$style=null,this.cssString="",this.ssrAtomIds=null,r.isBrowser&&(this.$style=null==(e=globalThis.document)||null==e.querySelector?void 0:e.querySelector("[data-fower]"))}var t=e.prototype;return t.createStyleElement=function(){var e=document.createElement("style");return e.dataset.fower="",document.head.append(e),e},t.getSsrAtomIds=function(){var e,t;return this.$style?this.ssrAtomIds?this.ssrAtomIds:(null==(e=this.$style)||null==(t=e.dataset.fower)?void 0:t.split(","))||[]:[]},t.insertStyleToHtml=function(e){if(r.isBrowser){this.$style||(this.$style=this.createStyleElement());for(var t,i=d(e);!(t=i()).done;){var o=t.value;try{this.$style.sheet.insertRule(o)}catch(e){console.warn(e)}}}},t.insertStyles=function(e){if(void 0===e&&(e=[]),e.length)return r.isBrowser?this.insertStyleToHtml(e):void(this.cssString=this.cssString+" "+e.join(" "))},t.getStyle=function(){return this.cssString},e}()),k=/(-columns|(^|[^e]-)padding|[^t]-spacing|l-align|rows|(^|(^border|[dkmnptx]|le|ne)-)width|^border|tom|[ek]-start|(o|[^e]-du)ration|us|(^|[^tv]-)left|(^|-)top|tance|rgin|e-offset|(er|g|n|t)-block|(^|[^tv]-)right|basis|[gnt]-inline|gap|(^|[^e]-)height|ness|(^|[^p]-)inset|[ek]-end|elay|tline|ve|dent|-rotate|n-rule|(c|ck|d|ne|t)-size)$/,j=["color","backgroundColor","borderColor"],x=["children","onClick","onChange","onBlur","id","className","style","title","tabIndex","placeholder","href","src","contentEditable","defaultChecked","defaultValue"],A=function(){function e(e){var t,r;void 0===e&&(e={}),this.props=e,this.atoms=[],this.data={},this.getClassNameById=function(e){return f.config.prefix+e},this.traverseProps(e),null!=(t=f.config.mode)&&null!=(r=t.autoDarkMode)&&r.enabled&&this.autoDarkMode()}var t=e.prototype;return t.traverseProps=function(e){if(!r.isEmptyObj(e)){for(var t,i=this.config,o=i.pseudos,n=void 0===o?[]:o,s=i.mode.modeList,a=i.theme.breakpoints||{},u=Object.keys(a),c=s||[],p=n,h=e.excludedProps,m=void 0===h?[]:h,y=Object.entries(e),g=d(this.plugins);!(t=g()).done;){var b=t.value;b.init&&b.init(e)}if(null!=e&&e.className)for(var k,j=d(e.className.split(/\s+/));!(k=j()).done;)y.push([k.value,!0]);for(var A=0,S=y;A<S.length;A++){var w,P=S[A],O=P[0],C=P[1];if(!m.includes(O)&&!x.includes(O)&&this.isValidProp(O,C))if(null!=(w=this.config.objectPropKeys)&&w.includes(O))this.parseObjectProp(C,{});else{if(O.startsWith("_")){var K=O.replace(/^_/,""),V=Array.isArray(C)?C.reduce((function(e,t){var r;return l({},e,((r={})[t]=!0,r))}),{}):C;if(c.includes(K)){this.parseObjectProp(V,{mode:K});continue}if(u.includes(K)){this.parseObjectProp(V,{breakpoint:a[K]});continue}if(p.includes(K)){this.parseObjectProp(V,{pseudoPrefix:":",pseudo:K});continue}}if(!Array.isArray(C)||/^bgGradient[XY].*/i.test(O)&&!Array.isArray(C[0])){var I=f.compositions.get(O);if(I){this.parseObjectProp(I,{});var M=new v({propKey:O,propValue:C});M.handled=!0,M.style={},this.addAtom(M)}else{var T=new v({propKey:O,propValue:C},!1);try{this.mutateAtom(T),T.handled&&this.addAtom(T)}catch(e){continue}}}else this.parseResponsiveValue(O,C)}}for(var R,$=d(this.plugins);!(R=$()).done;){var N=R.value;N.afterAtomStyleCreate&&N.afterAtomStyleCreate(this)}}},t.getAutoDarkModeAtom=function(e){var t;if(e.meta.mode)return null;if(!e.style)return null;var i=Object.entries(e.style);if(null==i||!i.length)return null;var o,n={},s=f.config,a=s.mode.autoDarkMode.mappings,u=s.theme.colors,c=i[0],d=c[0],p=c[1];if(!j.includes(d))return null;if(!u[p])return null;var h=(p.match(/^([a-z]+)(\d+)$/i)||[])[2];if(!1===a[p])return null;var m="color"===d,y="backgroundColor"===d,g="borderColor"===d;return u[o=a[p]?a[p]:p.replace(h,a[h])]?(m?n.propKey=o:y?n.propKey="bg"+r.upFirst(o):g&&(n.propKey="border"+r.upFirst(o)),n.propValue=!0):m?(n.propKey="color",n.propValue=o):y?(n.propKey="bg",n.propValue=o):g&&(n.propKey="borderColor",n.propValue=o),n.style=((t={})[d]=o,t),new v(l({},n,{meta:l({},e.meta,{mode:"dark"})}))},t.autoDarkMode=function(){for(var e,t=d(this.atoms);!(e=t()).done;){var r=e.value;if(!this.atoms.find((function(e){return j.includes(e.type)&&"dark"===e.meta.mode}))){var i=this.getAutoDarkModeAtom(r);if(i){var o=f.atomCache.get(i.id);this.addAtom(o||i)}}}},t.formatCssValue=function(e,t){if(!k.test(e))return t;var i;if(r.isPercentNumber(String(t)))return String(t).replace("p","%");if(!r.isNumber(t))return t;if((i=Number(t))<1&&i>0)return 100*i+"%";var o=f.config;return"none"!==o.unit?o.transformUnit?o.transformUnit(i):t+f.config.unit:i},t.styleToString=function(e,t){var i=this,n=t.important,s=t.colorPostfix;return Object.entries(e).reduce((function(e,t){var a=t[1],l=r.jsKeyToCssKey(t[0]),u=n?" !important":"",c=f.theme.colors;try{return e+(l+": ")+(a=s?o.formatColor((null==c?void 0:c[a])||a,s):i.formatCssValue(l,(null==c?void 0:c[a])||a))+u+";"}catch(e){return""}}),"")},t.addAtom=function(e){var t;e.id||e.setId(),f.atomCache.get(e.id)||f.atomCache.set(e.id,e);for(var r=b.getSsrAtomIds(),i=((null==(t=this.config.theme)?void 0:t.colors)||{}).modes,o=0,n=Object.entries(void 0===i?{}:i);o<n.length;o++){var s=n[o],a=s[0],u=s[1];if(e.style){var c=Object.entries(e.style);if(c.length){var d=c[0],p=d[0],h=u[d[1]];if(h){var m="--"+a,y=JSON.parse(JSON.stringify(e));y.key=e.key+m,y.id=e.id+m,y.meta=l({mode:a},e.meta),y.style[p]=h,r.includes(y.id)&&(y.inserted=!0),this.atoms.push(y)}}}}r.includes(e.id)&&(e.inserted=!0),this.atoms.push(e)},t.isValidProp=function(e,t){var r;return!!(null!=(r=this.config.objectPropKeys)&&r.includes(e)||e.startsWith("_")||Array.isArray(t)||["string","boolean","number","undefined","function"].includes(typeof t))},t.mutateAtom=function(e){for(var t,r=d(this.plugins);!(t=r()).done;){var i=t.value;null!=i.isMatch&&i.isMatch(e.key,this)&&(e.id||e.setId(),"function"==typeof e.value&&(e.value=e.value()),i.beforeHandleAtom&&(e=i.beforeHandleAtom(e,this)))}(Object.values(e.meta||{}).length||Object.values(e.style||{}).length)&&(e.id||e.setId());var o=f.atomCache.get(e.id);if(o)throw o.propKeys.push(e.propKey),this.addAtom(o),new Error("atom is cached, add to this.atoms directly, no need to mutate");if(e.handled)throw this.addAtom(e),new Error("atom is handled, add to this.atoms directly ,no need to mutate");for(var n,s=d(this.plugins);!(n=s()).done;){var a=n.value;if(null!=a.isMatch&&a.isMatch(e.key,this)){a.handleAtom&&(e=null==a.handleAtom?void 0:a.handleAtom(e,this)),e.handled=!0;break}}},t.parseResponsiveValue=function(e,t){var r=Object.keys(this.config.theme.breakpoints),i=t.reduce((function(t,i,o){var n;return l({},t,((n={})[e+(0===o?"":"--"+r[o-1])]=i,n))}),{});this.parseObjectProp(i)},t.parseObjectProp=function(e,t){void 0===t&&(t={});for(var r,i=d(n.parse(e));!(r=i()).done;){var o=r.value,s=o.selector,a=o.selectorType,u=o.style,c=Object.entries(u);if(c.length){var p=c[0],h={propKey:p[0],propValue:p[1],meta:l({},t)};if(u&&Object.keys(u).length&&(h.style=u),"pseudo"===a&&h.meta){var m=s.match(/(:+)(.+)/)||[],y=m[2];h.meta.pseudoPrefix=m[1],h.meta.pseudo=y}"child"===a&&h.meta&&(h.meta.childSelector=s),"sibling"===a&&h.meta&&(h.meta.siblingSelector=s);var g=new v(h,!1);try{this.mutateAtom(g)}catch(e){continue}g.style&&Object.keys(g.style).length||(g.handled=!0);var b=f.atomCache.get(g.id);this.addAtom(b||g)}}},t.makeResponsiveStyle=function(e,t){return"@media (min-width: "+this.config.theme.breakpoints[e]+") {"+t+"}"},t.getClassNames=function(){var e=this,t=[];this.atoms.reduce((function(r,i){if(!i.style||!Object.keys(i.style).length)return r;var o=r.findIndex((function(e){return e.styleKeysHash===i.styleKeysHash}));if(!i.isValid)return r;var n=e.getClassNameById(i.id);return-1===o?(t.push(n),r=[].concat(r,[i])):(r.splice(o,1,i),t.splice(o,1,n)),r}),[]);var r,i=this.props.className,o=(void 0===i?"":i).split(/\s+/).filter((function(e){return!t.includes(e)&&!!e}));return t=t.concat(o),this.hasResponsive&&(r=t).push.apply(r,Object.keys(this.config.theme.breakpoints).map((function(e){return"r-"+e}))),t},t.toStyle=function(){var e=this;return this.atoms.reduce((function(t,i){if(!i.isValid)return t;var o=f.theme.colors,n=Object.entries(i.style).reduce((function(t,i){var n,s=i[0],a=i[1],u=e.formatCssValue(r.jsKeyToCssKey(s),o[a]||a);return l({},t,((n={})[s]=u,n))}),{});return l({},t,n)}),{})},t.toRules=function(e){void 0===e&&(e=!1);for(var t,i=this.config.mode.classPrefix,o=void 0===i?"":i,n=[],s=Object.keys(this.config.theme.breakpoints),a=d(this.atoms);!(t=a()).done;){var l=t.value,u="",c=l.id,p=l.style,f=void 0===p?{}:p,h=l.meta;if(l.isValid&&!r.isEmptyObj(f)){var m=h.pseudo,y=h.pseudoPrefix,g=h.mode,v=h.breakpoint,b=void 0===v?"":v,k=h.childSelector,j=h.siblingSelector,x=h.parentClass;if(e||!l.inserted){l.inserted=!0;var A=this.getClassNameById(c),S=h.global?h.global:"."+A;if(g&&(S="."+o+g+" "+S),k&&(S=S+" "+k),j&&(S=""+S+j),m){var w=y+m;x?S="."+x+w+" "+S:S+=w}b&&(S=S+"."+s.slice(0,s.indexOf(b)+1).map((function(e){return"r-"+e})).join(".")),u=S+" { "+this.styleToString(f,l.meta)+" }",b&&(u=this.makeResponsiveStyle(b,u)),n.push(u)}}}return n},t.getParsedProps=function(){var e=this,t=this.props,i=this.atoms;return r.isEmptyObj(t)?{}:Object.entries(t).reduce((function(t,r){var o=r[0],n=r[1];return/.*--(\d+)?[a-z]+$/i.test(o)||i.find((function(t){return[t.propKey,t.key,t.id].concat(e.config.objectPropKeys||[]).includes(o)||t.propKeys.includes(o)}))||(t[o]=n),t}),{})},t.insertRules=function(){var e=this.toRules();b.insertStyles(e)},a(e,[{key:"uniqueClassName",get:function(){return r.objectToClassName(Object.keys(this.props))}},{key:"hasResponsive",get:function(){return this.atoms.some((function(e){return!!e.meta.breakpoint}))}},{key:"store",get:function(){return f}},{key:"config",get:function(){return f.config}},{key:"plugins",get:function(){return f.config.plugins}}]),e}();function S(e){for(var t=Object.entries(e),r=new A({}),i=0,o=t;i<o.length;i++){var n=o[i],s=n[0],a=n[1],l=new v({propKey:s,propValue:a,value:a,meta:{global:s},style:a});r.addAtom(l)}r.insertRules()}S({"*, ::before, ::after":{borderWidth:0,borderStyle:"solid",borderColor:"#d4d4d4",boxSizing:"border-box"}});var w=f.setConfig,P=f.getConfig,O=f.setTheme,C=f.getTheme,K=f.setMode,V=f.getMode,I=f.addAtom,M=f.composeAtom;exports.Atom=v,exports.Parser=A,exports.Store=p,exports.addAtom=I,exports.composeAtom=M,exports.createStyle=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var i=t.reduce((function(e,t){var r;return l({},e,"string"==typeof t?((r={})[t]=!0,r):{css:t})}),{}),o=new A(i),n=o.toStyle();return n},exports.css=function(){for(var e,t,i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];if(!o.length)return"";var s=new A(r.argsToProps(o,null==(e=f.config)||null==(t=e.objectPropKeys)?void 0:t[0]));return s.insertRules(),s.getClassNames().join(" ")},exports.digitReg=g,exports.getConfig=P,exports.getMode=V,exports.getTheme=C,exports.injectGlobalStyle=S,exports.isAtomicArgsValid=function(e){var t=r.argsToProps([e]),i=new A(t).getParsedProps();return!Object.keys(i).length},exports.keyframes=function(e,t){var i=Object.entries(e).reduce((function(e,t){var i=t[0],o=Object.entries(t[1]).reduce((function(e,t){var i=t[1];return e+(r.jsKeyToCssKey(t[0])+": ")+i+";"}),"");return e+(r.jsKeyToCssKey(i)+" {")+o+"}"}),""),o=t||"keyframes-"+r.hash(JSON.stringify(e));return b.insertStyles(["\n @keyframes "+o+" {\n "+i+"\n }\n "]),o},exports.setConfig=w,exports.setMode=K,exports.setTheme=O,exports.store=f,exports.styleSheet=b;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("deepmerge")),r=require("@fower/utils"),i=e(require("string-hash")),o=require("@fower/color-helper"),n=require("@fower/css-object-processor");function s(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function a(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(){return(l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}function u(e,t){if(null==e)return{};var r,i,o={},n=Object.keys(e);for(i=0;i<n.length;i++)t.indexOf(r=n[i])>=0||(o[r]=e[r]);return o}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function d(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return c(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}require("@fower/atomic-props");var p=function(){function e(){var e=this;this.config={unit:"px",objectPropKeys:["css"],inline:!1,important:!1,mode:{currentMode:"light",autoDarkMode:{enabled:!1,mappings:{white:"black",black:"white",50:"900",100:"800",200:"700",300:"600",400:"500",500:"400",600:"300",700:"200",800:"100",900:"50"}},modeList:["light","dark"],classPrefix:""},prefix:"",pseudos:["active","checked","disabled","enabled","default","empty","focus","focus-within","invalid","hover","link","visited","first-child","last-child","after","before","placeholder","selection"],theme:{breakpoints:{},colors:{},spacings:{}},plugins:[]},this.atomCache=new Map,this.getAtomIds=function(){return Array.from(e.atomCache.keys())},this.compositions=new Map,this.getConfig=function(){return e.config},this.setConfig=function(r,i){void 0===i&&(i="deepmerge"),"replace"===i?e.config=r:"merge"===i?e.config=l({},e.config,r):(e.config=t(e.config,r),r.objectPropKeys&&(e.config.objectPropKeys=r.objectPropKeys))},this.getTheme=function(){return e.config.theme},this.setTheme=function(r){e.config.theme=t(e.config.theme||{},r)},this.getMode=function(){var t;return(null==(t=e.config.mode)?void 0:t.currentMode)||""},this.setMode=function(t){if(r.isBrowser){var i=e.config.mode.currentMode;i&&document.documentElement.classList.remove(i),t&&document.documentElement.classList.add(t),localStorage.setItem("fower-mode",t),e.setConfig({mode:{currentMode:t}})}},this.use=function(){var t;(t=e.config.plugins).push.apply(t,arguments)},this.addAtom=function(t,r){var i={isMatch:function(e){return"string"==typeof t?e===t:t instanceof RegExp&&t.test(e)},handleAtom:"function"==typeof r?r:function(e){return e.style=r,e}};return e.use(i),i},this.composeAtom=function(t,r){e.compositions.set(t,r)}}return a(e,[{key:"theme",get:function(){return this.config.theme}}]),e}(),f=new p,h=["pseudoPrefix","childSelector","important"],m=["colorPostfix"],y=["excludedProps"],g=/^(m[xytrbl]?-?|p[xytrbl]?|space[xy]?|top-?|right-?|bottom-?|left-?|[wh]|square|circle|min[hw]|max[hw]|opacity|delay|duration|translate[xyz]|scale[xy]?|rotate[xy]?|skew[xy]?|text|zIndex-?|leading|stroke|fontWeight|outlineOffset|order|flex(Grow|Shrink|Basis)?|(row|column)?Gap|gridTemplateColumns|border(Top|Right|Bottom|Left)?|rounded(Top(Left|Right)?|Right|Bottom(Left|Right)?|Left)?)(-?\d+[a-z]*?|-auto)$/i,v=function(){function e(e,t){var r=this;void 0===t&&(t=!0),this.options=e,this.autoSetId=t,this.propKeys=[],this.value="",this.id="",this.type="",this.setId=function(){var e,t=r.meta,o=r.key,n=r.value,s=t.important,a=u(t,h),l=Object.values(a).sort();return s&&l.push("i"),t.global?(e=i(JSON.stringify(n)).toString(),r.id=e,e):(e="boolean"==typeof n&&!0===n?o:Array.isArray(n)?o+"-"+n.join("-"):o+"-"+String(n),l.length&&(e=e+"--"+l.join("--")),e=e.replace(/[#()"']/g,"").replace(".","_").replace(/\%/g,"p").replace(/\s+/g,"-"),r.isFalsyPropValue&&(e+="--false"),t.childSelector&&(e=t.childSelector+"-"+e),e=/^[a-zA-Z0-9-_]+$/.test(e)?e:"css-"+i(e),r.id=e,e)},this.propKey=e.propKey,this.propValue=e.propValue,this.propKeys=[this.propKey],this.key=e.key||this.propKey,this.value=e.value||this.propValue,this.style=e.style||{},this.handled=this.getInitialHandled(),this.isValid=this.getIsValid(),this.inserted=!1,this.meta=l({},e.meta)||{},this.preprocessAtom()}var t=e.prototype;return t.preprocessAtom=function(){var e=this.postfixPreprocessor();return this.autoSetId&&this.setId(),e},t.postfixPreprocessor=function(){var e=f.config,t=e.pseudos,r=void 0===t?[]:t,i=e.mode.modeList,o=this.propKey,n=this.propValue,s=Object.keys(e.theme.breakpoints),a=i||[],l=r,u="--("+s.join("|")+")",c="--("+a.join("|")+")",d="--("+l.join("|")+")",p=new RegExp(c),h=new RegExp(d),m=new RegExp(u),y=/--[told](\d{1,2}|100)($|--)/i;if(y.test(n)){var g=n.split("--"),v=g[1];this.value=g[0],this.meta.colorPostfix=v}var b=p.test(o),k=h.test(o),j=m.test(o),x=/--i/i.test(o),A=y.test(o),S=/--\$\w+/i.test(o);if(!(b||k||j||x||A))return this.digitPreprocessor();var w,P=o.split("--");if(this.key=P[0],b&&(this.meta.mode=P.find((function(e){return a.includes(e)}))),k){var O=P.find((function(e){return l.includes(e)}));this.meta.pseudoPrefix=["after","before","placeholder","selection"].includes(O)?"::":":",this.meta.pseudo=O}if(j){var C=P.find((function(e){return s.includes(e)}));this.meta.breakpoint=C}return x&&(this.meta.important=!!P.find((function(e){return"i"===e}))),A&&(this.meta.colorPostfix=P.find((function(e){return y.test("--"+e)}))),S&&(this.meta.parentClass=null==(w=P.find((function(e){return e.startsWith("$")})))?void 0:w.replace(/^\$/,"")),this.digitPreprocessor(),this},t.digitPreprocessor=function(){if(!g.test(this.key))return this;var e=f.config.theme.spacings,t=/^([a-z]+)(\d+)$/i.test(this.key),r=this.key.toString(),i=r.match(/^([a-z]+)(\d+)$/i)||r.match(/^([a-z]*)-(-?\d+[a-z]*?)$/i)||r.match(/^([a-z]+)-(auto)$/i);if(!i)return this;var o=i[2];return this.key=i[1],this.value=t?e[""+o.toLowerCase()]:o,this},t.getInitialHandled=function(){return this.options.handled?this.options.handled:!!this.isFalsyPropValue||!!y.includes(this.propKey)},t.getIsValid=function(){return!this.isFalsyPropValue&&!y.includes(this.propKey)},a(e,[{key:"isValueProp",get:function(){return"string"==typeof this.propValue||"number"==typeof this.propValue}},{key:"styleKeys",get:function(){return Object.keys(this.style||{}).join("-")}},{key:"styleKeysHash",get:function(){var e=u(this.meta,m);return Object.keys(this.style||{}).join("-")+JSON.stringify(e)}},{key:"isFalsyPropValue",get:function(){return null==this.propValue||"boolean"==typeof this.propValue&&!this.propValue}},{key:"isTruePropValue",get:function(){return"boolean"==typeof this.propValue&&this.propValue}}]),e}(),b=new(function(){function e(){var e;this.$style=null,this.cssString="",this.ssrAtomIds=null,r.isBrowser&&(this.$style=null==(e=globalThis.document)||null==e.querySelector?void 0:e.querySelector("[data-fower]"))}var t=e.prototype;return t.createStyleElement=function(){var e=document.createElement("style");return e.dataset.fower="",document.head.append(e),e},t.getSsrAtomIds=function(){var e,t;return this.$style?this.ssrAtomIds?this.ssrAtomIds:(null==(e=this.$style)||null==(t=e.dataset.fower)?void 0:t.split(","))||[]:[]},t.insertStyleToHtml=function(e){if(r.isBrowser){this.$style||(this.$style=this.createStyleElement());for(var t,i=d(e);!(t=i()).done;){var o=t.value;try{this.$style.sheet.insertRule(o)}catch(e){console.warn(e)}}}},t.insertStyles=function(e){if(void 0===e&&(e=[]),e.length)return r.isBrowser?this.insertStyleToHtml(e):void(this.cssString=this.cssString+" "+e.join(" "))},t.getStyle=function(){return this.cssString},e}()),k=/(-columns|(^|[^e]-)padding|[^t]-spacing|l-align|rows|(^|(^border|[dkmnptx]|le|ne)-)width|^border|tom|[ek]-start|(o|[^e]-du)ration|us|(^|[^tv]-)left|(^|-)top|tance|rgin|e-offset|(er|g|n|t)-block|(^|[^tv]-)right|basis|[gnt]-inline|gap|(^|[^e]-)height|ness|(^|[^p]-)inset|[ek]-end|elay|tline|ve|dent|-rotate|n-rule|(c|ck|d|ne|t)-size)$/,j=["color","backgroundColor","borderColor"],x=["children","onClick","onChange","onBlur","id","className","style","title","tabIndex","placeholder","href","src","contentEditable","defaultChecked","defaultValue"],A=function(){function e(e){var t,r;void 0===e&&(e={}),this.props=e,this.atoms=[],this.data={},this.getClassNameById=function(e){return f.config.prefix+e},this.traverseProps(e),null!=(t=f.config.mode)&&null!=(r=t.autoDarkMode)&&r.enabled&&this.autoDarkMode()}var t=e.prototype;return t.traverseProps=function(e){if(!r.isEmptyObj(e)){for(var t,i=this.config,o=i.pseudos,n=void 0===o?[]:o,s=i.mode.modeList,a=i.theme.breakpoints||{},u=Object.keys(a),c=s||[],p=n,h=e.excludedProps,m=void 0===h?[]:h,y=Object.entries(e),g=d(this.plugins);!(t=g()).done;){var b=t.value;b.init&&b.init(e)}if(null!=e&&e.className)for(var k,j=d(e.className.split(/\s+/));!(k=j()).done;)y.push([k.value,!0]);for(var A=0,S=y;A<S.length;A++){var w,P=S[A],O=P[0],C=P[1];if(!m.includes(O)&&!x.includes(O)&&this.isValidProp(O,C))if(null!=(w=this.config.objectPropKeys)&&w.includes(O))this.parseObjectProp(C,{});else{if(O.startsWith("_")){var K=O.replace(/^_/,""),V=Array.isArray(C)?C.reduce((function(e,t){var r;return l({},e,((r={})[t]=!0,r))}),{}):C;if(c.includes(K)){this.parseObjectProp(V,{mode:K});continue}if(u.includes(K)){this.parseObjectProp(V,{breakpoint:a[K]});continue}if(p.includes(K)){this.parseObjectProp(V,{pseudoPrefix:":",pseudo:K});continue}}if(!Array.isArray(C)||/^bgGradient[XY].*/i.test(O)&&!Array.isArray(C[0])){var I=f.compositions.get(O);if(I){this.parseObjectProp(I,{});var M=new v({propKey:O,propValue:C});M.handled=!0,M.style={},this.addAtom(M)}else{var T=new v({propKey:O,propValue:C},!1);try{this.mutateAtom(T),T.handled&&this.addAtom(T)}catch(e){continue}}}else this.parseResponsiveValue(O,C)}}for(var R,$=d(this.plugins);!(R=$()).done;){var N=R.value;N.afterAtomStyleCreate&&N.afterAtomStyleCreate(this)}}},t.getAutoDarkModeAtom=function(e){var t;if(e.meta.mode)return null;if(!e.style)return null;var i=Object.entries(e.style);if(null==i||!i.length)return null;var o,n={},s=f.config,a=s.mode.autoDarkMode.mappings,u=s.theme.colors,c=i[0],d=c[0],p=c[1];if(!j.includes(d))return null;if(!u[p])return null;var h=(p.match(/^([a-z]+)(\d+)$/i)||[])[2];if(!1===a[p])return null;var m="color"===d,y="backgroundColor"===d,g="borderColor"===d;return u[o=a[p]?a[p]:p.replace(h,a[h])]?(m?n.propKey=o:y?n.propKey="bg"+r.upFirst(o):g&&(n.propKey="border"+r.upFirst(o)),n.propValue=!0):m?(n.propKey="color",n.propValue=o):y?(n.propKey="bg",n.propValue=o):g&&(n.propKey="borderColor",n.propValue=o),n.style=((t={})[d]=o,t),new v(l({},n,{meta:l({},e.meta,{mode:"dark"})}))},t.autoDarkMode=function(){for(var e,t=d(this.atoms);!(e=t()).done;){var r=e.value;if(!this.atoms.find((function(e){return j.includes(e.type)&&"dark"===e.meta.mode}))){var i=this.getAutoDarkModeAtom(r);if(i){var o=f.atomCache.get(i.id);this.addAtom(o||i)}}}},t.formatCssValue=function(e,t){if(!k.test(e))return t;var i;if(r.isPercentNumber(String(t)))return String(t).replace("p","%");if(!r.isNumber(t))return t;if((i=Number(t))<1&&i>0)return 100*i+"%";var o=f.config;return"none"!==o.unit?o.transformUnit?o.transformUnit(i):t+f.config.unit:i},t.styleToString=function(e,t){var i=this,n=t.important,s=t.colorPostfix;return Object.entries(e).reduce((function(e,t){var a=t[1],l=r.jsKeyToCssKey(t[0]),u=n?" !important":"",c=f.theme.colors;try{return e+(l+": ")+(a=s?o.formatColor((null==c?void 0:c[a])||a,s):i.formatCssValue(l,(null==c?void 0:c[a])||a))+u+";"}catch(e){return""}}),"")},t.addAtom=function(e){var t;e.id||e.setId(),f.atomCache.get(e.id)||f.atomCache.set(e.id,e);for(var r=b.getSsrAtomIds(),i=((null==(t=this.config.theme)?void 0:t.colors)||{}).modes,o=0,n=Object.entries(void 0===i?{}:i);o<n.length;o++){var s=n[o],a=s[0],u=s[1];if(e.style){var c=Object.entries(e.style);if(c.length){var d=c[0],p=d[0],h=u[d[1]];if(h){var m="--"+a,y=JSON.parse(JSON.stringify(e));y.key=e.key+m,y.id=e.id+m,y.meta=l({mode:a},e.meta),y.style[p]=h,r.includes(y.id)&&(y.inserted=!0),this.atoms.push(y)}}}}r.includes(e.id)&&(e.inserted=!0),this.atoms.push(e)},t.isValidProp=function(e,t){var r;return!!(null!=(r=this.config.objectPropKeys)&&r.includes(e)||e.startsWith("_")||Array.isArray(t)||["string","boolean","number","undefined","function"].includes(typeof t))},t.mutateAtom=function(e){for(var t,r=d(this.plugins);!(t=r()).done;){var i=t.value;null!=i.isMatch&&i.isMatch(e.key,this)&&(e.id||e.setId(),"function"==typeof e.value&&(e.value=e.value()),i.beforeHandleAtom&&(e=i.beforeHandleAtom(e,this)))}(Object.values(e.meta||{}).length||Object.values(e.style||{}).length)&&(e.id||e.setId());var o=f.atomCache.get(e.id);if(o)throw o.propKeys.push(e.propKey),this.addAtom(o),new Error("atom is cached, add to this.atoms directly, no need to mutate");if(e.handled)throw this.addAtom(e),new Error("atom is handled, add to this.atoms directly ,no need to mutate");for(var n,s=d(this.plugins);!(n=s()).done;){var a=n.value;if(null!=a.isMatch&&a.isMatch(e.key,this)){a.handleAtom&&(e=null==a.handleAtom?void 0:a.handleAtom(e,this)),e.handled=!0;break}}},t.parseResponsiveValue=function(e,t){var r=Object.keys(this.config.theme.breakpoints),i=t.reduce((function(t,i,o){var n;return l({},t,((n={})[e+(0===o?"":"--"+r[o-1])]=i,n))}),{});this.parseObjectProp(i)},t.parseObjectProp=function(e,t){void 0===t&&(t={});for(var r,i=d(n.parse(e));!(r=i()).done;){var o=r.value,s=o.selector,a=o.selectorType,u=o.style,c=Object.entries(u);if(c.length){var p=c[0],h={propKey:p[0],propValue:p[1],meta:l({},t)};if(u&&Object.keys(u).length&&(h.style=u),"pseudo"===a&&h.meta){var m=s.match(/(:+)(.+)/)||[],y=m[2];h.meta.pseudoPrefix=m[1],h.meta.pseudo=y}"child"===a&&h.meta&&(h.meta.childSelector=s),"sibling"===a&&h.meta&&(h.meta.siblingSelector=s);var g=new v(h,!1);try{this.mutateAtom(g)}catch(e){continue}g.style&&Object.keys(g.style).length||(g.handled=!0);var b=f.atomCache.get(g.id);this.addAtom(b||g)}}},t.makeResponsiveStyle=function(e,t){return"@media (min-width: "+this.config.theme.breakpoints[e]+") {"+t+"}"},t.getClassNames=function(){var e=this,t=[];this.atoms.reduce((function(r,i){if(!i.style||!Object.keys(i.style).length)return r;var o=r.findIndex((function(e){return e.styleKeysHash===i.styleKeysHash}));if(!i.isValid)return r;var n=e.getClassNameById(i.id);return-1===o?(t.push(n),r=[].concat(r,[i])):(r.splice(o,1,i),t.splice(o,1,n)),r}),[]);var r,i=this.props.className,o=(void 0===i?"":i).split(/\s+/).filter((function(e){return!t.includes(e)&&!!e}));return t=t.concat(o),this.hasResponsive&&(r=t).push.apply(r,Object.keys(this.config.theme.breakpoints).map((function(e){return"r-"+e}))),t},t.toStyle=function(){var e=this;return this.atoms.reduce((function(t,i){if(!i.isValid)return t;var o=f.theme.colors,n=Object.entries(i.style).reduce((function(t,i){var n,s=i[0],a=i[1],u=e.formatCssValue(r.jsKeyToCssKey(s),o[a]||a);return l({},t,((n={})[s]=u,n))}),{});return l({},t,n)}),{})},t.toRules=function(e){void 0===e&&(e=!1);for(var t,i=this.config.mode.classPrefix,o=void 0===i?"":i,n=[],s=Object.keys(this.config.theme.breakpoints),a=d(this.atoms);!(t=a()).done;){var l=t.value,u="",c=l.id,p=l.style,f=void 0===p?{}:p,h=l.meta;if(l.isValid&&!r.isEmptyObj(f)){var m=h.pseudo,y=h.pseudoPrefix,g=h.mode,v=h.breakpoint,b=void 0===v?"":v,k=h.childSelector,j=h.siblingSelector,x=h.parentClass;if(e||!l.inserted){l.inserted=!0;var A=this.getClassNameById(c),S=h.global?h.global:"."+A;if(g&&(S="."+o+g+" "+S),k&&(S=S+" "+k),j&&(S=""+S+j),m){var w=y+m;x?S="."+x+w+" "+S:S+=w}b&&(S=S+"."+s.slice(0,s.indexOf(b)+1).map((function(e){return"r-"+e})).join(".")),u=S+" { "+this.styleToString(f,l.meta)+" }",b&&(u=this.makeResponsiveStyle(b,u)),n.push(u)}}}return n},t.getParsedProps=function(){var e=this,t=this.props,i=this.atoms;return r.isEmptyObj(t)?{}:Object.entries(t).reduce((function(t,r){var o=r[0],n=r[1];return/.*--(\d+)?[a-z]+$/i.test(o)||i.find((function(t){return[t.propKey,t.key,t.id].concat(e.config.objectPropKeys||[]).includes(o)||t.propKeys.includes(o)}))||(t[o]=n),t}),{})},t.insertRules=function(){var e=this.toRules();b.insertStyles(e)},a(e,[{key:"uniqueClassName",get:function(){return r.objectToClassName(Object.keys(this.props))}},{key:"hasResponsive",get:function(){return this.atoms.some((function(e){return!!e.meta.breakpoint}))}},{key:"store",get:function(){return f}},{key:"config",get:function(){return f.config}},{key:"plugins",get:function(){return f.config.plugins}}]),e}();function S(e){for(var t=Object.entries(e),r=new A({}),i=0,o=t;i<o.length;i++){var n=o[i],s=n[0],a=n[1],l=new v({propKey:s,propValue:a,value:a,meta:{global:s},style:a});r.addAtom(l)}r.insertRules()}S({"*, ::before, ::after":{borderWidth:0,borderStyle:"solid",borderColor:"#d4d4d4",boxSizing:"border-box"}});var w=f.setConfig,P=f.getConfig,O=f.setTheme,C=f.getTheme,K=f.setMode,V=f.getMode,I=f.addAtom,M=f.composeAtom;exports.Atom=v,exports.Parser=A,exports.Store=p,exports.addAtom=I,exports.composeAtom=M,exports.createStyle=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var i=t.reduce((function(e,t){var r;return l({},e,"string"==typeof t?((r={})[t]=!0,r):{css:t})}),{}),o=new A(i),n=o.toStyle();return n},exports.css=function(){for(var e,t,i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];if(!o.length)return"";var s=new A(r.argsToProps(o,null==(e=f.config)||null==(t=e.objectPropKeys)?void 0:t[0]));return s.insertRules(),s.getClassNames().join(" ")},exports.digitReg=g,exports.getConfig=P,exports.getMode=V,exports.getTheme=C,exports.injectGlobalStyle=S,exports.isAtomicArgsValid=function(e){var t=r.argsToProps([e]),i=new A(t).getParsedProps();return!Object.keys(i).length},exports.keyframes=function(e,t){var i=Object.entries(e).reduce((function(e,t){var i=t[0],o=Object.entries(t[1]).reduce((function(e,t){var i=t[1];return e+(r.jsKeyToCssKey(t[0])+": ")+i+";"}),"");return e+(r.jsKeyToCssKey(i)+" {")+o+"}"}),""),o=t||"keyframes-"+r.hash(JSON.stringify(e));return b.insertStyles(["\n @keyframes "+o+" {\n "+i+"\n }\n "]),o},exports.setConfig=w,exports.setMode=K,exports.setTheme=O,exports.store=f,exports.styleSheet=b;
//# sourceMappingURL=core.cjs.production.min.js.map

@@ -17,3 +17,2 @@ import deepmerge from 'deepmerge';

}
function _createClass(Constructor, protoProps, staticProps) {

@@ -27,8 +26,6 @@ if (protoProps) _defineProperties(Constructor.prototype, protoProps);

}
function _extends() {
_extends = Object.assign || function (target) {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {

@@ -40,9 +37,6 @@ if (Object.prototype.hasOwnProperty.call(source, key)) {

}
return target;
};
return _extends.apply(this, arguments);
}
function _objectWithoutPropertiesLoose(source, excluded) {

@@ -53,3 +47,2 @@ if (source == null) return {};

var key, i;
for (i = 0; i < sourceKeys.length; i++) {

@@ -60,6 +53,4 @@ key = sourceKeys[i];

}
return target;
}
function _unsupportedIterableToArray(o, minLen) {

@@ -73,15 +64,10 @@ if (!o) return;

}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (it) return (it = it.call(o)).next.bind(it);
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {

@@ -100,3 +86,2 @@ if (it) o = it;

}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");

@@ -109,3 +94,2 @@ }

var _this = this;
this.config = {

@@ -148,15 +132,11 @@ unit: 'px',

this.atomCache = new Map();
this.getAtomIds = function () {
return Array.from(_this.atomCache.keys());
}; // composed atomic props
};
// composed atomic props
this.compositions = new Map();
this.getConfig = function () {
return _this.config;
}; // user config
};
// user config
this.setConfig = function (config, strategy) {

@@ -166,3 +146,2 @@ if (strategy === void 0) {

}
if (strategy === 'replace') {

@@ -173,4 +152,4 @@ _this.config = config;

} else {
_this.config = deepmerge(_this.config, config); // TODO: need improve, 这个是特殊的
_this.config = deepmerge(_this.config, config);
// TODO: need improve, 这个是特殊的
if (config.objectPropKeys) {

@@ -181,31 +160,22 @@ _this.config.objectPropKeys = config.objectPropKeys;

};
this.getTheme = function () {
return _this.config.theme;
};
this.setTheme = function (partialThemeConfig) {
_this.config.theme = deepmerge(_this.config.theme || {}, partialThemeConfig);
};
this.getMode = function () {
var _this$config$mode;
return ((_this$config$mode = _this.config.mode) == null ? void 0 : _this$config$mode.currentMode) || '';
};
this.setMode = function (mode) {
if (!isBrowser) return;
var currentMode = _this.config.mode.currentMode;
if (currentMode) {
document.documentElement.classList.remove(currentMode);
}
if (mode) {
document.documentElement.classList.add(mode);
}
localStorage.setItem(modeCacheKey, mode);
_this.setConfig({

@@ -217,9 +187,6 @@ mode: {

};
this.use = function () {
var _this$config$plugins;
(_this$config$plugins = _this.config.plugins).push.apply(_this$config$plugins, arguments);
};
this.addAtom = function (matcher, handleAtomOrStyleObject) {

@@ -237,8 +204,5 @@ var plugin = {

};
_this.use(plugin);
return plugin;
};
this.composeAtom = function (atomName, cssObject) {

@@ -248,3 +212,2 @@ _this.compositions.set(atomName, cssObject);

}
_createClass(Store, [{

@@ -256,3 +219,2 @@ key: "theme",

}]);
return Store;

@@ -263,3 +225,3 @@ }();

var _excluded = ["pseudoPrefix", "childSelector", "important"],
_excluded2 = ["colorPostfix"];
_excluded2 = ["colorPostfix"];
var invalidProps = ['excludedProps'];

@@ -270,3 +232,2 @@ /**

*/
var digitReg = /^(m[xytrbl]?-?|p[xytrbl]?|space[xy]?|top-?|right-?|bottom-?|left-?|[wh]|square|circle|min[hw]|max[hw]|opacity|delay|duration|translate[xyz]|scale[xy]?|rotate[xy]?|skew[xy]?|text|zIndex-?|leading|stroke|fontWeight|outlineOffset|order|flex(Grow|Shrink|Basis)?|(row|column)?Gap|gridTemplateColumns|border(Top|Right|Bottom|Left)?|rounded(Top(Left|Right)?|Right|Bottom(Left|Right)?|Left)?)(-?\d+[a-z]*?|-auto)$/i;

@@ -281,7 +242,5 @@ var Atom = /*#__PURE__*/function () {

var _this = this;
if (autoSetId === void 0) {
autoSetId = true;
}
this.options = options;

@@ -292,3 +251,2 @@ this.autoSetId = autoSetId;

*/
this.propKeys = [];

@@ -303,3 +261,2 @@ /**

*/
this.value = '';

@@ -309,18 +266,14 @@ /**

*/
this.id = '';
this.type = '';
this.setId = function () {
var meta = _this.meta,
key = _this.key,
value = _this.value;
key = _this.key,
value = _this.value;
var important = meta.important,
rest = _objectWithoutPropertiesLoose(meta, _excluded);
rest = _objectWithoutPropertiesLoose(meta, _excluded);
var values = Object.values(rest).sort();
if (important) values.push('i');
var id; // is global style
var id;
// is global style
if (meta.global) {

@@ -331,3 +284,2 @@ id = hash(JSON.stringify(value)).toString();

}
if (typeof value === 'boolean' && value === true) {

@@ -337,3 +289,4 @@ id = key;

var valueStr = value.join('-');
id = key + "-" + valueStr; // } else if (typeof value === 'function') {
id = key + "-" + valueStr;
// } else if (typeof value === 'function') {
// const valueStr = hash(value.toString())

@@ -344,12 +297,9 @@ // id = `${key}-${valueStr}`

}
if (values.length) id = id + '--' + values.join('--'); // handle special character
if (values.length) id = id + '--' + values.join('--');
// handle special character
id = id.replace(/[#()"']/g, '').replace('.', '_').replace(/\%/g, 'p').replace(/\s+/g, '-');
if (_this.isFalsyPropValue) id = id + '--false';
if (meta.childSelector) {
id = meta.childSelector + '-' + id;
}
var isValid = /^[a-zA-Z0-9-_]+$/.test(id);

@@ -360,3 +310,2 @@ id = isValid ? id : "css-" + hash(id);

};
this.propKey = options.propKey;

@@ -370,4 +319,4 @@ this.propValue = options.propValue;

this.isValid = this.getIsValid();
this.inserted = false; // shallow clone it
this.inserted = false;
// shallow clone it
this.meta = _extends({}, options.meta) || {};

@@ -381,6 +330,3 @@ this.preprocessAtom();

*/
var _proto = Atom.prototype;
/**

@@ -396,3 +342,2 @@ *

};
_proto.postfixPreprocessor = function postfixPreprocessor() {

@@ -402,10 +347,10 @@ var connector = '--';

var _store$config = store.config,
_store$config$pseudos = _store$config.pseudos,
pseudos = _store$config$pseudos === void 0 ? [] : _store$config$pseudos,
theme = _store$config.theme,
mode = _store$config.mode;
_store$config$pseudos = _store$config.pseudos,
pseudos = _store$config$pseudos === void 0 ? [] : _store$config$pseudos,
theme = _store$config.theme,
mode = _store$config.mode;
var modeList = mode.modeList;
var breakpoints = theme.breakpoints;
var propKey = this.propKey,
propValue = this.propValue;
propValue = this.propValue;
var breakpointKeys = Object.keys(breakpoints);

@@ -424,12 +369,9 @@ var modeKeys = modeList || [];

/** handle value like: red500--T40, #666--O30 */
if (regColorPostfix.test(propValue)) {
var _propValue$split = propValue.split('--'),
colorName = _propValue$split[0],
postfix = _propValue$split[1];
colorName = _propValue$split[0],
postfix = _propValue$split[1];
this.value = colorName;
this.meta.colorPostfix = postfix;
}
var isMode = regMode.test(propKey);

@@ -445,3 +387,2 @@ var isPseudo = regPseudo.test(propKey);

this.key = result[0]; // key that already removed postfix
if (isMode) {

@@ -452,3 +393,2 @@ this.meta.mode = result.find(function (i) {

}
if (isPseudo) {

@@ -461,3 +401,2 @@ var pseudo = result.find(function (i) {

}
if (isResponsive) {

@@ -469,3 +408,2 @@ var breakpointType = result.find(function (i) {

}
if (isImportant) {

@@ -476,3 +414,2 @@ this.meta.important = !!result.find(function (i) {

}
if (isColorPostfix) {

@@ -483,20 +420,16 @@ this.meta.colorPostfix = result.find(function (i) {

}
if (isParentSelector) {
var _result$find;
this.meta.parentClass = (_result$find = result.find(function (i) {
return i.startsWith('$');
})) == null ? void 0 : _result$find.replace(/^\$/, '');
} // check is theme space key, if yes, preprocess it
}
// check is theme space key, if yes, preprocess it
this.digitPreprocessor();
return this;
};
_proto.digitPreprocessor = function digitPreprocessor() {
if (!digitReg.test(this.key)) return this;
var spacings = store.config.theme.spacings; // is theme space key
var spacings = store.config.theme.spacings;
// is theme space key
var isSpace = /^([a-z]+)(\d+)$/i.test(this.key);

@@ -509,3 +442,2 @@ /**

*/
var keyStr = this.key.toString();

@@ -515,3 +447,3 @@ var result = keyStr.match(/^([a-z]+)(\d+)$/i) || keyStr.match(/^([a-z]*)-(-?\d+[a-z]*?)$/i) || keyStr.match(/^([a-z]+)-(auto)$/i);

var newKey = result[1],
newPropValue = result[2];
newPropValue = result[2];
this.key = newKey;

@@ -521,3 +453,2 @@ this.value = isSpace ? spacings["" + newPropValue.toLowerCase()] : newPropValue;

};
_proto.getInitialHandled = function getInitialHandled() {

@@ -529,3 +460,2 @@ if (this.options.handled) return this.options.handled;

};
_proto.getIsValid = function getIsValid() {

@@ -536,3 +466,2 @@ if (this.isFalsyPropValue) return false;

};
_createClass(Atom, [{

@@ -551,3 +480,2 @@ key: "isValueProp",

*/
}, {

@@ -566,3 +494,2 @@ key: "styleKeys",

*/
}, {

@@ -572,5 +499,3 @@ key: "styleKeysHash",

var _this$meta = this.meta,
rest = _objectWithoutPropertiesLoose(_this$meta, _excluded2); // omit colorPostfix
rest = _objectWithoutPropertiesLoose(_this$meta, _excluded2); // omit colorPostfix
return Object.keys(this.style || {}).join('-') + JSON.stringify(rest);

@@ -590,3 +515,2 @@ }

}]);
return Atom;

@@ -600,12 +524,8 @@ }();

this.ssrAtomIds = null;
if (isBrowser) {
var _globalThis$document;
this.$style = (_globalThis$document = globalThis.document) == null ? void 0 : _globalThis$document.querySelector == null ? void 0 : _globalThis$document.querySelector('[data-fower]');
}
}
var _proto = StyleSheet.prototype;
_proto.createStyleElement = function createStyleElement() {

@@ -617,6 +537,4 @@ var $style = document.createElement('style');

};
_proto.getSsrAtomIds = function getSsrAtomIds() {
var _this$$style, _this$$style$dataset$;
if (!this.$style) return [];

@@ -626,16 +544,12 @@ if (this.ssrAtomIds) return this.ssrAtomIds;

};
_proto.insertStyleToHtml = function insertStyleToHtml(rules) {
if (!isBrowser) return;
if (!this.$style) {
this.$style = this.createStyleElement();
} // const str = rules.join('\n')
}
// const str = rules.join('\n')
// this.$style.innerHTML += str
// return
for (var _iterator = _createForOfIteratorHelperLoose(rules), _step; !(_step = _iterator()).done;) {
var rule = _step.value;
try {

@@ -648,3 +562,2 @@ this.$style.sheet.insertRule(rule);

};
_proto.insertStyles = function insertStyles(rules) {

@@ -654,3 +567,2 @@ if (rules === void 0) {

}
if (!rules.length) return;

@@ -660,10 +572,7 @@ if (isBrowser) return this.insertStyleToHtml(rules);

};
_proto.getStyle = function getStyle() {
return this.cssString;
};
return StyleSheet;
}();
var styleSheet = /*#__PURE__*/new StyleSheet();

@@ -678,3 +587,2 @@

*/
function isUnitProp(cssKey) {

@@ -685,3 +593,3 @@ return reg.test(cssKey);

var colorKeys = ['color', 'backgroundColor', 'borderColor'];
// high-frequency used props in react
var reactProps = ['children', 'onClick', 'onChange', 'onBlur', 'id', 'className', 'style', 'title', 'tabIndex', 'placeholder', 'href', 'src', 'contentEditable', 'defaultChecked', 'defaultValue'];

@@ -691,11 +599,8 @@ /**

*/
var Parser = /*#__PURE__*/function () {
function Parser(props) {
var _store$config$mode, _store$config$mode$au;
if (props === void 0) {
props = {};
}
this.props = props;

@@ -705,3 +610,2 @@ /**

*/
this.atoms = [];

@@ -711,11 +615,7 @@ /**

*/
this.data = {};
this.getClassNameById = function (id) {
return store.config.prefix + id;
};
this.traverseProps(props);
if ((_store$config$mode = store.config.mode) != null && (_store$config$mode$au = _store$config$mode.autoDarkMode) != null && _store$config$mode$au.enabled) {

@@ -725,5 +625,3 @@ this.autoDarkMode();

}
var _proto = Parser.prototype;
/**

@@ -735,6 +633,6 @@ * traverse Props to init atoms

var _this$config = this.config,
_this$config$pseudos = _this$config.pseudos,
pseudos = _this$config$pseudos === void 0 ? [] : _this$config$pseudos,
theme = _this$config.theme,
mode = _this$config.mode;
_this$config$pseudos = _this$config.pseudos,
pseudos = _this$config$pseudos === void 0 ? [] : _this$config$pseudos,
theme = _this$config.theme,
mode = _this$config.mode;
var modeList = mode.modeList;

@@ -746,8 +644,6 @@ var breakpoints = theme.breakpoints || {};

var _props$excludedProps = props.excludedProps,
excludedProps = _props$excludedProps === void 0 ? [] : _props$excludedProps;
excludedProps = _props$excludedProps === void 0 ? [] : _props$excludedProps;
var entries = Object.entries(props);
for (var _iterator = _createForOfIteratorHelperLoose(this.plugins), _step; !(_step = _iterator()).done;) {
var plugin = _step.value;
if (plugin.init) {

@@ -757,3 +653,2 @@ plugin.init(props);

}
if (props != null && props.className) {

@@ -764,16 +659,14 @@ for (var _iterator2 = _createForOfIteratorHelperLoose(props.className.split(/\s+/)), _step2; !(_step2 = _iterator2()).done;) {

}
} // traverse Props
}
// traverse Props
for (var _i = 0, _entries = entries; _i < _entries.length; _i++) {
var _this$config$objectPr;
var _entries$_i = _entries[_i],
propKey = _entries$_i[0],
propValue = _entries$_i[1];
propKey = _entries$_i[0],
propValue = _entries$_i[1];
// the prop should be excluded by user setting
if (excludedProps.includes(propKey)) continue;
if (reactProps.includes(propKey)) continue;
if (!this.isValidProp(propKey, propValue)) continue; // parse object prop
if (!this.isValidProp(propKey, propValue)) continue;
// parse object prop
if ((_this$config$objectPr = this.config.objectPropKeys) != null && _this$config$objectPr.includes(propKey)) {

@@ -784,4 +677,2 @@ this.parseObjectProp(propValue, {});

/** handle _hover, _sm, _dark... */
if (propKey.startsWith('_')) {

@@ -791,6 +682,4 @@ var postfix = propKey.replace(/^_/, '');

var _extends2;
return _extends({}, r, (_extends2 = {}, _extends2[cur] = true, _extends2));
}, {}) : propValue;
if (modeKeys.includes(postfix)) {

@@ -802,3 +691,2 @@ this.parseObjectProp(obj, {

}
if (breakpointKeys.includes(postfix)) {

@@ -810,3 +698,2 @@ this.parseObjectProp(obj, {

}
if (pseudoKeys.includes(postfix)) {

@@ -820,3 +707,2 @@ this.parseObjectProp(obj, {

}
if (Array.isArray(propValue)) {

@@ -829,8 +715,5 @@ // TODO: hack for bgGradientX, bgGradientY

}
var composition = store.compositions.get(propKey);
if (composition) {
this.parseObjectProp(composition, {});
var _atom = new Atom({

@@ -840,3 +723,2 @@ propKey: propKey,

});
_atom.handled = true;

@@ -846,5 +728,4 @@ _atom.style = {};

continue;
} // common props
}
// common props
var atom = new Atom({

@@ -854,3 +735,2 @@ propKey: propKey,

}, false);
try {

@@ -863,6 +743,4 @@ this.mutateAtom(atom);

}
for (var _iterator3 = _createForOfIteratorHelperLoose(this.plugins), _step3; !(_step3 = _iterator3()).done;) {
var _plugin = _step3.value;
if (_plugin.afterAtomStyleCreate) {

@@ -873,6 +751,4 @@ _plugin.afterAtomStyleCreate(this);

};
_proto.getAutoDarkModeAtom = function getAutoDarkModeAtom(atom) {
var _options$style;
if (atom.meta.mode) return null;

@@ -888,15 +764,13 @@ if (!atom.style) return null;

var _entries$ = entries[0],
colorKey = _entries$[0],
colorName = _entries$[1]; // check is valid color key
if (!colorKeys.includes(colorKey)) return null; // only color in theme is valid
if (!colors[colorName]) return null; // if scale is existed, scale should be 100,200,300,400...
colorKey = _entries$[0],
colorName = _entries$[1];
// check is valid color key
if (!colorKeys.includes(colorKey)) return null;
// only color in theme is valid
if (!colors[colorName]) return null;
// if scale is existed, scale should be 100,200,300,400...
var _ref = colorName.match(/^([a-z]+)(\d+)$/i) || [],
scale = _ref[2]; // is disable, eg: { red200: false}
scale = _ref[2];
// is disable, eg: { red200: false}
if (mappings[colorName] === false) return null;
if (mappings[colorName]) {

@@ -907,7 +781,5 @@ darkColor = mappings[colorName];

}
var isColor = colorKey === 'color';
var isBgColor = colorKey === 'backgroundColor';
var isBorderColor = colorKey === 'borderColor';
if (colors[darkColor]) {

@@ -921,3 +793,2 @@ if (isColor) {

}
options.propValue = true;

@@ -936,3 +807,2 @@ } else {

}
options.style = (_options$style = {}, _options$style[colorKey] = darkColor, _options$style);

@@ -945,3 +815,2 @@ return new Atom(_extends({}, options, {

};
_proto.autoDarkMode = function autoDarkMode() {

@@ -957,3 +826,2 @@ for (var _iterator4 = _createForOfIteratorHelperLoose(this.atoms), _step4; !(_step4 = _iterator4()).done;) {

var cachedAtom = store.atomCache.get(darkAtom.id);
if (cachedAtom) {

@@ -971,23 +839,18 @@ this.addAtom(cachedAtom);

* @returns
*/
;
*/;
_proto.formatCssValue = function formatCssValue(key, value) {
// no need unit
if (!isUnitProp(key)) return value;
var numValue = value; // 80p -> 80%, 50p-> -50%
var numValue = value;
// 80p -> 80%, 50p-> -50%
if (isPercentNumber(String(value))) {
return String(value).replace('p', '%');
}
if (!isNumber(value)) return value;
numValue = Number(value); // if num is between 0 and 1, convert it to percent number.
numValue = Number(value);
// if num is between 0 and 1, convert it to percent number.
if (numValue < 1 && numValue > 0) {
return numValue * 100 + '%';
}
var config = store.config;
if (config.unit !== 'none') {

@@ -1000,3 +863,2 @@ if (config.transformUnit) {

}
return numValue;

@@ -1012,17 +874,13 @@ }

* @returns
*/
;
*/;
_proto.styleToString = function styleToString(style, meta) {
var _this = this;
var important = meta.important,
colorPostfix = meta.colorPostfix;
colorPostfix = meta.colorPostfix;
return Object.entries(style).reduce(function (r, _ref2) {
var key = _ref2[0],
value = _ref2[1];
value = _ref2[1];
var cssKey = jsKeyToCssKey(key);
var postfix = important ? ' !important' : '';
var colors = store.theme.colors;
try {

@@ -1034,3 +892,2 @@ if (colorPostfix) {

}
return r + (cssKey + ": " + value + postfix + ";");

@@ -1042,38 +899,29 @@ } catch (error) {

};
_proto.addAtom = function addAtom(atom) {
var _this$config$theme;
if (!atom.id) atom.setId(); // if not cached, let's cache it
if (!atom.id) atom.setId();
// if not cached, let's cache it
if (!store.atomCache.get(atom.id)) {
store.atomCache.set(atom.id, atom);
}
var ssrAtomIds = styleSheet.getSsrAtomIds();
var _ref3 = ((_this$config$theme = this.config.theme) == null ? void 0 : _this$config$theme.colors) || {},
_ref3$modes = _ref3.modes,
modes = _ref3$modes === void 0 ? {} : _ref3$modes;
_ref3$modes = _ref3.modes,
modes = _ref3$modes === void 0 ? {} : _ref3$modes;
var entries = Object.entries(modes);
/** for color mode */
for (var _i2 = 0, _entries2 = entries; _i2 < _entries2.length; _i2++) {
var _entries2$_i = _entries2[_i2],
mode = _entries2$_i[0],
colors = _entries2$_i[1];
mode = _entries2$_i[0],
colors = _entries2$_i[1];
if (!atom.style) continue;
var _entries3 = Object.entries(atom.style);
if (!_entries3.length) continue;
var _entries3$ = _entries3[0],
styleKey = _entries3$[0],
styleValue = _entries3$[1];
styleKey = _entries3$[0],
styleValue = _entries3$[1];
var colorValue = colors[styleValue];
if (colorValue) {
var postfix = '--' + mode; // TODO: improve clone
var postfix = '--' + mode;
// TODO: improve clone
var modeAtom = JSON.parse(JSON.stringify(atom));

@@ -1090,3 +938,2 @@ modeAtom.key = atom.key + postfix;

}
if (ssrAtomIds.includes(atom.id)) atom.inserted = true;

@@ -1100,11 +947,8 @@ this.atoms.push(atom);

* @returns
*/
;
*/;
_proto.isValidProp = function isValidProp(propKey, propValue) {
var _this$config$objectPr2;
var validTypes = ['string', 'boolean', 'number', 'undefined', 'function'];
if ((_this$config$objectPr2 = this.config.objectPropKeys) != null && _this$config$objectPr2.includes(propKey)) return true; // for _hover,_sm,_dark...
if ((_this$config$objectPr2 = this.config.objectPropKeys) != null && _this$config$objectPr2.includes(propKey)) return true;
// for _hover,_sm,_dark...
if (propKey.startsWith('_')) return true;

@@ -1119,26 +963,20 @@ if (Array.isArray(propValue)) return true;

* @param atom
*/
;
*/;
_proto.mutateAtom = function mutateAtom(atom) {
for (var _iterator5 = _createForOfIteratorHelperLoose(this.plugins), _step5; !(_step5 = _iterator5()).done;) {
var plugin = _step5.value;
if (!(plugin.isMatch != null && plugin.isMatch(atom.key, this))) continue; // why set id here? because of function prop Value
if (!atom.id) atom.setId(); // 处理函数 props
if (!(plugin.isMatch != null && plugin.isMatch(atom.key, this))) continue;
// why set id here? because of function prop Value
if (!atom.id) atom.setId();
// 处理函数 props
if (typeof atom.value === 'function') atom.value = atom.value();
if (plugin.beforeHandleAtom) {
atom = plugin.beforeHandleAtom(atom, this);
}
} // for nested style, like css props
}
// for nested style, like css props
if (Object.values(atom.meta || {}).length || Object.values(atom.style || {}).length) {
if (!atom.id) atom.setId();
}
var cachedAtom = store.atomCache.get(atom.id);
if (cachedAtom) {

@@ -1148,5 +986,4 @@ cachedAtom.propKeys.push(atom.propKey);

throw new Error('atom is cached, add to this.atoms directly, no need to mutate');
} // if handled, push to this.atoms and skip it
}
// if handled, push to this.atoms and skip it
if (atom.handled) {

@@ -1156,11 +993,8 @@ this.addAtom(atom);

}
for (var _iterator6 = _createForOfIteratorHelperLoose(this.plugins), _step6; !(_step6 = _iterator6()).done;) {
var _plugin2 = _step6.value;
if (!(_plugin2.isMatch != null && _plugin2.isMatch(atom.key, this))) continue;
if (_plugin2.handleAtom) {
atom = _plugin2.handleAtom == null ? void 0 : _plugin2.handleAtom(atom, this);
}
atom.handled = true;

@@ -1170,3 +1004,2 @@ break; // break from this plugin

};
_proto.parseResponsiveValue = function parseResponsiveValue(propKey, propValue) {

@@ -1177,3 +1010,2 @@ var breakpoints = this.config.theme.breakpoints;

var _extends3;
var prop = "" + propKey + (i === 0 ? '' : '--' + keys[i - 1]);

@@ -1184,3 +1016,2 @@ return _extends({}, result, (_extends3 = {}, _extends3[prop] = cur, _extends3));

};
_proto.parseObjectProp = function parseObjectProp(propValue, meta) {

@@ -1190,16 +1021,14 @@ if (meta === void 0) {

}
var parsed = parse(propValue);
for (var _iterator7 = _createForOfIteratorHelperLoose(parsed), _step7; !(_step7 = _iterator7()).done;) {
var _step7$value = _step7.value,
selector = _step7$value.selector,
selectorType = _step7$value.selectorType,
style = _step7$value.style;
selector = _step7$value.selector,
selectorType = _step7$value.selectorType,
style = _step7$value.style;
var entries = Object.entries(style);
if (!entries.length) continue; // entries.length is 1
if (!entries.length) continue;
// entries.length is 1
var _entries$2 = entries[0],
propKey = _entries$2[0],
_propValue = _entries$2[1];
propKey = _entries$2[0],
_propValue = _entries$2[1];
var option = {

@@ -1209,27 +1038,21 @@ propKey: propKey,

meta: _extends({}, meta)
}; // 对于正常的css属性,例如 vertical-align,设置 style
};
// 对于正常的css属性,例如 vertical-align,设置 style
if (style && Object.keys(style).length) {
option.style = style;
}
if (selectorType === 'pseudo' && option.meta) {
var _ref4 = selector.match(/(:+)(.+)/) || [],
pseudoPrefix = _ref4[1],
pseudo = _ref4[2];
pseudoPrefix = _ref4[1],
pseudo = _ref4[2];
option.meta.pseudoPrefix = pseudoPrefix;
option.meta.pseudo = pseudo;
}
if (selectorType === 'child' && option.meta) {
option.meta.childSelector = selector;
}
if (selectorType === 'sibling' && option.meta) {
option.meta.siblingSelector = selector;
}
var atom = new Atom(option, false);
try {

@@ -1239,11 +1062,8 @@ this.mutateAtom(atom);

continue;
} // not match atomic props rule, 说明是非原子属性
}
// not match atomic props rule, 说明是非原子属性
if (!atom.style || !Object.keys(atom.style).length) {
atom.handled = true;
}
var cachedAtom = store.atomCache.get(atom.id);
if (cachedAtom) {

@@ -1256,3 +1076,2 @@ this.addAtom(cachedAtom);

};
_proto.makeResponsiveStyle = function makeResponsiveStyle(breakpoint, rule) {

@@ -1264,8 +1083,5 @@ var breakpoints = this.config.theme.breakpoints;

* get component classNames
*/
;
*/;
_proto.getClassNames = function getClassNames() {
var _this2 = this;
/**

@@ -1284,5 +1100,3 @@ * handle override style

if (!cur.isValid) return result;
var className = _this2.getClassNameById(cur.id);
if (index === -1) {

@@ -1295,7 +1109,6 @@ classNames.push(className);

}
return result;
}, []);
var _this$props$className = this.props.className,
className = _this$props$className === void 0 ? '' : _this$props$className;
className = _this$props$className === void 0 ? '' : _this$props$className;
var filteredClassNames = className.split(/\s+/).filter(function (i) {

@@ -1305,8 +1118,5 @@ return !classNames.includes(i) && !!i;

classNames = classNames.concat(filteredClassNames);
if (this.hasResponsive) {
var _classNames;
var breakpoints = this.config.theme.breakpoints;
(_classNames = classNames).push.apply(_classNames, Object.keys(breakpoints).map(function (i) {

@@ -1316,3 +1126,2 @@ return "r-" + i;

}
return classNames;

@@ -1322,20 +1131,13 @@ }

* get style object
*/
;
*/;
_proto.toStyle = function toStyle() {
var _this3 = this;
var style = this.atoms.reduce(function (result, atom) {
if (!atom.isValid) return result; // not style type
var colors = store.theme.colors;
var style = Object.entries(atom.style).reduce(function (c, _ref5) {
var _extends4;
var key = _ref5[0],
value = _ref5[1];
value = _ref5[1];
var cssValue = _this3.formatCssValue(jsKeyToCssKey(key), colors[value] || value);
return _extends({}, c, (_extends4 = {}, _extends4[key] = cssValue, _extends4));

@@ -1350,5 +1152,3 @@ }, {});

* @returns
*/
;
*/;
_proto.toRules = function toRules(enableInserted) {

@@ -1358,9 +1158,7 @@ if (enableInserted === void 0) {

}
var _this$config$mode$cla = this.config.mode.classPrefix,
classPrefix = _this$config$mode$cla === void 0 ? '' : _this$config$mode$cla;
classPrefix = _this$config$mode$cla === void 0 ? '' : _this$config$mode$cla;
var rules = [];
var breakpoints = this.config.theme.breakpoints;
var breakpointKeys = Object.keys(breakpoints);
for (var _iterator8 = _createForOfIteratorHelperLoose(this.atoms), _step8; !(_step8 = _iterator8()).done;) {

@@ -1370,23 +1168,21 @@ var atom = _step8.value;

var id = atom.id,
isValid = atom.isValid,
_atom$style = atom.style,
style = _atom$style === void 0 ? {} : _atom$style,
meta = atom.meta; // no style in falsy prop
if (!isValid) continue; // empty style
isValid = atom.isValid,
_atom$style = atom.style,
style = _atom$style === void 0 ? {} : _atom$style,
meta = atom.meta;
// no style in falsy prop
if (!isValid) continue;
// empty style
if (isEmptyObj(style)) continue;
var pseudo = meta.pseudo,
pseudoPrefix = meta.pseudoPrefix,
mode = meta.mode,
_meta$breakpoint = meta.breakpoint,
breakpoint = _meta$breakpoint === void 0 ? '' : _meta$breakpoint,
childSelector = meta.childSelector,
siblingSelector = meta.siblingSelector,
parentClass = meta.parentClass;
pseudoPrefix = meta.pseudoPrefix,
mode = meta.mode,
_meta$breakpoint = meta.breakpoint,
breakpoint = _meta$breakpoint === void 0 ? '' : _meta$breakpoint,
childSelector = meta.childSelector,
siblingSelector = meta.siblingSelector,
parentClass = meta.parentClass;
if (!enableInserted) {
if (atom.inserted) continue;
}
atom.inserted = true;

@@ -1397,10 +1193,7 @@ var className = this.getClassNameById(id);

if (childSelector) selector = selector + " " + childSelector;
if (siblingSelector) {
selector = "" + selector + siblingSelector;
}
if (pseudo) {
var pseudoSelector = pseudoPrefix + pseudo;
if (parentClass) {

@@ -1411,5 +1204,4 @@ selector = "." + parentClass + pseudoSelector + " " + selector;

}
} // TODO: need refactor
}
// TODO: need refactor
if (breakpoint) {

@@ -1421,24 +1213,19 @@ var keys = breakpointKeys.slice(0, breakpointKeys.indexOf(breakpoint) + 1);

}
rule = selector + " { " + this.styleToString(style, atom.meta) + " }";
if (breakpoint) rule = this.makeResponsiveStyle(breakpoint, rule);
rules.push(rule);
} // console.log('this.atoms---', this.atoms)
}
// console.log('this.atoms---', this.atoms)
return rules;
};
_proto.getParsedProps = function getParsedProps() {
var _this4 = this;
var props = this.props,
atoms = this.atoms;
atoms = this.atoms;
if (isEmptyObj(props)) return {};
var entries = Object.entries(props);
/** ignore atomic prop */
var parsedProps = entries.reduce(function (result, _ref6) {
var key = _ref6[0],
value = _ref6[1];
value = _ref6[1];
// ignore prop with postfix

@@ -1454,3 +1241,2 @@ if (/.*--(\d+)?[a-z]+$/i.test(key)) return result;

};
_proto.insertRules = function insertRules() {

@@ -1460,3 +1246,2 @@ var rules = this.toRules();

};
_createClass(Parser, [{

@@ -1490,3 +1275,2 @@ key: "uniqueClassName",

}]);
return Parser;

@@ -1513,10 +1297,7 @@ }();

*/
function css() {
var _store$config, _store$config$objectP;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (!args.length) return '';

@@ -1539,8 +1320,6 @@ var parser = new Parser(argsToProps(args, (_store$config = store.config) == null ? void 0 : (_store$config$objectP = _store$config.objectPropKeys) == null ? void 0 : _store$config$objectP[0]));

}
var props = args.reduce(function (result, cur) {
var _extends2;
if (typeof cur === 'string') return _extends({}, result, (_extends2 = {}, _extends2[cur] = true, _extends2)); // not string, is object
if (typeof cur === 'string') return _extends({}, result, (_extends2 = {}, _extends2[cur] = true, _extends2));
// not string, is object
return _extends({}, result, {

@@ -1560,10 +1339,9 @@ css: cur

*/
function keyframes(input, name) {
var content = Object.entries(input).reduce(function (result, _ref) {
var key = _ref[0],
value = _ref[1];
value = _ref[1];
var str = Object.entries(value).reduce(function (r, _ref2) {
var k = _ref2[0],
v = _ref2[1];
v = _ref2[1];
return r + (jsKeyToCssKey(k) + ": " + v + ";");

@@ -1596,11 +1374,9 @@ }, '');

*/
function injectGlobalStyle(cssObj) {
var entries = Object.entries(cssObj);
var parser = new Parser({});
for (var _i = 0, _entries = entries; _i < _entries.length; _i++) {
var _entries$_i = _entries[_i],
key = _entries$_i[0],
value = _entries$_i[1];
key = _entries$_i[0],
value = _entries$_i[1];
var atom = new Atom({

@@ -1617,3 +1393,2 @@ propKey: key,

}
parser.insertRules();

@@ -1631,11 +1406,11 @@ }

var setConfig = store.setConfig,
getConfig = store.getConfig,
setTheme = store.setTheme,
getTheme = store.getTheme,
setMode = store.setMode,
getMode = store.getMode,
addAtom = store.addAtom,
composeAtom = store.composeAtom;
getConfig = store.getConfig,
setTheme = store.setTheme,
getTheme = store.getTheme,
setMode = store.setMode,
getMode = store.getMode,
addAtom = store.addAtom,
composeAtom = store.composeAtom;
export { Atom, Parser, Store, addAtom, composeAtom, createStyle, css, digitReg, getConfig, getMode, getTheme, injectGlobalStyle, isAtomicArgsValid, keyframes, setConfig, setMode, setTheme, store, styleSheet };
//# sourceMappingURL=core.esm.js.map
{
"name": "@fower/core",
"version": "1.72.0",
"version": "1.73.0",
"license": "MIT",

@@ -25,10 +25,10 @@ "main": "dist/index.js",

"dependencies": {
"@fower/atomic-props": "^1.72.0",
"@fower/color-helper": "^1.72.0",
"@fower/css-object-processor": "^1.72.0",
"@fower/utils": "^1.72.0",
"@fower/atomic-props": "^1.73.0",
"@fower/color-helper": "^1.73.0",
"@fower/css-object-processor": "^1.73.0",
"@fower/utils": "^1.73.0",
"deepmerge": "^4.2.2",
"string-hash": "^1.1.3"
},
"gitHead": "c84a9d5fe0b3a55ab835f3a7a77c6654d25ef6ef"
"gitHead": "cfc4d4e79e4ed784b2a3442fc8c0b43061a23a8d"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc