UNPKG

@kuma-ui/sheet

Version:

🐻 Kuma UI is a utility-first, zero-runtime CSS-in-JS library that offers an outstanding developer experience and optimized performance.

112 lines (108 loc) 2.73 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/theme.ts var theme_exports = {}; __export(theme_exports, { Theme: () => Theme, defaultBreakpoints: () => defaultBreakpoints, theme: () => theme, tokens: () => tokens }); module.exports = __toCommonJS(theme_exports); // src/placeholders.ts var createPlaceholders = (theme2) => { const result = {}; for (const token of tokens) { const tokenValue = theme2[token]; if (tokenValue) { for (const key in tokenValue) { result[key] = tokenValue[key]; } } } return result; }; // src/theme.ts var defaultBreakpoints = Object.freeze({ sm: "576px", md: "768px", lg: "992px", xl: "1200px" }); var tokens = [ "colors", "fonts", "fontSizes", "fontWeights", "lineHeights", "letterSpacings", "spacings", "sizes", "radii", "zIndices", "breakpoints" ]; var Theme = class _Theme { static instance; _userTheme = { ...globalThis.__KUMA_USER_THEME__, breakpoints: globalThis.__KUMA_USER_THEME__?.breakpoints ?? defaultBreakpoints }; _placeholders = {}; constructor() { } static getInstance() { if (!_Theme.instance) { _Theme.instance = new _Theme(); } return _Theme.instance; } setUserTheme(userTheme) { if (Object.keys(userTheme.breakpoints || {}).length === 0) { delete userTheme.breakpoints; } this._userTheme = { ...this._userTheme, ...userTheme }; this._placeholders = createPlaceholders(this._userTheme); } getUserTheme() { return this._userTheme; } getPlaceholders() { return this._placeholders; } getVariants(componentName) { return this._userTheme.components?.[componentName] || {}; } reset() { this._userTheme = { breakpoints: defaultBreakpoints }; } }; var theme = Theme.getInstance(); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Theme, defaultBreakpoints, theme, tokens });