UNPKG

@react-spectrum/s2

Version:
154 lines (142 loc) 7.32 kB
require("./ColorField.css"); var $a0b996a550bb0891$exports = require("./Field.cjs"); var $bfa4962d90c8af48$exports = require("./Form.cjs"); var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs"); var $4UooL$reactjsxruntime = require("react/jsx-runtime"); var $4UooL$reactariacomponents = require("react-aria-components"); var $4UooL$react = require("react"); var $4UooL$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, "ColorFieldContext", () => $c7ab41f1e9757931$export$44644b8a16031b5b); $parcel$export(module.exports, "ColorField", () => $c7ab41f1e9757931$export$b865d4358897bb17); /* * 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 $c7ab41f1e9757931$export$44644b8a16031b5b = /*#__PURE__*/ (0, $4UooL$react.createContext)(null); const $c7ab41f1e9757931$export$b865d4358897bb17 = /*#__PURE__*/ (0, $4UooL$react.forwardRef)(function ColorField(props, ref) { [props, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props, ref, $c7ab41f1e9757931$export$44644b8a16031b5b); let formContext = (0, $4UooL$react.useContext)((0, $bfa4962d90c8af48$exports.FormContext)); props = (0, $bfa4962d90c8af48$exports.useFormProps)(props); let { label: label, description: description, errorMessage: errorMessage, necessityIndicator: necessityIndicator, labelPosition: labelPosition = 'top', labelAlign: labelAlign = 'start', UNSAFE_style: UNSAFE_style, UNSAFE_className: UNSAFE_className = '', styles: styles, ...fieldProps } = props; // Expose imperative interface for ref let domRef = (0, $4UooL$react.useRef)(null); let inputRef = (0, $4UooL$react.useRef)(null); (0, $4UooL$react.useImperativeHandle)(ref, ()=>({ ...(0, $4UooL$reactspectrumutils.createFocusableRef)(domRef, inputRef), select () { if (inputRef.current) inputRef.current.select(); }, getInputElement () { return inputRef.current; } })); return /*#__PURE__*/ (0, $4UooL$reactjsxruntime.jsx)((0, $4UooL$reactariacomponents.ColorField), { ...fieldProps, ref: domRef, style: UNSAFE_style, className: UNSAFE_className + function anonymous(props, overrides) { let rules = " "; let gridColumnStart = false; let gridColumnEnd = 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)[^\s]+/g); for (let p of matches){ if (p[1] === "z") gridColumnStart = true; if (p[1] === "y") gridColumnEnd = true; rules += p[0]; } rules += ' se1'; if (props.isInForm) { if (!gridColumnStart) rules += ' z2mU1'; } if (props.isInForm) { if (props.labelPosition === "side") { if (!gridColumnEnd) rules += ' yvoofG1'; } } if (props.isInForm) rules += ' DLwlgod1'; else { if (props.labelPosition === "side") rules += ' DPlN5qb1'; else if (props.labelPosition === "top") rules += ' DM8Mfn1'; } if (props.labelPosition === "side") rules += ' EPlN5qb1'; else if (props.labelPosition === "top") rules += ' E4w1sLc1'; if (props.labelPosition === "side") rules += ' CbRM95c1'; else if (props.labelPosition === "top") rules += ' Cxaocre1'; if (props.size === "XL") { rules += ' -_6BNtrc-e1'; rules += ' vx1'; } else if (props.size === "L") { rules += ' -_6BNtrc-d1'; rules += ' vx1'; } else if (props.size === "S") { rules += ' -_6BNtrc-b1'; rules += ' vx1'; } else if (props.size === "XS") { rules += ' -_6BNtrc-a1'; rules += ' vx1'; } else { rules += ' -_6BNtrc-c1'; rules += ' vx1'; } rules += ' ea1'; rules += ' _Fd1'; rules += ' _FnuYUweb1'; if (props.size === "XL") rules += ' -BhX7R-Fz1'; else if (props.size === "L") rules += ' -BhX7R-Fv1'; else if (props.size === "S") rules += ' -BhX7R-Fp1'; else if (props.size === "XS") rules += ' -BhX7R-Fn1'; else rules += ' -BhX7R-Fx1'; rules += ' -AJjOLd-UVkF0Db1'; rules += ' qg1'; rules += ' __ca1'; return rules; }({ size: props.size, labelPosition: labelPosition, isInForm: !!formContext }, styles), children: ({ isDisabled: isDisabled, isInvalid: isInvalid })=>/*#__PURE__*/ (0, $4UooL$reactjsxruntime.jsxs)((0, $4UooL$reactjsxruntime.Fragment), { children: [ /*#__PURE__*/ (0, $4UooL$reactjsxruntime.jsx)((0, $a0b996a550bb0891$exports.FieldLabel), { isDisabled: isDisabled, isRequired: props.isRequired, size: props.size, labelPosition: labelPosition, labelAlign: labelAlign, necessityIndicator: necessityIndicator, contextualHelp: props.contextualHelp, children: label }), /*#__PURE__*/ (0, $4UooL$reactjsxruntime.jsxs)((0, $a0b996a550bb0891$exports.FieldGroup), { size: props.size, children: [ /*#__PURE__*/ (0, $4UooL$reactjsxruntime.jsx)((0, $a0b996a550bb0891$exports.Input), { ref: inputRef }), isInvalid && /*#__PURE__*/ (0, $4UooL$reactjsxruntime.jsx)((0, $a0b996a550bb0891$exports.FieldErrorIcon), { isDisabled: isDisabled }) ] }), /*#__PURE__*/ (0, $4UooL$reactjsxruntime.jsx)((0, $a0b996a550bb0891$exports.HelpText), { size: props.size, isDisabled: isDisabled, isInvalid: isInvalid, description: description, children: errorMessage }) ] }) }); }); //# sourceMappingURL=ColorField.cjs.map