@react-spectrum/s2
Version:
Spectrum 2 UI components in React
90 lines (79 loc) • 4.24 kB
JavaScript
require("./ColorArea.css");
var $5b07976eb9e358fe$exports = require("./ColorHandle.cjs");
var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs");
var $lfrPf$reactjsxruntime = require("react/jsx-runtime");
var $lfrPf$reactariacomponents = require("react-aria-components");
var $lfrPf$react = require("react");
var $lfrPf$reactspectrumutils = require("@react-spectrum/utils");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "ColorAreaContext", () => $4c6639e34959fe36$export$ebe63fadcdce34ed);
$parcel$export(module.exports, "ColorArea", () => $4c6639e34959fe36$export$b2103f68a961418e);
/*
* 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.
*/
const $4c6639e34959fe36$export$ebe63fadcdce34ed = /*#__PURE__*/ (0, $lfrPf$react.createContext)(null);
const $4c6639e34959fe36$export$b2103f68a961418e = /*#__PURE__*/ (0, $lfrPf$react.forwardRef)(function ColorArea(props, ref) {
[props, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props, ref, $4c6639e34959fe36$export$ebe63fadcdce34ed);
let { UNSAFE_className: UNSAFE_className = '', UNSAFE_style: UNSAFE_style, styles: styles } = props;
let containerRef = (0, $lfrPf$reactspectrumutils.useDOMRef)(ref);
return /*#__PURE__*/ (0, $lfrPf$reactjsxruntime.jsx)((0, $lfrPf$reactariacomponents.ColorArea), {
...props,
ref: containerRef,
style: ({ defaultStyle: defaultStyle, isDisabled: isDisabled })=>({
...defaultStyle,
background: isDisabled ? undefined : defaultStyle.background,
// Move position: relative to style macro so it can be overridden.
position: undefined,
...UNSAFE_style
}),
className: (renderProps)=>UNSAFE_className + function anonymous(props, overrides) {
let rules = " ";
let position = false;
let width = false;
let height = false;
let minWidth = false;
let minHeight = false;
let matches = (overrides || '').matchAll(/(?:^|\s)(J|G|I|H|_u|_v|_s|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|Z|N|L|F|M|K)[^\s]+/g);
for (let p of matches){
if (p[1] === "_P") position = true;
if (p[1] === "Z") width = true;
if (p[1] === "F") height = true;
if (p[1] === "N") minWidth = true;
if (p[1] === "M") minHeight = true;
rules += p[0];
}
if (!position) rules += ' _Pc91';
if (!width) rules += ' Zr91';
if (!height) rules += ' Fs91';
if (!minWidth) rules += ' Nm91';
if (!minHeight) rules += ' Ml91';
rules += ' ob91';
rules += ' nb91';
rules += ' kb91';
rules += ' jb91';
rules += ' Oi91';
rules += ' Ola91';
rules += ' _Mb91';
rules += ' _Ka91';
if (props.isDisabled) rules += ' _Le91';
else rules += ' _Lf91';
if (props.isDisabled) rules += ' gH91';
return rules;
}(renderProps, styles),
children: ({ state: state })=>/*#__PURE__*/ (0, $lfrPf$reactjsxruntime.jsx)((0, $5b07976eb9e358fe$exports.ColorHandle), {
containerRef: containerRef,
getPosition: ()=>state.getThumbPosition()
})
});
});
//# sourceMappingURL=ColorArea.cjs.map