@foxford/ui 2.78.0-beta-e65fe87-20250911 → 2.79.0-beta-f5654ee-20250916
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/components/Button/Button.js +1 -1
- package/components/Button/Button.js.map +1 -1
- package/components/Button/Button.mjs +1 -1
- package/components/Button/Button.mjs.map +1 -1
- package/components/Button/sizes-default.js +2 -0
- package/components/Button/sizes-default.js.map +1 -0
- package/components/Button/sizes-default.mjs +2 -0
- package/components/Button/sizes-default.mjs.map +1 -0
- package/components/Button/sizes.js +2 -0
- package/components/Button/sizes.js.map +1 -0
- package/components/Button/sizes.mjs +2 -0
- package/components/Button/sizes.mjs.map +1 -0
- package/components/Button/style.js +1 -1
- package/components/Button/style.js.map +1 -1
- package/components/Button/style.mjs +1 -1
- package/components/Button/style.mjs.map +1 -1
- package/components/Chip/constants.js +1 -1
- package/components/Chip/constants.js.map +1 -1
- package/components/Chip/constants.mjs +1 -1
- package/components/Chip/constants.mjs.map +1 -1
- package/components/IconButton/IconButton.js +1 -1
- package/components/IconButton/IconButton.js.map +1 -1
- package/components/IconButton/IconButton.mjs +1 -1
- package/components/IconButton/IconButton.mjs.map +1 -1
- package/components/IconButton/sizes.js +2 -0
- package/components/IconButton/sizes.js.map +1 -0
- package/components/IconButton/sizes.mjs +2 -0
- package/components/IconButton/sizes.mjs.map +1 -0
- package/components/Input/constants.js +1 -1
- package/components/Input/constants.js.map +1 -1
- package/components/Input/constants.mjs +1 -1
- package/components/Input/constants.mjs.map +1 -1
- package/components/Notification/constants.js +1 -1
- package/components/Notification/constants.js.map +1 -1
- package/components/Notification/constants.mjs +1 -1
- package/components/Notification/constants.mjs.map +1 -1
- package/components/PopoverComponent/sizes.js +1 -1
- package/components/PopoverComponent/sizes.js.map +1 -1
- package/components/PopoverComponent/sizes.mjs +1 -1
- package/components/PopoverComponent/sizes.mjs.map +1 -1
- package/components/Scrollable/Scrollable.js.map +1 -1
- package/components/Scrollable/Scrollable.mjs.map +1 -1
- package/components/TabList/sizes.js +1 -1
- package/components/TabList/sizes.js.map +1 -1
- package/components/TabList/sizes.mjs +1 -1
- package/components/TabList/sizes.mjs.map +1 -1
- package/components/Text/Text.js +1 -1
- package/components/Text/Text.js.map +1 -1
- package/components/Text/Text.mjs +1 -1
- package/components/Text/Text.mjs.map +1 -1
- package/dts/index.d.ts +319 -108
- package/mixins/responsive-margin.js +1 -1
- package/mixins/responsive-margin.js.map +1 -1
- package/mixins/responsive-margin.mjs +1 -1
- package/mixins/responsive-margin.mjs.map +1 -1
- package/package.json +2 -2
- package/components/Button/constants.js +0 -2
- package/components/Button/constants.js.map +0 -1
- package/components/Button/constants.mjs +0 -2
- package/components/Button/constants.mjs.map +0 -1
- package/components/Button/default-constants.js +0 -2
- package/components/Button/default-constants.js.map +0 -1
- package/components/Button/default-constants.mjs +0 -2
- package/components/Button/default-constants.mjs.map +0 -1
- package/components/IconButton/constants.js +0 -2
- package/components/IconButton/constants.js.map +0 -1
- package/components/IconButton/constants.mjs +0 -2
- package/components/IconButton/constants.mjs.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{SIZES_SQUARE}from'../IconButton/
|
|
1
|
+
import{SIZES_SQUARE}from'../IconButton/sizes.mjs';import{SIZES as SIZES$1}from'../Badge/constants.mjs';const SIZES={xl:{display:'grid',gridTemplateColumns:'1fr',maxWidth:560,minWidth:'min-content',minHeight:60,gap:32,padding:32,borderRadius:16},l:{display:'grid',gridTemplateColumns:'1fr',maxWidth:456,minWidth:'min-content',minHeight:60,gap:24,padding:24,borderRadius:16},m:{display:'grid',gridTemplateColumns:'1fr',maxWidth:352,minWidth:'min-content',minHeight:60,gap:24,padding:24,borderRadius:16},s:{display:'grid',gridTemplateColumns:'1fr',maxWidth:288,minWidth:'min-content',minHeight:60,gap:20,padding:20,borderRadius:14},xs:{display:'grid',gridTemplateColumns:'1fr',maxWidth:224,minWidth:'min-content',minHeight:60,gap:20,padding:20,borderRadius:14}};const SIZES_CLOSE_BUTTON={xl:{...SIZES_SQUARE.xxl},l:{...SIZES_SQUARE.xl},m:{...SIZES_SQUARE.xl},s:{...SIZES_SQUARE.l},xs:{...SIZES_SQUARE.l}};const SIZES_HEADER_BADGE={xl:{...SIZES$1.l},l:{...SIZES$1.l},m:{...SIZES$1.m},s:{...SIZES$1.m},xs:{...SIZES$1.m}};const SIZES_CAPTION={xl:{fontSize:16},l:{fontSize:16},m:{fontSize:14},s:{fontSize:14},xs:{fontSize:14}};const SIZES_TITLE={xl:{fontSize:28},l:{fontSize:24},m:{fontSize:20},s:{fontSize:18},xs:{fontSize:16}};const SIZES_CONTENT={xl:{fontSize:20},l:{fontSize:18},m:{fontSize:16},s:{fontSize:16},xs:{fontSize:14}};export{SIZES,SIZES_CAPTION,SIZES_CLOSE_BUTTON,SIZES_CONTENT,SIZES_HEADER_BADGE,SIZES_TITLE};
|
|
2
2
|
//# sourceMappingURL=sizes.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sizes.mjs","sources":["../../../../src/components/PopoverComponent/sizes.ts"],"sourcesContent":["import type { CSSProperties } from 'react'\nimport { SIZES_SQUARE as SIZES_ICON_BUTTON } from 'components/IconButton'\nimport { SIZES as SIZES_BADGE } from 'components/Badge'\nimport type { Size } from './types'\n\nexport const SIZES: Record<Size, CSSProperties> = {\n xl: {\n display: 'grid',\n gridTemplateColumns: '1fr',\n maxWidth: 560,\n minWidth: 'min-content',\n minHeight: 60,\n gap: 32,\n padding: 32,\n borderRadius: 16,\n },\n l: {\n display: 'grid',\n gridTemplateColumns: '1fr',\n maxWidth: 456,\n minWidth: 'min-content',\n minHeight: 60,\n gap: 24,\n padding: 24,\n borderRadius: 16,\n },\n m: {\n display: 'grid',\n gridTemplateColumns: '1fr',\n maxWidth: 352,\n minWidth: 'min-content',\n minHeight: 60,\n gap: 24,\n padding: 24,\n borderRadius: 16,\n },\n s: {\n display: 'grid',\n gridTemplateColumns: '1fr',\n maxWidth: 288,\n minWidth: 'min-content',\n minHeight: 60,\n gap: 20,\n padding: 20,\n borderRadius: 14,\n },\n xs: {\n display: 'grid',\n gridTemplateColumns: '1fr',\n maxWidth: 224,\n minWidth: 'min-content',\n minHeight: 60,\n gap: 20,\n padding: 20,\n borderRadius: 14,\n },\n}\n\nexport const SIZES_CLOSE_BUTTON: Record<Size, CSSProperties> = {\n xl: { ...SIZES_ICON_BUTTON.xxl },\n l: { ...SIZES_ICON_BUTTON.xl },\n m: { ...SIZES_ICON_BUTTON.xl },\n s: { ...SIZES_ICON_BUTTON.l },\n xs: { ...SIZES_ICON_BUTTON.l },\n}\n\nexport const SIZES_HEADER_BADGE: Record<Size, CSSProperties> = {\n xl: { ...SIZES_BADGE.l },\n l: { ...SIZES_BADGE.l },\n m: { ...SIZES_BADGE.m },\n s: { ...SIZES_BADGE.m },\n xs: { ...SIZES_BADGE.m },\n}\n\nexport const SIZES_CAPTION: Record<Size, CSSProperties> = {\n xl: { fontSize: 16 },\n l: { fontSize: 16 },\n m: { fontSize: 14 },\n s: { fontSize: 14 },\n xs: { fontSize: 14 },\n}\n\nexport const SIZES_TITLE: Record<Size, CSSProperties> = {\n xl: { fontSize: 28 },\n l: { fontSize: 24 },\n m: { fontSize: 20 },\n s: { fontSize: 18 },\n xs: { fontSize: 16 },\n}\n\nexport const SIZES_CONTENT: Record<Size, CSSProperties> = {\n xl: { fontSize: 20 },\n l: { fontSize: 18 },\n m: { fontSize: 16 },\n s: { fontSize: 16 },\n xs: { fontSize: 14 },\n}\n"],"names":["SIZES","xl","display","gridTemplateColumns","maxWidth","minWidth","minHeight","gap","padding","borderRadius","l","m","s","xs","SIZES_CLOSE_BUTTON","SIZES_ICON_BUTTON","xxl","SIZES_HEADER_BADGE","SIZES_BADGE","SIZES_CAPTION","fontSize","SIZES_TITLE","SIZES_CONTENT"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sizes.mjs","sources":["../../../../src/components/PopoverComponent/sizes.ts"],"sourcesContent":["import type { CSSProperties } from 'react'\nimport { SIZES_SQUARE as SIZES_ICON_BUTTON } from 'components/IconButton'\nimport { SIZES as SIZES_BADGE } from 'components/Badge'\nimport type { Size } from './types'\n\nexport const SIZES: Record<Size, CSSProperties> = {\n xl: {\n display: 'grid',\n gridTemplateColumns: '1fr',\n maxWidth: 560,\n minWidth: 'min-content',\n minHeight: 60,\n gap: 32,\n padding: 32,\n borderRadius: 16,\n },\n l: {\n display: 'grid',\n gridTemplateColumns: '1fr',\n maxWidth: 456,\n minWidth: 'min-content',\n minHeight: 60,\n gap: 24,\n padding: 24,\n borderRadius: 16,\n },\n m: {\n display: 'grid',\n gridTemplateColumns: '1fr',\n maxWidth: 352,\n minWidth: 'min-content',\n minHeight: 60,\n gap: 24,\n padding: 24,\n borderRadius: 16,\n },\n s: {\n display: 'grid',\n gridTemplateColumns: '1fr',\n maxWidth: 288,\n minWidth: 'min-content',\n minHeight: 60,\n gap: 20,\n padding: 20,\n borderRadius: 14,\n },\n xs: {\n display: 'grid',\n gridTemplateColumns: '1fr',\n maxWidth: 224,\n minWidth: 'min-content',\n minHeight: 60,\n gap: 20,\n padding: 20,\n borderRadius: 14,\n },\n}\n\nexport const SIZES_CLOSE_BUTTON: Record<Size, CSSProperties> = {\n xl: { ...SIZES_ICON_BUTTON.xxl },\n l: { ...SIZES_ICON_BUTTON.xl },\n m: { ...SIZES_ICON_BUTTON.xl },\n s: { ...SIZES_ICON_BUTTON.l },\n xs: { ...SIZES_ICON_BUTTON.l },\n}\n\nexport const SIZES_HEADER_BADGE: Record<Size, CSSProperties> = {\n xl: { ...SIZES_BADGE.l },\n l: { ...SIZES_BADGE.l },\n m: { ...SIZES_BADGE.m },\n s: { ...SIZES_BADGE.m },\n xs: { ...SIZES_BADGE.m },\n}\n\nexport const SIZES_CAPTION: Record<Size, CSSProperties> = {\n xl: { fontSize: 16 },\n l: { fontSize: 16 },\n m: { fontSize: 14 },\n s: { fontSize: 14 },\n xs: { fontSize: 14 },\n}\n\nexport const SIZES_TITLE: Record<Size, CSSProperties> = {\n xl: { fontSize: 28 },\n l: { fontSize: 24 },\n m: { fontSize: 20 },\n s: { fontSize: 18 },\n xs: { fontSize: 16 },\n}\n\nexport const SIZES_CONTENT: Record<Size, CSSProperties> = {\n xl: { fontSize: 20 },\n l: { fontSize: 18 },\n m: { fontSize: 16 },\n s: { fontSize: 16 },\n xs: { fontSize: 14 },\n}\n"],"names":["SIZES","xl","display","gridTemplateColumns","maxWidth","minWidth","minHeight","gap","padding","borderRadius","l","m","s","xs","SIZES_CLOSE_BUTTON","SIZES_ICON_BUTTON","xxl","SIZES_HEADER_BADGE","SIZES_BADGE","SIZES_CAPTION","fontSize","SIZES_TITLE","SIZES_CONTENT"],"mappings":"uGAKO,MAAMA,MAAqC,CAChDC,GAAI,CACFC,QAAS,OACTC,oBAAqB,MACrBC,SAAU,IACVC,SAAU,cACVC,UAAW,GACXC,IAAK,GACLC,QAAS,GACTC,aAAc,IAEhBC,EAAG,CACDR,QAAS,OACTC,oBAAqB,MACrBC,SAAU,IACVC,SAAU,cACVC,UAAW,GACXC,IAAK,GACLC,QAAS,GACTC,aAAc,IAEhBE,EAAG,CACDT,QAAS,OACTC,oBAAqB,MACrBC,SAAU,IACVC,SAAU,cACVC,UAAW,GACXC,IAAK,GACLC,QAAS,GACTC,aAAc,IAEhBG,EAAG,CACDV,QAAS,OACTC,oBAAqB,MACrBC,SAAU,IACVC,SAAU,cACVC,UAAW,GACXC,IAAK,GACLC,QAAS,GACTC,aAAc,IAEhBI,GAAI,CACFX,QAAS,OACTC,oBAAqB,MACrBC,SAAU,IACVC,SAAU,cACVC,UAAW,GACXC,IAAK,GACLC,QAAS,GACTC,aAAc,KAIX,MAAMK,mBAAkD,CAC7Db,GAAI,IAAKc,aAAkBC,KAC3BN,EAAG,IAAKK,aAAkBd,IAC1BU,EAAG,IAAKI,aAAkBd,IAC1BW,EAAG,IAAKG,aAAkBL,GAC1BG,GAAI,IAAKE,aAAkBL,IAGtB,MAAMO,mBAAkD,CAC7DhB,GAAI,IAAKiB,QAAYR,GACrBA,EAAG,IAAKQ,QAAYR,GACpBC,EAAG,IAAKO,QAAYP,GACpBC,EAAG,IAAKM,QAAYP,GACpBE,GAAI,IAAKK,QAAYP,IAGhB,MAAMQ,cAA6C,CACxDlB,GAAI,CAAEmB,SAAU,IAChBV,EAAG,CAAEU,SAAU,IACfT,EAAG,CAAES,SAAU,IACfR,EAAG,CAAEQ,SAAU,IACfP,GAAI,CAAEO,SAAU,KAGX,MAAMC,YAA2C,CACtDpB,GAAI,CAAEmB,SAAU,IAChBV,EAAG,CAAEU,SAAU,IACfT,EAAG,CAAES,SAAU,IACfR,EAAG,CAAEQ,SAAU,IACfP,GAAI,CAAEO,SAAU,KAGX,MAAME,cAA6C,CACxDrB,GAAI,CAAEmB,SAAU,IAChBV,EAAG,CAAEU,SAAU,IACfT,EAAG,CAAES,SAAU,IACfR,EAAG,CAAEQ,SAAU,IACfP,GAAI,CAAEO,SAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scrollable.js","sources":["../../../../src/components/Scrollable/Scrollable.tsx"],"sourcesContent":["import { PureComponent } from 'react'\nimport { Scrollbars } from 'rc-scrollbars'\nimport type { ScrollbarsProps } from 'rc-scrollbars'\nimport { withTheme } from 'styled-components'\nimport type { DefaultTheme } from 'styled-components'\n\nexport interface ScrollableProps extends Partial<ScrollbarsProps> {\n /**\n * Children react node\n */\n children: React.ReactNode[] | React.ReactNode\n /**\n * Enable auto-hide mode\n * @see See [github docs](https://github.com/sakhnyuk/rc-scrollbars) for description\n */\n autoHide?: boolean\n /**\n * Hide delay in ms.\n */\n autoHideTimeout?: number\n /**\n * Duration for hide animation in ms.\n */\n autoHideDuration?: number\n /**\n * Enable auto-height mode.\n */\n autoHeight?: boolean\n /**\n * Set a minimum height for auto-height mode\n */\n autoHeightMin?: number\n /**\n * Set a maximum height for auto-height mode\n */\n autoHeightMax?: number\n /**\n * Event handler\n */\n onScroll?(): void\n /**\n * Runs inside the animation frame.\n */\n onScrollFrame?(): void\n /**\n * Called when scrolling starts\n */\n onScrollStart?(): void\n /**\n * Called when scrolling stops\n */\n onScrollStop?(): void\n /**\n * Height of shadow\n */\n shadowHeight?: number\n /**\n * Show shadow in scrollable component\n */\n withShadow?: boolean\n /**\n * Color of shadow from #Colors\n */\n shadowColor?: string\n /**\n * Opacity of shadow\n */\n shadowOpacity?: number\n /**\n * Color of thumb\n */\n thumbColor?: string\n /**\n * Opacity of thumb\n */\n thumbOpacity?: number\n /**\n * Border radius of thumb (px)\n */\n thumbBorderRadius?: number\n /**\n /**\n * Border radius of thumb (px)\n */\n thumbWidth?: number\n /**\n * Color of track (HEX)\n */\n trackColor?: string\n /**\n * Opacity of track\n */\n trackOpacity?: number\n /**\n * Border radius of track (px)\n */\n trackBorderRadius?: number\n /**\n /**\n * Border radius of track (px)\n */\n trackWidth?: number\n /**\n * Style for scrollable container\n */\n style?: object\n /**\n * Classname of scrollable container\n */\n className?: string\n /**\n * Disable scrollbar and return div\n */\n disabled?: boolean\n /**\n * Prevent body scrolling when start|end touched\n */\n isolate?: boolean\n\n theme?: DefaultTheme\n}\n\ntype ScrollableState = {\n scrollTop: number\n scrollHeight: number\n clientHeight: number\n}\n\nclass Scrollable extends PureComponent<typeof Scrollable.defaultProps & ScrollableProps, ScrollableState> {\n static displayName = 'Scrollable'\n static defaultProps = {\n autoHide: false,\n autoHideTimeout: 1000,\n autoHideDuration: 200,\n autoHeight: false,\n withShadow: false,\n shadowHeight: 50,\n shadowOpacity: 0.15,\n shadowColor: 'mineShaft',\n thumbColor: 'mineShaft',\n thumbOpacity: 0.15,\n thumbBorderRadius: 1,\n thumbWidth: 4,\n trackColor: '#333333',\n trackOpacity: 0.15,\n trackBorderRadius: 1,\n trackWidth: 4,\n disabled: false,\n isolate: true,\n }\n\n scrollable: HTMLDivElement | null = null\n ts = 0\n\n state = {\n scrollTop: 0,\n scrollHeight: 0,\n clientHeight: 0,\n }\n\n componentDidMount() {\n if (!this.scrollable || !this.scrollable.parentNode) return\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener('touchstart', this.handleTouchStart, false)\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener('touchmove', this.handleTouchMove, false)\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener('wheel', this.handleScroll, false)\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener(\n 'scroll',\n this.handleScroll as (_e: Event) => void,\n false\n )\n }\n\n componentWillUnmount() {\n if (!this.scrollable || !this.scrollable.parentNode) return\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener('touchstart', this.handleTouchStart)\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener('touchmove', this.handleTouchMove)\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener('wheel', this.handleScroll)\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener(\n 'scroll',\n this.handleScroll as (_e: Event) => void\n )\n }\n\n handleTouchStart = (e: TouchEvent) => {\n this.ts = e.touches[0].clientY\n }\n\n handleTouchMove = (e: TouchEvent) => {\n if (!this.props.isolate || !this.scrollable) return true\n\n const scrollarea = this.scrollable.parentNode\n\n if (!scrollarea) return\n\n const te = e.changedTouches[0].clientY\n const dir = this.ts > te ? -1 : 1\n\n const upTouch = dir === 1 && (scrollarea as HTMLDivElement).scrollTop === 0\n const endTouch =\n dir === -1 &&\n Math.floor((scrollarea as HTMLDivElement).scrollTop) ===\n (scrollarea as HTMLDivElement).scrollHeight - (scrollarea as HTMLDivElement).clientHeight\n\n if (upTouch || endTouch) {\n e.preventDefault()\n this.ts = te\n }\n\n return true\n }\n\n handleScroll = (e: WheelEvent) => {\n if (!this.props.isolate || !this.scrollable) return true\n\n const delta = e.deltaY || e.detail\n\n const scrollarea = this.scrollable.parentNode\n\n if (!scrollarea) return\n\n const dir = delta < 0 ? 1 : -1\n\n const upTouch = dir === 1 && (scrollarea as HTMLDivElement).scrollTop === 0\n const endTouch =\n dir === -1 &&\n (scrollarea as HTMLDivElement).scrollTop ===\n (scrollarea as HTMLDivElement).scrollHeight - (scrollarea as HTMLDivElement).clientHeight\n\n if (upTouch || endTouch) {\n e.preventDefault()\n }\n\n return true\n }\n\n handleUpdate = (values: ScrollableState) => {\n const { scrollTop, scrollHeight, clientHeight } = values\n\n this.setState({\n scrollTop,\n scrollHeight,\n clientHeight,\n })\n }\n\n calculateShadowOffset() {\n const { scrollTop, scrollHeight, clientHeight } = this.state\n const { shadowHeight = 50 } = this.props\n\n const diffH = scrollHeight - clientHeight || 0\n\n const a = (scrollTop * 100) / (diffH <= 0 ? 1 : diffH)\n const b = (shadowHeight * a) / 100\n\n return Math.floor(-shadowHeight + b)\n }\n\n hexToRgb = (hex: string) => {\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex)\n\n return result\n ? {\n r: parseInt(result[1], 16),\n g: parseInt(result[2], 16),\n b: parseInt(result[3], 16),\n }\n : null\n }\n\n renderTrack = ({ style, ...props }: { style: React.CSSProperties }, dir: 'vertical' | 'horizontal') => {\n const { trackColor, trackOpacity, trackBorderRadius, trackWidth } = this.props\n\n const hex = trackColor ? this.hexToRgb(trackColor) : null\n\n const trackStyle = {\n background: hex ? `rgba(${hex.r}, ${hex.g}, ${hex.b}, ${trackOpacity})` : `rgba(255,255,255,0)`,\n borderRadius: `${trackBorderRadius}px`,\n zIndex: 14,\n ...(dir === 'vertical'\n ? {\n right: 4,\n top: 2,\n bottom: 2,\n width: `${trackWidth}px`,\n }\n : {\n bottom: 4,\n left: 2,\n right: 2,\n height: `${trackWidth}px`,\n }),\n }\n\n return (\n <div\n style={{\n ...style,\n ...trackStyle,\n }}\n {...props}\n />\n )\n }\n\n renderThumb = ({ style, ...scrollableProps }: { style: React.CSSProperties }) => {\n const { thumbColor, thumbOpacity, thumbBorderRadius, thumbWidth } = this.props\n\n const thumbStyle = {\n opacity: thumbOpacity,\n backgroundColor: (this.props.theme as DefaultTheme).colors[thumbColor as keyof DefaultTheme['colors']],\n borderRadius: `${thumbBorderRadius}px`,\n width: `${thumbWidth}px`,\n }\n\n return <div style={{ ...style, ...thumbStyle }} {...scrollableProps} />\n }\n\n render() {\n const {\n children,\n withShadow,\n shadowHeight,\n shadowColor,\n shadowOpacity,\n className,\n thumbColor, // eslint-disable-line\n thumbOpacity, // eslint-disable-line\n thumbBorderRadius, // eslint-disable-line\n thumbWidth, // eslint-disable-line\n trackColor, // eslint-disable-line\n trackOpacity, // eslint-disable-line\n trackBorderRadius, // eslint-disable-line\n trackWidth, // eslint-disable-line\n isolate, // eslint-disable-line\n style,\n disabled,\n ...props\n } = this.props\n\n if (disabled) return <div>{children}</div>\n\n const { scrollHeight, clientHeight } = this.state\n\n const shadowOffset = this.calculateShadowOffset()\n\n return (\n <div\n style={{\n ...style,\n position: 'relative',\n }}\n className={className}\n >\n {withShadow && scrollHeight > clientHeight && shadowOffset !== -shadowHeight ? (\n <div\n style={{\n position: 'absolute',\n display: 'block',\n height: `${shadowHeight}px`,\n left: 0,\n right: 0,\n top: `-${shadowHeight}px`,\n opacity: shadowOpacity,\n backgroundImage: `linear-gradient(to bottom, ${\n (this.props.theme as DefaultTheme).colors[shadowColor as keyof DefaultTheme['colors']]\n } 20%, rgba(255, 255, 255, 0) 100%)`,\n transform: `translateY(${shadowHeight + shadowOffset}px)`,\n zIndex: 10,\n }}\n />\n ) : null}\n\n {withShadow && scrollHeight > clientHeight && shadowOffset < 0 ? (\n <div\n style={{\n position: 'absolute',\n display: 'block',\n height: `${shadowHeight}px`,\n left: 0,\n right: 0,\n bottom: 0,\n opacity: shadowOpacity,\n backgroundImage: `linear-gradient(to top, ${\n (this.props.theme as DefaultTheme).colors[shadowColor as keyof DefaultTheme['colors']]\n } 20%, rgba(255, 255, 255, 0) 100%)`,\n transform: `translateY(${shadowHeight + shadowOffset}px)`,\n zIndex: 10,\n }}\n />\n ) : null}\n\n <Scrollbars\n renderTrackVertical={(nodeProps) => this.renderTrack({ ...nodeProps }, 'vertical')}\n renderTrackHorizontal={(nodeProps) => this.renderTrack({ ...nodeProps }, 'horizontal')}\n renderThumbHorizontal={this.renderThumb}\n renderThumbVertical={this.renderThumb}\n onUpdate={this.handleUpdate}\n hideTracksWhenNotNeeded\n {...props}\n >\n <div\n ref={(node) => {\n this.scrollable = node\n }}\n >\n {children}\n </div>\n </Scrollbars>\n </div>\n )\n }\n}\n\n/**\n * Scrollable component for create custom scrollable content\n *\n * Based on https://github.com/sakhnyuk/rc-scrollbars\n */\nconst withThemeScrollable = withTheme(Scrollable)\n\nwithThemeScrollable.displayName = 'Scrollable'\n\nexport { withThemeScrollable as Scrollable }\n"],"names":["withThemeScrollable","withTheme","Scrollable","PureComponent","static","autoHide","autoHideTimeout","autoHideDuration","autoHeight","withShadow","shadowHeight","shadowOpacity","shadowColor","thumbColor","thumbOpacity","thumbBorderRadius","thumbWidth","trackColor","trackOpacity","trackBorderRadius","trackWidth","disabled","isolate","scrollable","ts","state","scrollTop","scrollHeight","clientHeight","componentDidMount","this","parentNode","addEventListener","handleTouchStart","handleTouchMove","handleScroll","componentWillUnmount","removeEventListener","e","touches","clientY","props","scrollarea","te","changedTouches","dir","upTouch","endTouch","Math","floor","preventDefault","deltaY","detail","handleUpdate","values","setState","calculateShadowOffset","diffH","hexToRgb","hex","result","exec","r","parseInt","g","b","renderTrack","style","trackStyle","background","borderRadius","zIndex","right","top","bottom","width","left","height","_jsx","renderThumb","scrollableProps","opacity","backgroundColor","theme","colors","render","children","className","jsx","shadowOffset","_jsxs","position","display","backgroundImage","transform","Scrollbars","renderTrackVertical","nodeProps","renderTrackHorizontal","renderThumbHorizontal","renderThumbVertical","onUpdate","hideTracksWhenNotNeeded","ref","node","displayName"],"mappings":"sKAkaA,MAAMA,oBAAsBC,OAASA,UAlSrC,MAAMC,mBAAmBC,MAAAA,cACvBC,mBAAqB,aACrBA,oBAAsB,CACpBC,UAAU,EACVC,gBAAiB,IACjBC,iBAAkB,IAClBC,YAAY,EACZC,YAAY,EACZC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MACXkE,KAAM,EACNJ,MAAO,EACPC,IAAK,IAAI/D,MACTuE,QAAStE,EACTkF,gBAAiB,8BACd/D,KAAKW,MAAM0C,MAAuBC,OAAOxE,uCAE5CkF,UAAW,cAAcpF,EAAe+E,OACxClB,OAAQ,MAGV,KAEH9D,GAAckB,EAAeC,GAAgB6D,EAAe,EAC3DX,WAAAU,IAAA,MAAA,CACErB,MAAO,CACLwB,SAAU,WACVC,QAAS,QACTf,OAAQ,GAAGnE,MACXkE,KAAM,EACNJ,MAAO,EACPE,OAAQ,EACRO,QAAStE,EACTkF,gBAAiB,2BACd/D,KAAKW,MAAM0C,MAAuBC,OAAOxE,uCAE5CkF,UAAW,cAAcpF,EAAe+E,OACxClB,OAAQ,MAGV,KAEJO,WAAAU,IAACO,wBAAU,CACTC,oBAAsBC,GAAcnE,KAAKoC,YAAY,IAAK+B,GAAa,YACvEC,sBAAwBD,GAAcnE,KAAKoC,YAAY,IAAK+B,GAAa,cACzEE,sBAAuBrE,KAAKiD,YAC5BqB,oBAAqBtE,KAAKiD,YAC1BsB,SAAUvE,KAAKuB,aACfiD,yBAAuB,KACnB7D,EAAK6C,SAETR,WAAAU,IAAA,MAAA,CACEe,IAAMC,IACJ1E,KAAKP,WAAaiF,CAAI,EACtBlB,SAEDA,QAKX,IAUFtF,oBAAoByG,YAAc"}
|
|
1
|
+
{"version":3,"file":"Scrollable.js","sources":["../../../../src/components/Scrollable/Scrollable.tsx"],"sourcesContent":["import { PureComponent } from 'react'\nimport { Scrollbars } from 'rc-scrollbars'\nimport type { ScrollbarsProps } from 'rc-scrollbars'\nimport { withTheme } from 'styled-components'\nimport type { DefaultTheme } from 'styled-components'\n\nexport interface ScrollableProps extends Partial<ScrollbarsProps> {\n /**\n * Children react node\n */\n children: React.ReactNode[] | React.ReactNode\n /**\n * Enable auto-hide mode\n * @see See [github docs](https://github.com/sakhnyuk/rc-scrollbars) for description\n */\n autoHide?: boolean\n /**\n * Hide delay in ms.\n */\n autoHideTimeout?: number\n /**\n * Duration for hide animation in ms.\n */\n autoHideDuration?: number\n /**\n * Enable auto-height mode.\n */\n autoHeight?: boolean\n /**\n * Set a minimum height for auto-height mode\n */\n autoHeightMin?: number\n /**\n * Set a maximum height for auto-height mode\n */\n autoHeightMax?: number\n /**\n * Event handler\n */\n onScroll?(): void\n /**\n * Runs inside the animation frame.\n */\n onScrollFrame?(): void\n /**\n * Called when scrolling starts\n */\n onScrollStart?(): void\n /**\n * Called when scrolling stops\n */\n onScrollStop?(): void\n /**\n * Height of shadow\n */\n shadowHeight?: number\n /**\n * Show shadow in scrollable component\n */\n withShadow?: boolean\n /**\n * Color of shadow from #Colors\n */\n shadowColor?: string\n /**\n * Opacity of shadow\n */\n shadowOpacity?: number\n /**\n * Color of thumb\n */\n thumbColor?: string\n /**\n * Opacity of thumb\n */\n thumbOpacity?: number\n /**\n * Border radius of thumb (px)\n */\n thumbBorderRadius?: number\n /**\n /**\n * Border radius of thumb (px)\n */\n thumbWidth?: number\n /**\n * Color of track (HEX)\n */\n trackColor?: string\n /**\n * Opacity of track\n */\n trackOpacity?: number\n /**\n * Border radius of track (px)\n */\n trackBorderRadius?: number\n /**\n /**\n * Border radius of track (px)\n */\n trackWidth?: number\n /**\n * Style for scrollable container\n */\n style?: React.CSSProperties\n /**\n * Classname of scrollable container\n */\n className?: string\n /**\n * Disable scrollbar and return div\n */\n disabled?: boolean\n /**\n * Prevent body scrolling when start|end touched\n */\n isolate?: boolean\n\n theme?: DefaultTheme\n}\n\ntype ScrollableState = {\n scrollTop: number\n scrollHeight: number\n clientHeight: number\n}\n\nclass Scrollable extends PureComponent<typeof Scrollable.defaultProps & ScrollableProps, ScrollableState> {\n static displayName = 'Scrollable'\n static defaultProps = {\n autoHide: false,\n autoHideTimeout: 1000,\n autoHideDuration: 200,\n autoHeight: false,\n withShadow: false,\n shadowHeight: 50,\n shadowOpacity: 0.15,\n shadowColor: 'mineShaft',\n thumbColor: 'mineShaft',\n thumbOpacity: 0.15,\n thumbBorderRadius: 1,\n thumbWidth: 4,\n trackColor: '#333333',\n trackOpacity: 0.15,\n trackBorderRadius: 1,\n trackWidth: 4,\n disabled: false,\n isolate: true,\n }\n\n scrollable: HTMLDivElement | null = null\n ts = 0\n\n state = {\n scrollTop: 0,\n scrollHeight: 0,\n clientHeight: 0,\n }\n\n componentDidMount() {\n if (!this.scrollable || !this.scrollable.parentNode) return\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener('touchstart', this.handleTouchStart, false)\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener('touchmove', this.handleTouchMove, false)\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener('wheel', this.handleScroll, false)\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener(\n 'scroll',\n this.handleScroll as (_e: Event) => void,\n false\n )\n }\n\n componentWillUnmount() {\n if (!this.scrollable || !this.scrollable.parentNode) return\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener('touchstart', this.handleTouchStart)\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener('touchmove', this.handleTouchMove)\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener('wheel', this.handleScroll)\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener(\n 'scroll',\n this.handleScroll as (_e: Event) => void\n )\n }\n\n handleTouchStart = (e: TouchEvent) => {\n this.ts = e.touches[0].clientY\n }\n\n handleTouchMove = (e: TouchEvent) => {\n if (!this.props.isolate || !this.scrollable) return true\n\n const scrollarea = this.scrollable.parentNode\n\n if (!scrollarea) return\n\n const te = e.changedTouches[0].clientY\n const dir = this.ts > te ? -1 : 1\n\n const upTouch = dir === 1 && (scrollarea as HTMLDivElement).scrollTop === 0\n const endTouch =\n dir === -1 &&\n Math.floor((scrollarea as HTMLDivElement).scrollTop) ===\n (scrollarea as HTMLDivElement).scrollHeight - (scrollarea as HTMLDivElement).clientHeight\n\n if (upTouch || endTouch) {\n e.preventDefault()\n this.ts = te\n }\n\n return true\n }\n\n handleScroll = (e: WheelEvent) => {\n if (!this.props.isolate || !this.scrollable) return true\n\n const delta = e.deltaY || e.detail\n\n const scrollarea = this.scrollable.parentNode\n\n if (!scrollarea) return\n\n const dir = delta < 0 ? 1 : -1\n\n const upTouch = dir === 1 && (scrollarea as HTMLDivElement).scrollTop === 0\n const endTouch =\n dir === -1 &&\n (scrollarea as HTMLDivElement).scrollTop ===\n (scrollarea as HTMLDivElement).scrollHeight - (scrollarea as HTMLDivElement).clientHeight\n\n if (upTouch || endTouch) {\n e.preventDefault()\n }\n\n return true\n }\n\n handleUpdate = (values: ScrollableState) => {\n const { scrollTop, scrollHeight, clientHeight } = values\n\n this.setState({\n scrollTop,\n scrollHeight,\n clientHeight,\n })\n }\n\n calculateShadowOffset() {\n const { scrollTop, scrollHeight, clientHeight } = this.state\n const { shadowHeight = 50 } = this.props\n\n const diffH = scrollHeight - clientHeight || 0\n\n const a = (scrollTop * 100) / (diffH <= 0 ? 1 : diffH)\n const b = (shadowHeight * a) / 100\n\n return Math.floor(-shadowHeight + b)\n }\n\n hexToRgb = (hex: string) => {\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex)\n\n return result\n ? {\n r: parseInt(result[1], 16),\n g: parseInt(result[2], 16),\n b: parseInt(result[3], 16),\n }\n : null\n }\n\n renderTrack = ({ style, ...props }: { style: React.CSSProperties }, dir: 'vertical' | 'horizontal') => {\n const { trackColor, trackOpacity, trackBorderRadius, trackWidth } = this.props\n\n const hex = trackColor ? this.hexToRgb(trackColor) : null\n\n const trackStyle = {\n background: hex ? `rgba(${hex.r}, ${hex.g}, ${hex.b}, ${trackOpacity})` : `rgba(255,255,255,0)`,\n borderRadius: `${trackBorderRadius}px`,\n zIndex: 14,\n ...(dir === 'vertical'\n ? {\n right: 4,\n top: 2,\n bottom: 2,\n width: `${trackWidth}px`,\n }\n : {\n bottom: 4,\n left: 2,\n right: 2,\n height: `${trackWidth}px`,\n }),\n }\n\n return (\n <div\n style={{\n ...style,\n ...trackStyle,\n }}\n {...props}\n />\n )\n }\n\n renderThumb = ({ style, ...scrollableProps }: { style: React.CSSProperties }) => {\n const { thumbColor, thumbOpacity, thumbBorderRadius, thumbWidth } = this.props\n\n const thumbStyle = {\n opacity: thumbOpacity,\n backgroundColor: (this.props.theme as DefaultTheme).colors[thumbColor as keyof DefaultTheme['colors']],\n borderRadius: `${thumbBorderRadius}px`,\n width: `${thumbWidth}px`,\n }\n\n return <div style={{ ...style, ...thumbStyle }} {...scrollableProps} />\n }\n\n render() {\n const {\n children,\n withShadow,\n shadowHeight,\n shadowColor,\n shadowOpacity,\n className,\n thumbColor, // eslint-disable-line\n thumbOpacity, // eslint-disable-line\n thumbBorderRadius, // eslint-disable-line\n thumbWidth, // eslint-disable-line\n trackColor, // eslint-disable-line\n trackOpacity, // eslint-disable-line\n trackBorderRadius, // eslint-disable-line\n trackWidth, // eslint-disable-line\n isolate, // eslint-disable-line\n style,\n disabled,\n ...props\n } = this.props\n\n if (disabled) return <div>{children}</div>\n\n const { scrollHeight, clientHeight } = this.state\n\n const shadowOffset = this.calculateShadowOffset()\n\n return (\n <div\n style={{\n ...style,\n position: 'relative',\n }}\n className={className}\n >\n {withShadow && scrollHeight > clientHeight && shadowOffset !== -shadowHeight ? (\n <div\n style={{\n position: 'absolute',\n display: 'block',\n height: `${shadowHeight}px`,\n left: 0,\n right: 0,\n top: `-${shadowHeight}px`,\n opacity: shadowOpacity,\n backgroundImage: `linear-gradient(to bottom, ${\n (this.props.theme as DefaultTheme).colors[shadowColor as keyof DefaultTheme['colors']]\n } 20%, rgba(255, 255, 255, 0) 100%)`,\n transform: `translateY(${shadowHeight + shadowOffset}px)`,\n zIndex: 10,\n }}\n />\n ) : null}\n\n {withShadow && scrollHeight > clientHeight && shadowOffset < 0 ? (\n <div\n style={{\n position: 'absolute',\n display: 'block',\n height: `${shadowHeight}px`,\n left: 0,\n right: 0,\n bottom: 0,\n opacity: shadowOpacity,\n backgroundImage: `linear-gradient(to top, ${\n (this.props.theme as DefaultTheme).colors[shadowColor as keyof DefaultTheme['colors']]\n } 20%, rgba(255, 255, 255, 0) 100%)`,\n transform: `translateY(${shadowHeight + shadowOffset}px)`,\n zIndex: 10,\n }}\n />\n ) : null}\n\n <Scrollbars\n renderTrackVertical={(nodeProps) => this.renderTrack({ ...nodeProps }, 'vertical')}\n renderTrackHorizontal={(nodeProps) => this.renderTrack({ ...nodeProps }, 'horizontal')}\n renderThumbHorizontal={this.renderThumb}\n renderThumbVertical={this.renderThumb}\n onUpdate={this.handleUpdate}\n hideTracksWhenNotNeeded\n {...props}\n >\n <div\n ref={(node) => {\n this.scrollable = node\n }}\n >\n {children}\n </div>\n </Scrollbars>\n </div>\n )\n }\n}\n\n/**\n * Scrollable component for create custom scrollable content\n *\n * Based on https://github.com/sakhnyuk/rc-scrollbars\n */\nconst withThemeScrollable = withTheme(Scrollable)\n\nwithThemeScrollable.displayName = 'Scrollable'\n\nexport { withThemeScrollable as Scrollable }\n"],"names":["withThemeScrollable","withTheme","Scrollable","PureComponent","static","autoHide","autoHideTimeout","autoHideDuration","autoHeight","withShadow","shadowHeight","shadowOpacity","shadowColor","thumbColor","thumbOpacity","thumbBorderRadius","thumbWidth","trackColor","trackOpacity","trackBorderRadius","trackWidth","disabled","isolate","scrollable","ts","state","scrollTop","scrollHeight","clientHeight","componentDidMount","this","parentNode","addEventListener","handleTouchStart","handleTouchMove","handleScroll","componentWillUnmount","removeEventListener","e","touches","clientY","props","scrollarea","te","changedTouches","dir","upTouch","endTouch","Math","floor","preventDefault","deltaY","detail","handleUpdate","values","setState","calculateShadowOffset","diffH","hexToRgb","hex","result","exec","r","parseInt","g","b","renderTrack","style","trackStyle","background","borderRadius","zIndex","right","top","bottom","width","left","height","_jsx","renderThumb","scrollableProps","opacity","backgroundColor","theme","colors","render","children","className","jsx","shadowOffset","_jsxs","position","display","backgroundImage","transform","Scrollbars","renderTrackVertical","nodeProps","renderTrackHorizontal","renderThumbHorizontal","renderThumbVertical","onUpdate","hideT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A,MAAA,CACEvB,MAAO,IACFA,EACHwB,SAAU,YAEZJ,UAAWA,EAAUD,SAEpB7E,CAAAA,GAAckB,EAAeC,GAAgB6D,KAAkB/E,EAC9DoE,WAAAU,IAAA,MAAA,CACErB,MAAO,CACLwB,SAAU,WACVC,QAAS,QACTf,OAAQ,GAAGnE,MACXkE,KAAM,EACNJ,MAAO,EACPC,IAAK,IAAI/D,MACTuE,QAAStE,EACTkF,gBAAiB,8BACd/D,KAAKW,MAAM0C,MAAuBC,OAAOxE,uCAE5CkF,UAAW,cAAcpF,EAAe+E,OACxClB,OAAQ,MAGV,KAEH9D,GAAckB,EAAeC,GAAgB6D,EAAe,EAC3DX,WAAAU,IAAA,MAAA,CACErB,MAAO,CACLwB,SAAU,WACVC,QAAS,QACTf,OAAQ,GAAGnE,MACXkE,KAAM,EACNJ,MAAO,EACPE,OAAQ,EACRO,QAAStE,EACTkF,gBAAiB,2BACd/D,KAAKW,MAAM0C,MAAuBC,OAAOxE,uCAE5CkF,UAAW,cAAcpF,EAAe+E,OACxClB,OAAQ,MAGV,KAEJO,WAAAU,IAACO,wBAAU,CACTC,oBAAsBC,GAAcnE,KAAKoC,YAAY,IAAK+B,GAAa,YACvEC,sBAAwBD,GAAcnE,KAAKoC,YAAY,IAAK+B,GAAa,cACzEE,sBAAuBrE,KAAKiD,YAC5BqB,oBAAqBtE,KAAKiD,YAC1BsB,SAAUvE,KAAKuB,aACfiD,yBAAuB,KACnB7D,EAAK6C,SAETR,WAAAU,IAAA,MAAA,CACEe,IAAMC,IACJ1E,KAAKP,WAAaiF,CAAI,EACtBlB,SAEDA,QAKX,IAUFtF,oBAAoByG,YAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scrollable.mjs","sources":["../../../../src/components/Scrollable/Scrollable.tsx"],"sourcesContent":["import { PureComponent } from 'react'\nimport { Scrollbars } from 'rc-scrollbars'\nimport type { ScrollbarsProps } from 'rc-scrollbars'\nimport { withTheme } from 'styled-components'\nimport type { DefaultTheme } from 'styled-components'\n\nexport interface ScrollableProps extends Partial<ScrollbarsProps> {\n /**\n * Children react node\n */\n children: React.ReactNode[] | React.ReactNode\n /**\n * Enable auto-hide mode\n * @see See [github docs](https://github.com/sakhnyuk/rc-scrollbars) for description\n */\n autoHide?: boolean\n /**\n * Hide delay in ms.\n */\n autoHideTimeout?: number\n /**\n * Duration for hide animation in ms.\n */\n autoHideDuration?: number\n /**\n * Enable auto-height mode.\n */\n autoHeight?: boolean\n /**\n * Set a minimum height for auto-height mode\n */\n autoHeightMin?: number\n /**\n * Set a maximum height for auto-height mode\n */\n autoHeightMax?: number\n /**\n * Event handler\n */\n onScroll?(): void\n /**\n * Runs inside the animation frame.\n */\n onScrollFrame?(): void\n /**\n * Called when scrolling starts\n */\n onScrollStart?(): void\n /**\n * Called when scrolling stops\n */\n onScrollStop?(): void\n /**\n * Height of shadow\n */\n shadowHeight?: number\n /**\n * Show shadow in scrollable component\n */\n withShadow?: boolean\n /**\n * Color of shadow from #Colors\n */\n shadowColor?: string\n /**\n * Opacity of shadow\n */\n shadowOpacity?: number\n /**\n * Color of thumb\n */\n thumbColor?: string\n /**\n * Opacity of thumb\n */\n thumbOpacity?: number\n /**\n * Border radius of thumb (px)\n */\n thumbBorderRadius?: number\n /**\n /**\n * Border radius of thumb (px)\n */\n thumbWidth?: number\n /**\n * Color of track (HEX)\n */\n trackColor?: string\n /**\n * Opacity of track\n */\n trackOpacity?: number\n /**\n * Border radius of track (px)\n */\n trackBorderRadius?: number\n /**\n /**\n * Border radius of track (px)\n */\n trackWidth?: number\n /**\n * Style for scrollable container\n */\n style?: object\n /**\n * Classname of scrollable container\n */\n className?: string\n /**\n * Disable scrollbar and return div\n */\n disabled?: boolean\n /**\n * Prevent body scrolling when start|end touched\n */\n isolate?: boolean\n\n theme?: DefaultTheme\n}\n\ntype ScrollableState = {\n scrollTop: number\n scrollHeight: number\n clientHeight: number\n}\n\nclass Scrollable extends PureComponent<typeof Scrollable.defaultProps & ScrollableProps, ScrollableState> {\n static displayName = 'Scrollable'\n static defaultProps = {\n autoHide: false,\n autoHideTimeout: 1000,\n autoHideDuration: 200,\n autoHeight: false,\n withShadow: false,\n shadowHeight: 50,\n shadowOpacity: 0.15,\n shadowColor: 'mineShaft',\n thumbColor: 'mineShaft',\n thumbOpacity: 0.15,\n thumbBorderRadius: 1,\n thumbWidth: 4,\n trackColor: '#333333',\n trackOpacity: 0.15,\n trackBorderRadius: 1,\n trackWidth: 4,\n disabled: false,\n isolate: true,\n }\n\n scrollable: HTMLDivElement | null = null\n ts = 0\n\n state = {\n scrollTop: 0,\n scrollHeight: 0,\n clientHeight: 0,\n }\n\n componentDidMount() {\n if (!this.scrollable || !this.scrollable.parentNode) return\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener('touchstart', this.handleTouchStart, false)\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener('touchmove', this.handleTouchMove, false)\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener('wheel', this.handleScroll, false)\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener(\n 'scroll',\n this.handleScroll as (_e: Event) => void,\n false\n )\n }\n\n componentWillUnmount() {\n if (!this.scrollable || !this.scrollable.parentNode) return\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener('touchstart', this.handleTouchStart)\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener('touchmove', this.handleTouchMove)\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener('wheel', this.handleScroll)\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener(\n 'scroll',\n this.handleScroll as (_e: Event) => void\n )\n }\n\n handleTouchStart = (e: TouchEvent) => {\n this.ts = e.touches[0].clientY\n }\n\n handleTouchMove = (e: TouchEvent) => {\n if (!this.props.isolate || !this.scrollable) return true\n\n const scrollarea = this.scrollable.parentNode\n\n if (!scrollarea) return\n\n const te = e.changedTouches[0].clientY\n const dir = this.ts > te ? -1 : 1\n\n const upTouch = dir === 1 && (scrollarea as HTMLDivElement).scrollTop === 0\n const endTouch =\n dir === -1 &&\n Math.floor((scrollarea as HTMLDivElement).scrollTop) ===\n (scrollarea as HTMLDivElement).scrollHeight - (scrollarea as HTMLDivElement).clientHeight\n\n if (upTouch || endTouch) {\n e.preventDefault()\n this.ts = te\n }\n\n return true\n }\n\n handleScroll = (e: WheelEvent) => {\n if (!this.props.isolate || !this.scrollable) return true\n\n const delta = e.deltaY || e.detail\n\n const scrollarea = this.scrollable.parentNode\n\n if (!scrollarea) return\n\n const dir = delta < 0 ? 1 : -1\n\n const upTouch = dir === 1 && (scrollarea as HTMLDivElement).scrollTop === 0\n const endTouch =\n dir === -1 &&\n (scrollarea as HTMLDivElement).scrollTop ===\n (scrollarea as HTMLDivElement).scrollHeight - (scrollarea as HTMLDivElement).clientHeight\n\n if (upTouch || endTouch) {\n e.preventDefault()\n }\n\n return true\n }\n\n handleUpdate = (values: ScrollableState) => {\n const { scrollTop, scrollHeight, clientHeight } = values\n\n this.setState({\n scrollTop,\n scrollHeight,\n clientHeight,\n })\n }\n\n calculateShadowOffset() {\n const { scrollTop, scrollHeight, clientHeight } = this.state\n const { shadowHeight = 50 } = this.props\n\n const diffH = scrollHeight - clientHeight || 0\n\n const a = (scrollTop * 100) / (diffH <= 0 ? 1 : diffH)\n const b = (shadowHeight * a) / 100\n\n return Math.floor(-shadowHeight + b)\n }\n\n hexToRgb = (hex: string) => {\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex)\n\n return result\n ? {\n r: parseInt(result[1], 16),\n g: parseInt(result[2], 16),\n b: parseInt(result[3], 16),\n }\n : null\n }\n\n renderTrack = ({ style, ...props }: { style: React.CSSProperties }, dir: 'vertical' | 'horizontal') => {\n const { trackColor, trackOpacity, trackBorderRadius, trackWidth } = this.props\n\n const hex = trackColor ? this.hexToRgb(trackColor) : null\n\n const trackStyle = {\n background: hex ? `rgba(${hex.r}, ${hex.g}, ${hex.b}, ${trackOpacity})` : `rgba(255,255,255,0)`,\n borderRadius: `${trackBorderRadius}px`,\n zIndex: 14,\n ...(dir === 'vertical'\n ? {\n right: 4,\n top: 2,\n bottom: 2,\n width: `${trackWidth}px`,\n }\n : {\n bottom: 4,\n left: 2,\n right: 2,\n height: `${trackWidth}px`,\n }),\n }\n\n return (\n <div\n style={{\n ...style,\n ...trackStyle,\n }}\n {...props}\n />\n )\n }\n\n renderThumb = ({ style, ...scrollableProps }: { style: React.CSSProperties }) => {\n const { thumbColor, thumbOpacity, thumbBorderRadius, thumbWidth } = this.props\n\n const thumbStyle = {\n opacity: thumbOpacity,\n backgroundColor: (this.props.theme as DefaultTheme).colors[thumbColor as keyof DefaultTheme['colors']],\n borderRadius: `${thumbBorderRadius}px`,\n width: `${thumbWidth}px`,\n }\n\n return <div style={{ ...style, ...thumbStyle }} {...scrollableProps} />\n }\n\n render() {\n const {\n children,\n withShadow,\n shadowHeight,\n shadowColor,\n shadowOpacity,\n className,\n thumbColor, // eslint-disable-line\n thumbOpacity, // eslint-disable-line\n thumbBorderRadius, // eslint-disable-line\n thumbWidth, // eslint-disable-line\n trackColor, // eslint-disable-line\n trackOpacity, // eslint-disable-line\n trackBorderRadius, // eslint-disable-line\n trackWidth, // eslint-disable-line\n isolate, // eslint-disable-line\n style,\n disabled,\n ...props\n } = this.props\n\n if (disabled) return <div>{children}</div>\n\n const { scrollHeight, clientHeight } = this.state\n\n const shadowOffset = this.calculateShadowOffset()\n\n return (\n <div\n style={{\n ...style,\n position: 'relative',\n }}\n className={className}\n >\n {withShadow && scrollHeight > clientHeight && shadowOffset !== -shadowHeight ? (\n <div\n style={{\n position: 'absolute',\n display: 'block',\n height: `${shadowHeight}px`,\n left: 0,\n right: 0,\n top: `-${shadowHeight}px`,\n opacity: shadowOpacity,\n backgroundImage: `linear-gradient(to bottom, ${\n (this.props.theme as DefaultTheme).colors[shadowColor as keyof DefaultTheme['colors']]\n } 20%, rgba(255, 255, 255, 0) 100%)`,\n transform: `translateY(${shadowHeight + shadowOffset}px)`,\n zIndex: 10,\n }}\n />\n ) : null}\n\n {withShadow && scrollHeight > clientHeight && shadowOffset < 0 ? (\n <div\n style={{\n position: 'absolute',\n display: 'block',\n height: `${shadowHeight}px`,\n left: 0,\n right: 0,\n bottom: 0,\n opacity: shadowOpacity,\n backgroundImage: `linear-gradient(to top, ${\n (this.props.theme as DefaultTheme).colors[shadowColor as keyof DefaultTheme['colors']]\n } 20%, rgba(255, 255, 255, 0) 100%)`,\n transform: `translateY(${shadowHeight + shadowOffset}px)`,\n zIndex: 10,\n }}\n />\n ) : null}\n\n <Scrollbars\n renderTrackVertical={(nodeProps) => this.renderTrack({ ...nodeProps }, 'vertical')}\n renderTrackHorizontal={(nodeProps) => this.renderTrack({ ...nodeProps }, 'horizontal')}\n renderThumbHorizontal={this.renderThumb}\n renderThumbVertical={this.renderThumb}\n onUpdate={this.handleUpdate}\n hideTracksWhenNotNeeded\n {...props}\n >\n <div\n ref={(node) => {\n this.scrollable = node\n }}\n >\n {children}\n </div>\n </Scrollbars>\n </div>\n )\n }\n}\n\n/**\n * Scrollable component for create custom scrollable content\n *\n * Based on https://github.com/sakhnyuk/rc-scrollbars\n */\nconst withThemeScrollable = withTheme(Scrollable)\n\nwithThemeScrollable.displayName = 'Scrollable'\n\nexport { withThemeScrollable as Scrollable }\n"],"names":["withThemeScrollable","withTheme","Scrollable","PureComponent","static","autoHide","autoHideTimeout","autoHideDuration","autoHeight","withShadow","shadowHeight","shadowOpacity","shadowColor","thumbColor","thumbOpacity","thumbBorderRadius","thumbWidth","trackColor","trackOpacity","trackBorderRadius","trackWidth","disabled","isolate","scrollable","ts","state","scrollTop","scrollHeight","clientHeight","componentDidMount","this","parentNode","addEventListener","handleTouchStart","handleTouchMove","handleScroll","componentWillUnmount","removeEventListener","e","touches","clientY","props","scrollarea","te","changedTouches","dir","upTouch","endTouch","Math","floor","preventDefault","deltaY","detail","handleUpdate","values","setState","calculateShadowOffset","diffH","hexToRgb","hex","result","exec","r","parseInt","g","b","renderTrack","style","trackStyle","background","borderRadius","zIndex","right","top","bottom","width","left","height","_jsx","renderThumb","scrollableProps","opacity","backgroundColor","theme","colors","render","children","className","shadowOffset","_jsxs","position","display","backgroundImage","transform","Scrollbars","renderTrackVertical","nodeProps","renderTrackHorizontal","renderThumbHorizontal","renderThumbVertical","onUpdate","hideTracksWhenNotNeeded","ref","node","displayName"],"mappings":"wJAkaA,MAAMA,oBAAsBC,UAlS5B,MAAMC,mBAAmBC,cACvBC,mBAAqB,aACrBA,oBAAsB,CACpBC,UAAU,EACVC,gBAAiB,IACjBC,iBAAkB,IAClBC,YAAY,EACZC,YAAY,EACZC,aAAc,GACdC,cAAe,IACfC,YAAa,YACbC,WAAY,YACZC,aAAc,IACdC,kBAAmB,EACnBC,WAAY,EACZC,WAAY,UACZC,aAAc,IACdC,kBAAmB,EACnBC,WAAY,EACZC,UAAU,EACVC,SAAS,GAGXC,WAAoC,KACpCC,GAAK,EAELC,MAAQ,CACNC,UAAW,EACXC,aAAc,EACdC,aAAc,GAGhBC,iBAAAA,GACOC,KAAKP,YAAeO,KAAKP,WAAWQ,aACvCD,KAAKP,WAAWQ,WAA8BC,iBAAiB,aAAcF,KAAKG,kBAAkB,GACpGH,KAAKP,WAAWQ,WAA8BC,iBAAiB,YAAaF,KAAKI,iBAAiB,GAClGJ,KAAKP,WAAWQ,WAA8BC,iBAAiB,QAASF,KAAKK,cAAc,GAC3FL,KAAKP,WAAWQ,WAA8BC,iBAC9C,SACAF,KAAKK,cACL,GAEJ,CAEAC,oBAAAA,GACON,KAAKP,YAAeO,KAAKP,WAAWQ,aACvCD,KAAKP,WAAWQ,WAA8BM,oBAAoB,aAAcP,KAAKG,kBACrFH,KAAKP,WAAWQ,WAA8BM,oBAAoB,YAAaP,KAAKI,iBACpFJ,KAAKP,WAAWQ,WAA8BM,oBAAoB,QAASP,KAAKK,cAChFL,KAAKP,WAAWQ,WAA8BM,oBAC9C,SACAP,KAAKK,cAET,CAEAF,iBAAoBK,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ollable.tsx"],"sourcesContent":["import { PureComponent } from 'react'\nimport { Scrollbars } from 'rc-scrollbars'\nimport type { ScrollbarsProps } from 'rc-scrollbars'\nimport { withTheme } from 'styled-components'\nimport type { DefaultTheme } from 'styled-components'\n\nexport interface ScrollableProps extends Partial<ScrollbarsProps> {\n /**\n * Children react node\n */\n children: React.ReactNode[] | React.ReactNode\n /**\n * Enable auto-hide mode\n * @see See [github docs](https://github.com/sakhnyuk/rc-scrollbars) for description\n */\n autoHide?: boolean\n /**\n * Hide delay in ms.\n */\n autoHideTimeout?: number\n /**\n * Duration for hide animation in ms.\n */\n autoHideDuration?: number\n /**\n * Enable auto-height mode.\n */\n autoHeight?: boolean\n /**\n * Set a minimum height for auto-height mode\n */\n autoHeightMin?: number\n /**\n * Set a maximum height for auto-height mode\n */\n autoHeightMax?: number\n /**\n * Event handler\n */\n onScroll?(): void\n /**\n * Runs inside the animation frame.\n */\n onScrollFrame?(): void\n /**\n * Called when scrolling starts\n */\n onScrollStart?(): void\n /**\n * Called when scrolling stops\n */\n onScrollStop?(): void\n /**\n * Height of shadow\n */\n shadowHeight?: number\n /**\n * Show shadow in scrollable component\n */\n withShadow?: boolean\n /**\n * Color of shadow from #Colors\n */\n shadowColor?: string\n /**\n * Opacity of shadow\n */\n shadowOpacity?: number\n /**\n * Color of thumb\n */\n thumbColor?: string\n /**\n * Opacity of thumb\n */\n thumbOpacity?: number\n /**\n * Border radius of thumb (px)\n */\n thumbBorderRadius?: number\n /**\n /**\n * Border radius of thumb (px)\n */\n thumbWidth?: number\n /**\n * Color of track (HEX)\n */\n trackColor?: string\n /**\n * Opacity of track\n */\n trackOpacity?: number\n /**\n * Border radius of track (px)\n */\n trackBorderRadius?: number\n /**\n /**\n * Border radius of track (px)\n */\n trackWidth?: number\n /**\n * Style for scrollable container\n */\n style?: React.CSSProperties\n /**\n * Classname of scrollable container\n */\n className?: string\n /**\n * Disable scrollbar and return div\n */\n disabled?: boolean\n /**\n * Prevent body scrolling when start|end touched\n */\n isolate?: boolean\n\n theme?: DefaultTheme\n}\n\ntype ScrollableState = {\n scrollTop: number\n scrollHeight: number\n clientHeight: number\n}\n\nclass Scrollable extends PureComponent<typeof Scrollable.defaultProps & ScrollableProps, ScrollableState> {\n static displayName = 'Scrollable'\n static defaultProps = {\n autoHide: false,\n autoHideTimeout: 1000,\n autoHideDuration: 200,\n autoHeight: false,\n withShadow: false,\n shadowHeight: 50,\n shadowOpacity: 0.15,\n shadowColor: 'mineShaft',\n thumbColor: 'mineShaft',\n thumbOpacity: 0.15,\n thumbBorderRadius: 1,\n thumbWidth: 4,\n trackColor: '#333333',\n trackOpacity: 0.15,\n trackBorderRadius: 1,\n trackWidth: 4,\n disabled: false,\n isolate: true,\n }\n\n scrollable: HTMLDivElement | null = null\n ts = 0\n\n state = {\n scrollTop: 0,\n scrollHeight: 0,\n clientHeight: 0,\n }\n\n componentDidMount() {\n if (!this.scrollable || !this.scrollable.parentNode) return\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener('touchstart', this.handleTouchStart, false)\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener('touchmove', this.handleTouchMove, false)\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener('wheel', this.handleScroll, false)\n ;(this.scrollable.parentNode as HTMLDivElement).addEventListener(\n 'scroll',\n this.handleScroll as (_e: Event) => void,\n false\n )\n }\n\n componentWillUnmount() {\n if (!this.scrollable || !this.scrollable.parentNode) return\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener('touchstart', this.handleTouchStart)\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener('touchmove', this.handleTouchMove)\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener('wheel', this.handleScroll)\n ;(this.scrollable.parentNode as HTMLDivElement).removeEventListener(\n 'scroll',\n this.handleScroll as (_e: Event) => void\n )\n }\n\n handleTouchStart = (e: TouchEvent) => {\n this.ts = e.touches[0].clientY\n }\n\n handleTouchMove = (e: TouchEvent) => {\n if (!this.props.isolate || !this.scrollable) return true\n\n const scrollarea = this.scrollable.parentNode\n\n if (!scrollarea) return\n\n const te = e.changedTouches[0].clientY\n const dir = this.ts > te ? -1 : 1\n\n const upTouch = dir === 1 && (scrollarea as HTMLDivElement).scrollTop === 0\n const endTouch =\n dir === -1 &&\n Math.floor((scrollarea as HTMLDivElement).scrollTop) ===\n (scrollarea as HTMLDivElement).scrollHeight - (scrollarea as HTMLDivElement).clientHeight\n\n if (upTouch || endTouch) {\n e.preventDefault()\n this.ts = te\n }\n\n return true\n }\n\n handleScroll = (e: WheelEvent) => {\n if (!this.props.isolate || !this.scrollable) return true\n\n const delta = e.deltaY || e.detail\n\n const scrollarea = this.scrollable.parentNode\n\n if (!scrollarea) return\n\n const dir = delta < 0 ? 1 : -1\n\n const upTouch = dir === 1 && (scrollarea as HTMLDivElement).scrollTop === 0\n const endTouch =\n dir === -1 &&\n (scrollarea as HTMLDivElement).scrollTop ===\n (scrollarea as HTMLDivElement).scrollHeight - (scrollarea as HTMLDivElement).clientHeight\n\n if (upTouch || endTouch) {\n e.preventDefault()\n }\n\n return true\n }\n\n handleUpdate = (values: ScrollableState) => {\n const { scrollTop, scrollHeight, clientHeight } = values\n\n this.setState({\n scrollTop,\n scrollHeight,\n clientHeight,\n })\n }\n\n calculateShadowOffset() {\n const { scrollTop, scrollHeight, clientHeight } = this.state\n const { shadowHeight = 50 } = this.props\n\n const diffH = scrollHeight - clientHeight || 0\n\n const a = (scrollTop * 100) / (diffH <= 0 ? 1 : diffH)\n const b = (shadowHeight * a) / 100\n\n return Math.floor(-shadowHeight + b)\n }\n\n hexToRgb = (hex: string) => {\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex)\n\n return result\n ? {\n r: parseInt(result[1], 16),\n g: parseInt(result[2], 16),\n b: parseInt(result[3], 16),\n }\n : null\n }\n\n renderTrack = ({ style, ...props }: { style: React.CSSProperties }, dir: 'vertical' | 'horizontal') => {\n const { trackColor, trackOpacity, trackBorderRadius, trackWidth } = this.props\n\n const hex = trackColor ? this.hexToRgb(trackColor) : null\n\n const trackStyle = {\n background: hex ? `rgba(${hex.r}, ${hex.g}, ${hex.b}, ${trackOpacity})` : `rgba(255,255,255,0)`,\n borderRadius: `${trackBorderRadius}px`,\n zIndex: 14,\n ...(dir === 'vertical'\n ? {\n right: 4,\n top: 2,\n bottom: 2,\n width: `${trackWidth}px`,\n }\n : {\n bottom: 4,\n left: 2,\n right: 2,\n height: `${trackWidth}px`,\n }),\n }\n\n return (\n <div\n style={{\n ...style,\n ...trackStyle,\n }}\n {...props}\n />\n )\n }\n\n renderThumb = ({ style, ...scrollableProps }: { style: React.CSSProperties }) => {\n const { thumbColor, thumbOpacity, thumbBorderRadius, thumbWidth } = this.props\n\n const thumbStyle = {\n opacity: thumbOpacity,\n backgroundColor: (this.props.theme as DefaultTheme).colors[thumbColor as keyof DefaultTheme['colors']],\n borderRadius: `${thumbBorderRadius}px`,\n width: `${thumbWidth}px`,\n }\n\n return <div style={{ ...style, ...thumbStyle }} {...scrollableProps} />\n }\n\n render() {\n const {\n children,\n withShadow,\n shadowHeight,\n shadowColor,\n shadowOpacity,\n className,\n thumbColor, // eslint-disable-line\n thumbOpacity, // eslint-disable-line\n thumbBorderRadius, // eslint-disable-line\n thumbWidth, // eslint-disable-line\n trackColor, // eslint-disable-line\n trackOpacity, // eslint-disable-line\n trackBorderRadius, // eslint-disable-line\n trackWidth, // eslint-disable-line\n isolate, // eslint-disable-line\n style,\n disabled,\n ...props\n } = this.props\n\n if (disabled) return <div>{children}</div>\n\n const { scrollHeight, clientHeight } = this.state\n\n const shadowOffset = this.calculateShadowOffset()\n\n return (\n <div\n style={{\n ...style,\n position: 'relative',\n }}\n className={className}\n >\n {withShadow && scrollHeight > clientHeight && shadowOffset !== -shadowHeight ? (\n <div\n style={{\n position: 'absolute',\n display: 'block',\n height: `${shadowHeight}px`,\n left: 0,\n right: 0,\n top: `-${shadowHeight}px`,\n opacity: shadowOpacity,\n backgroundImage: `linear-gradient(to bottom, ${\n (this.props.theme as DefaultTheme).colors[shadowColor as keyof DefaultTheme['colors']]\n } 20%, rgba(255, 255, 255, 0) 100%)`,\n transform: `translateY(${shadowHeight + shadowOffset}px)`,\n zIndex: 10,\n }}\n />\n ) : null}\n\n {withShadow && scrollHeight > clientHeight && shadowOffset < 0 ? (\n <div\n style={{\n position: 'absolute',\n display: 'block',\n height: `${shadowHeight}px`,\n left: 0,\n right: 0,\n bottom: 0,\n opacity: shadowOpacity,\n backgroundImage: `linear-gradient(to top, ${\n (this.props.theme as DefaultTheme).colors[shadowColor as keyof DefaultTheme['colors']]\n } 20%, rgba(255, 255, 255, 0) 100%)`,\n transform: `translateY(${shadowHeight + shadowOffset}px)`,\n zIndex: 10,\n }}\n />\n ) : null}\n\n <Scrollbars\n renderTrackVertical={(nodeProps) => this.renderTrack({ ...nodeProps }, 'vertical')}\n renderTrackHorizontal={(nodeProps) => this.renderTrack({ ...nodeProps }, 'horizontal')}\n renderThumbHorizontal={this.renderThumb}\n renderThumbVertical={this.renderThumb}\n onUpdate={this.handleUpdate}\n hideTracksWhenNotNeeded\n {...props}\n >\n <div\n ref={(node) => {\n this.scrollable = node\n }}\n >\n {children}\n </div>\n </Scrollbars>\n </div>\n )\n }\n}\n\n/**\n * Scrollable component for create custom scrollable content\n *\n * Based on https://github.com/sakhnyuk/rc-scrollbars\n */\nconst withThemeScrollable = withTheme(Scrollable)\n\nwithThemeScrollable.displayName = 'Scrollable'\n\nexport { withThemeScrollable as Scrollable }\n"],"names":["withThemeScrollable","withTheme","Scrollable","PureComponent","static","autoHide","autoHideTimeout","autoHideDuration","autoHeight","withShadow","shadowHeight","shadowOpacity","shadowColor","thumbColor","thumbOpacity","thumbBorderRadius","thumbWidth","trackColor","trackOpacity","trackBorderRadius","trackWidth","disabled","isolate","scrollable","ts","state","scrollTop","scrollHeight","clientHeight","componentDidMount","this","parentNode","addEventListener","handleTouchStart","handleTouchMove","handleScroll","componentWillUnmount","removeEventListener","e","touches","clientY","props","scrollarea","te","changedTouches","dir","upTouch","endTouch","Math","floor","preventDefault","deltaY","detail","handleUpdate","values","setState","calculateShadowOffset","diffH","hexToRgb","hex","result","exec","r","parseInt","g","b","renderTrack","style","trackStyle","background","borderRadius","zIndex","right","top","bottom","width","left","height","_jsx","renderThumb","scrollableProps","opacity","backgroundColor","theme","colors","render","children","className","shadowOffset","_jsxs","position","display","backgroundImage","transform","Scrollbars","renderTrackVertical","nodeProps","renderTrackHorizontal","renderThumbHorizontal","renderThumbVertical","onUpdate","hideTracksWhenNotNeeded","ref","node","displayName"],"mappings":"wJAkaA,MAAMA,oBAAsBC,UAlS5B,MAAMC,mBAAmBC,cACvBC,mBAAqB,aACrBA,oBAAsB,CACpBC,UAAU,EACVC,gBAAiB,IACjBC,iBAAkB,IAClBC,YAAY,EACZC,YAAY,EACZC,aAAc,GACdC,cAAe,IACfC,YAAa,YACbC,WAAY,YACZC,aAAc,IACdC,kBAAmB,EACnBC,WAAY,EACZC,WAAY,UACZC,aAAc,IACdC,kBAAmB,EACnBC,WAAY,EACZC,UAAU,EACVC,SAAS,GAGXC,WAAoC,KACpCC,GAAK,EAELC,MAAQ,CACNC,UAAW,EACXC,aAAc,EACdC,aAAc,GAGhBC,iBAAAA,GACOC,KAAKP,YAAeO,KAAKP,WAAWQ,aACvCD,KAAKP,WAAWQ,WAA8BC,iBAAiB,aAAcF,KAAKG,kBAAkB,GACpGH,KAAKP,WAAWQ,WAA8BC,iBAAiB,YAAaF,KAAKI,iBAAiB,GAClGJ,KAAKP,WAAWQ,WAA8BC,iBAAiB,QAASF,KAAKK,cAAc,GAC3FL,KAAKP,WAAWQ,WAA8BC,iBAC9C,SACAF,KAAKK,cACL,GAEJ,CAEAC,oBAAAA,GACON,KAAKP,YAAeO,KAAKP,WAAWQ,aACvCD,KAAKP,WAAWQ,WAA8BM,oBAAoB,aAAcP,KAAKG,kBACrFH,KAAKP,WAAWQ,WAA8BM,oBAAoB,YAAaP,KAAKI,i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AKP,WAAagF,CAAI,EACtBjB,SAEDA,QAKX,IAUFtF,oBAAoBwG,YAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var focus=require('../../mixins/focus.js');var
|
|
1
|
+
'use strict';var focus=require('../../mixins/focus.js');var sizes=require('../IconButton/sizes.js');const SIZES_PANEL={l:{padding:focus.focus.padding},m:{padding:focus.focus.padding},s:{padding:focus.focus.padding}};const SIZES_SCROLL_CONTROL={l:sizes.SIZES.xl,m:sizes.SIZES.xl,s:sizes.SIZES.l};exports.SIZES={l:{width:'100%'},m:{width:'100%'},s:{width:'100%'}},exports.SIZES_PANEL=SIZES_PANEL,exports.SIZES_SCROLL_CONTROL=SIZES_SCROLL_CONTROL;
|
|
2
2
|
//# sourceMappingURL=sizes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sizes.js","sources":["../../../../src/components/TabList/sizes.ts"],"sourcesContent":["import { focus } from 'mixins/focus'\nimport { SIZES as SIZES_ICON_BUTTON } from 'components/IconButton'\nimport type { Size } from './types'\n\nexport const SIZES: Record<Size, React.CSSProperties> = {\n l: { width: '100%' },\n m: { width: '100%' },\n s: { width: '100%' },\n}\n\nexport const SIZES_PANEL: Record<Size, React.CSSProperties> = {\n l: { padding: focus.padding },\n m: { padding: focus.padding },\n s: { padding: focus.padding },\n}\n\nexport const SIZES_SCROLL_CONTROL: Record<Size, React.CSSProperties> = {\n l: SIZES_ICON_BUTTON.xl,\n m: SIZES_ICON_BUTTON.xl,\n s: SIZES_ICON_BUTTON.l,\n}\n"],"names":["SIZES_PANEL","l","padding","focus","m","s","SIZES_SCROLL_CONTROL","SIZES_ICON_BUTTON","SIZES","xl","width"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sizes.js","sources":["../../../../src/components/TabList/sizes.ts"],"sourcesContent":["import { focus } from 'mixins/focus'\nimport { SIZES as SIZES_ICON_BUTTON } from 'components/IconButton'\nimport type { Size } from './types'\n\nexport const SIZES: Record<Size, React.CSSProperties> = {\n l: { width: '100%' },\n m: { width: '100%' },\n s: { width: '100%' },\n}\n\nexport const SIZES_PANEL: Record<Size, React.CSSProperties> = {\n l: { padding: focus.padding },\n m: { padding: focus.padding },\n s: { padding: focus.padding },\n}\n\nexport const SIZES_SCROLL_CONTROL: Record<Size, React.CSSProperties> = {\n l: SIZES_ICON_BUTTON.xl,\n m: SIZES_ICON_BUTTON.xl,\n s: SIZES_ICON_BUTTON.l,\n}\n"],"names":["SIZES_PANEL","l","padding","focus","m","s","SIZES_SCROLL_CONTROL","SIZES_ICON_BUTTON","SIZES","xl","width"],"mappings":"oGAUO,MAAMA,YAAiD,CAC5DC,EAAG,CAAEC,QAASC,MAAKA,MAACD,SACpBE,EAAG,CAAEF,QAASC,MAAKA,MAACD,SACpBG,EAAG,CAAEH,QAASC,MAAKA,MAACD,UAGf,MAAMI,qBAA0D,CACrEL,EAAGM,MAAiBC,MAACC,GACrBL,EAAGG,MAAiBC,MAACC,GACrBJ,EAAGE,MAAiBC,MAACP,iBAfiC,CACtDA,EAAG,CAAES,MAAO,QACZN,EAAG,CAAEM,MAAO,QACZL,EAAG,CAAEK,MAAO"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{focus}from'../../mixins/focus.mjs';import{SIZES as SIZES$1}from'../IconButton/
|
|
1
|
+
import{focus}from'../../mixins/focus.mjs';import{SIZES as SIZES$1}from'../IconButton/sizes.mjs';const SIZES={l:{width:'100%'},m:{width:'100%'},s:{width:'100%'}};const SIZES_PANEL={l:{padding:focus.padding},m:{padding:focus.padding},s:{padding:focus.padding}};const SIZES_SCROLL_CONTROL={l:SIZES$1.xl,m:SIZES$1.xl,s:SIZES$1.l};export{SIZES,SIZES_PANEL,SIZES_SCROLL_CONTROL};
|
|
2
2
|
//# sourceMappingURL=sizes.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sizes.mjs","sources":["../../../../src/components/TabList/sizes.ts"],"sourcesContent":["import { focus } from 'mixins/focus'\nimport { SIZES as SIZES_ICON_BUTTON } from 'components/IconButton'\nimport type { Size } from './types'\n\nexport const SIZES: Record<Size, React.CSSProperties> = {\n l: { width: '100%' },\n m: { width: '100%' },\n s: { width: '100%' },\n}\n\nexport const SIZES_PANEL: Record<Size, React.CSSProperties> = {\n l: { padding: focus.padding },\n m: { padding: focus.padding },\n s: { padding: focus.padding },\n}\n\nexport const SIZES_SCROLL_CONTROL: Record<Size, React.CSSProperties> = {\n l: SIZES_ICON_BUTTON.xl,\n m: SIZES_ICON_BUTTON.xl,\n s: SIZES_ICON_BUTTON.l,\n}\n"],"names":["SIZES","l","width","m","s","SIZES_PANEL","padding","focus","SIZES_SCROLL_CONTROL","SIZES_ICON_BUTTON","xl"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sizes.mjs","sources":["../../../../src/components/TabList/sizes.ts"],"sourcesContent":["import { focus } from 'mixins/focus'\nimport { SIZES as SIZES_ICON_BUTTON } from 'components/IconButton'\nimport type { Size } from './types'\n\nexport const SIZES: Record<Size, React.CSSProperties> = {\n l: { width: '100%' },\n m: { width: '100%' },\n s: { width: '100%' },\n}\n\nexport const SIZES_PANEL: Record<Size, React.CSSProperties> = {\n l: { padding: focus.padding },\n m: { padding: focus.padding },\n s: { padding: focus.padding },\n}\n\nexport const SIZES_SCROLL_CONTROL: Record<Size, React.CSSProperties> = {\n l: SIZES_ICON_BUTTON.xl,\n m: SIZES_ICON_BUTTON.xl,\n s: SIZES_ICON_BUTTON.l,\n}\n"],"names":["SIZES","l","width","m","s","SIZES_PANEL","padding","focus","SIZES_SCROLL_CONTROL","SIZES_ICON_BUTTON","xl"],"mappings":"gGAIO,MAAMA,MAA2C,CACtDC,EAAG,CAAEC,MAAO,QACZC,EAAG,CAAED,MAAO,QACZE,EAAG,CAAEF,MAAO,SAGP,MAAMG,YAAiD,CAC5DJ,EAAG,CAAEK,QAASC,MAAMD,SACpBH,EAAG,CAAEG,QAASC,MAAMD,SACpBF,EAAG,CAAEE,QAASC,MAAMD,UAGf,MAAME,qBAA0D,CACrEP,EAAGQ,QAAkBC,GACrBP,EAAGM,QAAkBC,GACrBN,EAAGK,QAAkBR"}
|
package/components/Text/Text.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var React=require('react');var withMergedProps=require('../../hocs/withMergedProps.js');var useClassname=require('../../hooks/useClassname.js');var Ellipsis=require('./Ellipsis.js');var constants=require('./constants.js');var defaultConstants=require('./default-constants.js');var style=require('./style.js');var jsxRuntime=require('react/jsx-runtime');var Text_Heading=require('../Text.Heading/Text.Heading.js');var Text_Ellipse=require('../Text.Ellipse/Text.Ellipse.js');const Text=Object.assign(withMergedProps.withMergedProps(React.forwardRef(((e,s)=>{const t=e.appearance?{...constants.APPEARANCE[e.appearance],...e}:e;const{size:a="m",weight:n="normal",lineHeight:r="m",fontStyle:i="normal",className:l,content:o,children:p,ellipsis:u,expandButtonProps:c,onExpandedChange:x,...d}=t;const E=typeof u=='object'&&u!==null?u:{};const T=useClassname.useClassname("Text",l);return jsxRuntime.jsx(style.Root,{...d,size:a,weight:n,lineHeight:r,fontStyle:i,className:T,ellipsis:u,ref:s,children:u?jsxRuntime.jsx(Ellipsis.Ellipsis,{...E,underline:d.underline,expandButtonProps:c,onExpandedChange:x,children:p
|
|
1
|
+
'use strict';var React=require('react');var withMergedProps=require('../../hocs/withMergedProps.js');var useClassname=require('../../hooks/useClassname.js');var Ellipsis=require('./Ellipsis.js');var constants=require('./constants.js');var defaultConstants=require('./default-constants.js');var style=require('./style.js');var jsxRuntime=require('react/jsx-runtime');var Text_Heading=require('../Text.Heading/Text.Heading.js');var Text_Ellipse=require('../Text.Ellipse/Text.Ellipse.js');const Text=Object.assign(withMergedProps.withMergedProps(React.forwardRef(((e,s)=>{const t=e.appearance?{...constants.APPEARANCE[e.appearance],...e}:e;const{size:a="m",weight:n="normal",lineHeight:r="m",fontStyle:i="normal",className:l,content:o,children:p,ellipsis:u,expandButtonProps:c,onExpandedChange:x,...d}=t;const E=typeof u=='object'&&u!==null?u:{};const T=useClassname.useClassname("Text",l);return jsxRuntime.jsx(style.Root,{...d,size:a,weight:n,lineHeight:r,fontStyle:i,className:T,ellipsis:u,ref:s,children:u?jsxRuntime.jsx(Ellipsis.Ellipsis,{...E,underline:d.underline,expandButtonProps:c,onExpandedChange:x,children:p??o}):p??o})})),{displayName:"Text",sizes:e=>typeof e.appearance=='string'?constants.SIZES[e.appearance]??defaultConstants.SIZES_DEFAULT:defaultConstants.SIZES_DEFAULT}),{Heading:Text_Heading.TextHeading,Ellipse:Text_Ellipse.TextEllipse});exports.COMPONENT_NAME="Text",exports.Text=Text;
|
|
2
2
|
//# sourceMappingURL=Text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.js","sources":["../../../../src/components/Text/Text.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { useClassname } from 'hooks/useClassname'\nimport { TextHeading } from 'components/Text.Heading'\nimport { TextEllipse } from 'components/Text.Ellipse'\nimport { Ellipsis } from './Ellipsis'\nimport type { TextProps } from './types'\nimport { APPEARANCE, SIZES } from './constants'\nimport { SIZES_DEFAULT } from './default-constants'\nimport * as Styled from './style'\n\nconst COMPONENT_NAME = 'Text'\n\n/**\n *\n * Компонент поддерживает все нативные атрибуты рутового элемента.\n *\n * Можно передать \"ref\", который будет ассоциирован с рутовым элементом.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/packages/ui/src/components/Text/types.ts).\n */\nconst Text: React.ForwardRefExoticComponent<TextProps> & { Heading: typeof TextHeading; Ellipse: typeof TextEllipse } =\n Object.assign(\n withMergedProps<TextProps, HTMLElement>(\n forwardRef<HTMLElement, MergedProps<TextProps>>((props, ref) => {\n const textProps = props.appearance ? { ...APPEARANCE[props.appearance], ...props } : props\n\n const {\n size = 'm',\n weight = 'normal',\n lineHeight = 'm',\n fontStyle = 'normal',\n className,\n content,\n children,\n ellipsis,\n expandButtonProps,\n onExpandedChange,\n ...restProps\n } = textProps\n\n const ellipsisProps = typeof ellipsis === 'object' && ellipsis !== null ? ellipsis : {}\n\n const textClassName = useClassname(COMPONENT_NAME, className)\n\n return (\n <Styled.Root\n {...restProps}\n size={size}\n weight={weight}\n lineHeight={lineHeight}\n fontStyle={fontStyle}\n className={textClassName}\n ellipsis={ellipsis}\n ref={ref}\n >\n {ellipsis ? (\n <Ellipsis\n {...ellipsisProps}\n underline={restProps.underline}\n expandButtonProps={expandButtonProps}\n onExpandedChange={onExpandedChange}\n >\n {children
|
|
1
|
+
{"version":3,"file":"Text.js","sources":["../../../../src/components/Text/Text.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { useClassname } from 'hooks/useClassname'\nimport { TextHeading } from 'components/Text.Heading'\nimport { TextEllipse } from 'components/Text.Ellipse'\nimport { Ellipsis } from './Ellipsis'\nimport type { TextProps } from './types'\nimport { APPEARANCE, SIZES } from './constants'\nimport { SIZES_DEFAULT } from './default-constants'\nimport * as Styled from './style'\n\nconst COMPONENT_NAME = 'Text'\n\n/**\n *\n * Компонент поддерживает все нативные атрибуты рутового элемента.\n *\n * Можно передать \"ref\", который будет ассоциирован с рутовым элементом.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/packages/ui/src/components/Text/types.ts).\n */\nconst Text: React.ForwardRefExoticComponent<TextProps> & { Heading: typeof TextHeading; Ellipse: typeof TextEllipse } =\n Object.assign(\n withMergedProps<TextProps, HTMLElement>(\n forwardRef<HTMLElement, MergedProps<TextProps>>((props, ref) => {\n const textProps = props.appearance ? { ...APPEARANCE[props.appearance], ...props } : props\n\n const {\n size = 'm',\n weight = 'normal',\n lineHeight = 'm',\n fontStyle = 'normal',\n className,\n content,\n children,\n ellipsis,\n expandButtonProps,\n onExpandedChange,\n ...restProps\n } = textProps\n\n const ellipsisProps = typeof ellipsis === 'object' && ellipsis !== null ? ellipsis : {}\n\n const textClassName = useClassname(COMPONENT_NAME, className)\n\n return (\n <Styled.Root\n {...restProps}\n size={size}\n weight={weight}\n lineHeight={lineHeight}\n fontStyle={fontStyle}\n className={textClassName}\n ellipsis={ellipsis}\n ref={ref}\n >\n {ellipsis ? (\n <Ellipsis\n {...ellipsisProps}\n underline={restProps.underline}\n expandButtonProps={expandButtonProps}\n onExpandedChange={onExpandedChange}\n >\n {children ?? content}\n </Ellipsis>\n ) : (\n (children ?? content)\n )}\n </Styled.Root>\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: (props) => {\n if (typeof props.appearance === 'string') {\n return SIZES[props.appearance] ?? SIZES_DEFAULT\n }\n\n return SIZES_DEFAULT\n },\n }\n ),\n {\n Heading: TextHeading,\n Ellipse: TextEllipse,\n }\n )\n\nexport { Text, COMPONENT_NAME }\n"],"names":["Text","Object","assign","withMergedProps","forwardRef","props","ref","textProps","appearance","APPEARANCE","size","weight","lineHeight","fontStyle","className","content","children","ellipsis","expandButtonProps","onExpandedChange","restProps","ellipsisProps","textClassName","useClassname","_jsx","Styled","jsx","Ellipsis","underline","displayName","sizes","SIZES","SIZES_DEFAULT","Heading","TextHeading","Ellipse","TextEllipse"],"mappings":"seAwBA,MAAMA,KACJC,OAAOC,OACLC,gBAAAA,gBACEC,MAAAA,YAAgD,CAACC,EAAOC,KACtD,MAAMC,EAAYF,EAAMG,WAAa,IAAKC,UAAUA,WAACJ,EAAMG,eAAgBH,GAAUA,EAErF,MAAMK,KACJA,EAAO,IAAGC,OACVA,EAAS,SAAQC,WACjBA,EAAa,IAAGC,UAChBA,EAAY,SAAQC,UACpBA,EAASC,QACTA,EAAOC,SACPA,EAAQC,SACRA,EAAQC,kBACRA,EAAiBC,iBACjBA,KACGC,GACDb,EAEJ,MAAMc,SAAuBJ,GAAa,UAAYA,IAAa,KAAOA,EAAW,GAErF,MAAMK,EAAgBC,aAAAA,aAlCP,OAkCoCT,GAEnD,OACEU,WAAAA,IAACC,MAAAA,KAAW,IACNL,EACJV,KAAMA,EACNC,OAAQA,EACRC,WAAYA,EACZC,UAAWA,EACXC,UAAWQ,EACXL,SAAUA,EACVX,IAAKA,EAAIU,SAERC,EACCO,WAAAE,IAACC,kBAAQ,IACHN,EACJO,UAAWR,EAAUQ,UACrBV,kBAAmBA,EACnBC,iBAAkBA,EAAiBH,SAElCA,GAAYD,IAGdC,GAAYD,GAEH,IAGlB,CACEc,YA/De,OAgEfC,MAAQzB,UACKA,EAAMG,YAAe,SACvBuB,gBAAM1B,EAAMG,aAAewB,iBAAAA,cAG7BA,iCAIb,CACEC,QAASC,aAAWA,YACpBC,QAASC,aAAAA,qCA3EQ"}
|
package/components/Text/Text.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{forwardRef}from'react';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{useClassname}from'../../hooks/useClassname.mjs';import{Ellipsis}from'./Ellipsis.mjs';import{SIZES,APPEARANCE}from'./constants.mjs';import{SIZES_DEFAULT}from'./default-constants.mjs';import{Root}from'./style.mjs';import{jsx}from'react/jsx-runtime';import{TextHeading}from'../Text.Heading/Text.Heading.mjs';import{TextEllipse}from'../Text.Ellipse/Text.Ellipse.mjs';const COMPONENT_NAME='Text';const Text=Object.assign(withMergedProps(forwardRef(((e,s)=>{const t=e.appearance?{...APPEARANCE[e.appearance],...e}:e;const{size:o="m",weight:n="normal",lineHeight:i="m",fontStyle:r="normal",className:a,content:l,children:p,ellipsis:m,expandButtonProps:E,onExpandedChange:c,...d}=t;const x=typeof m=='object'&&m!==null?m:{};const f=useClassname("Text",a);return jsx(Root,{...d,size:o,weight:n,lineHeight:i,fontStyle:r,className:f,ellipsis:m,ref:s,children:m?jsx(Ellipsis,{...x,underline:d.underline,expandButtonProps:E,onExpandedChange:c,children:p
|
|
1
|
+
import{forwardRef}from'react';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{useClassname}from'../../hooks/useClassname.mjs';import{Ellipsis}from'./Ellipsis.mjs';import{SIZES,APPEARANCE}from'./constants.mjs';import{SIZES_DEFAULT}from'./default-constants.mjs';import{Root}from'./style.mjs';import{jsx}from'react/jsx-runtime';import{TextHeading}from'../Text.Heading/Text.Heading.mjs';import{TextEllipse}from'../Text.Ellipse/Text.Ellipse.mjs';const COMPONENT_NAME='Text';const Text=Object.assign(withMergedProps(forwardRef(((e,s)=>{const t=e.appearance?{...APPEARANCE[e.appearance],...e}:e;const{size:o="m",weight:n="normal",lineHeight:i="m",fontStyle:r="normal",className:a,content:l,children:p,ellipsis:m,expandButtonProps:E,onExpandedChange:c,...d}=t;const x=typeof m=='object'&&m!==null?m:{};const f=useClassname("Text",a);return jsx(Root,{...d,size:o,weight:n,lineHeight:i,fontStyle:r,className:f,ellipsis:m,ref:s,children:m?jsx(Ellipsis,{...x,underline:d.underline,expandButtonProps:E,onExpandedChange:c,children:p??l}):p??l})})),{displayName:"Text",sizes:e=>typeof e.appearance=='string'?SIZES[e.appearance]??SIZES_DEFAULT:SIZES_DEFAULT}),{Heading:TextHeading,Ellipse:TextEllipse});export{COMPONENT_NAME,Text};
|
|
2
2
|
//# sourceMappingURL=Text.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.mjs","sources":["../../../../src/components/Text/Text.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { useClassname } from 'hooks/useClassname'\nimport { TextHeading } from 'components/Text.Heading'\nimport { TextEllipse } from 'components/Text.Ellipse'\nimport { Ellipsis } from './Ellipsis'\nimport type { TextProps } from './types'\nimport { APPEARANCE, SIZES } from './constants'\nimport { SIZES_DEFAULT } from './default-constants'\nimport * as Styled from './style'\n\nconst COMPONENT_NAME = 'Text'\n\n/**\n *\n * Компонент поддерживает все нативные атрибуты рутового элемента.\n *\n * Можно передать \"ref\", который будет ассоциирован с рутовым элементом.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/packages/ui/src/components/Text/types.ts).\n */\nconst Text: React.ForwardRefExoticComponent<TextProps> & { Heading: typeof TextHeading; Ellipse: typeof TextEllipse } =\n Object.assign(\n withMergedProps<TextProps, HTMLElement>(\n forwardRef<HTMLElement, MergedProps<TextProps>>((props, ref) => {\n const textProps = props.appearance ? { ...APPEARANCE[props.appearance], ...props } : props\n\n const {\n size = 'm',\n weight = 'normal',\n lineHeight = 'm',\n fontStyle = 'normal',\n className,\n content,\n children,\n ellipsis,\n expandButtonProps,\n onExpandedChange,\n ...restProps\n } = textProps\n\n const ellipsisProps = typeof ellipsis === 'object' && ellipsis !== null ? ellipsis : {}\n\n const textClassName = useClassname(COMPONENT_NAME, className)\n\n return (\n <Styled.Root\n {...restProps}\n size={size}\n weight={weight}\n lineHeight={lineHeight}\n fontStyle={fontStyle}\n className={textClassName}\n ellipsis={ellipsis}\n ref={ref}\n >\n {ellipsis ? (\n <Ellipsis\n {...ellipsisProps}\n underline={restProps.underline}\n expandButtonProps={expandButtonProps}\n onExpandedChange={onExpandedChange}\n >\n {children
|
|
1
|
+
{"version":3,"file":"Text.mjs","sources":["../../../../src/components/Text/Text.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { useClassname } from 'hooks/useClassname'\nimport { TextHeading } from 'components/Text.Heading'\nimport { TextEllipse } from 'components/Text.Ellipse'\nimport { Ellipsis } from './Ellipsis'\nimport type { TextProps } from './types'\nimport { APPEARANCE, SIZES } from './constants'\nimport { SIZES_DEFAULT } from './default-constants'\nimport * as Styled from './style'\n\nconst COMPONENT_NAME = 'Text'\n\n/**\n *\n * Компонент поддерживает все нативные атрибуты рутового элемента.\n *\n * Можно передать \"ref\", который будет ассоциирован с рутовым элементом.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/packages/ui/src/components/Text/types.ts).\n */\nconst Text: React.ForwardRefExoticComponent<TextProps> & { Heading: typeof TextHeading; Ellipse: typeof TextEllipse } =\n Object.assign(\n withMergedProps<TextProps, HTMLElement>(\n forwardRef<HTMLElement, MergedProps<TextProps>>((props, ref) => {\n const textProps = props.appearance ? { ...APPEARANCE[props.appearance], ...props } : props\n\n const {\n size = 'm',\n weight = 'normal',\n lineHeight = 'm',\n fontStyle = 'normal',\n className,\n content,\n children,\n ellipsis,\n expandButtonProps,\n onExpandedChange,\n ...restProps\n } = textProps\n\n const ellipsisProps = typeof ellipsis === 'object' && ellipsis !== null ? ellipsis : {}\n\n const textClassName = useClassname(COMPONENT_NAME, className)\n\n return (\n <Styled.Root\n {...restProps}\n size={size}\n weight={weight}\n lineHeight={lineHeight}\n fontStyle={fontStyle}\n className={textClassName}\n ellipsis={ellipsis}\n ref={ref}\n >\n {ellipsis ? (\n <Ellipsis\n {...ellipsisProps}\n underline={restProps.underline}\n expandButtonProps={expandButtonProps}\n onExpandedChange={onExpandedChange}\n >\n {children ?? content}\n </Ellipsis>\n ) : (\n (children ?? content)\n )}\n </Styled.Root>\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: (props) => {\n if (typeof props.appearance === 'string') {\n return SIZES[props.appearance] ?? SIZES_DEFAULT\n }\n\n return SIZES_DEFAULT\n },\n }\n ),\n {\n Heading: TextHeading,\n Ellipse: TextEllipse,\n }\n )\n\nexport { Text, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Text","Object","assign","withMergedProps","forwardRef","props","ref","textProps","appearance","APPEARANCE","size","weight","lineHeight","fontStyle","className","content","children","ellipsis","expandButtonProps","onExpandedChange","restProps","ellipsisProps","textClassName","useClassname","_jsx","Styled","Ellipsis","underline","displayName","sizes","SIZES","SIZES_DEFAULT","Heading","TextHeading","Ellipse","TextEllipse"],"mappings":"4cAYMA,MAAAA,eAAiB,OAYvB,MAAMC,KACJC,OAAOC,OACLC,gBACEC,YAAgD,CAACC,EAAOC,KACtD,MAAMC,EAAYF,EAAMG,WAAa,IAAKC,WAAWJ,EAAMG,eAAgBH,GAAUA,EAErF,MAAMK,KACJA,EAAO,IAAGC,OACVA,EAAS,SAAQC,WACjBA,EAAa,IAAGC,UAChBA,EAAY,SAAQC,UACpBA,EAASC,QACTA,EAAOC,SACPA,EAAQC,SACRA,EAAQC,kBACRA,EAAiBC,iBACjBA,KACGC,GACDb,EAEJ,MAAMc,SAAuBJ,GAAa,UAAYA,IAAa,KAAOA,EAAW,GAErF,MAAMK,EAAgBC,aAlCP,OAkCoCT,GAEnD,OACEU,IAACC,KAAW,IACNL,EACJV,KAAMA,EACNC,OAAQA,EACRC,WAAYA,EACZC,UAAWA,EACXC,UAAWQ,EACXL,SAAUA,EACVX,IAAKA,EAAIU,SAERC,EACCO,IAACE,SAAQ,IACHL,EACJM,UAAWP,EAAUO,UACrBT,kBAAmBA,EACnBC,iBAAkBA,EAAiBH,SAElCA,GAAYD,IAGdC,GAAYD,GAEH,IAGlB,CACEa,YA/De,OAgEfC,MAAQxB,UACKA,EAAMG,YAAe,SACvBsB,MAAMzB,EAAMG,aAAeuB,cAG7BA,gBAIb,CACEC,QAASC,YACTC,QAASC"}
|