@just-web/css 0.6.1 → 0.8.0

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.
Files changed (114) hide show
  1. package/cjs/index.cjs +394 -0
  2. package/cjs/index.cjs.map +1 -0
  3. package/cjs/index.d.cts +412 -0
  4. package/cjs/index.d.cts.map +1 -0
  5. package/esm/index.d.mts +412 -0
  6. package/esm/index.d.mts.map +1 -0
  7. package/esm/index.mjs +378 -0
  8. package/esm/index.mjs.map +1 -0
  9. package/package.json +36 -35
  10. package/src/convertors/px_2_num.ts +17 -0
  11. package/src/index.ts +6 -2
  12. package/src/{css-properties/css-properties.ts → properties/css_properties.ts} +6 -2
  13. package/{cjs/css-properties/css-properties.d.ts → src/properties/properties.ts} +9 -4
  14. package/src/{css-properties → properties}/to_dom_style.ts +1 -1
  15. package/src/props/class-name.ts +1 -1
  16. package/src/props/style.ts +3 -3
  17. package/cjs/convertors/px_2_rem.d.ts +0 -21
  18. package/cjs/convertors/px_2_rem.js +0 -17
  19. package/cjs/convertors/rem_2_px.d.ts +0 -21
  20. package/cjs/convertors/rem_2_px.js +0 -17
  21. package/cjs/css-properties/css-properties.js +0 -9
  22. package/cjs/css-properties/to_dom_style.d.ts +0 -19
  23. package/cjs/css-properties/to_dom_style.js +0 -14
  24. package/cjs/globals.ctx.d.ts +0 -5
  25. package/cjs/globals.ctx.js +0 -18
  26. package/cjs/index.d.ts +0 -12
  27. package/cjs/index.js +0 -137
  28. package/cjs/package.json +0 -1
  29. package/cjs/props/class-name.d.ts +0 -11
  30. package/cjs/props/class-name.js +0 -1
  31. package/cjs/props/style.d.ts +0 -7
  32. package/cjs/props/style.js +0 -1
  33. package/cjs/tailwind.css +0 -1
  34. package/cjs/testing/log-panel.d.ts +0 -4
  35. package/cjs/testing/log-panel.js +0 -19
  36. package/cjs/testing/toggle-attribute-button.d.ts +0 -4
  37. package/cjs/testing/toggle-attribute-button.js +0 -28
  38. package/cjs/theme/class-name.d.ts +0 -41
  39. package/cjs/theme/class-name.js +0 -32
  40. package/cjs/theme/data-attribute.d.ts +0 -83
  41. package/cjs/theme/data-attribute.js +0 -33
  42. package/cjs/utils/attribute.d.ts +0 -36
  43. package/cjs/utils/attribute.js +0 -25
  44. package/cjs/utils/data-attribute.d.ts +0 -23
  45. package/cjs/utils/data-attribute.js +0 -15
  46. package/cjs/utils/get-css-prop-values.d.ts +0 -16
  47. package/cjs/utils/get-css-prop-values.js +0 -13
  48. package/cjs/utils/prefers-color-scheme.d.ts +0 -33
  49. package/cjs/utils/prefers-color-scheme.js +0 -29
  50. package/esm/convertors/px_2_rem.d.ts +0 -22
  51. package/esm/convertors/px_2_rem.d.ts.map +0 -1
  52. package/esm/convertors/px_2_rem.js +0 -26
  53. package/esm/convertors/px_2_rem.js.map +0 -1
  54. package/esm/convertors/rem_2_px.d.ts +0 -22
  55. package/esm/convertors/rem_2_px.d.ts.map +0 -1
  56. package/esm/convertors/rem_2_px.js +0 -26
  57. package/esm/convertors/rem_2_px.js.map +0 -1
  58. package/esm/css-properties/css-properties.d.ts +0 -27
  59. package/esm/css-properties/css-properties.d.ts.map +0 -1
  60. package/esm/css-properties/css-properties.js +0 -20
  61. package/esm/css-properties/css-properties.js.map +0 -1
  62. package/esm/css-properties/to_dom_style.d.ts +0 -20
  63. package/esm/css-properties/to_dom_style.d.ts.map +0 -1
  64. package/esm/css-properties/to_dom_style.js +0 -27
  65. package/esm/css-properties/to_dom_style.js.map +0 -1
  66. package/esm/globals.ctx.d.ts +0 -6
  67. package/esm/globals.ctx.d.ts.map +0 -1
  68. package/esm/globals.ctx.js +0 -13
  69. package/esm/globals.ctx.js.map +0 -1
  70. package/esm/index.d.ts +0 -13
  71. package/esm/index.d.ts.map +0 -1
  72. package/esm/index.js +0 -13
  73. package/esm/index.js.map +0 -1
  74. package/esm/props/class-name.d.ts +0 -12
  75. package/esm/props/class-name.d.ts.map +0 -1
  76. package/esm/props/class-name.js +0 -6
  77. package/esm/props/class-name.js.map +0 -1
  78. package/esm/props/style.d.ts +0 -8
  79. package/esm/props/style.d.ts.map +0 -1
  80. package/esm/props/style.js +0 -2
  81. package/esm/props/style.js.map +0 -1
  82. package/esm/testing/log-panel.d.ts +0 -5
  83. package/esm/testing/log-panel.d.ts.map +0 -1
  84. package/esm/testing/log-panel.js +0 -5
  85. package/esm/testing/log-panel.js.map +0 -1
  86. package/esm/testing/toggle-attribute-button.d.ts +0 -5
  87. package/esm/testing/toggle-attribute-button.d.ts.map +0 -1
  88. package/esm/testing/toggle-attribute-button.js +0 -19
  89. package/esm/testing/toggle-attribute-button.js.map +0 -1
  90. package/esm/theme/class-name.d.ts +0 -42
  91. package/esm/theme/class-name.d.ts.map +0 -1
  92. package/esm/theme/class-name.js +0 -56
  93. package/esm/theme/class-name.js.map +0 -1
  94. package/esm/theme/data-attribute.d.ts +0 -84
  95. package/esm/theme/data-attribute.d.ts.map +0 -1
  96. package/esm/theme/data-attribute.js +0 -27
  97. package/esm/theme/data-attribute.js.map +0 -1
  98. package/esm/utils/attribute.d.ts +0 -37
  99. package/esm/utils/attribute.d.ts.map +0 -1
  100. package/esm/utils/attribute.js +0 -53
  101. package/esm/utils/attribute.js.map +0 -1
  102. package/esm/utils/data-attribute.d.ts +0 -24
  103. package/esm/utils/data-attribute.d.ts.map +0 -1
  104. package/esm/utils/data-attribute.js +0 -30
  105. package/esm/utils/data-attribute.js.map +0 -1
  106. package/esm/utils/get-css-prop-values.d.ts +0 -17
  107. package/esm/utils/get-css-prop-values.d.ts.map +0 -1
  108. package/esm/utils/get-css-prop-values.js +0 -8
  109. package/esm/utils/get-css-prop-values.js.map +0 -1
  110. package/esm/utils/prefers-color-scheme.d.ts +0 -34
  111. package/esm/utils/prefers-color-scheme.d.ts.map +0 -1
  112. package/esm/utils/prefers-color-scheme.js +0 -54
  113. package/esm/utils/prefers-color-scheme.js.map +0 -1
  114. package/src/tailwind.css +0 -3
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getDataAttribute = getDataAttribute;
7
- exports.observeDataAttributes = observeDataAttributes;
8
- var _globalsCtx = require("../globals.ctx.ts");
9
- var _attribute = require("./attribute.ts");
10
- function getDataAttribute(qualifiedName, element = _globalsCtx.ctx.getDocumentElement()) {
11
- return (0, _attribute.getAttribute)(qualifiedName, element);
12
- }
13
- function observeDataAttributes(handlers, element) {
14
- return (0, _attribute.observeAttributes)(handlers, element);
15
- }
@@ -1,16 +0,0 @@
1
- import type { CreateTuple } from 'type-plus';
2
- /**
3
- * Retrieves CSS custom property values from the specified element.
4
- *
5
- * @param element - The HTML element to get property values from
6
- * @param props - CSS custom property names to retrieve, must be in the format `--property-name`
7
- * @returns Array of property values corresponding to the requested custom properties
8
- */
9
- export declare function getCSSPropValues<Props extends Array<`--${string}`>>(element: HTMLElement, ...props: Props): CreateTuple<Props['length'], string>;
10
- /**
11
- * Retrieves CSS custom property values from `document.body`.
12
- *
13
- * @param props - CSS custom property names to retrieve, must be in the format `--property-name`
14
- * @returns Array of property values corresponding to the requested custom properties
15
- */
16
- export declare function getCSSPropValues<Props extends Array<`--${string}`>>(...props: Props): CreateTuple<Props['length'], string>;
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getCSSPropValues = getCSSPropValues;
7
- function getCSSPropValues(element, ...props) {
8
- if (typeof element === "string") {
9
- return getCSSPropValues(globalThis.document.body, element, ...props);
10
- }
11
- const style = globalThis.getComputedStyle(element);
12
- return props.map(v => style.getPropertyValue(v));
13
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * Observes system color scheme preference changes and calls handlers when they occur.
3
- *
4
- * @param themes - An object mapping theme names to handler functions that are called when that theme is activated
5
- * @returns A cleanup function that removes all event listeners
6
- *
7
- * @example
8
- * ```ts
9
- * // Observe light/dark mode changes
10
- * const cleanup = observePrefersColorScheme({
11
- * light: (theme) => console.log('Light mode activated'),
12
- * dark: (theme) => console.log('Dark mode activated')
13
- * })
14
- *
15
- * // Later, to stop observing:
16
- * cleanup()
17
- * ```
18
- */
19
- export declare function observePrefersColorScheme<T extends string>(themes: Record<T, (value: T | null) => void>): () => void;
20
- /**
21
- * Gets the current preferred color theme from the system settings.
22
- *
23
- * @param themes - A list of theme names to check against the system preference
24
- * @returns The first matching theme from the provided list, or null if none match
25
- *
26
- * @example
27
- * ```ts
28
- * // Check if system prefers light or dark mode
29
- * const theme = getPrefersColorTheme('light', 'dark')
30
- * // Returns 'light', 'dark', or null
31
- * ```
32
- */
33
- export declare function getPrefersColorTheme<T extends string>(...themes: T[]): any;
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getPrefersColorTheme = getPrefersColorTheme;
7
- exports.observePrefersColorScheme = observePrefersColorScheme;
8
- var _typePlus = require("type-plus");
9
- var _globalsCtx = require("../globals.ctx.ts");
10
- function observePrefersColorScheme(themes) {
11
- const removers = (0, _typePlus.mapKey)(themes, t => {
12
- const m = _globalsCtx.ctx.matchMedia(`(prefers-color-scheme: ${t})`);
13
- const listener = event => {
14
- if (event.matches) {
15
- themes[t]?.(t);
16
- }
17
- };
18
- m.addEventListener("change", listener);
19
- return () => m.removeEventListener("change", listener);
20
- });
21
- return () => {
22
- for (const remover of removers) {
23
- remover();
24
- }
25
- };
26
- }
27
- function getPrefersColorTheme(...themes) {
28
- return themes.find(theme => _globalsCtx.ctx.matchMedia(`(prefers-color-scheme: ${theme})`).matches) ?? null;
29
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * Converts pixel values to rem units.
3
- *
4
- * @param px - The pixel value to convert. Can be a number or string (e.g. '16px' or '16')
5
- * @param options - Optional configuration
6
- * @param options.base - Base pixel value to calculate rem units from. Defaults to 16
7
- * @param options.precision - Number of decimal places in the output. Defaults to 4
8
- * @returns The converted value as a string with 'rem' units
9
- *
10
- * @example
11
- * ```ts
12
- * px2rem(16) // '1.0000'
13
- * px2rem('32px') // '2.0000'
14
- * px2rem(20, { base: 20 }) // '1.0000'
15
- * px2rem(13, { precision: 2 }) // '0.81'
16
- * ```
17
- */
18
- export declare function px2rem(px: number | string, options?: {
19
- base?: number | undefined;
20
- precision?: number | undefined;
21
- }): number;
22
- //# sourceMappingURL=px_2_rem.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"px_2_rem.d.ts","sourceRoot":"","sources":["../../src/convertors/px_2_rem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CACrB,EAAE,EAAE,MAAM,GAAG,MAAM,EACnB,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GACrE,MAAM,CASR"}
@@ -1,26 +0,0 @@
1
- /**
2
- * Converts pixel values to rem units.
3
- *
4
- * @param px - The pixel value to convert. Can be a number or string (e.g. '16px' or '16')
5
- * @param options - Optional configuration
6
- * @param options.base - Base pixel value to calculate rem units from. Defaults to 16
7
- * @param options.precision - Number of decimal places in the output. Defaults to 4
8
- * @returns The converted value as a string with 'rem' units
9
- *
10
- * @example
11
- * ```ts
12
- * px2rem(16) // '1.0000'
13
- * px2rem('32px') // '2.0000'
14
- * px2rem(20, { base: 20 }) // '1.0000'
15
- * px2rem(13, { precision: 2 }) // '0.81'
16
- * ```
17
- */
18
- export function px2rem(px, options) {
19
- const { base = 16, precision = 4 } = options ?? {};
20
- if (typeof px === 'string') {
21
- px = px.replace(/px$/, '');
22
- px = Number.parseFloat(px);
23
- }
24
- return Number((px / base).toFixed(precision));
25
- }
26
- //# sourceMappingURL=px_2_rem.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"px_2_rem.js","sourceRoot":"","sources":["../../src/convertors/px_2_rem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,MAAM,CACrB,EAAmB,EACnB,OAAuE;IAEvE,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,GAAG,CAAC,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IAElD,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC5B,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QAC1B,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;IAC3B,CAAC;IAED,OAAO,MAAM,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAA;AAC9C,CAAC"}
@@ -1,22 +0,0 @@
1
- /**
2
- * Converts rem values to pixel units.
3
- *
4
- * @param rem - The rem value to convert. Can be a number or string (e.g. '1rem' or '1')
5
- * @param options - Optional configuration
6
- * @param options.base - Base pixel value to calculate pixels from. Defaults to 16
7
- * @param options.precision - Number of decimal places in the output. Defaults to 4
8
- * @returns The converted value as a string with 'px' units
9
- *
10
- * @example
11
- * ```ts
12
- * rem2px(1) // '16.0000'
13
- * rem2px('2rem') // '32.0000'
14
- * rem2px(1, { base: 20 }) // '20.0000'
15
- * rem2px(0.8125, { precision: 2 }) // '13.00'
16
- * ```
17
- */
18
- export declare function rem2px(rem: number | string, options?: {
19
- base?: number | undefined;
20
- precision?: number | undefined;
21
- }): number;
22
- //# sourceMappingURL=rem_2_px.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rem_2_px.d.ts","sourceRoot":"","sources":["../../src/convertors/rem_2_px.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CACrB,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GACrE,MAAM,CASR"}
@@ -1,26 +0,0 @@
1
- /**
2
- * Converts rem values to pixel units.
3
- *
4
- * @param rem - The rem value to convert. Can be a number or string (e.g. '1rem' or '1')
5
- * @param options - Optional configuration
6
- * @param options.base - Base pixel value to calculate pixels from. Defaults to 16
7
- * @param options.precision - Number of decimal places in the output. Defaults to 4
8
- * @returns The converted value as a string with 'px' units
9
- *
10
- * @example
11
- * ```ts
12
- * rem2px(1) // '16.0000'
13
- * rem2px('2rem') // '32.0000'
14
- * rem2px(1, { base: 20 }) // '20.0000'
15
- * rem2px(0.8125, { precision: 2 }) // '13.00'
16
- * ```
17
- */
18
- export function rem2px(rem, options) {
19
- const { base = 16, precision = 4 } = options ?? {};
20
- if (typeof rem === 'string') {
21
- rem = rem.replace(/rem$/, '');
22
- rem = Number.parseFloat(rem);
23
- }
24
- return Number((rem * base).toFixed(precision));
25
- }
26
- //# sourceMappingURL=rem_2_px.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rem_2_px.js","sourceRoot":"","sources":["../../src/convertors/rem_2_px.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,MAAM,CACrB,GAAoB,EACpB,OAAuE;IAEvE,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,GAAG,CAAC,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IAElD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC7B,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QAC7B,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IAC7B,CAAC;IAED,OAAO,MAAM,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAA;AAC/C,CAAC"}
@@ -1,27 +0,0 @@
1
- import type { Properties } from 'csstype';
2
- /**
3
- * Extends CSS properties to include custom properties.
4
- * Allows for string or number values for standard properties,
5
- * and string values for custom properties with '--' prefix.
6
- */
7
- export interface CSSProperties extends Properties<string | number> {
8
- [k: `--${string}`]: string;
9
- }
10
- /**
11
- * Defines CSS properties including custom properties.
12
- * This function is used to properly type CSS properties when defining styles,
13
- * especially when using CSS custom properties (variables).
14
- *
15
- * @param style - CSS properties object that can include both standard and custom properties
16
- * @returns The same style object with proper typing
17
- *
18
- * @example
19
- * ```ts
20
- * defineCSSProperties({
21
- * color: 'red',
22
- * '--custom-color': '#ff0000'
23
- * })
24
- * ```
25
- */
26
- export declare function defineCSSProperties(style: CSSProperties): any;
27
- //# sourceMappingURL=css-properties.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"css-properties.d.ts","sourceRoot":"","sources":["../../src/css-properties/css-properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;IACjE,CAAC,CAAC,EAAE,KAAK,MAAM,EAAE,GAAG,MAAM,CAAA;CAC1B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GACvC,GAAG,CACnB"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Defines CSS properties including custom properties.
3
- * This function is used to properly type CSS properties when defining styles,
4
- * especially when using CSS custom properties (variables).
5
- *
6
- * @param style - CSS properties object that can include both standard and custom properties
7
- * @returns The same style object with proper typing
8
- *
9
- * @example
10
- * ```ts
11
- * defineCSSProperties({
12
- * color: 'red',
13
- * '--custom-color': '#ff0000'
14
- * })
15
- * ```
16
- */
17
- export function defineCSSProperties(style) {
18
- return style;
19
- }
20
- //# sourceMappingURL=css-properties.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"css-properties.js","sourceRoot":"","sources":["../../src/css-properties/css-properties.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAoB;IACvD,OAAO,KAAY,CAAA;AACpB,CAAC"}
@@ -1,20 +0,0 @@
1
- import type { CSSProperties } from './css-properties.ts';
2
- /**
3
- * Converts React-style CSS properties to DOM style properties.
4
- * This function handles both standard CSS properties and custom properties,
5
- * ensuring proper formatting for DOM style application.
6
- *
7
- * @param style - React-style CSS properties object
8
- * @returns CSSStyleDeclaration compatible object for DOM style application
9
- *
10
- * @example
11
- * ```ts
12
- * const domStyle = toDOMStyle({
13
- * backgroundColor: 'red',
14
- * '--custom-color': '#ff0000'
15
- * })
16
- * element.style = domStyle
17
- * ```
18
- */
19
- export declare function toDOMStyle(style: CSSProperties | undefined): Partial<CSSStyleDeclaration> | undefined;
20
- //# sourceMappingURL=to_dom_style.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"to_dom_style.d.ts","sourceRoot":"","sources":["../../src/css-properties/to_dom_style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAUrG"}
@@ -1,27 +0,0 @@
1
- /**
2
- * Converts React-style CSS properties to DOM style properties.
3
- * This function handles both standard CSS properties and custom properties,
4
- * ensuring proper formatting for DOM style application.
5
- *
6
- * @param style - React-style CSS properties object
7
- * @returns CSSStyleDeclaration compatible object for DOM style application
8
- *
9
- * @example
10
- * ```ts
11
- * const domStyle = toDOMStyle({
12
- * backgroundColor: 'red',
13
- * '--custom-color': '#ff0000'
14
- * })
15
- * element.style = domStyle
16
- * ```
17
- */
18
- export function toDOMStyle(style) {
19
- if (style === undefined)
20
- return undefined;
21
- const result = {};
22
- for (const [key, value] of Object.entries(style)) {
23
- result[key.startsWith('--') ? key : key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)] = value;
24
- }
25
- return result;
26
- }
27
- //# sourceMappingURL=to_dom_style.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"to_dom_style.js","sourceRoot":"","sources":["../../src/css-properties/to_dom_style.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,UAAU,CAAC,KAAgC;IAC1D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAEzC,MAAM,MAAM,GAAG,EAAS,CAAA;IAExB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,CAAA;IACzG,CAAC;IAED,OAAO,MAAM,CAAA;AACd,CAAC"}
@@ -1,6 +0,0 @@
1
- export declare const ctx: {
2
- matchMedia(query: string): MediaQueryList;
3
- getDocumentElement(): HTMLElement;
4
- _reset(): void;
5
- };
6
- //# sourceMappingURL=globals.ctx.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"globals.ctx.d.ts","sourceRoot":"","sources":["../src/globals.ctx.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,GAAG;sBACG,MAAM;;;CAUxB,CAAA"}
@@ -1,13 +0,0 @@
1
- export const ctx = {
2
- matchMedia(query) {
3
- return globalThis.matchMedia(query);
4
- },
5
- getDocumentElement() {
6
- return globalThis.document.documentElement;
7
- },
8
- _reset() {
9
- this.matchMedia = globalThis.matchMedia;
10
- this.getDocumentElement = () => globalThis.document.documentElement;
11
- },
12
- };
13
- //# sourceMappingURL=globals.ctx.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"globals.ctx.js","sourceRoot":"","sources":["../src/globals.ctx.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,GAAG,GAAG;IAClB,UAAU,CAAC,KAAa;QACvB,OAAO,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IACD,kBAAkB;QACjB,OAAO,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAA;IAC3C,CAAC;IACD,MAAM;QACL,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,CAAA;QACvC,IAAI,CAAC,kBAAkB,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAA;IACpE,CAAC;CACD,CAAA"}
package/esm/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- export * from './convertors/px_2_rem.ts';
2
- export * from './convertors/rem_2_px.ts';
3
- export * from './css-properties/css-properties.ts';
4
- export * from './css-properties/to_dom_style.ts';
5
- export * from './props/class-name.ts';
6
- export * from './props/style.ts';
7
- export * from './theme/class-name.ts';
8
- export * from './theme/data-attribute.ts';
9
- export * from './utils/attribute.ts';
10
- export * from './utils/data-attribute.ts';
11
- export * from './utils/get-css-prop-values.ts';
12
- export * from './utils/prefers-color-scheme.ts';
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,oCAAoC,CAAA;AAClD,cAAc,kCAAkC,CAAA;AAChD,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iCAAiC,CAAA"}
package/esm/index.js DELETED
@@ -1,13 +0,0 @@
1
- export * from "./convertors/px_2_rem.js";
2
- export * from "./convertors/rem_2_px.js";
3
- export * from "./css-properties/css-properties.js";
4
- export * from "./css-properties/to_dom_style.js";
5
- export * from "./props/class-name.js";
6
- export * from "./props/style.js";
7
- export * from "./theme/class-name.js";
8
- export * from "./theme/data-attribute.js";
9
- export * from "./utils/attribute.js";
10
- export * from "./utils/data-attribute.js";
11
- export * from "./utils/get-css-prop-values.js";
12
- export * from "./utils/prefers-color-scheme.js";
13
- //# sourceMappingURL=index.js.map
package/esm/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,oCAAoC,CAAA;AAClD,cAAc,kCAAkC,CAAA;AAChD,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iCAAiC,CAAA"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Note that `className` could be specific to ReactJS.
3
- * So this type may be misplaced in this package.
4
- */
5
- /**
6
- * Interface for component props that include a className property.
7
- * The className property accepts a string value for CSS class names.
8
- */
9
- export interface ClassNameProps {
10
- className?: string | undefined;
11
- }
12
- //# sourceMappingURL=class-name.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"class-name.d.ts","sourceRoot":"","sources":["../../src/props/class-name.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Note that `className` could be specific to ReactJS.
3
- * So this type may be misplaced in this package.
4
- */
5
- export {};
6
- //# sourceMappingURL=class-name.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"class-name.js","sourceRoot":"","sources":["../../src/props/class-name.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -1,8 +0,0 @@
1
- import type { CSSProperties } from '../css-properties/css-properties.ts';
2
- /**
3
- * Interface for component props that include a style property.
4
- */
5
- export interface StyleProps {
6
- style?: CSSProperties | undefined;
7
- }
8
- //# sourceMappingURL=style.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/props/style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AAExE;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAA;CACjC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=style.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"style.js","sourceRoot":"","sources":["../../src/props/style.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- export declare function LogPanel({ title, log }: {
2
- title: string;
3
- log: string[];
4
- }): import("react/jsx-runtime").JSX.Element;
5
- //# sourceMappingURL=log-panel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"log-panel.d.ts","sourceRoot":"","sources":["../../src/testing/log-panel.tsx"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,EAAE,CAAA;CAAE,2CAWxE"}
@@ -1,5 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export function LogPanel({ title, log }) {
3
- return (_jsxs("div", { className: "bg-neutral-100 dark:bg-neutral-900 p-4 rounded overflow-y-auto", children: [_jsx("h4", { className: "mb-2", children: title }), log.map((entry, i) => (_jsx("pre", { className: "font-mono", children: entry }, i)))] }));
4
- }
5
- //# sourceMappingURL=log-panel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"log-panel.js","sourceRoot":"","sources":["../../src/testing/log-panel.tsx"],"names":[],"mappings":";AAAA,MAAM,UAAU,QAAQ,CAAC,EAAE,KAAK,EAAE,GAAG,EAAoC;IACxE,OAAO,CACN,eAAK,SAAS,EAAC,gEAAgE,aAC9E,aAAI,SAAS,EAAC,MAAM,YAAE,KAAK,GAAM,EAChC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CACtB,cAAa,SAAS,EAAC,WAAW,YAChC,KAAK,IADG,CAAC,CAEL,CACN,CAAC,IACG,CACN,CAAA;AACF,CAAC"}
@@ -1,5 +0,0 @@
1
- export declare const ToggleAttributeButton: import("react").ForwardRefExoticComponent<{
2
- attribute: string;
3
- values?: string[];
4
- } & import("react").RefAttributes<HTMLElement>>;
5
- //# sourceMappingURL=toggle-attribute-button.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toggle-attribute-button.d.ts","sourceRoot":"","sources":["../../src/testing/toggle-attribute-button.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB;eAAwC,MAAM;aAAW,MAAM,EAAE;+CA6BlG,CAAA"}
@@ -1,19 +0,0 @@
1
- import { jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useCallback } from 'react';
3
- export const ToggleAttributeButton = forwardRef(({ attribute, values = ['test-value'] }, ref) => {
4
- const handleAttributeChange = useCallback((attr) => {
5
- // Handle both RefObject and function ref cases
6
- const target = (ref && 'current' in ref ? ref.current : null) ?? document.documentElement;
7
- const currentValue = target.getAttribute(attr);
8
- const nextIndex = currentValue ? values.indexOf(currentValue) + 1 : 0;
9
- const newValue = nextIndex < values.length ? values[nextIndex] : null;
10
- if (newValue === null) {
11
- target.removeAttribute(attr);
12
- }
13
- else {
14
- target.setAttribute(attr, newValue);
15
- }
16
- }, [ref, values]);
17
- return (_jsxs("button", { className: "bg-cyan-700 text-white px-4 py-2 rounded-md shadow-md active:bg-cyan-800", onClick: () => handleAttributeChange(attribute), children: ["Toggle ", attribute] }, attribute));
18
- });
19
- //# sourceMappingURL=toggle-attribute-button.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toggle-attribute-button.js","sourceRoot":"","sources":["../../src/testing/toggle-attribute-button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAE/C,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAC9C,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE;IAC/C,MAAM,qBAAqB,GAAG,WAAW,CACxC,CAAC,IAAY,EAAE,EAAE;QAChB,+CAA+C;QAC/C,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,SAAS,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,eAAe,CAAA;QACzF,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QAC9C,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACrE,MAAM,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAE,CAAC,CAAC,CAAC,IAAI,CAAA;QAEtE,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YACvB,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;QAC7B,CAAC;aAAM,CAAC;YACP,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;QACpC,CAAC;IACF,CAAC,EACD,CAAC,GAAG,EAAE,MAAM,CAAC,CACb,CAAA;IAED,OAAO,CACN,kBAEC,SAAS,EAAC,0EAA0E,EACpF,OAAO,EAAE,GAAG,EAAE,CAAC,qBAAqB,CAAC,SAAS,CAAC,wBAEvC,SAAS,KAJZ,SAAS,CAKN,CACT,CAAA;AACF,CAAC,CACD,CAAA"}
@@ -1,42 +0,0 @@
1
- /**
2
- * Gets the current theme by checking element class names against a themes map.
3
- *
4
- * @param options - Configuration options
5
- * @param options.themes - Record mapping theme keys to their class name values
6
- * @param options.defaultTheme - Fallback theme key if no matching class is found
7
- * @param options.element - Element to check classes on (defaults to document.documentElement)
8
- * @returns The matching theme key or defaultTheme if no match found
9
- *
10
- * @example
11
- * ```ts
12
- * const themes = {
13
- * light: 'theme-light',
14
- * dark: 'theme-dark'
15
- * }
16
- *
17
- * // Get current theme from document.documentElement
18
- * const theme = getThemeByClassName({
19
- * themes,
20
- * defaultTheme: 'light'
21
- * })
22
- *
23
- * // Get theme from specific element
24
- * const theme = getThemeByClassName({
25
- * themes,
26
- * element: myElement,
27
- * defaultTheme: 'light'
28
- * })
29
- * ```
30
- */
31
- export declare function getThemeByClassName<Themes extends Record<string, string>>(options: {
32
- themes: Themes;
33
- defaultTheme?: keyof Themes | undefined;
34
- element?: Element | undefined;
35
- }): keyof Themes | undefined;
36
- export declare function observeThemeByClassName<Themes extends Record<string, string>>(options: {
37
- themes: Themes;
38
- handler: (value: string | undefined) => void;
39
- defaultTheme?: keyof Themes | undefined;
40
- element?: Element | undefined;
41
- }): MutationObserver;
42
- //# sourceMappingURL=class-name.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"class-name.d.ts","sourceRoot":"","sources":["../../src/theme/class-name.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE;IACnF,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IACvC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC7B,GAAG,MAAM,MAAM,GAAG,SAAS,CAK3B;AAED,wBAAgB,uBAAuB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE;IACvF,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAA;IAC5C,YAAY,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IACvC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC7B,oBAmBA"}
@@ -1,56 +0,0 @@
1
- import { findKey } from 'type-plus';
2
- import { ctx } from "../globals.ctx.js";
3
- import { observeAttributes } from "../utils/attribute.js";
4
- /**
5
- * Gets the current theme by checking element class names against a themes map.
6
- *
7
- * @param options - Configuration options
8
- * @param options.themes - Record mapping theme keys to their class name values
9
- * @param options.defaultTheme - Fallback theme key if no matching class is found
10
- * @param options.element - Element to check classes on (defaults to document.documentElement)
11
- * @returns The matching theme key or defaultTheme if no match found
12
- *
13
- * @example
14
- * ```ts
15
- * const themes = {
16
- * light: 'theme-light',
17
- * dark: 'theme-dark'
18
- * }
19
- *
20
- * // Get current theme from document.documentElement
21
- * const theme = getThemeByClassName({
22
- * themes,
23
- * defaultTheme: 'light'
24
- * })
25
- *
26
- * // Get theme from specific element
27
- * const theme = getThemeByClassName({
28
- * themes,
29
- * element: myElement,
30
- * defaultTheme: 'light'
31
- * })
32
- * ```
33
- */
34
- export function getThemeByClassName(options) {
35
- const element = options.element ?? ctx.getDocumentElement();
36
- const className = element.className;
37
- const theme = findKey(options.themes, (theme) => className.includes(options.themes[theme]));
38
- return theme ?? options.defaultTheme;
39
- }
40
- export function observeThemeByClassName(options) {
41
- return observeAttributes({
42
- class: (value) => {
43
- if (value === null) {
44
- options.handler(options.defaultTheme);
45
- return;
46
- }
47
- for (const name in options.themes) {
48
- if (value.includes(options.themes[name])) {
49
- options.handler(name);
50
- break;
51
- }
52
- }
53
- },
54
- }, options.element);
55
- }
56
- //# sourceMappingURL=class-name.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"class-name.js","sourceRoot":"","sources":["../../src/theme/class-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,mBAAmB,CAAwC,OAI1E;IACA,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,GAAG,CAAC,kBAAkB,EAAE,CAAA;IAC3D,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAE,CAAC,CAAC,CAAA;IAC5F,OAAO,KAAK,IAAI,OAAO,CAAC,YAAY,CAAA;AACrC,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAwC,OAK9E;IACA,OAAO,iBAAiB,CACvB;QACC,KAAK,EAAE,CAAC,KAAoB,EAAE,EAAE;YAC/B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACpB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,YAAsB,CAAC,CAAA;gBAC/C,OAAM;YACP,CAAC;YAED,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACnC,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAE,CAAC,EAAE,CAAC;oBAC3C,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;oBACrB,MAAK;gBACN,CAAC;YACF,CAAC;QACF,CAAC;KACD,EACD,OAAO,CAAC,OAAO,CACf,CAAA;AACF,CAAC"}