@lobehub/ui 6.0.0-beta.9 → 6.0.1
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/README.md +3 -3
- package/es/Accordion/style.d.mts +1 -1
- package/es/CodeDiff/DiffPanel.mjs +2 -2
- package/es/CodeDiff/DiffPanel.mjs.map +1 -1
- package/es/Drawer/atoms.mjs +2 -1
- package/es/Drawer/atoms.mjs.map +1 -1
- package/es/Drawer/style.mjs.map +1 -1
- package/es/DropdownMenu/atoms.mjs +2 -1
- package/es/DropdownMenu/atoms.mjs.map +1 -1
- package/es/FloatingPanel/style.mjs +3 -2
- package/es/FloatingPanel/style.mjs.map +1 -1
- package/es/Form/Form.mjs +6 -2
- package/es/Form/Form.mjs.map +1 -1
- package/es/Form/style.mjs +3 -3
- package/es/Form/style.mjs.map +1 -1
- package/es/Form/type.d.mts +7 -0
- package/es/Modal/atoms.mjs +2 -1
- package/es/Modal/atoms.mjs.map +1 -1
- package/es/Popover/PopoverInGroup.mjs +2 -1
- package/es/Popover/PopoverInGroup.mjs.map +1 -1
- package/es/Popover/atoms.mjs +2 -1
- package/es/Popover/atoms.mjs.map +1 -1
- package/es/Popover/style.mjs +1 -1
- package/es/Popover/style.mjs.map +1 -1
- package/es/ProTable/hooks/useFetchData.mjs +1 -1
- package/es/ProTable/hooks/useFetchData.mjs.map +1 -1
- package/es/ProTable/parts/FieldControl.mjs +28 -11
- package/es/ProTable/parts/FieldControl.mjs.map +1 -1
- package/es/ProTable/style.mjs +9 -0
- package/es/ProTable/style.mjs.map +1 -1
- package/es/ProTable/type.d.mts +5 -2
- package/es/Segmented/Segmented.mjs +2 -1
- package/es/Segmented/Segmented.mjs.map +1 -1
- package/es/Segmented/type.d.mts +7 -0
- package/es/Select/atoms.mjs +2 -1
- package/es/Select/atoms.mjs.map +1 -1
- package/es/Switch/Switch.mjs +8 -1
- package/es/Switch/Switch.mjs.map +1 -1
- package/es/Switch/atoms.d.mts +7 -1
- package/es/Switch/atoms.mjs +20 -4
- package/es/Switch/atoms.mjs.map +1 -1
- package/es/Switch/style.mjs +33 -2
- package/es/Switch/style.mjs.map +1 -1
- package/es/Table/Table.mjs +14 -5
- package/es/Table/Table.mjs.map +1 -1
- package/es/Table/render/FixedFrost.mjs +11 -2
- package/es/Table/render/FixedFrost.mjs.map +1 -1
- package/es/Table/style.mjs +4 -0
- package/es/Table/style.mjs.map +1 -1
- package/es/Toast/dodge.mjs +0 -1
- package/es/Toast/dodge.mjs.map +1 -1
- package/es/Toast/dodge.stylex.mjs +1 -4
- package/es/Toast/dodge.stylex.mjs.map +1 -1
- package/es/Toast/style.mjs +1 -1
- package/es/Toast/style.mjs.map +1 -1
- package/es/Tooltip/TooltipInGroup.mjs +2 -1
- package/es/Tooltip/TooltipInGroup.mjs.map +1 -1
- package/es/Tooltip/TooltipStandalone.mjs +2 -1
- package/es/Tooltip/TooltipStandalone.mjs.map +1 -1
- package/es/Tooltip/style.mjs +2 -2
- package/es/Tooltip/style.mjs.map +1 -1
- package/es/color/index.d.mts +2 -1
- package/es/color/index.mjs +2 -1
- package/es/color/status/error.mjs +67 -0
- package/es/color/status/error.mjs.map +1 -0
- package/es/color/status/index.d.mts +11 -0
- package/es/color/status/index.mjs +15 -0
- package/es/color/status/index.mjs.map +1 -0
- package/es/color/status/info.mjs +67 -0
- package/es/color/status/info.mjs.map +1 -0
- package/es/color/status/success.mjs +67 -0
- package/es/color/status/success.mjs.map +1 -0
- package/es/color/status/warning.mjs +67 -0
- package/es/color/status/warning.mjs.map +1 -0
- package/es/hooks/useNativeButton.mjs +1 -0
- package/es/hooks/useNativeButton.mjs.map +1 -1
- package/es/index.d.mts +4 -2
- package/es/index.mjs +4 -2
- package/es/style.css +114 -23
- package/es/styles/index.d.mts +4 -2
- package/es/styles/index.mjs +4 -2
- package/es/styles/stylex/cssVar.stylex.mjs +3 -0
- package/es/styles/stylex/cssVar.stylex.mjs.map +1 -1
- package/es/styles/theme/createLobeToken.d.mts +11 -7
- package/es/styles/theme/createLobeToken.mjs +3 -2
- package/es/styles/theme/createLobeToken.mjs.map +1 -1
- package/es/styles/theme/customNeutral.d.mts +28 -0
- package/es/styles/theme/customNeutral.mjs +84 -0
- package/es/styles/theme/customNeutral.mjs.map +1 -0
- package/es/styles/theme/customPalette.d.mts +6 -0
- package/es/styles/theme/customPalette.mjs +32 -0
- package/es/styles/theme/customPalette.mjs.map +1 -0
- package/es/styles/theme/customPrimary.mjs +52 -17
- package/es/styles/theme/customPrimary.mjs.map +1 -1
- package/es/styles/theme/scope.d.mts +7 -5
- package/es/styles/theme/scope.mjs +105 -22
- package/es/styles/theme/scope.mjs.map +1 -1
- package/es/styles/theme/themeCss.d.mts +3 -0
- package/es/styles/theme/themeCss.mjs +46 -1
- package/es/styles/theme/themeCss.mjs.map +1 -1
- package/es/styles/theme/token/legacy.mjs +12 -12
- package/es/styles/theme/token/legacy.mjs.map +1 -1
- package/es/styles/theme/token/neutral.mjs +13 -7
- package/es/styles/theme/token/neutral.mjs.map +1 -1
- package/es/styles/theme/token/neutralText.d.mts +4 -0
- package/es/styles/theme/token/neutralText.mjs +91 -0
- package/es/styles/theme/token/neutralText.mjs.map +1 -0
- package/es/styles/theme/token/palette.mjs +16 -41
- package/es/styles/theme/token/palette.mjs.map +1 -1
- package/es/styles/theme/token/static.mjs +3 -0
- package/es/styles/theme/token/static.mjs.map +1 -1
- package/es/theme.css +293 -290
- package/es/utils/getElementRef.mjs +17 -0
- package/es/utils/getElementRef.mjs.map +1 -0
- package/package.json +1 -1
package/es/Form/type.d.mts
CHANGED
|
@@ -24,6 +24,11 @@ export interface FormProps extends BaseFormProps {
|
|
|
24
24
|
item?: string;
|
|
25
25
|
};
|
|
26
26
|
collapsible?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Compact spacing for narrow containers (Drawer / Modal): `gap` 12px and `itemPadding` 10px
|
|
29
|
+
* unless set explicitly. Default `false` (unchanged spacing).
|
|
30
|
+
*/
|
|
31
|
+
compact?: boolean;
|
|
27
32
|
defaultActiveKey?: (string | number)[];
|
|
28
33
|
footer?: ReactNode;
|
|
29
34
|
gap?: number | string;
|
|
@@ -33,6 +38,8 @@ export interface FormProps extends BaseFormProps {
|
|
|
33
38
|
*/
|
|
34
39
|
initialValues?: FormValues;
|
|
35
40
|
itemMinWidth?: FormFieldProps['minWidth'];
|
|
41
|
+
/** Block (top / bottom) padding of every Form.Field. Default `16px`. */
|
|
42
|
+
itemPadding?: number | string;
|
|
36
43
|
items?: FormGroupItemType[] | FormFieldProps[];
|
|
37
44
|
itemsType?: ItemsType;
|
|
38
45
|
layout?: FormLayout;
|
package/es/Modal/atoms.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { useAppElement } from "../ConfigProvider/AppElementContext.mjs";
|
|
|
4
4
|
import { styleProps } from "../styles/stylex/props.mjs";
|
|
5
5
|
import { focusRing } from "../styles/stylex/focusRing.mjs";
|
|
6
6
|
import { useNativeButton } from "../hooks/useNativeButton.mjs";
|
|
7
|
+
import { getElementRef } from "../utils/getElementRef.mjs";
|
|
7
8
|
import { mergeRefs, useMergeRefs } from "../utils/mergeRefs.mjs";
|
|
8
9
|
import { useLayerZIndex } from "../internal/zIndex/useLayerZIndex.mjs";
|
|
9
10
|
import { backdropTransition, modalMotionConfig } from "./constants.mjs";
|
|
@@ -216,7 +217,7 @@ const ModalTrigger = ({ children, className, nativeButton, ref: refProp, ...rest
|
|
|
216
217
|
return cloneElement(children, {
|
|
217
218
|
...mergedProps,
|
|
218
219
|
ref: mergeRefs([
|
|
219
|
-
children
|
|
220
|
+
getElementRef(children),
|
|
220
221
|
props.ref,
|
|
221
222
|
refProp
|
|
222
223
|
])
|
package/es/Modal/atoms.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atoms.mjs","names":["clsx"],"sources":["../../src/Modal/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Dialog } from '@base-ui/react/dialog';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport * as stylex from '@stylexjs/stylex';\nimport clsx from 'clsx';\nimport { X } from 'lucide-react';\nimport { AnimatePresence } from 'motion/react';\nimport type React from 'react';\nimport {\n cloneElement,\n createContext,\n isValidElement,\n use,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport { useAppElement } from '@/ConfigProvider/AppElementContext';\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { useMotionComponent } from '@/MotionProvider';\nimport { focusRing } from '@/styles/stylex/focusRing';\nimport { styleProps } from '@/styles/stylex/props';\nimport { mergeRefs, useMergeRefs } from '@/utils/mergeRefs';\n\nimport { useLayerZIndex } from '../internal/zIndex';\nimport { backdropTransition, modalMotionConfig } from './constants';\nimport { ModalLayerProvider, useModalLayer } from './ModalLayerContext';\nimport { styles } from './style';\n\ntype XStyle = Parameters<typeof styleProps>[0];\n\nconst mergeStateClassName = <TState,>(\n xstyle: XStyle,\n className: string | ((state: TState) => string | undefined) | undefined,\n) => {\n const base = stylex.props(xstyle).className;\n if (typeof className === 'function') return (state: TState) => clsx(base, className(state));\n return clsx(base, className);\n};\n\n// --- Animation Contexts (granular to minimize re-renders) ---\n\n// State: open boolean, null = non-animated mode\nconst ModalOpenContext = createContext<boolean | null>(null);\n\n// Actions: stable callbacks, null = non-animated mode\ninterface ModalAnimationActions {\n onExitComplete: () => void;\n}\nconst ModalActionsContext = createContext<ModalAnimationActions | null>(null);\n\nexport const useModalOpen = () => use(ModalOpenContext);\nexport const useModalActions = () => use(ModalActionsContext);\n\n// --- Root ---\nexport type ModalRootProps = Dialog.Root.Props & {\n onExitComplete?: () => void;\n zIndex?: number;\n};\n\nconst AnimatedModalRoot = ({\n open,\n children,\n onExitComplete: onExitCompleteProp,\n zIndex: explicitZIndex,\n ...rest\n}: Omit<ModalRootProps, 'open'> & { open: boolean }) => {\n const [isPresent, setIsPresent] = useState(!!open);\n\n useEffect(() => {\n if (open) setIsPresent(true);\n }, [open]);\n\n const handleExitComplete = useCallback(() => {\n setIsPresent(false);\n onExitCompleteProp?.();\n }, [onExitCompleteProp]);\n\n const actions = useMemo(() => ({ onExitComplete: handleExitComplete }), [handleExitComplete]);\n\n const { zIndex, ref: popupRef } = useLayerZIndex<HTMLDivElement>('modal', explicitZIndex);\n const layer = useMemo(\n () => ({ popupRef: popupRef as (node: HTMLElement | null) => void, zIndex }),\n [zIndex, popupRef],\n );\n\n if (!isPresent) return null;\n\n return (\n <ModalOpenContext value={open}>\n <ModalActionsContext value={actions}>\n <ModalLayerProvider value={layer}>\n <Dialog.Root modal open {...rest}>\n {children}\n </Dialog.Root>\n </ModalLayerProvider>\n </ModalActionsContext>\n </ModalOpenContext>\n );\n};\n\nconst NonAnimatedModalRoot = ({ zIndex: explicitZIndex, children, ...rest }: ModalRootProps) => {\n const { zIndex, ref: popupRef } = useLayerZIndex<HTMLDivElement>('modal', explicitZIndex);\n const layer = useMemo(\n () => ({ popupRef: popupRef as (node: HTMLElement | null) => void, zIndex }),\n [zIndex, popupRef],\n );\n return (\n <ModalLayerProvider value={layer}>\n <Dialog.Root modal {...rest}>\n {children}\n </Dialog.Root>\n </ModalLayerProvider>\n );\n};\n\nexport const ModalRoot = ({ open, onExitComplete, ...rest }: ModalRootProps) => {\n if (open !== undefined) {\n return <AnimatedModalRoot open={open} onExitComplete={onExitComplete} {...rest} />;\n }\n return <NonAnimatedModalRoot {...rest} />;\n};\n\n// --- Portal ---\nexport type ModalPortalProps = React.ComponentProps<typeof Dialog.Portal> & {\n container?: HTMLElement | null;\n};\nexport const ModalPortal = ({ container, ...rest }: ModalPortalProps) => {\n const appElement = useAppElement();\n return <Dialog.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\n\n// --- Viewport ---\nexport type ModalViewportProps = React.ComponentProps<typeof Dialog.Viewport>;\nexport const ModalViewport = ({ className, ...rest }: ModalViewportProps) => (\n <Dialog.Viewport\n {...rest}\n className={mergeStateClassName(styles.viewport, className as any) as any}\n />\n);\n\n// --- Backdrop ---\nexport type ModalBackdropProps = React.ComponentProps<typeof Dialog.Backdrop>;\nexport const ModalBackdrop = ({ className, style, ...rest }: ModalBackdropProps) => {\n const open = useModalOpen();\n const layer = useModalLayer();\n const Motion = useMotionComponent();\n const layerStyle = layer?.zIndex !== undefined ? { zIndex: layer.zIndex } : undefined;\n\n if (open !== null) {\n return (\n <Dialog.Backdrop\n {...rest}\n className={clsx(stylex.props(styles.backdrop).className, className as string)}\n style={{ ...layerStyle, ...style, transition: 'none' }}\n render={\n <Motion.div\n animate={{ opacity: open ? 1 : 0 }}\n initial={{ opacity: 0 }}\n transition={backdropTransition}\n />\n }\n />\n );\n }\n\n return (\n <Dialog.Backdrop\n {...rest}\n className={mergeStateClassName(styles.backdrop, className as any) as any}\n style={{ ...layerStyle, ...style }}\n />\n );\n};\n\n// --- Popup ---\nexport type ModalPopupProps = React.ComponentProps<typeof Dialog.Popup> & {\n motionProps?: Record<string, any>;\n panelClassName?: string;\n popupStyle?: React.CSSProperties;\n width?: number | string;\n};\nexport const ModalPopupImpl = ({\n className,\n children,\n width,\n style,\n motionProps,\n panelClassName,\n panelXstyle,\n popupStyle,\n ref: forwardedRef,\n xstyle,\n ...rest\n}: ModalPopupProps & { panelXstyle?: XStyle; xstyle?: XStyle }) => {\n const open = useModalOpen();\n const actions = useModalActions();\n const layer = useModalLayer();\n const Motion = useMotionComponent();\n const popupZIndexStyle = layer?.zIndex !== undefined ? { zIndex: layer.zIndex + 1 } : undefined;\n const composedRef = useMergeRefs([forwardedRef, layer?.popupRef]);\n\n if (open !== null && actions) {\n return (\n <Dialog.Popup\n {...rest}\n className={clsx(stylex.props(styles.popup, xstyle).className, className as string)}\n ref={composedRef as any}\n style={{ ...popupZIndexStyle, ...popupStyle }}\n >\n <AnimatePresence onExitComplete={actions.onExitComplete}>\n {open ? (\n <Motion.div\n {...modalMotionConfig}\n {...motionProps}\n key=\"modal-popup-panel\"\n style={{ maxWidth: width ?? undefined, transition: 'none', ...style }}\n className={clsx(\n stylex.props(styles.popupInner, panelXstyle).className,\n panelClassName,\n )}\n >\n {children}\n </Motion.div>\n ) : null}\n </AnimatePresence>\n </Dialog.Popup>\n );\n }\n\n return (\n <Dialog.Popup\n {...rest}\n className={mergeStateClassName([styles.popup, xstyle], className as any) as any}\n ref={composedRef as any}\n style={{ ...popupZIndexStyle, ...popupStyle }}\n >\n <div\n {...styleProps([styles.popupInner, panelXstyle], panelClassName, {\n maxWidth: width ?? undefined,\n ...style,\n })}\n >\n {children}\n </div>\n </Dialog.Popup>\n );\n};\n\nexport const ModalPopup: React.FC<ModalPopupProps> = ModalPopupImpl;\n\n// --- Header ---\nexport type ModalHeaderProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalHeaderImpl = ({\n className,\n style,\n xstyle,\n ...rest\n}: ModalHeaderProps & { xstyle?: XStyle }) => (\n <div {...rest} {...styleProps([styles.header, xstyle], className, style)} />\n);\nexport const ModalHeader: React.FC<ModalHeaderProps> = ModalHeaderImpl;\n\n// --- Title ---\nexport type ModalTitleProps = React.ComponentProps<typeof Dialog.Title>;\nexport const ModalTitleImpl = ({\n className,\n xstyle,\n ...rest\n}: ModalTitleProps & { xstyle?: XStyle }) => (\n <Dialog.Title\n {...rest}\n className={mergeStateClassName([styles.title, xstyle], className as any) as any}\n />\n);\nexport const ModalTitle: React.FC<ModalTitleProps> = ModalTitleImpl;\n\n// --- Description ---\nexport type ModalDescriptionProps = React.ComponentProps<typeof Dialog.Description>;\nexport const ModalDescription: React.FC<ModalDescriptionProps> = Dialog.Description;\n\n// --- Content ---\nexport type ModalContentProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalContentImpl = ({\n className,\n style,\n xstyle,\n ...rest\n}: ModalContentProps & { xstyle?: XStyle }) => (\n <div {...rest} {...styleProps([styles.content, xstyle], className, style)} />\n);\nexport const ModalContent: React.FC<ModalContentProps> = ModalContentImpl;\n\n// --- Footer ---\nexport type ModalFooterProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalFooterImpl = ({\n className,\n style,\n xstyle,\n ...rest\n}: ModalFooterProps & { xstyle?: XStyle }) => (\n <div {...rest} {...styleProps([styles.footer, xstyle], className, style)} />\n);\nexport const ModalFooter: React.FC<ModalFooterProps> = ModalFooterImpl;\n\n// --- Close ---\nexport type ModalCloseProps = React.ComponentProps<typeof Dialog.Close>;\nexport const ModalCloseImpl = ({\n className,\n children,\n xstyle,\n ...rest\n}: ModalCloseProps & { xstyle?: XStyle }) => (\n <Dialog.Close\n {...rest}\n className={\n mergeStateClassName(\n [styles.closeInline, styles.close, focusRing.info, xstyle],\n className as any,\n ) as any\n }\n >\n {children ?? <X size={16} />}\n </Dialog.Close>\n);\nexport const ModalClose: React.FC<ModalCloseProps> = ModalCloseImpl;\n\n// --- Trigger ---\nexport type ModalTriggerProps = Omit<\n React.ComponentPropsWithRef<typeof Dialog.Trigger>,\n 'children' | 'render'\n> & {\n children?: React.ReactNode;\n nativeButton?: boolean;\n};\n\nexport const ModalTrigger = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: ModalTriggerProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n const renderer = (props: any) => {\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return props as any;\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { type, ...restProps } = props as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n return cloneElement(children as any, {\n ...mergedProps,\n ref: mergeRefs([(children as any).ref, (props as any).ref, refProp]),\n });\n };\n\n if (isValidElement(children)) {\n return (\n <Dialog.Trigger\n {...rest}\n className={className}\n nativeButton={resolvedNativeButton}\n render={renderer as any}\n />\n );\n }\n\n return (\n <Dialog.Trigger\n {...rest}\n className={className}\n nativeButton={resolvedNativeButton}\n ref={refProp as any}\n >\n {children}\n </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YAAY,UAAe;EAC/B,MAAM,uBAAuB;GAC3B,IAAI,8BAA8B,OAAO;GAEzC,MAAM,EACJ,MACA,GAAG,cACD;GACJ,OAAO;EACT,EAAA,CAAG;EACH,MAAM,cAAc,WAAY,SAAiB,OAAO,aAAa;EACrE,OAAO,aAAa,UAAiB;GACnC,GAAG;GACH,KAAK,UAAU;IAAE,SAAiB;IAAM,MAAc;IAAK;GAAO,CAAC;EACrE,CAAC;CACH;CACA,IAAI,eAAe,QAAQ,GACzB,OAAO,oBAAC,OAAO,SAAR;EAAgB,GAAI;EAAiB;EAAW,cAAc;EAAsB,QAAQ;CAAkB,CAAA;CAEvH,OAAO,oBAAC,OAAO,SAAR;EAAgB,GAAI;EAAiB;EAAW,cAAc;EAAsB,KAAK;EAC3F;CACa,CAAA;AACpB"}
|
|
1
|
+
{"version":3,"file":"atoms.mjs","names":["clsx"],"sources":["../../src/Modal/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Dialog } from '@base-ui/react/dialog';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport * as stylex from '@stylexjs/stylex';\nimport clsx from 'clsx';\nimport { X } from 'lucide-react';\nimport { AnimatePresence } from 'motion/react';\nimport type React from 'react';\nimport {\n cloneElement,\n createContext,\n isValidElement,\n use,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport { useAppElement } from '@/ConfigProvider/AppElementContext';\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { useMotionComponent } from '@/MotionProvider';\nimport { focusRing } from '@/styles/stylex/focusRing';\nimport { styleProps } from '@/styles/stylex/props';\nimport { getElementRef } from '@/utils/getElementRef';\nimport { mergeRefs, useMergeRefs } from '@/utils/mergeRefs';\n\nimport { useLayerZIndex } from '../internal/zIndex';\nimport { backdropTransition, modalMotionConfig } from './constants';\nimport { ModalLayerProvider, useModalLayer } from './ModalLayerContext';\nimport { styles } from './style';\n\ntype XStyle = Parameters<typeof styleProps>[0];\n\nconst mergeStateClassName = <TState,>(\n xstyle: XStyle,\n className: string | ((state: TState) => string | undefined) | undefined,\n) => {\n const base = stylex.props(xstyle).className;\n if (typeof className === 'function') return (state: TState) => clsx(base, className(state));\n return clsx(base, className);\n};\n\n// --- Animation Contexts (granular to minimize re-renders) ---\n\n// State: open boolean, null = non-animated mode\nconst ModalOpenContext = createContext<boolean | null>(null);\n\n// Actions: stable callbacks, null = non-animated mode\ninterface ModalAnimationActions {\n onExitComplete: () => void;\n}\nconst ModalActionsContext = createContext<ModalAnimationActions | null>(null);\n\nexport const useModalOpen = () => use(ModalOpenContext);\nexport const useModalActions = () => use(ModalActionsContext);\n\n// --- Root ---\nexport type ModalRootProps = Dialog.Root.Props & {\n onExitComplete?: () => void;\n zIndex?: number;\n};\n\nconst AnimatedModalRoot = ({\n open,\n children,\n onExitComplete: onExitCompleteProp,\n zIndex: explicitZIndex,\n ...rest\n}: Omit<ModalRootProps, 'open'> & { open: boolean }) => {\n const [isPresent, setIsPresent] = useState(!!open);\n\n useEffect(() => {\n if (open) setIsPresent(true);\n }, [open]);\n\n const handleExitComplete = useCallback(() => {\n setIsPresent(false);\n onExitCompleteProp?.();\n }, [onExitCompleteProp]);\n\n const actions = useMemo(() => ({ onExitComplete: handleExitComplete }), [handleExitComplete]);\n\n const { zIndex, ref: popupRef } = useLayerZIndex<HTMLDivElement>('modal', explicitZIndex);\n const layer = useMemo(\n () => ({ popupRef: popupRef as (node: HTMLElement | null) => void, zIndex }),\n [zIndex, popupRef],\n );\n\n if (!isPresent) return null;\n\n return (\n <ModalOpenContext value={open}>\n <ModalActionsContext value={actions}>\n <ModalLayerProvider value={layer}>\n <Dialog.Root modal open {...rest}>\n {children}\n </Dialog.Root>\n </ModalLayerProvider>\n </ModalActionsContext>\n </ModalOpenContext>\n );\n};\n\nconst NonAnimatedModalRoot = ({ zIndex: explicitZIndex, children, ...rest }: ModalRootProps) => {\n const { zIndex, ref: popupRef } = useLayerZIndex<HTMLDivElement>('modal', explicitZIndex);\n const layer = useMemo(\n () => ({ popupRef: popupRef as (node: HTMLElement | null) => void, zIndex }),\n [zIndex, popupRef],\n );\n return (\n <ModalLayerProvider value={layer}>\n <Dialog.Root modal {...rest}>\n {children}\n </Dialog.Root>\n </ModalLayerProvider>\n );\n};\n\nexport const ModalRoot = ({ open, onExitComplete, ...rest }: ModalRootProps) => {\n if (open !== undefined) {\n return <AnimatedModalRoot open={open} onExitComplete={onExitComplete} {...rest} />;\n }\n return <NonAnimatedModalRoot {...rest} />;\n};\n\n// --- Portal ---\nexport type ModalPortalProps = React.ComponentProps<typeof Dialog.Portal> & {\n container?: HTMLElement | null;\n};\nexport const ModalPortal = ({ container, ...rest }: ModalPortalProps) => {\n const appElement = useAppElement();\n return <Dialog.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\n\n// --- Viewport ---\nexport type ModalViewportProps = React.ComponentProps<typeof Dialog.Viewport>;\nexport const ModalViewport = ({ className, ...rest }: ModalViewportProps) => (\n <Dialog.Viewport\n {...rest}\n className={mergeStateClassName(styles.viewport, className as any) as any}\n />\n);\n\n// --- Backdrop ---\nexport type ModalBackdropProps = React.ComponentProps<typeof Dialog.Backdrop>;\nexport const ModalBackdrop = ({ className, style, ...rest }: ModalBackdropProps) => {\n const open = useModalOpen();\n const layer = useModalLayer();\n const Motion = useMotionComponent();\n const layerStyle = layer?.zIndex !== undefined ? { zIndex: layer.zIndex } : undefined;\n\n if (open !== null) {\n return (\n <Dialog.Backdrop\n {...rest}\n className={clsx(stylex.props(styles.backdrop).className, className as string)}\n style={{ ...layerStyle, ...style, transition: 'none' }}\n render={\n <Motion.div\n animate={{ opacity: open ? 1 : 0 }}\n initial={{ opacity: 0 }}\n transition={backdropTransition}\n />\n }\n />\n );\n }\n\n return (\n <Dialog.Backdrop\n {...rest}\n className={mergeStateClassName(styles.backdrop, className as any) as any}\n style={{ ...layerStyle, ...style }}\n />\n );\n};\n\n// --- Popup ---\nexport type ModalPopupProps = React.ComponentProps<typeof Dialog.Popup> & {\n motionProps?: Record<string, any>;\n panelClassName?: string;\n popupStyle?: React.CSSProperties;\n width?: number | string;\n};\nexport const ModalPopupImpl = ({\n className,\n children,\n width,\n style,\n motionProps,\n panelClassName,\n panelXstyle,\n popupStyle,\n ref: forwardedRef,\n xstyle,\n ...rest\n}: ModalPopupProps & { panelXstyle?: XStyle; xstyle?: XStyle }) => {\n const open = useModalOpen();\n const actions = useModalActions();\n const layer = useModalLayer();\n const Motion = useMotionComponent();\n const popupZIndexStyle = layer?.zIndex !== undefined ? { zIndex: layer.zIndex + 1 } : undefined;\n const composedRef = useMergeRefs([forwardedRef, layer?.popupRef]);\n\n if (open !== null && actions) {\n return (\n <Dialog.Popup\n {...rest}\n className={clsx(stylex.props(styles.popup, xstyle).className, className as string)}\n ref={composedRef as any}\n style={{ ...popupZIndexStyle, ...popupStyle }}\n >\n <AnimatePresence onExitComplete={actions.onExitComplete}>\n {open ? (\n <Motion.div\n {...modalMotionConfig}\n {...motionProps}\n key=\"modal-popup-panel\"\n style={{ maxWidth: width ?? undefined, transition: 'none', ...style }}\n className={clsx(\n stylex.props(styles.popupInner, panelXstyle).className,\n panelClassName,\n )}\n >\n {children}\n </Motion.div>\n ) : null}\n </AnimatePresence>\n </Dialog.Popup>\n );\n }\n\n return (\n <Dialog.Popup\n {...rest}\n className={mergeStateClassName([styles.popup, xstyle], className as any) as any}\n ref={composedRef as any}\n style={{ ...popupZIndexStyle, ...popupStyle }}\n >\n <div\n {...styleProps([styles.popupInner, panelXstyle], panelClassName, {\n maxWidth: width ?? undefined,\n ...style,\n })}\n >\n {children}\n </div>\n </Dialog.Popup>\n );\n};\n\nexport const ModalPopup: React.FC<ModalPopupProps> = ModalPopupImpl;\n\n// --- Header ---\nexport type ModalHeaderProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalHeaderImpl = ({\n className,\n style,\n xstyle,\n ...rest\n}: ModalHeaderProps & { xstyle?: XStyle }) => (\n <div {...rest} {...styleProps([styles.header, xstyle], className, style)} />\n);\nexport const ModalHeader: React.FC<ModalHeaderProps> = ModalHeaderImpl;\n\n// --- Title ---\nexport type ModalTitleProps = React.ComponentProps<typeof Dialog.Title>;\nexport const ModalTitleImpl = ({\n className,\n xstyle,\n ...rest\n}: ModalTitleProps & { xstyle?: XStyle }) => (\n <Dialog.Title\n {...rest}\n className={mergeStateClassName([styles.title, xstyle], className as any) as any}\n />\n);\nexport const ModalTitle: React.FC<ModalTitleProps> = ModalTitleImpl;\n\n// --- Description ---\nexport type ModalDescriptionProps = React.ComponentProps<typeof Dialog.Description>;\nexport const ModalDescription: React.FC<ModalDescriptionProps> = Dialog.Description;\n\n// --- Content ---\nexport type ModalContentProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalContentImpl = ({\n className,\n style,\n xstyle,\n ...rest\n}: ModalContentProps & { xstyle?: XStyle }) => (\n <div {...rest} {...styleProps([styles.content, xstyle], className, style)} />\n);\nexport const ModalContent: React.FC<ModalContentProps> = ModalContentImpl;\n\n// --- Footer ---\nexport type ModalFooterProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalFooterImpl = ({\n className,\n style,\n xstyle,\n ...rest\n}: ModalFooterProps & { xstyle?: XStyle }) => (\n <div {...rest} {...styleProps([styles.footer, xstyle], className, style)} />\n);\nexport const ModalFooter: React.FC<ModalFooterProps> = ModalFooterImpl;\n\n// --- Close ---\nexport type ModalCloseProps = React.ComponentProps<typeof Dialog.Close>;\nexport const ModalCloseImpl = ({\n className,\n children,\n xstyle,\n ...rest\n}: ModalCloseProps & { xstyle?: XStyle }) => (\n <Dialog.Close\n {...rest}\n className={\n mergeStateClassName(\n [styles.closeInline, styles.close, focusRing.info, xstyle],\n className as any,\n ) as any\n }\n >\n {children ?? <X size={16} />}\n </Dialog.Close>\n);\nexport const ModalClose: React.FC<ModalCloseProps> = ModalCloseImpl;\n\n// --- Trigger ---\nexport type ModalTriggerProps = Omit<\n React.ComponentPropsWithRef<typeof Dialog.Trigger>,\n 'children' | 'render'\n> & {\n children?: React.ReactNode;\n nativeButton?: boolean;\n};\n\nexport const ModalTrigger = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: ModalTriggerProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n const renderer = (props: any) => {\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return props as any;\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { type, ...restProps } = props as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n return cloneElement(children as any, {\n ...mergedProps,\n ref: mergeRefs([getElementRef(children), (props as any).ref, refProp]),\n });\n };\n\n if (isValidElement(children)) {\n return (\n <Dialog.Trigger\n {...rest}\n className={className}\n nativeButton={resolvedNativeButton}\n render={renderer as any}\n />\n );\n }\n\n return (\n <Dialog.Trigger\n {...rest}\n className={className}\n nativeButton={resolvedNativeButton}\n ref={refProp as any}\n >\n {children}\n </Dialog.Trigger>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,uBAAgC,QAAgB,cAA4E;CAChI,MAAM,OAAO,OAAO,MAAM,MAAM,CAAC,CAAC;CAClC,IAAI,OAAO,cAAc,YAAY,QAAQ,UAAkBA,OAAK,MAAM,UAAU,KAAK,CAAC;CAC1F,OAAOA,OAAK,MAAM,SAAS;AAC7B;AAKA,MAAM,mBAAmB,cAA8B,IAAI;AAM3D,MAAM,sBAAsB,cAA4C,IAAI;AAC5E,MAAa,qBAAqB,IAAI,gBAAgB;AACtD,MAAa,wBAAwB,IAAI,mBAAmB;AAO5D,MAAM,qBAAqB,EACzB,MACA,UACA,gBAAgB,oBAChB,QAAQ,gBACR,GAAG,WAGC;CACJ,MAAM,CAAC,WAAW,gBAAgB,SAAS,CAAC,CAAC,IAAI;CACjD,gBAAgB;EACd,IAAI,MAAM,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
2
|
import { useNativeButton } from "../hooks/useNativeButton.mjs";
|
|
3
|
+
import { getElementRef } from "../utils/getElementRef.mjs";
|
|
3
4
|
import { mergeRefs } from "../utils/mergeRefs.mjs";
|
|
4
5
|
import { parseTrigger } from "../utils/parseTrigger.mjs";
|
|
5
6
|
import { PopoverGroupHandleContext } from "./groupContext.mjs";
|
|
@@ -48,7 +49,7 @@ const PopoverInGroup = ({ children, ref: refProp, ...props }) => {
|
|
|
48
49
|
...mergedProps,
|
|
49
50
|
className: clsx$1(mergedProps.className, triggerClassName),
|
|
50
51
|
ref: mergeRefs([
|
|
51
|
-
children
|
|
52
|
+
getElementRef(children),
|
|
52
53
|
renderProps.ref,
|
|
53
54
|
refProp
|
|
54
55
|
])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverInGroup.mjs","names":["BasePopover","clsx"],"sources":["../../src/Popover/PopoverInGroup.tsx"],"sourcesContent":["'use client';\n\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { Popover as BasePopover } from '@base-ui/react/popover';\nimport clsx from 'clsx';\nimport { cloneElement, type FC, isValidElement, useMemo } from 'react';\nimport { use } from 'react';\n\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { mergeRefs } from '@/utils/mergeRefs';\nimport { parseTrigger } from '@/utils/parseTrigger';\n\nimport { PopoverGroupHandleContext } from './groupContext';\nimport { HOVER_ONLY_TRIGGER_ATTR } from './hoverOnlyPress';\nimport { type PopoverProps } from './type';\nimport { useMergedPopoverProps } from './useMergedPopoverProps';\n\nexport const PopoverInGroup: FC<PopoverProps> = ({ children, ref: refProp, ...props }) => {\n const group = use(PopoverGroupHandleContext);\n const item = useMergedPopoverProps(props);\n\n const { openOnClick, openOnHover } = useMemo(\n () => parseTrigger(item.trigger ?? 'hover'),\n [item.trigger],\n );\n\n const resolvedOpenDelay = item.openDelay ?? (item.mouseEnterDelay ?? 0.1) * 1000;\n const resolvedCloseDelay = item.closeDelay ?? (item.mouseLeaveDelay ?? 0.1) * 1000;\n const disabled = Boolean(item.disabled);\n\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton: item.nativeButton,\n });\n\n // Don't render trigger behavior if no content\n if (!item.content) {\n return children as any;\n }\n\n const triggerProps = {\n [HOVER_ONLY_TRIGGER_ATTR]: openOnClick ? undefined : '',\n closeDelay: resolvedCloseDelay,\n delay: resolvedOpenDelay,\n disabled,\n openOnHover: openOnHover && !disabled,\n ...item.triggerProps,\n payload: item,\n };\n\n const triggerClassName = item.classNames?.trigger;\n\n if (isValidElement(children)) {\n return (\n <BasePopover.Trigger\n handle={group ?? undefined}\n {...triggerProps}\n nativeButton={resolvedNativeButton}\n render={(renderProps) => {\n // Base UI's trigger props include `type=\"button\"` by default.\n // If we render into a non-<button> element, that prop is invalid and can warn.\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return renderProps as any;\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { type, ref: triggerRef, ...restProps } = renderProps as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n return cloneElement(children as any, {\n ...mergedProps,\n className: clsx(mergedProps.className, triggerClassName),\n ref: mergeRefs([(children
|
|
1
|
+
{"version":3,"file":"PopoverInGroup.mjs","names":["BasePopover","clsx"],"sources":["../../src/Popover/PopoverInGroup.tsx"],"sourcesContent":["'use client';\n\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { Popover as BasePopover } from '@base-ui/react/popover';\nimport clsx from 'clsx';\nimport { cloneElement, type FC, isValidElement, useMemo } from 'react';\nimport { use } from 'react';\n\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { getElementRef } from '@/utils/getElementRef';\nimport { mergeRefs } from '@/utils/mergeRefs';\nimport { parseTrigger } from '@/utils/parseTrigger';\n\nimport { PopoverGroupHandleContext } from './groupContext';\nimport { HOVER_ONLY_TRIGGER_ATTR } from './hoverOnlyPress';\nimport { type PopoverProps } from './type';\nimport { useMergedPopoverProps } from './useMergedPopoverProps';\n\nexport const PopoverInGroup: FC<PopoverProps> = ({ children, ref: refProp, ...props }) => {\n const group = use(PopoverGroupHandleContext);\n const item = useMergedPopoverProps(props);\n\n const { openOnClick, openOnHover } = useMemo(\n () => parseTrigger(item.trigger ?? 'hover'),\n [item.trigger],\n );\n\n const resolvedOpenDelay = item.openDelay ?? (item.mouseEnterDelay ?? 0.1) * 1000;\n const resolvedCloseDelay = item.closeDelay ?? (item.mouseLeaveDelay ?? 0.1) * 1000;\n const disabled = Boolean(item.disabled);\n\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton: item.nativeButton,\n });\n\n // Don't render trigger behavior if no content\n if (!item.content) {\n return children as any;\n }\n\n const triggerProps = {\n [HOVER_ONLY_TRIGGER_ATTR]: openOnClick ? undefined : '',\n closeDelay: resolvedCloseDelay,\n delay: resolvedOpenDelay,\n disabled,\n openOnHover: openOnHover && !disabled,\n ...item.triggerProps,\n payload: item,\n };\n\n const triggerClassName = item.classNames?.trigger;\n\n if (isValidElement(children)) {\n return (\n <BasePopover.Trigger\n handle={group ?? undefined}\n {...triggerProps}\n nativeButton={resolvedNativeButton}\n render={(renderProps) => {\n // Base UI's trigger props include `type=\"button\"` by default.\n // If we render into a non-<button> element, that prop is invalid and can warn.\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return renderProps as any;\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { type, ref: triggerRef, ...restProps } = renderProps as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n return cloneElement(children as any, {\n ...mergedProps,\n className: clsx(mergedProps.className, triggerClassName),\n ref: mergeRefs([getElementRef(children), (renderProps as any).ref, refProp]),\n });\n }}\n />\n );\n }\n\n return (\n <BasePopover.Trigger\n handle={group ?? undefined}\n {...triggerProps}\n className={triggerClassName}\n nativeButton={resolvedNativeButton}\n ref={refProp}\n >\n {children}\n </BasePopover.Trigger>\n );\n};\n\nPopoverInG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I;EACJ,WAAW;EACX,cAAc;EACd,KAAK;EAEJ;CACkB,CAAA;AAEzB;AAEA,eAAe,cAAc"}
|
package/es/Popover/atoms.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useNativeButton } from "../hooks/useNativeButton.mjs";
|
|
3
|
+
import { getElementRef } from "../utils/getElementRef.mjs";
|
|
3
4
|
import { mergeRefs, useMergeRefs } from "../utils/mergeRefs.mjs";
|
|
4
5
|
import { FloatingLayerProvider } from "../hooks/useFloatingLayer.mjs";
|
|
5
6
|
import { getFloatingCollisionPadding } from "../internal/floating/collisionPadding.mjs";
|
|
@@ -38,7 +39,7 @@ const PopoverTriggerElement = ({ children, className, nativeButton, ref: refProp
|
|
|
38
39
|
...mergedProps,
|
|
39
40
|
className: clsx$1(baseClassName, extraClassName),
|
|
40
41
|
ref: mergeRefs([
|
|
41
|
-
children
|
|
42
|
+
getElementRef(children),
|
|
42
43
|
props.ref,
|
|
43
44
|
refProp
|
|
44
45
|
])
|
package/es/Popover/atoms.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atoms.mjs","names":["BasePopover","clsx"],"sources":["../../src/Popover/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { Popover as BasePopover } from '@base-ui/react/popover';\nimport * as stylex from '@stylexjs/stylex';\nimport clsx from 'clsx';\nimport {\n cloneElement,\n type ComponentProps,\n type ComponentPropsWithRef,\n isValidElement,\n useState,\n} from 'react';\n\nimport { FloatingLayerProvider } from '@/hooks/useFloatingLayer';\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { getFloatingCollisionPadding } from '@/internal/floating';\nimport { mergeRefs, useMergeRefs } from '@/utils/mergeRefs';\nimport { placementMap } from '@/utils/placement';\n\nimport { useLayerZIndex } from '../internal/zIndex';\nimport { PopoverArrowIcon } from './ArrowIcon';\nimport { usePopoverPortalContainer } from './PopoverPortal';\nimport { styles } from './style';\nimport { type PopoverPlacement } from './type';\n\nexport const PopoverRoot = BasePopover.Root;\nexport const PopoverBackdrop = BasePopover.Backdrop;\n\nexport type PopoverTriggerElementProps = Omit<\n ComponentPropsWithRef<typeof BasePopover.Trigger>,\n 'children' | 'render'\n> & {\n children: ComponentProps<typeof BasePopover.Trigger>['children'];\n};\n\nexport const PopoverTriggerElement = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: PopoverTriggerElementProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n if (isValidElement(children)) {\n return (\n <BasePopover.Trigger\n {...rest}\n nativeButton={resolvedNativeButton}\n render={(props, state) => {\n // Base UI's trigger props include `type=\"button\"` by default.\n // If we render into a non-<button> element, that prop is invalid and can warn.\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return props as any;\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { type, ref: triggerRef, ...restProps } = props as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n const baseClassName =\n typeof (mergedProps as any).className === 'function'\n ? (mergedProps as any).className(state)\n : (mergedProps as any).className;\n const extraClassName =\n typeof (className as any) === 'function' ? (className as any)(state) : className;\n\n return cloneElement(children as any, {\n ...mergedProps,\n className: clsx(baseClassName, extraClassName),\n ref: mergeRefs([(children as any).ref, (props as any).ref, refProp]),\n });\n }}\n />\n );\n }\n\n return (\n <BasePopover.Trigger\n {...rest}\n className={className}\n nativeButton={resolvedNativeButton}\n ref={refProp}\n >\n {children}\n </BasePopover.Trigger>\n );\n};\n\nPopoverTriggerElement.displayName = 'PopoverTriggerElement';\n\nexport type PopoverPortalAtomProps = Omit<\n ComponentProps<typeof BasePopover.Portal>,\n 'container'\n> & {\n /**\n * Portal container. When not provided, it uses the shared container created by `usePopoverPortalContainer`.\n */\n container?: HTMLElement | null;\n /**\n * Root element used by `usePopoverPortalContainer` to create the default container.\n */\n root?: HTMLElement | ShadowRoot | null;\n};\n\nexport const PopoverPortal = ({ container, root, children, ...rest }: PopoverPortalAtomProps) => {\n const defaultContainer = usePopoverPortalContainer(root);\n const resolvedContainer = container ?? defaultContainer;\n\n if (!resolvedContainer) return null;\n\n return (\n <BasePopover.Portal container={resolvedContainer} {...rest}>\n {children}\n </BasePopover.Portal>\n );\n};\n\nPopoverPortal.displayName = 'PopoverPortal';\n\nexport type PopoverPositionerAtomProps = ComponentProps<typeof BasePopover.Positioner> & {\n hoverTrigger?: boolean;\n placement?: PopoverPlacement;\n};\n\nexport const PopoverPositioner = ({\n children,\n className,\n collisionPadding,\n hoverTrigger,\n placement,\n align,\n side,\n sideOffset,\n style,\n ...rest\n}: PopoverPositionerAtomProps) => {\n const placementConfig = placement ? placementMap[placement] : undefined;\n const [positionerNode, setPositionerNode] = useState<HTMLDivElement | null>(null);\n const explicitZIndex =\n typeof style !== 'function' && style?.zIndex != null && typeof style.zIndex === 'number'\n ? style.zIndex\n : undefined;\n const { zIndex, ref: zRef } = useLayerZIndex<HTMLDivElement>('floating', explicitZIndex);\n const composedRef = useMergeRefs([setPositionerNode, zRef]);\n\n const resolvedStyle =\n typeof style === 'function'\n ? (state: any) => ({ zIndex, ...style(state) })\n : { zIndex, ...style };\n\n return (\n <BasePopover.Positioner\n align={align ?? placementConfig?.align ?? 'center'}\n collisionPadding={collisionPadding ?? getFloatingCollisionPadding()}\n data-hover-trigger={hoverTrigger || undefined}\n data-placement={placement}\n ref={composedRef as any}\n side={side ?? placementConfig?.side ?? 'bottom'}\n sideOffset={sideOffset ?? 6}\n style={resolvedStyle}\n className={(state) =>\n clsx(\n stylex.props(styles.positioner).className,\n typeof className === 'function' ? className(state) : className,\n )\n }\n {...rest}\n >\n <FloatingLayerProvider value={positionerNode}>{children}</FloatingLayerProvider>\n </BasePopover.Positioner>\n );\n};\n\nPopoverPositioner.displayName = 'PopoverPositioner';\n\nexport type PopoverPopupAtomProps = ComponentProps<typeof BasePopover.Popup> & {\n xstyle?: stylex.StyleXStyles;\n};\n\nexport const PopoverPopup = ({ className, xstyle, ...rest }: PopoverPopupAtomProps) => {\n return (\n <BasePopover.Popup\n className={(state) =>\n clsx(\n stylex.props(styles.popup, xstyle).className,\n typeof className === 'function' ? className(state) : className,\n )\n }\n {...rest}\n />\n );\n};\n\nPopoverPopup.displayName = 'PopoverPopup';\n\nexport type PopoverArrowAtomProps = ComponentProps<typeof BasePopover.Arrow>;\n\nexport const PopoverArrow = ({ className, children, ...rest }: PopoverArrowAtomProps) => {\n return (\n <BasePopover.Arrow\n className={(state) =>\n clsx(\n stylex.props(styles.arrow).className,\n typeof className === 'function' ? className(state) : className,\n )\n }\n {...rest}\n >\n {children ?? PopoverArrowIcon}\n </BasePopover.Arrow>\n );\n};\n\nPopoverArrow.displayName = 'PopoverArrow';\n\nexport type PopoverViewportAtomProps = ComponentProps<typeof BasePopover.Viewport>;\n\nexport const PopoverViewport = ({ className, ...rest }: PopoverViewportAtomProps) => {\n return (\n <BasePopover.Viewport\n className={(state) =>\n clsx(\n stylex.props(styles.viewport).className,\n 'lobe-popover-viewport',\n typeof className === 'function' ? className(state) : className,\n )\n }\n {...rest}\n />\n );\n};\n\nPopoverViewport.displayName = 'PopoverViewport';\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,cAAcA,QAAY;AACvC,MAAa,kBAAkBA,QAAY;AAI3C,MAAa,yBAAyB,EACpC,UACA,WACA,cACA,KAAK,SACL,GAAG,WAC6B;CAChC,MAAM,EACJ,8BACA,yBACE,gBAAgB;EAClB;EACA;CACF,CAAC;CACD,IAAI,eAAe,QAAQ,GACzB,OAAO,oBAACA,QAAY,SAAb;EAAqB,GAAI;EAAM,cAAc;EAAsB,SAAS,OAAO,UAAU;GAGlG,MAAM,uBAAuB;IAC3B,IAAI,8BAA8B,OAAO;IAEzC,MAAM,EACJ,MACA,KAAK,YACL,GAAG,cACD;IACJ,OAAO;GACT,EAAA,CAAG;GACH,MAAM,cAAc,WAAY,SA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n\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { Popover as BasePopover } from '@base-ui/react/popover';\nimport * as stylex from '@stylexjs/stylex';\nimport clsx from 'clsx';\nimport {\n cloneElement,\n type ComponentProps,\n type ComponentPropsWithRef,\n isValidElement,\n useState,\n} from 'react';\n\nimport { FloatingLayerProvider } from '@/hooks/useFloatingLayer';\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { getFloatingCollisionPadding } from '@/internal/floating';\nimport { getElementRef } from '@/utils/getElementRef';\nimport { mergeRefs, useMergeRefs } from '@/utils/mergeRefs';\nimport { placementMap } from '@/utils/placement';\n\nimport { useLayerZIndex } from '../internal/zIndex';\nimport { PopoverArrowIcon } from './ArrowIcon';\nimport { usePopoverPortalContainer } from './PopoverPortal';\nimport { styles } from './style';\nimport { type PopoverPlacement } from './type';\n\nexport const PopoverRoot = BasePopover.Root;\nexport const PopoverBackdrop = BasePopover.Backdrop;\n\nexport type PopoverTriggerElementProps = Omit<\n ComponentPropsWithRef<typeof BasePopover.Trigger>,\n 'children' | 'render'\n> & {\n children: ComponentProps<typeof BasePopover.Trigger>['children'];\n};\n\nexport const PopoverTriggerElement = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: PopoverTriggerElementProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n if (isValidElement(children)) {\n return (\n <BasePopover.Trigger\n {...rest}\n nativeButton={resolvedNativeButton}\n render={(props, state) => {\n // Base UI's trigger props include `type=\"button\"` by default.\n // If we render into a non-<button> element, that prop is invalid and can warn.\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return props as any;\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { type, ref: triggerRef, ...restProps } = props as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n const baseClassName =\n typeof (mergedProps as any).className === 'function'\n ? (mergedProps as any).className(state)\n : (mergedProps as any).className;\n const extraClassName =\n typeof (className as any) === 'function' ? (className as any)(state) : className;\n\n return cloneElement(children as any, {\n ...mergedProps,\n className: clsx(baseClassName, extraClassName),\n ref: mergeRefs([getElementRef(children), (props as any).ref, refProp]),\n });\n }}\n />\n );\n }\n\n return (\n <BasePopover.Trigger\n {...rest}\n className={className}\n nativeButton={resolvedNativeButton}\n ref={refProp}\n >\n {children}\n </BasePopover.Trigger>\n );\n};\n\nPopoverTriggerElement.displayName = 'PopoverTriggerElement';\n\nexport type PopoverPortalAtomProps = Omit<\n ComponentProps<typeof BasePopover.Portal>,\n 'container'\n> & {\n /**\n * Portal container. When not provided, it uses the shared container created by `usePopoverPortalContainer`.\n */\n container?: HTMLElement | null;\n /**\n * Root element used by `usePopoverPortalContainer` to create the default container.\n */\n root?: HTMLElement | ShadowRoot | null;\n};\n\nexport const PopoverPortal = ({ container, root, children, ...rest }: PopoverPortalAtomProps) => {\n const defaultContainer = usePopoverPortalContainer(root);\n const resolvedContainer = container ?? defaultContainer;\n\n if (!resolvedContainer) return null;\n\n return (\n <BasePopover.Portal container={resolvedContainer} {...rest}>\n {children}\n </BasePopover.Portal>\n );\n};\n\nPopoverPortal.displayName = 'PopoverPortal';\n\nexport type PopoverPositionerAtomProps = ComponentProps<typeof BasePopover.Positioner> & {\n hoverTrigger?: boolean;\n placement?: PopoverPlacement;\n};\n\nexport const PopoverPositioner = ({\n children,\n className,\n collisionPadding,\n hoverTrigger,\n placement,\n align,\n side,\n sideOffset,\n style,\n ...rest\n}: PopoverPositionerAtomProps) => {\n const placementConfig = placement ? placementMap[placement] : undefined;\n const [positionerNode, setPositionerNode] = useState<HTMLDivElement | null>(null);\n const explicitZIndex =\n typeof style !== 'function' && style?.zIndex != null && typeof style.zIndex === 'number'\n ? style.zIndex\n : undefined;\n const { zIndex, ref: zRef } = useLayerZIndex<HTMLDivElement>('floating', explicitZIndex);\n const composedRef = useMergeRefs([setPositionerNode, zRef]);\n\n const resolvedStyle =\n typeof style === 'function'\n ? (state: any) => ({ zIndex, ...style(state) })\n : { zIndex, ...style };\n\n return (\n <BasePopover.Positioner\n align={align ?? placementConfig?.align ?? 'center'}\n collisionPadding={collisionPadding ?? getFloatingCollisionPadding()}\n data-hover-trigger={hoverTrigger || undefined}\n data-placement={placement}\n ref={composedRef as any}\n side={side ?? placementConfig?.side ?? 'bottom'}\n sideOffset={sideOffset ?? 6}\n style={resolvedStyle}\n className={(state) =>\n clsx(\n stylex.props(styles.positioner).className,\n typeof className === 'function' ? className(state) : className,\n )\n }\n {...rest}\n >\n <FloatingLayerProvider value={positionerNode}>{children}</FloatingLayerProvider>\n </BasePopover.Positioner>\n );\n};\n\nPopoverPositioner.displayName = 'PopoverPositioner';\n\nexport type PopoverPopupAtomProps = ComponentProps<typeof BasePopover.Popup> & {\n xstyle?: stylex.StyleXStyles;\n};\n\nexport const PopoverPopup = ({ className, xstyle, ...rest }: PopoverPopupAtomProps) => {\n return (\n <BasePopover.Popup\n className={(state) =>\n clsx(\n stylex.props(styles.popup, xstyle).className,\n typeof className === 'function' ? className(state) : className,\n )\n }\n {...rest}\n />\n );\n};\n\nPopoverPopup.displayName = 'PopoverPopup';\n\nexport type PopoverArrowAtomProps = ComponentProps<typeof BasePopover.Arrow>;\n\nexport const PopoverArrow = ({ className, children, ...rest }: PopoverArrowAtomProps) => {\n return (\n <BasePopover.Arrow\n className={(state) =>\n clsx(\n stylex.props(styles.arrow).className,\n typeof className === 'function' ? className(state) : className,\n )\n }\n {...rest}\n >\n {children ?? PopoverArrowIcon}\n </BasePopover.Arrow>\n );\n};\n\nPopoverArrow.displayName = 'PopoverArrow';\n\nexport type PopoverViewportAtomProps = ComponentProps<typeof BasePopover.Viewport>;\n\nexport const PopoverViewport = ({ className, ...rest }: PopoverViewportAtomProps) => {\n return (\n <BasePopover.Viewport\n className={(state) =>\n clsx(\n stylex.props(styles.viewport).className,\n 'lobe-popover-viewport',\n typeof className === 'function' ? className(state) : className,\n )\n }\n {...rest}\n />\n );\n};\n\nPopoverViewport.displayName = 'P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,OAAO,KAAK,CAAC,CAAC,WAAW,OAAO,cAAc,aAAa,UAAU,KAAK,IAAI,SAAS;EAAG,GAAI;EACzJ,UAAA,YAAY;CACI,CAAA;AACvB;AACA,aAAa,cAAc;AAE3B,MAAa,mBAAmB,EAC9B,WACA,GAAG,WAC2B;CAC9B,OAAO,oBAACD,QAAY,UAAb;EAAsB,YAAW,UAASC,OAAK,OAAO,MAAM,OAAO,QAAQ,CAAC,CAAC,WAAW,yBAAyB,OAAO,cAAc,aAAa,UAAU,KAAK,IAAI,SAAS;EAAG,GAAI;CAAO,CAAA;AACtM;AACA,gBAAgB,cAAc"}
|
package/es/Popover/style.mjs
CHANGED
|
@@ -61,7 +61,7 @@ const styles = {
|
|
|
61
61
|
"--lobe-popover-animation-scale": "lb191ky9q",
|
|
62
62
|
"--lobe-popover-animation-translate": "lb10lwwj9",
|
|
63
63
|
"--lobe-popover-layout-duration": "lbpmwb57 lbvabi",
|
|
64
|
-
"--lobe-popover-layout-ease": "
|
|
64
|
+
"--lobe-popover-layout-ease": "lb1yl6ih0",
|
|
65
65
|
"--lobe-popover-translate-x": "lbdtzx1f lb1u18tlr lb8cr33m",
|
|
66
66
|
"--lobe-popover-translate-y": "lb70ox3w lb132x4ng lb19ms9b6 lb1jpw2w9",
|
|
67
67
|
kfzvcC: "lb1tblq73",
|
package/es/Popover/style.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.mjs","names":[],"sources":["../../src/Popover/style.ts"],"sourcesContent":["import './style.css';\n\nimport * as stylex from '@stylexjs/stylex';\n\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\n\nconst reducedMotion = '@media (prefers-reduced-motion: reduce)';\nconst layoutAnimation = ':is([data-layout-animation])';\nconst instantOrRepop = ':is([data-instant], [data-repop])';\nconst instant = ':is([data-instant])';\nconst popupLayoutTiming =\n ':is([data-layout-animation]):not([data-repop], [data-ending-style], [data-instant])';\nconst popupLayoutProperty = ':is([data-layout-animation]):not([data-repop], [data-instant])';\nconst popupRepopTiming = ':is([data-repop]):not([data-ending-style], [data-instant])';\nconst popupEndingTiming = ':is([data-ending-style]):not([data-instant])';\nconst positionerLayout = ':is([data-layout-animation]):not([data-instant], [data-repop])';\nconst startingOrEnding = ':is([data-starting-style], [data-ending-style])';\nconst anchorHidden = \":is([data-anchor-hidden], [data-zero-origin='true'])\";\nconst placementTop =\n \":is([data-placement='top'], [data-placement='topLeft'], [data-placement='topRight'])\";\nconst placementLeft =\n \":is([data-placement='left'], [data-placement='leftTop'], [data-placement='leftBottom'])\";\nconst placementRight =\n \":is([data-placement='right'], [data-placement='rightTop'], [data-placement='rightBottom'])\";\n\
|
|
1
|
+
{"version":3,"file":"style.mjs","names":[],"sources":["../../src/Popover/style.ts"],"sourcesContent":["import './style.css';\n\nimport * as stylex from '@stylexjs/stylex';\n\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\n\nconst reducedMotion = '@media (prefers-reduced-motion: reduce)';\nconst layoutAnimation = ':is([data-layout-animation])';\nconst instantOrRepop = ':is([data-instant], [data-repop])';\nconst instant = ':is([data-instant])';\nconst popupLayoutTiming =\n ':is([data-layout-animation]):not([data-repop], [data-ending-style], [data-instant])';\nconst popupLayoutProperty = ':is([data-layout-animation]):not([data-repop], [data-instant])';\nconst popupRepopTiming = ':is([data-repop]):not([data-ending-style], [data-instant])';\nconst popupEndingTiming = ':is([data-ending-style]):not([data-instant])';\nconst positionerLayout = ':is([data-layout-animation]):not([data-instant], [data-repop])';\nconst startingOrEnding = ':is([data-starting-style], [data-ending-style])';\nconst anchorHidden = \":is([data-anchor-hidden], [data-zero-origin='true'])\";\nconst placementTop =\n \":is([data-placement='top'], [data-placement='topLeft'], [data-placement='topRight'])\";\nconst placementLeft =\n \":is([data-placement='left'], [data-placement='leftTop'], [data-placement='leftBottom'])\";\nconst placementRight =\n \":is([data-placement='right'], [data-placement='rightTop'], [data-placement='rightBottom'])\";\n\nexport const styles = stylex.create({\n arrow: {\n '--lobe-popover-arrow-offset-block': '5px',\n '--lobe-popover-arrow-offset-inline': '8px',\n 'transition':\n 'inset-inline-start var(--lobe-popover-layout-duration) var(--lobe-popover-layout-ease), inset-block-start var(--lobe-popover-layout-duration) var(--lobe-popover-layout-ease)',\n 'display': 'flex',\n 'insetBlockEnd': {\n 'default': null,\n \":is([data-side='top'])\": 'calc(var(--lobe-popover-arrow-offset-block) * -1)',\n },\n 'insetBlockStart': {\n 'default': null,\n \":is([data-side='bottom'])\": 'calc(var(--lobe-popover-arrow-offset-block) * -1)',\n },\n 'insetInlineEnd': {\n 'default': null,\n \":is([data-side='left'])\": 'calc(var(--lobe-popover-arrow-offset-inline) * -1)',\n },\n 'insetInlineStart': {\n 'default': null,\n \":is([data-side='right'])\": 'calc(var(--lobe-popover-arrow-offset-inline) * -1)',\n },\n 'pointerEvents': 'none',\n 'position': 'absolute',\n 'transform': {\n 'default': null,\n \":is([data-side='left'])\": 'rotate(90deg)',\n \":is([data-side='right'])\": 'rotate(-90deg)',\n \":is([data-side='top'])\": 'rotate(180deg)',\n },\n 'transformOrigin': 'center',\n 'height': 6,\n 'width': 12,\n },\n arrowFill: {\n fill: cssVar.colorBgElevated,\n },\n arrowStroke: {\n fill: 'none',\n stroke: cssVar.colorBorder,\n strokeWidth: '1px',\n },\n arrowSvg: {\n display: 'block',\n height: '100%',\n width: '100%',\n },\n\n popup: {\n borderRadius: cssVar.borderRadius,\n outline: 'none',\n backgroundColor: cssVar.colorBgElevated,\n boxShadow: `${cssVar.boxShadowSecondary}, var(--lobe-ring)`,\n boxSizing: 'border-box',\n color: cssVar.colorText,\n opacity: { default: null, [startingOrEnding]: 0 },\n position: 'relative',\n transform: {\n default: null,\n [startingOrEnding]:\n 'translate3d(var(--lobe-popover-translate-x), var(--lobe-popover-translate-y), 0) scale(var(--lobe-popover-animation-scale))',\n },\n transformOrigin: 'var(--transform-origin)',\n transitionDuration: {\n default: 'var(--lobe-popover-animation-duration)',\n [instant]: '0s',\n [popupEndingTiming]: 'var(--lobe-popover-animation-duration-exit)',\n [popupLayoutTiming]:\n 'var(--lobe-popover-animation-duration), var(--lobe-popover-animation-duration), var(--lobe-popover-layout-duration), var(--lobe-popover-layout-duration)',\n [popupRepopTiming]: '0s',\n },\n transitionProperty: {\n default: 'opacity, transform',\n [instantOrRepop]: 'none',\n [popupLayoutProperty]: 'opacity, transform, width, height',\n },\n transitionTimingFunction: {\n default: 'var(--lobe-popover-animation-ease-out)',\n [instant]: 'ease',\n [popupEndingTiming]: 'var(--lobe-popover-animation-ease-in)',\n [popupLayoutTiming]:\n 'var(--lobe-popover-animation-ease-out), var(--lobe-popover-animation-ease-out), var(--lobe-popover-layout-ease), var(--lobe-popover-layout-ease)',\n [popupRepopTiming]: 'ease',\n },\n height: { default: null, [layoutAnimation]: 'var(--popup-height, auto)' },\n maxWidth: 'var(--available-width)',\n minWidth: 120,\n width: { default: null, [layoutAnimation]: 'var(--popup-width, auto)' },\n },\n\n positioner: {\n '--lobe-popover-animation-duration': '150ms',\n '--lobe-popover-animation-duration-exit': '75ms',\n '--lobe-popover-animation-ease-in': 'ease-in',\n '--lobe-popover-animation-ease-out': cssVar.motionEaseOut,\n '--lobe-popover-animation-scale': '0.96',\n '--lobe-popover-animation-translate': '6px',\n '--lobe-popover-layout-duration': { default: '380ms', [reducedMotion]: '0s' },\n '--lobe-popover-layout-ease': cssVar.motionSpringBouncy,\n '--lobe-popover-translate-x': {\n default: '0',\n [placementLeft]: 'var(--lobe-popover-animation-translate)',\n [placementRight]: 'calc(var(--lobe-popover-animation-translate) * -1)',\n },\n '--lobe-popover-translate-y': {\n default: 'calc(var(--lobe-popover-animation-translate) * -1)',\n [placementLeft]: '0',\n [placementRight]: '0',\n [placementTop]: 'var(--lobe-popover-animation-translate)',\n },\n 'pointerEvents': { [anchorHidden]: 'none', default: null },\n 'transitionDuration': {\n default: 'var(--lobe-popover-animation-duration)',\n [instantOrRepop]: '0s',\n [positionerLayout]: 'var(--lobe-popover-layout-duration)',\n },\n 'transitionProperty': {\n default: 'none',\n [positionerLayout]:\n 'inset-block-start, inset-inline-start, inset-inline-end, inset-block-end, transform',\n },\n 'transitionTimingFunction': {\n default: 'var(--lobe-popover-animation-ease-out)',\n [instantOrRepop]: 'ease',\n [positionerLayout]: 'var(--lobe-popover-layout-ease)',\n },\n 'visibility': { [anchorHidden]: 'hidden', default: null },\n 'zIndex': 1100,\n 'height': 'var(--positioner-height)',\n 'width': 'min(var(--positioner-width), var(--available-width))',\n },\n\n viewport: {\n '--lobe-popover-content-blur': '4px',\n '--lobe-popover-content-shift': '8px',\n '--lobe-popover-viewport-inline-padding': '12px',\n 'overflow': 'clip',\n 'paddingBlock': 12,\n 'paddingInline': 'var(--lobe-popover-viewport-inline-padding)',\n 'position': 'relative',\n },\n});\n"],"mappings":";AAkBA,MAAa,SAAS;CACpB,OAAO;EACL,qCAAqC;EACrC,sCAAsC;EACtC,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,YAAY;EACV,qCAAqC;EACrC,0CAA0C;EAC1C,oCAAoC;EACpC,qCAAqC;EACrC,kCAAkC;EAClC,sCAAsC;EACtC,kCAAkC;EAClC,8BAA8B;EAC9B,8BAA8B;EAC9B,8BAA8B;EAC9B,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,+BAA+B;EAC/B,gCAAgC;EAChC,0CAA0C;EAC1C,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;AACF"}
|
|
@@ -24,7 +24,7 @@ const useFetchData = (options) => {
|
|
|
24
24
|
params.current = opts.pageInfo.current;
|
|
25
25
|
params.pageSize = opts.pageInfo.pageSize;
|
|
26
26
|
}
|
|
27
|
-
const response = await opts.request(params, opts.sort, opts.filter);
|
|
27
|
+
const response = await opts.request(params, opts.sort, opts.filter) ?? { data: [] };
|
|
28
28
|
if (id !== requestId.current) return;
|
|
29
29
|
if (response.success === false) return;
|
|
30
30
|
const raw = response.data ?? [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchData.mjs","names":[],"sources":["../../../src/ProTable/hooks/useFetchData.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\nimport type { SortOrder } from '@/Table/type';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"useFetchData.mjs","names":[],"sources":["../../../src/ProTable/hooks/useFetchData.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\nimport type { SortOrder } from '@/Table/type';\n\nimport type {\n ProTablePageInfo,\n ProTableRequest,\n ProTableRequestData,\n ProTableRequestFilter,\n} from '../type';\n\ntype Filter = Record<string, (string | number | boolean)[] | null>;\n\nexport interface UseFetchDataOptions<T> {\n debounceTime: number;\n defaultData?: T[];\n depsKey: string;\n filter: Filter;\n getParams: () => Record<string, any>;\n manual: boolean;\n onDataSourceChange?: (data: T[]) => void;\n onLoad?: (data: T[]) => void;\n onLoadingChange?: (loading: boolean) => void;\n onRequestError?: (error: Error) => void;\n pageInfo: ProTablePageInfo;\n paginated: boolean;\n polling?: number | ((data: T[]) => number);\n postData?: (data: T[]) => T[];\n request?: ProTableRequest<T, any>;\n setTotal: (total: number) => void;\n sort: Record<string, SortOrder>;\n}\n\nexport const useFetchData = <T>(options: UseFetchDataOptions<T>) => {\n const [data, setData] = useState<T[]>(options.defaultData ?? []);\n const [loading, setLoading] = useState(false);\n const latest = useRef(options);\n latest.current = options;\n const requestId = useRef(0);\n const [enabled, setEnabled] = useState(!options.manual);\n const [token, setToken] = useState(0);\n const pending = useRef<(() => void)[]>([]);\n\n const updateLoading = (next: boolean) => {\n setLoading(next);\n latest.current.onLoadingChange?.(next);\n };\n\n const run = useCallback(async () => {\n const opts = latest.current;\n if (!opts.request) return;\n const id = ++requestId.current;\n updateLoading(true);\n try {\n const params: Record<string, any> = { ...opts.getParams() };\n if (opts.paginated) {\n params.current = opts.pageInfo.current;\n params.pageSize = opts.pageInfo.pageSize;\n }\n // A `request` resolving `null` / `undefined` (e.g. an empty API body) is treated as empty data.\n const response: Partial<ProTableRequestData<T>> = (await opts.request(\n params as any,\n opts.sort,\n opts.filter as ProTableRequestFilter,\n )) ?? { data: [] };\n if (id !== requestId.current) return;\n if (response.success === false) {\n // Pro keeps the previous data when the request reports failure.\n return;\n }\n const raw = response.data ?? [];\n const next = opts.postData ? opts.postData(raw) : raw;\n setData(next);\n opts.setTotal(response.total ?? next.length);\n opts.onLoad?.(next);\n opts.onDataSourceChange?.(next);\n } catch (error) {\n if (id !== requestId.current) return;\n if (opts.onRequestError) opts.onRequestError(error as Error);\n else console.error(error);\n } finally {\n if (id === requestId.current) updateLoading(false);\n const resolvers = pending.current;\n pending.current = [];\n resolvers.forEach((resolve) => resolve());\n }\n }, []);\n\n const { current, pageSize } = options.pageInfo;\n useEffect(() => {\n if (!enabled || !latest.current.request) return;\n const delay = latest.current.debounceTime;\n if (delay <= 0) {\n void run();\n return;\n }\n const timer = setTimeout(() => void run(), delay);\n return () => clearTimeout(timer);\n }, [enabled, token, options.depsKey, current, pageSize, run]);\n\n useEffect(() => {\n const { polling } = latest.current;\n if (!polling || loading || !enabled) return;\n const interval = typeof polling === 'function' ? polling(data) : polling;\n if (!interval) return;\n const timer = setTimeout(() => void run(), Math.max(interval, 2000));\n return () => clearTimeout(timer);\n }, [data, loading, enabled, options.polling, run]);\n\n const reload = useCallback(\n () =>\n new Promise<void>((resolve) => {\n if (!latest.current.request) {\n resolve();\n return;\n }\n pending.current.push(resolve);\n setEnabled(true);\n setToken((value) => value + 1);\n }),\n [],\n );\n\n return { data, loading, reload, setData };\n};\n"],"mappings":";;AAiCA,MAAa,gBAAmB,YAAoC;CAClE,MAAM,CAAC,MAAM,WAAW,SAAc,QAAQ,eAAe,CAAC,CAAC;CAC/D,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,SAAS,OAAO,OAAO;CAC7B,OAAO,UAAU;CACjB,MAAM,YAAY,OAAO,CAAC;CAC1B,MAAM,CAAC,SAAS,cAAc,SAAS,CAAC,QAAQ,MAAM;CACtD,MAAM,CAAC,OAAO,YAAY,SAAS,CAAC;CACpC,MAAM,UAAU,OAAuB,CAAC,CAAC;CAEzC,MAAM,iBAAiB,SAAkB;EACvC,WAAW,IAAI;EACf,OAAO,QAAQ,kBAAkB,IAAI;CACvC;CAEA,MAAM,MAAM,YAAY,YAAY;EAClC,MAAM,OAAO,OAAO;EACpB,IAAI,CAAC,KAAK,SAAS;EACnB,MAAM,KAAK,EAAE,UAAU;EACvB,cAAc,IAAI;EAClB,IAAI;GACF,MAAM,SAA8B,EAAE,GAAG,KAAK,UAAU,EAAE;GAC1D,IAAI,KAAK,WAAW;IAClB,OAAO,UAAU,KAAK,SAAS;IAC/B,OAAO,WAAW,KAAK,SAAS;GAClC;GAEA,MAAM,WAA6C,MAAM,KAAK,QAC5D,QACA,KAAK,MACL,KAAK,MACP,KAAM,EAAE,MAAM,CAAC,EAAE;GACjB,IAAI,OAAO,UAAU,SAAS;GAC9B,IAAI,SAAS,YAAY,OAEvB;GAEF,MAAM,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S;IAC3B,QAAQ;IACR;GACF;GACA,QAAQ,QAAQ,KAAK,OAAO;GAC5B,WAAW,IAAI;GACf,UAAU,UAAU,QAAQ,CAAC;EAC/B,CAAC,GACH,CAAC,CAG0B;EAAG;CAAQ;AAC1C"}
|
|
@@ -6,8 +6,9 @@ import Select from "../../Select/Select.mjs";
|
|
|
6
6
|
import DayjsDatePicker from "../../DatePicker/DayjsDatePicker.mjs";
|
|
7
7
|
import DayjsDateRangePicker from "../../DatePicker/DayjsDateRangePicker.mjs";
|
|
8
8
|
import { resolveValueEnum, resolveValueType, valueEnumToList } from "../utils.mjs";
|
|
9
|
+
import { styles } from "../style.mjs";
|
|
9
10
|
import { useColumnRequest } from "../hooks/useColumnRequest.mjs";
|
|
10
|
-
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
import dayjs from "dayjs";
|
|
12
13
|
//#region src/ProTable/parts/FieldControl.tsx
|
|
13
14
|
const SELECT_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -21,11 +22,16 @@ const FieldControl = ({ column, form, light, onChange, placeholder, value }) =>
|
|
|
21
22
|
const valueType = resolveValueType(column) ?? "text";
|
|
22
23
|
const valueEnum = resolveValueEnum(column);
|
|
23
24
|
const { fieldProps = {} } = column;
|
|
24
|
-
const label = typeof column.title === "string" ? column.title : void 0;
|
|
25
25
|
const size = light ? "small" : void 0;
|
|
26
26
|
const { isDarkMode } = useThemeMode();
|
|
27
27
|
const variant = light ? isDarkMode ? "filled" : "outlined" : void 0;
|
|
28
28
|
const remote = useColumnRequest(column);
|
|
29
|
+
const lightLabel = light && column.title !== void 0 && column.title !== null && typeof column.title !== "function" ? /* @__PURE__ */ jsx("span", {
|
|
30
|
+
className: styles.lightFilterLabel,
|
|
31
|
+
"data-pro-table-light-label": "",
|
|
32
|
+
children: column.title
|
|
33
|
+
}) : void 0;
|
|
34
|
+
const labelProps = lightLabel ? { prefix: lightLabel } : {};
|
|
29
35
|
if (column.renderFormItem) return column.renderFormItem(column, {
|
|
30
36
|
form,
|
|
31
37
|
isQuery: !light,
|
|
@@ -43,8 +49,9 @@ const FieldControl = ({ column, form, light, onChange, placeholder, value }) =>
|
|
|
43
49
|
loading: remote.loading,
|
|
44
50
|
mode: valueType === "checkbox" ? "multiple" : void 0,
|
|
45
51
|
options,
|
|
46
|
-
placeholder:
|
|
52
|
+
placeholder: placeholder.select,
|
|
47
53
|
size,
|
|
54
|
+
...labelProps,
|
|
48
55
|
style: { width: "100%" },
|
|
49
56
|
value: value ?? (valueType === "checkbox" ? [] : null),
|
|
50
57
|
variant,
|
|
@@ -61,24 +68,32 @@ const FieldControl = ({ column, form, light, onChange, placeholder, value }) =>
|
|
|
61
68
|
case "money":
|
|
62
69
|
case "percent":
|
|
63
70
|
case "progress": return /* @__PURE__ */ jsx(InputNumber_default, {
|
|
64
|
-
placeholder:
|
|
71
|
+
placeholder: placeholder.input,
|
|
65
72
|
size,
|
|
73
|
+
...labelProps,
|
|
66
74
|
style: { width: "100%" },
|
|
67
75
|
value: value ?? null,
|
|
68
76
|
variant,
|
|
69
77
|
...fieldProps,
|
|
70
78
|
onChange: (next) => onChange(next ?? void 0)
|
|
71
79
|
});
|
|
72
|
-
case "switch":
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
case "switch": {
|
|
81
|
+
const control = /* @__PURE__ */ jsx(Switch, {
|
|
82
|
+
checked: !!value,
|
|
83
|
+
...fieldProps,
|
|
84
|
+
onChange: (next) => onChange(next)
|
|
85
|
+
});
|
|
86
|
+
return lightLabel ? /* @__PURE__ */ jsxs("span", {
|
|
87
|
+
className: styles.lightFilterSwitch,
|
|
88
|
+
children: [lightLabel, control]
|
|
89
|
+
}) : control;
|
|
90
|
+
}
|
|
77
91
|
case "date":
|
|
78
92
|
case "dateTime": return /* @__PURE__ */ jsx(DayjsDatePicker, {
|
|
79
93
|
allowClear: true,
|
|
80
|
-
placeholder:
|
|
94
|
+
placeholder: placeholder.select,
|
|
81
95
|
size,
|
|
96
|
+
...labelProps,
|
|
82
97
|
style: { width: "100%" },
|
|
83
98
|
value: toDayjs(value),
|
|
84
99
|
variant,
|
|
@@ -89,6 +104,7 @@ const FieldControl = ({ column, form, light, onChange, placeholder, value }) =>
|
|
|
89
104
|
case "dateTimeRange": return /* @__PURE__ */ jsx(DayjsDateRangePicker, {
|
|
90
105
|
allowClear: true,
|
|
91
106
|
size,
|
|
107
|
+
...labelProps,
|
|
92
108
|
style: { width: "100%" },
|
|
93
109
|
value: value ? [toDayjs(value[0]), toDayjs(value[1])] : null,
|
|
94
110
|
variant,
|
|
@@ -97,8 +113,9 @@ const FieldControl = ({ column, form, light, onChange, placeholder, value }) =>
|
|
|
97
113
|
});
|
|
98
114
|
default: return /* @__PURE__ */ jsx(Input_default, {
|
|
99
115
|
allowClear: true,
|
|
100
|
-
placeholder:
|
|
116
|
+
placeholder: placeholder.input,
|
|
101
117
|
size,
|
|
118
|
+
...labelProps,
|
|
102
119
|
type: valueType === "password" ? "password" : void 0,
|
|
103
120
|
value: value ?? "",
|
|
104
121
|
variant,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldControl.mjs","names":["InputNumber","DatePicker","DateRangePicker","Input"],"sources":["../../../src/ProTable/parts/FieldControl.tsx"],"sourcesContent":["import dayjs, { type Dayjs } from 'dayjs';\nimport { type ReactNode } from 'react';\n\nimport DatePicker from '@/DatePicker/DayjsDatePicker';\nimport DateRangePicker from '@/DatePicker/DayjsDateRangePicker';\nimport Input from '@/Input/Input';\nimport InputNumber from '@/Input/InputNumber';\nimport Select from '@/Select';\nimport { useThemeMode } from '@/styles/theme/scope';\nimport Switch from '@/Switch';\n\nimport { useColumnRequest } from '../hooks/useColumnRequest';\nimport type { ProColumnType, ProTableFormInstance, ProTableValueType } from '../type';\nimport { resolveValueEnum, resolveValueType, valueEnumToList } from '../utils';\n\nexport interface FieldControlProps {\n column: ProColumnType<any>;\n form: ProTableFormInstance;\n light?: boolean;\n onChange: (value: any) => void;\n placeholder: { input: string; select: string };\n value: any;\n}\n\nconst SELECT_TYPES = new Set<ProTableValueType>(['select', 'radio', 'checkbox']);\n\n// Form values stay native Date (ProTable's contract); the picker works in Dayjs.\nconst toDayjs = (value: unknown) => (value ? dayjs(value as Date) : null);\nconst toDate = (value: Dayjs | null | undefined) => value?.toDate() ?? null;\n\nconst FieldControl = ({ column, form, light, onChange, placeholder, value }: FieldControlProps) => {\n const valueType = resolveValueType(column) ?? 'text';\n const valueEnum = resolveValueEnum(column);\n const { fieldProps = {} } = column;\n const
|
|
1
|
+
{"version":3,"file":"FieldControl.mjs","names":["InputNumber","DatePicker","DateRangePicker","Input"],"sources":["../../../src/ProTable/parts/FieldControl.tsx"],"sourcesContent":["import dayjs, { type Dayjs } from 'dayjs';\nimport { type ReactNode } from 'react';\n\nimport DatePicker from '@/DatePicker/DayjsDatePicker';\nimport DateRangePicker from '@/DatePicker/DayjsDateRangePicker';\nimport Input from '@/Input/Input';\nimport InputNumber from '@/Input/InputNumber';\nimport Select from '@/Select';\nimport { useThemeMode } from '@/styles/theme/scope';\nimport Switch from '@/Switch';\n\nimport { useColumnRequest } from '../hooks/useColumnRequest';\nimport { styles } from '../style';\nimport type { ProColumnType, ProTableFormInstance, ProTableValueType } from '../type';\nimport { resolveValueEnum, resolveValueType, valueEnumToList } from '../utils';\n\nexport interface FieldControlProps {\n column: ProColumnType<any>;\n form: ProTableFormInstance;\n light?: boolean;\n onChange: (value: any) => void;\n placeholder: { input: string; select: string };\n value: any;\n}\n\nconst SELECT_TYPES = new Set<ProTableValueType>(['select', 'radio', 'checkbox']);\n\n// Form values stay native Date (ProTable's contract); the picker works in Dayjs.\nconst toDayjs = (value: unknown) => (value ? dayjs(value as Date) : null);\nconst toDate = (value: Dayjs | null | undefined) => value?.toDate() ?? null;\n\nconst FieldControl = ({ column, form, light, onChange, placeholder, value }: FieldControlProps) => {\n const valueType = resolveValueType(column) ?? 'text';\n const valueEnum = resolveValueEnum(column);\n const { fieldProps = {} } = column;\n const size = light ? 'small' : undefined;\n const { isDarkMode } = useThemeMode();\n // Light filter: outlined on light backgrounds, filled in dark mode.\n const variant = light ? (isDarkMode ? 'filled' : 'outlined') : undefined;\n const remote = useColumnRequest(column);\n // Light filter: the field label always stays visible inside the control (Pro `FieldLabel`\n // style, \"Status: All\"), so a placeholder such as \"All\" is never ambiguous.\n const lightLabel =\n light &&\n column.title !== undefined &&\n column.title !== null &&\n typeof column.title !== 'function' ? (\n <span className={styles.lightFilterLabel} data-pro-table-light-label=\"\">\n {column.title as ReactNode}\n </span>\n ) : undefined;\n const labelProps = lightLabel ? { prefix: lightLabel } : {};\n\n if (column.renderFormItem) {\n return column.renderFormItem(\n column,\n { form, isQuery: !light, onChange, value },\n form,\n ) as ReactNode;\n }\n\n if (remote.enabled || valueEnum || SELECT_TYPES.has(valueType)) {\n const options =\n remote.options ??\n fieldProps.options ??\n valueEnumToList(valueEnum).map((item) => ({\n disabled: item.disabled,\n label: item.text,\n value: item.value,\n }));\n return (\n <Select\n allowClear\n loading={remote.loading}\n mode={valueType === 'checkbox' ? 'multiple' : undefined}\n options={options as any}\n placeholder={placeholder.select}\n size={size}\n {...labelProps}\n style={{ width: '100%' }}\n value={value ?? (valueType === 'checkbox' ? [] : null)}\n variant={variant}\n {...fieldProps}\n onChange={(next) => onChange(next ?? undefined)}\n onSearch={\n remote.onSearch\n ? (keyWords: string) => {\n remote.onSearch!(keyWords);\n fieldProps.onSearch?.(keyWords);\n }\n : fieldProps.onSearch\n }\n />\n );\n }\n\n switch (valueType) {\n case 'digit':\n case 'money':\n case 'percent':\n case 'progress': {\n return (\n <InputNumber\n placeholder={placeholder.input}\n size={size}\n {...labelProps}\n style={{ width: '100%' }}\n value={value ?? null}\n variant={variant}\n {...fieldProps}\n onChange={(next) => onChange(next ?? undefined)}\n />\n );\n }\n case 'switch': {\n const control = (\n <Switch checked={!!value} {...fieldProps} onChange={(next) => onChange(next)} />\n );\n return lightLabel ? (\n <span className={styles.lightFilterSwitch}>\n {lightLabel}\n {control}\n </span>\n ) : (\n control\n );\n }\n case 'date':\n case 'dateTime': {\n return (\n <DatePicker\n allowClear\n placeholder={placeholder.select}\n size={size}\n {...labelProps}\n style={{ width: '100%' }}\n value={toDayjs(value)}\n variant={variant}\n {...fieldProps}\n onChange={(next) => onChange(toDate(next) ?? undefined)}\n />\n );\n }\n case 'dateRange':\n case 'dateTimeRange': {\n return (\n <DateRangePicker\n allowClear\n size={size}\n {...labelProps}\n style={{ width: '100%' }}\n value={value ? [toDayjs(value[0]), toDayjs(value[1])] : null}\n variant={variant}\n {...fieldProps}\n onChange={(next) =>\n onChange(next && (next[0] || next[1]) ? [toDate(next[0]), toDate(next[1])] : undefined)\n }\n />\n );\n }\n default: {\n return (\n <Input\n allowClear\n placeholder={placeholder.input}\n size={size}\n {...labelProps}\n type={valueType === 'password' ? 'password' : undefined}\n value={value ?? ''}\n variant={variant}\n {...fieldProps}\n onChange={(event) => onChange(event.target.value === '' ? undefined : event.target.value)}\n onClear={() => {\n onChange(undefined);\n fieldProps.onClear?.();\n }}\n />\n );\n }\n }\n};\n\nexport default FieldControl;\n"],"mappings":";;;;;;;;;;;;;AAyBA,MAAM,+BAAe,IAAI,IAAuB;CAAC;CAAU;CAAS;AAAU,CAAC;AAG/E,MAAM,WAAW,UAAoB,QAAQ,MAAM,KAAa,IAAI;AACpE,MAAM,UAAU,UAAoC,OAAO,OAAO,KAAK;AAEvE,MAAM,gBAAgB,EAAE,QAAQ,MAAM,OAAO,UAAU,aAAa,YAA+B;CACjG,MAAM,YAAY,iBAAiB,MAAM,KAAK;CAC9C,MAAM,YAAY,iBAAiB,MAAM;CACzC,MAAM,EAAE,aAAa,CAAC,MAAM;CAC5B,MAAM,OAAO,QAAQ,UAAU,KAAA;CAC/B,MAAM,EAAE,eAAe,aAAa;CAEpC,MAAM,UAAU,QAAS,aAAa,WAAW,aAAc,KAAA;CAC/D,MAAM,SAAS,iBAA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H: "lbxobqjj",
|
|
82
83
|
khDVqt: "lbuxw1ft",
|
|
84
|
+
k5JduY: "lbbg6shv",
|
|
85
|
+
$$css: true
|
|
86
|
+
},
|
|
87
|
+
lightFilterSwitch: {
|
|
88
|
+
kOIVth: "lb167g77z",
|
|
89
|
+
kGNEyG: "lb6s0dn4",
|
|
90
|
+
k1xSpc: "lb3nfvp2",
|
|
83
91
|
$$css: true
|
|
84
92
|
},
|
|
85
93
|
optionCell: {
|
|
@@ -244,6 +252,7 @@ const styles = {
|
|
|
244
252
|
lightFilter: cls(raw.lightFilter),
|
|
245
253
|
lightFilterItem: `${PRO_PREFIX_CLS}-light-filter-item`,
|
|
246
254
|
lightFilterLabel: cls(raw.lightFilterLabel),
|
|
255
|
+
lightFilterSwitch: cls(raw.lightFilterSwitch),
|
|
247
256
|
optionCell: cls(raw.optionCell),
|
|
248
257
|
part: cls(raw.part),
|
|
249
258
|
partBordered: cls(raw.partBordered),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.mjs","names":["clsx"],"sources":["../../src/ProTable/style.ts"],"sourcesContent":["import './style.css';\n\nimport * as stylex from '@stylexjs/stylex';\nimport clsx from 'clsx';\n\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\n\nexport const PRO_PREFIX_CLS = 'lobe-pro-table';\n\nconst raw = stylex.create({\n alert: {\n borderRadius: cssVar.borderRadius,\n gap: 12,\n paddingBlock: 6,\n paddingInline: 12,\n alignItems: 'center',\n backgroundColor: `color-mix(in srgb, ${cssVar.colorPrimary} 8%, transparent)`,\n color: cssVar.colorText,\n display: 'flex',\n fontSize: cssVar.fontSize,\n justifyContent: 'space-between',\n marginBlockEnd: 12,\n minHeight: 40,\n },\n alertInfo: {\n flex: '1',\n gap: 12,\n alignItems: 'center',\n display: 'flex',\n flexWrap: 'wrap',\n minWidth: 0,\n },\n alertOption: {\n flex: 'none',\n gap: 8,\n alignItems: 'center',\n display: 'flex',\n },\n code: {\n borderRadius: cssVar.borderRadiusSM,\n paddingBlock: 1,\n paddingInline: 6,\n backgroundColor: cssVar.colorFillTertiary,\n fontFamily: cssVar.fontFamilyCode,\n fontSize: '0.9em',\n },\n copyable: {\n gap: 4,\n alignItems: 'center',\n display: 'inline-flex',\n maxWidth: '100%',\n },\n copyableText: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n minWidth: 0,\n },\n density: {\n padding: 4,\n display: 'flex',\n flexDirection: 'column',\n minWidth: 140,\n },\n enumList: {\n gap: 8,\n display: 'inline-flex',\n flexWrap: 'wrap',\n },\n lightFilter: {\n gap: 8,\n alignItems: 'center',\n display: 'flex',\n flexWrap: 'wrap',\n },\n lightFilterLabel: {\n color: cssVar.colorTextSecondary,\n fontSize: cssVar.fontSizeSM,\n whiteSpace: 'nowrap',\n },\n optionCell: {\n gap: 4,\n alignItems: 'center',\n display: 'flex',\n flexWrap: 'wrap',\n justifyContent: 'flex-end',\n },\n part: {\n minWidth: 0,\n },\n partBordered: {\n padding: 16,\n borderColor: cssVar.colorBorderSecondary,\n borderRadius: cssVar.borderRadiusLG,\n borderStyle: 'solid',\n borderWidth: 1,\n },\n search: {\n alignItems: 'center',\n columnGap: 24,\n display: 'grid',\n rowGap: 16,\n },\n searchFieldControl: {\n flex: '1',\n minWidth: 0,\n },\n searchLabelText: {\n overflow: 'hidden',\n display: 'block',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n maxWidth: '100%',\n minWidth: 0,\n },\n setting: {\n paddingBlock: 4,\n display: 'flex',\n flexDirection: 'column',\n maxHeight: 420,\n width: 260,\n },\n settingGroupTitle: {\n paddingInline: 12,\n color: cssVar.colorTextDescription,\n fontSize: cssVar.fontSizeSM,\n paddingBlockEnd: 2,\n paddingBlockStart: 6,\n },\n settingHeader: {\n paddingInline: 12,\n alignItems: 'center',\n borderBlockEndColor: cssVar.colorSplit,\n borderBlockEndStyle: 'solid',\n borderBlockEndWidth: 1,\n display: 'flex',\n justifyContent: 'space-between',\n paddingBlockEnd: 8,\n paddingBlockStart: 4,\n },\n settingItemTitle: {\n flex: '1',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n minWidth: 0,\n },\n settingList: {\n flex: '1',\n overflow: 'auto',\n paddingBlock: 4,\n },\n status: {\n gap: 8,\n alignItems: 'center',\n display: 'inline-flex',\n },\n statusDot: {\n borderRadius: '50%',\n flex: 'none',\n height: 6,\n width: 6,\n },\n title: {\n flex: 'none',\n gap: 4,\n alignItems: 'center',\n color: cssVar.colorText,\n display: 'flex',\n fontSize: cssVar.fontSizeLG,\n fontWeight: 600,\n minWidth: 0,\n },\n titleSub: {\n color: cssVar.colorTextDescription,\n fontSize: cssVar.fontSize,\n fontWeight: 'normal',\n },\n titleTooltip: {\n gap: 4,\n alignItems: 'center',\n display: 'inline-flex',\n },\n toolbar: {\n gap: 12,\n alignItems: 'center',\n display: 'flex',\n flexWrap: 'nowrap',\n justifyContent: 'space-between',\n marginBlockEnd: 16,\n },\n toolbarActions: {\n flex: '1',\n gap: 8,\n alignItems: 'center',\n display: 'flex',\n flexWrap: 'wrap',\n justifyContent: 'flex-end',\n marginInlineStart: 'auto',\n minWidth: 0,\n },\n toolbarOptions: {\n flex: 'none',\n gap: 2,\n alignItems: 'center',\n display: 'flex',\n },\n});\n\nconst cls = (style: stylex.StyleXStyles) => stylex.props(style).className ?? '';\n\nexport const styles = {\n alert: cls(raw.alert),\n alertInfo: cls(raw.alertInfo),\n alertOption: cls(raw.alertOption),\n code: cls(raw.code),\n copyable: cls(raw.copyable),\n copyableText: cls(raw.copyableText),\n density: cls(raw.density),\n densityItem: `${PRO_PREFIX_CLS}-density-item`,\n enumList: cls(raw.enumList),\n indexBorder: `${PRO_PREFIX_CLS}-index-border`,\n lightFilter: cls(raw.lightFilter),\n lightFilterItem: `${PRO_PREFIX_CLS}-light-filter-item`,\n lightFilterLabel: cls(raw.lightFilterLabel),\n optionCell: cls(raw.optionCell),\n part: cls(raw.part),\n partBordered: cls(raw.partBordered),\n root: `${PRO_PREFIX_CLS}-root`,\n search: cls(raw.search),\n searchActions: `${PRO_PREFIX_CLS}-search-actions`,\n searchField: `${PRO_PREFIX_CLS}-search-field`,\n searchFieldControl: cls(raw.searchFieldControl),\n searchLabel: `${PRO_PREFIX_CLS}-search-label`,\n searchLabelText: cls(raw.searchLabelText),\n setting: cls(raw.setting),\n settingGroupTitle: cls(raw.settingGroupTitle),\n settingHeader: cls(raw.settingHeader),\n settingItem: `${PRO_PREFIX_CLS}-setting-item`,\n settingItemActions: `${PRO_PREFIX_CLS}-setting-item-actions`,\n settingItemTitle: cls(raw.settingItemTitle),\n settingList: cls(raw.settingList),\n status: cls(raw.status),\n statusDot: cls(raw.statusDot),\n statusProcessing: `${PRO_PREFIX_CLS}-status-processing`,\n title: cls(raw.title),\n titleSub: cls(raw.titleSub),\n titleTooltip: cls(raw.titleTooltip),\n toolbar: cls(raw.toolbar),\n toolbarActions: cls(raw.toolbarActions),\n toolbarOptions: cls(raw.toolbarOptions),\n};\n\nexport const partClass = (\n cardBordered: boolean | { search?: boolean; table?: boolean } | undefined,\n part: 'search' | 'table',\n) =>\n clsx(\n styles.part,\n (typeof cardBordered === 'object' ? cardBordered[part] : cardBordered) && styles.partBordered,\n `${PRO_PREFIX_CLS}-${part}`,\n );\n"],"mappings":";;;AAKA,MAAa,iBAAiB;AAC9B,MAAM,MAAM;CACV,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR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a,IAAI,IAAI,WAAW;CAChC,iBAAiB,GAAG,eAAe;CACnC,kBAAkB,IAAI,IAAI,gBAAgB;CAC1C,YAAY,IAAI,IAAI,UAAU;CAC9B,MAAM,IAAI,IAAI,IAAI;CAClB,cAAc,IAAI,IAAI,YAAY;CAClC,MAAM,GAAG,eAAe;CACxB,QAAQ,IAAI,IAAI,MAAM;CACtB,eAAe,GAAG,eAAe;CACjC,aAAa,GAAG,eAAe;CAC/B,oBAAoB,IAAI,IAAI,kBAAkB;CAC9C,aAAa,GAAG,eAAe;CAC/B,iBAAiB,IAAI,IAAI,eAAe;CACxC,SAAS,IAAI,IAAI,OAAO;CACxB,mBAAmB,IAAI,IAAI,iBAAiB;CAC5C,eAAe,IAAI,IAAI,aAAa;CACpC,aAAa,GAAG,eAAe;CAC/B,oBAAoB,GAAG,eAAe;CACtC,kBAAkB,IAAI,IAAI,gBAAgB;CAC1C,aAAa,IAAI,IAAI,WAAW;CAChC,QAAQ,IAAI,IAAI,MAAM;CACtB,WAAW,IAAI,IAAI,SAAS;CAC5B,kBAAkB,GAAG,eAAe;CACpC,OAAO,IAAI,IAAI,KAAK;CACpB,UAAU,IAAI,IAAI,QAAQ;CAC1B,cAAc,IAAI,IAAI,YAAY;CAClC,SAAS,IAAI,IAAI,OAAO;CACxB,gBAAgB,IAAI,IAAI,cAAc;CACtC,gBAAgB,IAAI,IAAI,cAAc;AACxC;AACA,MAAa,aAAa,cAGX,SAA6BA,OAAK,OAAO,OAAO,OAAO,iBAAiB,WAAW,aAAa,QAAQ,iBAAiB,OAAO,cAAc,GAAG,eAAe,GAAG,MAAM"}
|
|
1
|
+
{"version":3,"file":"style.mjs","names":["clsx"],"sources":["../../src/ProTable/style.ts"],"sourcesContent":["import './style.css';\n\nimport * as stylex from '@stylexjs/stylex';\nimport clsx from 'clsx';\n\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\n\nexport const PRO_PREFIX_CLS = 'lobe-pro-table';\n\nconst raw = stylex.create({\n alert: {\n borderRadius: cssVar.borderRadius,\n gap: 12,\n paddingBlock: 6,\n paddingInline: 12,\n alignItems: 'center',\n backgroundColor: `color-mix(in srgb, ${cssVar.colorPrimary} 8%, transparent)`,\n color: cssVar.colorText,\n display: 'flex',\n fontSize: cssVar.fontSize,\n justifyContent: 'space-between',\n marginBlockEnd: 12,\n minHeight: 40,\n },\n alertInfo: {\n flex: '1',\n gap: 12,\n alignItems: 'center',\n display: 'flex',\n flexWrap: 'wrap',\n minWidth: 0,\n },\n alertOption: {\n flex: 'none',\n gap: 8,\n alignItems: 'center',\n display: 'flex',\n },\n code: {\n borderRadius: cssVar.borderRadiusSM,\n paddingBlock: 1,\n paddingInline: 6,\n backgroundColor: cssVar.colorFillTertiary,\n fontFamily: cssVar.fontFamilyCode,\n fontSize: '0.9em',\n },\n copyable: {\n gap: 4,\n alignItems: 'center',\n display: 'inline-flex',\n maxWidth: '100%',\n },\n copyableText: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n minWidth: 0,\n },\n density: {\n padding: 4,\n display: 'flex',\n flexDirection: 'column',\n minWidth: 140,\n },\n enumList: {\n gap: 8,\n display: 'inline-flex',\n flexWrap: 'wrap',\n },\n lightFilter: {\n gap: 8,\n alignItems: 'center',\n display: 'flex',\n flexWrap: 'wrap',\n },\n lightFilterLabel: {\n 'flex': 'none',\n 'color': cssVar.colorTextSecondary,\n 'fontSize': cssVar.fontSizeSM,\n 'whiteSpace': 'nowrap',\n '::after': { content: \"':'\" },\n },\n lightFilterSwitch: {\n gap: 8,\n alignItems: 'center',\n display: 'inline-flex',\n },\n optionCell: {\n gap: 4,\n alignItems: 'center',\n display: 'flex',\n flexWrap: 'wrap',\n justifyContent: 'flex-end',\n },\n part: {\n minWidth: 0,\n },\n partBordered: {\n padding: 16,\n borderColor: cssVar.colorBorderSecondary,\n borderRadius: cssVar.borderRadiusLG,\n borderStyle: 'solid',\n borderWidth: 1,\n },\n search: {\n alignItems: 'center',\n columnGap: 24,\n display: 'grid',\n rowGap: 16,\n },\n searchFieldControl: {\n flex: '1',\n minWidth: 0,\n },\n searchLabelText: {\n overflow: 'hidden',\n display: 'block',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n maxWidth: '100%',\n minWidth: 0,\n },\n setting: {\n paddingBlock: 4,\n display: 'flex',\n flexDirection: 'column',\n maxHeight: 420,\n width: 260,\n },\n settingGroupTitle: {\n paddingInline: 12,\n color: cssVar.colorTextDescription,\n fontSize: cssVar.fontSizeSM,\n paddingBlockEnd: 2,\n paddingBlockStart: 6,\n },\n settingHeader: {\n paddingInline: 12,\n alignItems: 'center',\n borderBlockEndColor: cssVar.colorSplit,\n borderBlockEndStyle: 'solid',\n borderBlockEndWidth: 1,\n display: 'flex',\n justifyContent: 'space-between',\n paddingBlockEnd: 8,\n paddingBlockStart: 4,\n },\n settingItemTitle: {\n flex: '1',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n minWidth: 0,\n },\n settingList: {\n flex: '1',\n overflow: 'auto',\n paddingBlock: 4,\n },\n status: {\n gap: 8,\n alignItems: 'center',\n display: 'inline-flex',\n },\n statusDot: {\n borderRadius: '50%',\n flex: 'none',\n height: 6,\n width: 6,\n },\n title: {\n flex: 'none',\n gap: 4,\n alignItems: 'center',\n color: cssVar.colorText,\n display: 'flex',\n fontSize: cssVar.fontSizeLG,\n fontWeight: 600,\n minWidth: 0,\n },\n titleSub: {\n color: cssVar.colorTextDescription,\n fontSize: cssVar.fontSize,\n fontWeight: 'normal',\n },\n titleTooltip: {\n gap: 4,\n alignItems: 'center',\n display: 'inline-flex',\n },\n toolbar: {\n gap: 12,\n alignItems: 'center',\n display: 'flex',\n flexWrap: 'nowrap',\n justifyContent: 'space-between',\n marginBlockEnd: 16,\n },\n toolbarActions: {\n flex: '1',\n gap: 8,\n alignItems: 'center',\n display: 'flex',\n flexWrap: 'wrap',\n justifyContent: 'flex-end',\n marginInlineStart: 'auto',\n minWidth: 0,\n },\n toolbarOptions: {\n flex: 'none',\n gap: 2,\n alignItems: 'center',\n display: 'flex',\n },\n});\n\nconst cls = (style: stylex.StyleXStyles) => stylex.props(style).className ?? '';\n\nexport const styles = {\n alert: cls(raw.alert),\n alertInfo: cls(raw.alertInfo),\n alertOption: cls(raw.alertOption),\n code: cls(raw.code),\n copyable: cls(raw.copyable),\n copyableText: cls(raw.copyableText),\n density: cls(raw.density),\n densityItem: `${PRO_PREFIX_CLS}-density-item`,\n enumList: cls(raw.enumList),\n indexBorder: `${PRO_PREFIX_CLS}-index-border`,\n lightFilter: cls(raw.lightFilter),\n lightFilterItem: `${PRO_PREFIX_CLS}-light-filter-item`,\n lightFilterLabel: cls(raw.lightFilterLabel),\n lightFilterSwitch: cls(raw.lightFilterSwitch),\n optionCell: cls(raw.optionCell),\n part: cls(raw.part),\n partBordered: cls(raw.partBordered),\n root: `${PRO_PREFIX_CLS}-root`,\n search: cls(raw.search),\n searchActions: `${PRO_PREFIX_CLS}-search-actions`,\n searchField: `${PRO_PREFIX_CLS}-search-field`,\n searchFieldControl: cls(raw.searchFieldControl),\n searchLabel: `${PRO_PREFIX_CLS}-search-label`,\n searchLabelText: cls(raw.searchLabelText),\n setting: cls(raw.setting),\n settingGroupTitle: cls(raw.settingGroupTitle),\n settingHeader: cls(raw.settingHeader),\n settingItem: `${PRO_PREFIX_CLS}-setting-item`,\n settingItemActions: `${PRO_PREFIX_CLS}-setting-item-actions`,\n settingItemTitle: cls(raw.settingItemTitle),\n settingList: cls(raw.settingList),\n status: cls(raw.status),\n statusDot: cls(raw.statusDot),\n statusProcessing: `${PRO_PREFIX_CLS}-status-processing`,\n title: cls(raw.title),\n titleSub: cls(raw.titleSub),\n titleTooltip: cls(raw.titleTooltip),\n toolbar: cls(raw.toolbar),\n toolbarActions: cls(raw.toolbarActions),\n toolbarOptions: cls(raw.toolbarOptions),\n};\n\nexport const partClass = (\n cardBordered: boolean | { search?: boolean; table?: boolean } | undefined,\n part: 'search' | 'table',\n) =>\n clsx(\n styles.part,\n (typeof cardBordered === 'object' ? cardBordered[part] : cardBordered) && styles.partBordered,\n `${PRO_PREFIX_CLS}-${part}`,\n );\n"],"mappings":";;;AAKA,MAAa,iBAAiB;AAC9B,MAAM,MAAM;CACV,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,cAAc;EACZ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,SAAS;EACP,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,kBAAkB;EAChB,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,mBAAmB;EACjB,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,YAAY;EACV,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,OAAO;CACT;CACA,cAAc;EACZ,QA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;CAChC,QAAQ,IAAI,IAAI,MAAM;CACtB,WAAW,IAAI,IAAI,SAAS;CAC5B,kBAAkB,GAAG,eAAe;CACpC,OAAO,IAAI,IAAI,KAAK;CACpB,UAAU,IAAI,IAAI,QAAQ;CAC1B,cAAc,IAAI,IAAI,YAAY;CAClC,SAAS,IAAI,IAAI,OAAO;CACxB,gBAAgB,IAAI,IAAI,cAAc;CACtC,gBAAgB,IAAI,IAAI,cAAc;AACxC;AACA,MAAa,aAAa,cAGX,SAA6BA,OAAK,OAAO,OAAO,OAAO,iBAAiB,WAAW,aAAa,QAAQ,iBAAiB,OAAO,cAAc,GAAG,eAAe,GAAG,MAAM"}
|
package/es/ProTable/type.d.mts
CHANGED
|
@@ -185,13 +185,16 @@ export interface ProTableRequestData<T> {
|
|
|
185
185
|
export type ProTableRequestSort = Record<string, SortOrder>;
|
|
186
186
|
/** `filter` argument of `request`: column key → selected filter values (ProComponents shape). */
|
|
187
187
|
export type ProTableRequestFilter = Record<string, (string | number)[] | null>;
|
|
188
|
-
/**
|
|
188
|
+
/**
|
|
189
|
+
* `request(params, sort, filter)`; resolves `{ data, total, success }` (all optional). A `null` /
|
|
190
|
+
* `undefined` result is treated as empty data.
|
|
191
|
+
*/
|
|
189
192
|
export type ProTableRequest<T, Params = Record<string, any>> = (params: Params & {
|
|
190
193
|
[key: string]: any;
|
|
191
194
|
current?: number;
|
|
192
195
|
keyword?: string;
|
|
193
196
|
pageSize?: number;
|
|
194
|
-
}, sort: ProTableRequestSort, filter: ProTableRequestFilter) => Promise<Partial<ProTableRequestData<T
|
|
197
|
+
}, sort: ProTableRequestSort, filter: ProTableRequestFilter) => Promise<Partial<ProTableRequestData<T>> | null | undefined>;
|
|
195
198
|
/**
|
|
196
199
|
* `loading` as an object: Spin options of the table overlay (`tip`, `variant`, …) plus `delay`
|
|
197
200
|
* (ms before the overlay shows). Without `spinning` the overlay follows the `request` state.
|
|
@@ -62,11 +62,12 @@ const Segmented = ({ block = false, className, classNames, defaultValue, disable
|
|
|
62
62
|
const groupValue = useMemo(() => innerValue != null ? [innerValue] : [], [innerValue]);
|
|
63
63
|
const rootStyle = {
|
|
64
64
|
...style,
|
|
65
|
+
...customStyles?.list,
|
|
65
66
|
...customStyles?.root
|
|
66
67
|
};
|
|
67
68
|
return /* @__PURE__ */ jsxs(SegmentedRoot, {
|
|
68
69
|
block,
|
|
69
|
-
className: clsx$1(classNames?.root, className),
|
|
70
|
+
className: clsx$1(classNames?.root, classNames?.list, className),
|
|
70
71
|
disabled,
|
|
71
72
|
glass,
|
|
72
73
|
id,
|