@react-spectrum/s2
Version:
Spectrum 2 UI components in React
56 lines (53 loc) • 2.09 kB
JavaScript
/*
* 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 $feb886035e0d4633$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 $feb886035e0d4633$var$parse(style))map.set(k, v);
let res = '';
for (let value of map.values())res += value;
return res;
}
function $feb886035e0d4633$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;
}
export {$feb886035e0d4633$export$e618dc39ac9ad607 as mergeStyles};
//# sourceMappingURL=runtime.mjs.map