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

Function getPropertyDefinitions

packages/dev/s2-docs/src/styleProperties.ts:1629–1705  ·  view source on GitHub ↗
(propertyCategory: string)

Source from the content-addressed store, hash-verified

1627}
1628
1629export function getPropertyDefinitions(propertyCategory: string): {
1630 [key: string]: StyleMacroPropertyDefinition;
1631} {
1632 let result: {[key: string]: StyleMacroPropertyDefinition} = {};
1633 let propertiesMapping = properties[propertyCategory] || {};
1634
1635 for (let [name, values] of Object.entries(propertiesMapping)) {
1636 let links: {[value: string]: {href: string; isRelative?: boolean}} = {};
1637
1638 // check for property specific MDN links
1639 if (mdnPropertyLinks[name]) {
1640 for (let [key, href] of Object.entries(mdnPropertyLinks[name])) {
1641 links[key] = {href};
1642 }
1643 }
1644
1645 // if values array is empty but we have MDN links, add value (ensures flexShrink/etc get values)
1646 if (values.length === 0 && Object.keys(links).length > 0) {
1647 values = Object.keys(links);
1648 }
1649
1650 // see if the property has any common types that should link to MDN
1651 for (let value of values) {
1652 // skip if we already have a property specific link
1653 if (links[value]) {
1654 continue;
1655 }
1656
1657 // make sure not to overwrite number in sizing properties and pill in other sections aka effects
1658 if (
1659 (value === 'number' && sizingProperties.has(name)) ||
1660 (value === 'pill' && propertyCategory !== 'dimensions')
1661 ) {
1662 continue;
1663 }
1664
1665 if (mdnTypeLinks[value]) {
1666 links[value] = {href: mdnTypeLinks[value]};
1667 }
1668 }
1669
1670 result[name] = {
1671 values,
1672 additionalTypes: getAdditionalTypes(name),
1673 links: Object.keys(links).length > 0 ? links : undefined,
1674 description: propertyDescriptions[name]
1675 };
1676 }
1677
1678 // add relevant shorthands to the property category too
1679 for (let [shorthandName, shorthandDef] of Object.entries(shorthandMapping)) {
1680 if (shorthandDef.category === propertyCategory) {
1681 let values = shorthandDef.values;
1682 let links: {[value: string]: {href: string; isRelative?: boolean}} = {};
1683
1684 for (let value of values) {
1685 if (value === 'pill' && shorthandName.includes('border')) {
1686 continue;

Callers

nothing calls this directly

Calls 2

getAdditionalTypesFunction · 0.70
hasMethod · 0.65

Tested by

no test coverage detected