MCPcopy Create free account
hub / github.com/adobe/react-spectrum / generateName

Function generateName

packages/@react-spectrum/s2/style/style-macro.ts:796–813  ·  view source on GitHub ↗
(index: number, atStart = false)

Source from the content-addressed store, hash-verified

794// For numbers larger than 62, an underscore is prepended.
795// This encoding allows easy parsing to enable runtime merging by property.
796function generateName(index: number, atStart = false): string {
797 if (index < 26) {
798 // lower case letters
799 return String.fromCharCode(index + 97);
800 }
801
802 if (index < 52) {
803 // upper case letters
804 return String.fromCharCode(index - 26 + 65);
805 }
806
807 if (index < 62 && !atStart) {
808 // numbers
809 return String.fromCharCode(index - 52 + 48);
810 }
811
812 return '_' + generateName(index - (atStart ? 52 : 62));
813}
814
815// For arbitrary values, we use a hash of the string to generate the class name.
816function generateArbitraryValueSelector(v: string, atStart = false) {

Callers 3

createThemeFunction · 0.70
compileConditionFunction · 0.70
toBase62Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected