@ifhover/leaf-ui 0.16.7 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser/modules/confirm/confirm.cjs +2 -2
- package/dist/cjs/browser/modules/confirm/confirm.cjs.map +1 -1
- package/dist/cjs/browser/modules/drawer/drawer.cjs +120 -61
- package/dist/cjs/browser/modules/drawer/drawer.cjs.map +1 -1
- package/dist/cjs/browser/modules/filelist/filelist.cjs +2 -2
- package/dist/cjs/browser/modules/filelist/filelist.cjs.map +1 -1
- package/dist/cjs/browser/modules/modal/base.cjs +287 -0
- package/dist/cjs/browser/modules/modal/base.cjs.map +1 -0
- package/dist/cjs/browser/modules/modal/modal.cjs +64 -209
- package/dist/cjs/browser/modules/modal/modal.cjs.map +1 -1
- package/dist/cjs/browser/modules/shared/presence.cjs +12 -6
- package/dist/cjs/browser/modules/shared/presence.cjs.map +1 -1
- package/dist/cjs/browser/modules/tabletanstack/tabletanstack.cjs +14 -2
- package/dist/cjs/browser/modules/tabletanstack/tabletanstack.cjs.map +1 -1
- package/dist/cjs/browser/modules/tabs/tabs.cjs +194 -175
- package/dist/cjs/browser/modules/tabs/tabs.cjs.map +1 -1
- package/dist/cjs/confirm/confirm.cjs +2 -2
- package/dist/cjs/confirm/confirm.cjs.map +1 -1
- package/dist/cjs/drawer/drawer.cjs +120 -61
- package/dist/cjs/drawer/drawer.cjs.map +1 -1
- package/dist/cjs/drawer/drawer.d.cts +6 -0
- package/dist/cjs/drawer/drawer.d.cts.map +1 -1
- package/dist/cjs/drawer/index.d.cts +1 -1
- package/dist/cjs/drawer/index.d.cts.map +1 -1
- package/dist/cjs/filelist/filelist.cjs +2 -2
- package/dist/cjs/filelist/filelist.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/index.d.cts.map +1 -1
- package/dist/cjs/modal/base.cjs +285 -0
- package/dist/cjs/modal/base.cjs.map +1 -0
- package/dist/cjs/modal/base.d.cts +23 -0
- package/dist/cjs/modal/base.d.cts.map +1 -0
- package/dist/cjs/modal/index.d.cts +1 -1
- package/dist/cjs/modal/index.d.cts.map +1 -1
- package/dist/cjs/modal/modal.cjs +64 -209
- package/dist/cjs/modal/modal.cjs.map +1 -1
- package/dist/cjs/modal/modal.d.cts +8 -3
- package/dist/cjs/modal/modal.d.cts.map +1 -1
- package/dist/cjs/shared/presence.cjs +12 -6
- package/dist/cjs/shared/presence.cjs.map +1 -1
- package/dist/cjs/shared/presence.d.cts +1 -1
- package/dist/cjs/shared/presence.d.cts.map +1 -1
- package/dist/cjs/styles/card.css +1 -1
- package/dist/cjs/styles/colorpicker.css +1 -1
- package/dist/cjs/styles/components/card.css +1 -1
- package/dist/cjs/styles/components/drawer.css +1 -1
- package/dist/cjs/styles/components/modal.css +1 -1
- package/dist/cjs/styles/components/tabletanstack.css +1 -1
- package/dist/cjs/styles/components/tabs.css +1 -1
- package/dist/cjs/styles/config-provider.css +1 -1
- package/dist/cjs/styles/confirm.css +1 -1
- package/dist/cjs/styles/daterangepicker.css +1 -1
- package/dist/cjs/styles/drawer.css +1 -1
- package/dist/cjs/styles/filelist.css +1 -1
- package/dist/cjs/styles/index.css +75 -14
- package/dist/cjs/styles/index.css.map +1 -1
- package/dist/cjs/styles/modal.css +1 -1
- package/dist/cjs/styles/tabletanstack.css +1 -1
- package/dist/cjs/styles/tabs.css +1 -1
- package/dist/cjs/styles/upload.css +1 -1
- package/dist/cjs/tabletanstack/tabletanstack.cjs +14 -2
- package/dist/cjs/tabletanstack/tabletanstack.cjs.map +1 -1
- package/dist/cjs/tabletanstack/tabletanstack.d.cts.map +1 -1
- package/dist/cjs/tabs/tabs.cjs +194 -175
- package/dist/cjs/tabs/tabs.cjs.map +1 -1
- package/dist/cjs/tabs/tabs.d.cts +14 -1
- package/dist/cjs/tabs/tabs.d.cts.map +1 -1
- package/dist/esm/browser/modules/confirm/confirm.js +1 -1
- package/dist/esm/browser/modules/confirm/confirm.js.map +1 -1
- package/dist/esm/browser/modules/drawer/drawer.js +121 -62
- package/dist/esm/browser/modules/drawer/drawer.js.map +1 -1
- package/dist/esm/browser/modules/filelist/filelist.js +1 -1
- package/dist/esm/browser/modules/filelist/filelist.js.map +1 -1
- package/dist/esm/browser/modules/modal/base.js +249 -0
- package/dist/esm/browser/modules/modal/base.js.map +1 -0
- package/dist/esm/browser/modules/modal/modal.js +65 -207
- package/dist/esm/browser/modules/modal/modal.js.map +1 -1
- package/dist/esm/browser/modules/shared/presence.js +12 -6
- package/dist/esm/browser/modules/shared/presence.js.map +1 -1
- package/dist/esm/browser/modules/tabletanstack/tabletanstack.js +14 -2
- package/dist/esm/browser/modules/tabletanstack/tabletanstack.js.map +1 -1
- package/dist/esm/browser/modules/tabs/tabs.js +190 -174
- package/dist/esm/browser/modules/tabs/tabs.js.map +1 -1
- package/dist/esm/confirm/confirm.js +1 -1
- package/dist/esm/confirm/confirm.js.map +1 -1
- package/dist/esm/drawer/drawer.d.ts +6 -0
- package/dist/esm/drawer/drawer.d.ts.map +1 -1
- package/dist/esm/drawer/drawer.js +121 -62
- package/dist/esm/drawer/drawer.js.map +1 -1
- package/dist/esm/drawer/index.d.ts +1 -1
- package/dist/esm/drawer/index.d.ts.map +1 -1
- package/dist/esm/filelist/filelist.js +1 -1
- package/dist/esm/filelist/filelist.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/modal/base.d.ts +23 -0
- package/dist/esm/modal/base.d.ts.map +1 -0
- package/dist/esm/modal/base.js +247 -0
- package/dist/esm/modal/base.js.map +1 -0
- package/dist/esm/modal/index.d.ts +1 -1
- package/dist/esm/modal/index.d.ts.map +1 -1
- package/dist/esm/modal/modal.d.ts +8 -3
- package/dist/esm/modal/modal.d.ts.map +1 -1
- package/dist/esm/modal/modal.js +65 -207
- package/dist/esm/modal/modal.js.map +1 -1
- package/dist/esm/shared/presence.d.ts +1 -1
- package/dist/esm/shared/presence.d.ts.map +1 -1
- package/dist/esm/shared/presence.js +12 -6
- package/dist/esm/shared/presence.js.map +1 -1
- package/dist/esm/styles/card.css +1 -1
- package/dist/esm/styles/colorpicker.css +1 -1
- package/dist/esm/styles/components/card.css +1 -1
- package/dist/esm/styles/components/drawer.css +1 -1
- package/dist/esm/styles/components/modal.css +1 -1
- package/dist/esm/styles/components/tabletanstack.css +1 -1
- package/dist/esm/styles/components/tabs.css +1 -1
- package/dist/esm/styles/config-provider.css +1 -1
- package/dist/esm/styles/confirm.css +1 -1
- package/dist/esm/styles/daterangepicker.css +1 -1
- package/dist/esm/styles/drawer.css +1 -1
- package/dist/esm/styles/filelist.css +1 -1
- package/dist/esm/styles/index.css +75 -14
- package/dist/esm/styles/index.css.map +1 -1
- package/dist/esm/styles/modal.css +1 -1
- package/dist/esm/styles/tabletanstack.css +1 -1
- package/dist/esm/styles/tabs.css +1 -1
- package/dist/esm/styles/upload.css +1 -1
- package/dist/esm/tabletanstack/tabletanstack.d.ts.map +1 -1
- package/dist/esm/tabletanstack/tabletanstack.js +14 -2
- package/dist/esm/tabletanstack/tabletanstack.js.map +1 -1
- package/dist/esm/tabs/tabs.d.ts +14 -1
- package/dist/esm/tabs/tabs.d.ts.map +1 -1
- package/dist/esm/tabs/tabs.js +190 -174
- package/dist/esm/tabs/tabs.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal/modal.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../../../src/modal/modal.tsx"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { X } from 'lucide-react';\nimport { type HTMLAttributes, type ReactNode, useEffect, useId, useRef, useState } from 'react';\nimport { ButtonControl, type ButtonProps } from '../button/button';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { useLeafConfig } from '../config-provider/context';\nimport { ScrollbarControl as Scrollbar } from '../scrollbar/scrollbar';\nimport { classes } from '../shared/classes';\nimport { type DialogFocusOptions, useDialog } from '../shared/dialog';\nimport { inertProps } from '../shared/inert';\nimport { OverlayOwner } from '../shared/overlay-owner';\nimport { useNaturalHeightTransition, usePresence } from '../shared/presence';\nimport { ScopedPortal } from '../shared/scoped-portal';\n\nexport interface ModalFooterActions {\n confirmButton: ReactNode;\n cancelButton: ReactNode;\n}\nexport interface ModalProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>,\n DialogFocusOptions {\n open: boolean;\n title?: ReactNode;\n /** Supporting text displayed below the title. */\n description?: ReactNode;\n /** Decorative header icon. */\n icon?: ReactNode;\n /** Separate the header and footer with subtle borders. */\n divided?: boolean;\n footer?: ReactNode | ((actions: ModalFooterActions) => ReactNode);\n confirmText?: ReactNode;\n cancelText?: ReactNode;\n confirmLoading?: boolean;\n confirmButtonProps?: ButtonProps;\n cancelButtonProps?: ButtonProps;\n onConfirm?: () => void | Promise<void>;\n onCancel?: () => void;\n width?: number | string;\n closable?: boolean;\n maskClosable?: boolean;\n keyboard?: boolean;\n onClose?: () => void;\n afterClose?: () => void;\n forceRender?: boolean;\n destroyOnClose?: boolean;\n preserve?: boolean;\n container?: Element | DocumentFragment | (() => Element | DocumentFragment);\n}\n\nfunction ModalSurface({\n open,\n title,\n description,\n icon,\n divided = true,\n footer,\n confirmText,\n cancelText,\n confirmLoading = false,\n confirmButtonProps,\n cancelButtonProps,\n onConfirm,\n onCancel,\n width = 480,\n closable = true,\n maskClosable = true,\n keyboard = true,\n onClose,\n afterClose,\n forceRender = false,\n destroyOnClose = false,\n preserve,\n initialFocus,\n returnFocus,\n container: _container,\n children,\n className,\n style,\n ...props\n}: ModalProps) {\n const { messages, maskBlur } = useLeafConfig();\n const [pending, setPending] = useState(false);\n const [error, setError] = useState<string>();\n const mounted = useRef(true);\n const accepting = useRef(false);\n const generation = useRef(0);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n useEffect(() => {\n generation.current++;\n accepting.current = false;\n setPending(false);\n if (open) setError(undefined);\n }, [open]);\n const busy = pending || confirmLoading;\n async function accept() {\n if (accepting.current || busy) return;\n if (!onConfirm) {\n if (confirmButtonProps?.type !== 'submit') onClose?.();\n return;\n }\n accepting.current = true;\n const request = generation.current;\n setPending(true);\n setError(undefined);\n try {\n await onConfirm();\n } catch (reason) {\n if (mounted.current && generation.current === request)\n setError(reason instanceof Error ? reason.message : String(reason));\n } finally {\n if (generation.current === request) {\n accepting.current = false;\n if (mounted.current) setPending(false);\n }\n }\n }\n const cancel = () => {\n if (!busy) (onCancel ?? onClose)?.();\n };\n const actions: ModalFooterActions = {\n cancelButton: (\n <ButtonControl\n type=\"button\"\n variant=\"outline\"\n {...cancelButtonProps}\n disabled={busy || cancelButtonProps?.disabled}\n onClick={(event) => {\n cancelButtonProps?.onClick?.(event);\n if (!event.defaultPrevented) cancel();\n }}\n >\n {cancelText ?? messages.common.cancel}\n </ButtonControl>\n ),\n confirmButton: (\n <ButtonControl\n type=\"button\"\n variant=\"solid\"\n {...confirmButtonProps}\n loading={busy || confirmButtonProps?.loading}\n onClick={(event) => {\n confirmButtonProps?.onClick?.(event);\n if (!event.defaultPrevented) void accept();\n }}\n >\n {confirmText ?? messages.common.confirm}\n </ButtonControl>\n ),\n };\n const renderedFooter =\n typeof footer === 'function' ? (\n footer(actions)\n ) : footer === undefined ? (\n <div className=\"leaf-modal__actions\">\n {actions.cancelButton}\n {actions.confirmButton}\n </div>\n ) : (\n footer\n );\n const panel = useRef<HTMLDivElement>(null);\n const content = useRef<HTMLDivElement>(null);\n const backdrop = useRef<HTMLButtonElement>(null);\n const present = usePresence(open, backdrop);\n useNaturalHeightTransition(panel, content, open);\n const titleId = `${useId()}-title`;\n const descriptionId = `${useId()}-description`;\n const modalId = `${useId()}-dialog`;\n const close = useRef(cancel);\n close.current = cancel;\n const wasPresent = useRef(false);\n useEffect(() => {\n if (wasPresent.current && !present) afterClose?.();\n wasPresent.current = present;\n }, [present, afterClose]);\n useDialog(open, panel, modalId, cancel, keyboard, { initialFocus, returnFocus });\n const visited = useRef(false);\n if (open) visited.current = true;\n if (\n !present &&\n !forceRender &&\n ((preserve === undefined ? destroyOnClose : !preserve) || !visited.current)\n )\n return null;\n return (\n <div\n hidden={!present}\n className=\"leaf-modal-mask\"\n data-blur={maskBlur ? undefined : 'off'}\n data-state={open ? 'open' : 'closing'}\n aria-hidden={!open || undefined}\n {...inertProps(!open)}\n >\n <button\n ref={backdrop}\n type=\"button\"\n className=\"leaf-modal-backdrop\"\n tabIndex={-1}\n aria-label={messages.common.close}\n onClick={() => {\n if (maskClosable) close.current?.();\n }}\n />\n {/* biome-ignore lint/a11y/useAriaPropsSupportedByRole: dialog and alertdialog both support aria-modal. */}\n <div\n {...props}\n ref={panel}\n id={props.id ?? modalId}\n role={props.role ?? 'dialog'}\n aria-modal=\"true\"\n aria-labelledby={title != null ? titleId : props['aria-labelledby']}\n aria-describedby={\n [props['aria-describedby'], description != null && descriptionId]\n .filter(Boolean)\n .join(' ') || undefined\n }\n tabIndex={-1}\n className={classes('leaf-modal', divided && 'leaf-modal--divided', className)}\n style={{ width, ...style }}\n >\n <OverlayOwner.Provider value={modalId}>\n {(title != null || description != null || icon != null || closable) && (\n <div\n className={classes(\n 'leaf-modal__header',\n description == null && 'leaf-modal__header--simple',\n icon != null && 'leaf-modal__header--icon',\n title == null &&\n description == null &&\n icon == null &&\n 'leaf-modal__header--compact',\n )}\n >\n {icon != null && (\n <span className=\"leaf-modal__icon\" aria-hidden=\"true\">\n {icon}\n </span>\n )}\n {(title != null || description != null) && (\n <div className=\"leaf-modal__heading\">\n {title != null && <h2 id={titleId}>{title}</h2>}\n {description != null && (\n <div id={descriptionId} className=\"leaf-modal__description\">\n {description}\n </div>\n )}\n </div>\n )}\n {closable && (\n <button\n type=\"button\"\n className=\"leaf-modal__close\"\n aria-label={messages.common.close}\n onClick={() => close.current?.()}\n >\n <X size={18} aria-hidden=\"true\" />\n </button>\n )}\n </div>\n )}\n {((children != null && children !== false) || error != null) && (\n <Scrollbar\n className=\"leaf-modal__body\"\n viewportClassName=\"leaf-modal__viewport\"\n orientation=\"vertical\"\n aria-labelledby={title != null ? titleId : undefined}\n aria-label={\n title == null ? (props['aria-label'] ?? messages.common.confirm) : undefined\n }\n >\n <div ref={content} className=\"leaf-modal__content\">\n {children}\n {error && (\n <p role=\"alert\" className=\"leaf-confirm-error\">\n {error}\n </p>\n )}\n </div>\n </Scrollbar>\n )}\n {renderedFooter != null && <div className=\"leaf-modal__footer\">{renderedFooter}</div>}\n </OverlayOwner.Provider>\n </div>\n </div>\n );\n}\n// Other components reuse the dialog mechanics without inheriting public Modal defaults.\nexport function ModalBase(props: ModalProps) {\n return (\n <ScopedPortal container={props.container}>\n <ModalSurface {...props} />\n </ScopedPortal>\n );\n}\nexport function Modal(rawProps: ModalProps) {\n const props = useComponentProps('Modal', rawProps);\n return <ModalBase {...props} />;\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","ModalSurface","open","title","description","icon","divided","footer","confirmText","cancelText","confirmLoading","confirmButtonProps","cancelButtonProps","onConfirm","onCancel","width","closable","maskClosable","keyboard","onClose","afterClose","forceRender","destroyOnClose","preserve","initialFocus","returnFocus","_container","children","className","style","props","messages","maskBlur","useLeafConfig","pending","setPending","useState","error","setError","mounted","useRef","accepting","generation","useEffect","undefined","busy","accept","request","reason","Error","String","cancel","actions","ButtonControl","event","renderedFooter","panel","content","backdrop","present","usePresence","useNaturalHeightTransition","titleId","useId","descriptionId","modalId","close","wasPresent","useDialog","visited","inertProps","Boolean","classes","OverlayOwner","X","Scrollbar","ModalBase","ScopedPortal","Modal","rawProps","useComponentProps"],"mappings":";;;;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAF,oBAAoB,CAAC,GAAG,CAACQ,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFT,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOU,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;;;;;AC0CA,SAASI,aAAa,EACpBC,IAAI,EACJC,KAAK,EACLC,WAAW,EACXC,IAAI,EACJC,UAAU,IAAI,EACdC,MAAM,EACNC,WAAW,EACXC,UAAU,EACVC,iBAAiB,KAAK,EACtBC,kBAAkB,EAClBC,iBAAiB,EACjBC,SAAS,EACTC,QAAQ,EACRC,QAAQ,GAAG,EACXC,WAAW,IAAI,EACfC,eAAe,IAAI,EACnBC,WAAW,IAAI,EACfC,OAAO,EACP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,QAAfC,eACC,AADsB,WAAR,GACd,qCAAC;4CAAI,IAAI4D;4CAAe,WAAU;sDAC/B5D;;;;gCAKRY,YACC,AADW,WAAZA,GACC,qCAAC;oCACC,MAAK;oCACL,WAAU;oCACV,cAAYe,SAAS,MAAM,CAAC,KAAK;oCACjC,SAAS,IAAMmC,MAAM,OAAO;8CAE5B,mDAACQ,sCAAAA,CAACA,EAAAA;wCAAC,MAAM;wCAAI,eAAY;;;;;wBAK9B/C,CAAAA,AAAY,QAAZA,YAAoBA,AAAa,UAAbA,YAAuBU,AAAS,QAATA,KAAY,KACxD,AADwD,cACxD,qCAACsC,8BAAAA,gBAASA,EAAAA;4BACR,WAAU;4BACV,mBAAkB;4BAClB,aAAY;4BACZ,mBAAiBxE,AAAS,QAATA,QAAgB2D,UAAUlB;4BAC3C,cACEzC,AAAS,QAATA,QAAiB2B,KAAK,CAAC,aAAa,IAAIC,SAAS,MAAM,CAAC,OAAO,GAAIa;sCAGrE,oDAAC;gCAAI,KAAKa;gCAAS,WAAU;;oCAC1B9B;oCACAU,SACC,AADQ,WAATA,GACC,qCAAC;wCAAE,MAAK;wCAAQ,WAAU;kDACvBA;;;;;wBAMQ,QAAlBkB,kBAA0B,WAAR,GAAQ,qCAAC;4BAAI,WAAU;sCAAsBA;;;;;;;AAK1E;AAEO,SAASqB,UAAU9C,KAAiB;IACzC,OACE,AADK,WAAP,GACE,qCAAC+C,kCAAAA,YAAYA,EAAAA;QAAC,WAAW/C,MAAM,SAAS;kBACtC,mDAAC7B,cAAAA;YAAc,GAAG6B,KAAK;;;AAG7B;AACO,SAASgD,MAAMC,QAAoB;IACxC,MAAMjD,QAAQkD,AAAAA,IAAAA,uCAAAA,iBAAAA,AAAAA,EAAkB,SAASD;IACzC,OAAO,WAAP,GAAO,qCAACH,WAAAA;QAAW,GAAG9C,KAAK;;AAC7B"}
|
|
1
|
+
{"version":3,"file":"modal/modal.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../../../src/modal/modal.tsx"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type HTMLAttributes, type ReactNode, useEffect, useLayoutEffect, useRef } from 'react';\nimport type { ButtonProps } from '../button/button';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { ScrollbarControl as Scrollbar } from '../scrollbar/scrollbar';\nimport { classes } from '../shared/classes';\nimport type { DialogFocusOptions } from '../shared/dialog';\nimport { type TabsProps, useTabsParts } from '../tabs/tabs';\nimport { ModalBase, type ModalTabsRenderProps } from './base';\n\nconst useBrowserLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\nexport interface ModalFooterActions {\n confirmButton: ReactNode;\n cancelButton: ReactNode;\n}\n/** Tabs controls integrated with the modal; Modal fixes the line type and top placement. */\nexport interface ModalTabsProps extends Omit<TabsProps, 'type' | 'placement' | 'children'> {}\n\nexport interface ModalProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>,\n DialogFocusOptions {\n open: boolean;\n title?: ReactNode;\n /** Supporting text displayed below the title. */\n description?: ReactNode;\n /** Decorative header icon. */\n icon?: ReactNode;\n /** Separate the header and footer with subtle borders. */\n divided?: boolean;\n /** Embedded tabs placed below the heading, or replacing it when no title is supplied. */\n tabs?: ModalTabsProps;\n footer?: ReactNode | ((actions: ModalFooterActions) => ReactNode);\n confirmText?: ReactNode;\n cancelText?: ReactNode;\n confirmLoading?: boolean;\n confirmButtonProps?: ButtonProps;\n cancelButtonProps?: ButtonProps;\n onConfirm?: () => void | Promise<void>;\n onCancel?: () => void;\n width?: number | string;\n closable?: boolean;\n maskClosable?: boolean;\n keyboard?: boolean;\n onClose?: () => void;\n afterClose?: () => void;\n forceRender?: boolean;\n destroyOnClose?: boolean;\n preserve?: boolean;\n container?: Element | DocumentFragment | (() => Element | DocumentFragment);\n}\n\nfunction ModalTabsLayout({\n open,\n tabs,\n title,\n titleId,\n hasHeading,\n closeButton,\n contentRef,\n snapHeight,\n ariaLabel,\n ariaLabelledBy,\n scrollbarLabel,\n scrollbarLabelledBy,\n error,\n children,\n}: ModalTabsRenderProps) {\n const tabExtra =\n !hasHeading && closeButton != null ? (\n <div className=\"leaf-dialog-tab-extra leaf-modal__tab-extra\">\n {tabs.extra}\n {closeButton}\n </div>\n ) : (\n tabs.extra\n );\n const tabLabel = tabs['aria-label'] ?? (typeof title === 'string' ? title : ariaLabel);\n const tabLabelledBy =\n tabs['aria-labelledby'] ??\n (tabs['aria-label'] == null && title != null\n ? titleId\n : tabs['aria-label'] == null\n ? ariaLabelledBy\n : undefined);\n const parts = useTabsParts({\n ...tabs,\n type: 'line',\n placement: 'top',\n size: tabs.size ?? 'md',\n 'aria-label': tabLabel,\n 'aria-labelledby': tabLabelledBy,\n extra: tabExtra,\n className: classes(\n 'leaf-dialog-tabs',\n hasHeading && 'leaf-dialog-tabs--headed',\n 'leaf-modal__tabs',\n tabs.className,\n ),\n panelsClassName: 'leaf-dialog-panels',\n visibilityKey: open,\n });\n const previousSelected = useRef(parts?.selected);\n useBrowserLayoutEffect(() => {\n if (previousSelected.current === parts?.selected) return;\n previousSelected.current = parts?.selected;\n snapHeight();\n }, [parts?.selected, snapHeight]);\n\n return (\n <>\n {parts && <div {...parts.rootProps}>{parts.header}</div>}\n {(parts?.hasPanels || (children != null && children !== false) || error != null) && (\n <Scrollbar\n className=\"leaf-modal__body\"\n viewportClassName=\"leaf-modal__viewport\"\n orientation=\"vertical\"\n aria-labelledby={scrollbarLabelledBy}\n aria-label={scrollbarLabel}\n >\n <div ref={contentRef} className=\"leaf-modal__content\">\n {parts?.panels}\n {children}\n {error && (\n <p role=\"alert\" className=\"leaf-confirm-error\">\n {error}\n </p>\n )}\n </div>\n </Scrollbar>\n )}\n </>\n );\n}\n\ntype ModalControlProps = ModalProps;\n\nfunction ModalControl({\n divided = true,\n confirmLoading = false,\n width = 480,\n closable = true,\n maskClosable = true,\n keyboard = true,\n forceRender = false,\n destroyOnClose = false,\n ...props\n}: ModalControlProps) {\n return (\n <ModalBase\n {...props}\n divided={divided}\n confirmLoading={confirmLoading}\n width={width}\n closable={closable}\n maskClosable={maskClosable}\n keyboard={keyboard}\n forceRender={forceRender}\n destroyOnClose={destroyOnClose}\n renderTabsLayout={ModalTabsLayout}\n />\n );\n}\n\nexport function Modal(rawProps: ModalProps) {\n const props = useComponentProps('Modal', rawProps);\n return <ModalControl {...props} />;\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","useBrowserLayoutEffect","window","useEffect","useLayoutEffect","ModalTabsLayout","open","tabs","title","titleId","hasHeading","closeButton","contentRef","snapHeight","ariaLabel","ariaLabelledBy","scrollbarLabel","scrollbarLabelledBy","error","children","tabExtra","tabLabel","tabLabelledBy","undefined","parts","useTabsParts","classes","previousSelected","useRef","Scrollbar","ModalControl","divided","confirmLoading","width","closable","maskClosable","keyboard","forceRender","destroyOnClose","props","ModalBase","Modal","rawProps","useComponentProps"],"mappings":";;;;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,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,gBAAgBC;QAChB,OAAOC;QACP,UAAUC;QACV,cAAcC;QACd,UAAUC;QACV,aAAaC;QACb,gBAAgBC;QAChB,kBAAkBjC;;AAGxB;AAEO,SAASoC,MAAMC,QAAoB;IACxC,MAAMH,QAAQI,AAAAA,IAAAA,uCAAAA,iBAAAA,AAAAA,EAAkB,SAASD;IACzC,OAAO,WAAP,GAAO,qCAACZ,cAAAA;QAAc,GAAGS,KAAK;;AAChC"}
|
|
@@ -39,6 +39,7 @@ const useBrowserLayoutEffect = "u" < typeof window ? external_react_namespaceObj
|
|
|
39
39
|
function useNaturalHeightTransition(surfaceRef, contentRef, open) {
|
|
40
40
|
const enabled = (0, external_motion_cjs_namespaceObject.useMotionEnabled)();
|
|
41
41
|
const sync = (0, external_react_namespaceObject.useRef)(void 0);
|
|
42
|
+
const snap = (0, external_react_namespaceObject.useRef)(()=>{});
|
|
42
43
|
useBrowserLayoutEffect(()=>{
|
|
43
44
|
const surface = surfaceRef.current;
|
|
44
45
|
const content = contentRef.current;
|
|
@@ -87,6 +88,14 @@ function useNaturalHeightTransition(surfaceRef, contentRef, open) {
|
|
|
87
88
|
});
|
|
88
89
|
};
|
|
89
90
|
sync.current = update;
|
|
91
|
+
snap.current = ()=>{
|
|
92
|
+
animation?.cancel();
|
|
93
|
+
reveal?.cancel();
|
|
94
|
+
animation = void 0;
|
|
95
|
+
reveal = void 0;
|
|
96
|
+
lastHeight = surface.offsetHeight;
|
|
97
|
+
lastLayout = layout();
|
|
98
|
+
};
|
|
90
99
|
let observer;
|
|
91
100
|
if ("u" > typeof ResizeObserver) {
|
|
92
101
|
observer = new ResizeObserver(update);
|
|
@@ -94,12 +103,7 @@ function useNaturalHeightTransition(surfaceRef, contentRef, open) {
|
|
|
94
103
|
for (const part of parts())observer.observe(part);
|
|
95
104
|
}
|
|
96
105
|
const resize = ()=>{
|
|
97
|
-
|
|
98
|
-
reveal?.cancel();
|
|
99
|
-
animation = void 0;
|
|
100
|
-
reveal = void 0;
|
|
101
|
-
lastHeight = surface.offsetHeight;
|
|
102
|
-
lastLayout = layout();
|
|
106
|
+
snap.current();
|
|
103
107
|
};
|
|
104
108
|
window.addEventListener('resize', resize);
|
|
105
109
|
window.visualViewport?.addEventListener('resize', resize);
|
|
@@ -110,6 +114,7 @@ function useNaturalHeightTransition(surfaceRef, contentRef, open) {
|
|
|
110
114
|
animation?.cancel();
|
|
111
115
|
reveal?.cancel();
|
|
112
116
|
sync.current = void 0;
|
|
117
|
+
snap.current = ()=>{};
|
|
113
118
|
};
|
|
114
119
|
}, [
|
|
115
120
|
open,
|
|
@@ -120,6 +125,7 @@ function useNaturalHeightTransition(surfaceRef, contentRef, open) {
|
|
|
120
125
|
useBrowserLayoutEffect(()=>{
|
|
121
126
|
sync.current?.();
|
|
122
127
|
});
|
|
128
|
+
return (0, external_react_namespaceObject.useRef)(()=>snap.current()).current;
|
|
123
129
|
}
|
|
124
130
|
function useContentTransition(ref, view, direction = 0, layoutOnly = false) {
|
|
125
131
|
const enabled = (0, external_motion_cjs_namespaceObject.useMotionEnabled)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared/presence.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../../../src/shared/presence.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type RefObject, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { animateMotion, useMotionEnabled } from './motion';\n\nconst useBrowserLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\n/** Interpolate natural dialog height, including state changes inside its children. */\nexport function useNaturalHeightTransition(\n surfaceRef: RefObject<HTMLElement | null>,\n contentRef: RefObject<HTMLElement | null>,\n open: boolean,\n) {\n const enabled = useMotionEnabled();\n const sync = useRef<(() => void) | undefined>(undefined);\n useBrowserLayoutEffect(() => {\n const surface = surfaceRef.current;\n const content = contentRef.current;\n if (!open || !enabled || !surface || !content) return;\n let animation: Animation | undefined;\n let reveal: Animation | undefined;\n let lastHeight = surface.offsetHeight;\n let lastLayout = '';\n const parts = () =>\n Array.from(surface.children).filter(\n (child): child is HTMLElement => child instanceof HTMLElement && !child.contains(content),\n );\n const layout = () =>\n [surface.offsetWidth, content.offsetHeight, ...parts().map((part) => part.offsetHeight)].join(\n ':',\n );\n lastLayout = layout();\n const update = () => {\n const nextLayout = layout();\n if (nextLayout === lastLayout || surface.closest('[data-state=\"closing\"]')) return;\n lastLayout = nextLayout;\n // CSS height is unaffected by the separate entrance scale on the surface.\n const before =\n animation?.playState === 'running'\n ? Number.parseFloat(getComputedStyle(surface).height) || lastHeight\n : lastHeight;\n const opacity = reveal?.playState === 'running' ? getComputedStyle(content).opacity : '0.72';\n animation?.cancel();\n reveal?.cancel();\n const height = surface.offsetHeight;\n lastHeight = height;\n if (!before || !height || Math.abs(before - height) < 1) return;\n animation = animateMotion(surface, [{ height: `${before}px` }, { height: `${height}px` }], {\n durationMultiplier: 1.6,\n });\n if (animation)\n reveal = animateMotion(content, [{ opacity }, { opacity: 1 }], {\n durationMultiplier: 1.25,\n });\n };\n sync.current = update;\n let observer: ResizeObserver | undefined;\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(update);\n observer.observe(content);\n for (const part of parts()) observer.observe(part);\n }\n // Viewport constraints change the visible height without changing content.\n // Resizing establishes a fresh baseline instead of animating stale geometry.\n const resize = () => {\n animation?.cancel();\n reveal?.cancel();\n animation = undefined;\n reveal = undefined;\n lastHeight = surface.offsetHeight;\n lastLayout = layout();\n };\n window.addEventListener('resize', resize);\n window.visualViewport?.addEventListener('resize', resize);\n return () => {\n window.removeEventListener('resize', resize);\n window.visualViewport?.removeEventListener('resize', resize);\n observer?.disconnect();\n animation?.cancel();\n reveal?.cancel();\n sync.current = undefined;\n };\n }, [open, enabled, surfaceRef, contentRef]);\n // React updates to the header/footer are measurable before the next paint.\n useBrowserLayoutEffect(() => {\n sync.current?.();\n });\n}\n\n/** Animate a panel's explicit view change without remounting its focused controls. */\nexport function useContentTransition(\n ref: RefObject<HTMLElement | null>,\n view: string | number,\n direction = 0,\n layoutOnly = false,\n) {\n const enabled = useMotionEnabled();\n const travel = useRef(direction);\n travel.current = direction;\n const previous = useRef<{ view: string | number; height: number } | undefined>(undefined);\n useBrowserLayoutEffect(() => {\n const node = ref.current;\n if (!node) {\n previous.current = undefined;\n return;\n }\n const height = Number.parseFloat(getComputedStyle(node).height) || node.offsetHeight;\n const last = previous.current;\n previous.current = { view, height };\n if (!enabled || !last || last.view === view || node.closest('[data-state=\"closing\"]')) return;\n const changesHeight = last.height > 0 && height > 0 && Math.abs(last.height - height) > 1;\n if (layoutOnly && !changesHeight) return;\n const animation = animateMotion(\n node,\n [\n {\n ...(layoutOnly ? {} : { opacity: 0.45, translate: `${travel.current * 12}px 4px` }),\n ...(changesHeight ? { height: `${last.height}px`, overflow: 'clip' } : {}),\n },\n {\n ...(layoutOnly ? {} : { opacity: 1, translate: '0 0' }),\n ...(changesHeight ? { height: `${height}px`, overflow: 'clip' } : {}),\n },\n ],\n { durationMultiplier: 1.25 },\n );\n return () => {\n if (animation && changesHeight && previous.current)\n previous.current.height =\n Number.parseFloat(getComputedStyle(node).height) || node.offsetHeight;\n animation?.cancel();\n };\n }, [enabled, ref, view, layoutOnly]);\n}\n\n/** Keep a closing overlay mounted until its CSS transition or animation finishes. */\nexport function usePresence(open: boolean, ref: RefObject<HTMLElement | null>) {\n const enabled = useMotionEnabled();\n const [present, setPresent] = useState(open);\n if (open && !present) setPresent(true);\n useEffect(() => {\n if (open || !present) return;\n const node = ref.current;\n if (!node || !enabled) {\n setPresent(false);\n return;\n }\n const computed = getComputedStyle(node);\n const durations = [computed.animationDuration, computed.transitionDuration];\n const delays = [computed.animationDelay, computed.transitionDelay];\n const milliseconds = (value: string) => {\n const numeric = Number.parseFloat(value) || 0;\n return value.trim().endsWith('ms') ? numeric : numeric * 1000;\n };\n const duration = Math.max(\n 0,\n ...durations.flatMap((list, index) => {\n const delay = (delays[index] || '0s').split(',').map(milliseconds);\n return (list || '0s')\n .split(',')\n .map((value, i) => milliseconds(value) + (delay[i % delay.length] ?? 0));\n }),\n );\n const finish = () => setPresent(false);\n const ended = (event: Event) => {\n if (event.target === node && (!('propertyName' in event) || event.propertyName === 'opacity'))\n finish();\n };\n const timer = setTimeout(finish, duration ? duration + 32 : 0);\n node.addEventListener('animationend', ended);\n node.addEventListener('transitionend', ended);\n return () => {\n clearTimeout(timer);\n node.removeEventListener('animationend', ended);\n node.removeEventListener('transitionend', ended);\n };\n }, [open, present, ref, enabled]);\n return present;\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","useBrowserLayoutEffect","window","useEffect","useLayoutEffect","useNaturalHeightTransition","surfaceRef","contentRef","open","enabled","useMotionEnabled","sync","useRef","undefined","surface","content","animation","reveal","lastHeight","lastLayout","parts","Array","child","HTMLElement","layout","part","update","nextLayout","before","Number","getComputedStyle","opacity","height","Math","animateMotion","observer","ResizeObserver","resize","useContentTransition","ref","view","direction","layoutOnly","travel","previous","node","last","changesHeight","usePresence","present","setPresent","useState","computed","durations","delays","milliseconds","value","numeric","duration","list","index","delay","i","finish","ended","event","timer","setTimeout","clearTimeout"],"mappings":";;;;IAAAA,oBAAoB,CAAC,GAAG,C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AAME,SAAS;YAACF,SAAS,cAAc;YAAEA,SAAS,eAAe;SAAC;QAClE,MAAMG,eAAe,CAACC;YACpB,MAAMC,UAAU5B,OAAO,UAAU,CAAC2B,UAAU;YAC5C,OAAOA,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQC,UAAUA,AAAU,OAAVA;QACjD;QACA,MAAMC,WAAWzB,KAAK,GAAG,CACvB,MACGoB,UAAU,OAAO,CAAC,CAACM,MAAMC;YAC1B,MAAMC,QAASP,AAAAA,CAAAA,MAAM,CAACM,MAAM,IAAI,IAAG,EAAG,KAAK,CAAC,KAAK,GAAG,CAACL;YACrD,OAAQI,AAAAA,CAAAA,QAAQ,IAAG,EAChB,KAAK,CAAC,KACN,GAAG,CAAC,CAACH,OAAOM,IAAMP,aAAaC,SAAUK,CAAAA,KAAK,CAACC,IAAID,MAAM,MAAM,CAAC,IAAI;QACzE;QAEF,MAAME,SAAS,IAAMb,WAAW;QAChC,MAAMc,QAAQ,CAACC;YACb,IAAIA,MAAM,MAAM,KAAKpB,QAAS,EAAE,mBAAkBoB,KAAI,KAAMA,AAAuB,cAAvBA,MAAM,YAAY,AAAa,GACzFF;QACJ;QACA,MAAMG,QAAQC,WAAWJ,QAAQL,WAAWA,WAAW,KAAK;QAC5Db,KAAK,gBAAgB,CAAC,gBAAgBmB;QACtCnB,KAAK,gBAAgB,CAAC,iBAAiBmB;QACvC,OAAO;YACLI,aAAaF;YACbrB,KAAK,mBAAmB,CAAC,gBAAgBmB;YACzCnB,KAAK,mBAAmB,CAAC,iBAAiBmB;QAC5C;IACF,GAAG;QAACxD;QAAMyC;QAASV;QAAK9B;KAAQ;IAChC,OAAOwC;AACT"}
|
|
1
|
+
{"version":3,"file":"shared/presence.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../../../../../src/shared/presence.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type RefObject, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { animateMotion, useMotionEnabled } from './motion';\n\nconst useBrowserLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\n/** Interpolate natural dialog height, including state changes inside its children. */\nexport function useNaturalHeightTransition(\n surfaceRef: RefObject<HTMLElement | null>,\n contentRef: RefObject<HTMLElement | null>,\n open: boolean,\n) {\n const enabled = useMotionEnabled();\n const sync = useRef<(() => void) | undefined>(undefined);\n const snap = useRef<() => void>(() => {});\n useBrowserLayoutEffect(() => {\n const surface = surfaceRef.current;\n const content = contentRef.current;\n if (!open || !enabled || !surface || !content) return;\n let animation: Animation | undefined;\n let reveal: Animation | undefined;\n let lastHeight = surface.offsetHeight;\n let lastLayout = '';\n const parts = () =>\n Array.from(surface.children).filter(\n (child): child is HTMLElement => child instanceof HTMLElement && !child.contains(content),\n );\n const layout = () =>\n [surface.offsetWidth, content.offsetHeight, ...parts().map((part) => part.offsetHeight)].join(\n ':',\n );\n lastLayout = layout();\n const update = () => {\n const nextLayout = layout();\n if (nextLayout === lastLayout || surface.closest('[data-state=\"closing\"]')) return;\n lastLayout = nextLayout;\n // CSS height is unaffected by the separate entrance scale on the surface.\n const before =\n animation?.playState === 'running'\n ? Number.parseFloat(getComputedStyle(surface).height) || lastHeight\n : lastHeight;\n const opacity = reveal?.playState === 'running' ? getComputedStyle(content).opacity : '0.72';\n animation?.cancel();\n reveal?.cancel();\n const height = surface.offsetHeight;\n lastHeight = height;\n if (!before || !height || Math.abs(before - height) < 1) return;\n animation = animateMotion(surface, [{ height: `${before}px` }, { height: `${height}px` }], {\n durationMultiplier: 1.6,\n });\n if (animation)\n reveal = animateMotion(content, [{ opacity }, { opacity: 1 }], {\n durationMultiplier: 1.25,\n });\n };\n sync.current = update;\n // 切换标签页时立即刷新高度基线,避免触发容器高度缓动。\n snap.current = () => {\n animation?.cancel();\n reveal?.cancel();\n animation = undefined;\n reveal = undefined;\n lastHeight = surface.offsetHeight;\n lastLayout = layout();\n };\n let observer: ResizeObserver | undefined;\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(update);\n observer.observe(content);\n for (const part of parts()) observer.observe(part);\n }\n // Viewport constraints change the visible height without changing content.\n // Resizing establishes a fresh baseline instead of animating stale geometry.\n const resize = () => {\n snap.current();\n };\n window.addEventListener('resize', resize);\n window.visualViewport?.addEventListener('resize', resize);\n return () => {\n window.removeEventListener('resize', resize);\n window.visualViewport?.removeEventListener('resize', resize);\n observer?.disconnect();\n animation?.cancel();\n reveal?.cancel();\n sync.current = undefined;\n snap.current = () => {};\n };\n }, [open, enabled, surfaceRef, contentRef]);\n // React updates to the header/footer are measurable before the next paint.\n useBrowserLayoutEffect(() => {\n sync.current?.();\n });\n return useRef(() => snap.current()).current;\n}\n\n/** Animate a panel's explicit view change without remounting its focused controls. */\nexport function useContentTransition(\n ref: RefObject<HTMLElement | null>,\n view: string | number,\n direction = 0,\n layoutOnly = false,\n) {\n const enabled = useMotionEnabled();\n const travel = useRef(direction);\n travel.current = direction;\n const previous = useRef<{ view: string | number; height: number } | undefined>(undefined);\n useBrowserLayoutEffect(() => {\n const node = ref.current;\n if (!node) {\n previous.current = undefined;\n return;\n }\n const height = Number.parseFloat(getComputedStyle(node).height) || node.offsetHeight;\n const last = previous.current;\n previous.current = { view, height };\n if (!enabled || !last || last.view === view || node.closest('[data-state=\"closing\"]')) return;\n const changesHeight = last.height > 0 && height > 0 && Math.abs(last.height - height) > 1;\n if (layoutOnly && !changesHeight) return;\n const animation = animateMotion(\n node,\n [\n {\n ...(layoutOnly ? {} : { opacity: 0.45, translate: `${travel.current * 12}px 4px` }),\n ...(changesHeight ? { height: `${last.height}px`, overflow: 'clip' } : {}),\n },\n {\n ...(layoutOnly ? {} : { opacity: 1, translate: '0 0' }),\n ...(changesHeight ? { height: `${height}px`, overflow: 'clip' } : {}),\n },\n ],\n { durationMultiplier: 1.25 },\n );\n return () => {\n if (animation && changesHeight && previous.current)\n previous.current.height =\n Number.parseFloat(getComputedStyle(node).height) || node.offsetHeight;\n animation?.cancel();\n };\n }, [enabled, ref, view, layoutOnly]);\n}\n\n/** Keep a closing overlay mounted until its CSS transition or animation finishes. */\nexport function usePresence(open: boolean, ref: RefObject<HTMLElement | null>) {\n const enabled = useMotionEnabled();\n const [present, setPresent] = useState(open);\n if (open && !present) setPresent(true);\n useEffect(() => {\n if (open || !present) return;\n const node = ref.current;\n if (!node || !enabled) {\n setPresent(false);\n return;\n }\n const computed = getComputedStyle(node);\n const durations = [computed.animationDuration, computed.transitionDuration];\n const delays = [computed.animationDelay, computed.transitionDelay];\n const milliseconds = (value: string) => {\n const numeric = Number.parseFloat(value) || 0;\n return value.trim().endsWith('ms') ? numeric : numeric * 1000;\n };\n const duration = Math.max(\n 0,\n ...durations.flatMap((list, index) => {\n const delay = (delays[index] || '0s').split(',').map(milliseconds);\n return (list || '0s')\n .split(',')\n .map((value, i) => milliseconds(value) + (delay[i % delay.length] ?? 0));\n }),\n );\n const finish = () => setPresent(false);\n const ended = (event: Event) => {\n if (event.target === node && (!('propertyName' in event) || event.propertyName === 'opacity'))\n finish();\n };\n const timer = setTimeout(finish, duration ? duration + 32 : 0);\n node.addEventListener('animationend', ended);\n node.addEventListener('transitionend', ended);\n return () => {\n clearTimeout(timer);\n node.removeEventListener('animationend', ended);\n node.removeEventListener('transitionend', ended);\n };\n }, [open, present, ref, enabled]);\n return present;\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","useBrowserLayoutEffect","window","useEffect","useLayoutEffect","useNaturalHeightTransition","surfaceRef","contentRef","open","enabled","useMotionEnabled","sync","useRef","undefined","snap","surface","content","animation","reveal","lastHeight","lastLayout","parts","Array","child","HTMLElement","layout","part","update","nextLayout","before","Number","getComputedStyle","opacity","height","Math","animateMotion","observer","ResizeObserver","resize","useContentTransition","ref","view","direction","layoutOnly","travel","previous","node","last","changesHeight","usePresence","present","setPresent","useState","computed","durations","delays","milliseconds","value","numeric","duration","list","index","delay","i","finish","ended","event","timer","setTimeout","clearTimeout"],"mappings":";;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAF,oBAAoB,CAAC,GAAG,CAACQ,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFT,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOU,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;ACHA,MAAMI,yBAAyB,AAAkB,MAAlB,OAAOC,SAAyBC,+BAAAA,SAASA,GAAGC,+BAAAA,eAAeA;AAGnF,SAASC,2B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C,IAAID,MAAM,MAAM,CAAC,IAAI;QACzE;QAEF,MAAME,SAAS,IAAMb,WAAW;QAChC,MAAMc,QAAQ,CAACC;YACb,IAAIA,MAAM,MAAM,KAAKpB,QAAS,EAAE,mBAAkBoB,KAAI,KAAMA,AAAuB,cAAvBA,MAAM,YAAY,AAAa,GACzFF;QACJ;QACA,MAAMG,QAAQC,WAAWJ,QAAQL,WAAWA,WAAW,KAAK;QAC5Db,KAAK,gBAAgB,CAAC,gBAAgBmB;QACtCnB,KAAK,gBAAgB,CAAC,iBAAiBmB;QACvC,OAAO;YACLI,aAAaF;YACbrB,KAAK,mBAAmB,CAAC,gBAAgBmB;YACzCnB,KAAK,mBAAmB,CAAC,iBAAiBmB;QAC5C;IACF,GAAG;QAACzD;QAAM0C;QAASV;QAAK/B;KAAQ;IAChC,OAAOyC;AACT"}
|
|
@@ -61,6 +61,15 @@ function warnDevelopment(key, message) {
|
|
|
61
61
|
developmentWarnings.add(key);
|
|
62
62
|
console.warn(`Leaf UI: ${message}`);
|
|
63
63
|
}
|
|
64
|
+
const SELECTION_CONTENT_WIDTH = 34;
|
|
65
|
+
function resolvePx(value, fallback) {
|
|
66
|
+
if ('number' == typeof value) return Number.isFinite(value) && value >= 0 ? value : fallback;
|
|
67
|
+
if ('string' == typeof value) {
|
|
68
|
+
const match = /^\s*(?:0+(?:\.0+)?|(\d+(?:\.\d+)?)\s*px)\s*$/iu.exec(value);
|
|
69
|
+
if (match) return Number(match[1] ?? 0);
|
|
70
|
+
}
|
|
71
|
+
return fallback;
|
|
72
|
+
}
|
|
64
73
|
function hasSortingModel(table) {
|
|
65
74
|
return Boolean(table.options.getSortedRowModel || table.options.manualSorting);
|
|
66
75
|
}
|
|
@@ -548,6 +557,7 @@ function ordinaryRows(rows) {
|
|
|
548
557
|
function DataTableContentControl({ className, ...props }) {
|
|
549
558
|
const config = useDataTableContext();
|
|
550
559
|
const { table, tableRef, loading, error, emptyContent, onRetry, selection, resizable, virtual } = config;
|
|
560
|
+
const { theme } = (0, context_cjs_namespaceObject.useLeafConfig)();
|
|
551
561
|
const t = (0, use_text_cjs_namespaceObject.useText)();
|
|
552
562
|
const viewport = (0, external_react_namespaceObject.useRef)(null);
|
|
553
563
|
const [availableWidth, setAvailableWidth] = (0, external_react_namespaceObject.useState)(0);
|
|
@@ -579,10 +589,12 @@ function DataTableContentControl({ className, ...props }) {
|
|
|
579
589
|
const expandable = config.expandable && !config.renderRowHeader;
|
|
580
590
|
const utilityCount = Number(Boolean(selection)) + Number(expandable);
|
|
581
591
|
const colSpan = Math.max(1, columns.length + utilityCount);
|
|
592
|
+
const selectionBorderWidth = config.bordered ? resolvePx(theme.components?.Table?.borderWidth ?? theme.tokens?.borderWidth, 1) : 0;
|
|
593
|
+
const selectionWidth = SELECTION_CONTENT_WIDTH + selectionBorderWidth;
|
|
582
594
|
const layout = (0, external_column_sizing_cjs_namespaceObject.getColumnLayout)(table, columns, {
|
|
583
595
|
forceFixed: Boolean(resizable || virtual || columns.some((column)=>column.getIsPinned())),
|
|
584
596
|
availableWidth,
|
|
585
|
-
utilityWidth: (selection ?
|
|
597
|
+
utilityWidth: (selection ? selectionWidth : 0) + (expandable ? 48 : 0)
|
|
586
598
|
});
|
|
587
599
|
const status = null != error && false !== error ? 'error' : rows.length && columns.length ? null : loading ? 'loading' : 'empty';
|
|
588
600
|
const expanded = table.getState().expanded;
|
|
@@ -646,7 +658,7 @@ function DataTableContentControl({ className, ...props }) {
|
|
|
646
658
|
children: [
|
|
647
659
|
selection && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("col", {
|
|
648
660
|
style: {
|
|
649
|
-
width:
|
|
661
|
+
width: config.bordered ? `calc(${SELECTION_CONTENT_WIDTH}px + var(--leaf-table-border-width))` : SELECTION_CONTENT_WIDTH
|
|
650
662
|
}
|
|
651
663
|
}),
|
|
652
664
|
expandable && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("col", {
|