-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
698f036
commit e6cb4a1
Showing
7 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true, | ||
}); | ||
|
||
exports.default = require('../processors/createExtendSxProp').CreateExtendSxPropProcessor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default function createExtendSxProp(): <T extends Record<string, any>>(props: T) => T; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Runtime function for creating `extendSxProp`. | ||
* | ||
* This is a placeholder for the runtime function for replacing the `extendSxProp` in Material UI | ||
* to reduce bundle size only. DO NOT use it in your codebase. | ||
*/ | ||
function extendSxProp(props) { | ||
return props; | ||
} | ||
export default function createExtendSxProp() { | ||
return extendSxProp; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/pigment-css-react/src/processors/createExtendSxProp.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { Expression, Params, TailProcessorParams } from '@wyw-in-js/processor-utils'; | ||
import BaseProcessor from './base-processor'; | ||
|
||
export class CreateExtendSxPropProcessor extends BaseProcessor { | ||
constructor(params: Params, ...args: TailProcessorParams) { | ||
super([params[0]], ...args); | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
build(): void {} | ||
|
||
doEvaltimeReplacement(): void { | ||
this.replacer(this.value, false); | ||
} | ||
|
||
get value(): Expression { | ||
return this.astService.nullLiteral(); | ||
} | ||
|
||
doRuntimeReplacement(): void { | ||
const t = this.astService; | ||
|
||
const extendSxPropImportIdentifier = t.addNamedImport( | ||
this.tagSource.imported, | ||
process.env.PACKAGE_NAME as string, | ||
); | ||
|
||
this.replacer(t.callExpression(extendSxPropImportIdentifier, []), true); | ||
} | ||
|
||
public override get asSelector(): string { | ||
// For completeness, this is not intended to be used. | ||
return `.${this.className}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters