@react-spectrum/s2
Version:
Spectrum 2 UI components in React
165 lines (155 loc) • 6.51 kB
JavaScript
require("./Icon.css");
var $308b180f49d82d28$exports = require("./runtime.cjs");
var $5eb75e0c130e0669$exports = require("./Skeleton.cjs");
var $ac757a4c2bd72aee$exports = require("./useSpectrumContextProps.cjs");
var $l0021$reactjsxruntime = require("react/jsx-runtime");
var $l0021$react = require("react");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "IconContext", () => $bde97c91243ed164$export$a49f528ae1a4d0ed);
$parcel$export(module.exports, "IllustrationContext", () => $bde97c91243ed164$export$207c7561471de4bd);
$parcel$export(module.exports, "createIcon", () => $bde97c91243ed164$export$274edc73af1ae9c8);
$parcel$export(module.exports, "createIllustration", () => $bde97c91243ed164$export$4d00e7be716a0093);
/*
* 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.
*/
// Custom list of overrides, excluding width/height/flexGrow/flexShrink/flexBasis
const $bde97c91243ed164$var$allowedOverrides = [
'margin',
'marginStart',
'marginEnd',
'marginTop',
'marginBottom',
'marginX',
'marginY',
'justifySelf',
'alignSelf',
'order',
'gridArea',
'gridRowStart',
'gridRowEnd',
'gridColumnStart',
'gridColumnEnd',
'position',
'zIndex',
'top',
'bottom',
'inset',
'insetX',
'insetY',
'insetStart',
'insetEnd',
'rotate',
'--iconPrimary',
'size'
];
const $bde97c91243ed164$export$a49f528ae1a4d0ed = /*#__PURE__*/ (0, $l0021$react.createContext)({});
const $bde97c91243ed164$export$207c7561471de4bd = /*#__PURE__*/ (0, $l0021$react.createContext)({});
const $bde97c91243ed164$var$iconStyles = function anonymous(props, overrides) {
let rules = " ";
let width = false;
let height = false;
let matches = (overrides || '').matchAll(/(?:^|\s)(J|G|I|H|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|_S|-_8sjo0b-|Z|F)[^\s]+/g);
for (let p of matches){
if (p[1] === "Z") width = true;
if (p[1] === "F") height = true;
rules += p[0];
}
if (!width) rules += ' Zm1';
if (!height) rules += ' Fn1';
rules += ' _va1';
return rules;
};
function $bde97c91243ed164$export$274edc73af1ae9c8(Component, context = $bde97c91243ed164$export$a49f528ae1a4d0ed) {
return (props)=>{
let ref = (0, $l0021$react.useRef)(null);
let ctx;
// TODO: remove this default once we release RAC and use DEFAULT_SLOT.
[ctx, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)({
slot: props.slot || 'icon'
}, ref, context);
let { render: render, styles: ctxStyles } = ctx;
let { UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style, slot: slot, 'aria-label': ariaLabel, 'aria-hidden': ariaHidden, styles: styles, ...otherProps } = props;
if (!ariaHidden) ariaHidden = undefined;
let svg = /*#__PURE__*/ (0, $l0021$reactjsxruntime.jsx)((0, $5eb75e0c130e0669$exports.SkeletonWrapper), {
children: /*#__PURE__*/ (0, $l0021$reactjsxruntime.jsx)(Component, {
...otherProps,
focusable: false,
"aria-label": ariaLabel,
"aria-hidden": ariaLabel ? ariaHidden || undefined : true,
role: "img",
"data-slot": slot,
className: (UNSAFE_className ?? '') + ' ' + (0, $5eb75e0c130e0669$exports.useSkeletonIcon)((0, $308b180f49d82d28$exports.mergeStyles)($bde97c91243ed164$var$iconStyles(null, styles), ctxStyles)),
style: UNSAFE_style
})
});
if (render) return render(svg);
return svg;
};
}
const $bde97c91243ed164$var$illustrationStyles = function anonymous(props, overrides) {
let rules = " ";
let width = false;
let height = false;
let matches = (overrides || '').matchAll(/(?:^|\s)(J|G|I|H|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|_S|-_8sjo0b-|Z|F)[^\s]+/g);
for (let p of matches){
if (p[1] === "Z") width = true;
if (p[1] === "F") height = true;
rules += p[0];
}
if (props.size === "L") {
if (!width) rules += ' Zq1';
} else if (props.size === "M") {
if (!width) rules += ' ZH1';
} else if (props.size === "S") {
if (!width) rules += ' ZF1';
}
if (props.size === "L") {
if (!height) rules += ' Fr1';
} else if (props.size === "M") {
if (!height) rules += ' FB1';
} else if (props.size === "S") {
if (!height) rules += ' Fz1';
}
rules += ' _va1';
return rules;
};
function $bde97c91243ed164$export$4d00e7be716a0093(Component) {
return (props)=>{
let ref = (0, $l0021$react.useRef)(null);
let ctx;
[ctx, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)({
slot: props.slot || 'icon'
}, ref, $bde97c91243ed164$export$207c7561471de4bd);
let { styles: ctxStyles } = ctx;
let { UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style, slot: slot, 'aria-label': ariaLabel, 'aria-hidden': ariaHidden, size: size = ctx.size || 'M', styles: styles, render: // @ts-ignore
render, ...otherProps } = props;
if (!ariaHidden) ariaHidden = undefined;
let svg = /*#__PURE__*/ (0, $l0021$reactjsxruntime.jsx)(Component, {
...otherProps,
// @ts-ignore
size: size,
focusable: false,
"aria-label": ariaLabel,
"aria-hidden": ariaLabel ? ariaHidden || undefined : true,
role: "img",
"data-slot": slot,
className: (UNSAFE_className ?? '') + ' ' + $bde97c91243ed164$var$illustrationStyles({
size: size
}, styles) + (ctxStyles || ''),
style: UNSAFE_style
});
if (render) return render(svg);
return svg;
};
}
//# sourceMappingURL=Icon.cjs.map