yummies 7.10.0 → 7.12.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 (154) hide show
  1. package/async.cjs +162 -48
  2. package/async.cjs.map +1 -1
  3. package/async.d.ts +112 -13
  4. package/async.js +163 -54
  5. package/async.js.map +1 -1
  6. package/chunk-CVq3Gv4J.cjs +50 -0
  7. package/chunk-YKewjYmz.js +37 -0
  8. package/common.cjs +48 -8
  9. package/common.cjs.map +1 -1
  10. package/common.d.ts +35 -2
  11. package/common.js +49 -11
  12. package/common.js.map +1 -1
  13. package/complex.cjs +275 -104
  14. package/complex.cjs.map +1 -1
  15. package/complex.d.ts +133 -13
  16. package/complex.js +275 -109
  17. package/complex.js.map +1 -1
  18. package/cookie.cjs +17 -7
  19. package/cookie.cjs.map +1 -1
  20. package/cookie.d.ts +8 -0
  21. package/cookie.js +18 -9
  22. package/cookie.js.map +1 -1
  23. package/css.cjs +147 -39
  24. package/css.cjs.map +1 -1
  25. package/css.d.ts +98 -6
  26. package/css.js +143 -41
  27. package/css.js.map +1 -1
  28. package/data.cjs +90 -55
  29. package/data.cjs.map +1 -1
  30. package/data.d.ts +32 -0
  31. package/data.js +91 -61
  32. package/data.js.map +1 -1
  33. package/date-time.cjs +578 -412
  34. package/date-time.cjs.map +1 -1
  35. package/date-time.d.ts +88 -0
  36. package/date-time.js +575 -421
  37. package/date-time.js.map +1 -1
  38. package/device.cjs +48 -23
  39. package/device.cjs.map +1 -1
  40. package/device.d.ts +32 -0
  41. package/device.js +49 -31
  42. package/device.js.map +1 -1
  43. package/encodings.cjs +275 -266
  44. package/encodings.cjs.map +1 -1
  45. package/encodings.d.ts +8 -0
  46. package/encodings.js +276 -268
  47. package/encodings.js.map +1 -1
  48. package/errors.cjs +20 -18
  49. package/errors.cjs.map +1 -1
  50. package/errors.js +19 -19
  51. package/errors.js.map +1 -1
  52. package/file.cjs +42 -24
  53. package/file.cjs.map +1 -1
  54. package/file.d.ts +16 -0
  55. package/file.js +43 -27
  56. package/file.js.map +1 -1
  57. package/format.cjs +125 -83
  58. package/format.cjs.map +1 -1
  59. package/format.d.ts +89 -4
  60. package/format.js +118 -82
  61. package/format.js.map +1 -1
  62. package/html.cjs +226 -137
  63. package/html.cjs.map +1 -1
  64. package/html.d.ts +67 -3
  65. package/html.js +223 -150
  66. package/html.js.map +1 -1
  67. package/id.cjs +74 -17
  68. package/id.cjs.map +1 -1
  69. package/id.d.ts +10 -10
  70. package/id.js +73 -24
  71. package/id.js.map +1 -1
  72. package/imports.cjs +41 -29
  73. package/imports.cjs.map +1 -1
  74. package/imports.d.ts +13 -4
  75. package/imports.js +40 -31
  76. package/imports.js.map +1 -1
  77. package/math.cjs +32 -6
  78. package/math.cjs.map +1 -1
  79. package/math.d.ts +17 -1
  80. package/math.js +33 -10
  81. package/math.js.map +1 -1
  82. package/media.cjs +275 -84
  83. package/media.cjs.map +1 -1
  84. package/media.d.ts +188 -2
  85. package/media.js +274 -93
  86. package/media.js.map +1 -1
  87. package/mobx.cjs +353 -193
  88. package/mobx.cjs.map +1 -1
  89. package/mobx.d.ts +172 -6
  90. package/mobx.js +351 -200
  91. package/mobx.js.map +1 -1
  92. package/ms.cjs +21 -10
  93. package/ms.cjs.map +1 -1
  94. package/ms.d.ts +1 -1
  95. package/ms.js +22 -13
  96. package/ms.js.map +1 -1
  97. package/number.cjs +13 -7
  98. package/number.cjs.map +1 -1
  99. package/number.js +14 -9
  100. package/number.js.map +1 -1
  101. package/package.json +13 -5
  102. package/parser.cjs +117 -64
  103. package/parser.cjs.map +1 -1
  104. package/parser.d.ts +63 -0
  105. package/parser.js +111 -64
  106. package/parser.js.map +1 -1
  107. package/price.cjs +24 -18
  108. package/price.cjs.map +1 -1
  109. package/price.d.ts +8 -0
  110. package/price.js +25 -20
  111. package/price.js.map +1 -1
  112. package/random.cjs +79 -13
  113. package/random.cjs.map +1 -1
  114. package/random.d.ts +64 -0
  115. package/random.js +80 -22
  116. package/random.js.map +1 -1
  117. package/react.cjs +673 -214
  118. package/react.cjs.map +1 -1
  119. package/react.d.ts +428 -9
  120. package/react.js +674 -239
  121. package/react.js.map +1 -1
  122. package/sound.cjs +14 -9
  123. package/sound.cjs.map +1 -1
  124. package/sound.d.ts +1 -1
  125. package/sound.js +15 -11
  126. package/sound.js.map +1 -1
  127. package/storage.cjs +49 -50
  128. package/storage.cjs.map +1 -1
  129. package/storage.d.ts +15 -6
  130. package/storage.js +50 -53
  131. package/storage.js.map +1 -1
  132. package/text.cjs +51 -34
  133. package/text.cjs.map +1 -1
  134. package/text.d.ts +5 -5
  135. package/text.js +52 -37
  136. package/text.js.map +1 -1
  137. package/type-guard.cjs +292 -72
  138. package/type-guard.cjs.map +1 -1
  139. package/type-guard.d.ts +199 -42
  140. package/type-guard.js +288 -73
  141. package/type-guard.js.map +1 -1
  142. package/types.cjs +0 -2
  143. package/types.global.cjs +0 -2
  144. package/types.global.js +0 -2
  145. package/types.js +0 -2
  146. package/vibrate.cjs +31 -6
  147. package/vibrate.cjs.map +1 -1
  148. package/vibrate.d.ts +23 -1
  149. package/vibrate.js +32 -8
  150. package/vibrate.js.map +1 -1
  151. package/types.cjs.map +0 -1
  152. package/types.global.cjs.map +0 -1
  153. package/types.global.js.map +0 -1
  154. package/types.js.map +0 -1
package/css.cjs CHANGED
@@ -1,46 +1,154 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const classVarianceAuthority = require("class-variance-authority");
4
- const clsx = require("clsx");
5
- const tailwindMerge = require("tailwind-merge");
6
- const toRem = (px, remValue = 16) => `${px / remValue}rem`;
7
- const cx = (...args) => tailwindMerge.twMerge(clsx(...args));
8
- const cva = ((...args) => {
9
- const schema = classVarianceAuthority.cva(...args);
10
- return (...inputArgs) => tailwindMerge.twMerge(schema(...inputArgs));
2
+ const require_chunk = require("./chunk-CVq3Gv4J.cjs");
3
+ let class_variance_authority = require("class-variance-authority");
4
+ let clsx = require("clsx");
5
+ clsx = require_chunk.__toESM(clsx);
6
+ let tailwind_merge = require("tailwind-merge");
7
+ //#region src/css.ts
8
+ /**
9
+ * Converts a length in **pixels** to a CSS **`rem`** string (`"<number>rem"`).
10
+ *
11
+ * Use when authoring component styles in JS/TS where design tokens are in px but the stylesheet
12
+ * should scale with root font size (accessibility, user zoom). `remValue` is the assumed
13
+ * `1rem` size in px (browser default is typically `16`).
14
+ *
15
+ * @param px - Pixel value to convert (not rounded; stringification keeps full float).
16
+ * @param remValue - How many pixels one `rem` equals. Defaults to `16`.
17
+ * @returns A string like `"1.5rem"` suitable for `style` or CSS-in-JS.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const width = toRem(24); // '1.5rem' with default 16px root
22
+ * ```
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * // Custom root / design system where 1rem === 10px
27
+ * const gap = toRem(20, 10); // '2rem'
28
+ * ```
29
+ */
30
+ var toRem = (px, remValue = 16) => `${px / remValue}rem`;
31
+ /**
32
+ * Composes conditional class names like {@link https://github.com/lukeed/clsx | clsx}, then runs
33
+ * the result through {@link https://github.com/dcastil/tailwind-merge | tailwind-merge} so
34
+ * conflicting Tailwind utilities collapse to the last/intended one (e.g. two `padding-x` classes).
35
+ *
36
+ * Accepts the same argument shapes as `clsx`: strings, objects, arrays, falsy values to omit.
37
+ *
38
+ * @param args - Same as `clsx(...args)` — `ClassValue` rest parameters.
39
+ * @returns A single merged class string, safe for `className` on DOM/React.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * cx('px-2 py-1 text-sm', 'px-4'); // 'py-1 text-sm px-4' — padding-x merged
44
+ * ```
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * cx('btn', { 'btn--active': isActive, 'btn--disabled': disabled }, className);
49
+ * ```
50
+ */
51
+ var cx = (...args) => (0, tailwind_merge.twMerge)((0, clsx.default)(...args));
52
+ /**
53
+ * {@link https://cva.style/docs | Class Variance Authority (cva)} with the same **tailwind-merge**
54
+ * pass as {@link cx}: the class string produced by the variant function is merged so Tailwind
55
+ * conflicts resolve predictably.
56
+ *
57
+ * API matches `cva` from `class-variance-authority`: optional `base` classes, `config` with
58
+ * `variants`, `defaultVariants`, and `compoundVariants`. The returned function accepts variant
59
+ * props plus optional `class` / `className` for one-off overrides.
60
+ *
61
+ * Use {@link VariantProps} with `typeof buttonVariants` (or similar) to type component props.
62
+ *
63
+ * @param base - Base `ClassValue`(s) always applied.
64
+ * @param config - Variant schema and defaults (same shape as upstream `cva`).
65
+ * @returns A function `(props?) => string` that resolves variant classes, merged with tw-merge.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const button = cva('rounded font-medium', {
70
+ * variants: {
71
+ * tone: { primary: 'bg-blue-600 text-white', ghost: 'bg-transparent' },
72
+ * size: { sm: 'text-sm px-2', md: 'text-base px-4' },
73
+ * },
74
+ * defaultVariants: { tone: 'primary', size: 'md' },
75
+ * });
76
+ * button({ tone: 'ghost', className: 'ml-2' });
77
+ * ```
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * const card = cva('border p-4', {
82
+ * variants: { elevated: { true: 'shadow-lg', false: 'shadow-none' } },
83
+ * defaultVariants: { elevated: false },
84
+ * });
85
+ * card({ elevated: true });
86
+ * ```
87
+ */
88
+ var cva = ((...args) => {
89
+ const schema = (0, class_variance_authority.cva)(...args);
90
+ return (...inputArgs) => (0, tailwind_merge.twMerge)(schema(...inputArgs));
11
91
  });
12
- const loadCssFile = (url, attrubutes) => new Promise((resolve, reject) => {
13
- let link;
14
- if (attrubutes?.id) {
15
- link = document.getElementById(attrubutes.id);
16
- if (link) {
17
- link.remove();
18
- }
19
- }
20
- link = document.createElement("link");
21
- const handleLoad = () => {
22
- resolve(void 0);
23
- link.removeEventListener("load", handleLoad);
24
- link.removeEventListener("error", handleError);
25
- };
26
- const handleError = () => {
27
- reject(void 0);
28
- link.removeEventListener("load", handleLoad);
29
- link.removeEventListener("error", handleError);
30
- };
31
- link.addEventListener("load", handleLoad);
32
- link.addEventListener("error", handleError);
33
- link.setAttribute("href", url);
34
- if (!attrubutes?.rel) {
35
- link.setAttribute("rel", "stylesheet");
36
- }
37
- Object.entries(attrubutes || {}).forEach(([key, value]) => {
38
- link.setAttribute(key, value);
39
- });
40
- document.head.appendChild(link);
92
+ /**
93
+ * Injects a stylesheet by appending a `<link rel="stylesheet">` to `document.head`.
94
+ * Resolves when the sheet fires `load`; rejects on `error` (e.g. 404 or network failure).
95
+ *
96
+ * **Id replacement:** if `attrubutes.id` is set, any existing element with that `id` is removed
97
+ * first, so repeated calls with the same `id` replace the previous link (useful for theme or
98
+ * font URLs that change).
99
+ *
100
+ * If `rel` is omitted in `attrubutes`, it defaults to `stylesheet`. Other attributes (`crossorigin`,
101
+ * `media`, `data-*`, etc.) are set via `setAttribute` from the record entries.
102
+ *
103
+ * @param url - Stylesheet URL (`href`).
104
+ * @param attrubutes - Optional HTML attributes for the `<link>` element (see `id` / `rel` behavior above).
105
+ * @returns Promise that resolves to `undefined` on load, or rejects on load error.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * await loadCssFile('https://example.com/fonts.css', {
110
+ * id: 'app-fonts',
111
+ * crossOrigin: 'anonymous',
112
+ * });
113
+ * ```
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * // Swap theme stylesheet without duplicate link tags
118
+ * await loadCssFile('/themes/dark.css', { id: 'theme' });
119
+ * await loadCssFile('/themes/light.css', { id: 'theme' });
120
+ * ```
121
+ */
122
+ var loadCssFile = (url, attrubutes) => new Promise((resolve, reject) => {
123
+ let link;
124
+ if (attrubutes?.id) {
125
+ link = document.getElementById(attrubutes.id);
126
+ if (link) link.remove();
127
+ }
128
+ link = document.createElement("link");
129
+ const handleLoad = () => {
130
+ resolve(void 0);
131
+ link.removeEventListener("load", handleLoad);
132
+ link.removeEventListener("error", handleError);
133
+ };
134
+ const handleError = () => {
135
+ reject(void 0);
136
+ link.removeEventListener("load", handleLoad);
137
+ link.removeEventListener("error", handleError);
138
+ };
139
+ link.addEventListener("load", handleLoad);
140
+ link.addEventListener("error", handleError);
141
+ link.setAttribute("href", url);
142
+ if (!attrubutes?.rel) link.setAttribute("rel", "stylesheet");
143
+ Object.entries(attrubutes || {}).forEach(([key, value]) => {
144
+ link.setAttribute(key, value);
145
+ });
146
+ document.head.appendChild(link);
41
147
  });
148
+ //#endregion
42
149
  exports.cva = cva;
43
150
  exports.cx = cx;
44
151
  exports.loadCssFile = loadCssFile;
45
152
  exports.toRem = toRem;
46
- //# sourceMappingURL=css.cjs.map
153
+
154
+ //# sourceMappingURL=css.cjs.map
package/css.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"css.cjs","sources":["../src/css.ts"],"sourcesContent":["import { cva as cvaLib } from 'class-variance-authority';\nimport clsx, { type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\nimport type { Maybe } from 'yummies/types';\n\ntype ClassProp = {\n class?: ClassValue;\n className?: ClassValue;\n};\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;\n\n/**\n * Перевод значения в пикселях в rem строковое\n */\nexport const toRem = (px: number, remValue = 16) => `${px / remValue}rem`;\n\n/**\n * classNames/clsx но с примесями tailwind-merge\n */\nexport const cx = (...args: Parameters<typeof clsx>) => twMerge(clsx(...args));\n\ntype ConfigSchema = Record<string, Record<string, ClassValue>>;\ntype ConfigVariants<T extends ConfigSchema> = {\n [Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | null | undefined;\n};\ntype ConfigVariantsMulti<T extends ConfigSchema> = {\n [Variant in keyof T]?:\n | StringToBoolean<keyof T[Variant]>\n | StringToBoolean<keyof T[Variant]>[]\n | undefined;\n};\ntype Config<T> = T extends ConfigSchema\n ? {\n variants?: T;\n defaultVariants?: ConfigVariants<T>;\n compoundVariants?: (T extends ConfigSchema\n ? (ConfigVariants<T> | ConfigVariantsMulti<T>) & ClassProp\n : ClassProp)[];\n }\n : never;\n\ntype Props<T> = T extends ConfigSchema\n ? ConfigVariants<T> & ClassProp\n : ClassProp;\n\n/**\n * Class Variance Authority но с примесями tailwind-merge\n *\n * https://cva.style/docs\n */\nexport const cva = ((...args: any[]) => {\n const schema = cvaLib(...args);\n return (...inputArgs: any[]) => twMerge(schema(...inputArgs));\n}) as any as <T>(\n base?: ClassValue,\n config?: Config<T>,\n) => (props?: Props<T>) => string;\n\nexport type { VariantProps } from 'class-variance-authority';\nexport type { ClassValue } from 'clsx';\n\n/**\n * Load CSS file by providing `url`.\n *\n * **NOTE:** If `id` is provided, it will remove the existing link element with the same `id` before creating a new one.\n */\nexport const loadCssFile = (url: string, attrubutes?: Record<string, any>) =>\n new Promise((resolve, reject) => {\n let link: Maybe<HTMLLinkElement>;\n\n if (attrubutes?.id) {\n link = document.getElementById(attrubutes.id) as HTMLLinkElement | null;\n\n if (link) {\n link.remove();\n }\n }\n\n link = document.createElement('link');\n\n const handleLoad = () => {\n resolve(undefined);\n link!.removeEventListener('load', handleLoad);\n link!.removeEventListener('error', handleError);\n };\n\n const handleError = () => {\n reject(undefined);\n link!.removeEventListener('load', handleLoad);\n link!.removeEventListener('error', handleError);\n };\n\n link.addEventListener('load', handleLoad);\n link.addEventListener('error', handleError);\n\n link.setAttribute('href', url);\n\n if (!attrubutes?.rel) {\n link.setAttribute('rel', 'stylesheet');\n }\n\n Object.entries(attrubutes || {}).forEach(([key, value]) => {\n link.setAttribute(key, value);\n });\n\n document.head.appendChild(link);\n });\n"],"names":["twMerge","cvaLib"],"mappings":";;;;;AAeO,MAAM,QAAQ,CAAC,IAAY,WAAW,OAAO,GAAG,KAAK,QAAQ;AAK7D,MAAM,KAAK,IAAI,SAAkCA,cAAAA,QAAQ,KAAK,GAAG,IAAI,CAAC;AA+BtE,MAAM,OAAO,IAAI,SAAgB;AACtC,QAAM,SAASC,2BAAO,GAAG,IAAI;AAC7B,SAAO,IAAI,cAAqBD,cAAAA,QAAQ,OAAO,GAAG,SAAS,CAAC;AAC9D;AAaO,MAAM,cAAc,CAAC,KAAa,eACvC,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC/B,MAAI;AAEJ,MAAI,YAAY,IAAI;AAClB,WAAO,SAAS,eAAe,WAAW,EAAE;AAE5C,QAAI,MAAM;AACR,WAAK,OAAA;AAAA,IACP;AAAA,EACF;AAEA,SAAO,SAAS,cAAc,MAAM;AAEpC,QAAM,aAAa,MAAM;AACvB,YAAQ,MAAS;AACjB,SAAM,oBAAoB,QAAQ,UAAU;AAC5C,SAAM,oBAAoB,SAAS,WAAW;AAAA,EAChD;AAEA,QAAM,cAAc,MAAM;AACxB,WAAO,MAAS;AAChB,SAAM,oBAAoB,QAAQ,UAAU;AAC5C,SAAM,oBAAoB,SAAS,WAAW;AAAA,EAChD;AAEA,OAAK,iBAAiB,QAAQ,UAAU;AACxC,OAAK,iBAAiB,SAAS,WAAW;AAE1C,OAAK,aAAa,QAAQ,GAAG;AAE7B,MAAI,CAAC,YAAY,KAAK;AACpB,SAAK,aAAa,OAAO,YAAY;AAAA,EACvC;AAEA,SAAO,QAAQ,cAAc,CAAA,CAAE,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACzD,SAAK,aAAa,KAAK,KAAK;AAAA,EAC9B,CAAC;AAED,WAAS,KAAK,YAAY,IAAI;AAChC,CAAC;;;;;"}
1
+ {"version":3,"file":"css.cjs","names":[],"sources":["../src/css.ts"],"sourcesContent":["import { cva as cvaLib } from 'class-variance-authority';\nimport clsx, { type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\nimport type { Maybe } from 'yummies/types';\n\ntype ClassProp = {\n class?: ClassValue;\n className?: ClassValue;\n};\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;\n\n/**\n * Converts a length in **pixels** to a CSS **`rem`** string (`\"<number>rem\"`).\n *\n * Use when authoring component styles in JS/TS where design tokens are in px but the stylesheet\n * should scale with root font size (accessibility, user zoom). `remValue` is the assumed\n * `1rem` size in px (browser default is typically `16`).\n *\n * @param px - Pixel value to convert (not rounded; stringification keeps full float).\n * @param remValue - How many pixels one `rem` equals. Defaults to `16`.\n * @returns A string like `\"1.5rem\"` suitable for `style` or CSS-in-JS.\n *\n * @example\n * ```ts\n * const width = toRem(24); // '1.5rem' with default 16px root\n * ```\n *\n * @example\n * ```ts\n * // Custom root / design system where 1rem === 10px\n * const gap = toRem(20, 10); // '2rem'\n * ```\n */\nexport const toRem = (px: number, remValue = 16) => `${px / remValue}rem`;\n\n/**\n * Composes conditional class names like {@link https://github.com/lukeed/clsx | clsx}, then runs\n * the result through {@link https://github.com/dcastil/tailwind-merge | tailwind-merge} so\n * conflicting Tailwind utilities collapse to the last/intended one (e.g. two `padding-x` classes).\n *\n * Accepts the same argument shapes as `clsx`: strings, objects, arrays, falsy values to omit.\n *\n * @param args - Same as `clsx(...args)` — `ClassValue` rest parameters.\n * @returns A single merged class string, safe for `className` on DOM/React.\n *\n * @example\n * ```ts\n * cx('px-2 py-1 text-sm', 'px-4'); // 'py-1 text-sm px-4' — padding-x merged\n * ```\n *\n * @example\n * ```ts\n * cx('btn', { 'btn--active': isActive, 'btn--disabled': disabled }, className);\n * ```\n */\nexport const cx = (...args: Parameters<typeof clsx>) => twMerge(clsx(...args));\n\ntype ConfigSchema = Record<string, Record<string, ClassValue>>;\ntype ConfigVariants<T extends ConfigSchema> = {\n [Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | null | undefined;\n};\ntype ConfigVariantsMulti<T extends ConfigSchema> = {\n [Variant in keyof T]?:\n | StringToBoolean<keyof T[Variant]>\n | StringToBoolean<keyof T[Variant]>[]\n | undefined;\n};\ntype Config<T> = T extends ConfigSchema\n ? {\n variants?: T;\n defaultVariants?: ConfigVariants<T>;\n compoundVariants?: (T extends ConfigSchema\n ? (ConfigVariants<T> | ConfigVariantsMulti<T>) & ClassProp\n : ClassProp)[];\n }\n : never;\n\ntype Props<T> = T extends ConfigSchema\n ? ConfigVariants<T> & ClassProp\n : ClassProp;\n\n/**\n * {@link https://cva.style/docs | Class Variance Authority (cva)} with the same **tailwind-merge**\n * pass as {@link cx}: the class string produced by the variant function is merged so Tailwind\n * conflicts resolve predictably.\n *\n * API matches `cva` from `class-variance-authority`: optional `base` classes, `config` with\n * `variants`, `defaultVariants`, and `compoundVariants`. The returned function accepts variant\n * props plus optional `class` / `className` for one-off overrides.\n *\n * Use {@link VariantProps} with `typeof buttonVariants` (or similar) to type component props.\n *\n * @param base - Base `ClassValue`(s) always applied.\n * @param config - Variant schema and defaults (same shape as upstream `cva`).\n * @returns A function `(props?) => string` that resolves variant classes, merged with tw-merge.\n *\n * @example\n * ```ts\n * const button = cva('rounded font-medium', {\n * variants: {\n * tone: { primary: 'bg-blue-600 text-white', ghost: 'bg-transparent' },\n * size: { sm: 'text-sm px-2', md: 'text-base px-4' },\n * },\n * defaultVariants: { tone: 'primary', size: 'md' },\n * });\n * button({ tone: 'ghost', className: 'ml-2' });\n * ```\n *\n * @example\n * ```ts\n * const card = cva('border p-4', {\n * variants: { elevated: { true: 'shadow-lg', false: 'shadow-none' } },\n * defaultVariants: { elevated: false },\n * });\n * card({ elevated: true });\n * ```\n */\nexport const cva = ((...args: any[]) => {\n const schema = cvaLib(...args);\n return (...inputArgs: any[]) => twMerge(schema(...inputArgs));\n}) as any as <T>(\n base?: ClassValue,\n config?: Config<T>,\n) => (props?: Props<T>) => string;\n\n/**\n * Utility type from `class-variance-authority`: infers the variant prop object from a `cva` instance.\n * Use it to type React (or other) components that forward variant props.\n *\n * @example\n * ```ts\n * const input = cva('border', { variants: { size: { sm: 'h-8', lg: 'h-12' } } });\n * type InputVariants = VariantProps<typeof input>;\n * // { size?: 'sm' | 'lg' | null }\n * ```\n */\nexport type { VariantProps } from 'class-variance-authority';\n\n/**\n * Re-export from `clsx`: a class name fragment — string, number, nested arrays, object map of\n * flags, or falsy nodes to skip. Used by {@link cx}, {@link cva}, and typical `className` helpers.\n *\n * @example\n * ```ts\n * const value: ClassValue = ['btn', false && 'hidden', { active: true }];\n * ```\n */\nexport type { ClassValue } from 'clsx';\n\n/**\n * Injects a stylesheet by appending a `<link rel=\"stylesheet\">` to `document.head`.\n * Resolves when the sheet fires `load`; rejects on `error` (e.g. 404 or network failure).\n *\n * **Id replacement:** if `attrubutes.id` is set, any existing element with that `id` is removed\n * first, so repeated calls with the same `id` replace the previous link (useful for theme or\n * font URLs that change).\n *\n * If `rel` is omitted in `attrubutes`, it defaults to `stylesheet`. Other attributes (`crossorigin`,\n * `media`, `data-*`, etc.) are set via `setAttribute` from the record entries.\n *\n * @param url - Stylesheet URL (`href`).\n * @param attrubutes - Optional HTML attributes for the `<link>` element (see `id` / `rel` behavior above).\n * @returns Promise that resolves to `undefined` on load, or rejects on load error.\n *\n * @example\n * ```ts\n * await loadCssFile('https://example.com/fonts.css', {\n * id: 'app-fonts',\n * crossOrigin: 'anonymous',\n * });\n * ```\n *\n * @example\n * ```ts\n * // Swap theme stylesheet without duplicate link tags\n * await loadCssFile('/themes/dark.css', { id: 'theme' });\n * await loadCssFile('/themes/light.css', { id: 'theme' });\n * ```\n */\nexport const loadCssFile = (url: string, attrubutes?: Record<string, any>) =>\n new Promise((resolve, reject) => {\n let link: Maybe<HTMLLinkElement>;\n\n if (attrubutes?.id) {\n link = document.getElementById(attrubutes.id) as HTMLLinkElement | null;\n\n if (link) {\n link.remove();\n }\n }\n\n link = document.createElement('link');\n\n const handleLoad = () => {\n resolve(undefined);\n link!.removeEventListener('load', handleLoad);\n link!.removeEventListener('error', handleError);\n };\n\n const handleError = () => {\n reject(undefined);\n link!.removeEventListener('load', handleLoad);\n link!.removeEventListener('error', handleError);\n };\n\n link.addEventListener('load', handleLoad);\n link.addEventListener('error', handleError);\n\n link.setAttribute('href', url);\n\n if (!attrubutes?.rel) {\n link.setAttribute('rel', 'stylesheet');\n }\n\n Object.entries(attrubutes || {}).forEach(([key, value]) => {\n link.setAttribute(key, value);\n });\n\n document.head.appendChild(link);\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,SAAS,IAAY,WAAW,OAAO,GAAG,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;AAsBrE,IAAa,MAAM,GAAG,UAAA,GAAA,eAAA,UAAA,GAAA,KAAA,SAA+C,GAAG,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8D9E,IAAa,QAAQ,GAAG,SAAgB;CACtC,MAAM,UAAA,GAAA,yBAAA,KAAgB,GAAG,KAAK;AAC9B,SAAQ,GAAG,eAAA,GAAA,eAAA,SAA6B,OAAO,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4D/D,IAAa,eAAe,KAAa,eACvC,IAAI,SAAS,SAAS,WAAW;CAC/B,IAAI;AAEJ,KAAI,YAAY,IAAI;AAClB,SAAO,SAAS,eAAe,WAAW,GAAG;AAE7C,MAAI,KACF,MAAK,QAAQ;;AAIjB,QAAO,SAAS,cAAc,OAAO;CAErC,MAAM,mBAAmB;AACvB,UAAQ,KAAA,EAAU;AAClB,OAAM,oBAAoB,QAAQ,WAAW;AAC7C,OAAM,oBAAoB,SAAS,YAAY;;CAGjD,MAAM,oBAAoB;AACxB,SAAO,KAAA,EAAU;AACjB,OAAM,oBAAoB,QAAQ,WAAW;AAC7C,OAAM,oBAAoB,SAAS,YAAY;;AAGjD,MAAK,iBAAiB,QAAQ,WAAW;AACzC,MAAK,iBAAiB,SAAS,YAAY;AAE3C,MAAK,aAAa,QAAQ,IAAI;AAE9B,KAAI,CAAC,YAAY,IACf,MAAK,aAAa,OAAO,aAAa;AAGxC,QAAO,QAAQ,cAAc,EAAE,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;AACzD,OAAK,aAAa,KAAK,MAAM;GAC7B;AAEF,UAAS,KAAK,YAAY,KAAK;EAC/B"}
package/css.d.ts CHANGED
@@ -8,11 +8,47 @@ type ClassProp = {
8
8
  };
9
9
  type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
10
10
  /**
11
- * Перевод значения в пикселях в rem строковое
11
+ * Converts a length in **pixels** to a CSS **`rem`** string (`"<number>rem"`).
12
+ *
13
+ * Use when authoring component styles in JS/TS where design tokens are in px but the stylesheet
14
+ * should scale with root font size (accessibility, user zoom). `remValue` is the assumed
15
+ * `1rem` size in px (browser default is typically `16`).
16
+ *
17
+ * @param px - Pixel value to convert (not rounded; stringification keeps full float).
18
+ * @param remValue - How many pixels one `rem` equals. Defaults to `16`.
19
+ * @returns A string like `"1.5rem"` suitable for `style` or CSS-in-JS.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * const width = toRem(24); // '1.5rem' with default 16px root
24
+ * ```
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * // Custom root / design system where 1rem === 10px
29
+ * const gap = toRem(20, 10); // '2rem'
30
+ * ```
12
31
  */
13
32
  declare const toRem: (px: number, remValue?: number) => string;
14
33
  /**
15
- * classNames/clsx но с примесями tailwind-merge
34
+ * Composes conditional class names like {@link https://github.com/lukeed/clsx | clsx}, then runs
35
+ * the result through {@link https://github.com/dcastil/tailwind-merge | tailwind-merge} so
36
+ * conflicting Tailwind utilities collapse to the last/intended one (e.g. two `padding-x` classes).
37
+ *
38
+ * Accepts the same argument shapes as `clsx`: strings, objects, arrays, falsy values to omit.
39
+ *
40
+ * @param args - Same as `clsx(...args)` — `ClassValue` rest parameters.
41
+ * @returns A single merged class string, safe for `className` on DOM/React.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * cx('px-2 py-1 text-sm', 'px-4'); // 'py-1 text-sm px-4' — padding-x merged
46
+ * ```
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * cx('btn', { 'btn--active': isActive, 'btn--disabled': disabled }, className);
51
+ * ```
16
52
  */
17
53
  declare const cx: (...args: Parameters<typeof clsx>) => string;
18
54
  type ConfigSchema = Record<string, Record<string, ClassValue>>;
@@ -29,16 +65,72 @@ type Config<T> = T extends ConfigSchema ? {
29
65
  } : never;
30
66
  type Props<T> = T extends ConfigSchema ? ConfigVariants<T> & ClassProp : ClassProp;
31
67
  /**
32
- * Class Variance Authority но с примесями tailwind-merge
68
+ * {@link https://cva.style/docs | Class Variance Authority (cva)} with the same **tailwind-merge**
69
+ * pass as {@link cx}: the class string produced by the variant function is merged so Tailwind
70
+ * conflicts resolve predictably.
33
71
  *
34
- * https://cva.style/docs
72
+ * API matches `cva` from `class-variance-authority`: optional `base` classes, `config` with
73
+ * `variants`, `defaultVariants`, and `compoundVariants`. The returned function accepts variant
74
+ * props plus optional `class` / `className` for one-off overrides.
75
+ *
76
+ * Use {@link VariantProps} with `typeof buttonVariants` (or similar) to type component props.
77
+ *
78
+ * @param base - Base `ClassValue`(s) always applied.
79
+ * @param config - Variant schema and defaults (same shape as upstream `cva`).
80
+ * @returns A function `(props?) => string` that resolves variant classes, merged with tw-merge.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * const button = cva('rounded font-medium', {
85
+ * variants: {
86
+ * tone: { primary: 'bg-blue-600 text-white', ghost: 'bg-transparent' },
87
+ * size: { sm: 'text-sm px-2', md: 'text-base px-4' },
88
+ * },
89
+ * defaultVariants: { tone: 'primary', size: 'md' },
90
+ * });
91
+ * button({ tone: 'ghost', className: 'ml-2' });
92
+ * ```
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const card = cva('border p-4', {
97
+ * variants: { elevated: { true: 'shadow-lg', false: 'shadow-none' } },
98
+ * defaultVariants: { elevated: false },
99
+ * });
100
+ * card({ elevated: true });
101
+ * ```
35
102
  */
36
103
  declare const cva: <T>(base?: ClassValue, config?: Config<T>) => (props?: Props<T>) => string;
37
104
 
38
105
  /**
39
- * Load CSS file by providing `url`.
106
+ * Injects a stylesheet by appending a `<link rel="stylesheet">` to `document.head`.
107
+ * Resolves when the sheet fires `load`; rejects on `error` (e.g. 404 or network failure).
108
+ *
109
+ * **Id replacement:** if `attrubutes.id` is set, any existing element with that `id` is removed
110
+ * first, so repeated calls with the same `id` replace the previous link (useful for theme or
111
+ * font URLs that change).
112
+ *
113
+ * If `rel` is omitted in `attrubutes`, it defaults to `stylesheet`. Other attributes (`crossorigin`,
114
+ * `media`, `data-*`, etc.) are set via `setAttribute` from the record entries.
115
+ *
116
+ * @param url - Stylesheet URL (`href`).
117
+ * @param attrubutes - Optional HTML attributes for the `<link>` element (see `id` / `rel` behavior above).
118
+ * @returns Promise that resolves to `undefined` on load, or rejects on load error.
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * await loadCssFile('https://example.com/fonts.css', {
123
+ * id: 'app-fonts',
124
+ * crossOrigin: 'anonymous',
125
+ * });
126
+ * ```
40
127
  *
41
- * **NOTE:** If `id` is provided, it will remove the existing link element with the same `id` before creating a new one.
128
+ * @example
129
+ * ```ts
130
+ * // Swap theme stylesheet without duplicate link tags
131
+ * await loadCssFile('/themes/dark.css', { id: 'theme' });
132
+ * await loadCssFile('/themes/light.css', { id: 'theme' });
133
+ * ```
42
134
  */
43
135
  declare const loadCssFile: (url: string, attrubutes?: Record<string, any>) => Promise<unknown>;
44
136
 
package/css.js CHANGED
@@ -1,46 +1,148 @@
1
1
  import { cva as cva$1 } from "class-variance-authority";
2
2
  import clsx from "clsx";
3
3
  import { twMerge } from "tailwind-merge";
4
- const toRem = (px, remValue = 16) => `${px / remValue}rem`;
5
- const cx = (...args) => twMerge(clsx(...args));
6
- const cva = ((...args) => {
7
- const schema = cva$1(...args);
8
- return (...inputArgs) => twMerge(schema(...inputArgs));
4
+ //#region src/css.ts
5
+ /**
6
+ * Converts a length in **pixels** to a CSS **`rem`** string (`"<number>rem"`).
7
+ *
8
+ * Use when authoring component styles in JS/TS where design tokens are in px but the stylesheet
9
+ * should scale with root font size (accessibility, user zoom). `remValue` is the assumed
10
+ * `1rem` size in px (browser default is typically `16`).
11
+ *
12
+ * @param px - Pixel value to convert (not rounded; stringification keeps full float).
13
+ * @param remValue - How many pixels one `rem` equals. Defaults to `16`.
14
+ * @returns A string like `"1.5rem"` suitable for `style` or CSS-in-JS.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const width = toRem(24); // '1.5rem' with default 16px root
19
+ * ```
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * // Custom root / design system where 1rem === 10px
24
+ * const gap = toRem(20, 10); // '2rem'
25
+ * ```
26
+ */
27
+ var toRem = (px, remValue = 16) => `${px / remValue}rem`;
28
+ /**
29
+ * Composes conditional class names like {@link https://github.com/lukeed/clsx | clsx}, then runs
30
+ * the result through {@link https://github.com/dcastil/tailwind-merge | tailwind-merge} so
31
+ * conflicting Tailwind utilities collapse to the last/intended one (e.g. two `padding-x` classes).
32
+ *
33
+ * Accepts the same argument shapes as `clsx`: strings, objects, arrays, falsy values to omit.
34
+ *
35
+ * @param args - Same as `clsx(...args)` — `ClassValue` rest parameters.
36
+ * @returns A single merged class string, safe for `className` on DOM/React.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * cx('px-2 py-1 text-sm', 'px-4'); // 'py-1 text-sm px-4' — padding-x merged
41
+ * ```
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * cx('btn', { 'btn--active': isActive, 'btn--disabled': disabled }, className);
46
+ * ```
47
+ */
48
+ var cx = (...args) => twMerge(clsx(...args));
49
+ /**
50
+ * {@link https://cva.style/docs | Class Variance Authority (cva)} with the same **tailwind-merge**
51
+ * pass as {@link cx}: the class string produced by the variant function is merged so Tailwind
52
+ * conflicts resolve predictably.
53
+ *
54
+ * API matches `cva` from `class-variance-authority`: optional `base` classes, `config` with
55
+ * `variants`, `defaultVariants`, and `compoundVariants`. The returned function accepts variant
56
+ * props plus optional `class` / `className` for one-off overrides.
57
+ *
58
+ * Use {@link VariantProps} with `typeof buttonVariants` (or similar) to type component props.
59
+ *
60
+ * @param base - Base `ClassValue`(s) always applied.
61
+ * @param config - Variant schema and defaults (same shape as upstream `cva`).
62
+ * @returns A function `(props?) => string` that resolves variant classes, merged with tw-merge.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const button = cva('rounded font-medium', {
67
+ * variants: {
68
+ * tone: { primary: 'bg-blue-600 text-white', ghost: 'bg-transparent' },
69
+ * size: { sm: 'text-sm px-2', md: 'text-base px-4' },
70
+ * },
71
+ * defaultVariants: { tone: 'primary', size: 'md' },
72
+ * });
73
+ * button({ tone: 'ghost', className: 'ml-2' });
74
+ * ```
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const card = cva('border p-4', {
79
+ * variants: { elevated: { true: 'shadow-lg', false: 'shadow-none' } },
80
+ * defaultVariants: { elevated: false },
81
+ * });
82
+ * card({ elevated: true });
83
+ * ```
84
+ */
85
+ var cva = ((...args) => {
86
+ const schema = cva$1(...args);
87
+ return (...inputArgs) => twMerge(schema(...inputArgs));
9
88
  });
10
- const loadCssFile = (url, attrubutes) => new Promise((resolve, reject) => {
11
- let link;
12
- if (attrubutes?.id) {
13
- link = document.getElementById(attrubutes.id);
14
- if (link) {
15
- link.remove();
16
- }
17
- }
18
- link = document.createElement("link");
19
- const handleLoad = () => {
20
- resolve(void 0);
21
- link.removeEventListener("load", handleLoad);
22
- link.removeEventListener("error", handleError);
23
- };
24
- const handleError = () => {
25
- reject(void 0);
26
- link.removeEventListener("load", handleLoad);
27
- link.removeEventListener("error", handleError);
28
- };
29
- link.addEventListener("load", handleLoad);
30
- link.addEventListener("error", handleError);
31
- link.setAttribute("href", url);
32
- if (!attrubutes?.rel) {
33
- link.setAttribute("rel", "stylesheet");
34
- }
35
- Object.entries(attrubutes || {}).forEach(([key, value]) => {
36
- link.setAttribute(key, value);
37
- });
38
- document.head.appendChild(link);
89
+ /**
90
+ * Injects a stylesheet by appending a `<link rel="stylesheet">` to `document.head`.
91
+ * Resolves when the sheet fires `load`; rejects on `error` (e.g. 404 or network failure).
92
+ *
93
+ * **Id replacement:** if `attrubutes.id` is set, any existing element with that `id` is removed
94
+ * first, so repeated calls with the same `id` replace the previous link (useful for theme or
95
+ * font URLs that change).
96
+ *
97
+ * If `rel` is omitted in `attrubutes`, it defaults to `stylesheet`. Other attributes (`crossorigin`,
98
+ * `media`, `data-*`, etc.) are set via `setAttribute` from the record entries.
99
+ *
100
+ * @param url - Stylesheet URL (`href`).
101
+ * @param attrubutes - Optional HTML attributes for the `<link>` element (see `id` / `rel` behavior above).
102
+ * @returns Promise that resolves to `undefined` on load, or rejects on load error.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * await loadCssFile('https://example.com/fonts.css', {
107
+ * id: 'app-fonts',
108
+ * crossOrigin: 'anonymous',
109
+ * });
110
+ * ```
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * // Swap theme stylesheet without duplicate link tags
115
+ * await loadCssFile('/themes/dark.css', { id: 'theme' });
116
+ * await loadCssFile('/themes/light.css', { id: 'theme' });
117
+ * ```
118
+ */
119
+ var loadCssFile = (url, attrubutes) => new Promise((resolve, reject) => {
120
+ let link;
121
+ if (attrubutes?.id) {
122
+ link = document.getElementById(attrubutes.id);
123
+ if (link) link.remove();
124
+ }
125
+ link = document.createElement("link");
126
+ const handleLoad = () => {
127
+ resolve(void 0);
128
+ link.removeEventListener("load", handleLoad);
129
+ link.removeEventListener("error", handleError);
130
+ };
131
+ const handleError = () => {
132
+ reject(void 0);
133
+ link.removeEventListener("load", handleLoad);
134
+ link.removeEventListener("error", handleError);
135
+ };
136
+ link.addEventListener("load", handleLoad);
137
+ link.addEventListener("error", handleError);
138
+ link.setAttribute("href", url);
139
+ if (!attrubutes?.rel) link.setAttribute("rel", "stylesheet");
140
+ Object.entries(attrubutes || {}).forEach(([key, value]) => {
141
+ link.setAttribute(key, value);
142
+ });
143
+ document.head.appendChild(link);
39
144
  });
40
- export {
41
- cva,
42
- cx,
43
- loadCssFile,
44
- toRem
45
- };
46
- //# sourceMappingURL=css.js.map
145
+ //#endregion
146
+ export { cva, cx, loadCssFile, toRem };
147
+
148
+ //# sourceMappingURL=css.js.map
package/css.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"css.js","sources":["../src/css.ts"],"sourcesContent":["import { cva as cvaLib } from 'class-variance-authority';\nimport clsx, { type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\nimport type { Maybe } from 'yummies/types';\n\ntype ClassProp = {\n class?: ClassValue;\n className?: ClassValue;\n};\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;\n\n/**\n * Перевод значения в пикселях в rem строковое\n */\nexport const toRem = (px: number, remValue = 16) => `${px / remValue}rem`;\n\n/**\n * classNames/clsx но с примесями tailwind-merge\n */\nexport const cx = (...args: Parameters<typeof clsx>) => twMerge(clsx(...args));\n\ntype ConfigSchema = Record<string, Record<string, ClassValue>>;\ntype ConfigVariants<T extends ConfigSchema> = {\n [Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | null | undefined;\n};\ntype ConfigVariantsMulti<T extends ConfigSchema> = {\n [Variant in keyof T]?:\n | StringToBoolean<keyof T[Variant]>\n | StringToBoolean<keyof T[Variant]>[]\n | undefined;\n};\ntype Config<T> = T extends ConfigSchema\n ? {\n variants?: T;\n defaultVariants?: ConfigVariants<T>;\n compoundVariants?: (T extends ConfigSchema\n ? (ConfigVariants<T> | ConfigVariantsMulti<T>) & ClassProp\n : ClassProp)[];\n }\n : never;\n\ntype Props<T> = T extends ConfigSchema\n ? ConfigVariants<T> & ClassProp\n : ClassProp;\n\n/**\n * Class Variance Authority но с примесями tailwind-merge\n *\n * https://cva.style/docs\n */\nexport const cva = ((...args: any[]) => {\n const schema = cvaLib(...args);\n return (...inputArgs: any[]) => twMerge(schema(...inputArgs));\n}) as any as <T>(\n base?: ClassValue,\n config?: Config<T>,\n) => (props?: Props<T>) => string;\n\nexport type { VariantProps } from 'class-variance-authority';\nexport type { ClassValue } from 'clsx';\n\n/**\n * Load CSS file by providing `url`.\n *\n * **NOTE:** If `id` is provided, it will remove the existing link element with the same `id` before creating a new one.\n */\nexport const loadCssFile = (url: string, attrubutes?: Record<string, any>) =>\n new Promise((resolve, reject) => {\n let link: Maybe<HTMLLinkElement>;\n\n if (attrubutes?.id) {\n link = document.getElementById(attrubutes.id) as HTMLLinkElement | null;\n\n if (link) {\n link.remove();\n }\n }\n\n link = document.createElement('link');\n\n const handleLoad = () => {\n resolve(undefined);\n link!.removeEventListener('load', handleLoad);\n link!.removeEventListener('error', handleError);\n };\n\n const handleError = () => {\n reject(undefined);\n link!.removeEventListener('load', handleLoad);\n link!.removeEventListener('error', handleError);\n };\n\n link.addEventListener('load', handleLoad);\n link.addEventListener('error', handleError);\n\n link.setAttribute('href', url);\n\n if (!attrubutes?.rel) {\n link.setAttribute('rel', 'stylesheet');\n }\n\n Object.entries(attrubutes || {}).forEach(([key, value]) => {\n link.setAttribute(key, value);\n });\n\n document.head.appendChild(link);\n });\n"],"names":["cvaLib"],"mappings":";;;AAeO,MAAM,QAAQ,CAAC,IAAY,WAAW,OAAO,GAAG,KAAK,QAAQ;AAK7D,MAAM,KAAK,IAAI,SAAkC,QAAQ,KAAK,GAAG,IAAI,CAAC;AA+BtE,MAAM,OAAO,IAAI,SAAgB;AACtC,QAAM,SAASA,MAAO,GAAG,IAAI;AAC7B,SAAO,IAAI,cAAqB,QAAQ,OAAO,GAAG,SAAS,CAAC;AAC9D;AAaO,MAAM,cAAc,CAAC,KAAa,eACvC,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC/B,MAAI;AAEJ,MAAI,YAAY,IAAI;AAClB,WAAO,SAAS,eAAe,WAAW,EAAE;AAE5C,QAAI,MAAM;AACR,WAAK,OAAA;AAAA,IACP;AAAA,EACF;AAEA,SAAO,SAAS,cAAc,MAAM;AAEpC,QAAM,aAAa,MAAM;AACvB,YAAQ,MAAS;AACjB,SAAM,oBAAoB,QAAQ,UAAU;AAC5C,SAAM,oBAAoB,SAAS,WAAW;AAAA,EAChD;AAEA,QAAM,cAAc,MAAM;AACxB,WAAO,MAAS;AAChB,SAAM,oBAAoB,QAAQ,UAAU;AAC5C,SAAM,oBAAoB,SAAS,WAAW;AAAA,EAChD;AAEA,OAAK,iBAAiB,QAAQ,UAAU;AACxC,OAAK,iBAAiB,SAAS,WAAW;AAE1C,OAAK,aAAa,QAAQ,GAAG;AAE7B,MAAI,CAAC,YAAY,KAAK;AACpB,SAAK,aAAa,OAAO,YAAY;AAAA,EACvC;AAEA,SAAO,QAAQ,cAAc,CAAA,CAAE,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACzD,SAAK,aAAa,KAAK,KAAK;AAAA,EAC9B,CAAC;AAED,WAAS,KAAK,YAAY,IAAI;AAChC,CAAC;"}
1
+ {"version":3,"file":"css.js","names":[],"sources":["../src/css.ts"],"sourcesContent":["import { cva as cvaLib } from 'class-variance-authority';\nimport clsx, { type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\nimport type { Maybe } from 'yummies/types';\n\ntype ClassProp = {\n class?: ClassValue;\n className?: ClassValue;\n};\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;\n\n/**\n * Converts a length in **pixels** to a CSS **`rem`** string (`\"<number>rem\"`).\n *\n * Use when authoring component styles in JS/TS where design tokens are in px but the stylesheet\n * should scale with root font size (accessibility, user zoom). `remValue` is the assumed\n * `1rem` size in px (browser default is typically `16`).\n *\n * @param px - Pixel value to convert (not rounded; stringification keeps full float).\n * @param remValue - How many pixels one `rem` equals. Defaults to `16`.\n * @returns A string like `\"1.5rem\"` suitable for `style` or CSS-in-JS.\n *\n * @example\n * ```ts\n * const width = toRem(24); // '1.5rem' with default 16px root\n * ```\n *\n * @example\n * ```ts\n * // Custom root / design system where 1rem === 10px\n * const gap = toRem(20, 10); // '2rem'\n * ```\n */\nexport const toRem = (px: number, remValue = 16) => `${px / remValue}rem`;\n\n/**\n * Composes conditional class names like {@link https://github.com/lukeed/clsx | clsx}, then runs\n * the result through {@link https://github.com/dcastil/tailwind-merge | tailwind-merge} so\n * conflicting Tailwind utilities collapse to the last/intended one (e.g. two `padding-x` classes).\n *\n * Accepts the same argument shapes as `clsx`: strings, objects, arrays, falsy values to omit.\n *\n * @param args - Same as `clsx(...args)` — `ClassValue` rest parameters.\n * @returns A single merged class string, safe for `className` on DOM/React.\n *\n * @example\n * ```ts\n * cx('px-2 py-1 text-sm', 'px-4'); // 'py-1 text-sm px-4' — padding-x merged\n * ```\n *\n * @example\n * ```ts\n * cx('btn', { 'btn--active': isActive, 'btn--disabled': disabled }, className);\n * ```\n */\nexport const cx = (...args: Parameters<typeof clsx>) => twMerge(clsx(...args));\n\ntype ConfigSchema = Record<string, Record<string, ClassValue>>;\ntype ConfigVariants<T extends ConfigSchema> = {\n [Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | null | undefined;\n};\ntype ConfigVariantsMulti<T extends ConfigSchema> = {\n [Variant in keyof T]?:\n | StringToBoolean<keyof T[Variant]>\n | StringToBoolean<keyof T[Variant]>[]\n | undefined;\n};\ntype Config<T> = T extends ConfigSchema\n ? {\n variants?: T;\n defaultVariants?: ConfigVariants<T>;\n compoundVariants?: (T extends ConfigSchema\n ? (ConfigVariants<T> | ConfigVariantsMulti<T>) & ClassProp\n : ClassProp)[];\n }\n : never;\n\ntype Props<T> = T extends ConfigSchema\n ? ConfigVariants<T> & ClassProp\n : ClassProp;\n\n/**\n * {@link https://cva.style/docs | Class Variance Authority (cva)} with the same **tailwind-merge**\n * pass as {@link cx}: the class string produced by the variant function is merged so Tailwind\n * conflicts resolve predictably.\n *\n * API matches `cva` from `class-variance-authority`: optional `base` classes, `config` with\n * `variants`, `defaultVariants`, and `compoundVariants`. The returned function accepts variant\n * props plus optional `class` / `className` for one-off overrides.\n *\n * Use {@link VariantProps} with `typeof buttonVariants` (or similar) to type component props.\n *\n * @param base - Base `ClassValue`(s) always applied.\n * @param config - Variant schema and defaults (same shape as upstream `cva`).\n * @returns A function `(props?) => string` that resolves variant classes, merged with tw-merge.\n *\n * @example\n * ```ts\n * const button = cva('rounded font-medium', {\n * variants: {\n * tone: { primary: 'bg-blue-600 text-white', ghost: 'bg-transparent' },\n * size: { sm: 'text-sm px-2', md: 'text-base px-4' },\n * },\n * defaultVariants: { tone: 'primary', size: 'md' },\n * });\n * button({ tone: 'ghost', className: 'ml-2' });\n * ```\n *\n * @example\n * ```ts\n * const card = cva('border p-4', {\n * variants: { elevated: { true: 'shadow-lg', false: 'shadow-none' } },\n * defaultVariants: { elevated: false },\n * });\n * card({ elevated: true });\n * ```\n */\nexport const cva = ((...args: any[]) => {\n const schema = cvaLib(...args);\n return (...inputArgs: any[]) => twMerge(schema(...inputArgs));\n}) as any as <T>(\n base?: ClassValue,\n config?: Config<T>,\n) => (props?: Props<T>) => string;\n\n/**\n * Utility type from `class-variance-authority`: infers the variant prop object from a `cva` instance.\n * Use it to type React (or other) components that forward variant props.\n *\n * @example\n * ```ts\n * const input = cva('border', { variants: { size: { sm: 'h-8', lg: 'h-12' } } });\n * type InputVariants = VariantProps<typeof input>;\n * // { size?: 'sm' | 'lg' | null }\n * ```\n */\nexport type { VariantProps } from 'class-variance-authority';\n\n/**\n * Re-export from `clsx`: a class name fragment — string, number, nested arrays, object map of\n * flags, or falsy nodes to skip. Used by {@link cx}, {@link cva}, and typical `className` helpers.\n *\n * @example\n * ```ts\n * const value: ClassValue = ['btn', false && 'hidden', { active: true }];\n * ```\n */\nexport type { ClassValue } from 'clsx';\n\n/**\n * Injects a stylesheet by appending a `<link rel=\"stylesheet\">` to `document.head`.\n * Resolves when the sheet fires `load`; rejects on `error` (e.g. 404 or network failure).\n *\n * **Id replacement:** if `attrubutes.id` is set, any existing element with that `id` is removed\n * first, so repeated calls with the same `id` replace the previous link (useful for theme or\n * font URLs that change).\n *\n * If `rel` is omitted in `attrubutes`, it defaults to `stylesheet`. Other attributes (`crossorigin`,\n * `media`, `data-*`, etc.) are set via `setAttribute` from the record entries.\n *\n * @param url - Stylesheet URL (`href`).\n * @param attrubutes - Optional HTML attributes for the `<link>` element (see `id` / `rel` behavior above).\n * @returns Promise that resolves to `undefined` on load, or rejects on load error.\n *\n * @example\n * ```ts\n * await loadCssFile('https://example.com/fonts.css', {\n * id: 'app-fonts',\n * crossOrigin: 'anonymous',\n * });\n * ```\n *\n * @example\n * ```ts\n * // Swap theme stylesheet without duplicate link tags\n * await loadCssFile('/themes/dark.css', { id: 'theme' });\n * await loadCssFile('/themes/light.css', { id: 'theme' });\n * ```\n */\nexport const loadCssFile = (url: string, attrubutes?: Record<string, any>) =>\n new Promise((resolve, reject) => {\n let link: Maybe<HTMLLinkElement>;\n\n if (attrubutes?.id) {\n link = document.getElementById(attrubutes.id) as HTMLLinkElement | null;\n\n if (link) {\n link.remove();\n }\n }\n\n link = document.createElement('link');\n\n const handleLoad = () => {\n resolve(undefined);\n link!.removeEventListener('load', handleLoad);\n link!.removeEventListener('error', handleError);\n };\n\n const handleError = () => {\n reject(undefined);\n link!.removeEventListener('load', handleLoad);\n link!.removeEventListener('error', handleError);\n };\n\n link.addEventListener('load', handleLoad);\n link.addEventListener('error', handleError);\n\n link.setAttribute('href', url);\n\n if (!attrubutes?.rel) {\n link.setAttribute('rel', 'stylesheet');\n }\n\n Object.entries(attrubutes || {}).forEach(([key, value]) => {\n link.setAttribute(key, value);\n });\n\n document.head.appendChild(link);\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,SAAS,IAAY,WAAW,OAAO,GAAG,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;AAsBrE,IAAa,MAAM,GAAG,SAAkC,QAAQ,KAAK,GAAG,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8D9E,IAAa,QAAQ,GAAG,SAAgB;CACtC,MAAM,SAAS,MAAO,GAAG,KAAK;AAC9B,SAAQ,GAAG,cAAqB,QAAQ,OAAO,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4D/D,IAAa,eAAe,KAAa,eACvC,IAAI,SAAS,SAAS,WAAW;CAC/B,IAAI;AAEJ,KAAI,YAAY,IAAI;AAClB,SAAO,SAAS,eAAe,WAAW,GAAG;AAE7C,MAAI,KACF,MAAK,QAAQ;;AAIjB,QAAO,SAAS,cAAc,OAAO;CAErC,MAAM,mBAAmB;AACvB,UAAQ,KAAA,EAAU;AAClB,OAAM,oBAAoB,QAAQ,WAAW;AAC7C,OAAM,oBAAoB,SAAS,YAAY;;CAGjD,MAAM,oBAAoB;AACxB,SAAO,KAAA,EAAU;AACjB,OAAM,oBAAoB,QAAQ,WAAW;AAC7C,OAAM,oBAAoB,SAAS,YAAY;;AAGjD,MAAK,iBAAiB,QAAQ,WAAW;AACzC,MAAK,iBAAiB,SAAS,YAAY;AAE3C,MAAK,aAAa,QAAQ,IAAI;AAE9B,KAAI,CAAC,YAAY,IACf,MAAK,aAAa,OAAO,aAAa;AAGxC,QAAO,QAAQ,cAAc,EAAE,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;AACzD,OAAK,aAAa,KAAK,MAAM;GAC7B;AAEF,UAAS,KAAK,YAAY,KAAK;EAC/B"}