@consta/uikit 5.6.1 → 5.7.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/__internal__/src/components/Chips/Chips.js +1 -1
- package/__internal__/src/components/Chips/Chips.js.map +1 -1
- package/__internal__/src/components/Informer/Informer.css +1 -1
- package/__internal__/src/components/Informer/Informer.js +1 -1
- package/__internal__/src/components/Informer/Informer.js.map +1 -1
- package/__internal__/src/components/Popover/Popover.d.ts +4 -2
- package/__internal__/src/components/Popover/Popover.js +1 -1
- package/__internal__/src/components/Popover/Popover.js.map +1 -1
- package/__internal__/src/components/Popover/helpers.d.ts +5 -0
- package/__internal__/src/components/Popover/helpers.js +1 -1
- package/__internal__/src/components/Popover/helpers.js.map +1 -1
- package/__internal__/src/components/Popover/usePopoverReposition.js.map +1 -1
- package/__internal__/src/components/Table/TextFilter/TableTextFilter.js +1 -1
- package/__internal__/src/components/Table/TextFilter/TableTextFilter.js.map +1 -1
- package/__internal__/src/components/Tooltip/Tooltip.d.ts +1 -1
- package/__internal__/src/components/Tooltip/Tooltip.js +1 -1
- package/__internal__/src/components/Tooltip/Tooltip.js.map +1 -1
- package/__internal__/src/components/Tooltip/types.d.ts +1 -0
- package/__internal__/src/components/Tooltip/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["items","getItemActive","getItemDisabled","getItemAs","getItemAttributes","getItemIconLeft","getItemIconRight","getItemLabel","getItemRef","getItemStatus","className","interactive","onItemClick","onItemRightIconClick","activeView","size","disabled"];import"./Chips.css";import React,{forwardRef}from"react";import{cn}from"../../utils/bem";import{ChipsItem}from"./ChipsItem";import{withDefaultGetters}from"./helpers";var cnChips=cn("Chips"),ChipsRender=function(a,b){var c=withDefaultGetters(a),d=c.items,e=c.getItemActive,f=c.getItemDisabled,g=c.getItemAs,h=c.getItemAttributes,i=c.getItemIconLeft,j=c.getItemIconRight,k=c.getItemLabel,l=c.getItemRef,m=c.getItemStatus,n=c.className,o=c.interactive,p=c.onItemClick,q=c.onItemRightIconClick,r=c.activeView,s=c.size,t=c.disabled,u=_objectWithoutProperties(c,_excluded);return React.createElement("div",Object.assign({},u,{ref:b,className:cnChips(null,[n])}),d.map(function(a,b){var c=f(a)||void 0!==t&&t;return React.createElement(ChipsItem,Object.assign({},h(a),{key:b,size:s,activeView:r,onClick:p&&!c?function(b){return p(a,{e:b})}:void 0,onRightIconClick:q
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["items","getItemActive","getItemDisabled","getItemAs","getItemAttributes","getItemIconLeft","getItemIconRight","getItemLabel","getItemRef","getItemStatus","className","interactive","onItemClick","onItemRightIconClick","activeView","size","disabled"];import"./Chips.css";import React,{forwardRef}from"react";import{cn}from"../../utils/bem";import{ChipsItem}from"./ChipsItem";import{withDefaultGetters}from"./helpers";var cnChips=cn("Chips"),ChipsRender=function(a,b){var c=withDefaultGetters(a),d=c.items,e=c.getItemActive,f=c.getItemDisabled,g=c.getItemAs,h=c.getItemAttributes,i=c.getItemIconLeft,j=c.getItemIconRight,k=c.getItemLabel,l=c.getItemRef,m=c.getItemStatus,n=c.className,o=c.interactive,p=c.onItemClick,q=c.onItemRightIconClick,r=c.activeView,s=c.size,t=c.disabled,u=_objectWithoutProperties(c,_excluded);return React.createElement("div",Object.assign({},u,{ref:b,className:cnChips(null,[n])}),d.map(function(a,b){var c=f(a)||void 0!==t&&t;return React.createElement(ChipsItem,Object.assign({},h(a),{key:b,size:s,activeView:r,onClick:p&&!c?function(b){return p(a,{e:b})}:void 0,onRightIconClick:q&&!c?function(b){return q(a,{e:b})}:void 0,label:k(a),as:g(a),active:e(a),iconLeft:i(a),iconRight:j(a),ref:l(a),status:m(a),interactive:!c&&o,disabled:c}))}))};export var Chips=forwardRef(ChipsRender);
|
|
2
2
|
//# sourceMappingURL=Chips.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chips.js","names":["React","forwardRef","cn","ChipsItem","withDefaultGetters","cnChips","ChipsRender","props","ref","items","getItemActive","getItemDisabled","getItemAs","getItemAttributes","getItemIconLeft","getItemIconRight","getItemLabel","getItemRef","getItemStatus","className","interactive","onItemClick","onItemRightIconClick","activeView","size","disabled","otherProps","map","item","index","itemDisabled","e","Chips"],"sources":["../../../../../src/components/Chips/Chips.tsx"],"sourcesContent":["import './Chips.css';\n\nimport React, { forwardRef } from 'react';\n\nimport { cn } from '##/utils/bem';\n\nimport { ChipsItem } from './ChipsItem';\nimport { withDefaultGetters } from './helpers';\nimport { ChipsComponent, ChipsProps } from './types';\n\nconst cnChips = cn('Chips');\n\nconst ChipsRender = (props: ChipsProps, ref: React.Ref<HTMLDivElement>) => {\n const {\n items,\n getItemActive,\n getItemDisabled,\n getItemAs,\n getItemAttributes,\n getItemIconLeft,\n getItemIconRight,\n getItemLabel,\n getItemRef,\n getItemStatus,\n className,\n interactive,\n onItemClick,\n onItemRightIconClick,\n activeView,\n size,\n disabled = false,\n ...otherProps\n } = withDefaultGetters(props);\n\n return (\n <div {...otherProps} ref={ref} className={cnChips(null, [className])}>\n {items.map((item, index) => {\n const itemDisabled = getItemDisabled(item) || disabled;\n return (\n <ChipsItem\n {...getItemAttributes(item)}\n key={index}\n size={size}\n activeView={activeView}\n onClick={\n onItemClick && !itemDisabled\n ? (e: React.MouseEvent) => onItemClick(item, { e })\n : undefined\n }\n onRightIconClick={\n onItemRightIconClick && itemDisabled\n ? (e: React.MouseEvent) => onItemRightIconClick(item, { e })\n : undefined\n }\n label={getItemLabel(item)}\n as={getItemAs(item)}\n active={getItemActive(item)}\n iconLeft={getItemIconLeft(item)}\n iconRight={getItemIconRight(item)}\n ref={getItemRef(item)}\n status={getItemStatus(item)}\n interactive={!itemDisabled && interactive}\n disabled={itemDisabled}\n />\n );\n })}\n </div>\n );\n};\n\nexport const Chips = forwardRef(ChipsRender) as Chip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,OANJ,CAUE,gBAAgB,CACdT,CAAoB,
|
|
1
|
+
{"version":3,"file":"Chips.js","names":["React","forwardRef","cn","ChipsItem","withDefaultGetters","cnChips","ChipsRender","props","ref","items","getItemActive","getItemDisabled","getItemAs","getItemAttributes","getItemIconLeft","getItemIconRight","getItemLabel","getItemRef","getItemStatus","className","interactive","onItemClick","onItemRightIconClick","activeView","size","disabled","otherProps","map","item","index","itemDisabled","e","Chips"],"sources":["../../../../../src/components/Chips/Chips.tsx"],"sourcesContent":["import './Chips.css';\n\nimport React, { forwardRef } from 'react';\n\nimport { cn } from '##/utils/bem';\n\nimport { ChipsItem } from './ChipsItem';\nimport { withDefaultGetters } from './helpers';\nimport { ChipsComponent, ChipsProps } from './types';\n\nconst cnChips = cn('Chips');\n\nconst ChipsRender = (props: ChipsProps, ref: React.Ref<HTMLDivElement>) => {\n const {\n items,\n getItemActive,\n getItemDisabled,\n getItemAs,\n getItemAttributes,\n getItemIconLeft,\n getItemIconRight,\n getItemLabel,\n getItemRef,\n getItemStatus,\n className,\n interactive,\n onItemClick,\n onItemRightIconClick,\n activeView,\n size,\n disabled = false,\n ...otherProps\n } = withDefaultGetters(props);\n\n return (\n <div {...otherProps} ref={ref} className={cnChips(null, [className])}>\n {items.map((item, index) => {\n const itemDisabled = getItemDisabled(item) || disabled;\n return (\n <ChipsItem\n {...getItemAttributes(item)}\n key={index}\n size={size}\n activeView={activeView}\n onClick={\n onItemClick && !itemDisabled\n ? (e: React.MouseEvent) => onItemClick(item, { e })\n : undefined\n }\n onRightIconClick={\n onItemRightIconClick && !itemDisabled\n ? (e: React.MouseEvent) => onItemRightIconClick(item, { e })\n : undefined\n }\n label={getItemLabel(item)}\n as={getItemAs(item)}\n active={getItemActive(item)}\n iconLeft={getItemIconLeft(item)}\n iconRight={getItemIconRight(item)}\n ref={getItemRef(item)}\n status={getItemStatus(item)}\n interactive={!itemDisabled && interactive}\n disabled={itemDisabled}\n />\n );\n })}\n </div>\n );\n};\n\nexport const Chips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CAAF,CAAP,CAApC,CADJ,OANJ,CAUE,gBAAgB,CACdT,CAAoB,EAAI,CAACQ,CAAzB,CACI,SAACC,CAAD,QAAyBT,EAAoB,CAACM,CAAD,CAAO,CAAEG,CAAC,CAADA,CAAF,CAAP,CAA7C,CADJ,OAXJ,CAeE,KAAK,CAAEf,CAAY,CAACY,CAAD,CAfrB,CAgBE,EAAE,CAAEhB,CAAS,CAACgB,CAAD,CAhBf,CAiBE,MAAM,CAAElB,CAAa,CAACkB,CAAD,CAjBvB,CAkBE,QAAQ,CAAEd,CAAe,CAACc,CAAD,CAlB3B,CAmBE,SAAS,CAAEb,CAAgB,CAACa,CAAD,CAnB7B,CAoBE,GAAG,CAAEX,CAAU,CAACW,CAAD,CApBjB,CAqBE,MAAM,CAAEV,CAAa,CAACU,CAAD,CArBvB,CAsBE,WAAW,CAAE,CAACE,CAAD,EAAiBV,CAtBhC,CAuBE,QAAQ,CAAEU,CAvBZ,GA0BH,CA7BA,CADH,CAiCH,C,CAED,MAAO,IAAME,MAAK,CAAG/B,UAAU,CAACK,WAAD,CAAxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.Informer{border-radius:var(--control-radius);color:var(--color-typo-primary);padding:var(--space-s) var(--space-m)}.Informer_withIcon{display:flex;flex-wrap:nowrap}.
|
|
1
|
+
.Informer{border-radius:var(--control-radius);color:var(--color-typo-primary);padding:var(--space-s) var(--space-m)}.Informer_withIcon{display:flex;flex-wrap:nowrap}.Informer_view_bordered{background-color:var(--color-bg-default);border-left:var(--space-xs) solid var(--informer-status-color);box-shadow:var(--shadow-layer)}.Informer_view_filled{background-color:var(--informer-status-color)}.Informer-Icon{flex-shrink:0;margin-right:var(--space-s);transform:translateY(var(--space-3xs))}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["view","status","size","icon","label","title","children"];import"./Informer.css";import{classnames}from"@bem-react/classnames";import React from"react";import{cnMixSpace}from"../../mixs/MixSpace";import{cn}from"../../utils/bem";import{Text}from"../Text/Text";import{useTheme}from"../Theme/Theme";export var informerPropView=["filled","bordered"];export var informerPropViewDefault=informerPropView[0];export var informerPropStatus=["success","system","alert","warning"];export var informerPropStatusDefault=informerPropStatus[0];export var informerPropSize=["m","s"];export var informerPropSiseDefault=informerPropSize[0];export var cnInformer=cn("Informer");export var Informer=React.forwardRef(function(a,b){var c=a.view,d=void 0===c?informerPropViewDefault:c,e=a.status,f=void 0===e?informerPropStatusDefault:e,g=a.size,h=void 0===g?informerPropSiseDefault:g,i=a.icon,j=a.label,k=a.title,l=a.children,m=_objectWithoutProperties(a,_excluded),
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["view","status","size","icon","label","title","children","style"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./Informer.css";import{classnames}from"@bem-react/classnames";import React from"react";import{cnMixSpace}from"../../mixs/MixSpace";import{cn}from"../../utils/bem";import{Text}from"../Text/Text";import{useTheme}from"../Theme/Theme";export var informerPropView=["filled","bordered"];export var informerPropViewDefault=informerPropView[0];export var informerPropStatus=["success","system","alert","warning"];export var informerPropStatusDefault=informerPropStatus[0];export var informerPropSize=["m","s"];export var informerPropSiseDefault=informerPropSize[0];export var cnInformer=cn("Informer");export var Informer=React.forwardRef(function(a,b){var c=a.view,d=void 0===c?informerPropViewDefault:c,e=a.status,f=void 0===e?informerPropStatusDefault:e,g=a.size,h=void 0===g?informerPropSiseDefault:g,i=a.icon,j=a.label,k=a.title,l=a.children,m=a.style,n=_objectWithoutProperties(a,_excluded),o=i,p=useTheme(),q=p.themeClassNames,r="system"!==f&&"filled"===d?classnames(a.className,q.color.accent):a.className;return React.createElement("div",Object.assign({},n,{className:cnInformer({view:d,withIcon:!!i},[r,cnMixSpace({p:h})]),style:_objectSpread(_objectSpread({},m),{},_defineProperty({},"--informer-status-color",f?"var(--color-bg-".concat(f,")"):void 0)),ref:b}),o&&React.createElement(o,{className:cnInformer("Icon"),size:"s"}),React.createElement("div",{className:cnInformer("Content")},k&&React.createElement(Text,{lineHeight:"xs",className:cnInformer("Title",[cnMixSpace({mB:"2xs"})]),weight:"bold",size:h,view:"primary"},k),j?React.createElement(Text,{lineHeight:"xs",view:"primary",className:cnInformer("Label"),size:h},j):l))});
|
|
2
2
|
//# sourceMappingURL=Informer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Informer.js","names":["classnames","React","cnMixSpace","cn","Text","useTheme","informerPropView","informerPropViewDefault","informerPropStatus","informerPropStatusDefault","informerPropSize","informerPropSiseDefault","cnInformer","Informer","forwardRef","props","ref","view","status","size","icon","label","title","children","otherProps","Icon","themeClassNames","className","color","accent","withIcon","p","mB"],"sources":["../../../../../src/components/Informer/Informer.tsx"],"sourcesContent":["import './Informer.css';\n\nimport { classnames } from '@bem-react/classnames';\nimport { IconComponent } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { cnMixSpace } from '##/mixs/MixSpace';\n\nimport { cn } from '../../utils/bem';\nimport { PropsWithHTMLAttributes } from '../../utils/types/PropsWithHTMLAttributes';\nimport { Text } from '../Text/Text';\nimport { useTheme } from '../Theme/Theme';\n\nexport const informerPropView = ['filled', 'bordered'] as const;\nexport type InformerPropView = typeof informerPropView[number];\nexport const informerPropViewDefault: InformerPropView = informerPropView[0];\n\nexport const informerPropStatus = [\n 'success',\n 'system',\n 'alert',\n 'warning',\n] as const;\nexport type InformerPropStatus = typeof informerPropStatus[number];\nexport const informerPropStatusDefault: InformerPropStatus =\n informerPropStatus[0];\n\nexport const informerPropSize = ['m', 's'] as const;\nexport type InformerPropSize = typeof informerPropSize[number];\nexport const informerPropSiseDefault: InformerPropSize = informerPropSize[0];\n\ntype Props = {\n view?: InformerPropView;\n status?: InformerPropStatus;\n icon?: IconComponent;\n label?: React.ReactNode;\n title?: string;\n size?: InformerPropSize;\n};\n\nexport type InformerProps = PropsWithHTMLAttributes<Props, HTMLDivElement>;\n\nexport const cnInformer = cn('Informer');\n\nexport const Informer = React.forwardRef<HTMLDivElement, InformerProps>(\n (props, ref) => {\n const {\n view = informerPropViewDefault,\n status = informerPropStatusDefault,\n size = informerPropSiseDefault,\n icon,\n label,\n title,\n children,\n ...otherProps\n } = props;\n const Icon = icon;\n const withIcon = !!icon;\n const { themeClassNames } = useTheme();\n const className =\n status !== 'system' && view === 'filled'\n ? classnames(props.className, themeClassNames.color.accent)\n : props.className;\n\n return (\n <div\n {...otherProps}\n className={cnInformer(\n {\n view,\n
|
|
1
|
+
{"version":3,"file":"Informer.js","names":["classnames","React","cnMixSpace","cn","Text","useTheme","informerPropView","informerPropViewDefault","informerPropStatus","informerPropStatusDefault","informerPropSize","informerPropSiseDefault","cnInformer","Informer","forwardRef","props","ref","view","status","size","icon","label","title","children","style","otherProps","Icon","themeClassNames","className","color","accent","withIcon","p","mB"],"sources":["../../../../../src/components/Informer/Informer.tsx"],"sourcesContent":["import './Informer.css';\n\nimport { classnames } from '@bem-react/classnames';\nimport { IconComponent } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { cnMixSpace } from '##/mixs/MixSpace';\n\nimport { cn } from '../../utils/bem';\nimport { PropsWithHTMLAttributes } from '../../utils/types/PropsWithHTMLAttributes';\nimport { Text } from '../Text/Text';\nimport { useTheme } from '../Theme/Theme';\n\nexport const informerPropView = ['filled', 'bordered'] as const;\nexport type InformerPropView = typeof informerPropView[number];\nexport const informerPropViewDefault: InformerPropView = informerPropView[0];\n\nexport const informerPropStatus = [\n 'success',\n 'system',\n 'alert',\n 'warning',\n] as const;\nexport type InformerPropStatus = typeof informerPropStatus[number];\nexport const informerPropStatusDefault: InformerPropStatus =\n informerPropStatus[0];\n\nexport const informerPropSize = ['m', 's'] as const;\nexport type InformerPropSize = typeof informerPropSize[number];\nexport const informerPropSiseDefault: InformerPropSize = informerPropSize[0];\n\ntype Props = {\n view?: InformerPropView;\n status?: InformerPropStatus;\n icon?: IconComponent;\n label?: React.ReactNode;\n title?: string;\n size?: InformerPropSize;\n};\n\nexport type InformerProps = PropsWithHTMLAttributes<Props, HTMLDivElement>;\n\nexport const cnInformer = cn('Informer');\n\nexport const Informer = React.forwardRef<HTMLDivElement, InformerProps>(\n (props, ref) => {\n const {\n view = informerPropViewDefault,\n status = informerPropStatusDefault,\n size = informerPropSiseDefault,\n icon,\n label,\n title,\n children,\n style,\n ...otherProps\n } = props;\n const Icon = icon;\n const withIcon = !!icon;\n const { themeClassNames } = useTheme();\n const className =\n status !== 'system' && view === 'filled'\n ? classnames(props.className, themeClassNames.color.accent)\n : props.className;\n\n return (\n <div\n {...otherProps}\n className={cnInformer(\n {\n view,\n withIcon,\n },\n [className, cnMixSpace({ p: size })],\n )}\n style={{\n ...style,\n ['--informer-status-color' as string]: status\n ? `var(--color-bg-${status})`\n : undefined,\n }}\n ref={ref}\n >\n {Icon && <Icon className={cnInformer('Icon')} size=\"s\" />}\n <div className={cnInformer('Content')}>\n {title && (\n <Text\n lineHeight=\"xs\"\n className={cnInformer('Title', [cnMixSpace({ mB: '2xs' })])}\n weight=\"bold\"\n size={size}\n view=\"primary\"\n >\n {title}\n </Text>\n )}\n {label ? (\n <Text\n lineHeight=\"xs\"\n view=\"primary\"\n className={cnInformer('Label')}\n size={size}\n >\n {label}\n </Text>\n ) : (\n children\n )}\n </div>\n </div>\n );\n },\n);\n"],"mappings":"20BAAA,u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e,CAAK,CAACa,SAAP,CAAkBD,CAAe,CAACE,KAAhB,CAAsBC,MAAxC,CADd,CAEIf,CAAK,CAACa,SAlBE,CAoBd,MACE,4CACMH,CADN,EAEE,SAAS,CAAEb,UAAU,CACnB,CACEK,IAAI,CAAJA,CADF,CAEEc,QAAQ,CAbC,CAAC,CAACX,CAWb,CADmB,CAKnB,CAACQ,CAAD,CAAY1B,UAAU,CAAC,CAAE8B,CAAC,CAAEb,CAAL,CAAD,CAAtB,CALmB,CAFvB,CASE,KAAK,gCACAK,CADA,wBAEF,yBAFE,CAEoCN,CAAM,0BACvBA,CADuB,YAF1C,EATP,CAeE,GAAG,CAAEF,CAfP,GAiBGU,CAAI,EAAI,oBAAC,CAAD,EAAM,SAAS,CAAEd,UAAU,CAAC,MAAD,CAA3B,CAAqC,IAAI,CAAC,GAA1C,EAjBX,CAkBE,2BAAK,SAAS,CAAEA,UAAU,CAAC,SAAD,CAA1B,EACGU,CAAK,EACJ,oBAAC,IAAD,EACE,UAAU,CAAC,IADb,CAEE,SAAS,CAAEV,UAAU,CAAC,OAAD,CAAU,CAACV,UAAU,CAAC,CAAE+B,EAAE,CAAE,KAAN,CAAD,CAAX,CAAV,CAFvB,CAGE,MAAM,CAAC,MAHT,CAIE,IAAI,CAAEd,CAJR,CAKE,IAAI,CAAC,SALP,EAOGG,CAPH,CAFJ,CAYGD,CAAK,CACJ,oBAAC,IAAD,EACE,UAAU,CAAC,IADb,CAEE,IAAI,CAAC,SAFP,CAGE,SAAS,CAAET,UAAU,CAAC,OAAD,CAHvB,CAIE,IAAI,CAAEO,CAJR,EAMGE,CANH,CADI,CAUJE,CAtBJ,CAlBF,CA6CH,CAnEqB,CAAjB"}
|
|
@@ -26,7 +26,7 @@ export declare type PositioningProps = {
|
|
|
26
26
|
position: Position;
|
|
27
27
|
};
|
|
28
28
|
declare type ChildrenRenderProp = (direction: Direction) => React.ReactNode;
|
|
29
|
-
export declare type
|
|
29
|
+
export declare type PopoverProps = PropsWithJsxAttributes<{
|
|
30
30
|
direction?: Direction;
|
|
31
31
|
spareDirection?: Direction;
|
|
32
32
|
offset?: PopoverPropOffset;
|
|
@@ -36,6 +36,8 @@ export declare type Props = PropsWithJsxAttributes<{
|
|
|
36
36
|
children: React.ReactNode | ChildrenRenderProp;
|
|
37
37
|
onClickOutside?: ClickOutsideHandler;
|
|
38
38
|
onSetDirection?: (direction: Direction) => void;
|
|
39
|
+
viewportRef?: React.RefObject<HTMLElement>;
|
|
39
40
|
} & PositioningProps>;
|
|
40
|
-
export declare
|
|
41
|
+
export declare type Props = PopoverProps;
|
|
42
|
+
export declare const Popover: React.ForwardRefExoticComponent<Pick<PopoverProps, "slot" | "style" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "position" | "arrowOffset" | "offset" | "direction" | "possibleDirections" | "spareDirection" | "isInteractive" | "onClickOutside" | "onSetDirection" | "viewportRef" | "anchorRef" | "equalAnchorWidth"> & React.RefAttributes<HTMLDivElement>>;
|
|
41
43
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";var _excluded=["children","direction","offset","arrowOffset","possibleDirections","isInteractive","onClickOutside","spareDirection","style","className","position","anchorRef","equalAnchorWidth","onSetDirection"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./Popover.css";import React,{forwardRef,useEffect,useLayoutEffect,useMemo}from"react";import{PortalWithTheme,usePortalContext}from"../PortalWithTheme";import{useTheme}from"../Theme/Theme";import{useClickOutside}from"../../hooks/useClickOutside";import{useComponentSize}from"../../hooks/useComponentSize";import{useForkRef}from"../../hooks/useForkRef";import{cn}from"../../utils/bem";import{isRenderProp}from"../../utils/isRenderProp";import{isNumber,isString}from"../../utils/type-guards";import{getComputedPositionAndDirection}from"./helpers";import{usePopoverReposition}from"./usePopoverReposition";export var directionsStartCenter=["downCenter","upCenter","downRight","downLeft","upRight","upLeft","leftUp","leftCenter","leftDown","rightUp","rightCenter","rightDown"];export var directionsStartEdge=["downStartLeft","upStartLeft","downStartRight","upStartRight","leftStartUp","leftStartDown","rightStartUp","rightStartDown"];export var popoverPropOffset=["3xs","2xs","xs","s","m","l","xl","2xl","3xl","4xl","5xl","6xl"];export var directions=[].concat(directionsStartCenter,directionsStartEdge);var getOffset=function(a,b){if(isNumber(b))return b;if(isString(b)&&a.current){var g=getComputedStyle(a.current).getPropertyValue("--space-".concat(b));if(g&&/px$/.test(g))return+g.slice(0,g.length-2);if(g&&/rem$/.test(g)){var c=parseFloat(getComputedStyle(document.documentElement).fontSize),d=+g.slice(0,g.length-3);return c*d}if(g&&/em$/.test(g)){var e=parseFloat(getComputedStyle(a.current).fontSize),f=+g.slice(0,g.length-2);return e*f}return 0}return 0},ContextConsumer=function(a){var b=a.onClickOutside,c=a.children,d=a.ignoreClicksInsideRefs,e=usePortalContext(),f=e.refs;return useClickOutside({isActive:!!b,ignoreClicksInsideRefs:[].concat(_toConsumableArray(d||[]),_toConsumableArray(f||[])),handler:b}),c},cnPopover=cn("Popover");export var Popover=forwardRef(function(a,b){var c,d=a.children,e=a.direction,f=void 0===e?"upCenter":e,g=a.offset,h=void 0===g?0:g,i=a.arrowOffset,j=a.possibleDirections,k=void 0===j?directions:j,l=a.isInteractive,m=a.onClickOutside,n=a.spareDirection,o=void 0===n?"downStartLeft":n,p=a.style,q=a.className,r=a.position,s=a.anchorRef,t=a.equalAnchorWidth,u=a.onSetDirection,v=_objectWithoutProperties(a,_excluded),
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";var _excluded=["children","direction","offset","arrowOffset","possibleDirections","isInteractive","onClickOutside","spareDirection","style","className","position","anchorRef","equalAnchorWidth","onSetDirection","viewportRef"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./Popover.css";import React,{forwardRef,useEffect,useLayoutEffect,useMemo}from"react";import{PortalWithTheme,usePortalContext}from"../PortalWithTheme";import{useTheme}from"../Theme/Theme";import{useClickOutside}from"../../hooks/useClickOutside";import{useComponentSize}from"../../hooks/useComponentSize";import{useForkRef}from"../../hooks/useForkRef";import{cn}from"../../utils/bem";import{isRenderProp}from"../../utils/isRenderProp";import{isNumber,isString}from"../../utils/type-guards";import{getComputedPositionAndDirection,getPointPossition,getRenderPosition}from"./helpers";import{usePopoverReposition}from"./usePopoverReposition";export var directionsStartCenter=["downCenter","upCenter","downRight","downLeft","upRight","upLeft","leftUp","leftCenter","leftDown","rightUp","rightCenter","rightDown"];export var directionsStartEdge=["downStartLeft","upStartLeft","downStartRight","upStartRight","leftStartUp","leftStartDown","rightStartUp","rightStartDown"];export var popoverPropOffset=["3xs","2xs","xs","s","m","l","xl","2xl","3xl","4xl","5xl","6xl"];export var directions=[].concat(directionsStartCenter,directionsStartEdge);var getOffset=function(a,b){if(isNumber(b))return b;if(isString(b)&&a.current){var g=getComputedStyle(a.current).getPropertyValue("--space-".concat(b));if(g&&/px$/.test(g))return+g.slice(0,g.length-2);if(g&&/rem$/.test(g)){var c=parseFloat(getComputedStyle(document.documentElement).fontSize),d=+g.slice(0,g.length-3);return c*d}if(g&&/em$/.test(g)){var e=parseFloat(getComputedStyle(a.current).fontSize),f=+g.slice(0,g.length-2);return e*f}return 0}return 0},ContextConsumer=function(a){var b=a.onClickOutside,c=a.children,d=a.ignoreClicksInsideRefs,e=usePortalContext(),f=e.refs;return useClickOutside({isActive:!!b,ignoreClicksInsideRefs:[].concat(_toConsumableArray(d||[]),_toConsumableArray(f||[])),handler:b}),c},cnPopover=cn("Popover");export var Popover=forwardRef(function(a,b){var c,d=a.children,e=a.direction,f=void 0===e?"upCenter":e,g=a.offset,h=void 0===g?0:g,i=a.arrowOffset,j=a.possibleDirections,k=void 0===j?directions:j,l=a.isInteractive,m=a.onClickOutside,n=a.spareDirection,o=void 0===n?"downStartLeft":n,p=a.style,q=a.className,r=a.position,s=a.anchorRef,t=a.equalAnchorWidth,u=a.onSetDirection,v=a.viewportRef,w=_objectWithoutProperties(a,_excluded),x=(null===v||void 0===v?void 0:v.current)||document.documentElement,y=React.useRef(null),z=useTheme(),A=z.theme,B=React.useState(),C=_slicedToArray(B,2),D=C[0],E=C[1],F=useComponentSize(y),G=F.width,H=F.height,I=useComponentSize(s||{current:null}),J=React.useRef(null),K=React.useState([]),L=_slicedToArray(K,2),M=L[0],N=L[1],O=function(){N(function(a){return a.length?[]:a}),J.current=null},P=function(){var a;return E(null===s||void 0===s||null===(a=s.current)||void 0===a?void 0:a.getBoundingClientRect())},Q=useMemo(function(){return getOffset(y,h)},[h,!!y.current]),R=getComputedPositionAndDirection({contentSize:{width:G,height:H},viewportSize:{width:x.clientWidth,height:x.clientHeight},arrowOffset:i,offset:Q,direction:f,possibleDirections:k,bannedDirections:M,position:getPointPossition(x,D?{x:D.left,y:D.top}:r,!!(null!==v&&void 0!==v&&v.current)),anchorSize:I,spareDirection:o}),S=R.position,T=R.direction;useEffect(function(){return null===u||void 0===u?void 0:u(T)},[T]),useEffect(P,[I]),usePopoverReposition({isActive:!0,scrollAnchorRef:s||{current:null},onRequestReposition:function onRequestReposition(){O(),P()}}),useLayoutEffect(function(){J.current!==T&&(J.current&&!M.includes(J.current)&&!M.includes(T)&&T!==o&&N(function(a){return J.current?[].concat(_toConsumableArray(a),[J.current]):a}),J.current=T)},[T]),useLayoutEffect(O,[a]);var U=getRenderPosition(x,S,!!(null!==v&&void 0!==v&&v.current),G,H),V=!U||!H||!G;return React.createElement(PortalWithTheme,Object.assign({},w,{preset:A,className:cnPopover({direction:T,notVisible:V},[q]),container:window.document.body,ref:useForkRef([y,b]),style:_objectSpread(_objectSpread({},p),V?{}:(c={},_defineProperty(c,"--popover-left","".concat(U.x,"px")),_defineProperty(c,"--popover-top","".concat(U.y,"px")),_defineProperty(c,"--popover-width",t?"".concat(I.width,"px"):void 0),_defineProperty(c,"--popover-pointer-events",!(void 0!==l)||l?void 0:"none"),_defineProperty(c,"--popover-visibility",S?void 0:"hidden"),c))}),React.createElement(ContextConsumer,{onClickOutside:m,ignoreClicksInsideRefs:[y,s||{current:null}]},isRenderProp(d)?d(T):d))});
|
|
2
2
|
//# sourceMappingURL=Popover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.js","names":["React","forwardRef","useEffect","useLayoutEffect","useMemo","PortalWithTheme","usePortalContext","useTheme","useClickOutside","useComponentSize","useForkRef","cn","isRenderProp","isNumber","isString","getComputedPositionAndDirection","usePopoverReposition","directionsStartCenter","directionsStartEdge","popoverPropOffset","directions","getOffset","ref","propOffset","current","cssVar","getComputedStyle","getPropertyValue","test","slice","length","fontSize","parseFloat","document","documentElement","rem","em","ContextConsumer","onClickOutside","children","ignoreClicksInsideRefs","refs","isActive","handler","cnPopover","Popover","props","componentRef","direction","passedDirection","offset","arrowOffset","possibleDirections","isInteractive","spareDirection","style","className","passedPosition","position","anchorRef","equalAnchorWidth","onSetDirection","otherProps","useRef","theme","useState","anchorClientRect","setAnchorClientRect","width","height","anchorSize","previousDirectionRef","bannedDirections","setBannedDirections","resetBannedDirections","state","updateAnchorClientRect","getBoundingClientRect","contentSize","viewportSize","clientWidth","clientHeight","x","left","y","top","scrollAnchorRef","onRequestReposition","includes","notVisible","window","body","scrollY","scrollX"],"sources":["../../../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import './Popover.css';\n\nimport React, { forwardRef, useEffect, useLayoutEffect, useMemo } from 'react';\n\nimport {\n PortalWithTheme,\n usePortalContext,\n} from '##/components/PortalWithTheme';\nimport { useTheme } from '##/components/Theme/Theme';\nimport { ClickOutsideHandler, useClickOutside } from '##/hooks/useClickOutside';\nimport { useComponentSize } from '##/hooks/useComponentSize';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { cn } from '##/utils/bem';\nimport { isRenderProp } from '##/utils/isRenderProp';\nimport { isNumber, isString } from '##/utils/type-guards';\nimport { PropsWithJsxAttributes } from '##/utils/types/PropsWithJsxAttributes';\n\nimport { getComputedPositionAndDirection } from './helpers';\nimport { usePopoverReposition } from './usePopoverReposition';\n\n/**\n * Стороны упорядочены по приоритету:\n * Используется первая сторона, в которую смог вписаться поповер.\n */\nexport const directionsStartCenter = [\n 'downCenter',\n 'upCenter',\n\n 'downRight',\n 'downLeft',\n 'upRight',\n 'upLeft',\n\n 'leftUp',\n 'leftCenter',\n 'leftDown',\n\n 'rightUp',\n 'rightCenter',\n 'rightDown',\n] as const;\n\nexport const directionsStartEdge = [\n 'downStartLeft',\n 'upStartLeft',\n\n 'downStartRight',\n 'upStartRight',\n\n 'leftStartUp',\n 'leftStartDown',\n\n 'rightStartUp',\n 'rightStartDown',\n] as const;\n\nexport const popoverPropOffset = [\n '3xs',\n '2xs',\n 'xs',\n 's',\n 'm',\n 'l',\n 'xl',\n '2xl',\n '3xl',\n '4xl',\n '5xl',\n '6xl',\n] as const;\nexport type PopoverPropOffset = typeof popoverPropOffset[number] | number;\n\nexport const directions = [...directionsStartCenter, ...directionsStartEdge];\n\nexport type Direction = typeof directions[number];\n\nexport type Position = { x: number; y: number } | undefined;\n\nexport type PositioningProps =\n | {\n anchorRef: React.RefObject<HTMLElement>;\n equalAnchorWidth?: boolean;\n position?: never;\n }\n | {\n anchorRef?: never;\n equalAnchorWidth?: never;\n position: Position;\n };\n\ntype ChildrenRenderProp = (direction: Direction) => React.ReactNode;\n\nexport type Props = PropsWithJsxAttributes<\n {\n direction?: Direction;\n spareDirection?: Direction;\n offset?: PopoverPropOffset;\n arrowOffset?: number;\n possibleDirections?: readonly Direction[];\n isInteractive?: boolean;\n children: React.ReactNode | ChildrenRenderProp;\n onClickOutside?: ClickOutsideHandler;\n onSetDirection?: (direction: Direction) => void;\n } & PositioningProps\n>;\n\nconst getOffset = (\n ref: React.RefObject<HTMLDivElement>,\n propOffset: PopoverPropOffset,\n) => {\n if (isNumber(propOffset)) {\n return propOffset;\n }\n\n if (isString(propOffset) && ref.current) {\n const cssVar = getComputedStyle(ref.current).getPropertyValue(\n `--space-${propOffset}`,\n );\n\n if (cssVar && /px$/.test(cssVar)) {\n return Number(cssVar.slice(0, cssVar.length - 2));\n }\n\n if (cssVar && /rem$/.test(cssVar)) {\n const fontSize = parseFloat(\n getComputedStyle(document.documentElement).fontSize,\n );\n const rem = Number(cssVar.slice(0, cssVar.length - 3));\n\n return fontSize * rem;\n }\n\n if (cssVar && /em$/.test(cssVar)) {\n const fontSize = parseFloat(getComputedStyle(ref.current).fontSize);\n const em = Number(cssVar.slice(0, cssVar.length - 2));\n\n return fontSize * em;\n }\n\n return 0;\n }\n\n return 0;\n};\n\n/**\n * Подписчик на PortalWithThemeProvider\n * получает рефы всех вложенных порталов в модалку\n * для дальнейшего исключения их из useClickOutside\n */\nconst ContextConsumer: React.FC<{\n onClickOutside?: (event: MouseEvent) => void;\n ignoreClicksInsideRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n children: React.ReactNode;\n}> = ({ onClickOutside, children, ignoreClicksInsideRefs }) => {\n const { refs } = usePortalContext();\n\n useClickOutside({\n isActive: !!onClickOutside,\n ignoreClicksInsideRefs: [\n ...(ignoreClicksInsideRefs || []),\n ...(refs || []),\n ],\n handler: onClickOutside,\n });\n\n return children as React.ReactElement;\n};\n\nconst cnPopover = cn('Popover');\n\nexport const Popover = forwardRef<HTMLDivElement, Props>(\n (props, componentRef) => {\n const {\n children,\n direction: passedDirection = 'upCenter',\n offset: propOffset = 0,\n arrowOffset,\n possibleDirections = directions,\n isInteractive = true,\n onClickOutside,\n spareDirection = 'downStartLeft',\n style,\n className,\n position: passedPosition,\n anchorRef,\n equalAnchorWidth,\n onSetDirection,\n ...otherProps\n } = props;\n\n const ref = React.useRef<HTMLDivElement>(null);\n const { theme } = useTheme();\n\n const [anchorClientRect, setAnchorClientRect] = React.useState<\n DOMRect | undefined\n >();\n const { width, height } = useComponentSize(ref);\n const anchorSize = useComponentSize(anchorRef || { current: null });\n const previousDirectionRef = React.useRef<Direction | null>(null);\n const [bannedDirections, setBannedDirections] = React.useState<\n readonly Direction[]\n >([]);\n\n const resetBannedDirections = () => {\n setBannedDirections((state) => (state.length ? [] : state));\n previousDirectionRef.current = null;\n };\n\n const updateAnchorClientRect = () =>\n setAnchorClientRect(anchorRef?.current?.getBoundingClientRect());\n\n const offset = useMemo(\n () => getOffset(ref, propOffset),\n [propOffset, Boolean(ref.current)],\n );\n\n const { position, direction } = getComputedPositionAndDirection({\n contentSize: { width, height },\n viewportSize: {\n // Размер вьюпорта без скроллбаров\n width: document.documentElement.clientWidth,\n height: document.documentElement.clientHeight,\n },\n arrowOffset,\n offset,\n direction: passedDirection,\n possibleDirections,\n bannedDirections,\n position: anchorClientRect\n ? { x: anchorClientRect.left, y: anchorClientRect.top }\n : passedPosition,\n anchorSize,\n spareDirection,\n });\n\n useEffect(() => onSetDirection?.(direction), [direction]);\n\n useEffect(updateAnchorClientRect, [anchorSize]);\n\n usePopoverReposition({\n isActive: true,\n scrollAnchorRef: anchorRef || { current: null },\n onRequestReposition: () => {\n resetBannedDirections();\n updateAnchorClientRect();\n },\n });\n\n /**\n * Может возникнуть ситуация, когда перерасчет поповера всегда будет выдавать 2 направления\n * и бесконечно зацикливать себя. Для избежания таких кейсов мы запоминаем стороны,\n * которые не подошли, чтобы не возвращаться к ним и предотвратить бесконечный ререндер.\n * См. PopoverBannedPositionsStory\n */\n\n useLayoutEffect(() => {\n if (previousDirectionRef.current !== direction) {\n if (\n previousDirectionRef.current &&\n !bannedDirections.includes(previousDirectionRef.current) &&\n !bannedDirections.includes(direction) &&\n direction !== spareDirection\n ) {\n setBannedDirections((state) =>\n previousDirectionRef.current\n ? [...state, previousDirectionRef.current]\n : state,\n );\n }\n previousDirectionRef.current = direction;\n }\n }, [direction]);\n\n // Сбрасываем при любом изменении пропсов, чтобы заново начать перебор направлений\n // Главное не сбрасывать при изменении размеров поповера, т.к. именно оно может вызвать бесконечный перебор\n\n useLayoutEffect(resetBannedDirections, [props]);\n\n const notVisible = !position || !height || !width;\n\n return (\n <PortalWithTheme\n {...otherProps}\n preset={theme}\n className={cnPopover({ direction, notVisible }, [className])}\n container={window.document.body}\n ref={useForkRef([ref, componentRef])}\n style={{\n ...style,\n ...(notVisible\n ? {}\n : {\n ['--popover-top' as string]: `${\n (position?.y || 0) + window.scrollY\n }px`,\n ['--popover-left' as string]: `${\n (position?.x || 0) + window.scrollX\n }px`,\n [`--popover-width` as string]: equalAnchorWidth\n ? `${anchorSize.width}px`\n : undefined,\n [`--popover-pointer-events` as string]: isInteractive\n ? undefined\n : 'none',\n [`--popover-visibility` as string]: position\n ? undefined\n : 'hidden',\n }),\n }}\n >\n <ContextConsumer\n onClickOutside={onClickOutside}\n ignoreClicksInsideRefs={[ref, anchorRef || { current: null }]}\n >\n {isRenderProp(children) ? children(direction) : children}\n </ContextConsumer>\n </PortalWithTheme>\n );\n },\n);\n"],"mappings":"wlCAAA,sBAEA,MAAOA,MAAP,EAAgBC,UAAhB,CAA4BC,SAA5B,CAAuCC,eAAvC,CAAwDC,OAAxD,KAAuE,OAAvE,CAEA,OACEC,eADF,CAEEC,gBAFF,0BAIA,OAASC,QAAT,sBACA,OAA8BC,eAA9B,mCACA,OAASC,gBAAT,oCACA,OAASC,UAAT,8BACA,OAASC,EAAT,uBACA,OAASC,YAAT,gCACA,OAASC,QAAT,CAAmBC,QAAnB,+BAGA,OAASC,+BAAT,iBACA,OAASC,oBAAT,8BAMA,MAAO,IAAMC,sBAAqB,CAAG,CACnC,YADmC,CAEnC,UAFmC,CAInC,WAJmC,CAKnC,UALmC,CAMnC,SANmC,CAOnC,QAPmC,CASnC,QATmC,CAUnC,YAVmC,CAWnC,UAXmC,CAanC,SAbmC,CAcnC,aAdmC,CAenC,WAfmC,CAA9B,CAkBP,MAAO,IAAMC,oBAAmB,CAAG,CACjC,eADiC,CAEjC,aAFiC,CAIjC,gBAJiC,CAKjC,cALiC,CAOjC,aAPiC,CAQjC,eARiC,CAUjC,cAViC,CAWjC,gBAXiC,CAA5B,CAcP,MAAO,IAAMC,kBAAiB,CAAG,CAC/B,KAD+B,CAE/B,KAF+B,CAG/B,IAH+B,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D,CAAjC,CAA+CT,CAJlD,CA7BF,CAqCH,CApJ8B,CAA1B"}
|
|
1
|
+
{"version":3,"file":"Popover.js","names":["React","forwardRef","useEffect","useLayoutEffect","useMemo","PortalWithTheme","usePortalContext","useTheme","useClickOutside","useComponentSize","useForkRef","cn","isRenderProp","isNumber","isString","getComputedPositionAndDirection","getPointPossition","getRenderPosition","usePopoverReposition","directionsStartCenter","directionsStartEdge","popoverPropOffset","directions","getOffset","ref","propOffset","current","cssVar","getComputedStyle","getPropertyValue","test","slice","length","fontSize","parseFloat","document","documentElement","rem","em","ContextConsumer","onClickOutside","children","ignoreClicksInsideRefs","refs","isActive","handler","cnPopover","Popover","props","componentRef","direction","passedDirection","offset","arrowOffset","possibleDirections","isInteractive","spareDirection","style","className","passedPosition","position","anchorRef","equalAnchorWidth","onSetDirection","viewportRef","otherProps","viewportElement","useRef","theme","useState","anchorClientRect","setAnchorClientRect","width","height","anchorSize","previousDirectionRef","bannedDirections","setBannedDirections","resetBannedDirections","state","updateAnchorClientRect","getBoundingClientRect","contentSize","viewportSize","clientWidth","clientHeight","x","left","y","top","scrollAnchorRef","onRequestReposition","includes","renderPosition","notVisible","window","body"],"sources":["../../../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import './Popover.css';\n\nimport React, { forwardRef, useEffect, useLayoutEffect, useMemo } from 'react';\n\nimport {\n PortalWithTheme,\n usePortalContext,\n} from '##/components/PortalWithTheme';\nimport { useTheme } from '##/components/Theme/Theme';\nimport { ClickOutsideHandler, useClickOutside } from '##/hooks/useClickOutside';\nimport { useComponentSize } from '##/hooks/useComponentSize';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { cn } from '##/utils/bem';\nimport { isRenderProp } from '##/utils/isRenderProp';\nimport { isNumber, isString } from '##/utils/type-guards';\nimport { PropsWithJsxAttributes } from '##/utils/types/PropsWithJsxAttributes';\n\nimport {\n getComputedPositionAndDirection,\n getPointPossition,\n getRenderPosition,\n} from './helpers';\nimport { usePopoverReposition } from './usePopoverReposition';\n\n/**\n * Стороны упорядочены по приоритету:\n * Используется первая сторона, в которую смог вписаться поповер.\n */\nexport const directionsStartCenter = [\n 'downCenter',\n 'upCenter',\n\n 'downRight',\n 'downLeft',\n 'upRight',\n 'upLeft',\n\n 'leftUp',\n 'leftCenter',\n 'leftDown',\n\n 'rightUp',\n 'rightCenter',\n 'rightDown',\n] as const;\n\nexport const directionsStartEdge = [\n 'downStartLeft',\n 'upStartLeft',\n\n 'downStartRight',\n 'upStartRight',\n\n 'leftStartUp',\n 'leftStartDown',\n\n 'rightStartUp',\n 'rightStartDown',\n] as const;\n\nexport const popoverPropOffset = [\n '3xs',\n '2xs',\n 'xs',\n 's',\n 'm',\n 'l',\n 'xl',\n '2xl',\n '3xl',\n '4xl',\n '5xl',\n '6xl',\n] as const;\nexport type PopoverPropOffset = typeof popoverPropOffset[number] | number;\n\nexport const directions = [...directionsStartCenter, ...directionsStartEdge];\n\nexport type Direction = typeof directions[number];\n\nexport type Position = { x: number; y: number } | undefined;\n\nexport type PositioningProps =\n | {\n anchorRef: React.RefObject<HTMLElement>;\n equalAnchorWidth?: boolean;\n position?: never;\n }\n | {\n anchorRef?: never;\n equalAnchorWidth?: never;\n position: Position;\n };\n\ntype ChildrenRenderProp = (direction: Direction) => React.ReactNode;\n\nexport type PopoverProps = PropsWithJsxAttributes<\n {\n direction?: Direction;\n spareDirection?: Direction;\n offset?: PopoverPropOffset;\n arrowOffset?: number;\n possibleDirections?: readonly Direction[];\n isInteractive?: boolean;\n children: React.ReactNode | ChildrenRenderProp;\n onClickOutside?: ClickOutsideHandler;\n onSetDirection?: (direction: Direction) => void;\n viewportRef?: React.RefObject<HTMLElement>;\n } & PositioningProps\n>;\n\nexport type Props = PopoverProps; // удалить при мажере\n\nconst getOffset = (\n ref: React.RefObject<HTMLDivElement>,\n propOffset: PopoverPropOffset,\n) => {\n if (isNumber(propOffset)) {\n return propOffset;\n }\n\n if (isString(propOffset) && ref.current) {\n const cssVar = getComputedStyle(ref.current).getPropertyValue(\n `--space-${propOffset}`,\n );\n\n if (cssVar && /px$/.test(cssVar)) {\n return Number(cssVar.slice(0, cssVar.length - 2));\n }\n\n if (cssVar && /rem$/.test(cssVar)) {\n const fontSize = parseFloat(\n getComputedStyle(document.documentElement).fontSize,\n );\n const rem = Number(cssVar.slice(0, cssVar.length - 3));\n\n return fontSize * rem;\n }\n\n if (cssVar && /em$/.test(cssVar)) {\n const fontSize = parseFloat(getComputedStyle(ref.current).fontSize);\n const em = Number(cssVar.slice(0, cssVar.length - 2));\n\n return fontSize * em;\n }\n\n return 0;\n }\n\n return 0;\n};\n\n/**\n * Подписчик на PortalWithThemeProvider\n * получает рефы всех вложенных порталов в модалку\n * для дальнейшего исключения их из useClickOutside\n */\nconst ContextConsumer: React.FC<{\n onClickOutside?: (event: MouseEvent) => void;\n ignoreClicksInsideRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n children: React.ReactNode;\n}> = ({ onClickOutside, children, ignoreClicksInsideRefs }) => {\n const { refs } = usePortalContext();\n\n useClickOutside({\n isActive: !!onClickOutside,\n ignoreClicksInsideRefs: [\n ...(ignoreClicksInsideRefs || []),\n ...(refs || []),\n ],\n handler: onClickOutside,\n });\n\n return children as React.ReactElement;\n};\n\nconst cnPopover = cn('Popover');\n\nexport const Popover = forwardRef<HTMLDivElement, PopoverProps>(\n (props, componentRef) => {\n const {\n children,\n direction: passedDirection = 'upCenter',\n offset: propOffset = 0,\n arrowOffset,\n possibleDirections = directions,\n isInteractive = true,\n onClickOutside,\n spareDirection = 'downStartLeft',\n style,\n className,\n position: passedPosition,\n anchorRef,\n equalAnchorWidth,\n onSetDirection,\n viewportRef,\n ...otherProps\n } = props;\n\n // console.log(viewportRef);\n\n const viewportElement = viewportRef?.current || document.documentElement;\n\n const ref = React.useRef<HTMLDivElement>(null);\n const { theme } = useTheme();\n\n const [anchorClientRect, setAnchorClientRect] = React.useState<\n DOMRect | undefined\n >();\n const { width, height } = useComponentSize(ref);\n const anchorSize = useComponentSize(anchorRef || { current: null });\n const previousDirectionRef = React.useRef<Direction | null>(null);\n const [bannedDirections, setBannedDirections] = React.useState<\n readonly Direction[]\n >([]);\n\n const resetBannedDirections = () => {\n setBannedDirections((state) => (state.length ? [] : state));\n previousDirectionRef.current = null;\n };\n\n const updateAnchorClientRect = () =>\n setAnchorClientRect(anchorRef?.current?.getBoundingClientRect());\n\n const offset = useMemo(\n () => getOffset(ref, propOffset),\n [propOffset, Boolean(ref.current)],\n );\n\n const { position, direction } = getComputedPositionAndDirection({\n contentSize: { width, height },\n viewportSize: {\n // Размер вьюпорта без скроллбаров\n width: viewportElement.clientWidth,\n height: viewportElement.clientHeight,\n },\n arrowOffset,\n offset,\n direction: passedDirection,\n possibleDirections,\n bannedDirections,\n position: getPointPossition(\n viewportElement,\n anchorClientRect\n ? { x: anchorClientRect.left, y: anchorClientRect.top }\n : passedPosition,\n !!viewportRef?.current,\n ),\n anchorSize,\n spareDirection,\n });\n\n useEffect(() => onSetDirection?.(direction), [direction]);\n\n useEffect(updateAnchorClientRect, [anchorSize]);\n\n usePopoverReposition({\n isActive: true,\n scrollAnchorRef: anchorRef || { current: null },\n onRequestReposition: () => {\n resetBannedDirections();\n updateAnchorClientRect();\n },\n });\n\n /**\n * Может возникнуть ситуация, когда перерасчет поповера всегда будет выдавать 2 направления\n * и бесконечно зацикливать себя. Для избежания таких кейсов мы запоминаем стороны,\n * которые не подошли, чтобы не возвращаться к ним и предотвратить бесконечный ререндер.\n * См. PopoverBannedPositionsStory\n */\n\n useLayoutEffect(() => {\n if (previousDirectionRef.current !== direction) {\n if (\n previousDirectionRef.current &&\n !bannedDirections.includes(previousDirectionRef.current) &&\n !bannedDirections.includes(direction) &&\n direction !== spareDirection\n ) {\n setBannedDirections((state) =>\n previousDirectionRef.current\n ? [...state, previousDirectionRef.current]\n : state,\n );\n }\n previousDirectionRef.current = direction;\n }\n }, [direction]);\n\n // Сбрасываем при любом изменении пропсов, чтобы заново начать перебор направлений\n // Главное не сбрасывать при изменении размеров поповера, т.к. именно оно может вызвать бесконечный перебор\n\n useLayoutEffect(resetBannedDirections, [props]);\n\n const renderPosition = getRenderPosition(\n viewportElement,\n position,\n !!viewportRef?.current,\n width,\n height,\n );\n\n const notVisible = !renderPosition || !height || !width;\n\n return (\n <PortalWithTheme\n {...otherProps}\n preset={theme}\n className={cnPopover({ direction, notVisible }, [className])}\n container={window.document.body}\n ref={useForkRef([ref, componentRef])}\n style={{\n ...style,\n ...(notVisible\n ? {}\n : {\n ['--popover-left' as string]: `${renderPosition.x}px`,\n ['--popover-top' as string]: `${renderPosition.y}px`,\n [`--popover-width` as string]: equalAnchorWidth\n ? `${anchorSize.width}px`\n : undefined,\n [`--popover-pointer-events` as string]: isInteractive\n ? undefined\n : 'none',\n [`--popover-visibility` as string]: position\n ? undefined\n : 'hidden',\n }),\n }}\n >\n <ContextConsumer\n onClickOutside={onClickOutside}\n ignoreClicksInsideRefs={[ref, anchorRef || { current: null }]}\n >\n {isRenderProp(children) ? children(direction) : children}\n </ContextConsumer>\n </PortalWithTheme>\n );\n },\n);\n"],"mappings":"smCAAA,sBAEA,MAAOA,MAAP,EAAgBC,UAAhB,CAA4BC,SAA5B,CAAuCC,eAAvC,CAAwDC,OAAxD,KAAuE,OAAvE,CAEA,OACEC,eADF,CAEEC,gBAFF,0BAIA,OAASC,QAAT,sBACA,OAA8BC,eAA9B,mCACA,OAASC,gBAAT,oCACA,OAASC,UAAT,8BACA,OAASC,EAAT,uBACA,OAASC,YAAT,gCACA,OAASC,QAAT,CAAmBC,QAAnB,+BAGA,OACEC,+BADF,CAEEC,iBAFF,CAGEC,iBAHF,iBAKA,OAASC,oBAAT,8BAMA,MAAO,IAAMC,sBAAqB,CAAG,CACnC,YADmC,CAEnC,UAFmC,CAInC,WAJmC,CAKnC,UALmC,CAMnC,SANmC,CAOnC,QAPmC,CASnC,QATmC,CAUnC,YAVmC,CAWnC,UAXmC,CAanC,SAbmC,CAcnC,aAdmC,CAenC,WAfmC,CA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AACc,CAAD,CAAMyB,CAAN,CAAD,CALjB,CAME,KAAK,gCACAQ,CADA,EAECqC,CAAU,CACV,EADU,yBAGP,gBAHO,WAGyBD,CAAc,CAACP,CAHxC,0BAIP,eAJO,WAIwBO,CAAc,CAACL,CAJvC,4CAKuB1B,CAAgB,WACxCY,CAAU,CAACF,KAD6B,aALvC,+CAQgC,wBAEpC,MAVI,2CAW4BZ,CAAQ,QAExC,QAbI,IAFX,CANP,GAyBE,oBAAC,eAAD,EACE,cAAc,CAAEpB,CADlB,CAEE,sBAAsB,CAAE,CAAChB,CAAD,CAAMqC,CAAS,EAAI,CAAEnC,OAAO,CAAE,IAAX,CAAnB,CAF1B,EAIGd,YAAY,CAAC6B,CAAD,CAAZ,CAAyBA,CAAQ,CAACS,CAAD,CAAjC,CAA+CT,CAJlD,CAzBF,CAiCH,CAjK8B,CAA1B"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Direction, Position } from './Popover';
|
|
2
2
|
declare type Size = Pick<DOMRect, 'width' | 'height'>;
|
|
3
3
|
declare type PositionsByDirection = Record<Direction, NonNullable<Position>>;
|
|
4
|
+
export declare const getPointPossition: (viewportElement: HTMLElement, positionInDocument: Position, withCustomViewPort: boolean) => Position;
|
|
5
|
+
export declare const getRenderPosition: (viewportElement: HTMLElement, position: Position, withCustomViewPort: Boolean, width: number | undefined, height: number | undefined) => {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
} | undefined;
|
|
4
9
|
export declare const getPositionsByDirection: ({ contentSize, anchorSize, position: { x, y }, arrowOffset, offset, }: {
|
|
5
10
|
contentSize: Size;
|
|
6
11
|
anchorSize: Size;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";var getPosition=function(a,b){return{x:Math.round(a),y:Math.round(b)}};export var getPositionsByDirection=function(a){var b=a.contentSize,c=a.anchorSize,d=a.position,e=d.x,f=d.y,g=a.arrowOffset,h=void 0===g?0:g,i=a.offset,j=void 0===i?0:i,k=b.width,l=b.height,m=c.width,n=c.height,o={x:e+m/2,y:f+n/2},p=e+m+j,q=e-k-j,r={right:o.x-h,center:o.x-k/2,left:o.x-k+h},s=f+n+j,t=f-l-j,u={up:o.y-l+h,center:o.y-l/2,down:o.y-h},v=e,w=e-k+m,x=f,y=f-l+n;return{upLeft:getPosition(r.left,t),upCenter:getPosition(r.center,t),upRight:getPosition(r.right,t),downLeft:getPosition(r.left,s),downCenter:getPosition(r.center,s),downRight:getPosition(r.right,s),rightUp:getPosition(p,u.up),rightCenter:getPosition(p,u.center),rightDown:getPosition(p,u.down),leftUp:getPosition(q,u.up),leftCenter:getPosition(q,u.center),leftDown:getPosition(q,u.down),downStartLeft:getPosition(v,s),downStartRight:getPosition(w,s),upStartLeft:getPosition(v,t),upStartRight:getPosition(w,t),leftStartUp:getPosition(q,x),leftStartDown:getPosition(q,y),rightStartUp:getPosition(p,x),rightStartDown:getPosition(p,y)}};export var getComputedPositionAndDirection=function(a){var b=a.position,c=a.contentSize,d=a.viewportSize,e=a.anchorSize,f=void 0===e?{width:0,height:0}:e,g=a.arrowOffset,h=a.direction,i=a.possibleDirections,j=a.bannedDirections,k=a.spareDirection,l=a.offset,m=void 0===l?0:l;if(!b)return{position:b,direction:h};var n=getPositionsByDirection({contentSize:c,anchorSize:f,position:b,arrowOffset:g,offset:m}),o=[h].concat(_toConsumableArray(i)).filter(function(a){return!j.includes(a)}).find(function(a){var b=n[a],e=c.width,f=c.height,g=b.y+f<=d.height,h=0<=b.y,i=0<=b.x,j=b.x+e<=d.width;return h&&g&&i&&j})||k;return{direction:o,position:n[o]}};
|
|
1
|
+
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";var getPosition=function(a,b){return{x:Math.round(a),y:Math.round(b)}};export var getPointPossition=function(a,b,c){if(b){if(!c)return b;var d=a.getBoundingClientRect(),e=getPosition(b.x-d.left,b.y-d.top);return e}};export var getRenderPosition=function(a,b,c,d,e){if(d&&e){if(!c)return getPosition(((null===b||void 0===b?void 0:b.x)||0)+window.scrollX,((null===b||void 0===b?void 0:b.y)||0)+window.scrollY);var f=a.getBoundingClientRect();return!b||0>b.x||0>b.y||b.x+d>a.clientWidth||b.y+e>a.clientHeight?void 0:getPosition(((null===b||void 0===b?void 0:b.x)||0)+window.scrollX+f.left,((null===b||void 0===b?void 0:b.y)||0)+window.scrollY+f.top)}};export var getPositionsByDirection=function(a){var b=a.contentSize,c=a.anchorSize,d=a.position,e=d.x,f=d.y,g=a.arrowOffset,h=void 0===g?0:g,i=a.offset,j=void 0===i?0:i,k=b.width,l=b.height,m=c.width,n=c.height,o={x:e+m/2,y:f+n/2},p=e+m+j,q=e-k-j,r={right:o.x-h,center:o.x-k/2,left:o.x-k+h},s=f+n+j,t=f-l-j,u={up:o.y-l+h,center:o.y-l/2,down:o.y-h},v=e,w=e-k+m,x=f,y=f-l+n;return{upLeft:getPosition(r.left,t),upCenter:getPosition(r.center,t),upRight:getPosition(r.right,t),downLeft:getPosition(r.left,s),downCenter:getPosition(r.center,s),downRight:getPosition(r.right,s),rightUp:getPosition(p,u.up),rightCenter:getPosition(p,u.center),rightDown:getPosition(p,u.down),leftUp:getPosition(q,u.up),leftCenter:getPosition(q,u.center),leftDown:getPosition(q,u.down),downStartLeft:getPosition(v,s),downStartRight:getPosition(w,s),upStartLeft:getPosition(v,t),upStartRight:getPosition(w,t),leftStartUp:getPosition(q,x),leftStartDown:getPosition(q,y),rightStartUp:getPosition(p,x),rightStartDown:getPosition(p,y)}};export var getComputedPositionAndDirection=function(a){var b=a.position,c=a.contentSize,d=a.viewportSize,e=a.anchorSize,f=void 0===e?{width:0,height:0}:e,g=a.arrowOffset,h=a.direction,i=a.possibleDirections,j=a.bannedDirections,k=a.spareDirection,l=a.offset,m=void 0===l?0:l;if(!b)return{position:b,direction:h};var n=getPositionsByDirection({contentSize:c,anchorSize:f,position:b,arrowOffset:g,offset:m}),o=[h].concat(_toConsumableArray(i)).filter(function(a){return!j.includes(a)}).find(function(a){var b=n[a],e=c.width,f=c.height,g=b.y+f<=d.height,h=0<=b.y,i=0<=b.x,j=b.x+e<=d.width;return h&&g&&i&&j})||k;return{direction:o,position:n[o]}};
|
|
2
2
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["getPosition","x","y","Math","round","getPositionsByDirection","contentSize","anchorSize","position","arrowOffset","offset","contentWidth","width","contentHeight","height","anchorWidth","anchorHeight","anchorCenter","xForRightDirections","xForLeftDirections","xForVerticalDirections","right","center","left","yForDownDirections","yForUpDirections","yForHorizontalDirections","up","down","xForStartLeftDirections","xForStartRightDirections","yForStartUpDirections","yForStartDownDirections","upLeft","upCenter","upRight","downLeft","downCenter","downRight","rightUp","rightCenter","rightDown","leftUp","leftCenter","leftDown","downStartLeft","downStartRight","upStartLeft","upStartRight","leftStartUp","leftStartDown","rightStartUp","rightStartDown","getComputedPositionAndDirection","initialPosition","viewportSize","initialDirection","direction","possibleDirections","bannedDirections","spareDirection","positionsByDirection","filter","dir","includes","find","pos","isFittingDown","isFittingUp","isFittingLeft","isFittingRight"],"sources":["../../../../../src/components/Popover/helpers.ts"],"sourcesContent":["import { Direction, Position } from './Popover';\n\ntype Size = Pick<DOMRect, 'width' | 'height'>;\n\ntype PositionsByDirection = Record<Direction, NonNullable<Position>>;\n\nconst getPosition = (x: number, y: number): NonNullable<Position> => ({\n x: Math.round(x),\n y: Math.round(y),\n});\n\nexport const getPositionsByDirection = ({\n contentSize,\n anchorSize,\n position: { x, y },\n arrowOffset = 0,\n offset = 0,\n}: {\n contentSize: Size;\n anchorSize: Size;\n position: NonNullable<Position>;\n arrowOffset?: number;\n offset?: number;\n}): PositionsByDirection => {\n const { width: contentWidth, height: contentHeight } = contentSize;\n const { width: anchorWidth, height: anchorHeight } = anchorSize;\n const anchorCenter = {\n x: x + anchorWidth / 2,\n y: y + anchorHeight / 2,\n };\n\n const xForRightDirections = x + anchorWidth + offset;\n const xForLeftDirections = x - contentWidth - offset;\n const xForVerticalDirections = {\n right: anchorCenter.x - arrowOffset,\n center: anchorCenter.x - contentWidth / 2,\n left: anchorCenter.x - contentWidth + arrowOffset,\n };\n\n const yForDownDirections = y + anchorHeight + offset;\n const yForUpDirections = y - contentHeight - offset;\n const yForHorizontalDirections = {\n up: anchorCenter.y - contentHeight + arrowOffset,\n center: anchorCenter.y - contentHeight / 2,\n down: anchorCenter.y - arrowOffset,\n };\n\n const xForStartLeftDirections = x;\n const xForStartRightDirections = x - contentWidth + anchorWidth;\n\n const yForStartUpDirections = y;\n const yForStartDownDirections = y - contentHeight + anchorHeight;\n\n return {\n upLeft: getPosition(xForVerticalDirections.left, yForUpDirections),\n upCenter: getPosition(xForVerticalDirections.center, yForUpDirections),\n upRight: getPosition(xForVerticalDirections.right, yForUpDirections),\n\n downLeft: getPosition(xForVerticalDirections.left, yForDownDirections),\n downCenter: getPosition(xForVerticalDirections.center, yForDownDirections),\n downRight: getPosition(xForVerticalDirections.right, yForDownDirections),\n\n rightUp: getPosition(xForRightDirections, yForHorizontalDirections.up),\n rightCenter: getPosition(\n xForRightDirections,\n yForHorizontalDirections.center,\n ),\n rightDown: getPosition(xForRightDirections, yForHorizontalDirections.down),\n\n leftUp: getPosition(xForLeftDirections, yForHorizontalDirections.up),\n leftCenter: getPosition(\n xForLeftDirections,\n yForHorizontalDirections.center,\n ),\n leftDown: getPosition(xForLeftDirections, yForHorizontalDirections.down),\n\n downStartLeft: getPosition(xForStartLeftDirections, yForDownDirections),\n downStartRight: getPosition(xForStartRightDirections, yForDownDirections),\n\n upStartLeft: getPosition(xForStartLeftDirections, yForUpDirections),\n upStartRight: getPosition(xForStartRightDirections, yForUpDirections),\n\n leftStartUp: getPosition(xForLeftDirections, yForStartUpDirections),\n leftStartDown: getPosition(xForLeftDirections, yForStartDownDirections),\n\n rightStartUp: getPosition(xForRightDirections, yForStartUpDirections),\n rightStartDown: getPosition(xForRightDirections, yForStartDownDirections),\n };\n};\n\ntype ComputedPositionAndDirectionParams = {\n // Координата точки, к которой крепится поповер. Для якоря — координата левой верхней точки якоря\n position: Position;\n contentSize: Size;\n viewportSize: Size;\n anchorSize?: Size;\n offset?: number;\n arrowOffset?: number;\n direction: Direction;\n spareDirection: Direction;\n possibleDirections: readonly Direction[];\n bannedDirections: readonly Direction[];\n};\n\nexport const getComputedPositionAndDirection = ({\n position: initialPosition,\n contentSize,\n viewportSize,\n anchorSize = { width: 0, height: 0 },\n arrowOffset,\n direction: initialDirection,\n possibleDirections,\n bannedDirections,\n spareDirection,\n offset = 0,\n}: ComputedPositionAndDirectionParams): {\n direction: Direction;\n position: Position;\n} => {\n if (!initialPosition) {\n return { position: initialPosition, direction: initialDirection };\n }\n\n const positionsByDirection = getPositionsByDirection({\n contentSize,\n anchorSize,\n position: initialPosition,\n arrowOffset,\n offset,\n });\n\n const direction =\n [initialDirection, ...possibleDirections]\n .filter((dir) => !bannedDirections.includes(dir))\n .find((dir) => {\n const pos = positionsByDirection[dir];\n const { width, height } = contentSize;\n\n const isFittingDown = pos.y + height <= viewportSize.height;\n const isFittingUp = pos.y >= 0;\n\n const isFittingLeft = pos.x >= 0;\n const isFittingRight = pos.x + width <= viewportSize.width;\n\n return isFittingUp && isFittingDown && isFittingLeft && isFittingRight;\n }) || spareDirection;\n\n return {\n direction,\n position: positionsByDirection[direction],\n };\n};\n"],"mappings":"yEAMA,GAAMA,YAAW,CAAG,SAACC,CAAD,CAAYC,CAAZ,QAAkD,CACpED,CAAC,CAAEE,IAAI,CAACC,KAAL,CAAWH,CAAX,CADiE,CAEpEC,CAAC,CAAEC,IAAI,CAACC,KAAL,CAAWF,CAAX,CAFiE,CAAlD,CAApB,CAKA,MAAO,IAAMG,wBAAuB,CAAG,WAYX,IAX1BC,EAW0B,GAX1BA,WAW0B,CAV1BC,CAU0B,GAV1BA,UAU0B,KAT1BC,QAS0B,CATdP,CASc,GATdA,CASc,CATXC,CASW,GATXA,CASW,KAR1BO,WAQ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K,CAEEE,CAFF,CAEaR,CAFb,CAEEQ,MAFF,CAIPqD,CAAa,CAAGD,CAAG,CAAChE,CAAJ,CAAQY,CAAR,EAAkByC,CAAY,CAACzC,MAJxC,CAKPsD,CAAW,CAAY,CAAT,EAAAF,CAAG,CAAChE,CALX,CAOPmE,CAAa,CAAY,CAAT,EAAAH,CAAG,CAACjE,CAPb,CAQPqE,CAAc,CAAGJ,CAAG,CAACjE,CAAJ,CAAQW,CAAR,EAAiB2C,CAAY,CAAC3C,KARxC,CAUb,MAAOwD,EAAW,EAAID,CAAf,EAAgCE,CAAhC,EAAiDC,CACzD,CAbH,GAaQV,CA3BP,CA6BH,MAAO,CACLH,SAAS,CAATA,CADK,CAELjD,QAAQ,CAAEqD,CAAoB,CAACJ,CAAD,CAFzB,CAIR,CA/CM"}
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["getPosition","x","y","Math","round","getPointPossition","viewportElement","positionInDocument","withCustomViewPort","viewportRect","getBoundingClientRect","position","left","top","getRenderPosition","width","height","window","scrollX","scrollY","clientWidth","clientHeight","getPositionsByDirection","contentSize","anchorSize","arrowOffset","offset","contentWidth","contentHeight","anchorWidth","anchorHeight","anchorCenter","xForRightDirections","xForLeftDirections","xForVerticalDirections","right","center","yForDownDirections","yForUpDirections","yForHorizontalDirections","up","down","xForStartLeftDirections","xForStartRightDirections","yForStartUpDirections","yForStartDownDirections","upLeft","upCenter","upRight","downLeft","downCenter","downRight","rightUp","rightCenter","rightDown","leftUp","leftCenter","leftDown","downStartLeft","downStartRight","upStartLeft","upStartRight","leftStartUp","leftStartDown","rightStartUp","rightStartDown","getComputedPositionAndDirection","initialPosition","viewportSize","initialDirection","direction","possibleDirections","bannedDirections","spareDirection","positionsByDirection","filter","dir","includes","find","pos","isFittingDown","isFittingUp","isFittingLeft","isFittingRight"],"sources":["../../../../../src/components/Popover/helpers.ts"],"sourcesContent":["import { Direction, Position } from './Popover';\n\ntype Size = Pick<DOMRect, 'width' | 'height'>;\n\ntype PositionsByDirection = Record<Direction, NonNullable<Position>>;\n\nconst getPosition = (x: number, y: number): NonNullable<Position> => ({\n x: Math.round(x),\n y: Math.round(y),\n});\n\nexport const getPointPossition = (\n viewportElement: HTMLElement,\n positionInDocument: Position,\n withCustomViewPort: boolean,\n): Position => {\n if (!positionInDocument) {\n return undefined;\n }\n\n if (!withCustomViewPort) {\n return positionInDocument;\n }\n\n const viewportRect = viewportElement.getBoundingClientRect();\n\n const position: Position = getPosition(\n positionInDocument.x - viewportRect.left,\n positionInDocument.y - viewportRect.top,\n );\n\n return position;\n};\n\nexport const getRenderPosition = (\n viewportElement: HTMLElement,\n position: Position,\n withCustomViewPort: Boolean,\n width: number | undefined,\n height: number | undefined,\n) => {\n if (!width || !height) {\n return undefined;\n }\n\n if (!withCustomViewPort) {\n return getPosition(\n (position?.x || 0) + window.scrollX,\n (position?.y || 0) + window.scrollY,\n );\n }\n\n const viewportRect = viewportElement.getBoundingClientRect();\n\n if (\n !position ||\n position.x < 0 ||\n position.y < 0 ||\n position.x + width > viewportElement.clientWidth ||\n position.y + height > viewportElement.clientHeight\n ) {\n return undefined;\n }\n\n return getPosition(\n (position?.x || 0) + window.scrollX + viewportRect.left,\n (position?.y || 0) + window.scrollY + viewportRect.top,\n );\n};\n\nexport const getPositionsByDirection = ({\n contentSize,\n anchorSize,\n position: { x, y },\n arrowOffset = 0,\n offset = 0,\n}: {\n contentSize: Size;\n anchorSize: Size;\n position: NonNullable<Position>;\n arrowOffset?: number;\n offset?: number;\n}): PositionsByDirection => {\n const { width: contentWidth, height: contentHeight } = contentSize;\n const { width: anchorWidth, height: anchorHeight } = anchorSize;\n const anchorCenter = {\n x: x + anchorWidth / 2,\n y: y + anchorHeight / 2,\n };\n\n const xForRightDirections = x + anchorWidth + offset;\n const xForLeftDirections = x - contentWidth - offset;\n const xForVerticalDirections = {\n right: anchorCenter.x - arrowOffset,\n center: anchorCenter.x - contentWidth / 2,\n left: anchorCenter.x - contentWidth + arrowOffset,\n };\n\n const yForDownDirections = y + anchorHeight + offset;\n const yForUpDirections = y - contentHeight - offset;\n const yForHorizontalDirections = {\n up: anchorCenter.y - contentHeight + arrowOffset,\n center: anchorCenter.y - contentHeight / 2,\n down: anchorCenter.y - arrowOffset,\n };\n\n const xForStartLeftDirections = x;\n const xForStartRightDirections = x - contentWidth + anchorWidth;\n\n const yForStartUpDirections = y;\n const yForStartDownDirections = y - contentHeight + anchorHeight;\n\n return {\n upLeft: getPosition(xForVerticalDirections.left, yForUpDirections),\n upCenter: getPosition(xForVerticalDirections.center, yForUpDirections),\n upRight: getPosition(xForVerticalDirections.right, yForUpDirections),\n\n downLeft: getPosition(xForVerticalDirections.left, yForDownDirections),\n downCenter: getPosition(xForVerticalDirections.center, yForDownDirections),\n downRight: getPosition(xForVerticalDirections.right, yForDownDirections),\n\n rightUp: getPosition(xForRightDirections, yForHorizontalDirections.up),\n rightCenter: getPosition(\n xForRightDirections,\n yForHorizontalDirections.center,\n ),\n rightDown: getPosition(xForRightDirections, yForHorizontalDirections.down),\n\n leftUp: getPosition(xForLeftDirections, yForHorizontalDirections.up),\n leftCenter: getPosition(\n xForLeftDirections,\n yForHorizontalDirections.center,\n ),\n leftDown: getPosition(xForLeftDirections, yForHorizontalDirections.down),\n\n downStartLeft: getPosition(xForStartLeftDirections, yForDownDirections),\n downStartRight: getPosition(xForStartRightDirections, yForDownDirections),\n\n upStartLeft: getPosition(xForStartLeftDirections, yForUpDirections),\n upStartRight: getPosition(xForStartRightDirections, yForUpDirections),\n\n leftStartUp: getPosition(xForLeftDirections, yForStartUpDirections),\n leftStartDown: getPosition(xForLeftDirections, yForStartDownDirections),\n\n rightStartUp: getPosition(xForRightDirections, yForStartUpDirections),\n rightStartDown: getPosition(xForRightDirections, yForStartDownDirections),\n };\n};\n\ntype ComputedPositionAndDirectionParams = {\n // Координата точки, к которой крепится поповер. Для якоря — координата левой верхней точки якоря\n position: Position;\n contentSize: Size;\n viewportSize: Size;\n anchorSize?: Size;\n offset?: number;\n arrowOffset?: number;\n direction: Direction;\n spareDirection: Direction;\n possibleDirections: readonly Direction[];\n bannedDirections: readonly Direction[];\n};\n\nexport const getComputedPositionAndDirection = ({\n position: initialPosition,\n contentSize,\n viewportSize,\n anchorSize = { width: 0, height: 0 },\n arrowOffset,\n direction: initialDirection,\n possibleDirections,\n bannedDirections,\n spareDirection,\n offset = 0,\n}: ComputedPositionAndDirectionParams): {\n direction: Direction;\n position: Position;\n} => {\n if (!initialPosition) {\n return { position: initialPosition, direction: initialDirection };\n }\n\n const positionsByDirection = getPositionsByDirection({\n contentSize,\n anchorSize,\n position: initialPosition,\n arrowOffset,\n offset,\n });\n\n const direction =\n [initialDirection, ...possibleDirections]\n .filter((dir) => !bannedDirections.includes(dir))\n .find((dir) => {\n const pos = positionsByDirection[dir];\n const { width, height } = contentSize;\n\n const isFittingDown = pos.y + height <= viewportSize.height;\n const isFittingUp = pos.y >= 0;\n\n const isFittingLeft = pos.x >= 0;\n const isFittingRight = pos.x + width <= viewportSize.width;\n\n return isFittingUp && isFittingDown && isFittingLeft && isFittingRight;\n }) || spareDirection;\n\n return {\n direction,\n position: positionsByDirection[direction],\n };\n};\n"],"mappings":"yEAMA,GAAMA,YAAW,CAAG,SAACC,CAAD,CAAYC,CAAZ,QAAkD,CACpED,CAAC,CAAEE,IAAI,CAACC,KAAL,CAAWH,CAAX,CADiE,CAEpEC,CAAC,CAAEC,IAAI,CAACC,KAAL,CAAWF,CAAX,CAFiE,CAAlD,CAApB,CAKA,MAAO,IAAMG,kBAAiB,CAAG,SAC/BC,CAD+B,CAE/BC,CAF+B,CAG/BC,CAH+B,CAIlB,CACb,GAAKD,CAAL,EAIA,GAAI,CAACC,CAAL,CACE,MAAOD,EAAP,CALF,GAQME,EAAY,CAAGH,CAAe,CAACI,qBAAhB,EARrB,CAUMC,CAAkB,CAAGX,WAAW,CACpCO,CAAkB,CAACN,CAAnB,CAAuBQ,CAAY,CAACG,IADA,CAEpCL,CAAkB,CAACL,CAAnB,CAAuBO,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AEL7D,CAFK,CAEaQ,CAFb,CAELR,KAFK,CAEEC,CAFF,CAEaO,CAFb,CAEEP,MAFF,CAIPgE,CAAa,CAAGD,CAAG,CAAC7E,CAAJ,CAAQc,CAAR,EAAkBoD,CAAY,CAACpD,MAJxC,CAKPiE,CAAW,CAAY,CAAT,EAAAF,CAAG,CAAC7E,CALX,CAOPgF,CAAa,CAAY,CAAT,EAAAH,CAAG,CAAC9E,CAPb,CAQPkF,CAAc,CAAGJ,CAAG,CAAC9E,CAAJ,CAAQc,CAAR,EAAiBqD,CAAY,CAACrD,KARxC,CAUb,MAAOkE,EAAW,EAAID,CAAf,EAAgCE,CAAhC,EAAiDC,CACzD,CAbH,GAaQV,CA3BP,CA6BH,MAAO,CACLH,SAAS,CAATA,CADK,CAEL3D,QAAQ,CAAE+D,CAAoB,CAACJ,CAAD,CAFzB,CAIR,CA/CM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePopoverReposition.js","names":["useEffect","useMutableRef","getAllParents","element","mutableParents","currentNode","push","parentNode","usePopoverReposition","isActive","scrollAnchorRef","onRequestReposition","onRequestRepositionRef","fn","current","window","addEventListener","allParents","forEach","parentEl","removeEventListener"],"sources":["../../../../../src/components/Popover/usePopoverReposition.ts"],"sourcesContent":["import React, { useEffect } from 'react';\n\nimport { useMutableRef } from '
|
|
1
|
+
{"version":3,"file":"usePopoverReposition.js","names":["useEffect","useMutableRef","getAllParents","element","mutableParents","currentNode","push","parentNode","usePopoverReposition","isActive","scrollAnchorRef","onRequestReposition","onRequestRepositionRef","fn","current","window","addEventListener","allParents","forEach","parentEl","removeEventListener"],"sources":["../../../../../src/components/Popover/usePopoverReposition.ts"],"sourcesContent":["import React, { useEffect } from 'react';\n\nimport { useMutableRef } from '##/hooks/useMutableRef/useMutableRef';\n\nconst getAllParents = (element: HTMLElement): readonly Node[] => {\n const mutableParents: Node[] = [];\n let currentNode: Node | null = element;\n\n while (currentNode) {\n currentNode !== element && mutableParents.push(currentNode);\n currentNode = currentNode.parentNode;\n }\n\n return mutableParents;\n};\n\n/** Запрос репозиции поповера при ресайзе окна и скролле */\nexport const usePopoverReposition = ({\n isActive,\n scrollAnchorRef,\n onRequestReposition,\n}: {\n isActive: boolean;\n /** При скролле родителей этого элемента будет запрашиваться репозиция поповера */\n scrollAnchorRef: React.RefObject<HTMLElement | null>;\n onRequestReposition: () => void;\n}) => {\n const onRequestRepositionRef = useMutableRef(onRequestReposition);\n\n useEffect(() => {\n const fn = () => onRequestRepositionRef.current();\n if (isActive) {\n window.addEventListener('resize', fn);\n\n const allParents = scrollAnchorRef?.current\n ? getAllParents(scrollAnchorRef.current)\n : [];\n allParents.forEach((parentEl) => parentEl.addEventListener('scroll', fn));\n\n return () => {\n window.removeEventListener('resize', fn);\n\n allParents.forEach((parentEl) =>\n parentEl.removeEventListener('scroll', fn),\n );\n };\n }\n return undefined;\n }, [scrollAnchorRef]);\n};\n"],"mappings":"AAAA,OAAgBA,SAAhB,KAAiC,OAAjC,CAEA,OAASC,aAAT,+CAEA,GAAMC,cAAa,CAAG,SAACC,CAAD,CAA2C,QACzDC,EAAsB,CAAG,EADgC,CAE3DC,CAAwB,CAAGF,CAFgC,CAIxDE,CAJwD,EAK7DA,CAAW,GAAKF,CAAhB,EAA2BC,CAAc,CAACE,IAAf,CAAoBD,CAApB,CALkC,CAM7DA,CAAW,CAAGA,CAAW,CAACE,UANmC,CAS/D,MAAOH,EACR,CAVD,CAaA,MAAO,IAAMI,qBAAoB,CAAG,WAS9B,IARJC,EAQI,GARJA,QAQI,CAPJC,CAOI,GAPJA,eAOI,CANJC,CAMI,GANJA,mBAMI,CACEC,CAAsB,CAAGX,aAAa,CAACU,CAAD,CADxC,CAGJX,SAAS,CAAC,UAAM,CACd,GAAMa,EAAE,CAAG,iBAAMD,EAAsB,CAACE,OAAvB,EAAN,CAAX,CACA,GAAIL,CAAJ,CAAc,CACZM,MAAM,CAACC,gBAAP,CAAwB,QAAxB,CAAkCH,CAAlC,CADY,CAGZ,GAAMI,EAAU,CAAG,OAAAP,CAAe,WAAfA,CAAA,EAAAA,CAAe,CAAEI,OAAjB,CACfZ,aAAa,CAACQ,CAAe,CAACI,OAAjB,CADE,CAEf,EAFJ,CAKA,MAFAG,EAAU,CAACC,OAAX,CAAmB,SAACC,CAAD,QAAcA,EAAQ,CAACH,gBAAT,CAA0B,QAA1B,CAAoCH,CAApC,CAAd,CAAnB,CAEA,CAAO,UAAM,CACXE,MAAM,CAACK,mBAAP,CAA2B,QAA3B,CAAqCP,CAArC,CADW,CAGXI,CAAU,CAACC,OAAX,CAAmB,SAACC,CAAD,QACjBA,EAAQ,CAACC,mBAAT,CAA6B,QAA7B,CAAuCP,CAAvC,CADiB,CAAnB,CAGD,CACF,CAEF,CAnBQ,CAmBN,CAACH,CAAD,CAnBM,CAoBV,CAhCM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import"./TableTextFilter.css";import{IconSearchStroked}from"@consta/icons/IconSearchStroked";import React,{useMemo,useState}from"react";import{cnMixScrollBar}from"../../../mixs/MixScrollBar";import{cn}from"../../../utils/bem";import{Button}from"../../Button/Button";import{CheckboxGroup}from"../../CheckboxGroup";import{Text}from"../../Text/Text";import{TextField}from"../../TextField/TextField";import{TableFilterContainer}from"../FilterContainer/TableFilterContainer";var cnTextFilter=cn("TableTextFilter"),sanitizeRegex=function(a){return a.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&").replaceAll(/\$/g,"$$$$")};export var TableTextFilter=function(a){var b=a.items,c=void 0===b?[]:b,d=a.withSearch,e=a.onConfirm,f=a.onCancel,g=a.filterValue,h=a.title,i=a.emptySearchText,j=void 0===i?"\u041D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E :(":i,k=useState(null),l=_slicedToArray(k,2),m=l[0],n=l[1],o=useState(g||c),p=_slicedToArray(o,2),q=p[0],r=p[1],s=useMemo(function(){return m
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import"./TableTextFilter.css";import{IconSearchStroked}from"@consta/icons/IconSearchStroked";import React,{useMemo,useState}from"react";import{cnMixScrollBar}from"../../../mixs/MixScrollBar";import{cn}from"../../../utils/bem";import{Button}from"../../Button/Button";import{CheckboxGroup}from"../../CheckboxGroup";import{Text}from"../../Text/Text";import{TextField}from"../../TextField/TextField";import{TableFilterContainer}from"../FilterContainer/TableFilterContainer";var cnTextFilter=cn("TableTextFilter"),sanitizeRegex=function(a){return a.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&").replaceAll(/\$/g,"$$$$")},intersectArrays=function(a,b){return a.filter(function(a){var c=a.value;return b.some(function(a){var b=a.value;return c===b})})};export var TableTextFilter=function(a){var b=a.items,c=void 0===b?[]:b,d=a.withSearch,e=a.onConfirm,f=a.onCancel,g=a.filterValue,h=a.title,i=a.emptySearchText,j=void 0===i?"\u041D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E :(":i,k=useState(null),l=_slicedToArray(k,2),m=l[0],n=l[1],o=useState(g||c),p=_slicedToArray(o,2),q=p[0],r=p[1],s=useMemo(function(){if(!m)return c;var a=new RegExp(sanitizeRegex(m),"i");return c.filter(function(b){var c=b.name;return c.match(a)})},[m,c]),t=useMemo(function(){return intersectArrays(s,null!==q&&void 0!==q?q:[])},[s,q]),u=useMemo(function(){return s.length===t.length},[s,t]),v=useMemo(function(){return t.length},[t]);return React.createElement(TableFilterContainer,{title:h,onCancel:f,onConfirm:function confirmHandler(){n(null),e(t)}},void 0!==d&&d&&React.createElement(TextField,{value:m,onChange:n,leftSide:IconSearchStroked,size:"s",placeholder:"\u041D\u0430\u0439\u0442\u0438 \u0432 \u0441\u043F\u0438\u0441\u043A\u0435",className:cnTextFilter("Searchbar")}),React.createElement("div",{className:cnTextFilter("Controls")},React.createElement(Button,{size:"m",type:"button",form:"brick",label:"\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435",view:"clear",onClick:function setAll(){r(s)},disabled:!s.length||u}),React.createElement(Button,{size:"m",form:"brick",type:"button",label:"\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C",view:"clear",onClick:function resetHandler(){r(null)},disabled:!s.length||!v})),React.createElement("div",{className:cnTextFilter("Checkboxes",[cnMixScrollBar()])},s.length?React.createElement(CheckboxGroup,{items:s,value:q,getItemLabel:function getItemLabel(a){return a.name},onChange:r,name:"checkboxGroup"}):React.createElement(Text,{lineHeight:"2xs",view:"primary",size:"m"},j)))};
|
|
2
2
|
//# sourceMappingURL=TableTextFilter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableTextFilter.js","names":["IconSearchStroked","React","useMemo","useState","cnMixScrollBar","cn","Button","CheckboxGroup","Text","TextField","TableFilterContainer","cnTextFilter","sanitizeRegex","futureRegex","replaceAll","TableTextFilter","items","withSearch","onConfirm","onCancel","filterValue","title","emptySearchText","searchValue","setSearchValue","checkboxGroupValue","setCheckboxGroupValue","filteredItems","
|
|
1
|
+
{"version":3,"file":"TableTextFilter.js","names":["IconSearchStroked","React","useMemo","useState","cnMixScrollBar","cn","Button","CheckboxGroup","Text","TextField","TableFilterContainer","cnTextFilter","sanitizeRegex","futureRegex","replaceAll","intersectArrays","one","other","filter","oneValue","value","some","otherValue","TableTextFilter","items","withSearch","onConfirm","onCancel","filterValue","title","emptySearchText","searchValue","setSearchValue","checkboxGroupValue","setCheckboxGroupValue","filteredItems","regex","RegExp","name","match","filteredAndChecked","isAllSelected","length","isSelected","confirmHandler","setAll","resetHandler","item"],"sources":["../../../../../../src/components/Table/TextFilter/TableTextFilter.tsx"],"sourcesContent":["import './TableTextFilter.css';\n\nimport { IconSearchStroked } from '@consta/icons/IconSearchStroked';\nimport React, { useMemo, useState } from 'react';\n\nimport { cnMixScrollBar } from '##/mixs/MixScrollBar';\n\nimport { cn } from '../../../utils/bem';\nimport { Button } from '../../Button/Button';\nimport { CheckboxGroup } from '../../CheckboxGroup';\nimport { Text } from '../../Text/Text';\nimport { TextField } from '../../TextField/TextField';\nimport { TableFilterContainer } from '../FilterContainer/TableFilterContainer';\nimport { FilterComponentProps } from '../filtering';\n\nconst cnTextFilter = cn('TableTextFilter');\n\ntype Item = {\n name: string;\n value: string;\n};\n\ntype TableTextFilterProps = FilterComponentProps & {\n items?: Item[];\n withSearch?: boolean;\n title?: string;\n emptySearchText?: string;\n};\n\nconst sanitizeRegex = (futureRegex: string): string =>\n futureRegex\n .replaceAll(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n .replaceAll(/\\$/g, '$$$$');\n\nconst intersectArrays = (one: Item[], other: Item[]) =>\n one.filter(({ value: oneValue }) =>\n other.some(({ value: otherValue }) => oneValue === otherValue),\n );\n\nexport const TableTextFilter: React.FC<TableTextFilterProps> = ({\n items = [],\n withSearch = false,\n onConfirm,\n onCancel,\n filterValue,\n title,\n emptySearchText = 'Ничего не найдено :(',\n}) => {\n const [searchValue, setSearchValue] = useState<string | null>(null);\n const [checkboxGroupValue, setCheckboxGroupValue] = useState<Item[] | null>(\n (filterValue as Item[]) || items,\n );\n\n const filteredItems = useMemo(() => {\n if (!searchValue) {\n return items;\n }\n\n const regex = new RegExp(sanitizeRegex(searchValue), 'i');\n\n return items.filter(({ name }) => name.match(regex));\n }, [searchValue, items]);\n\n const setAll = () => {\n setCheckboxGroupValue(filteredItems);\n };\n\n const filteredAndChecked = useMemo(\n () => intersectArrays(filteredItems, checkboxGroupValue ?? []),\n [filteredItems, checkboxGroupValue],\n );\n\n const isAllSelected = useMemo(\n () => filteredItems.length === filteredAndChecked.length,\n [filteredItems, filteredAndChecked],\n );\n\n const isSelected = useMemo(\n () => filteredAndChecked.length,\n [filteredAndChecked],\n );\n\n const confirmHandler = () => {\n setSearchValue(null);\n onConfirm(filteredAndChecked);\n };\n\n const resetHandler = () => {\n setCheckboxGroupValue(null);\n };\n\n return (\n <TableFilterContainer\n title={title}\n onCancel={onCancel}\n onConfirm={confirmHandler}\n >\n {withSearch && (\n <TextField\n value={searchValue}\n onChange={setSearchValue}\n leftSide={IconSearchStroked}\n size=\"s\"\n placeholder=\"Найти в списке\"\n className={cnTextFilter('Searchbar')}\n />\n )}\n <div className={cnTextFilter('Controls')}>\n <Button\n size=\"m\"\n type=\"button\"\n form=\"brick\"\n label=\"Выбрать все\"\n view=\"clear\"\n onClick={setAll}\n disabled={!filteredItems.length || isAllSelected}\n />\n <Button\n size=\"m\"\n form=\"brick\"\n type=\"button\"\n label=\"Сбросить\"\n view=\"clear\"\n onClick={resetHandler}\n disabled={!filteredItems.length || !isSelected}\n />\n </div>\n <div className={cnTextFilter('Checkboxes', [cnMixScrollBar()])}>\n {filteredItems.length ? (\n <CheckboxGroup\n items={filteredItems}\n value={checkboxGroupValue}\n getItemLabel={(item) => item.name}\n onChange={setCheckboxGroupValue}\n name=\"checkboxGroup\"\n />\n ) : (\n <Text lineHeight=\"2xs\" view=\"primary\" size=\"m\">\n {emptySearchText}\n </Text>\n )}\n </div>\n </TableFilterContainer>\n );\n};\n"],"mappings":"iEAAA,8BAEA,OAASA,iBAAT,KAAkC,iCAAlC,CACA,MAAOC,MAAP,EAAgBC,OAAhB,CAAyBC,QAAzB,KAAyC,OAAzC,CAEA,OAASC,cAAT,kCAEA,OAASC,EAAT,0BACA,OAASC,MAAT,2BACA,OAASC,aAAT,2BACA,OAASC,IAAT,uBACA,OAASC,SAAT,iCACA,OAASC,oBAAT,+C,GAGMC,aAAY,CAAGN,EAAE,CAAC,iBAAD,C,CAcjBO,aAAa,CAAG,SAACC,CAAD,QACpBA,EAAW,CACRC,UADH,CACc,qBADd,CACqC,MADrC,EAEGA,UAFH,CAEc,KAFd,CAEqB,MAFrB,CADoB,C,CAKhBC,eAAe,CAAG,SAACC,CAAD,CAAcC,CAAd,QACtBD,EAAG,CAACE,MAAJ,CAAW,eAAUC,EAAV,GAAGC,KAAH,OACTH,EAAK,CAACI,IAAN,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sBAACc,CAAD,QAAUA,EAAI,CAACT,IAAf,CAHhB,CAIE,QAAQ,CAAEJ,CAJZ,CAKE,IAAI,CAAC,eALP,EADD,CASC,oBAAC,IAAD,EAAM,UAAU,CAAC,KAAjB,CAAuB,IAAI,CAAC,SAA5B,CAAsC,IAAI,CAAC,GAA3C,EACGJ,CADH,CAVJ,CAnCF,CAoDH,CAzGM"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import './Tooltip.css';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { TooltipProps } from './types';
|
|
4
|
-
export declare const Tooltip: React.ForwardRefExoticComponent<Pick<TooltipProps, "slot" | "style" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "size" | "status" | "position" | "offset" | "direction" | "possibleDirections" | "spareDirection" | "isInteractive" | "onClickOutside" | "onSetDirection" | "anchorRef" | "equalAnchorWidth" | "isOpen"> & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export declare const Tooltip: React.ForwardRefExoticComponent<Pick<TooltipProps, "slot" | "style" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "size" | "status" | "position" | "offset" | "direction" | "possibleDirections" | "spareDirection" | "isInteractive" | "onClickOutside" | "onSetDirection" | "viewportRef" | "anchorRef" | "equalAnchorWidth" | "isOpen"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["isOpen","size","status","onSetDirection","offset","style","className","children"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./Tooltip.css";import React,{forwardRef,useMemo,useRef,useState}from"react";import{Transition}from"react-transition-group";import{useForkRef}from"../../hooks/useForkRef";import{animateTimeout,cnMixPopoverAnimate}from"../../mixs/MixPopoverAnimate";import{cnMixPopoverArrow}from"../../mixs/MixPopoverArrow/MixPopoverArrow";import{cn}from"../../utils/bem";import{Popover}from"../Popover";import{Text}from"../Text";import{generateDeps,generateThemeClassNames,ThemeContext,useTheme}from"../Theme";import{tooltipPropSizesDefault}from"./types";var cnTooltip=cn("Tooltip"),ARROW_SIZE=6,ARROW_OFFSET=8;export var Tooltip=forwardRef(function(a,b){var c=a.isOpen,d=a.size,e=void 0===d?tooltipPropSizesDefault:d,f=a.status,g=a.onSetDirection,h=a.offset,i=void 0===h?0:h,j=a.style,k=a.className,l=a.children,m=_objectWithoutProperties(a,_excluded),
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["isOpen","size","status","onSetDirection","offset","style","className","children","viewportRef"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./Tooltip.css";import React,{forwardRef,useMemo,useRef,useState}from"react";import{Transition}from"react-transition-group";import{useForkRef}from"../../hooks/useForkRef";import{animateTimeout,cnMixPopoverAnimate}from"../../mixs/MixPopoverAnimate";import{cnMixPopoverArrow}from"../../mixs/MixPopoverArrow/MixPopoverArrow";import{cn}from"../../utils/bem";import{Popover}from"../Popover";import{Text}from"../Text";import{generateDeps,generateThemeClassNames,ThemeContext,useTheme}from"../Theme";import{tooltipPropSizesDefault}from"./types";var cnTooltip=cn("Tooltip"),ARROW_SIZE=6,ARROW_OFFSET=8;export var Tooltip=forwardRef(function(a,b){var c=a.isOpen,d=a.size,e=void 0===d?tooltipPropSizesDefault:d,f=a.status,g=a.onSetDirection,h=a.offset,i=void 0===h?0:h,j=a.style,k=a.className,l=a.children,m=a.viewportRef,n=_objectWithoutProperties(a,_excluded),o=useRef(null),p=useForkRef([o,b]),q=useTheme(),r=q.theme,s=useState(),t=_slicedToArray(s,2),u=t[0],v=t[1],w=function(a){null===g||void 0===g?void 0:g(a),v(a)},x=useMemo(function(){var a=_objectSpread(_objectSpread({},r),{},{color:{primary:f?r.color.accent:r.color.invert,accent:r.color.accent,invert:r.color.primary}});return{theme:a,themeClassNames:generateThemeClassNames(a)}},[generateDeps(r),f]);return React.createElement(Transition,{in:c,unmountOnExit:!0,timeout:animateTimeout,nodeRef:o},function(a){var b;return React.createElement(ThemeContext.Provider,{value:x},React.createElement(Popover,Object.assign({},n,{arrowOffset:ARROW_OFFSET+ARROW_SIZE,offset:ARROW_SIZE+ARROW_OFFSET/2+i,onSetDirection:w,ref:p,viewportRef:m,className:cnTooltip({status:f},[k,cnMixPopoverAnimate({animate:a})]),style:_objectSpread((b={},_defineProperty(b,"--popover-arrow-size","".concat(ARROW_SIZE,"px")),_defineProperty(b,"--popover-arrow-offset","".concat(ARROW_OFFSET,"px")),b),j)}),React.createElement("div",{className:cnTooltip("Background")}),React.createElement("div",{className:cnTooltip("Arrow",[cnMixPopoverArrow({direction:u})])}),React.createElement("div",{className:cnTooltip("Content",{size:e})},"string"==typeof l||"number"==typeof l?React.createElement(Text,{view:"primary",size:"m",lineHeight:"m"},l):l)))})});
|
|
2
2
|
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","names":["React","forwardRef","useMemo","useRef","useState","Transition","useForkRef","animateTimeout","cnMixPopoverAnimate","cnMixPopoverArrow","cn","Popover","Text","generateDeps","generateThemeClassNames","ThemeContext","useTheme","tooltipPropSizesDefault","cnTooltip","ARROW_SIZE","ARROW_OFFSET","Tooltip","props","ref","isOpen","size","status","onSetDirectionProp","onSetDirection","offset","style","className","children","otherProps","contentRef","contentForkedRef","theme","direction","setDirection","value","tooltipTheme","color","primary","accent","invert","themeClassNames","animate"],"sources":["../../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import './Tooltip.css';\n\nimport React, { forwardRef, useMemo, useRef, useState } from 'react';\nimport { Transition } from 'react-transition-group';\n\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { animateTimeout, cnMixPopoverAnimate } from '##/mixs/MixPopoverAnimate';\nimport { cnMixPopoverArrow } from '##/mixs/MixPopoverArrow/MixPopoverArrow';\nimport { cn } from '##/utils/bem';\n\nimport { Direction, Popover } from '../Popover';\nimport { Text } from '../Text';\nimport {\n generateDeps,\n generateThemeClassNames,\n ThemeContext,\n useTheme,\n} from '../Theme';\nimport { TooltipProps, tooltipPropSizesDefault } from './types';\n\nconst cnTooltip = cn('Tooltip');\n\nconst ARROW_SIZE = 6;\nconst ARROW_OFFSET = 8;\n\nexport const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(\n (props, ref) => {\n const {\n isOpen,\n size = tooltipPropSizesDefault,\n status,\n onSetDirection: onSetDirectionProp,\n offset = 0,\n style,\n className,\n children,\n ...otherProps\n } = props;\n\n const contentRef = useRef(null);\n const contentForkedRef = useForkRef([contentRef, ref]);\n\n const { theme } = useTheme();\n\n const [direction, setDirection] = useState<Direction | undefined>();\n\n const onSetDirection = (direction: Direction) => {\n onSetDirectionProp?.(direction);\n setDirection(direction);\n };\n\n const value = useMemo(() => {\n const tooltipTheme = {\n ...theme,\n color: {\n primary: status ? theme.color.accent : theme.color.invert,\n accent: theme.color.accent,\n invert: theme.color.primary,\n },\n };\n return {\n theme: tooltipTheme,\n themeClassNames: generateThemeClassNames(tooltipTheme),\n };\n }, [generateDeps(theme), status]);\n\n return (\n <Transition\n in={isOpen}\n unmountOnExit\n timeout={animateTimeout}\n nodeRef={contentRef}\n >\n {(animate) => (\n <ThemeContext.Provider value={value}>\n <Popover\n {...otherProps}\n arrowOffset={ARROW_OFFSET + ARROW_SIZE}\n offset={ARROW_SIZE + ARROW_OFFSET / 2 + offset}\n onSetDirection={onSetDirection}\n ref={contentForkedRef}\n className={cnTooltip({ status }, [\n className,\n cnMixPopoverAnimate({ animate }),\n ])}\n style={{\n ['--popover-arrow-size' as string]: `${ARROW_SIZE}px`,\n ['--popover-arrow-offset' as string]: `${ARROW_OFFSET}px`,\n ...style,\n }}\n >\n <div className={cnTooltip('Background')} />\n <div\n className={cnTooltip('Arrow', [\n cnMixPopoverArrow({ direction }),\n ])}\n />\n <div className={cnTooltip('Content', { size })}>\n {typeof children === 'string' ||\n typeof children === 'number' ? (\n <Text view=\"primary\" size=\"m\" lineHeight=\"m\">\n {children}\n </Text>\n ) : (\n children\n )}\n </div>\n </Popover>\n </ThemeContext.Provider>\n )}\n </Transition>\n );\n },\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":["React","forwardRef","useMemo","useRef","useState","Transition","useForkRef","animateTimeout","cnMixPopoverAnimate","cnMixPopoverArrow","cn","Popover","Text","generateDeps","generateThemeClassNames","ThemeContext","useTheme","tooltipPropSizesDefault","cnTooltip","ARROW_SIZE","ARROW_OFFSET","Tooltip","props","ref","isOpen","size","status","onSetDirectionProp","onSetDirection","offset","style","className","children","viewportRef","otherProps","contentRef","contentForkedRef","theme","direction","setDirection","value","tooltipTheme","color","primary","accent","invert","themeClassNames","animate"],"sources":["../../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import './Tooltip.css';\n\nimport React, { forwardRef, useMemo, useRef, useState } from 'react';\nimport { Transition } from 'react-transition-group';\n\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { animateTimeout, cnMixPopoverAnimate } from '##/mixs/MixPopoverAnimate';\nimport { cnMixPopoverArrow } from '##/mixs/MixPopoverArrow/MixPopoverArrow';\nimport { cn } from '##/utils/bem';\n\nimport { Direction, Popover } from '../Popover';\nimport { Text } from '../Text';\nimport {\n generateDeps,\n generateThemeClassNames,\n ThemeContext,\n useTheme,\n} from '../Theme';\nimport { TooltipProps, tooltipPropSizesDefault } from './types';\n\nconst cnTooltip = cn('Tooltip');\n\nconst ARROW_SIZE = 6;\nconst ARROW_OFFSET = 8;\n\nexport const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(\n (props, ref) => {\n const {\n isOpen,\n size = tooltipPropSizesDefault,\n status,\n onSetDirection: onSetDirectionProp,\n offset = 0,\n style,\n className,\n children,\n viewportRef,\n ...otherProps\n } = props;\n\n const contentRef = useRef(null);\n const contentForkedRef = useForkRef([contentRef, ref]);\n\n const { theme } = useTheme();\n\n const [direction, setDirection] = useState<Direction | undefined>();\n\n const onSetDirection = (direction: Direction) => {\n onSetDirectionProp?.(direction);\n setDirection(direction);\n };\n\n const value = useMemo(() => {\n const tooltipTheme = {\n ...theme,\n color: {\n primary: status ? theme.color.accent : theme.color.invert,\n accent: theme.color.accent,\n invert: theme.color.primary,\n },\n };\n return {\n theme: tooltipTheme,\n themeClassNames: generateThemeClassNames(tooltipTheme),\n };\n }, [generateDeps(theme), status]);\n\n return (\n <Transition\n in={isOpen}\n unmountOnExit\n timeout={animateTimeout}\n nodeRef={contentRef}\n >\n {(animate) => (\n <ThemeContext.Provider value={value}>\n <Popover\n {...otherProps}\n arrowOffset={ARROW_OFFSET + ARROW_SIZE}\n offset={ARROW_SIZE + ARROW_OFFSET / 2 + offset}\n onSetDirection={onSetDirection}\n ref={contentForkedRef}\n viewportRef={viewportRef}\n className={cnTooltip({ status }, [\n className,\n cnMixPopoverAnimate({ animate }),\n ])}\n style={{\n ['--popover-arrow-size' as string]: `${ARROW_SIZE}px`,\n ['--popover-arrow-offset' as string]: `${ARROW_OFFSET}px`,\n ...style,\n }}\n >\n <div className={cnTooltip('Background')} />\n <div\n className={cnTooltip('Arrow', [\n cnMixPopoverArrow({ direction }),\n ])}\n />\n <div className={cnTooltip('Content', { size })}>\n {typeof children === 'string' ||\n typeof children === 'number' ? (\n <Text view=\"primary\" size=\"m\" lineHeight=\"m\">\n {children}\n </Text>\n ) : (\n children\n )}\n </div>\n </Popover>\n </ThemeContext.Provider>\n )}\n </Transition>\n );\n },\n);\n"],"mappings":"26BAAA,sBAEA,MAAOA,MAAP,EAAg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F,CAkBE,2BACE,SAAS,CAAEA,SAAS,CAAC,OAAD,CAAU,CAC5BT,iBAAiB,CAAC,CAAE6B,SAAS,CAATA,CAAF,CAAD,CADW,CAAV,CADtB,EAlBF,CAuBE,2BAAK,SAAS,CAAEpB,SAAS,CAAC,SAAD,CAAY,CAAEO,IAAI,CAAJA,CAAF,CAAZ,CAAzB,EACuB,QAApB,QAAOO,EAAP,EACmB,QAApB,QAAOA,EADN,CAEC,oBAAC,IAAD,EAAM,IAAI,CAAC,SAAX,CAAqB,IAAI,CAAC,GAA1B,CAA8B,UAAU,CAAC,GAAzC,EACGA,CADH,CAFD,CAMCA,CAPJ,CAvBF,CADF,CADD,CANH,CA8CH,CAzF8B,CAA1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["tooltipPropSizes","tooltipPropSizesDefault","tooltipPropStatus"],"sources":["../../../../../src/components/Tooltip/types.ts"],"sourcesContent":["import { ClickOutsideHandler } from '##/hooks/useClickOutside/useClickOutside';\nimport { PropsWithJsxAttributes } from '##/utils/types/PropsWithJsxAttributes';\n\nimport { Direction, PositioningProps } from '../Popover/Popover';\n\nexport const tooltipPropSizes = ['m', 's', 'l'] as const;\nexport type TooltipPropSize = typeof tooltipPropSizes[number];\nexport const tooltipPropSizesDefault: TooltipPropSize = tooltipPropSizes[0];\n\nexport const tooltipPropStatus = [\n 'normal',\n 'alert',\n 'success',\n 'warning',\n] as const;\nexport type TooltipPropStatus = typeof tooltipPropStatus[number];\n\nexport type TooltipProps = PropsWithJsxAttributes<\n {\n isOpen?: boolean;\n size?: TooltipPropSize;\n status?: TooltipPropStatus;\n direction?: Direction;\n spareDirection?: Direction;\n possibleDirections?: readonly Direction[];\n isInteractive?: boolean;\n children: React.ReactNode;\n onClickOutside?: ClickOutsideHandler;\n className?: string;\n offset?: number;\n onSetDirection?: (direction: Direction) => void;\n } & PositioningProps\n>;\n"],"mappings":"AAKA,MAAO,IAAMA,iBAAgB,CAAG,CAAC,GAAD,CAAM,GAAN,CAAW,GAAX,CAAzB,CAEP,MAAO,IAAMC,wBAAwC,CAAGD,gBAAgB,CAAC,CAAD,CAAjE,CAEP,MAAO,IAAME,kBAAiB,CAAG,CAC/B,QAD+B,CAE/B,OAF+B,CAG/B,SAH+B,CAI/B,SAJ+B,CAA1B"}
|
|
1
|
+
{"version":3,"file":"types.js","names":["tooltipPropSizes","tooltipPropSizesDefault","tooltipPropStatus"],"sources":["../../../../../src/components/Tooltip/types.ts"],"sourcesContent":["import { ClickOutsideHandler } from '##/hooks/useClickOutside/useClickOutside';\nimport { PropsWithJsxAttributes } from '##/utils/types/PropsWithJsxAttributes';\n\nimport { Direction, PositioningProps } from '../Popover/Popover';\n\nexport const tooltipPropSizes = ['m', 's', 'l'] as const;\nexport type TooltipPropSize = typeof tooltipPropSizes[number];\nexport const tooltipPropSizesDefault: TooltipPropSize = tooltipPropSizes[0];\n\nexport const tooltipPropStatus = [\n 'normal',\n 'alert',\n 'success',\n 'warning',\n] as const;\nexport type TooltipPropStatus = typeof tooltipPropStatus[number];\n\nexport type TooltipProps = PropsWithJsxAttributes<\n {\n isOpen?: boolean;\n size?: TooltipPropSize;\n status?: TooltipPropStatus;\n direction?: Direction;\n spareDirection?: Direction;\n possibleDirections?: readonly Direction[];\n isInteractive?: boolean;\n children: React.ReactNode;\n onClickOutside?: ClickOutsideHandler;\n className?: string;\n offset?: number;\n onSetDirection?: (direction: Direction) => void;\n viewportRef?: React.RefObject<HTMLElement>;\n } & PositioningProps\n>;\n"],"mappings":"AAKA,MAAO,IAAMA,iBAAgB,CAAG,CAAC,GAAD,CAAM,GAAN,CAAW,GAAX,CAAzB,CAEP,MAAO,IAAMC,wBAAwC,CAAGD,gBAAgB,CAAC,CAAD,CAAjE,CAEP,MAAO,IAAME,kBAAiB,CAAG,CAC/B,QAD+B,CAE/B,OAF+B,CAG/B,SAH+B,CAI/B,SAJ+B,CAA1B"}
|