@medalsocial/meda 2.7.1 → 2.7.2

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.
@@ -1,2 +1,2 @@
1
- import { type ClassValue } from 'clsx';
1
+ import type { ClassValue } from 'clsx';
2
2
  export declare function cn(...inputs: ClassValue[]): string;
package/dist/lib/utils.js CHANGED
@@ -1,5 +1,44 @@
1
- import { clsx } from 'clsx';
2
1
  import { twMerge } from 'tailwind-merge';
2
+ /**
3
+ * Flatten one clsx-style class value.
4
+ *
5
+ * Deliberately inlined instead of calling `clsx`, so that `cn` — which nearly
6
+ * every component in this package calls — leaves no RUNTIME edge to the `clsx`
7
+ * module. `clsx` stays a dependency for its `ClassValue` type, which appears in
8
+ * this file's public signature; `import type` is erased at compile time.
9
+ *
10
+ * Why it is worth inlining twenty lines: `clsx` is also a dependency of
11
+ * `recharts`, so a bundler that groups the chart vendor graph into one chunk
12
+ * puts the single shared `clsx` module in THAT chunk. Every eager importer of
13
+ * `cn` then hard-depends on the whole chart bundle. Measured in the Medal web
14
+ * app (2026-09-06): the `/login` server closure reached a 392 kB
15
+ * `vendor-recharts` chunk through exactly one edge — the shell's `cn` — and
16
+ * removing this import dropped that closure from 4,758,902 to 4,357,355 bytes
17
+ * with the chart chunk no longer reachable at all.
18
+ *
19
+ * Behaviour is identical to `clsx`, pinned by the equivalence test in
20
+ * `test/unit/lib/utils.test.ts`.
21
+ */
22
+ function toClassName(input) {
23
+ if (!input)
24
+ return '';
25
+ if (typeof input === 'string' || typeof input === 'number') {
26
+ return String(input);
27
+ }
28
+ if (Array.isArray(input)) {
29
+ return input.map(toClassName).filter(Boolean).join(' ');
30
+ }
31
+ if (typeof input === 'object') {
32
+ let className = '';
33
+ for (const key in input) {
34
+ if (input[key]) {
35
+ className = className ? `${className} ${key}` : key;
36
+ }
37
+ }
38
+ return className;
39
+ }
40
+ return '';
41
+ }
3
42
  export function cn(...inputs) {
4
- return twMerge(clsx(inputs));
43
+ return twMerge(toClassName(inputs));
5
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medalsocial/meda",
3
- "version": "2.7.1",
3
+ "version": "2.7.2",
4
4
  "description": "Shared Meda UI shell and runtime package.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {