@react-spectrum/s2
Version:
Spectrum 2 UI components in React
91 lines (82 loc) • 4.37 kB
JavaScript
import "./ColorArea.css";
import {ColorHandle as $b4f7db7c45cd3de9$export$92862704de639678} from "./ColorHandle.mjs";
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../icons/useSpectrumContextProps.mjs";
import {jsx as $dNfSU$jsx} from "react/jsx-runtime";
import {useLocale as $dNfSU$useLocale, ColorArea as $dNfSU$ColorArea} from "react-aria-components";
import {createContext as $dNfSU$createContext, forwardRef as $dNfSU$forwardRef} from "react";
import {useDOMRef as $dNfSU$useDOMRef} from "@react-spectrum/utils";
/*
* 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 $40a2b649525568ab$export$ebe63fadcdce34ed = /*#__PURE__*/ (0, $dNfSU$createContext)(null);
const $40a2b649525568ab$export$b2103f68a961418e = /*#__PURE__*/ (0, $dNfSU$forwardRef)(function ColorArea(props, ref) {
[props, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props, ref, $40a2b649525568ab$export$ebe63fadcdce34ed);
let { UNSAFE_className: UNSAFE_className = '', UNSAFE_style: UNSAFE_style, styles: styles } = props;
let containerRef = (0, $dNfSU$useDOMRef)(ref);
let { direction: direction } = (0, $dNfSU$useLocale)();
return /*#__PURE__*/ (0, $dNfSU$jsx)((0, $dNfSU$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|_6|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 += ' _Pc1';
if (!width) rules += ' Zr1';
if (!height) rules += ' Fs1';
if (!minWidth) rules += ' Nm1';
if (!minHeight) rules += ' Ml1';
rules += ' ob1';
rules += ' nb1';
rules += ' kb1';
rules += ' jb1';
rules += ' Oi1';
rules += ' Ola1';
rules += ' _Mb1';
rules += ' _Ka1';
if (props.isDisabled) rules += ' _Le1';
else rules += ' _Lf1';
if (props.isDisabled) rules += ' gH1';
return rules;
}(renderProps, styles),
children: ({ state: state })=>/*#__PURE__*/ (0, $dNfSU$jsx)((0, $b4f7db7c45cd3de9$export$92862704de639678), {
containerRef: containerRef,
getPosition: ()=>{
let { x: x, y: y } = state.getThumbPosition();
return {
x: direction === 'ltr' ? x : 1 - x,
y: y
};
}
})
});
});
export {$40a2b649525568ab$export$ebe63fadcdce34ed as ColorAreaContext, $40a2b649525568ab$export$b2103f68a961418e as ColorArea};
//# sourceMappingURL=ColorArea.mjs.map