UNPKG

@teamsparta/stack-custom-modal

Version:
251 lines (246 loc) 8.52 kB
"use client"; "use strict"; "use client"; var __create = Object.create; var __defProp = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropNames = Object.getOwnPropertyNames; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); var __objRest = (source, exclude) => { var target = {}; for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop]; if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) { if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop]; } return target; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/compounds/CustomModalDescription.tsx var CustomModalDescription_exports = {}; __export(CustomModalDescription_exports, { CustomModalDescription: () => CustomModalDescription }); module.exports = __toCommonJS(CustomModalDescription_exports); var Dialog = __toESM(require("@radix-ui/react-dialog")); var import_stack_text = require("@teamsparta/stack-text"); var import_stack_tokens2 = require("@teamsparta/stack-tokens"); var import_react2 = require("react"); // src/style.ts var import_react = require("@emotion/react"); var import_stack_tokens = require("@teamsparta/stack-tokens"); var import_stack_utils = require("@teamsparta/stack-utils"); var import_stack_z_index = require("@teamsparta/stack-z-index"); var descriptionMarginVar = "--stack-modal-description-margin"; var contentMaxWidthVar = "--stack-modal-content-max-width"; var contentMaxHeightVar = "--stack-modal-content-max-height"; var contentMaxHeightDvhVar = "--stack-modal-content-max-height-dvh"; var contentHeightVar = "--stack-modal-content-height"; var contentHeightDvhVar = "--stack-modal-content-height-dvh"; var contentRadiusVar = "--stack-modal-content-radius"; var modalSizeVariants = { md: { [contentMaxWidthVar]: "460px", [contentMaxHeightVar]: "calc(100vh - 40px)", [contentMaxHeightDvhVar]: "calc(100dvh - 40px)", [contentHeightVar]: "auto", [contentHeightDvhVar]: "auto", [contentRadiusVar]: "16px", [descriptionMarginVar]: "4px 0 0 0" }, lg: { [contentMaxWidthVar]: "640px", [contentMaxHeightVar]: "calc(100vh - 40px)", [contentMaxHeightDvhVar]: "calc(100dvh - 40px)", [contentHeightVar]: "auto", [contentHeightDvhVar]: "auto", [contentRadiusVar]: "16px", [descriptionMarginVar]: "12px 0 0 0" }, xl: { [contentMaxWidthVar]: "1024px", [contentMaxHeightVar]: "100vh", [contentMaxHeightDvhVar]: "100dvh", [contentHeightVar]: "100vh", [contentHeightDvhVar]: "100dvh", [contentRadiusVar]: "0px", [descriptionMarginVar]: "12px 0 0 0" } }; var overlayCss = (0, import_react.css)({ backgroundColor: import_stack_tokens.vars.dimm.default, position: "fixed", inset: 0, zIndex: import_stack_z_index.zIndex.overlay }); var contentWrapperCss = (0, import_react.css)({ position: "fixed", transform: "translate(-50%, -50%)", top: "50%", left: "50%", zIndex: import_stack_z_index.zIndex.modal, "&:focus": { outline: "none" } }); var contentCss = (0, import_react.css)({ display: "flex", flexDirection: "column", maxWidth: (0, import_stack_utils.getVar)(contentMaxWidthVar), width: "100vw", maxHeight: (0, import_stack_utils.getVar)(contentMaxHeightVar), height: (0, import_stack_utils.getVar)(contentHeightVar), backgroundColor: import_stack_tokens.vars.background.modal, boxShadow: import_stack_tokens.vars.shadow.elevation1, borderRadius: (0, import_stack_utils.getVar)(contentRadiusVar), "@supports (height: 100dvh)": { maxHeight: (0, import_stack_utils.getVar)(contentMaxHeightDvhVar), height: (0, import_stack_utils.getVar)(contentHeightDvhVar) } }); var bodyCss = (0, import_react.css)({ padding: "0 32px", flex: 1 }); var headerCss = (0, import_react.css)({ position: "relative" }); var headerHasScrollCss = (0, import_react.css)({ padding: "32px 32px 24px 32px", borderBottom: `1px solid ${import_stack_tokens.vars.line.nonClickable}` }); var titleCss = (0, import_react.css)({ wordBreak: "keep-all", whiteSpace: "pre-wrap" }); var descriptionCss = (0, import_react.css)({ wordBreak: "keep-all", whiteSpace: "pre-wrap", margin: (0, import_stack_utils.getVar)(descriptionMarginVar) }); var footerHasScrollCss = (0, import_react.css)({ padding: "24px 32px 32px 32px", borderTop: `1px solid ${import_stack_tokens.vars.line.nonClickable}` }); var captionCss = (0, import_react.css)({ width: "100%", marginTop: 16, wordBreak: "keep-all", whiteSpace: "pre-wrap" }); var scrollAreaRootCss = (0, import_react.css)({ height: "100%", width: "100%", overflow: "hidden", display: "flex", flexDirection: "column" }); var scrollAreaContentCss = (0, import_react.css)({ flex: 1, overflow: "auto" }); var scrollAreaScrollbarCss = (0, import_react.css)({ width: "12px", display: "flex", userSelect: "none", touchAction: "none", paddingInline: "4px", transition: "background-color 160ms ease-out" }); var scrollAreaThumbCss = (0, import_react.css)({ flex: 1, backgroundColor: import_stack_tokens.vars.neutral[30], borderRadius: "10px", position: "relative", transition: "background-color 160ms ease-out" }); var closeButtonCss = (0, import_react.css)({ position: "absolute", right: 32, top: 32, zIndex: 1, display: "inline-flex", alignItems: "center", justifyContent: "center", padding: 0, width: "28px", height: "28px", flexShrink: 0, borderRadius: "50%", backgroundColor: import_stack_tokens.vars.fill.subtle, border: "none", cursor: "pointer" }); // src/compounds/CustomModalDescription.tsx var import_jsx_runtime = require("@emotion/react/jsx-runtime"); var CustomModalDescription = (0, import_react2.forwardRef)( (_a, ref) => { var _b = _a, { children, font = "bodyCompact", color = import_stack_tokens2.vars.text.tertiary } = _b, restProps = __objRest(_b, [ "children", "font", "color" ]); return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dialog.Description, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_stack_text.Text, __spreadProps(__spreadValues({ ref, as: "p", font, color, css: descriptionCss }, restProps), { children }) ) }); } ); CustomModalDescription.displayName = "CustomModalDescription"; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { CustomModalDescription });