@coveord/plasma-react-icons 56.3.1 → 56.3.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.
Files changed (42) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/cjs/generated/index.d.ts +479 -479
  3. package/dist/cjs/generated/index.d.ts.map +1 -1
  4. package/dist/cjs/generated/index.js +1630 -1630
  5. package/dist/cjs/generated/index.js.map +1 -1
  6. package/dist/cjs/mock/MockUtils.d.ts +5 -0
  7. package/dist/cjs/mock/MockUtils.d.ts.map +1 -0
  8. package/dist/cjs/mock/MockUtils.js +30 -0
  9. package/dist/cjs/mock/MockUtils.js.map +1 -0
  10. package/dist/cjs/mock/MockUtils.spec.d.ts +2 -0
  11. package/dist/cjs/mock/MockUtils.spec.d.ts.map +1 -0
  12. package/dist/cjs/mock/index.d.ts.map +1 -1
  13. package/dist/cjs/mock/index.js +22 -8
  14. package/dist/cjs/mock/index.js.map +1 -1
  15. package/dist/cjs/mock/index.spec.d.ts +2 -0
  16. package/dist/cjs/mock/index.spec.d.ts.map +1 -0
  17. package/dist/cjs/vite-plugin/index.d.ts.map +1 -1
  18. package/dist/cjs/vite-plugin/index.js +11 -6
  19. package/dist/cjs/vite-plugin/index.js.map +1 -1
  20. package/dist/cjs/vite-plugin/index.spec.d.ts +2 -0
  21. package/dist/cjs/vite-plugin/index.spec.d.ts.map +1 -0
  22. package/dist/esm/generated/index.d.ts +479 -479
  23. package/dist/esm/generated/index.d.ts.map +1 -1
  24. package/dist/esm/generated/index.js +479 -479
  25. package/dist/esm/generated/index.js.map +1 -1
  26. package/dist/esm/mock/MockUtils.d.ts +5 -0
  27. package/dist/esm/mock/MockUtils.d.ts.map +1 -0
  28. package/dist/esm/mock/MockUtils.js +16 -0
  29. package/dist/esm/mock/MockUtils.js.map +1 -0
  30. package/dist/esm/mock/MockUtils.spec.d.ts +2 -0
  31. package/dist/esm/mock/MockUtils.spec.d.ts.map +1 -0
  32. package/dist/esm/mock/index.d.ts.map +1 -1
  33. package/dist/esm/mock/index.js +18 -8
  34. package/dist/esm/mock/index.js.map +1 -1
  35. package/dist/esm/mock/index.spec.d.ts +2 -0
  36. package/dist/esm/mock/index.spec.d.ts.map +1 -0
  37. package/dist/esm/vite-plugin/index.d.ts.map +1 -1
  38. package/dist/esm/vite-plugin/index.js +10 -7
  39. package/dist/esm/vite-plugin/index.js.map +1 -1
  40. package/dist/esm/vite-plugin/index.spec.d.ts +2 -0
  41. package/dist/esm/vite-plugin/index.spec.d.ts.map +1 -0
  42. package/package.json +1 -1
@@ -0,0 +1,5 @@
1
+ export declare const MockUtils: {
2
+ formatLabel: (name: string) => string;
3
+ formatToTablerClassName: (name: string) => string;
4
+ };
5
+ //# sourceMappingURL=MockUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockUtils.d.ts","sourceRoot":"","sources":["../../../src/mock/MockUtils.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,SAAS;wBAhBK,MAAM;oCAaM,MAAM;CAM5C,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Transforms ArrowUpSize16Px into arrowUp
3
+ */ const formatLabel = (name)=>{
4
+ const label = name.replace(/(.+)Size\d+Px/, '$1');
5
+ return label.charAt(0).toLowerCase() + label.slice(1);
6
+ };
7
+ const transformToKebabCase = (name)=>name.charAt(0).toLowerCase() + name.slice(1).replace(/([a-z])([A-Z])/g, '$1-$2') // Add hyphen between camelCase
8
+ .replace(/([a-zA-Z])(\d+)/g, '$1-$2') // Add hyphen before numbers
9
+ .toLowerCase();
10
+ const formatToTablerClassName = (name)=>name.startsWith('Icon') ? `tabler-icon tabler-${transformToKebabCase(name)}` : name;
11
+ export const MockUtils = {
12
+ formatLabel,
13
+ formatToTablerClassName
14
+ };
15
+
16
+ //# sourceMappingURL=MockUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/mock/MockUtils.ts"],"sourcesContent":["/**\n * Transforms ArrowUpSize16Px into arrowUp\n */\nconst formatLabel = (name: string) => {\n const label = name.replace(/(.+)Size\\d+Px/, '$1');\n return label.charAt(0).toLowerCase() + label.slice(1);\n};\n\nconst transformToKebabCase = (name: string) =>\n name.charAt(0).toLowerCase() +\n name\n .slice(1)\n .replace(/([a-z])([A-Z])/g, '$1-$2') // Add hyphen between camelCase\n .replace(/([a-zA-Z])(\\d+)/g, '$1-$2') // Add hyphen before numbers\n .toLowerCase();\n\nconst formatToTablerClassName = (name: string) =>\n name.startsWith('Icon') ? `tabler-icon tabler-${transformToKebabCase(name)}` : name;\n\nexport const MockUtils = {\n formatLabel,\n formatToTablerClassName,\n};\n"],"names":["formatLabel","name","label","replace","charAt","toLowerCase","slice","transformToKebabCase","formatToTablerClassName","startsWith","MockUtils"],"mappings":"AAAA;;CAEC,GACD,MAAMA,cAAc,CAACC;IACjB,MAAMC,QAAQD,KAAKE,OAAO,CAAC,iBAAiB;IAC5C,OAAOD,MAAME,MAAM,CAAC,GAAGC,WAAW,KAAKH,MAAMI,KAAK,CAAC;AACvD;AAEA,MAAMC,uBAAuB,CAACN,OAC1BA,KAAKG,MAAM,CAAC,GAAGC,WAAW,KAC1BJ,KACKK,KAAK,CAAC,GACNH,OAAO,CAAC,mBAAmB,SAAS,+BAA+B;KACnEA,OAAO,CAAC,oBAAoB,SAAS,4BAA4B;KACjEE,WAAW;AAEpB,MAAMG,0BAA0B,CAACP,OAC7BA,KAAKQ,UAAU,CAAC,UAAU,CAAC,mBAAmB,EAAEF,qBAAqBN,OAAO,GAAGA;AAEnF,OAAO,MAAMS,YAAY;IACrBV;IACAQ;AACJ,EAAE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MockUtils.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockUtils.spec.d.ts","sourceRoot":"","sources":["../../../src/mock/MockUtils.spec.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mock/index.tsx"],"names":[],"mappings":";AAiCA,wBAAsC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mock/index.tsx"],"names":[],"mappings":";AA8CA,wBAAsC"}
@@ -1,21 +1,31 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
+ import { MockUtils } from './MockUtils';
3
4
  /**
4
5
  * You can use the following mock in jest to avoid loading the actual icons during tests, it can slow down your tests if you don't.
5
6
  * Just add the following entry to your moduleNameMappter config
6
7
  * '^@coveord/plasma-react-icons$': '<rootDir>/node_modules/@coveord/plasma-react-icons/mock',
7
- */ /**
8
- * Transforms ArrowUpSize16Px into arrowUp
9
- */ const formatLabel = (name)=>{
10
- const label = name.replace(/(.+)Size\d+Px/, '$1');
11
- return label.charAt(0).toLowerCase() + label.slice(1);
12
- };
13
- const handler = {
8
+ */ const handler = {
14
9
  get: (obj, prop)=>{
10
+ if (prop.startsWith('Icon')) {
11
+ const TablerIconMock = /*#__PURE__*/ forwardRef(({ height, width, className, ...others }, ref)=>{
12
+ const tablerClassName = MockUtils.formatToTablerClassName(prop);
13
+ const combinedClassName = className ? `${tablerClassName} ${className}` : tablerClassName;
14
+ return /*#__PURE__*/ _jsx("svg", {
15
+ ref: ref,
16
+ width: width || height || '1em',
17
+ height: height || width || '1em',
18
+ className: combinedClassName,
19
+ ...others
20
+ });
21
+ });
22
+ TablerIconMock.displayName = prop;
23
+ return TablerIconMock;
24
+ }
15
25
  const IconMock = /*#__PURE__*/ forwardRef(({ height, width, ...others }, ref)=>/*#__PURE__*/ _jsx("svg", {
16
26
  ref: ref,
17
27
  role: "img",
18
- "aria-label": formatLabel(prop),
28
+ "aria-label": MockUtils.formatLabel(prop),
19
29
  width: width || height || '1em',
20
30
  height: height || width || '1em',
21
31
  ...others
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/mock/index.tsx"],"sourcesContent":["import {forwardRef, type SVGProps} from 'react';\n\n/**\n * You can use the following mock in jest to avoid loading the actual icons during tests, it can slow down your tests if you don't.\n * Just add the following entry to your moduleNameMappter config\n * '^@coveord/plasma-react-icons$': '<rootDir>/node_modules/@coveord/plasma-react-icons/mock',\n */\n\n/**\n * Transforms ArrowUpSize16Px into arrowUp\n */\nconst formatLabel = (name: string) => {\n const label = name.replace(/(.+)Size\\d+Px/, '$1');\n return label.charAt(0).toLowerCase() + label.slice(1);\n};\n\nconst handler = {\n get: (obj: any, prop: string) => {\n const IconMock = forwardRef<SVGSVGElement, SVGProps<SVGSVGElement>>(({height, width, ...others}, ref) => (\n <svg\n ref={ref}\n role=\"img\"\n aria-label={formatLabel(prop)}\n width={width || height || '1em'}\n height={height || width || '1em'}\n {...others}\n />\n ));\n IconMock.displayName = prop;\n return IconMock;\n },\n};\n\nexport default new Proxy({}, handler);\n"],"names":["forwardRef","formatLabel","name","label","replace","charAt","toLowerCase","slice","handler","get","obj","prop","IconMock","height","width","others","ref","svg","role","aria-label","displayName","Proxy"],"mappings":";AAAA,SAAQA,UAAU,QAAsB,QAAQ;AAEhD;;;;CAIC,GAED;;CAEC,GACD,MAAMC,cAAc,CAACC;IACjB,MAAMC,QAAQD,KAAKE,OAAO,CAAC,iBAAiB;IAC5C,OAAOD,MAAME,MAAM,CAAC,GAAGC,WAAW,KAAKH,MAAMI,KAAK,CAAC;AACvD;AAEA,MAAMC,UAAU;IACZC,KAAK,CAACC,KAAUC;QACZ,MAAMC,yBAAWZ,WAAmD,CAAC,EAACa,MAAM,EAAEC,KAAK,EAAE,GAAGC,QAAO,EAAEC,oBAC7F,KAACC;gBACGD,KAAKA;gBACLE,MAAK;gBACLC,cAAYlB,YAAYU;gBACxBG,OAAOA,SAASD,UAAU;gBAC1BA,QAAQA,UAAUC,SAAS;gBAC1B,GAAGC,MAAM;;QAGlBH,SAASQ,WAAW,GAAGT;QACvB,OAAOC;IACX;AACJ;AAEA,eAAe,IAAIS,MAAM,CAAC,GAAGb,SAAS"}
1
+ {"version":3,"sources":["../../../src/mock/index.tsx"],"sourcesContent":["import {forwardRef, type SVGProps} from 'react';\nimport {MockUtils} from './MockUtils';\n\n/**\n * You can use the following mock in jest to avoid loading the actual icons during tests, it can slow down your tests if you don't.\n * Just add the following entry to your moduleNameMappter config\n * '^@coveord/plasma-react-icons$': '<rootDir>/node_modules/@coveord/plasma-react-icons/mock',\n */\n\nconst handler = {\n get: (obj: any, prop: string) => {\n if (prop.startsWith('Icon')) {\n const TablerIconMock = forwardRef<SVGSVGElement, SVGProps<SVGSVGElement>>(\n ({height, width, className, ...others}, ref) => {\n const tablerClassName = MockUtils.formatToTablerClassName(prop);\n const combinedClassName = className ? `${tablerClassName} ${className}` : tablerClassName;\n return (\n <svg\n ref={ref}\n width={width || height || '1em'}\n height={height || width || '1em'}\n className={combinedClassName}\n {...others}\n />\n );\n },\n );\n TablerIconMock.displayName = prop;\n return TablerIconMock;\n }\n\n const IconMock = forwardRef<SVGSVGElement, SVGProps<SVGSVGElement>>(({height, width, ...others}, ref) => (\n <svg\n ref={ref}\n role=\"img\"\n aria-label={MockUtils.formatLabel(prop)}\n width={width || height || '1em'}\n height={height || width || '1em'}\n {...others}\n />\n ));\n IconMock.displayName = prop;\n return IconMock;\n },\n};\n\nexport default new Proxy({}, handler);\n"],"names":["forwardRef","MockUtils","handler","get","obj","prop","startsWith","TablerIconMock","height","width","className","others","ref","tablerClassName","formatToTablerClassName","combinedClassName","svg","displayName","IconMock","role","aria-label","formatLabel","Proxy"],"mappings":";AAAA,SAAQA,UAAU,QAAsB,QAAQ;AAChD,SAAQC,SAAS,QAAO,cAAc;AAEtC;;;;CAIC,GAED,MAAMC,UAAU;IACZC,KAAK,CAACC,KAAUC;QACZ,IAAIA,KAAKC,UAAU,CAAC,SAAS;YACzB,MAAMC,+BAAiBP,WACnB,CAAC,EAACQ,MAAM,EAAEC,KAAK,EAAEC,SAAS,EAAE,GAAGC,QAAO,EAAEC;gBACpC,MAAMC,kBAAkBZ,UAAUa,uBAAuB,CAACT;gBAC1D,MAAMU,oBAAoBL,YAAY,GAAGG,gBAAgB,CAAC,EAAEH,WAAW,GAAGG;gBAC1E,qBACI,KAACG;oBACGJ,KAAKA;oBACLH,OAAOA,SAASD,UAAU;oBAC1BA,QAAQA,UAAUC,SAAS;oBAC3BC,WAAWK;oBACV,GAAGJ,MAAM;;YAGtB;YAEJJ,eAAeU,WAAW,GAAGZ;YAC7B,OAAOE;QACX;QAEA,MAAMW,yBAAWlB,WAAmD,CAAC,EAACQ,MAAM,EAAEC,KAAK,EAAE,GAAGE,QAAO,EAAEC,oBAC7F,KAACI;gBACGJ,KAAKA;gBACLO,MAAK;gBACLC,cAAYnB,UAAUoB,WAAW,CAAChB;gBAClCI,OAAOA,SAASD,UAAU;gBAC1BA,QAAQA,UAAUC,SAAS;gBAC1B,GAAGE,MAAM;;QAGlBO,SAASD,WAAW,GAAGZ;QACvB,OAAOa;IACX;AACJ;AAEA,eAAe,IAAII,MAAM,CAAC,GAAGpB,SAAS"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../src/mock/index.spec.tsx"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite-plugin/index.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,QAAA,MAAM,qBAAqB;;;sBAID,MAAM,MAAM,MAAM;;;;CAkDrB,CAAC;AAExB,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite-plugin/index.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,QAAA,MAAM,qBAAqB;;;sBAID,MAAM,MAAM,MAAM;;;;CAyDrB,CAAC;AAExB,eAAe,qBAAqB,CAAC"}
@@ -6,15 +6,17 @@
6
6
  name: 'coveord/plasma-react-icons/mock',
7
7
  enforce: 'pre',
8
8
  transform: (code, id)=>{
9
- // Only transform relevant files (e.g., .ts, .tsx, .js, .jsx) that import from @coveord/plasma-react-icons
10
- if (!code.includes('@coveord/plasma-react-icons') || !/\.(ts|tsx|js|jsx)$/.test(id)) {
9
+ // Only transform relevant files (e.g., .ts, .tsx, .js, .jsx) that import from @coveord/plasma-react-icons and aren't in node_modules
10
+ if (!code.includes('@coveord/plasma-react-icons') || id.includes('/node_modules/') || !/\.(ts|tsx|js|jsx)$/.test(id)) {
11
11
  return null;
12
12
  }
13
13
  // Transform named imports to default import + destructuring
14
- // e.g., import { IconA, IconB } from '@coveord/plasma-react-icons'
15
- // becomes: import __plasmaIcons from '@coveord/plasma-react-icons/mock'; const IconA = __plasmaIcons.IconA; const IconB = __plasmaIcons.IconB;
16
- // Only match value imports, not type-only imports
17
- const namedImportRegex = /import\s+(?!type\b)\{([^}]+)}\s+from\s+['"]@coveord\/plasma-react-icons['"]/g;
14
+ // e.g., import { ArrowUpSize16Px, IconHome } from '@coveord/plasma-react-icons'
15
+ // becomes:
16
+ // import __plasmaIcons from '@coveord/plasma-react-icons/mock';
17
+ // const ArrowUpSize16Px = __plasmaIcons.ArrowUpSize16Px;
18
+ // const IconHome = __plasmaIcons.IconHome;
19
+ const namedImportRegex = /import\s+(?!type\b)\{([^}]+)}\s+from\s+['"]@coveord\/plasma-react-icons['"];?/g;
18
20
  let transformedCode = code;
19
21
  const imports = [];
20
22
  // Collect all matches first to avoid issues with regex state and string mutation
@@ -24,7 +26,8 @@
24
26
  if (/import\s+type\s*\{/.test(match[0])) {
25
27
  continue;
26
28
  }
27
- const importedNames = match[1].split(',').map((name)=>name.trim()).filter((name)=>name);
29
+ const importedNames = match[1].split(',').map((name)=>name.trim()).filter((name)=>!name.startsWith('type ')) // avoid type-only imports
30
+ .filter((name)=>name);
28
31
  imports.push(...importedNames);
29
32
  // Remove the original import
30
33
  transformedCode = transformedCode.replace(match[0], '');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/vite-plugin/index.ts"],"sourcesContent":["import type {Plugin} from 'vite';\n\n/**\n * Vitest plugin to mock @coveord/plasma-react-icons with the mock version.\n * The mock uses a Proxy that dynamically generates icon components based on the property name.\n * This plugin transforms named imports into property access on the default import.\n */\nconst plasmaIconsMockPlugin = () =>\n ({\n name: 'coveord/plasma-react-icons/mock',\n enforce: 'pre',\n transform: (code: string, id: string) => {\n // Only transform relevant files (e.g., .ts, .tsx, .js, .jsx) that import from @coveord/plasma-react-icons\n if (!code.includes('@coveord/plasma-react-icons') || !/\\.(ts|tsx|js|jsx)$/.test(id)) {\n return null;\n }\n\n // Transform named imports to default import + destructuring\n // e.g., import { IconA, IconB } from '@coveord/plasma-react-icons'\n // becomes: import __plasmaIcons from '@coveord/plasma-react-icons/mock'; const IconA = __plasmaIcons.IconA; const IconB = __plasmaIcons.IconB;\n // Only match value imports, not type-only imports\n const namedImportRegex = /import\\s+(?!type\\b)\\{([^}]+)}\\s+from\\s+['\"]@coveord\\/plasma-react-icons['\"]/g;\n\n let transformedCode = code;\n const imports: string[] = [];\n\n // Collect all matches first to avoid issues with regex state and string mutation\n const matches = Array.from(code.matchAll(namedImportRegex));\n for (const match of matches) {\n // Extra safety: skip if this is a type-only import (shouldn't match, but just in case)\n if (/import\\s+type\\s*\\{/.test(match[0])) {\n continue;\n }\n\n const importedNames = match[1]\n .split(',')\n .map((name) => name.trim())\n .filter((name) => name);\n\n imports.push(...importedNames);\n\n // Remove the original import\n transformedCode = transformedCode.replace(match[0], '');\n }\n\n if (imports.length > 0) {\n // Add the default import and const declarations at the top\n const mockImport = `import __plasmaIconsMock from '@coveord/plasma-react-icons/mock';\\n`;\n const constDeclarations = imports\n .map((name) => `const ${name} = __plasmaIconsMock.${name};`)\n .join('\\n');\n transformedCode = mockImport + constDeclarations + '\\n' + transformedCode;\n\n return {\n code: transformedCode,\n map: null,\n };\n }\n\n return null;\n },\n }) satisfies Plugin;\n\nexport default plasmaIconsMockPlugin;\n"],"names":["plasmaIconsMockPlugin","name","enforce","transform","code","id","includes","test","namedImportRegex","transformedCode","imports","matches","Array","from","matchAll","match","importedNames","split","map","trim","filter","push","replace","length","mockImport","constDeclarations","join"],"mappings":"AAEA;;;;CAIC,GACD,MAAMA,wBAAwB,IACzB,CAAA;QACGC,MAAM;QACNC,SAAS;QACTC,WAAW,CAACC,MAAcC;YACtB,0GAA0G;YAC1G,IAAI,CAACD,KAAKE,QAAQ,CAAC,kCAAkC,CAAC,qBAAqBC,IAAI,CAACF,KAAK;gBACjF,OAAO;YACX;YAEA,4DAA4D;YAC5D,mEAAmE;YACnE,+IAA+I;YAC/I,kDAAkD;YAClD,MAAMG,mBAAmB;YAEzB,IAAIC,kBAAkBL;YACtB,MAAMM,UAAoB,EAAE;YAE5B,iFAAiF;YACjF,MAAMC,UAAUC,MAAMC,IAAI,CAACT,KAAKU,QAAQ,CAACN;YACzC,KAAK,MAAMO,SAASJ,QAAS;gBACzB,uFAAuF;gBACvF,IAAI,qBAAqBJ,IAAI,CAACQ,KAAK,CAAC,EAAE,GAAG;oBACrC;gBACJ;gBAEA,MAAMC,gBAAgBD,KAAK,CAAC,EAAE,CACzBE,KAAK,CAAC,KACNC,GAAG,CAAC,CAACjB,OAASA,KAAKkB,IAAI,IACvBC,MAAM,CAAC,CAACnB,OAASA;gBAEtBS,QAAQW,IAAI,IAAIL;gBAEhB,6BAA6B;gBAC7BP,kBAAkBA,gBAAgBa,OAAO,CAACP,KAAK,CAAC,EAAE,EAAE;YACxD;YAEA,IAAIL,QAAQa,MAAM,GAAG,GAAG;gBACpB,2DAA2D;gBAC3D,MAAMC,aAAa,CAAC,mEAAmE,CAAC;gBACxF,MAAMC,oBAAoBf,QACrBQ,GAAG,CAAC,CAACjB,OAAS,CAAC,MAAM,EAAEA,KAAK,qBAAqB,EAAEA,KAAK,CAAC,CAAC,EAC1DyB,IAAI,CAAC;gBACVjB,kBAAkBe,aAAaC,oBAAoB,OAAOhB;gBAE1D,OAAO;oBACHL,MAAMK;oBACNS,KAAK;gBACT;YACJ;YAEA,OAAO;QACX;IACJ,CAAA;AAEJ,eAAelB,sBAAsB"}
1
+ {"version":3,"sources":["../../../src/vite-plugin/index.ts"],"sourcesContent":["import type {Plugin} from 'vite';\n\n/**\n * Vitest plugin to mock @coveord/plasma-react-icons with the mock version.\n * The mock uses a Proxy that dynamically generates icon components based on the property name.\n * This plugin transforms named imports into property access on the default import.\n */\nconst plasmaIconsMockPlugin = () =>\n ({\n name: 'coveord/plasma-react-icons/mock',\n enforce: 'pre',\n transform: (code: string, id: string) => {\n // Only transform relevant files (e.g., .ts, .tsx, .js, .jsx) that import from @coveord/plasma-react-icons and aren't in node_modules\n if (\n !code.includes('@coveord/plasma-react-icons') ||\n id.includes('/node_modules/') ||\n !/\\.(ts|tsx|js|jsx)$/.test(id)\n ) {\n return null;\n }\n\n // Transform named imports to default import + destructuring\n // e.g., import { ArrowUpSize16Px, IconHome } from '@coveord/plasma-react-icons'\n // becomes:\n // import __plasmaIcons from '@coveord/plasma-react-icons/mock';\n // const ArrowUpSize16Px = __plasmaIcons.ArrowUpSize16Px;\n // const IconHome = __plasmaIcons.IconHome;\n const namedImportRegex = /import\\s+(?!type\\b)\\{([^}]+)}\\s+from\\s+['\"]@coveord\\/plasma-react-icons['\"];?/g;\n\n let transformedCode = code;\n const imports: string[] = [];\n\n // Collect all matches first to avoid issues with regex state and string mutation\n const matches = Array.from(code.matchAll(namedImportRegex));\n for (const match of matches) {\n // Extra safety: skip if this is a type-only import (shouldn't match, but just in case)\n if (/import\\s+type\\s*\\{/.test(match[0])) {\n continue;\n }\n\n const importedNames = match[1]\n .split(',')\n .map((name) => name.trim())\n .filter((name) => !name.startsWith('type ')) // avoid type-only imports\n .filter((name) => name);\n\n imports.push(...importedNames);\n\n // Remove the original import\n transformedCode = transformedCode.replace(match[0], '');\n }\n\n if (imports.length > 0) {\n // Add the default import and const declarations at the top\n const mockImport = `import __plasmaIconsMock from '@coveord/plasma-react-icons/mock';\\n`;\n const constDeclarations = imports\n .map((name) => `const ${name} = __plasmaIconsMock.${name};`)\n .join('\\n');\n transformedCode = mockImport + constDeclarations + '\\n' + transformedCode;\n\n return {\n code: transformedCode,\n map: null,\n };\n }\n\n return null;\n },\n }) satisfies Plugin;\n\nexport default plasmaIconsMockPlugin;\n"],"names":["plasmaIconsMockPlugin","name","enforce","transform","code","id","includes","test","namedImportRegex","transformedCode","imports","matches","Array","from","matchAll","match","importedNames","split","map","trim","filter","startsWith","push","replace","length","mockImport","constDeclarations","join"],"mappings":"AAEA;;;;CAIC,GACD,MAAMA,wBAAwB,IACzB,CAAA;QACGC,MAAM;QACNC,SAAS;QACTC,WAAW,CAACC,MAAcC;YACtB,qIAAqI;YACrI,IACI,CAACD,KAAKE,QAAQ,CAAC,kCACfD,GAAGC,QAAQ,CAAC,qBACZ,CAAC,qBAAqBC,IAAI,CAACF,KAC7B;gBACE,OAAO;YACX;YAEA,4DAA4D;YAC5D,gFAAgF;YAChF,WAAW;YACX,gEAAgE;YAChE,yDAAyD;YACzD,2CAA2C;YAC3C,MAAMG,mBAAmB;YAEzB,IAAIC,kBAAkBL;YACtB,MAAMM,UAAoB,EAAE;YAE5B,iFAAiF;YACjF,MAAMC,UAAUC,MAAMC,IAAI,CAACT,KAAKU,QAAQ,CAACN;YACzC,KAAK,MAAMO,SAASJ,QAAS;gBACzB,uFAAuF;gBACvF,IAAI,qBAAqBJ,IAAI,CAACQ,KAAK,CAAC,EAAE,GAAG;oBACrC;gBACJ;gBAEA,MAAMC,gBAAgBD,KAAK,CAAC,EAAE,CACzBE,KAAK,CAAC,KACNC,GAAG,CAAC,CAACjB,OAASA,KAAKkB,IAAI,IACvBC,MAAM,CAAC,CAACnB,OAAS,CAACA,KAAKoB,UAAU,CAAC,UAAU,0BAA0B;iBACtED,MAAM,CAAC,CAACnB,OAASA;gBAEtBS,QAAQY,IAAI,IAAIN;gBAEhB,6BAA6B;gBAC7BP,kBAAkBA,gBAAgBc,OAAO,CAACR,KAAK,CAAC,EAAE,EAAE;YACxD;YAEA,IAAIL,QAAQc,MAAM,GAAG,GAAG;gBACpB,2DAA2D;gBAC3D,MAAMC,aAAa,CAAC,mEAAmE,CAAC;gBACxF,MAAMC,oBAAoBhB,QACrBQ,GAAG,CAAC,CAACjB,OAAS,CAAC,MAAM,EAAEA,KAAK,qBAAqB,EAAEA,KAAK,CAAC,CAAC,EAC1D0B,IAAI,CAAC;gBACVlB,kBAAkBgB,aAAaC,oBAAoB,OAAOjB;gBAE1D,OAAO;oBACHL,MAAMK;oBACNS,KAAK;gBACT;YACJ;YAEA,OAAO;QACX;IACJ,CAAA;AAEJ,eAAelB,sBAAsB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../src/vite-plugin/index.spec.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coveord/plasma-react-icons",
3
- "version": "56.3.1",
3
+ "version": "56.3.3",
4
4
  "description": "Plasma iconography exposed as react components",
5
5
  "keywords": [
6
6
  "plasma",