@just-web/css 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../src/convertors/px_2_num.ts","../src/convertors/px_2_rem.ts","../src/convertors/rem_2_px.ts","../src/properties/css_properties.ts","../src/properties/properties.ts","../src/properties/to_dom_style.ts","../src/globals.ctx.ts","../src/utils/attribute.ts","../src/theme/class-name.ts","../src/utils/data-attribute.ts","../src/theme/data-attribute.ts","../src/utils/get-css-prop-values.ts","../src/utils/prefers-color-scheme.ts"],"sourcesContent":["/**\n * Converts pixel values to numbers.\n *\n * @param px - The pixel value to convert. Can be a number or string (e.g. '16px' or '16')\n * @returns The numeric value\n *\n * @example\n * ```ts\n * px2num(16) // 16\n * px2num('32px') // 32\n * px2num('12.5px') // 12.5\n * px2num('0px') // 0\n * ```\n */\nexport function px2num(px: number | string | undefined): number {\n\treturn typeof px === 'string' ? Number.parseFloat(px.replace(/px$/, '')) : Number(px)\n}\n","/**\n * Converts pixel values to rem units.\n *\n * @param px - The pixel value to convert. Can be a number or string (e.g. '16px' or '16')\n * @param options - Optional configuration\n * @param options.base - Base pixel value to calculate rem units from. Defaults to 16\n * @param options.precision - Number of decimal places in the output. Defaults to 4\n * @returns The converted value as a string with 'rem' units\n *\n * @example\n * ```ts\n * px2rem(16) // '1.0000'\n * px2rem('32px') // '2.0000'\n * px2rem(20, { base: 20 }) // '1.0000'\n * px2rem(13, { precision: 2 }) // '0.81'\n * ```\n */\nexport function px2rem(\n\tpx: number | string,\n\toptions?: { base?: number | undefined; precision?: number | undefined },\n): number {\n\tconst { base = 16, precision = 4 } = options ?? {}\n\n\tif (typeof px === 'string') {\n\t\tpx = px.replace(/px$/, '')\n\t\tpx = Number.parseFloat(px)\n\t}\n\n\treturn Number((px / base).toFixed(precision))\n}\n","/**\n * Converts rem values to pixel units.\n *\n * @param rem - The rem value to convert. Can be a number or string (e.g. '1rem' or '1')\n * @param options - Optional configuration\n * @param options.base - Base pixel value to calculate pixels from. Defaults to 16\n * @param options.precision - Number of decimal places in the output. Defaults to 4\n * @returns The converted value as a string with 'px' units\n *\n * @example\n * ```ts\n * rem2px(1) // '16.0000'\n * rem2px('2rem') // '32.0000'\n * rem2px(1, { base: 20 }) // '20.0000'\n * rem2px(0.8125, { precision: 2 }) // '13.00'\n * ```\n */\nexport function rem2px(\n\trem: number | string,\n\toptions?: { base?: number | undefined; precision?: number | undefined },\n): number {\n\tconst { base = 16, precision = 4 } = options ?? {}\n\n\tif (typeof rem === 'string') {\n\t\trem = rem.replace(/rem$/, '')\n\t\trem = Number.parseFloat(rem)\n\t}\n\n\treturn Number((rem * base).toFixed(precision))\n}\n","import type { Properties as CSSTypeProperties } from 'csstype'\n\n/** Custom CSS properties (variables) with `--` prefix. */\ntype CustomProperties = { [k: `--${string}`]: string }\n\n/**\n * Widens CSS properties to support custom properties.\n * Allows for string or number values for standard properties,\n * and string values for custom properties with '--' prefix.\n * Defined as a union so plain Properties (e.g. from React) are assignable.\n */\nexport type CSSProperties<TLength = string | number, TTime = string & {}> =\n\t| CSSTypeProperties<TLength, TTime>\n\t| (CSSTypeProperties<TLength, TTime> & CustomProperties)\n\n/**\n * Defines CSS properties including custom properties.\n * This function is used to properly type CSS properties when defining styles,\n * especially when using CSS custom properties (variables).\n *\n * @deprecated Use `defineProperties` instead.\n *\n * @param style - CSS properties object that can include both standard and custom properties\n * @returns The same style object with proper typing\n *\n * @example\n * ```ts\n * defineCSSProperties({\n * color: 'red',\n * '--custom-color': '#ff0000'\n * })\n * ```\n */\nexport function defineCSSProperties(style: CSSProperties) {\n\treturn style as any\n}\n","import type { Properties as CSSTypeProperties } from 'csstype'\n\n/** Custom CSS properties (variables) with `--` prefix. */\ntype CustomProperties = { [k: `--${string}`]: string }\n\n/**\n * Extends CSS properties to include custom properties.\n * Allows for string or number values for standard properties,\n * and string values for custom properties with '--' prefix.\n */\nexport type Properties<TLength = 0 | (string & {}), TTime = string & {}> =\n\t| CSSTypeProperties<TLength, TTime>\n\t| (CSSTypeProperties<TLength, TTime> & CustomProperties)\n\n/**\n * Defines CSS properties including custom properties.\n * This function is used to properly type CSS properties when defining styles,\n * especially when using CSS custom properties (variables).\n *\n * @param style - CSS properties object that can include both standard and custom properties\n * @returns The same style object with proper typing\n *\n * @example\n * ```ts\n * defineCSSProperties({\n * color: 'red',\n * '--custom-color': '#ff0000'\n * })\n * ```\n */\nexport function defineProperties<TLength = 0 | (string & {}), TTime = string & {}>(style: Properties<TLength, TTime>) {\n\treturn style as Properties\n}\n","import type { CSSProperties } from './css_properties.ts'\n\n/**\n * Converts React-style CSS properties to DOM style properties.\n * This function handles both standard CSS properties and custom properties,\n * ensuring proper formatting for DOM style application.\n *\n * @param style - React-style CSS properties object\n * @returns CSSStyleDeclaration compatible object for DOM style application\n *\n * @example\n * ```ts\n * const domStyle = toDOMStyle({\n * backgroundColor: 'red',\n * '--custom-color': '#ff0000'\n * })\n * element.style = domStyle\n * ```\n */\nexport function toDOMStyle(style: CSSProperties | undefined): Partial<CSSStyleDeclaration> | undefined {\n\tif (style === undefined) return undefined\n\n\tconst result = {} as any\n\n\tfor (const [key, value] of Object.entries(style)) {\n\t\tresult[key.startsWith('--') ? key : key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)] = value\n\t}\n\n\treturn result\n}\n","export const ctx = {\n\tmatchMedia(query: string) {\n\t\treturn globalThis.matchMedia(query)\n\t},\n\tgetDocumentElement() {\n\t\treturn globalThis.document.documentElement\n\t},\n\t_reset() {\n\t\tthis.matchMedia = globalThis.matchMedia\n\t\tthis.getDocumentElement = () => globalThis.document.documentElement\n\t},\n}\n","import { ctx } from '../globals.ctx.ts'\n\n/**\n * Gets the value of an attribute from an element.\n *\n * @param qualifiedName - The name of the attribute to get\n * @param element - The element to get the attribute from. Defaults to `document.documentElement`\n * @returns The attribute value cast to type T, or null if the attribute doesn't exist\n *\n * @example\n * ```ts\n * // Get theme from document root\n * const theme = getAttribute('data-theme')\n *\n * // Get data-testid from a specific element\n * const testId = getAttribute('data-testid', element)\n * ```\n */\nexport function getAttribute<T extends string>(\n\tqualifiedName: T,\n\telement: Element | undefined = ctx.getDocumentElement(),\n) {\n\treturn element?.getAttribute(qualifiedName)\n}\n\n/**\n * Observes attributes changes on an element and calls corresponding handlers.\n *\n * @param handlers - An object mapping attribute names to handler functions.\n * @param element - The element to observe. Defaults to `document.documentElement`.\n * @returns {MutationObserver} The observer instance, which can be used to disconnect the observer.\n *\n * @example\n * ```ts\n * const observer = observeAttributes({\n * 'data-theme': (attr, value) => console.log(`Theme changed to: ${value}`),\n * 'class': (attr, value) => console.log(`class changed to: ${value}`)\n * });\n *\n * // Later, to stop observing:\n * observer.disconnect();\n * ```\n */\nexport function observeAttributes<T extends string>(\n\thandlers: Record<string, (value: T | null) => void>,\n\telement: Element | undefined = ctx.getDocumentElement(),\n) {\n\tconst observer = new MutationObserver((mutations) => {\n\t\tfor (const mutation of mutations) {\n\t\t\tconst attribute = mutation.attributeName!\n\t\t\tconst value = element.getAttribute(attribute) as T | null\n\t\t\thandlers[attribute]?.(value)\n\t\t}\n\t})\n\tobserver.observe(element, {\n\t\tattributes: true,\n\t\tattributeFilter: Object.keys(handlers),\n\t})\n\treturn observer\n}\n","import { findKey } from 'type-plus'\nimport { ctx } from '../globals.ctx.ts'\nimport { observeAttributes } from '../utils/attribute.ts'\n\n/**\n * Gets the current theme by checking element class names against a themes map.\n *\n * @param options - Configuration options\n * @param options.themes - Record mapping theme keys to their class name values\n * @param options.defaultTheme - Fallback theme key if no matching class is found\n * @param options.element - Element to check classes on (defaults to document.documentElement)\n * @returns The matching theme key or defaultTheme if no match found\n *\n * @example\n * ```ts\n * const themes = {\n * light: 'theme-light',\n * dark: 'theme-dark'\n * }\n *\n * // Get current theme from document.documentElement\n * const theme = getThemeByClassName({\n * themes,\n * defaultTheme: 'light'\n * })\n *\n * // Get theme from specific element\n * const theme = getThemeByClassName({\n * themes,\n * element: myElement,\n * defaultTheme: 'light'\n * })\n * ```\n */\nexport function getThemeByClassName<Themes extends Record<string, string>>(options: {\n\tthemes: Themes\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): keyof Themes | undefined {\n\tconst element = options.element ?? ctx.getDocumentElement()\n\tconst className = element.className\n\tconst theme = findKey(options.themes, (theme) => className.includes(options.themes[theme]!))\n\treturn theme ?? options.defaultTheme\n}\n\nexport function observeThemeByClassName<Themes extends Record<string, string>>(options: {\n\tthemes: Themes\n\thandler: (value: string | undefined) => void\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}) {\n\treturn observeAttributes(\n\t\t{\n\t\t\tclass: (value: string | null) => {\n\t\t\t\tif (value === null) {\n\t\t\t\t\toptions.handler(options.defaultTheme as string)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tfor (const name in options.themes) {\n\t\t\t\t\tif (value.includes(options.themes[name]!)) {\n\t\t\t\t\t\toptions.handler(name)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\toptions.element,\n\t)\n}\n","import { ctx } from '../globals.ctx.ts'\nimport { getAttribute, observeAttributes } from './attribute.ts'\n\nexport function getDataAttribute<T extends `data-${string}`>(\n\tqualifiedName: T,\n\telement: Element | undefined = ctx.getDocumentElement(),\n) {\n\treturn getAttribute(qualifiedName, element)\n}\n\n/**\n * Observes changes to `data-*` attributes on an element and calls corresponding handlers.\n *\n * @param options - Configuration options\n * @param options.handlers - An object mapping `data-*` attribute names to handler functions.\n * @param options.element - The element to observe. Defaults to `document.documentElement`\n * @returns {MutationObserver} The observer instance, which can be used to disconnect the observer\n *\n * @example\n * ```ts\n * const observer = observeDataAttributes({\n * handlers: {\n * 'data-theme': (value) => console.log(`Theme changed to: ${value}`),\n * 'data-mode': (value) => console.log(`Mode changed to: ${value}`)\n * }\n * });\n *\n * // Later, to stop observing:\n * observer.disconnect();\n * ```\n */\nexport function observeDataAttributes<T extends string, K extends `data-${string}`>(\n\thandlers: Record<K, (value: T | null) => void>,\n\telement?: Element | undefined,\n) {\n\treturn observeAttributes(handlers, element)\n}\n","import { findKey } from 'type-plus'\nimport { getDataAttribute, observeDataAttributes } from '../utils/data-attribute.ts'\n\n/**\n * Gets the theme based on a data attribute value.\n *\n * @param options - Configuration options\n * @param options.themes - Record mapping theme keys to their data attribute values\n * @param options.defaultTheme - Fallback theme key if attribute value doesn't match any theme\n * @param options.attributeName - Name of the data attribute to check (must start with 'data-')\n * @param options.allowCustom - Whether to allow custom themes value\n * @returns The matching theme key, or defaultTheme if no match found\n *\n * @example\n * ```ts\n * const themes = {\n * light: 'light',\n * dark: 'dark',\n * system: 'system'\n * }\n *\n * // Get theme from data-theme attribute\n * const theme = getThemeByDataAttribute({\n * themes,\n * defaultTheme: 'system',\n * attributeName: 'data-theme'\n * })\n * ```\n */\nexport function getThemeByDataAttribute<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tdefaultTheme?: keyof Themes | undefined\n\tthemes: Themes\n\telement?: Element | undefined\n}): keyof Themes | undefined\nexport function getThemeByDataAttribute<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tallowCustom: true | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\tthemes: Themes\n\telement?: Element | undefined\n}): string | undefined\nexport function getThemeByDataAttribute<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tallowCustom?: boolean | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\tthemes: Themes\n\telement?: Element | undefined\n}): keyof Themes | undefined {\n\tconst value = getDataAttribute(options.attributeName, options.element) ?? undefined\n\tconst theme = findKey(options.themes, (theme) => options.themes[theme] === value)\n\n\treturn theme ?? options.defaultTheme ?? (options.allowCustom ? value : undefined)\n}\n\n/**\n * Observes changes to a theme data attribute and calls a handler when it changes.\n *\n * @param options - Configuration options\n * @param options.themes - Record mapping theme keys to their data attribute values\n * @param options.handler - Callback function called with the new theme value or null when removed\n * @param options.defaultTheme - Fallback theme key if attribute value doesn't match any theme\n * @param options.attributeName - Name of the data attribute to observe (must start with 'data-')\n * @returns A MutationObserver that can be disconnected to stop observing\n *\n * @example\n * ```ts\n * const themes = {\n * light: 'light',\n * dark: 'dark'\n * }\n *\n * // Observe data-theme attribute changes\n * const observer = observeThemeByDataAttributes({\n * themes,\n * handler: (theme) => console.log('Theme changed to:', theme),\n * defaultTheme: 'light',\n * attributeName: 'data-theme'\n * })\n *\n * // Stop observing\n * observer.disconnect()\n * ```\n */\nexport function observeThemeByDataAttributes<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tthemes: Themes\n\thandler: (value: string | null) => void\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): MutationObserver\nexport function observeThemeByDataAttributes<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tthemes: Themes\n\thandler: (value: string | null) => void\n\tallowCustom: true | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): MutationObserver\nexport function observeThemeByDataAttributes<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tthemes: Themes\n\thandler: (value: string | null) => void\n\tallowCustom?: boolean | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): MutationObserver {\n\treturn observeDataAttributes(\n\t\t{\n\t\t\t[options.attributeName]: (value: string | null) => {\n\t\t\t\tif (value === null) {\n\t\t\t\t\toptions.handler((options.defaultTheme as string) ?? null)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tfor (const name in options.themes) {\n\t\t\t\t\tif (options.themes[name] === value) {\n\t\t\t\t\t\toptions.handler(name)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (options.allowCustom) {\n\t\t\t\t\toptions.handler(value)\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\toptions.element,\n\t)\n}\n","import type { CreateTuple } from 'type-plus'\n\n/**\n * Retrieves CSS custom property values from the specified element.\n *\n * @param element - The HTML element to get property values from\n * @param props - CSS custom property names to retrieve, must be in the format `--property-name`\n * @returns Array of property values corresponding to the requested custom properties\n */\nexport function getCSSPropValues<Props extends Array<`--${string}`>>(\n\telement: HTMLElement,\n\t...props: Props\n): CreateTuple<Props['length'], string>\n/**\n * Retrieves CSS custom property values from `document.body`.\n *\n * @param props - CSS custom property names to retrieve, must be in the format `--property-name`\n * @returns Array of property values corresponding to the requested custom properties\n */\nexport function getCSSPropValues<Props extends Array<`--${string}`>>(\n\t...props: Props\n): CreateTuple<Props['length'], string>\nexport function getCSSPropValues<Props extends Array<`--${string}`>>(element: unknown, ...props: Props) {\n\tif (typeof element === 'string') {\n\t\treturn getCSSPropValues(globalThis.document.body, element as `--${string}`, ...props)\n\t}\n\tconst style = globalThis.getComputedStyle(element as HTMLElement)\n\treturn props.map((v) => style.getPropertyValue(v)) as any\n}\n","import { mapKey } from 'type-plus'\nimport { ctx } from '../globals.ctx.ts'\n\n/**\n * Observes system color scheme preference changes and calls handlers when they occur.\n *\n * @param themes - An object mapping theme names to handler functions that are called when that theme is activated\n * @returns A cleanup function that removes all event listeners\n *\n * @example\n * ```ts\n * // Observe light/dark mode changes\n * const cleanup = observePrefersColorScheme({\n * light: (theme) => console.log('Light mode activated'),\n * dark: (theme) => console.log('Dark mode activated')\n * })\n *\n * // Later, to stop observing:\n * cleanup()\n * ```\n */\nexport function observePrefersColorScheme<T extends string>(themes: Record<T, (value: T | null) => void>) {\n\tconst removers = mapKey(themes, (t) => {\n\t\tconst m = ctx.matchMedia(`(prefers-color-scheme: ${t as string})`)\n\t\tconst listener = (event: MediaQueryListEvent) => {\n\t\t\tif (event.matches) {\n\t\t\t\tthemes[t]?.(t)\n\t\t\t}\n\t\t}\n\n\t\tm.addEventListener('change', listener)\n\t\treturn () => m.removeEventListener('change', listener)\n\t})\n\n\treturn () => {\n\t\tfor (const remover of removers) {\n\t\t\tremover()\n\t\t}\n\t}\n}\n\n/**\n * Gets the current preferred color theme from the system settings.\n *\n * @param themes - A list of theme names to check against the system preference\n * @returns The first matching theme from the provided list, or null if none match\n *\n * @example\n * ```ts\n * // Check if system prefers light or dark mode\n * const theme = getPrefersColorTheme('light', 'dark')\n * // Returns 'light', 'dark', or null\n * ```\n */\nexport function getPrefersColorTheme<T extends string>(...themes: T[]) {\n\treturn themes.find((theme) => ctx.matchMedia(`(prefers-color-scheme: ${theme})`).matches) ?? null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAcA,SAAgB,OAAO,IAAyC;AAC/D,QAAO,OAAO,OAAO,WAAW,OAAO,WAAW,GAAG,QAAQ,OAAO,GAAG,CAAC,GAAG,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;ACEtF,SAAgB,OACf,IACA,SACS;CACT,MAAM,EAAE,OAAO,IAAI,YAAY,MAAM,WAAW,EAAE;AAElD,KAAI,OAAO,OAAO,UAAU;AAC3B,OAAK,GAAG,QAAQ,OAAO,GAAG;AAC1B,OAAK,OAAO,WAAW,GAAG;;AAG3B,QAAO,QAAQ,KAAK,MAAM,QAAQ,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;ACX9C,SAAgB,OACf,KACA,SACS;CACT,MAAM,EAAE,OAAO,IAAI,YAAY,MAAM,WAAW,EAAE;AAElD,KAAI,OAAO,QAAQ,UAAU;AAC5B,QAAM,IAAI,QAAQ,QAAQ,GAAG;AAC7B,QAAM,OAAO,WAAW,IAAI;;AAG7B,QAAO,QAAQ,MAAM,MAAM,QAAQ,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;ACK/C,SAAgB,oBAAoB,OAAsB;AACzD,QAAO;;;;;;;;;;;;;;;;;;;;;ACJR,SAAgB,iBAAmE,OAAmC;AACrH,QAAO;;;;;;;;;;;;;;;;;;;;;;ACZR,SAAgB,WAAW,OAA4E;AACtG,KAAI,UAAU,OAAW,QA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iB,UAAU,SAAS;AACtC,eAAa,EAAE,oBAAoB,UAAU,SAAS;GACrD;AAEF,cAAa;AACZ,OAAK,MAAM,WAAW,SACrB,UAAS;;;;;;;;;;;;;;;;AAkBZ,SAAgB,qBAAuC,GAAG,QAAa;AACtE,QAAO,OAAO,MAAM,UAAU,IAAI,WAAW,0BAA0B,MAAM,GAAG,CAAC,QAAQ,IAAI"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/convertors/px_2_num.ts","../src/convertors/px_2_rem.ts","../src/convertors/rem_2_px.ts","../src/properties/css_properties.ts","../src/properties/properties.ts","../src/properties/to_dom_style.ts","../src/globals.ctx.ts","../src/utils/attribute.ts","../src/theme/class-name.ts","../src/utils/data-attribute.ts","../src/theme/data-attribute.ts","../src/utils/get-css-prop-values.ts","../src/utils/prefers-color-scheme.ts"],"sourcesContent":["/**\n * Converts pixel values to numbers.\n *\n * @param px - The pixel value to convert. Can be a number or string (e.g. '16px' or '16')\n * @returns The numeric value\n *\n * @example\n * ```ts\n * px2num(16) // 16\n * px2num('32px') // 32\n * px2num('12.5px') // 12.5\n * px2num('0px') // 0\n * ```\n */\nexport function px2num(px: number | string | undefined): number {\n\treturn typeof px === 'string' ? Number.parseFloat(px.replace(/px$/, '')) : Number(px)\n}\n","/**\n * Converts pixel values to rem units.\n *\n * @param px - The pixel value to convert. Can be a number or string (e.g. '16px' or '16')\n * @param options - Optional configuration\n * @param options.base - Base pixel value to calculate rem units from. Defaults to 16\n * @param options.precision - Number of decimal places in the output. Defaults to 4\n * @returns The converted value as a string with 'rem' units\n *\n * @example\n * ```ts\n * px2rem(16) // '1.0000'\n * px2rem('32px') // '2.0000'\n * px2rem(20, { base: 20 }) // '1.0000'\n * px2rem(13, { precision: 2 }) // '0.81'\n * ```\n */\nexport function px2rem(\n\tpx: number | string,\n\toptions?: { base?: number | undefined; precision?: number | undefined },\n): number {\n\tconst { base = 16, precision = 4 } = options ?? {}\n\n\tif (typeof px === 'string') {\n\t\tpx = px.replace(/px$/, '')\n\t\tpx = Number.parseFloat(px)\n\t}\n\n\treturn Number((px / base).toFixed(precision))\n}\n","/**\n * Converts rem values to pixel units.\n *\n * @param rem - The rem value to convert. Can be a number or string (e.g. '1rem' or '1')\n * @param options - Optional configuration\n * @param options.base - Base pixel value to calculate pixels from. Defaults to 16\n * @param options.precision - Number of decimal places in the output. Defaults to 4\n * @returns The converted value as a string with 'px' units\n *\n * @example\n * ```ts\n * rem2px(1) // '16.0000'\n * rem2px('2rem') // '32.0000'\n * rem2px(1, { base: 20 }) // '20.0000'\n * rem2px(0.8125, { precision: 2 }) // '13.00'\n * ```\n */\nexport function rem2px(\n\trem: number | string,\n\toptions?: { base?: number | undefined; precision?: number | undefined },\n): number {\n\tconst { base = 16, precision = 4 } = options ?? {}\n\n\tif (typeof rem === 'string') {\n\t\trem = rem.replace(/rem$/, '')\n\t\trem = Number.parseFloat(rem)\n\t}\n\n\treturn Number((rem * base).toFixed(precision))\n}\n","import type { Properties as CSSTypeProperties } from 'csstype'\n\n/** Custom CSS properties (variables) with `--` prefix. */\ntype CustomProperties = { [k: `--${string}`]: string }\n\n/**\n * Widens CSS properties to support custom properties.\n * Allows for string or number values for standard properties,\n * and string values for custom properties with '--' prefix.\n * Defined as a union so plain Properties (e.g. from React) are assignable.\n */\nexport interface CSSProperties<TLength = string | number, TTime = string & {}>\n\textends CSSTypeProperties<TLength, TTime>,\n\t\tCustomProperties {}\n\n/**\n * Defines CSS properties including custom properties.\n * This function is used to properly type CSS properties when defining styles,\n * especially when using CSS custom properties (variables).\n *\n * @deprecated Use `defineProperties` instead.\n *\n * @param style - CSS properties object that can include both standard and custom properties\n * @returns The same style object with proper typing\n *\n * @example\n * ```ts\n * defineCSSProperties({\n * color: 'red',\n * '--custom-color': '#ff0000'\n * })\n * ```\n */\nexport function defineCSSProperties(style: CSSProperties) {\n\treturn style as any\n}\n","import type { Properties as CSSTypeProperties } from 'csstype'\n\n/** Custom CSS properties (variables) with `--` prefix. */\ntype CustomProperties = { [k: `--${string}`]: string }\n\n/**\n * Extends CSS properties to include custom properties.\n * Allows for string or number values for standard properties,\n * and string values for custom properties with '--' prefix.\n */\nexport interface Properties<TLength = 0 | (string & {}), TTime = string & {}>\n\textends CSSTypeProperties<TLength, TTime>,\n\t\tCustomProperties {}\n\n/**\n * Defines CSS properties including custom properties.\n * This function is used to properly type CSS properties when defining styles,\n * especially when using CSS custom properties (variables).\n *\n * @param style - CSS properties object that can include both standard and custom properties\n * @returns The same style object with proper typing\n *\n * @example\n * ```ts\n * defineCSSProperties({\n * color: 'red',\n * '--custom-color': '#ff0000'\n * })\n * ```\n */\nexport function defineProperties<TLength = 0 | (string & {}), TTime = string & {}>(style: Properties<TLength, TTime>) {\n\treturn style as Properties\n}\n","import type { CSSProperties } from './css_properties.ts'\n\n/**\n * Converts React-style CSS properties to DOM style properties.\n * This function handles both standard CSS properties and custom properties,\n * ensuring proper formatting for DOM style application.\n *\n * @param style - React-style CSS properties object\n * @returns CSSStyleDeclaration compatible object for DOM style application\n *\n * @example\n * ```ts\n * const domStyle = toDOMStyle({\n * backgroundColor: 'red',\n * '--custom-color': '#ff0000'\n * })\n * element.style = domStyle\n * ```\n */\nexport function toDOMStyle(style: CSSProperties | undefined): Partial<CSSStyleDeclaration> | undefined {\n\tif (style === undefined) return undefined\n\n\tconst result = {} as any\n\n\tfor (const [key, value] of Object.entries(style)) {\n\t\tresult[key.startsWith('--') ? key : key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)] = value\n\t}\n\n\treturn result\n}\n","export const ctx = {\n\tmatchMedia(query: string) {\n\t\treturn globalThis.matchMedia(query)\n\t},\n\tgetDocumentElement() {\n\t\treturn globalThis.document.documentElement\n\t},\n\t_reset() {\n\t\tthis.matchMedia = globalThis.matchMedia\n\t\tthis.getDocumentElement = () => globalThis.document.documentElement\n\t},\n}\n","import { ctx } from '../globals.ctx.ts'\n\n/**\n * Gets the value of an attribute from an element.\n *\n * @param qualifiedName - The name of the attribute to get\n * @param element - The element to get the attribute from. Defaults to `document.documentElement`\n * @returns The attribute value cast to type T, or null if the attribute doesn't exist\n *\n * @example\n * ```ts\n * // Get theme from document root\n * const theme = getAttribute('data-theme')\n *\n * // Get data-testid from a specific element\n * const testId = getAttribute('data-testid', element)\n * ```\n */\nexport function getAttribute<T extends string>(\n\tqualifiedName: T,\n\telement: Element | undefined = ctx.getDocumentElement(),\n) {\n\treturn element?.getAttribute(qualifiedName)\n}\n\n/**\n * Observes attributes changes on an element and calls corresponding handlers.\n *\n * @param handlers - An object mapping attribute names to handler functions.\n * @param element - The element to observe. Defaults to `document.documentElement`.\n * @returns {MutationObserver} The observer instance, which can be used to disconnect the observer.\n *\n * @example\n * ```ts\n * const observer = observeAttributes({\n * 'data-theme': (attr, value) => console.log(`Theme changed to: ${value}`),\n * 'class': (attr, value) => console.log(`class changed to: ${value}`)\n * });\n *\n * // Later, to stop observing:\n * observer.disconnect();\n * ```\n */\nexport function observeAttributes<T extends string>(\n\thandlers: Record<string, (value: T | null) => void>,\n\telement: Element | undefined = ctx.getDocumentElement(),\n) {\n\tconst observer = new MutationObserver((mutations) => {\n\t\tfor (const mutation of mutations) {\n\t\t\tconst attribute = mutation.attributeName!\n\t\t\tconst value = element.getAttribute(attribute) as T | null\n\t\t\thandlers[attribute]?.(value)\n\t\t}\n\t})\n\tobserver.observe(element, {\n\t\tattributes: true,\n\t\tattributeFilter: Object.keys(handlers),\n\t})\n\treturn observer\n}\n","import { findKey } from 'type-plus'\nimport { ctx } from '../globals.ctx.ts'\nimport { observeAttributes } from '../utils/attribute.ts'\n\n/**\n * Gets the current theme by checking element class names against a themes map.\n *\n * @param options - Configuration options\n * @param options.themes - Record mapping theme keys to their class name values\n * @param options.defaultTheme - Fallback theme key if no matching class is found\n * @param options.element - Element to check classes on (defaults to document.documentElement)\n * @returns The matching theme key or defaultTheme if no match found\n *\n * @example\n * ```ts\n * const themes = {\n * light: 'theme-light',\n * dark: 'theme-dark'\n * }\n *\n * // Get current theme from document.documentElement\n * const theme = getThemeByClassName({\n * themes,\n * defaultTheme: 'light'\n * })\n *\n * // Get theme from specific element\n * const theme = getThemeByClassName({\n * themes,\n * element: myElement,\n * defaultTheme: 'light'\n * })\n * ```\n */\nexport function getThemeByClassName<Themes extends Record<string, string>>(options: {\n\tthemes: Themes\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): keyof Themes | undefined {\n\tconst element = options.element ?? ctx.getDocumentElement()\n\tconst className = element.className\n\tconst theme = findKey(options.themes, (theme) => className.includes(options.themes[theme]!))\n\treturn theme ?? options.defaultTheme\n}\n\nexport function observeThemeByClassName<Themes extends Record<string, string>>(options: {\n\tthemes: Themes\n\thandler: (value: string | undefined) => void\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}) {\n\treturn observeAttributes(\n\t\t{\n\t\t\tclass: (value: string | null) => {\n\t\t\t\tif (value === null) {\n\t\t\t\t\toptions.handler(options.defaultTheme as string)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tfor (const name in options.themes) {\n\t\t\t\t\tif (value.includes(options.themes[name]!)) {\n\t\t\t\t\t\toptions.handler(name)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\toptions.element,\n\t)\n}\n","import { ctx } from '../globals.ctx.ts'\nimport { getAttribute, observeAttributes } from './attribute.ts'\n\nexport function getDataAttribute<T extends `data-${string}`>(\n\tqualifiedName: T,\n\telement: Element | undefined = ctx.getDocumentElement(),\n) {\n\treturn getAttribute(qualifiedName, element)\n}\n\n/**\n * Observes changes to `data-*` attributes on an element and calls corresponding handlers.\n *\n * @param options - Configuration options\n * @param options.handlers - An object mapping `data-*` attribute names to handler functions.\n * @param options.element - The element to observe. Defaults to `document.documentElement`\n * @returns {MutationObserver} The observer instance, which can be used to disconnect the observer\n *\n * @example\n * ```ts\n * const observer = observeDataAttributes({\n * handlers: {\n * 'data-theme': (value) => console.log(`Theme changed to: ${value}`),\n * 'data-mode': (value) => console.log(`Mode changed to: ${value}`)\n * }\n * });\n *\n * // Later, to stop observing:\n * observer.disconnect();\n * ```\n */\nexport function observeDataAttributes<T extends string, K extends `data-${string}`>(\n\thandlers: Record<K, (value: T | null) => void>,\n\telement?: Element | undefined,\n) {\n\treturn observeAttributes(handlers, element)\n}\n","import { findKey } from 'type-plus'\nimport { getDataAttribute, observeDataAttributes } from '../utils/data-attribute.ts'\n\n/**\n * Gets the theme based on a data attribute value.\n *\n * @param options - Configuration options\n * @param options.themes - Record mapping theme keys to their data attribute values\n * @param options.defaultTheme - Fallback theme key if attribute value doesn't match any theme\n * @param options.attributeName - Name of the data attribute to check (must start with 'data-')\n * @param options.allowCustom - Whether to allow custom themes value\n * @returns The matching theme key, or defaultTheme if no match found\n *\n * @example\n * ```ts\n * const themes = {\n * light: 'light',\n * dark: 'dark',\n * system: 'system'\n * }\n *\n * // Get theme from data-theme attribute\n * const theme = getThemeByDataAttribute({\n * themes,\n * defaultTheme: 'system',\n * attributeName: 'data-theme'\n * })\n * ```\n */\nexport function getThemeByDataAttribute<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tdefaultTheme?: keyof Themes | undefined\n\tthemes: Themes\n\telement?: Element | undefined\n}): keyof Themes | undefined\nexport function getThemeByDataAttribute<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tallowCustom: true | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\tthemes: Themes\n\telement?: Element | undefined\n}): string | undefined\nexport function getThemeByDataAttribute<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tallowCustom?: boolean | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\tthemes: Themes\n\telement?: Element | undefined\n}): keyof Themes | undefined {\n\tconst value = getDataAttribute(options.attributeName, options.element) ?? undefined\n\tconst theme = findKey(options.themes, (theme) => options.themes[theme] === value)\n\n\treturn theme ?? options.defaultTheme ?? (options.allowCustom ? value : undefined)\n}\n\n/**\n * Observes changes to a theme data attribute and calls a handler when it changes.\n *\n * @param options - Configuration options\n * @param options.themes - Record mapping theme keys to their data attribute values\n * @param options.handler - Callback function called with the new theme value or null when removed\n * @param options.defaultTheme - Fallback theme key if attribute value doesn't match any theme\n * @param options.attributeName - Name of the data attribute to observe (must start with 'data-')\n * @returns A MutationObserver that can be disconnected to stop observing\n *\n * @example\n * ```ts\n * const themes = {\n * light: 'light',\n * dark: 'dark'\n * }\n *\n * // Observe data-theme attribute changes\n * const observer = observeThemeByDataAttributes({\n * themes,\n * handler: (theme) => console.log('Theme changed to:', theme),\n * defaultTheme: 'light',\n * attributeName: 'data-theme'\n * })\n *\n * // Stop observing\n * observer.disconnect()\n * ```\n */\nexport function observeThemeByDataAttributes<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tthemes: Themes\n\thandler: (value: string | null) => void\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): MutationObserver\nexport function observeThemeByDataAttributes<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tthemes: Themes\n\thandler: (value: string | null) => void\n\tallowCustom: true | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): MutationObserver\nexport function observeThemeByDataAttributes<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tthemes: Themes\n\thandler: (value: string | null) => void\n\tallowCustom?: boolean | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): MutationObserver {\n\treturn observeDataAttributes(\n\t\t{\n\t\t\t[options.attributeName]: (value: string | null) => {\n\t\t\t\tif (value === null) {\n\t\t\t\t\toptions.handler((options.defaultTheme as string) ?? null)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tfor (const name in options.themes) {\n\t\t\t\t\tif (options.themes[name] === value) {\n\t\t\t\t\t\toptions.handler(name)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (options.allowCustom) {\n\t\t\t\t\toptions.handler(value)\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\toptions.element,\n\t)\n}\n","import type { CreateTuple } from 'type-plus'\n\n/**\n * Retrieves CSS custom property values from the specified element.\n *\n * @param element - The HTML element to get property values from\n * @param props - CSS custom property names to retrieve, must be in the format `--property-name`\n * @returns Array of property values corresponding to the requested custom properties\n */\nexport function getCSSPropValues<Props extends Array<`--${string}`>>(\n\telement: HTMLElement,\n\t...props: Props\n): CreateTuple<Props['length'], string>\n/**\n * Retrieves CSS custom property values from `document.body`.\n *\n * @param props - CSS custom property names to retrieve, must be in the format `--property-name`\n * @returns Array of property values corresponding to the requested custom properties\n */\nexport function getCSSPropValues<Props extends Array<`--${string}`>>(\n\t...props: Props\n): CreateTuple<Props['length'], string>\nexport function getCSSPropValues<Props extends Array<`--${string}`>>(element: unknown, ...props: Props) {\n\tif (typeof element === 'string') {\n\t\treturn getCSSPropValues(globalThis.document.body, element as `--${string}`, ...props)\n\t}\n\tconst style = globalThis.getComputedStyle(element as HTMLElement)\n\treturn props.map((v) => style.getPropertyValue(v)) as any\n}\n","import { mapKey } from 'type-plus'\nimport { ctx } from '../globals.ctx.ts'\n\n/**\n * Observes system color scheme preference changes and calls handlers when they occur.\n *\n * @param themes - An object mapping theme names to handler functions that are called when that theme is activated\n * @returns A cleanup function that removes all event listeners\n *\n * @example\n * ```ts\n * // Observe light/dark mode changes\n * const cleanup = observePrefersColorScheme({\n * light: (theme) => console.log('Light mode activated'),\n * dark: (theme) => console.log('Dark mode activated')\n * })\n *\n * // Later, to stop observing:\n * cleanup()\n * ```\n */\nexport function observePrefersColorScheme<T extends string>(themes: Record<T, (value: T | null) => void>) {\n\tconst removers = mapKey(themes, (t) => {\n\t\tconst m = ctx.matchMedia(`(prefers-color-scheme: ${t as string})`)\n\t\tconst listener = (event: MediaQueryListEvent) => {\n\t\t\tif (event.matches) {\n\t\t\t\tthemes[t]?.(t)\n\t\t\t}\n\t\t}\n\n\t\tm.addEventListener('change', listener)\n\t\treturn () => m.removeEventListener('change', listener)\n\t})\n\n\treturn () => {\n\t\tfor (const remover of removers) {\n\t\t\tremover()\n\t\t}\n\t}\n}\n\n/**\n * Gets the current preferred color theme from the system settings.\n *\n * @param themes - A list of theme names to check against the system preference\n * @returns The first matching theme from the provided list, or null if none match\n *\n * @example\n * ```ts\n * // Check if system prefers light or dark mode\n * const theme = getPrefersColorTheme('light', 'dark')\n * // Returns 'light', 'dark', or null\n * ```\n */\nexport function getPrefersColorTheme<T extends string>(...themes: T[]) {\n\treturn themes.find((theme) => ctx.matchMedia(`(prefers-color-scheme: ${theme})`).matches) ?? null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAcA,SAAgB,OAAO,IAAyC;AAC/D,QAAO,OAAO,OAAO,WAAW,OAAO,WAAW,GAAG,QAAQ,OAAO,GAAG,CAAC,GAAG,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;ACEtF,SAAgB,OACf,IACA,SACS;CACT,MAAM,EAAE,OAAO,IAAI,YAAY,MAAM,WAAW,EAAE;AAElD,KAAI,OAAO,OAAO,UAAU;AAC3B,OAAK,GAAG,QAAQ,OAAO,GAAG;AAC1B,OAAK,OAAO,WAAW,GAAG;;AAG3B,QAAO,QAAQ,KAAK,MAAM,QAAQ,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;ACX9C,SAAgB,OACf,KACA,SACS;CACT,MAAM,EAAE,OAAO,IAAI,YAAY,MAAM,WAAW,EAAE;AAElD,KAAI,OAAO,QAAQ,UAAU;AAC5B,QAAM,IAAI,QAAQ,QAAQ,GAAG;AAC7B,QAAM,OAAO,WAAW,IAAI;;AAG7B,QAAO,QAAQ,MAAM,MAAM,QAAQ,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;ACK/C,SAAgB,oBAAoB,OAAsB;AACzD,QAAO;;;;;;;;;;;;;;;;;;;;;ACJR,SAAgB,iBAAmE,OAAmC;AACrH,QAAO;;;;;;;;;;;;;;;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;AAChD,OAAI,MAAM,QACT,QAAO,KAAK,EAAE;;AAIhB,IAAE,iBAAiB,UAAU,SAAS;AACtC,eAAa,EAAE,oBAAoB,UAAU,SAAS;GACrD;AAEF,cAAa;AACZ,OAAK,MAAM,WAAW,SACrB,UAAS;;;;;;;;;;;;;;;;AAkBZ,SAAgB,qBAAuC,GAAG,QAAa;AACtE,QAAO,OAAO,MAAM,UAAU,IAAI,WAAW,0BAA0B,MAAM,GAAG,CAAC,QAAQ,IAAI"}
package/cjs/index.d.cts CHANGED
@@ -77,7 +77,7 @@ type CustomProperties$1 = {
77
77
  * and string values for custom properties with '--' prefix.
78
78
  * Defined as a union so plain Properties (e.g. from React) are assignable.
79
79
  */
80
- type CSSProperties<TLength = string | number, TTime = string & {}> = Properties$1<TLength, TTime> | (Properties$1<TLength, TTime> & CustomProperties$1);
80
+ interface CSSProperties<TLength = string | number, TTime = string & {}> extends Properties$1<TLength, TTime>, CustomProperties$1 {}
81
81
  /**
82
82
  * Defines CSS properties including custom properties.
83
83
  * This function is used to properly type CSS properties when defining styles,
@@ -108,7 +108,7 @@ type CustomProperties = {
108
108
  * Allows for string or number values for standard properties,
109
109
  * and string values for custom properties with '--' prefix.
110
110
  */
111
- type Properties<TLength = 0 | (string & {}), TTime = string & {}> = Properties$1<TLength, TTime> | (Properties$1<TLength, TTime> & CustomProperties);
111
+ interface Properties<TLength = 0 | (string & {}), TTime = string & {}> extends Properties$1<TLength, TTime>, CustomProperties {}
112
112
  /**
113
113
  * Defines CSS properties including custom properties.
114
114
  * This function is used to properly type CSS properties when defining styles,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/convertors/px_2_num.ts","../src/convertors/px_2_rem.ts","../src/convertors/rem_2_px.ts","../src/properties/css_properties.ts","../src/properties/properties.ts","../src/properties/to_dom_style.ts","../src/props/class-name.ts","../src/props/style.ts","../src/theme/class-name.ts","../src/theme/data-attribute.ts","../src/utils/attribute.ts","../src/utils/data-attribute.ts","../src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AAW9D;;;AACG,iBQmBa,qBRnBb,CAAA,UAAA,MAAA,EAAA,UAAA,QAAA,MAAA,EAAA,CAAA,CAAA,QAAA,EQoBQ,MRpBR,CQoBe,CRpBf,EAAA,CAAA,KAAA,EQoB0B,CRpB1B,GAAA,IAAA,EAAA,GAAA,IAAA,CAAA,EAAA,OAAA,CAAA,EQqBQ,ORrBR,GAAA,SAAA,CAAA,EQqB2B,gBRrB3B;;;;;;;;AHEH;;iBYLgB,+BAA+B,+BACrC,uBACC,QACR,YAAY;;AXKf;;;;ACAA;iBUEgB,+BAA+B,gCACpC,QACR,YAAY;;;;;;;;;AZPf;;;;ACGA;;;;ACAA;;;;ACdK,iBUkBW,yBVlBK,CAAA,UAAA,MAAA,CAAA,CAAA,MAAA,EUkB+C,MVlB/C,CUkBsD,CVlBtD,EAAA,CAAA,KAAA,EUkBiE,CVlBjE,GAAA,IAAA,EAAA,GAAA,IAAA,CAAA,CAAA,EAAA,GAAA,GAAA,IAAA;AAQrB;;;;;;;;;AAsBA;;;;AC9BK,iBSmDW,oBTnDK,CAAA,UAAA,MAAA,CAAA,CAAA,GAAA,MAAA,ESmD6C,CTnD7C,EAAA,CAAA,ESmDgD,CTnDhD,GAAA,IAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/convertors/px_2_num.ts","../src/convertors/px_2_rem.ts","../src/convertors/rem_2_px.ts","../src/properties/css_properties.ts","../src/properties/properties.ts","../src/properties/to_dom_style.ts","../src/props/class-name.ts","../src/props/style.ts","../src/theme/class-name.ts","../src/theme/data-attribute.ts","../src/utils/attribute.ts","../src/utils/data-attribute.ts","../src/utils/get-css-prop-values.ts","../src/utils/prefers-color-scheme.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;AAcA;;;;ACGA;;;;ACAgB,iBFHA,MAAA,CEGM,EAAA,EAAA,MAAA,GAAA,MAAA,GAAA,SAAA,CAAA,EAAA,MAAA;;;;;;;;;AFHtB;;;;ACGA;;;;ACAA;;;iBDAg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ACAA;iBUEgB,+BAA+B,gCACpC,QACR,YAAY;;;;;;;;;AZPf;;;;ACGA;;;;ACAA;;;;ACdK,iBUkBW,yBVlBK,CAAA,UAAA,MAAA,CAAA,CAAA,MAAA,EUkB+C,MVlB/C,CUkBsD,CVlBtD,EAAA,CAAA,KAAA,EUkBiE,CVlBjE,GAAA,IAAA,EAAA,GAAA,IAAA,CAAA,CAAA,EAAA,GAAA,GAAA,IAAA;AAQrB;;;;;;AAsBA;;;;ACjC8D;AAU9D;;AACoC,iBS2CpB,oBT3CoB,CAAA,UAAA,MAAA,CAAA,CAAA,GAAA,MAAA,ES2C8B,CT3C9B,EAAA,CAAA,ES2CiC,CT3CjC,GAAA,IAAA"}
package/esm/index.d.mts CHANGED
@@ -77,7 +77,7 @@ type CustomProperties$1 = {
77
77
  * and string values for custom properties with '--' prefix.
78
78
  * Defined as a union so plain Properties (e.g. from React) are assignable.
79
79
  */
80
- type CSSProperties<TLength = string | number, TTime = string & {}> = Properties$1<TLength, TTime> | (Properties$1<TLength, TTime> & CustomProperties$1);
80
+ interface CSSProperties<TLength = string | number, TTime = string & {}> extends Properties$1<TLength, TTime>, CustomProperties$1 {}
81
81
  /**
82
82
  * Defines CSS properties including custom properties.
83
83
  * This function is used to properly type CSS properties when defining styles,
@@ -108,7 +108,7 @@ type CustomProperties = {
108
108
  * Allows for string or number values for standard properties,
109
109
  * and string values for custom properties with '--' prefix.
110
110
  */
111
- type Properties<TLength = 0 | (string & {}), TTime = string & {}> = Properties$1<TLength, TTime> | (Properties$1<TLength, TTime> & CustomProperties);
111
+ interface Properties<TLength = 0 | (string & {}), TTime = string & {}> extends Properties$1<TLength, TTime>, CustomProperties {}
112
112
  /**
113
113
  * Defines CSS properties including custom properties.
114
114
  * This function is used to properly type CSS properties when defining styles,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/convertors/px_2_num.ts","../src/convertors/px_2_rem.ts","../src/convertors/rem_2_px.ts","../src/properties/css_properties.ts","../src/properties/properties.ts","../src/properties/to_dom_style.ts","../src/props/class-name.ts","../src/props/style.ts","../src/theme/class-name.ts","../src/theme/data-attribute.ts","../src/utils/attribute.ts","../src/utils/data-attribute.ts","../src/utils/get-css-prop-values.ts","../src/utils/prefers-color-scheme.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;AAcA;;;;ACGA;;;;ACAgB,iBFHA,MAAA,CEGM,EAAA,EAAA,MAAA,GAAA,MAAA,GAAA,SAAA,CAAA,EAAA,MAAA;;;;;;;;;AFHtB;;;;ACGA;;;;ACAA;;;iBDAgB,MAAA,6BELK;EAThB,IAAA,CAAA,EAAA,MAAA,GAAA,SAAgB;EAQT,SAAA,CAAA,EAAA,MAAa,GAAA,SAAA;CACJ,CAAA,EAAA,MAAA;;;;;;;;;AHErB;;;;ACGA;;;;ACAA;;;iBAAgB,MAAA,8BCLK;EAThB,IAAA,CAAA,EAAA,MAAA,GAAA,SAAgB;EAQT,SAAA,CAAA,EAAA,MAAa,GAAA,SAAA;CACJ,CAAA,EAAA,MAAA;;;;KAThB,kBAAA;;;;AHWL;;;;ACGA;KENY,gEACT,aAAkB,SAAS,UAC1B,aAAkB,SAAS,SAAS;;;ADIxC;;;;ACjB8D;AAW9D;;;;;;;;;AAsBA;;iBAAgB,mBAAA,QAA2B;;;;KC9BtC,gBAAA;;;;AJWL;;;;ACGgB,KGPJ,UHOU,CAAA,UAAA,CAAA,GAAA,CAAA,MAAA,GAAA,CAAA,CAAA,CAAA,EAAA,QAAA,MAAA,GAAA,CAAA,CAAA,CAAA,GGNnB,YHMmB,CGND,OHMC,EGNQ,KHMR,CAAA,GAAA,CGLlB,YHKkB,CGLA,OHKA,EGLS,KHKT,CAAA,GGLkB,gBHKlB,CAAA;;;;ACAtB;;;;ACjB8D;AAW9D;;;;;;;;AAEwD,iBCiBxC,gBDjBwC,CAAA,UAAA,CAAA,GAAA,CAAA,MAAA,GAAA,CAAA,CAAA,CAAA,EAAA,QAAA,MAAA,GAAA,CAAA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AA,OAAA,CAAA,EMkCpB,ONlCoB,GAAA,SAAA,CAAA,EMkC0B,gBNlC1B;;;iBORd,4DACA,aACN;;;;;;AXSV;;;;ACGA;;;;ACAA;;;;ACjB8D;AAW9D;;;AACG,iBQmBa,qBRnBb,CAAA,UAAA,MAAA,EAAA,UAAA,QAAA,MAAA,EAAA,CAAA,CAAA,QAAA,EQoBQ,MRpBR,CQoBe,CRpBf,EAAA,CAAA,KAAA,EQoB0B,CRpB1B,GAAA,IAAA,EAAA,GAAA,IAAA,CAAA,EAAA,OAAA,CAAA,EQqBQ,ORrBR,GAAA,SAAA,CAAA,EQqB2B,gBRrB3B;;;;;;;;AHEH;;iBYLgB,+BAA+B,+BACrC,uBACC,QACR,YAAY;;AXKf;;;;ACAA;iBUEgB,+BAA+B,gCACpC,QACR,YAAY;;;;;;;;;AZPf;;;;ACGA;;;;ACAA;;;;ACdK,iBUkBW,yBVlBK,CAAA,UAAA,MAAA,CAAA,CAAA,MAAA,EUkB+C,MVlB/C,CUkBsD,CVlBtD,EAAA,CAAA,KAAA,EUkBiE,CVlBjE,GAAA,IAAA,EAAA,GAAA,IAAA,CAAA,CAAA,EAAA,GAAA,GAAA,IAAA;AAQrB;;;;;;;;;AAsBA;;;;AC9BK,iBSmDW,oBTnDK,CAAA,UAAA,MAAA,CAAA,CAAA,GAAA,MAAA,ESmD6C,CTnD7C,EAAA,CAAA,ESmDgD,CTnDhD,GAAA,IAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/convertors/px_2_num.ts","../src/convertors/px_2_rem.ts","../src/convertors/rem_2_px.ts","../src/properties/css_properties.ts","../src/properties/properties.ts","../src/properties/to_dom_style.ts","../src/props/class-name.ts","../src/props/style.ts","../src/theme/class-name.ts","../src/theme/data-attribute.ts","../src/utils/attribute.ts","../src/utils/data-attribute.ts","../src/utils/get-css-prop-values.ts","../src/utils/prefers-color-scheme.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;AAcA;;;;ACGA;;;;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,OAAA,CAAA,EQqBE,ORrBF,GAAA,SAAA,CAAA,EQqBqB,gBRrBrB;;;;;;;;AHET;;iBYLgB,+BAA+B,+BACrC,uBACC,QACR,YAAY;;AXKf;;;;ACAA;iBUEgB,+BAA+B,gCACpC,QACR,YAAY;;;;;;;;;AZPf;;;;ACGA;;;;ACAA;;;;ACdK,iBUkBW,yBVlBK,CAAA,UAAA,MAAA,CAAA,CAAA,MAAA,EUkB+C,MVlB/C,CUkBsD,CVlBtD,EAAA,CAAA,KAAA,EUkBiE,CVlBjE,GAAA,IAAA,EAAA,GAAA,IAAA,CAAA,CAAA,EAAA,GAAA,GAAA,IAAA;AAQrB;;;;;;AAsBA;;;;ACjC8D;AAU9D;;AACoC,iBS2CpB,oBT3CoB,CAAA,UAAA,MAAA,CAAA,CAAA,GAAA,MAAA,ES2C8B,CT3C9B,EAAA,CAAA,ES2CiC,CT3CjC,GAAA,IAAA"}
package/esm/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/convertors/px_2_num.ts","../src/convertors/px_2_rem.ts","../src/convertors/rem_2_px.ts","../src/properties/css_properties.ts","../src/properties/properties.ts","../src/properties/to_dom_style.ts","../src/globals.ctx.ts","../src/utils/attribute.ts","../src/theme/class-name.ts","../src/utils/data-attribute.ts","../src/theme/data-attribute.ts","../src/utils/get-css-prop-values.ts","../src/utils/prefers-color-scheme.ts"],"sourcesContent":["/**\n * Converts pixel values to numbers.\n *\n * @param px - The pixel value to convert. Can be a number or string (e.g. '16px' or '16')\n * @returns The numeric value\n *\n * @example\n * ```ts\n * px2num(16) // 16\n * px2num('32px') // 32\n * px2num('12.5px') // 12.5\n * px2num('0px') // 0\n * ```\n */\nexport function px2num(px: number | string | undefined): number {\n\treturn typeof px === 'string' ? Number.parseFloat(px.replace(/px$/, '')) : Number(px)\n}\n","/**\n * Converts pixel values to rem units.\n *\n * @param px - The pixel value to convert. Can be a number or string (e.g. '16px' or '16')\n * @param options - Optional configuration\n * @param options.base - Base pixel value to calculate rem units from. Defaults to 16\n * @param options.precision - Number of decimal places in the output. Defaults to 4\n * @returns The converted value as a string with 'rem' units\n *\n * @example\n * ```ts\n * px2rem(16) // '1.0000'\n * px2rem('32px') // '2.0000'\n * px2rem(20, { base: 20 }) // '1.0000'\n * px2rem(13, { precision: 2 }) // '0.81'\n * ```\n */\nexport function px2rem(\n\tpx: number | string,\n\toptions?: { base?: number | undefined; precision?: number | undefined },\n): number {\n\tconst { base = 16, precision = 4 } = options ?? {}\n\n\tif (typeof px === 'string') {\n\t\tpx = px.replace(/px$/, '')\n\t\tpx = Number.parseFloat(px)\n\t}\n\n\treturn Number((px / base).toFixed(precision))\n}\n","/**\n * Converts rem values to pixel units.\n *\n * @param rem - The rem value to convert. Can be a number or string (e.g. '1rem' or '1')\n * @param options - Optional configuration\n * @param options.base - Base pixel value to calculate pixels from. Defaults to 16\n * @param options.precision - Number of decimal places in the output. Defaults to 4\n * @returns The converted value as a string with 'px' units\n *\n * @example\n * ```ts\n * rem2px(1) // '16.0000'\n * rem2px('2rem') // '32.0000'\n * rem2px(1, { base: 20 }) // '20.0000'\n * rem2px(0.8125, { precision: 2 }) // '13.00'\n * ```\n */\nexport function rem2px(\n\trem: number | string,\n\toptions?: { base?: number | undefined; precision?: number | undefined },\n): number {\n\tconst { base = 16, precision = 4 } = options ?? {}\n\n\tif (typeof rem === 'string') {\n\t\trem = rem.replace(/rem$/, '')\n\t\trem = Number.parseFloat(rem)\n\t}\n\n\treturn Number((rem * base).toFixed(precision))\n}\n","import type { Properties as CSSTypeProperties } from 'csstype'\n\n/** Custom CSS properties (variables) with `--` prefix. */\ntype CustomProperties = { [k: `--${string}`]: string }\n\n/**\n * Widens CSS properties to support custom properties.\n * Allows for string or number values for standard properties,\n * and string values for custom properties with '--' prefix.\n * Defined as a union so plain Properties (e.g. from React) are assignable.\n */\nexport type CSSProperties<TLength = string | number, TTime = string & {}> =\n\t| CSSTypeProperties<TLength, TTime>\n\t| (CSSTypeProperties<TLength, TTime> & CustomProperties)\n\n/**\n * Defines CSS properties including custom properties.\n * This function is used to properly type CSS properties when defining styles,\n * especially when using CSS custom properties (variables).\n *\n * @deprecated Use `defineProperties` instead.\n *\n * @param style - CSS properties object that can include both standard and custom properties\n * @returns The same style object with proper typing\n *\n * @example\n * ```ts\n * defineCSSProperties({\n * color: 'red',\n * '--custom-color': '#ff0000'\n * })\n * ```\n */\nexport function defineCSSProperties(style: CSSProperties) {\n\treturn style as any\n}\n","import type { Properties as CSSTypeProperties } from 'csstype'\n\n/** Custom CSS properties (variables) with `--` prefix. */\ntype CustomProperties = { [k: `--${string}`]: string }\n\n/**\n * Extends CSS properties to include custom properties.\n * Allows for string or number values for standard properties,\n * and string values for custom properties with '--' prefix.\n */\nexport type Properties<TLength = 0 | (string & {}), TTime = string & {}> =\n\t| CSSTypeProperties<TLength, TTime>\n\t| (CSSTypeProperties<TLength, TTime> & CustomProperties)\n\n/**\n * Defines CSS properties including custom properties.\n * This function is used to properly type CSS properties when defining styles,\n * especially when using CSS custom properties (variables).\n *\n * @param style - CSS properties object that can include both standard and custom properties\n * @returns The same style object with proper typing\n *\n * @example\n * ```ts\n * defineCSSProperties({\n * color: 'red',\n * '--custom-color': '#ff0000'\n * })\n * ```\n */\nexport function defineProperties<TLength = 0 | (string & {}), TTime = string & {}>(style: Properties<TLength, TTime>) {\n\treturn style as Properties\n}\n","import type { CSSProperties } from './css_properties.ts'\n\n/**\n * Converts React-style CSS properties to DOM style properties.\n * This function handles both standard CSS properties and custom properties,\n * ensuring proper formatting for DOM style application.\n *\n * @param style - React-style CSS properties object\n * @returns CSSStyleDeclaration compatible object for DOM style application\n *\n * @example\n * ```ts\n * const domStyle = toDOMStyle({\n * backgroundColor: 'red',\n * '--custom-color': '#ff0000'\n * })\n * element.style = domStyle\n * ```\n */\nexport function toDOMStyle(style: CSSProperties | undefined): Partial<CSSStyleDeclaration> | undefined {\n\tif (style === undefined) return undefined\n\n\tconst result = {} as any\n\n\tfor (const [key, value] of Object.entries(style)) {\n\t\tresult[key.startsWith('--') ? key : key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)] = value\n\t}\n\n\treturn result\n}\n","export const ctx = {\n\tmatchMedia(query: string) {\n\t\treturn globalThis.matchMedia(query)\n\t},\n\tgetDocumentElement() {\n\t\treturn globalThis.document.documentElement\n\t},\n\t_reset() {\n\t\tthis.matchMedia = globalThis.matchMedia\n\t\tthis.getDocumentElement = () => globalThis.document.documentElement\n\t},\n}\n","import { ctx } from '../globals.ctx.ts'\n\n/**\n * Gets the value of an attribute from an element.\n *\n * @param qualifiedName - The name of the attribute to get\n * @param element - The element to get the attribute from. Defaults to `document.documentElement`\n * @returns The attribute value cast to type T, or null if the attribute doesn't exist\n *\n * @example\n * ```ts\n * // Get theme from document root\n * const theme = getAttribute('data-theme')\n *\n * // Get data-testid from a specific element\n * const testId = getAttribute('data-testid', element)\n * ```\n */\nexport function getAttribute<T extends string>(\n\tqualifiedName: T,\n\telement: Element | undefined = ctx.getDocumentElement(),\n) {\n\treturn element?.getAttribute(qualifiedName)\n}\n\n/**\n * Observes attributes changes on an element and calls corresponding handlers.\n *\n * @param handlers - An object mapping attribute names to handler functions.\n * @param element - The element to observe. Defaults to `document.documentElement`.\n * @returns {MutationObserver} The observer instance, which can be used to disconnect the observer.\n *\n * @example\n * ```ts\n * const observer = observeAttributes({\n * 'data-theme': (attr, value) => console.log(`Theme changed to: ${value}`),\n * 'class': (attr, value) => console.log(`class changed to: ${value}`)\n * });\n *\n * // Later, to stop observing:\n * observer.disconnect();\n * ```\n */\nexport function observeAttributes<T extends string>(\n\thandlers: Record<string, (value: T | null) => void>,\n\telement: Element | undefined = ctx.getDocumentElement(),\n) {\n\tconst observer = new MutationObserver((mutations) => {\n\t\tfor (const mutation of mutations) {\n\t\t\tconst attribute = mutation.attributeName!\n\t\t\tconst value = element.getAttribute(attribute) as T | null\n\t\t\thandlers[attribute]?.(value)\n\t\t}\n\t})\n\tobserver.observe(element, {\n\t\tattributes: true,\n\t\tattributeFilter: Object.keys(handlers),\n\t})\n\treturn observer\n}\n","import { findKey } from 'type-plus'\nimport { ctx } from '../globals.ctx.ts'\nimport { observeAttributes } from '../utils/attribute.ts'\n\n/**\n * Gets the current theme by checking element class names against a themes map.\n *\n * @param options - Configuration options\n * @param options.themes - Record mapping theme keys to their class name values\n * @param options.defaultTheme - Fallback theme key if no matching class is found\n * @param options.element - Element to check classes on (defaults to document.documentElement)\n * @returns The matching theme key or defaultTheme if no match found\n *\n * @example\n * ```ts\n * const themes = {\n * light: 'theme-light',\n * dark: 'theme-dark'\n * }\n *\n * // Get current theme from document.documentElement\n * const theme = getThemeByClassName({\n * themes,\n * defaultTheme: 'light'\n * })\n *\n * // Get theme from specific element\n * const theme = getThemeByClassName({\n * themes,\n * element: myElement,\n * defaultTheme: 'light'\n * })\n * ```\n */\nexport function getThemeByClassName<Themes extends Record<string, string>>(options: {\n\tthemes: Themes\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): keyof Themes | undefined {\n\tconst element = options.element ?? ctx.getDocumentElement()\n\tconst className = element.className\n\tconst theme = findKey(options.themes, (theme) => className.includes(options.themes[theme]!))\n\treturn theme ?? options.defaultTheme\n}\n\nexport function observeThemeByClassName<Themes extends Record<string, string>>(options: {\n\tthemes: Themes\n\thandler: (value: string | undefined) => void\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}) {\n\treturn observeAttributes(\n\t\t{\n\t\t\tclass: (value: string | null) => {\n\t\t\t\tif (value === null) {\n\t\t\t\t\toptions.handler(options.defaultTheme as string)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tfor (const name in options.themes) {\n\t\t\t\t\tif (value.includes(options.themes[name]!)) {\n\t\t\t\t\t\toptions.handler(name)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\toptions.element,\n\t)\n}\n","import { ctx } from '../globals.ctx.ts'\nimport { getAttribute, observeAttributes } from './attribute.ts'\n\nexport function getDataAttribute<T extends `data-${string}`>(\n\tqualifiedName: T,\n\telement: Element | undefined = ctx.getDocumentElement(),\n) {\n\treturn getAttribute(qualifiedName, element)\n}\n\n/**\n * Observes changes to `data-*` attributes on an element and calls corresponding handlers.\n *\n * @param options - Configuration options\n * @param options.handlers - An object mapping `data-*` attribute names to handler functions.\n * @param options.element - The element to observe. Defaults to `document.documentElement`\n * @returns {MutationObserver} The observer instance, which can be used to disconnect the observer\n *\n * @example\n * ```ts\n * const observer = observeDataAttributes({\n * handlers: {\n * 'data-theme': (value) => console.log(`Theme changed to: ${value}`),\n * 'data-mode': (value) => console.log(`Mode changed to: ${value}`)\n * }\n * });\n *\n * // Later, to stop observing:\n * observer.disconnect();\n * ```\n */\nexport function observeDataAttributes<T extends string, K extends `data-${string}`>(\n\thandlers: Record<K, (value: T | null) => void>,\n\telement?: Element | undefined,\n) {\n\treturn observeAttributes(handlers, element)\n}\n","import { findKey } from 'type-plus'\nimport { getDataAttribute, observeDataAttributes } from '../utils/data-attribute.ts'\n\n/**\n * Gets the theme based on a data attribute value.\n *\n * @param options - Configuration options\n * @param options.themes - Record mapping theme keys to their data attribute values\n * @param options.defaultTheme - Fallback theme key if attribute value doesn't match any theme\n * @param options.attributeName - Name of the data attribute to check (must start with 'data-')\n * @param options.allowCustom - Whether to allow custom themes value\n * @returns The matching theme key, or defaultTheme if no match found\n *\n * @example\n * ```ts\n * const themes = {\n * light: 'light',\n * dark: 'dark',\n * system: 'system'\n * }\n *\n * // Get theme from data-theme attribute\n * const theme = getThemeByDataAttribute({\n * themes,\n * defaultTheme: 'system',\n * attributeName: 'data-theme'\n * })\n * ```\n */\nexport function getThemeByDataAttribute<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tdefaultTheme?: keyof Themes | undefined\n\tthemes: Themes\n\telement?: Element | undefined\n}): keyof Themes | undefined\nexport function getThemeByDataAttribute<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tallowCustom: true | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\tthemes: Themes\n\telement?: Element | undefined\n}): string | undefined\nexport function getThemeByDataAttribute<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tallowCustom?: boolean | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\tthemes: Themes\n\telement?: Element | undefined\n}): keyof Themes | undefined {\n\tconst value = getDataAttribute(options.attributeName, options.element) ?? undefined\n\tconst theme = findKey(options.themes, (theme) => options.themes[theme] === value)\n\n\treturn theme ?? options.defaultTheme ?? (options.allowCustom ? value : undefined)\n}\n\n/**\n * Observes changes to a theme data attribute and calls a handler when it changes.\n *\n * @param options - Configuration options\n * @param options.themes - Record mapping theme keys to their data attribute values\n * @param options.handler - Callback function called with the new theme value or null when removed\n * @param options.defaultTheme - Fallback theme key if attribute value doesn't match any theme\n * @param options.attributeName - Name of the data attribute to observe (must start with 'data-')\n * @returns A MutationObserver that can be disconnected to stop observing\n *\n * @example\n * ```ts\n * const themes = {\n * light: 'light',\n * dark: 'dark'\n * }\n *\n * // Observe data-theme attribute changes\n * const observer = observeThemeByDataAttributes({\n * themes,\n * handler: (theme) => console.log('Theme changed to:', theme),\n * defaultTheme: 'light',\n * attributeName: 'data-theme'\n * })\n *\n * // Stop observing\n * observer.disconnect()\n * ```\n */\nexport function observeThemeByDataAttributes<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tthemes: Themes\n\thandler: (value: string | null) => void\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): MutationObserver\nexport function observeThemeByDataAttributes<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tthemes: Themes\n\thandler: (value: string | null) => void\n\tallowCustom: true | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): MutationObserver\nexport function observeThemeByDataAttributes<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tthemes: Themes\n\thandler: (value: string | null) => void\n\tallowCustom?: boolean | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): MutationObserver {\n\treturn observeDataAttributes(\n\t\t{\n\t\t\t[options.attributeName]: (value: string | null) => {\n\t\t\t\tif (value === null) {\n\t\t\t\t\toptions.handler((options.defaultTheme as string) ?? null)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tfor (const name in options.themes) {\n\t\t\t\t\tif (options.themes[name] === value) {\n\t\t\t\t\t\toptions.handler(name)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (options.allowCustom) {\n\t\t\t\t\toptions.handler(value)\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\toptions.element,\n\t)\n}\n","import type { CreateTuple } from 'type-plus'\n\n/**\n * Retrieves CSS custom property values from the specified element.\n *\n * @param element - The HTML element to get property values from\n * @param props - CSS custom property names to retrieve, must be in the format `--property-name`\n * @returns Array of property values corresponding to the requested custom properties\n */\nexport function getCSSPropValues<Props extends Array<`--${string}`>>(\n\telement: HTMLElement,\n\t...props: Props\n): CreateTuple<Props['length'], string>\n/**\n * Retrieves CSS custom property values from `document.body`.\n *\n * @param props - CSS custom property names to retrieve, must be in the format `--property-name`\n * @returns Array of property values corresponding to the requested custom properties\n */\nexport function getCSSPropValues<Props extends Array<`--${string}`>>(\n\t...props: Props\n): CreateTuple<Props['length'], string>\nexport function getCSSPropValues<Props extends Array<`--${string}`>>(element: unknown, ...props: Props) {\n\tif (typeof element === 'string') {\n\t\treturn getCSSPropValues(globalThis.document.body, element as `--${string}`, ...props)\n\t}\n\tconst style = globalThis.getComputedStyle(element as HTMLElement)\n\treturn props.map((v) => style.getPropertyValue(v)) as any\n}\n","import { mapKey } from 'type-plus'\nimport { ctx } from '../globals.ctx.ts'\n\n/**\n * Observes system color scheme preference changes and calls handlers when they occur.\n *\n * @param themes - An object mapping theme names to handler functions that are called when that theme is activated\n * @returns A cleanup function that removes all event listeners\n *\n * @example\n * ```ts\n * // Observe light/dark mode changes\n * const cleanup = observePrefersColorScheme({\n * light: (theme) => console.log('Light mode activated'),\n * dark: (theme) => console.log('Dark mode activated')\n * })\n *\n * // Later, to stop observing:\n * cleanup()\n * ```\n */\nexport function observePrefersColorScheme<T extends string>(themes: Record<T, (value: T | null) => void>) {\n\tconst removers = mapKey(themes, (t) => {\n\t\tconst m = ctx.matchMedia(`(prefers-color-scheme: ${t as string})`)\n\t\tconst listener = (event: MediaQueryListEvent) => {\n\t\t\tif (event.matches) {\n\t\t\t\tthemes[t]?.(t)\n\t\t\t}\n\t\t}\n\n\t\tm.addEventListener('change', listener)\n\t\treturn () => m.removeEventListener('change', listener)\n\t})\n\n\treturn () => {\n\t\tfor (const remover of removers) {\n\t\t\tremover()\n\t\t}\n\t}\n}\n\n/**\n * Gets the current preferred color theme from the system settings.\n *\n * @param themes - A list of theme names to check against the system preference\n * @returns The first matching theme from the provided list, or null if none match\n *\n * @example\n * ```ts\n * // Check if system prefers light or dark mode\n * const theme = getPrefersColorTheme('light', 'dark')\n * // Returns 'light', 'dark', or null\n * ```\n */\nexport function getPrefersColorTheme<T extends string>(...themes: T[]) {\n\treturn themes.find((theme) => ctx.matchMedia(`(prefers-color-scheme: ${theme})`).matches) ?? null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAcA,SAAgB,OAAO,IAAyC;AAC/D,QAAO,OAAO,OAAO,WAAW,OAAO,WAAW,GAAG,QAAQ,OAAO,GAAG,CAAC,GAAG,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;ACEtF,SAAgB,OACf,IACA,SACS;CACT,MAAM,EAAE,OAAO,IAAI,YAAY,MAAM,WAAW,EAAE;AAElD,KAAI,OAAO,OAAO,UAAU;AAC3B,OAAK,GAAG,QAAQ,OAAO,GAAG;AAC1B,OAAK,OAAO,WAAW,GAAG;;AAG3B,QAAO,QAAQ,KAAK,MAAM,QAAQ,UAAU,CAAC;;;;;;;;;;;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B,EACD,QAAQ,QACR;;;;;AC1GF,SAAgB,iBAAqD,SAAkB,GAAG,OAAc;AACvG,KAAI,OAAO,YAAY,SACtB,QAAO,iBAAiB,WAAW,SAAS,MAAM,SAA0B,GAAG,MAAM;CAEtF,MAAM,QAAQ,WAAW,iBAAiB,QAAuB;AACjE,QAAO,MAAM,KAAK,MAAM,MAAM,iBAAiB,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;ACNnD,SAAgB,0BAA4C,QAA8C;CACzG,MAAM,WAAW,OAAO,SAAS,MAAM;EACtC,MAAM,IAAI,IAAI,WAAW,0BAA0B,EAAY,GAAG;EAClE,MAAM,YAAY,UAA+B;AAChD,OAAI,MAAM,QACT,QAAO,KAAK,EAAE;;AAIhB,IAAE,iBAAiB,UAAU,SAAS;AACtC,eAAa,EAAE,oBAAoB,UAAU,SAAS;GACrD;AAEF,cAAa;AACZ,OAAK,MAAM,WAAW,SACrB,UAAS;;;;;;;;;;;;;;;;AAkBZ,SAAgB,qBAAuC,GAAG,QAAa;AACtE,QAAO,OAAO,MAAM,UAAU,IAAI,WAAW,0BAA0B,MAAM,GAAG,CAAC,QAAQ,IAAI"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/convertors/px_2_num.ts","../src/convertors/px_2_rem.ts","../src/convertors/rem_2_px.ts","../src/properties/css_properties.ts","../src/properties/properties.ts","../src/properties/to_dom_style.ts","../src/globals.ctx.ts","../src/utils/attribute.ts","../src/theme/class-name.ts","../src/utils/data-attribute.ts","../src/theme/data-attribute.ts","../src/utils/get-css-prop-values.ts","../src/utils/prefers-color-scheme.ts"],"sourcesContent":["/**\n * Converts pixel values to numbers.\n *\n * @param px - The pixel value to convert. Can be a number or string (e.g. '16px' or '16')\n * @returns The numeric value\n *\n * @example\n * ```ts\n * px2num(16) // 16\n * px2num('32px') // 32\n * px2num('12.5px') // 12.5\n * px2num('0px') // 0\n * ```\n */\nexport function px2num(px: number | string | undefined): number {\n\treturn typeof px === 'string' ? Number.parseFloat(px.replace(/px$/, '')) : Number(px)\n}\n","/**\n * Converts pixel values to rem units.\n *\n * @param px - The pixel value to convert. Can be a number or string (e.g. '16px' or '16')\n * @param options - Optional configuration\n * @param options.base - Base pixel value to calculate rem units from. Defaults to 16\n * @param options.precision - Number of decimal places in the output. Defaults to 4\n * @returns The converted value as a string with 'rem' units\n *\n * @example\n * ```ts\n * px2rem(16) // '1.0000'\n * px2rem('32px') // '2.0000'\n * px2rem(20, { base: 20 }) // '1.0000'\n * px2rem(13, { precision: 2 }) // '0.81'\n * ```\n */\nexport function px2rem(\n\tpx: number | string,\n\toptions?: { base?: number | undefined; precision?: number | undefined },\n): number {\n\tconst { base = 16, precision = 4 } = options ?? {}\n\n\tif (typeof px === 'string') {\n\t\tpx = px.replace(/px$/, '')\n\t\tpx = Number.parseFloat(px)\n\t}\n\n\treturn Number((px / base).toFixed(precision))\n}\n","/**\n * Converts rem values to pixel units.\n *\n * @param rem - The rem value to convert. Can be a number or string (e.g. '1rem' or '1')\n * @param options - Optional configuration\n * @param options.base - Base pixel value to calculate pixels from. Defaults to 16\n * @param options.precision - Number of decimal places in the output. Defaults to 4\n * @returns The converted value as a string with 'px' units\n *\n * @example\n * ```ts\n * rem2px(1) // '16.0000'\n * rem2px('2rem') // '32.0000'\n * rem2px(1, { base: 20 }) // '20.0000'\n * rem2px(0.8125, { precision: 2 }) // '13.00'\n * ```\n */\nexport function rem2px(\n\trem: number | string,\n\toptions?: { base?: number | undefined; precision?: number | undefined },\n): number {\n\tconst { base = 16, precision = 4 } = options ?? {}\n\n\tif (typeof rem === 'string') {\n\t\trem = rem.replace(/rem$/, '')\n\t\trem = Number.parseFloat(rem)\n\t}\n\n\treturn Number((rem * base).toFixed(precision))\n}\n","import type { Properties as CSSTypeProperties } from 'csstype'\n\n/** Custom CSS properties (variables) with `--` prefix. */\ntype CustomProperties = { [k: `--${string}`]: string }\n\n/**\n * Widens CSS properties to support custom properties.\n * Allows for string or number values for standard properties,\n * and string values for custom properties with '--' prefix.\n * Defined as a union so plain Properties (e.g. from React) are assignable.\n */\nexport interface CSSProperties<TLength = string | number, TTime = string & {}>\n\textends CSSTypeProperties<TLength, TTime>,\n\t\tCustomProperties {}\n\n/**\n * Defines CSS properties including custom properties.\n * This function is used to properly type CSS properties when defining styles,\n * especially when using CSS custom properties (variables).\n *\n * @deprecated Use `defineProperties` instead.\n *\n * @param style - CSS properties object that can include both standard and custom properties\n * @returns The same style object with proper typing\n *\n * @example\n * ```ts\n * defineCSSProperties({\n * color: 'red',\n * '--custom-color': '#ff0000'\n * })\n * ```\n */\nexport function defineCSSProperties(style: CSSProperties) {\n\treturn style as any\n}\n","import type { Properties as CSSTypeProperties } from 'csstype'\n\n/** Custom CSS properties (variables) with `--` prefix. */\ntype CustomProperties = { [k: `--${string}`]: string }\n\n/**\n * Extends CSS properties to include custom properties.\n * Allows for string or number values for standard properties,\n * and string values for custom properties with '--' prefix.\n */\nexport interface Properties<TLength = 0 | (string & {}), TTime = string & {}>\n\textends CSSTypeProperties<TLength, TTime>,\n\t\tCustomProperties {}\n\n/**\n * Defines CSS properties including custom properties.\n * This function is used to properly type CSS properties when defining styles,\n * especially when using CSS custom properties (variables).\n *\n * @param style - CSS properties object that can include both standard and custom properties\n * @returns The same style object with proper typing\n *\n * @example\n * ```ts\n * defineCSSProperties({\n * color: 'red',\n * '--custom-color': '#ff0000'\n * })\n * ```\n */\nexport function defineProperties<TLength = 0 | (string & {}), TTime = string & {}>(style: Properties<TLength, TTime>) {\n\treturn style as Properties\n}\n","import type { CSSProperties } from './css_properties.ts'\n\n/**\n * Converts React-style CSS properties to DOM style properties.\n * This function handles both standard CSS properties and custom properties,\n * ensuring proper formatting for DOM style application.\n *\n * @param style - React-style CSS properties object\n * @returns CSSStyleDeclaration compatible object for DOM style application\n *\n * @example\n * ```ts\n * const domStyle = toDOMStyle({\n * backgroundColor: 'red',\n * '--custom-color': '#ff0000'\n * })\n * element.style = domStyle\n * ```\n */\nexport function toDOMStyle(style: CSSProperties | undefined): Partial<CSSStyleDeclaration> | undefined {\n\tif (style === undefined) return undefined\n\n\tconst result = {} as any\n\n\tfor (const [key, value] of Object.entries(style)) {\n\t\tresult[key.startsWith('--') ? key : key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)] = value\n\t}\n\n\treturn result\n}\n","export const ctx = {\n\tmatchMedia(query: string) {\n\t\treturn globalThis.matchMedia(query)\n\t},\n\tgetDocumentElement() {\n\t\treturn globalThis.document.documentElement\n\t},\n\t_reset() {\n\t\tthis.matchMedia = globalThis.matchMedia\n\t\tthis.getDocumentElement = () => globalThis.document.documentElement\n\t},\n}\n","import { ctx } from '../globals.ctx.ts'\n\n/**\n * Gets the value of an attribute from an element.\n *\n * @param qualifiedName - The name of the attribute to get\n * @param element - The element to get the attribute from. Defaults to `document.documentElement`\n * @returns The attribute value cast to type T, or null if the attribute doesn't exist\n *\n * @example\n * ```ts\n * // Get theme from document root\n * const theme = getAttribute('data-theme')\n *\n * // Get data-testid from a specific element\n * const testId = getAttribute('data-testid', element)\n * ```\n */\nexport function getAttribute<T extends string>(\n\tqualifiedName: T,\n\telement: Element | undefined = ctx.getDocumentElement(),\n) {\n\treturn element?.getAttribute(qualifiedName)\n}\n\n/**\n * Observes attributes changes on an element and calls corresponding handlers.\n *\n * @param handlers - An object mapping attribute names to handler functions.\n * @param element - The element to observe. Defaults to `document.documentElement`.\n * @returns {MutationObserver} The observer instance, which can be used to disconnect the observer.\n *\n * @example\n * ```ts\n * const observer = observeAttributes({\n * 'data-theme': (attr, value) => console.log(`Theme changed to: ${value}`),\n * 'class': (attr, value) => console.log(`class changed to: ${value}`)\n * });\n *\n * // Later, to stop observing:\n * observer.disconnect();\n * ```\n */\nexport function observeAttributes<T extends string>(\n\thandlers: Record<string, (value: T | null) => void>,\n\telement: Element | undefined = ctx.getDocumentElement(),\n) {\n\tconst observer = new MutationObserver((mutations) => {\n\t\tfor (const mutation of mutations) {\n\t\t\tconst attribute = mutation.attributeName!\n\t\t\tconst value = element.getAttribute(attribute) as T | null\n\t\t\thandlers[attribute]?.(value)\n\t\t}\n\t})\n\tobserver.observe(element, {\n\t\tattributes: true,\n\t\tattributeFilter: Object.keys(handlers),\n\t})\n\treturn observer\n}\n","import { findKey } from 'type-plus'\nimport { ctx } from '../globals.ctx.ts'\nimport { observeAttributes } from '../utils/attribute.ts'\n\n/**\n * Gets the current theme by checking element class names against a themes map.\n *\n * @param options - Configuration options\n * @param options.themes - Record mapping theme keys to their class name values\n * @param options.defaultTheme - Fallback theme key if no matching class is found\n * @param options.element - Element to check classes on (defaults to document.documentElement)\n * @returns The matching theme key or defaultTheme if no match found\n *\n * @example\n * ```ts\n * const themes = {\n * light: 'theme-light',\n * dark: 'theme-dark'\n * }\n *\n * // Get current theme from document.documentElement\n * const theme = getThemeByClassName({\n * themes,\n * defaultTheme: 'light'\n * })\n *\n * // Get theme from specific element\n * const theme = getThemeByClassName({\n * themes,\n * element: myElement,\n * defaultTheme: 'light'\n * })\n * ```\n */\nexport function getThemeByClassName<Themes extends Record<string, string>>(options: {\n\tthemes: Themes\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): keyof Themes | undefined {\n\tconst element = options.element ?? ctx.getDocumentElement()\n\tconst className = element.className\n\tconst theme = findKey(options.themes, (theme) => className.includes(options.themes[theme]!))\n\treturn theme ?? options.defaultTheme\n}\n\nexport function observeThemeByClassName<Themes extends Record<string, string>>(options: {\n\tthemes: Themes\n\thandler: (value: string | undefined) => void\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}) {\n\treturn observeAttributes(\n\t\t{\n\t\t\tclass: (value: string | null) => {\n\t\t\t\tif (value === null) {\n\t\t\t\t\toptions.handler(options.defaultTheme as string)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tfor (const name in options.themes) {\n\t\t\t\t\tif (value.includes(options.themes[name]!)) {\n\t\t\t\t\t\toptions.handler(name)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\toptions.element,\n\t)\n}\n","import { ctx } from '../globals.ctx.ts'\nimport { getAttribute, observeAttributes } from './attribute.ts'\n\nexport function getDataAttribute<T extends `data-${string}`>(\n\tqualifiedName: T,\n\telement: Element | undefined = ctx.getDocumentElement(),\n) {\n\treturn getAttribute(qualifiedName, element)\n}\n\n/**\n * Observes changes to `data-*` attributes on an element and calls corresponding handlers.\n *\n * @param options - Configuration options\n * @param options.handlers - An object mapping `data-*` attribute names to handler functions.\n * @param options.element - The element to observe. Defaults to `document.documentElement`\n * @returns {MutationObserver} The observer instance, which can be used to disconnect the observer\n *\n * @example\n * ```ts\n * const observer = observeDataAttributes({\n * handlers: {\n * 'data-theme': (value) => console.log(`Theme changed to: ${value}`),\n * 'data-mode': (value) => console.log(`Mode changed to: ${value}`)\n * }\n * });\n *\n * // Later, to stop observing:\n * observer.disconnect();\n * ```\n */\nexport function observeDataAttributes<T extends string, K extends `data-${string}`>(\n\thandlers: Record<K, (value: T | null) => void>,\n\telement?: Element | undefined,\n) {\n\treturn observeAttributes(handlers, element)\n}\n","import { findKey } from 'type-plus'\nimport { getDataAttribute, observeDataAttributes } from '../utils/data-attribute.ts'\n\n/**\n * Gets the theme based on a data attribute value.\n *\n * @param options - Configuration options\n * @param options.themes - Record mapping theme keys to their data attribute values\n * @param options.defaultTheme - Fallback theme key if attribute value doesn't match any theme\n * @param options.attributeName - Name of the data attribute to check (must start with 'data-')\n * @param options.allowCustom - Whether to allow custom themes value\n * @returns The matching theme key, or defaultTheme if no match found\n *\n * @example\n * ```ts\n * const themes = {\n * light: 'light',\n * dark: 'dark',\n * system: 'system'\n * }\n *\n * // Get theme from data-theme attribute\n * const theme = getThemeByDataAttribute({\n * themes,\n * defaultTheme: 'system',\n * attributeName: 'data-theme'\n * })\n * ```\n */\nexport function getThemeByDataAttribute<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tdefaultTheme?: keyof Themes | undefined\n\tthemes: Themes\n\telement?: Element | undefined\n}): keyof Themes | undefined\nexport function getThemeByDataAttribute<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tallowCustom: true | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\tthemes: Themes\n\telement?: Element | undefined\n}): string | undefined\nexport function getThemeByDataAttribute<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tallowCustom?: boolean | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\tthemes: Themes\n\telement?: Element | undefined\n}): keyof Themes | undefined {\n\tconst value = getDataAttribute(options.attributeName, options.element) ?? undefined\n\tconst theme = findKey(options.themes, (theme) => options.themes[theme] === value)\n\n\treturn theme ?? options.defaultTheme ?? (options.allowCustom ? value : undefined)\n}\n\n/**\n * Observes changes to a theme data attribute and calls a handler when it changes.\n *\n * @param options - Configuration options\n * @param options.themes - Record mapping theme keys to their data attribute values\n * @param options.handler - Callback function called with the new theme value or null when removed\n * @param options.defaultTheme - Fallback theme key if attribute value doesn't match any theme\n * @param options.attributeName - Name of the data attribute to observe (must start with 'data-')\n * @returns A MutationObserver that can be disconnected to stop observing\n *\n * @example\n * ```ts\n * const themes = {\n * light: 'light',\n * dark: 'dark'\n * }\n *\n * // Observe data-theme attribute changes\n * const observer = observeThemeByDataAttributes({\n * themes,\n * handler: (theme) => console.log('Theme changed to:', theme),\n * defaultTheme: 'light',\n * attributeName: 'data-theme'\n * })\n *\n * // Stop observing\n * observer.disconnect()\n * ```\n */\nexport function observeThemeByDataAttributes<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tthemes: Themes\n\thandler: (value: string | null) => void\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): MutationObserver\nexport function observeThemeByDataAttributes<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tthemes: Themes\n\thandler: (value: string | null) => void\n\tallowCustom: true | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): MutationObserver\nexport function observeThemeByDataAttributes<Themes extends Record<string, string>>(options: {\n\tattributeName: `data-${string}`\n\tthemes: Themes\n\thandler: (value: string | null) => void\n\tallowCustom?: boolean | undefined\n\tdefaultTheme?: keyof Themes | undefined\n\telement?: Element | undefined\n}): MutationObserver {\n\treturn observeDataAttributes(\n\t\t{\n\t\t\t[options.attributeName]: (value: string | null) => {\n\t\t\t\tif (value === null) {\n\t\t\t\t\toptions.handler((options.defaultTheme as string) ?? null)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tfor (const name in options.themes) {\n\t\t\t\t\tif (options.themes[name] === value) {\n\t\t\t\t\t\toptions.handler(name)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (options.allowCustom) {\n\t\t\t\t\toptions.handler(value)\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\toptions.element,\n\t)\n}\n","import type { CreateTuple } from 'type-plus'\n\n/**\n * Retrieves CSS custom property values from the specified element.\n *\n * @param element - The HTML element to get property values from\n * @param props - CSS custom property names to retrieve, must be in the format `--property-name`\n * @returns Array of property values corresponding to the requested custom properties\n */\nexport function getCSSPropValues<Props extends Array<`--${string}`>>(\n\telement: HTMLElement,\n\t...props: Props\n): CreateTuple<Props['length'], string>\n/**\n * Retrieves CSS custom property values from `document.body`.\n *\n * @param props - CSS custom property names to retrieve, must be in the format `--property-name`\n * @returns Array of property values corresponding to the requested custom properties\n */\nexport function getCSSPropValues<Props extends Array<`--${string}`>>(\n\t...props: Props\n): CreateTuple<Props['length'], string>\nexport function getCSSPropValues<Props extends Array<`--${string}`>>(element: unknown, ...props: Props) {\n\tif (typeof element === 'string') {\n\t\treturn getCSSPropValues(globalThis.document.body, element as `--${string}`, ...props)\n\t}\n\tconst style = globalThis.getComputedStyle(element as HTMLElement)\n\treturn props.map((v) => style.getPropertyValue(v)) as any\n}\n","import { mapKey } from 'type-plus'\nimport { ctx } from '../globals.ctx.ts'\n\n/**\n * Observes system color scheme preference changes and calls handlers when they occur.\n *\n * @param themes - An object mapping theme names to handler functions that are called when that theme is activated\n * @returns A cleanup function that removes all event listeners\n *\n * @example\n * ```ts\n * // Observe light/dark mode changes\n * const cleanup = observePrefersColorScheme({\n * light: (theme) => console.log('Light mode activated'),\n * dark: (theme) => console.log('Dark mode activated')\n * })\n *\n * // Later, to stop observing:\n * cleanup()\n * ```\n */\nexport function observePrefersColorScheme<T extends string>(themes: Record<T, (value: T | null) => void>) {\n\tconst removers = mapKey(themes, (t) => {\n\t\tconst m = ctx.matchMedia(`(prefers-color-scheme: ${t as string})`)\n\t\tconst listener = (event: MediaQueryListEvent) => {\n\t\t\tif (event.matches) {\n\t\t\t\tthemes[t]?.(t)\n\t\t\t}\n\t\t}\n\n\t\tm.addEventListener('change', listener)\n\t\treturn () => m.removeEventListener('change', listener)\n\t})\n\n\treturn () => {\n\t\tfor (const remover of removers) {\n\t\t\tremover()\n\t\t}\n\t}\n}\n\n/**\n * Gets the current preferred color theme from the system settings.\n *\n * @param themes - A list of theme names to check against the system preference\n * @returns The first matching theme from the provided list, or null if none match\n *\n * @example\n * ```ts\n * // Check if system prefers light or dark mode\n * const theme = getPrefersColorTheme('light', 'dark')\n * // Returns 'light', 'dark', or null\n * ```\n */\nexport function getPrefersColorTheme<T extends string>(...themes: T[]) {\n\treturn themes.find((theme) => ctx.matchMedia(`(prefers-color-scheme: ${theme})`).matches) ?? null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAcA,SAAgB,OAAO,IAAyC;AAC/D,QAAO,OAAO,OAAO,WAAW,OAAO,WAAW,GAAG,QAAQ,OAAO,GAAG,CAAC,GAAG,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;ACEtF,SAAgB,OACf,IACA,SACS;CACT,MAAM,EAAE,OAAO,IAAI,YAAY,MAAM,WAAW,EAAE;AAElD,KAAI,OAAO,OAAO,UAAU;AAC3B,OAAK,GAAG,QAAQ,OAAO,GAAG;AAC1B,OAAK,OAAO,WA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AQ,QAAQ,KAAK;AACrB;;AAIF,MAAI,QAAQ,YACX,SAAQ,QAAQ,MAAM;IAGxB,EACD,QAAQ,QACR;;;;;AC1GF,SAAgB,iBAAqD,SAAkB,GAAG,OAAc;AACvG,KAAI,OAAO,YAAY,SACtB,QAAO,iBAAiB,WAAW,SAAS,MAAM,SAA0B,GAAG,MAAM;CAEtF,MAAM,QAAQ,WAAW,iBAAiB,QAAuB;AACjE,QAAO,MAAM,KAAK,MAAM,MAAM,iBAAiB,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;ACNnD,SAAgB,0BAA4C,QAA8C;CACzG,MAAM,WAAW,OAAO,SAAS,MAAM;EACtC,MAAM,IAAI,IAAI,WAAW,0BAA0B,EAAY,GAAG;EAClE,MAAM,YAAY,UAA+B;AAChD,OAAI,MAAM,QACT,QAAO,KAAK,EAAE;;AAIhB,IAAE,iBAAiB,UAAU,SAAS;AACtC,eAAa,EAAE,oBAAoB,UAAU,SAAS;GACrD;AAEF,cAAa;AACZ,OAAK,MAAM,WAAW,SACrB,UAAS;;;;;;;;;;;;;;;;AAkBZ,SAAgB,qBAAuC,GAAG,QAAa;AACtE,QAAO,OAAO,MAAM,UAAU,IAAI,WAAW,0BAA0B,MAAM,GAAG,CAAC,QAAQ,IAAI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@just-web/css",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "CSS types and utilities",
5
5
  "homepage": "https://github.com/justland/just-web-foundation/tree/main/libs/css",
6
6
  "repository": {
package/src/index.ts CHANGED
@@ -3,8 +3,8 @@ export * from './convertors/px_2_num.ts'
3
3
  export * from './convertors/px_2_rem.ts'
4
4
  export * from './convertors/rem_2_px.ts'
5
5
  export * from './properties/css_properties.ts'
6
- export { defineProperties } from './properties/properties.ts'
7
6
  export type { Properties } from './properties/properties.ts'
7
+ export { defineProperties } from './properties/properties.ts'
8
8
  export * from './properties/to_dom_style.ts'
9
9
  export * from './props/class-name.ts'
10
10
  export * from './props/style.ts'
@@ -9,9 +9,9 @@ type CustomProperties = { [k: `--${string}`]: string }
9
9
  * and string values for custom properties with '--' prefix.
10
10
  * Defined as a union so plain Properties (e.g. from React) are assignable.
11
11
  */
12
- export type CSSProperties<TLength = string | number, TTime = string & {}> =
13
- | CSSTypeProperties<TLength, TTime>
14
- | (CSSTypeProperties<TLength, TTime> & CustomProperties)
12
+ export interface CSSProperties<TLength = string | number, TTime = string & {}>
13
+ extends CSSTypeProperties<TLength, TTime>,
14
+ CustomProperties {}
15
15
 
16
16
  /**
17
17
  * Defines CSS properties including custom properties.
@@ -8,9 +8,9 @@ type CustomProperties = { [k: `--${string}`]: string }
8
8
  * Allows for string or number values for standard properties,
9
9
  * and string values for custom properties with '--' prefix.
10
10
  */
11
- export type Properties<TLength = 0 | (string & {}), TTime = string & {}> =
12
- | CSSTypeProperties<TLength, TTime>
13
- | (CSSTypeProperties<TLength, TTime> & CustomProperties)
11
+ export interface Properties<TLength = 0 | (string & {}), TTime = string & {}>
12
+ extends CSSTypeProperties<TLength, TTime>,
13
+ CustomProperties {}
14
14
 
15
15
  /**
16
16
  * Defines CSS properties including custom properties.