UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

1 lines 3.49 kB
{"version":3,"file":"atoms.mjs","names":["BaseUIToggleGroup","BaseUIToggle"],"sources":["../../../src/base-ui/Segmented/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Toggle as BaseUIToggle } from '@base-ui/react/toggle';\nimport { ToggleGroup as BaseUIToggleGroup } from '@base-ui/react/toggle-group';\nimport { cx } from 'antd-style';\nimport { type ComponentProps, type CSSProperties, type FC, type ReactNode } from 'react';\n\nimport { itemVariants, listVariants, styles } from './style';\nimport type { SegmentedSize, SegmentedVariant } from './type';\n\nexport type SegmentedRootProps<Value extends string = string> = Omit<\n ComponentProps<typeof BaseUIToggleGroup<Value>>,\n 'className' | 'render'\n> & {\n block?: boolean;\n className?: string;\n glass?: boolean;\n shadow?: boolean;\n variant?: SegmentedVariant;\n};\n\nexport const SegmentedRoot = <Value extends string = string>({\n block = false,\n className,\n glass = false,\n shadow = false,\n variant = 'filled',\n ...rest\n}: SegmentedRootProps<Value>) => {\n return (\n <BaseUIToggleGroup<Value>\n className={cx(listVariants({ block, glass, shadow, variant }), className)}\n {...rest}\n />\n );\n};\n\nSegmentedRoot.displayName = 'SegmentedRoot';\n\nexport type SegmentedItemProps<Value extends string = string> = Omit<\n ComponentProps<typeof BaseUIToggle<Value>>,\n 'className' | 'render'\n> & {\n block?: boolean;\n className?: string;\n size?: SegmentedSize;\n};\n\nexport const SegmentedItem = <Value extends string = string>({\n block = false,\n className,\n size = 'middle',\n ...rest\n}: SegmentedItemProps<Value>) => {\n return <BaseUIToggle<Value> className={cx(itemVariants({ block, size }), className)} {...rest} />;\n};\n\nSegmentedItem.displayName = 'SegmentedItem';\n\ninterface SimpleSpanProps {\n children?: ReactNode;\n className?: string;\n style?: CSSProperties;\n}\n\nexport const SegmentedItemIcon: FC<SimpleSpanProps> = ({ children, className, style }) => (\n <span className={cx(styles.itemIcon, className)} style={style}>\n {children}\n </span>\n);\nSegmentedItemIcon.displayName = 'SegmentedItemIcon';\n\nexport const SegmentedItemLabel: FC<SimpleSpanProps> = ({ children, className, style }) => (\n <span className={cx(styles.itemLabel, className)} style={style}>\n {children}\n </span>\n);\nSegmentedItemLabel.displayName = 'SegmentedItemLabel';\n\nexport interface SegmentedIndicatorProps {\n className?: string;\n style?: CSSProperties;\n}\n\nexport const SegmentedIndicator: FC<SegmentedIndicatorProps> = ({ className, style }) => (\n <span aria-hidden className={cx(styles.indicator, className)} style={style} />\n);\nSegmentedIndicator.displayName = 'SegmentedIndicator';\n"],"mappings":";;;;;;;AAqBA,MAAa,iBAAgD,EAC3D,QAAQ,OACR,WACA,QAAQ,OACR,SAAS,OACT,UAAU,UACV,GAAG,WAC4B;AAC/B,QACE,oBAACA,aAAD;EACE,WAAW,GAAG,aAAa;GAAE;GAAO;GAAO;GAAQ;GAAS,CAAC,EAAE,UAAU;EACzE,GAAI;EACJ,CAAA;;AAIN,cAAc,cAAc;AAW5B,MAAa,iBAAgD,EAC3D,QAAQ,OACR,WACA,OAAO,UACP,GAAG,WAC4B;AAC/B,QAAO,oBAACC,QAAD;EAAqB,WAAW,GAAG,aAAa;GAAE;GAAO;GAAM,CAAC,EAAE,UAAU;EAAE,GAAI;EAAQ,CAAA;;AAGnG,cAAc,cAAc;AAQ5B,MAAa,qBAA0C,EAAE,UAAU,WAAW,YAC5E,oBAAC,QAAD;CAAM,WAAW,GAAG,OAAO,UAAU,UAAU;CAAS;CACrD;CACI,CAAA;AAET,kBAAkB,cAAc;AAEhC,MAAa,sBAA2C,EAAE,UAAU,WAAW,YAC7E,oBAAC,QAAD;CAAM,WAAW,GAAG,OAAO,WAAW,UAAU;CAAS;CACtD;CACI,CAAA;AAET,mBAAmB,cAAc;AAOjC,MAAa,sBAAmD,EAAE,WAAW,YAC3E,oBAAC,QAAD;CAAM,eAAA;CAAY,WAAW,GAAG,OAAO,WAAW,UAAU;CAAS;CAAS,CAAA;AAEhF,mBAAmB,cAAc"}