@react-spectrum/s2
Version:
Spectrum 2 UI components in React
145 lines (133 loc) • 5.54 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|_6|Z|N|L|F|M|K)[^\s]+/g);
for (let p of matches){
if (p[1] === "_P") position = true;
rules += p[0];
}
rules += ' sd1';
rules += ' _Ca1';
rules += ' eb1';
if (!position) rules += ' _Pc1';
rules += ' uk1';
rules += ' ucJ9TBTb1';
rules += ' ud3Euai1';
rules += ' uea1';
rules += ' ugb1';
rules += ' uhd1';
rules += ' uje1';
rules += ' u2NhKxcl1';
rules += ' uic1';
rules += ' po1';
if (props.isDropTarget) rules += ' _jf1';
else rules += ' _ja1';
if (props.isDropTarget) rules += ' g_e1';
rules += ' _kc1';
rules += ' hc1';
rules += ' mc1';
rules += ' lc1';
if (props.isFocusVisible) rules += ' ix1';
else if (props.isDropTarget) rules += ' ix1';
else rules += ' iq1';
rules += ' oc1';
rules += ' nc1';
rules += ' kc1';
rules += ' jc1';
rules += ' Th1';
rules += ' Qh1';
rules += ' Sh1';
rules += ' Rh1';
rules += ' _oa1';
return rules;
};
const $fb6e45fba2483f65$var$banner = function anonymous(props) {
let rules = " ";
rules += ' _Pa1';
rules += ' _Er1';
rules += ' _Rr1';
rules += ' IM1';
rules += ' HM1';
rules += ' sd1';
rules += ' eb1';
rules += ' _Ca1';
rules += ' MAyFGYc1';
rules += ' ZJ1';
if (props.size === "L") rules += ' Lg1';
else if (props.size === "S") rules += ' Le1';
else rules += ' Lf1';
rules += ' g21';
rules += ' ob1';
rules += ' nb1';
rules += ' kb1';
rules += ' jb1';
rules += ' px1';
rules += ' xd1';
rules += ' _xa1';
rules += ' xX0cczbc1';
rules += ' _xX0cczba1';
rules += ' T85xBjb1';
rules += ' Q85xBjb1';
rules += ' S85xBjb1';
rules += ' R85xBjb1';
rules += ' -M_-Mf1';
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