UNPKG

@react-spectrum/s2

Version:
61 lines (56 loc) 2.25 kB
function $parcel$export(e, n, v, s) { Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); } $parcel$export(module.exports, "mergeStyles", () => $308b180f49d82d28$export$e618dc39ac9ad607); /* * Copyright 2024 Adobe. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ function $308b180f49d82d28$export$e618dc39ac9ad607(...styles) { let definedStyles = styles.filter(Boolean); if (definedStyles.length === 1) return definedStyles[0]; let map = new Map(); for (let style of definedStyles)for (let [k, v] of $308b180f49d82d28$var$parse(style))map.set(k, v); let res = ''; for (let value of map.values())res += value; return res; } function $308b180f49d82d28$var$parse(s) { let properties = new Map(); let i = 0; while(i < s.length){ while(i < s.length && s[i] === ' ')i++; let start = i; readValue(); // property index // read conditions (up to the last segment) let condition = i; while(i < s.length && s[i] !== ' ')readValue(); let property = s.slice(start, condition); properties.set(property, (properties.get(property) || '') + ' ' + s.slice(start, i)); } function readValue() { if (s[i] === '-') // the beginning and end of arbitrary values are marked with - while(i < s.length && s[i] !== ' '){ i++; if (s[i] === '-') { i++; break; } } else { while(i < s.length)if (s[i] === '_') i++; else { i++; break; } } } return properties; } //# sourceMappingURL=runtime.cjs.map