@react-spectrum/s2
Version:
Spectrum 2 UI components in React
142 lines (130 loc) • 5.5 kB
JavaScript
import "./DropZone.css";
import {IllustratedMessageContext as $4950413ac998f607$export$d661ef89ad42d682} from "./IllustratedMessage.mjs";
import $4h9kk$intlStringsmjs from "./intlStrings.mjs";
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../icons/useSpectrumContextProps.mjs";
import {jsx as $4h9kk$jsx, jsxs as $4h9kk$jsxs, Fragment as $4h9kk$Fragment} from "react/jsx-runtime";
import {DropZone as $4h9kk$DropZone} from "react-aria-components";
import {createContext as $4h9kk$createContext, forwardRef as $4h9kk$forwardRef} from "react";
import {useDOMRef as $4h9kk$useDOMRef} from "@react-spectrum/utils";
import {useLocalizedStringFormatter as $4h9kk$useLocalizedStringFormatter} from "@react-aria/i18n";
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
/*
* 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 $fb6e45fba2483f65$export$14a72053295ff9a6 = /*#__PURE__*/ (0, $4h9kk$createContext)(null);
const $fb6e45fba2483f65$var$dropzone = function anonymous(props, overrides) {
let rules = " ";
let position = 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;
rules += p[0];
}
rules += ' sd91';
rules += ' _Ca91';
rules += ' eb91';
if (!position) rules += ' _Pc91';
rules += ' ug91';
rules += ' uch91';
rules += ' udi91';
rules += ' uea91';
rules += ' ugb91';
rules += ' uhd91';
rules += ' uje91';
rules += ' uic91';
rules += ' po91';
if (props.isDropTarget) rules += ' _jf91';
else rules += ' _ja91';
if (props.isDropTarget) rules += ' g_e91';
rules += ' _kc91';
rules += ' hc91';
rules += ' mc91';
rules += ' lc91';
if (props.isFocusVisible) rules += ' ix91';
else if (props.isDropTarget) rules += ' ix91';
else rules += ' iq91';
rules += ' oc91';
rules += ' nc91';
rules += ' kc91';
rules += ' jc91';
rules += ' Th91';
rules += ' Qh91';
rules += ' Sh91';
rules += ' Rh91';
return rules;
};
const $fb6e45fba2483f65$var$banner = function anonymous(props) {
let rules = " ";
rules += ' _Pa91';
rules += ' _Er91';
rules += ' _Rr91';
rules += ' IM91';
rules += ' HM91';
rules += ' sd91';
rules += ' eb91';
rules += ' _Ca91';
rules += ' MAyFGYc91';
rules += ' ZJ91';
if (props.size === "L") rules += ' Lg91';
else if (props.size === "S") rules += ' Le91';
else rules += ' Lf91';
rules += ' g291';
rules += ' ob91';
rules += ' nb91';
rules += ' kb91';
rules += ' jb91';
rules += ' px91';
rules += ' wd91';
rules += ' xd91';
rules += ' _xa91';
rules += ' T85xBjb91';
rules += ' Q85xBjb91';
rules += ' S85xBjb91';
rules += ' R85xBjb91';
rules += ' -M_-Mf91';
return rules;
};
const $fb6e45fba2483f65$export$3c6489d84dc98b6 = /*#__PURE__*/ (0, $4h9kk$forwardRef)(function DropZone(props, ref) {
let stringFormatter = (0, $4h9kk$useLocalizedStringFormatter)((0, ($parcel$interopDefault($4h9kk$intlStringsmjs))), '@react-spectrum/s2');
[props, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props, ref, $fb6e45fba2483f65$export$14a72053295ff9a6);
let { size: size = 'M' } = props;
let domRef = (0, $4h9kk$useDOMRef)(ref);
return /*#__PURE__*/ (0, $4h9kk$jsx)((0, $4h9kk$DropZone), {
...props,
ref: domRef,
style: props.UNSAFE_style,
className: (renderProps)=>(props.UNSAFE_className || '') + $fb6e45fba2483f65$var$dropzone(renderProps, props.styles),
children: (renderProps)=>/*#__PURE__*/ (0, $4h9kk$jsxs)((0, $4h9kk$Fragment), {
children: [
/*#__PURE__*/ (0, $4h9kk$jsx)((0, $4950413ac998f607$export$d661ef89ad42d682).Provider, {
value: {
isInDropZone: true,
isDropTarget: renderProps.isDropTarget,
size: size
},
children: props.children
}),
renderProps.isDropTarget && props.isFilled && /*#__PURE__*/ (0, $4h9kk$jsx)("div", {
className: $fb6e45fba2483f65$var$banner({
size: size
}),
children: /*#__PURE__*/ (0, $4h9kk$jsx)("span", {
children: props.replaceMessage ? props.replaceMessage : stringFormatter.format('dropzone.replaceMessage')
})
})
]
})
});
});
export {$fb6e45fba2483f65$export$14a72053295ff9a6 as DropZoneContext, $fb6e45fba2483f65$export$3c6489d84dc98b6 as DropZone};
//# sourceMappingURL=DropZone.mjs.map