@bioturing/components 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Badge/component.js +7 -20
- package/dist/components/Badge/component.js.map +1 -1
- package/dist/components/ColorSelect/component.js +138 -0
- package/dist/components/ColorSelect/component.js.map +1 -0
- package/dist/components/ColorSelect/style.css +1 -0
- package/dist/components/DragDrop/context.js +18 -0
- package/dist/components/DragDrop/context.js.map +1 -0
- package/dist/components/DragDrop/draggable.js +64 -0
- package/dist/components/DragDrop/draggable.js.map +1 -0
- package/dist/components/DragDrop/droppable.js +48 -0
- package/dist/components/DragDrop/droppable.js.map +1 -0
- package/dist/components/DragDrop/hooks.js +139 -0
- package/dist/components/DragDrop/hooks.js.map +1 -0
- package/dist/components/DragDrop/index.js +45 -0
- package/dist/components/DragDrop/index.js.map +1 -0
- package/dist/components/DragDrop/style.css +1 -0
- package/dist/components/IconButton/component.js +54 -43
- package/dist/components/IconButton/component.js.map +1 -1
- package/dist/components/IconButton/style.css +1 -1
- package/dist/components/Nav/context.js +7 -0
- package/dist/components/Nav/context.js.map +1 -0
- package/dist/components/Nav/group.js +16 -0
- package/dist/components/Nav/group.js.map +1 -0
- package/dist/components/Nav/heading.js +16 -0
- package/dist/components/Nav/heading.js.map +1 -0
- package/dist/components/Nav/index.js +13 -0
- package/dist/components/Nav/index.js.map +1 -0
- package/dist/components/Nav/item.js +36 -0
- package/dist/components/Nav/item.js.map +1 -0
- package/dist/components/Nav/style.css +1 -0
- package/dist/components/PopupPanel/component.js +69 -74
- package/dist/components/PopupPanel/component.js.map +1 -1
- package/dist/components/Stack/Stack.js +40 -34
- package/dist/components/Stack/Stack.js.map +1 -1
- package/dist/components/Stack/StackChild.js +59 -54
- package/dist/components/Stack/StackChild.js.map +1 -1
- package/dist/components/Tag/component.js +59 -24
- package/dist/components/Tag/component.js.map +1 -1
- package/dist/components/Tag/style.css +1 -1
- package/dist/components/ThemeProvider/component.js +18 -18
- package/dist/components/ThemeProvider/component.js.map +1 -1
- package/dist/components/ThemeProvider/style.css +1 -1
- package/dist/components/Toast/component.js +29 -35
- package/dist/components/Toast/component.js.map +1 -1
- package/dist/components/Tooltip/component.js +4 -22
- package/dist/components/Tooltip/component.js.map +1 -1
- package/dist/components/VerticalCollapsiblePanel/component.js +37 -37
- package/dist/components/VerticalCollapsiblePanel/component.js.map +1 -1
- package/dist/components/hooks/useCharts.js +19 -17
- package/dist/components/hooks/useCharts.js.map +1 -1
- package/dist/components/utils/colors.js +5 -0
- package/dist/components/utils/colors.js.map +1 -0
- package/dist/index.d.ts +724 -23
- package/dist/index.js +186 -162
- package/dist/index.js.map +1 -1
- package/dist/metadata.js +45 -7
- package/dist/metadata.js.map +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/tokens/and-theme/tokens.js +13 -7
- package/dist/tokens/and-theme/tokens.js.map +1 -1
- package/dist/tokens/charts/{tokens.js → palettes/cloudscape.js} +22 -12
- package/dist/tokens/charts/palettes/cloudscape.js.map +1 -0
- package/dist/tokens/charts/palettes/colorbrewer.js +1525 -0
- package/dist/tokens/charts/palettes/colorbrewer.js.map +1 -0
- package/dist/tokens/charts/palettes/index.js +61 -0
- package/dist/tokens/charts/palettes/index.js.map +1 -0
- package/dist/tokens/charts/palettes/tableau.js +112 -0
- package/dist/tokens/charts/palettes/tableau.js.map +1 -0
- package/dist/tokens/utils.js.map +1 -1
- package/package.json +2 -2
- package/dist/tokens/charts/index.js +0 -18
- package/dist/tokens/charts/index.js.map +0 -1
- package/dist/tokens/charts/tokens.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/PopupPanel/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n useCls,\n clsx,\n useAntdCssVarClassname,\n parseAntdPlacement,\n} from \"../utils\";\nimport { Popover } from \"@base-ui-components/react/popover\";\n\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport Flex from \"antd/es/flex\";\nimport { IconButton } from \"../IconButton\";\nimport { X } from \"@bioturing/assets\";\nimport { PopupPanelSize } from \"./constants\";\nimport { useControlledState } from \"../hooks\";\nimport { useResizable, type MoveValues } from \"react-use-resizable\";\nimport mergeRefs from \"merge-refs\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport interface PopupPanelProps\n extends Omit<\n React.ComponentPropsWithRef<\"div\">,\n \"title\" | \"content\" | \"children\"\n > {\n /** The trigger element that opens the popup panel */\n children?: React.ComponentProps<typeof Popover.Trigger>[\"render\"];\n /** Placement of the popup panel relative to its trigger */\n placement?: PopoverProps[\"placement\"];\n /** Whether to open the popup panel on hover */\n openOnHover?: boolean;\n /** Controls the open state of the popup panel */\n open?: boolean;\n /** Callback fired when the open state changes */\n onOpenChange?: Popover.Root.Props[\"onOpenChange\"];\n /** Content to display inside the popup panel */\n content?: React.ReactNode;\n /** Title text or element to display in the panel header */\n title?: React.ReactNode;\n /** The event that triggers the popup panel */\n /**\n * @default \"click\"\n */\n trigger?: \"click\" | \"hover\";\n /** Custom anchor element for positioning the panel */\n anchor?: Popover.Positioner.Props[\"anchor\"];\n /** Content to display before the close button */\n beforeCloseButton?: React.ReactNode;\n /** Content to display after the close button */\n afterCloseButton?: React.ReactNode;\n /** Content to display after the title */\n afterTitle?: React.ReactNode;\n /**\n * Predefined sizes for the popup panel\n * - xsmall: 320px\n * - small: 400px\n * - medium: 480px (default)\n * - large: 640px\n * - xlarge: 840px\n * @default \"medium\" for default type, \"xsmall\" for other types\n */\n size?: keyof typeof PopupPanelSize;\n /**\n * Footer content for the popup panel\n * Can be a React node or a function that returns a React node\n */\n footer?:\n | React.ReactNode\n | ((props: { close: () => void }) => React.ReactNode);\n /**\n * Whether the panel should be open by default when uncontrolled\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Whether the panel should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Custom class names for different parts of the popup panel\n * @default {}\n */\n classNames?: {\n root?: string;\n trigger?: string;\n popup?: string;\n header?: string;\n title?: string;\n content?: string;\n footer?: string;\n resizeHandle?: string;\n };\n /**\n * Whether to close the panel when clicking outside\n * @default true\n */\n closeOnClickOutside?: boolean;\n /**\n * Whether to use modal mode\n * @default false\n */\n modal?: Popover.Root.Props[\"modal\"];\n}\n\nexport const PopupPanel = ({\n children,\n placement,\n openOnHover = false,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n content,\n title,\n trigger = \"click\",\n className,\n anchor,\n beforeCloseButton,\n afterCloseButton,\n afterTitle,\n size = \"medium\",\n footer,\n defaultOpen,\n resizable = false,\n classNames,\n modal = false,\n closeOnClickOutside = true,\n}: PopupPanelProps) => {\n // Use controlled state with proper initialization to prevent switching between controlled/uncontrolled\n const [open, setOpen] = useControlledState(\n outsideOpen,\n outsideOnOpenChange,\n defaultOpen ?? false // Always provide a default value to prevent undefined\n );\n\n const cls = useCls();\n const antdCssVarClassname = useAntdCssVarClassname();\n const headlessUIPlacement = parseAntdPlacement(placement);\n // We don't need triggerRef since we're using callbackRef for the popup\n const [popupRef, setPopupRef] = useState<HTMLDivElement | null>(null);\n const [width, setWidth] = useState<number>();\n const [height, setHeight] = useState<number>();\n const callbackRef = useCallback((node: HTMLDivElement) => {\n setPopupRef(node);\n }, []);\n useEffect(() => {\n if (!popupRef) return;\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n setWidth(entry.contentRect.width);\n setHeight(entry.contentRect.height);\n }\n });\n observer.observe(popupRef);\n return () => {\n observer.disconnect();\n };\n }, [popupRef]);\n\n const defaultCloseIcon = useMemo(() => <X size={16} />, []);\n const renderTitle = useCallback(() => {\n return (\n <div className={clsx(cls(\"popup-panel-header\"), classNames?.header)}>\n <Flex\n align=\"center\"\n gap={8}\n className={cls(\"popup-panel-title-wrapper\")}\n >\n <Popover.Title\n render={\n <div className={clsx(cls(\"grow\", \"truncate\"), classNames?.title)}>\n {title}\n </div>\n }\n ></Popover.Title>\n <div className=\"flex items-center gap-2\">\n {beforeCloseButton}\n <Popover.Close\n render={<IconButton>{defaultCloseIcon}</IconButton>}\n />\n {afterCloseButton}\n </div>\n </Flex>\n {afterTitle ? afterTitle : null}\n </div>\n );\n }, [\n afterCloseButton,\n afterTitle,\n beforeCloseButton,\n cls,\n classNames?.header,\n classNames?.title,\n defaultCloseIcon,\n title,\n ]);\n const [resizing, setResizing] = useState(false);\n const { getRootProps, getHandleProps, rootRef } = useResizable({\n initialWidth: width,\n initialHeight: height,\n onDragStart: () => setResizing(true),\n onDragEnd: () => setResizing(false),\n });\n useEffect(() => {\n if (resizing) {\n document.body.style.userSelect = \"none\";\n } else {\n document.body.style.userSelect = \"\";\n }\n }, [resizing]);\n const { ref: rootRefProp, ...rootPropsWithoutRef } = getRootProps();\n // Handle reverse handle change for vertical resizing\n // Currently not used but kept for future implementation\n // const _onReverseHandleChangeVertical = (\n // parent: React.RefObject<HTMLDivElement>,\n // values: MoveValues\n // ) => {\n // if (!parent.current) return;\n // const { heightDiff } = values;\n // parent.current.style.top = `${\n // parseInt(parent.current.style.top || \"0\") - heightDiff\n // }px`;\n // };\n\n // Handle reverse handle change\n const onReverseHandleChangeHorizontal = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current) return;\n const { widthDiff } = values;\n parent.current.style.left = `${\n parseInt(parent.current.style.left || \"0\") - widthDiff\n }px`;\n };\n\n return (\n <Popover.Root\n openOnHover={trigger === \"hover\" ? true : openOnHover}\n open={open}\n onOpenChange={(open, event, reason) => {\n if (reason === \"outside-press\" && !closeOnClickOutside) return;\n setOpen(open, event, reason);\n }}\n modal={modal}\n >\n <Popover.Trigger\n render={children}\n className={clsx(cls(\"popup-panel-trigger\"), classNames?.trigger)}\n ></Popover.Trigger>\n <Popover.Portal>\n <Popover.Positioner\n className={clsx(\n cls(\"popup-panel-root\"),\n classNames?.root,\n antdCssVarClassname\n )}\n side={headlessUIPlacement.placement}\n align={headlessUIPlacement.align}\n sideOffset={4}\n anchor={anchor}\n style={\n {\n \"--size-width\": size ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n >\n <Popover.Popup\n className={clsx(\n cls(\"popup-panel\"),\n cls(`popup-panel-size-${size}`),\n className,\n classNames?.popup,\n antdCssVarClassname\n )}\n ref={mergeRefs(rootRefProp, callbackRef)}\n {...rootPropsWithoutRef}\n {...(resizing ? { \"data-resizing\": true } : {})}\n >\n {/* <div ref={popupRef}> */}\n {title && renderTitle()}\n <div\n className={clsx(cls(\"popup-panel-content\"), classNames?.content)}\n >\n <div className={cls(\"popup-panel-content-inner\")}>{content}</div>\n </div>\n {footer && (\n <div\n className={clsx(cls(\"popup-panel-footer\"), classNames?.footer)}\n >\n {typeof footer === \"function\"\n ? footer({ close: () => setOpen(false) })\n : footer}\n </div>\n )}\n {resizable && (\n <>\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-left\"\n {...getHandleProps({\n lockHorizontal: true,\n })}\n />\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-left\"\n {...getHandleProps({\n reverse: true,\n lockVertical: true,\n onResize: (values) =>\n onReverseHandleChangeHorizontal(rootRef, values),\n })}\n />\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-right\"\n {...getHandleProps({\n lockVertical: true,\n })}\n />\n </>\n )}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n};\n"],"names":["PopupPanel","children","placement","openOnHover","outsideOpen","outsideOnOpenChange","content","title","trigger","className","anchor","beforeCloseButton","afterCloseButton","afterTitle","size","footer","defaultOpen","resizable","classNames","modal","closeOnClickOutside","open","setOpen","useControlledState","cls","useCls","antdCssVarClassname","useAntdCssVarClassname","headlessUIPlacement","parseAntdPlacement","popupRef","setPopupRef","useState","width","setWidth","height","setHeight","callbackRef","useCallback","node","useEffect","observer","entries","entry","defaultCloseIcon","useMemo","jsx","X","renderTitle","jsxs","clsx","Flex","Popover","IconButton","resizing","setResizing","getRootProps","getHandleProps","rootRef","useResizable","rootRefProp","rootPropsWithoutRef","onReverseHandleChangeHorizontal","parent","values","widthDiff","event","reason","PopupPanelSize","mergeRefs","Fragment"],"mappings":";;;;;;;;;;;;;;AA2GO,MAAMA,KAAa,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAMC;AAAA,EACN,cAAcC;AAAA,EACd,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,QAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,YAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,qBAAAC,IAAsB;AACxB,MAAuB;AAEf,QAAA,CAACC,GAAMC,CAAO,IAAIC;AAAA,IACtBnB;AAAA,IACAC;AAAA,IACAW,KAAe;AAAA;AAAA,EACjB,GAEMQ,IAAMC,GAAO,GACbC,IAAsBC,GAAuB,GAC7CC,IAAsBC,GAAmB3B,CAAS,GAElD,CAAC4B,GAAUC,CAAW,IAAIC,EAAgC,IAAI,GAC9D,CAACC,GAAOC,CAAQ,IAAIF,EAAiB,GACrC,CAACG,GAAQC,CAAS,IAAIJ,EAAiB,GACvCK,IAAcC,EAAY,CAACC,MAAyB;AACxD,IAAAR,EAAYQ,CAAI;AAAA,EAClB,GAAG,EAAE;AACL,EAAAC,EAAU,MAAM;AACd,QAAI,CAACV,EAAU;AACf,UAAMW,IAAW,IAAI,eAAe,CAACC,MAAY;AAC/C,iBAAWC,KAASD;AACT,QAAAR,EAAAS,EAAM,YAAY,KAAK,GACt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gBAAAA,EAAY;AAAA,wBACd;AAAA,wBACA,kBAAe;AAAA,wBACd,GAAGuC,EAAe;AAAA,0BACjB,gBAAgB;AAAA,wBACjB,CAAA;AAAA,sBAAA;AAAA,oBACH;AAAA,oBACA,gBAAAX;AAAA,sBAAC;AAAA,sBAAA;AAAA,wBACC,WAAWI;AAAA,0BACT1B,EAAI,2BAA2B;AAAA,0BAC/BN,KAAA,gBAAAA,EAAY;AAAA,wBACd;AAAA,wBACA,kBAAe;AAAA,wBACd,GAAGuC,EAAe;AAAA,0BACjB,SAAS;AAAA,0BACT,cAAc;AAAA,0BACd,UAAU,CAACO,MACTF,EAAgCJ,GAASM,CAAM;AAAA,wBAClD,CAAA;AAAA,sBAAA;AAAA,oBACH;AAAA,oBACA,gBAAAlB;AAAA,sBAAC;AAAA,sBAAA;AAAA,wBACC,WAAWI;AAAA,0BACT1B,EAAI,2BAA2B;AAAA,0BAC/BN,KAAA,gBAAAA,EAAY;AAAA,wBACd;AAAA,wBACA,kBAAe;AAAA,wBACd,GAAGuC,EAAe;AAAA,0BACjB,cAAc;AAAA,wBACf,CAAA;AAAA,sBAAA;AAAA,oBAAA;AAAA,kBACH,EACF,CAAA;AAAA,gBAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UAEJ;AAAA,QAAA,EAEJ,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/PopupPanel/component.tsx"],"sourcesContent":["\"use client\";\nimport { useCls, clsx, parseAntdPlacement } from \"../utils\";\nimport { Popover } from \"@base-ui-components/react/popover\";\n\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport Flex from \"antd/es/flex\";\nimport { IconButton } from \"../IconButton\";\nimport { X } from \"@bioturing/assets\";\nimport { PopupPanelSize } from \"./constants\";\nimport { useControlledState } from \"../hooks\";\nimport { useResizable, type MoveValues } from \"react-use-resizable\";\nimport mergeRefs from \"merge-refs\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport interface PopupPanelProps\n extends Omit<\n React.ComponentPropsWithRef<\"div\">,\n \"title\" | \"content\" | \"children\"\n > {\n /** The trigger element that opens the popup panel */\n children?: React.ComponentProps<typeof Popover.Trigger>[\"render\"];\n /** Placement of the popup panel relative to its trigger */\n placement?: PopoverProps[\"placement\"];\n /** Whether to open the popup panel on hover */\n openOnHover?: boolean;\n /** Controls the open state of the popup panel */\n open?: boolean;\n /** Callback fired when the open state changes */\n onOpenChange?: Popover.Root.Props[\"onOpenChange\"];\n /** Content to display inside the popup panel */\n content?: React.ReactNode;\n /** Title text or element to display in the panel header */\n title?: React.ReactNode;\n /** The event that triggers the popup panel */\n /**\n * @default \"click\"\n */\n trigger?: \"click\" | \"hover\";\n /** Custom anchor element for positioning the panel */\n anchor?: Popover.Positioner.Props[\"anchor\"];\n /** Content to display before the close button */\n beforeCloseButton?: React.ReactNode;\n /** Content to display after the close button */\n afterCloseButton?: React.ReactNode;\n /** Content to display after the title */\n afterTitle?: React.ReactNode;\n /**\n * Predefined sizes for the popup panel\n * - xsmall: 320px\n * - small: 400px\n * - medium: 480px (default)\n * - large: 640px\n * - xlarge: 840px\n * @default \"medium\" for default type, \"xsmall\" for other types\n */\n size?: keyof typeof PopupPanelSize;\n /**\n * Footer content for the popup panel\n * Can be a React node or a function that returns a React node\n */\n footer?:\n | React.ReactNode\n | ((props: { close: () => void }) => React.ReactNode);\n /**\n * Whether the panel should be open by default when uncontrolled\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Whether the panel should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Custom class names for different parts of the popup panel\n * @default {}\n */\n classNames?: {\n root?: string;\n trigger?: string;\n popup?: string;\n header?: string;\n title?: string;\n content?: string;\n footer?: string;\n resizeHandle?: string;\n };\n /**\n * Whether to close the panel when clicking outside\n * @default true\n */\n closeOnClickOutside?: boolean;\n /**\n * Whether to use modal mode\n * @default false\n */\n modal?: Popover.Root.Props[\"modal\"];\n}\n\nexport const PopupPanel = ({\n children,\n placement,\n openOnHover = false,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n content,\n title,\n trigger = \"click\",\n className,\n anchor,\n beforeCloseButton,\n afterCloseButton,\n afterTitle,\n size = \"medium\",\n footer,\n defaultOpen,\n resizable = false,\n classNames,\n modal = false,\n closeOnClickOutside = true,\n}: PopupPanelProps) => {\n // Use controlled state with proper initialization to prevent switching between controlled/uncontrolled\n const [open, setOpen] = useControlledState(\n outsideOpen,\n outsideOnOpenChange,\n defaultOpen ?? false // Always provide a default value to prevent undefined\n );\n\n const cls = useCls();\n const headlessUIPlacement = parseAntdPlacement(placement);\n // We don't need triggerRef since we're using callbackRef for the popup\n const [popupRef, setPopupRef] = useState<HTMLDivElement | null>(null);\n const [width, setWidth] = useState<number>();\n const [height, setHeight] = useState<number>();\n const callbackRef = useCallback((node: HTMLDivElement) => {\n setPopupRef(node);\n }, []);\n useEffect(() => {\n if (!popupRef) return;\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n setWidth(entry.contentRect.width);\n setHeight(entry.contentRect.height);\n }\n });\n observer.observe(popupRef);\n return () => {\n observer.disconnect();\n };\n }, [popupRef]);\n\n const defaultCloseIcon = useMemo(() => <X size={16} />, []);\n const renderTitle = useCallback(() => {\n return (\n <div className={clsx(cls(\"popup-panel-header\"), classNames?.header)}>\n <Flex\n align=\"center\"\n gap={8}\n className={cls(\"popup-panel-title-wrapper\")}\n >\n <Popover.Title\n render={\n <div className={clsx(cls(\"grow\", \"truncate\"), classNames?.title)}>\n {title}\n </div>\n }\n ></Popover.Title>\n <div className=\"flex items-center gap-2\">\n {beforeCloseButton}\n <Popover.Close\n render={<IconButton>{defaultCloseIcon}</IconButton>}\n />\n {afterCloseButton}\n </div>\n </Flex>\n {afterTitle ? afterTitle : null}\n </div>\n );\n }, [\n afterCloseButton,\n afterTitle,\n beforeCloseButton,\n cls,\n classNames?.header,\n classNames?.title,\n defaultCloseIcon,\n title,\n ]);\n const [resizing, setResizing] = useState(false);\n const { getRootProps, getHandleProps, rootRef } = useResizable({\n initialWidth: width,\n initialHeight: height,\n onDragStart: () => setResizing(true),\n onDragEnd: () => setResizing(false),\n });\n useEffect(() => {\n if (resizing) {\n document.body.style.userSelect = \"none\";\n } else {\n document.body.style.userSelect = \"\";\n }\n }, [resizing]);\n const { ref: rootRefProp, ...rootPropsWithoutRef } = getRootProps();\n // Handle reverse handle change for vertical resizing\n // Currently not used but kept for future implementation\n // const _onReverseHandleChangeVertical = (\n // parent: React.RefObject<HTMLDivElement>,\n // values: MoveValues\n // ) => {\n // if (!parent.current) return;\n // const { heightDiff } = values;\n // parent.current.style.top = `${\n // parseInt(parent.current.style.top || \"0\") - heightDiff\n // }px`;\n // };\n\n // Handle reverse handle change\n const onReverseHandleChangeHorizontal = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current) return;\n const { widthDiff } = values;\n parent.current.style.left = `${\n parseInt(parent.current.style.left || \"0\") - widthDiff\n }px`;\n };\n\n return (\n <Popover.Root\n openOnHover={trigger === \"hover\" ? true : openOnHover}\n open={open}\n onOpenChange={(open, event, reason) => {\n if (reason === \"outside-press\" && !closeOnClickOutside) return;\n setOpen(open, event, reason);\n }}\n modal={modal}\n >\n <Popover.Trigger\n render={children}\n className={clsx(cls(\"popup-panel-trigger\"), classNames?.trigger)}\n ></Popover.Trigger>\n <Popover.Portal>\n <Popover.Positioner\n className={clsx(cls(\"popup-panel-root\"), classNames?.root)}\n side={headlessUIPlacement.placement}\n align={headlessUIPlacement.align}\n sideOffset={4}\n anchor={anchor}\n style={\n {\n \"--size-width\": size ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n >\n <Popover.Popup\n className={clsx(\n cls(\"popup-panel\"),\n cls(`popup-panel-size-${size}`),\n className,\n classNames?.popup\n )}\n ref={mergeRefs(rootRefProp, callbackRef)}\n {...rootPropsWithoutRef}\n {...(resizing ? { \"data-resizing\": true } : {})}\n >\n {/* <div ref={popupRef}> */}\n {title && renderTitle()}\n <div\n className={clsx(cls(\"popup-panel-content\"), classNames?.content)}\n >\n <div className={cls(\"popup-panel-content-inner\")}>{content}</div>\n </div>\n {footer && (\n <div\n className={clsx(cls(\"popup-panel-footer\"), classNames?.footer)}\n >\n {typeof footer === \"function\"\n ? footer({ close: () => setOpen(false) })\n : footer}\n </div>\n )}\n {resizable && (\n <>\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-left\"\n {...getHandleProps({\n lockHorizontal: true,\n })}\n />\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-left\"\n {...getHandleProps({\n reverse: true,\n lockVertical: true,\n onResize: (values) =>\n onReverseHandleChangeHorizontal(rootRef, values),\n })}\n />\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-right\"\n {...getHandleProps({\n lockVertical: true,\n })}\n />\n </>\n )}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n};\n"],"names":["PopupPanel","children","placement","openOnHover","outsideOpen","outsideOnOpenChange","content","title","trigger","className","anchor","beforeCloseButton","afterCloseButton","afterTitle","size","footer","defaultOpen","resizable","classNames","modal","closeOnClickOutside","open","setOpen","useControlledState","cls","useCls","headlessUIPlacement","parseAntdPlacement","popupRef","setPopupRef","useState","width","setWidth","height","setHeight","callbackRef","useCallback","node","useEffect","observer","entries","entry","defaultCloseIcon","useMemo","jsx","X","renderTitle","jsxs","clsx","Flex","Popover","IconButton","resizing","setResizing","getRootProps","getHandleProps","rootRef","useResizable","rootRefProp","rootPropsWithoutRef","onReverseHandleChangeHorizontal","parent","values","widthDiff","event","reason","PopupPanelSize","mergeRefs","Fragment"],"mappings":";;;;;;;;;;;;;;AAsGO,MAAMA,KAAa,CAAC;A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0BACjB,SAAS;AAAA,0BACT,cAAc;AAAA,0BACd,UAAU,CAACO,MACTF,EAAgCJ,GAASM,CAAM;AAAA,wBAClD,CAAA;AAAA,sBAAA;AAAA,oBACH;AAAA,oBACA,gBAAAlB;AAAA,sBAAC;AAAA,sBAAA;AAAA,wBACC,WAAWI;AAAA,0BACTxB,EAAI,2BAA2B;AAAA,0BAC/BN,KAAA,gBAAAA,EAAY;AAAA,wBACd;AAAA,wBACA,kBAAe;AAAA,wBACd,GAAGqC,EAAe;AAAA,0BACjB,cAAc;AAAA,wBACf,CAAA;AAAA,sBAAA;AAAA,oBAAA;AAAA,kBACH,EACF,CAAA;AAAA,gBAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UAEJ;AAAA,QAAA,EAEJ,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -1,37 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as p } from "react";
|
|
4
|
+
import { cn as n } from "../utils/cn.js";
|
|
5
|
+
import { useCls as u } from "../utils/antdUtils.js";
|
|
6
|
+
const x = p(
|
|
7
|
+
({
|
|
8
|
+
hug: a = !1,
|
|
9
|
+
align: s = "flex-start",
|
|
10
|
+
justify: c = "flex-start",
|
|
11
|
+
vertical: r = !1,
|
|
12
|
+
gap: l = 0,
|
|
13
|
+
wrap: e = !1,
|
|
14
|
+
className: o,
|
|
15
|
+
children: f,
|
|
16
|
+
...i
|
|
17
|
+
}, k) => {
|
|
18
|
+
const t = u();
|
|
19
|
+
return /* @__PURE__ */ m(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
ref: k,
|
|
23
|
+
className: n(
|
|
24
|
+
t("stack"),
|
|
25
|
+
t(a ? "stack-hug" : "stack-fill"),
|
|
26
|
+
t(`stack-gap-${l}`),
|
|
27
|
+
t(r ? "stack-vertical" : "stack-horizontal"),
|
|
28
|
+
e && t("stack-wrap"),
|
|
29
|
+
t(`stack-align-${s}`),
|
|
30
|
+
t(`stack-justify-${c}`),
|
|
31
|
+
o
|
|
32
|
+
),
|
|
33
|
+
...i,
|
|
34
|
+
children: f
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
x.displayName = "Stack";
|
|
34
40
|
export {
|
|
35
|
-
|
|
41
|
+
x as Stack
|
|
36
42
|
};
|
|
37
43
|
//# sourceMappingURL=Stack.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stack.js","sources":["../../../src/components/Stack/Stack.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"Stack.js","sources":["../../../src/components/Stack/Stack.tsx"],"sourcesContent":["\"use client\";\nimport React, { forwardRef } from \"react\";\nimport { cn, useCls } from \"../utils\";\n\nexport type StackGap = 0 | 1 | 2 | 4 | 8 | 12 | 16 | 24 | 28 | 32 | 40 | 48;\n\nexport interface StackProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Whether the stack should hug its content (inline-flex) instead of filling available space\n * @default false\n */\n hug?: boolean;\n\n /**\n * Vertical alignment of items within the stack\n * @default \"flex-start\"\n */\n align?: \"flex-start\" | \"flex-end\" | \"center\" | \"stretch\" | \"baseline\";\n\n /**\n * Horizontal alignment of items within the stack\n * @default \"flex-start\"\n */\n justify?:\n | \"flex-start\"\n | \"flex-end\"\n | \"center\"\n | \"space-between\"\n | \"space-around\"\n | \"space-evenly\";\n\n /**\n * Whether the stack should render items vertically\n * @default false\n */\n vertical?: boolean;\n\n /**\n * Gap between stack items in pixels\n * @default 0\n */\n gap?: StackGap;\n\n /**\n * Wrap items to multiple lines if needed\n * @default false\n */\n wrap?: boolean;\n\n /**\n * Children of the stack\n */\n children?: React.ReactNode;\n}\n\nexport const Stack = forwardRef<HTMLDivElement, StackProps>(\n (\n {\n hug = false,\n align = \"flex-start\",\n justify = \"flex-start\",\n vertical = false,\n gap = 0,\n wrap = false,\n className,\n children,\n ...rest\n },\n ref\n ) => {\n const cls = useCls();\n\n return (\n <div\n ref={ref}\n className={cn(\n cls(\"stack\"),\n hug ? cls(\"stack-hug\") : cls(\"stack-fill\"),\n cls(`stack-gap-${gap}`),\n vertical ? cls(\"stack-vertical\") : cls(\"stack-horizontal\"),\n wrap && cls(\"stack-wrap\"),\n cls(`stack-align-${align}`),\n cls(`stack-justify-${justify}`),\n className\n )}\n {...rest}\n >\n {children}\n </div>\n );\n }\n);\n\nStack.displayName = \"Stack\";\n"],"names":["Stack","forwardRef","hug","align","justify","vertical","gap","wrap","className","children","rest","ref","cls","useCls","jsx","cn"],"mappings":";;;;;AAuDO,MAAMA,IAAQC;AAAA,EACnB,CACE;AAAA,IACE,KAAAC,IAAM;AAAA,IACN,OAAAC,IAAQ;AAAA,IACR,SAAAC,IAAU;AAAA,IACV,UAAAC,IAAW;AAAA,IACX,KAAAC,IAAM;AAAA,IACN,MAAAC,IAAO;AAAA,IACP,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,GAAGC;AAAA,KAELC,MACG;AACH,UAAMC,IAAMC,EAAO;AAGjB,WAAA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAAH;AAAA,QACA,WAAWI;AAAA,UACTH,EAAI,OAAO;AAAA,UACLA,EAANV,IAAU,cAAmB,YAAR;AAAA,UACrBU,EAAI,aAAaN,CAAG,EAAE;AAAA,UACXM,EAAXP,IAAe,mBAAwB,kBAAR;AAAA,UAC/BE,KAAQK,EAAI,YAAY;AAAA,UACxBA,EAAI,eAAeT,CAAK,EAAE;AAAA,UAC1BS,EAAI,iBAAiBR,CAAO,EAAE;AAAA,UAC9BI;AAAA,QACF;AAAA,QACC,GAAGE;AAAA,QAEH,UAAAD;AAAA,MAAA;AAAA,IACH;AAAA,EAAA;AAGN;AAEAT,EAAM,cAAc;"}
|
|
@@ -1,60 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import b, { forwardRef as g } from "react";
|
|
4
|
+
import { useRender as R } from "@base-ui-components/react/use-render";
|
|
5
|
+
import { mergeProps as S } from "@base-ui-components/react/merge-props";
|
|
5
6
|
import { Stack as V } from "./Stack.js";
|
|
6
7
|
import { useCls as v } from "../utils/antdUtils.js";
|
|
7
|
-
import { cn as
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
8
|
+
import { cn as w } from "../utils/cn.js";
|
|
9
|
+
const E = g(
|
|
10
|
+
({
|
|
11
|
+
flex: e,
|
|
12
|
+
grow: l = !1,
|
|
13
|
+
shrink: c = !1,
|
|
14
|
+
children: t,
|
|
15
|
+
style: f,
|
|
16
|
+
stack: m = !1,
|
|
17
|
+
// stack props
|
|
18
|
+
hug: i = !1,
|
|
19
|
+
align: n = "flex-start",
|
|
20
|
+
justify: p = "flex-start",
|
|
21
|
+
vertical: d = !1,
|
|
22
|
+
gap: k = 0,
|
|
23
|
+
wrap: u = !1,
|
|
24
|
+
className: x,
|
|
25
|
+
...h
|
|
26
|
+
}, y) => {
|
|
27
|
+
const s = v(), C = {
|
|
28
|
+
hug: i,
|
|
29
|
+
align: n,
|
|
30
|
+
justify: p,
|
|
31
|
+
vertical: d,
|
|
32
|
+
gap: k,
|
|
33
|
+
wrap: u
|
|
34
|
+
};
|
|
35
|
+
let o = "";
|
|
36
|
+
typeof e == "boolean" && (o = s(e ? "stack-child-flex-1" : "stack-child-flex-0"));
|
|
37
|
+
const a = w(
|
|
38
|
+
s("stack-child"),
|
|
39
|
+
l && s("stack-child-grow"),
|
|
40
|
+
c && s("stack-child-shrink"),
|
|
41
|
+
o,
|
|
42
|
+
x
|
|
43
|
+
), N = R({
|
|
44
|
+
render: () => b.isValidElement(t) ? t : /* @__PURE__ */ r("div", { children: t }),
|
|
45
|
+
ref: y,
|
|
46
|
+
props: S(
|
|
47
|
+
{
|
|
48
|
+
className: a,
|
|
49
|
+
style: {
|
|
50
|
+
...f,
|
|
51
|
+
flex: typeof e == "string" || typeof e == "number" ? e : void 0
|
|
52
|
+
},
|
|
53
|
+
...h
|
|
49
54
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
{}
|
|
56
|
+
)
|
|
57
|
+
});
|
|
58
|
+
return m ? /* @__PURE__ */ r(V, { ...C, className: a, children: t }) : N;
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
E.displayName = "StackChild";
|
|
57
62
|
export {
|
|
58
|
-
|
|
63
|
+
E as StackChild
|
|
59
64
|
};
|
|
60
65
|
//# sourceMappingURL=StackChild.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackChild.js","sources":["../../../src/components/Stack/StackChild.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"StackChild.js","sources":["../../../src/components/Stack/StackChild.tsx"],"sourcesContent":["\"use client\";\nimport React, { forwardRef } from \"react\";\nimport { cn, useCls } from \"../utils\";\nimport { useRender } from \"@base-ui-components/react/use-render\";\nimport { mergeProps } from \"@base-ui-components/react/merge-props\";\nimport { Stack, StackProps } from \"./Stack\";\n\nexport interface StackChildProps extends StackProps {\n /**\n * CSS flex property value (e.g. \"1\", \"1 0 auto\", \"0 1 auto\")\n * When boolean: true = 1, false = 0\n * @default undefined\n */\n flex?: string | number | boolean;\n\n /**\n * Whether this child should grow to fill available space\n * @default false\n */\n grow?: boolean;\n\n /**\n * Whether this child should shrink if necessary\n * @default false\n */\n shrink?: boolean;\n\n /**\n * Children of the stack child\n */\n children?: React.ReactNode;\n /**\n * Whether to render the child with a stack wrapper\n * @default false\n */\n stack?: boolean;\n}\n\nexport const StackChild = forwardRef<HTMLDivElement, StackChildProps>(\n (\n {\n flex,\n grow = false,\n shrink = false,\n children,\n style,\n stack = false,\n // stack props\n hug = false,\n align = \"flex-start\",\n justify = \"flex-start\",\n vertical = false,\n gap = 0,\n wrap = false,\n className,\n ...rest\n },\n ref\n ) => {\n const cls = useCls();\n const stackProps = {\n hug,\n align,\n justify,\n vertical,\n gap,\n wrap,\n };\n\n // Determine flex class based on flex prop type\n let flexClass = \"\";\n if (typeof flex === \"boolean\") {\n flexClass = flex ? cls(\"stack-child-flex-1\") : cls(\"stack-child-flex-0\");\n }\n\n // Calculate the combined className\n const combinedClassName = cn(\n cls(\"stack-child\"),\n grow && cls(\"stack-child-grow\"),\n shrink && cls(\"stack-child-shrink\"),\n flexClass,\n className\n );\n\n // Calculate the flex style value\n const flexValue =\n typeof flex === \"string\" || typeof flex === \"number\" ? flex : undefined;\n\n // Use useRender to apply props directly to the child without creating a wrapper\n const renderedElement = useRender({\n render: () =>\n React.isValidElement(children) ? children : <div>{children}</div>,\n ref,\n props: mergeProps<\"div\">(\n {\n className: combinedClassName,\n style: {\n ...style,\n flex: flexValue,\n },\n ...rest,\n },\n {}\n ),\n });\n\n return stack ? (\n <Stack {...stackProps} className={combinedClassName}>\n {children}\n </Stack>\n ) : (\n renderedElement\n );\n }\n);\n\nStackChild.displayName = \"StackChild\";\n"],"names":["StackChild","forwardRef","flex","grow","shrink","children","style","stack","hug","align","justify","vertical","gap","wrap","className","rest","ref","cls","useCls","stackProps","flexClass","combinedClassName","cn","renderedElement","useRender","React","jsx","mergeProps","Stack"],"mappings":";;;;;;;;AAsCO,MAAMA,IAAaC;AAAA,EACxB,CACE;AAAA,IACE,MAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,QAAAC,IAAS;AAAA,IACT,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,OAAAC,IAAQ;AAAA;AAAA,IAER,KAAAC,IAAM;AAAA,IACN,OAAAC,IAAQ;AAAA,IACR,SAAAC,IAAU;AAAA,IACV,UAAAC,IAAW;AAAA,IACX,KAAAC,IAAM;AAAA,IACN,MAAAC,IAAO;AAAA,IACP,WAAAC;AAAA,IACA,GAAGC;AAAA,KAELC,MACG;AACH,UAAMC,IAAMC,EAAO,GACbC,IAAa;AAAA,MACjB,KAAAX;AAAA,MACA,OAAAC;AAAA,MACA,SAAAC;AAAA,MACA,UAAAC;AAAA,MACA,KAAAC;AAAA,MACA,MAAAC;AAAA,IACF;AAGA,QAAIO,IAAY;AACZ,IAAA,OAAOlB,KAAS,cAClBkB,IAAmBH,EAAPf,IAAW,uBAA4B,oBAAR;AAI7C,UAAMmB,IAAoBC;AAAA,MACxBL,EAAI,aAAa;AAAA,MACjBd,KAAQc,EAAI,kBAAkB;AAAA,MAC9Bb,KAAUa,EAAI,oBAAoB;AAAA,MAClCG;AAAA,MACAN;AAAA,IACF,GAOMS,IAAkBC,EAAU;AAAA,MAChC,QAAQ,MACNC,EAAM,eAAepB,CAAQ,IAAIA,IAAY,gBAAAqB,EAAA,OAAA,EAAK,UAAArB,GAAS;AAAA,MAC7D,KAAAW;AAAA,MACA,OAAOW;AAAA,QACL;AAAA,UACE,WAAWN;AAAA,UACX,OAAO;AAAA,YACL,GAAGf;AAAA,YACH,MAZN,OAAOJ,KAAS,YAAY,OAAOA,KAAS,WAAWA,IAAO;AAAA,UAa1D;AAAA,UACA,GAAGa;AAAA,QACL;AAAA,QACA,CAAA;AAAA,MAAC;AAAA,IACH,CACD;AAEM,WAAAR,sBACJqB,GAAO,EAAA,GAAGT,GAAY,WAAWE,GAC/B,UAAAhB,EACH,CAAA,IAEAkB;AAAA,EAAA;AAGN;AAEAvB,EAAW,cAAc;"}
|
|
@@ -1,31 +1,66 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
2
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as l } from "react";
|
|
4
|
+
import { XIcon as C } from "@bioturing/assets";
|
|
5
|
+
import g from "antd/es/tag";
|
|
5
6
|
import './style.css';/* empty css */
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
import { useCls as i } from "../utils/antdUtils.js";
|
|
8
|
+
import { clsx as p } from "../utils/cn.js";
|
|
9
|
+
const I = l(
|
|
10
|
+
({
|
|
11
|
+
className: a,
|
|
12
|
+
active: e = !1,
|
|
13
|
+
color: o,
|
|
14
|
+
style: s,
|
|
15
|
+
closeIcon: r,
|
|
16
|
+
closable: t,
|
|
17
|
+
size: f = "small",
|
|
18
|
+
children: n,
|
|
19
|
+
...u
|
|
20
|
+
}, T) => {
|
|
21
|
+
const d = /* @__PURE__ */ c(C, { weight: "bold" }), m = i();
|
|
22
|
+
return /* @__PURE__ */ c(
|
|
23
|
+
g,
|
|
24
|
+
{
|
|
25
|
+
ref: T,
|
|
26
|
+
className: p(
|
|
27
|
+
m("tag"),
|
|
28
|
+
m(`tag-${f}`),
|
|
29
|
+
!n && m("tag-empty"),
|
|
30
|
+
a
|
|
31
|
+
),
|
|
32
|
+
color: o,
|
|
33
|
+
style: s,
|
|
34
|
+
closable: t,
|
|
35
|
+
closeIcon: t ? r || d : void 0,
|
|
36
|
+
...e ? { "data-active": "true" } : {},
|
|
37
|
+
...u,
|
|
38
|
+
children: n
|
|
39
|
+
}
|
|
40
|
+
);
|
|
24
41
|
}
|
|
25
|
-
),
|
|
26
|
-
|
|
42
|
+
), b = l(
|
|
43
|
+
({ className: a, size: e = "small", children: o, ...s }, r) => {
|
|
44
|
+
const t = i();
|
|
45
|
+
return /* @__PURE__ */ c(
|
|
46
|
+
g.CheckableTag,
|
|
47
|
+
{
|
|
48
|
+
ref: r,
|
|
49
|
+
className: p(
|
|
50
|
+
t("tag"),
|
|
51
|
+
t(`tag-${e}`),
|
|
52
|
+
!o && t("tag-empty"),
|
|
53
|
+
a
|
|
54
|
+
),
|
|
55
|
+
...s,
|
|
56
|
+
children: o
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
), $ = Object.assign(I, {
|
|
61
|
+
CheckableTag: b
|
|
27
62
|
});
|
|
28
63
|
export {
|
|
29
|
-
|
|
64
|
+
$ as Tag
|
|
30
65
|
};
|
|
31
66
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/Tag/component.tsx"],"sourcesContent":["\"use client\";\nimport {
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/Tag/component.tsx"],"sourcesContent":["\"use client\";\nimport { forwardRef } from \"react\";\nimport { XIcon } from \"@bioturing/assets\";\nimport {\n default as AntTag,\n type CheckableTagProps as AntCheckableTagProps,\n type TagProps as AntTagProps,\n type TagType,\n} from \"antd/es/tag\";\nimport { clsx, useCls } from \"../utils\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport { TagType };\n\n// Define props interface extending Ant Design's TagProps\nexport interface TagProps extends AntTagProps {\n /**\n * Indicates if the tag is active\n * @default false\n */\n active?: boolean;\n /**\n * Size of the tag\n * @default \"small\"\n */\n size?: \"small\" | \"medium\" | \"large\";\n}\n\nexport interface CheckableTagProps extends AntCheckableTagProps {\n size?: \"small\" | \"medium\" | \"large\";\n}\n\n// Create Tag component\nconst InternalTag = forwardRef<HTMLSpanElement, TagProps>(\n (\n {\n className,\n active = false,\n color,\n style,\n closeIcon,\n closable,\n size = \"small\",\n children,\n ...rest\n },\n ref\n ) => {\n const renderedCloseIcon = <XIcon weight=\"bold\" />;\n const cls = useCls();\n return (\n <AntTag\n ref={ref}\n className={clsx(\n cls(\"tag\"),\n cls(`tag-${size}`),\n !children && cls(\"tag-empty\"),\n className\n )}\n color={color}\n style={style}\n closable={closable}\n closeIcon={closable ? closeIcon || renderedCloseIcon : undefined}\n {...(active ? { \"data-active\": \"true\" } : {})}\n {...rest}\n >\n {children}\n </AntTag>\n );\n }\n);\n\nconst CheckableTag = forwardRef<HTMLSpanElement, CheckableTagProps>(\n ({ className, size = \"small\", children, ...rest }, ref) => {\n const cls = useCls();\n return (\n <AntTag.CheckableTag\n ref={ref}\n className={clsx(\n cls(\"tag\"),\n cls(`tag-${size}`),\n !children && cls(\"tag-empty\"),\n className\n )}\n {...rest}\n >\n {children}\n </AntTag.CheckableTag>\n );\n }\n);\n\nexport const Tag = Object.assign(InternalTag, {\n CheckableTag,\n});\n"],"names":["InternalTag","forwardRef","className","active","color","style","closeIcon","closable","size","children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,IACH;AAAA,EAAA;AAGN,GAEaW,IAAM,OAAO,OAAOpB,GAAa;AAAA,EAC5C,cAAAmB;AACF,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.ds-tag{display:inline-flex;align-items:center}.ds-tag[data-active]{background-color:var(--ds-color-primary-bg);border-color:var(--ds-color-primary);color:var(--ds-color-primary)}.ds-tag .ds-tag-close-icon{color:var(--ds-color-icon)}}
|
|
1
|
+
@layer components{.ds-tag{display:inline-flex;align-items:center;font-size:var(--ds-font-size-sm);padding:.0625rem .4375rem}.ds-tag[data-active]{background-color:var(--ds-color-primary-bg);border-color:var(--ds-color-primary);color:var(--ds-color-primary)}.ds-tag .ds-tag-close-icon{color:var(--ds-color-icon)}.ds-tag.ds-tag-medium{padding:.1875rem .4375rem}.ds-tag.ds-tag-large{font-size:var(--ds-font-size);padding:.1875rem .4375rem}.ds-tag:is(.ds-tag-magenta,.ds-tag-red,.ds-tag-volcano,.ds-tag-orange,.ds-tag-gold,.ds-tag-lime,.ds-tag-green,.ds-tag-cyan,.ds-tag-blue,.ds-tag-geekblue,.ds-tag-purple) .ds-tag-close-icon{color:currentColor}.ds-tag.ds-tag-empty .ds-tag-close-icon{margin-left:0}}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import
|
|
4
|
-
import { useLayoutEffect as
|
|
5
|
-
import { lightTheme as
|
|
6
|
-
import { StyleProvider as
|
|
2
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
3
|
+
import f from "antd/es/config-provider";
|
|
4
|
+
import { useLayoutEffect as u, Children as a, isValidElement as p, cloneElement as d } from "react";
|
|
5
|
+
import { lightTheme as v, darkTheme as g } from "../../tokens/and-theme/tokens.js";
|
|
6
|
+
import { StyleProvider as h } from "@ant-design/cssinjs";
|
|
7
7
|
import './style.css';/* empty css */
|
|
8
|
-
import { useCls as
|
|
9
|
-
import { clsx as
|
|
10
|
-
const
|
|
8
|
+
import { useCls as y, useAntdCssVarClassname as x } from "../utils/antdUtils.js";
|
|
9
|
+
import { clsx as n } from "../utils/cn.js";
|
|
10
|
+
const S = ({
|
|
11
11
|
children: t,
|
|
12
|
-
theme:
|
|
12
|
+
theme: s,
|
|
13
13
|
appendClassesTo: r
|
|
14
14
|
}) => {
|
|
15
|
-
const l =
|
|
16
|
-
return
|
|
15
|
+
const c = y(), l = x(), m = n(c("theme-provider"), s.toString(), l);
|
|
16
|
+
return u(() => {
|
|
17
17
|
const e = m.split(" "), o = typeof r == "string" ? document.querySelector(r) : r;
|
|
18
18
|
return o && o.classList.add(...e), () => {
|
|
19
19
|
o && o.classList.remove(...e);
|
|
20
20
|
};
|
|
21
|
-
}, [r, m]), r === void 0 ?
|
|
22
|
-
className:
|
|
21
|
+
}, [r, m]), r === void 0 ? a.map(t, (e) => p(e) ? d(e, {
|
|
22
|
+
className: n(
|
|
23
23
|
e.props.className,
|
|
24
24
|
m
|
|
25
25
|
)
|
|
26
26
|
}) : e) : t;
|
|
27
27
|
}, q = ({
|
|
28
28
|
theme: t,
|
|
29
|
-
appendClassesTo:
|
|
29
|
+
appendClassesTo: s,
|
|
30
30
|
children: r
|
|
31
|
-
}) => /* @__PURE__ */
|
|
32
|
-
|
|
31
|
+
}) => /* @__PURE__ */ i(h, { layer: !0, children: /* @__PURE__ */ i(
|
|
32
|
+
f,
|
|
33
33
|
{
|
|
34
|
-
theme: t == "light" ?
|
|
34
|
+
theme: t == "light" ? v : g,
|
|
35
35
|
prefixCls: "ds",
|
|
36
|
-
children: /* @__PURE__ */
|
|
36
|
+
children: /* @__PURE__ */ i(S, { theme: t, appendClassesTo: s, children: r })
|
|
37
37
|
}
|
|
38
38
|
) });
|
|
39
39
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/ThemeProvider/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n default as ConfigProvider,\n type ConfigProviderProps,\n} from \"antd/es/config-provider\";\nimport { Children, cloneElement, isValidElement, useLayoutEffect } from \"react\";\nimport { darkTheme, lightTheme } from \"../../tokens/and-theme/tokens\";\nimport { useCls, clsx } from \"../utils\";\nimport { StyleProvider } from \"@ant-design/cssinjs\";\n
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/ThemeProvider/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n default as ConfigProvider,\n type ConfigProviderProps,\n} from \"antd/es/config-provider\";\nimport { Children, cloneElement, isValidElement, useLayoutEffect } from \"react\";\nimport { darkTheme, lightTheme } from \"../../tokens/and-theme/tokens\";\nimport { useCls, clsx, useAntdCssVarClassname } from \"../utils\";\nimport { StyleProvider } from \"@ant-design/cssinjs\";\n// Import component-specific styles\nimport \"./style.css\";\n\nexport interface ThemeProviderProps\n extends Omit<ConfigProviderProps, \"theme\" | \"prefixCls\"> {\n theme: \"light\" | \"dark\";\n appendClassesTo?: string | HTMLElement;\n}\n\nconst DSWrapper = ({\n children,\n theme,\n appendClassesTo,\n}: {\n children: React.ReactNode;\n theme: \"light\" | \"dark\";\n appendClassesTo?: string | HTMLElement;\n}) => {\n const cls = useCls();\n const cssVars = useAntdCssVarClassname();\n const className = clsx(cls(\"theme-provider\"), theme.toString(), cssVars);\n useLayoutEffect(() => {\n const classes = className.split(\" \");\n const el =\n typeof appendClassesTo === \"string\"\n ? document.querySelector(appendClassesTo)\n : appendClassesTo;\n if (el) {\n el.classList.add(...classes);\n }\n return () => {\n if (el) {\n el.classList.remove(...classes);\n }\n };\n }, [appendClassesTo, className]);\n return appendClassesTo === undefined\n ? Children.map(children, (child) => {\n if (isValidElement(child))\n return cloneElement(child, {\n className: clsx(\n (child.props as { className?: string }).className,\n className\n ),\n } as { className: string });\n return child;\n })\n : children;\n};\n\nexport const ThemeProvider = ({\n theme,\n appendClassesTo,\n children,\n}: ThemeProviderProps) => {\n return (\n <StyleProvider layer>\n <ConfigProvider\n theme={theme == \"light\" ? lightTheme : darkTheme}\n prefixCls=\"ds\"\n >\n <DSWrapper theme={theme} appendClassesTo={appendClassesTo}>\n {children}\n </DSWrapper>\n </ConfigProvider>\n </StyleProvider>\n );\n};\n"],"names":["DSWrapper","children","theme","appendClassesTo","cls","useCls","cssVars","useAntdCssVarClassname","className","clsx","useLayoutEffect","classes","el","Children","child","isValidElement","cloneElement","ThemeProvider","jsx","StyleProvider","ConfigProvider","lightTheme","darkTheme"],"mappings":";;;;;;;;;AAkBA,MAAMA,IAAY,CAAC;AAAA,EACjB,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,iBAAAC;AACF,MAIM;AACJ,QAAMC,IAAMC,EAAO,GACbC,IAAUC,EAAuB,GACjCC,IAAYC,EAAKL,EAAI,gBAAgB,GAAGF,EAAM,YAAYI,CAAO;AACvE,SAAAI,EAAgB,MAAM;AACd,UAAAC,IAAUH,EAAU,MAAM,GAAG,GAC7BI,IACJ,OAAOT,KAAoB,WACvB,SAAS,cAAcA,CAAe,IACtCA;AACN,WAAIS,KACCA,EAAA,UAAU,IAAI,GAAGD,CAAO,GAEtB,MAAM;AACX,MAAIC,KACCA,EAAA,UAAU,OAAO,GAAGD,CAAO;AAAA,IAElC;AAAA,EAAA,GACC,CAACR,GAAiBK,CAAS,CAAC,GACxBL,MAAoB,SACvBU,EAAS,IAAIZ,GAAU,CAACa,MAClBC,EAAeD,CAAK,IACfE,EAAaF,GAAO;AAAA,IACzB,WAAWL;AAAA,MACRK,EAAM,MAAiC;AAAA,MACxCN;AAAA,IAAA;AAAA,EACF,CACwB,IACrBM,CACR,IACDb;AACN,GAEagB,IAAgB,CAAC;AAAA,EAC5B,OAAAf;AAAA,EACA,iBAAAC;AAAA,EACA,UAAAF;AACF,MAEI,gBAAAiB,EAACC,GAAc,EAAA,OAAK,IAClB,UAAA,gBAAAD;AAAA,EAACE;AAAA,EAAA;AAAA,IACC,OAAOlB,KAAS,UAAUmB,IAAaC;AAAA,IACvC,WAAU;AAAA,IAEV,UAAC,gBAAAJ,EAAAlB,GAAA,EAAU,OAAAE,GAAc,iBAAAC,GACtB,UAAAF,EACH,CAAA;AAAA,EAAA;AAAA,GAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
@layer components{.ds-theme-provider{--ds-modal-padding: 24px;--ds-modal-edge-padding: 16px;--ds-popup-panel-padding: 16px;--ds-scrollbar-width: auto;--ds-scrollbar-width-legacy: 15;--ds-box-shadow-popover-arrow: 0px 0px 1px 0px var(--ds-modal-color-border), 2px 2px 5px rgba(0, 0, 0, .05);--ds-input-color-border-active: var(--ds-color-primary);--ds-input-shadow-active: 0 0 0 2px color-mix(in oklab, var(--ds-color-primary) 20%, transparent);--ds-input-shadow-error-active: 0 0 0 2px color-mix(in oklab, var(--ds-color-error) 20%, transparent);--ds-input-shadow-warning-active: 0 0 0 2px color-mix(in oklab, var(--ds-color-warning) 20%, transparent);--ds-inter: "Inter", Helvetica, Arial, sans-serif;--ds-roboto-mono: "Roboto Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace}@supports (font-variation-settings: normal){.ds-theme-provider{--ds-inter: "InterVariable", Inter, Helvetica, Arial, sans-serif;--ds-roboto-mono: "Roboto Mono Variable", Roboto Mono, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;font-optical-sizing:auto}}.ds-theme-provider{--ds-segment-color-bg-active: #ffffff;--ds-scrollbar-color-thumb: rgba(0, 0, 0, .2);--ds-scrollbar-color-track: rgba(0, 0, 0, 0);--ds-color-base-solid: #000000;--ds-color-table-fixed-column-shadow: rgb(0 0 0 / 10%);--ds-modal-color-border: rgba(0, 0, 0, .24)}.ds-theme-provider.dark{--ds-modal-color-border: rgba(255, 255, 255, .55);--ds-segment-color-bg-active: #424248;--ds-scrollbar-color-thumb: rgba(255, 255, 255, .2);--ds-scrollbar-color-track: rgba(0, 0, 0, 0);--ds-color-base-solid: #ffffff;--ds-color-table-fixed-column-shadow: rgb(0 0 0 / 20%)}}
|