@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
60 lines (56 loc) • 2.45 kB
JavaScript
"use client";
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
const require_utils_index = require('../../utils/index.cjs');
const require_utils = require('./utils.cjs');
let __emotion_react = require("@emotion/react");
__emotion_react = require_rolldown_runtime.__toESM(__emotion_react);
let __emotion_sheet = require("@emotion/sheet");
__emotion_sheet = require_rolldown_runtime.__toESM(__emotion_sheet);
//#region src/core/css/animation.ts
const styleSheet = (0, require_utils_index.utils_exports.createdDom)() ? new __emotion_sheet.StyleSheet({
key: "css",
container: document.head
}) : void 0;
function transformAnimationValue(value) {
return Object.entries(value).reduce((prev, [key, value$1]) => {
if (key === "keyframes") prev._keyframes = value$1;
else if (key === "duration") prev.animationDuration = value$1;
else if (key === "timingFunction") prev.animationTimingFunction = value$1;
else prev[key] = value$1;
return prev;
}, {});
}
function injectKeyframes(value) {
const { name, styles } = (0, __emotion_react.keyframes)(value);
styleSheet?.insert(styles);
return name;
}
function animation(value, { css, system, theme }) {
if (value == null || require_utils.globalValues.has(value)) return value;
if ((0, require_utils_index.utils_exports.isObject)(value)) {
const { animationDuration = "0s", animationName, animationTimingFunction = "ease", delay = "0s", direction = "normal", fillMode = "none", iterationCount = "1", playState = "running" } = css?.(system, theme)(transformAnimationValue(value)) ?? {};
return `${animationName} ${animationDuration} ${animationTimingFunction} ${delay} ${iterationCount} ${direction} ${fillMode} ${playState}`;
} else if (value.includes(",")) {
value = value.split(",").map((value$1) => {
value$1 = value$1.trim();
value$1 = require_utils.tokenToVar(system)("animations", value$1);
return value$1;
}).join(",");
return value;
} else {
value = require_utils.tokenToVar(system)("animations", value);
return value;
}
}
function keyframes(value, { css, system, theme }) {
if (value == null) return value;
if ((0, require_utils_index.utils_exports.isObject)(value)) {
value = css?.(system, theme)(value);
return injectKeyframes(value);
} else return value;
}
//#endregion
exports.animation = animation;
exports.injectKeyframes = injectKeyframes;
exports.keyframes = keyframes;
//# sourceMappingURL=animation.cjs.map