@consta/uikit 4.26.1 → 4.27.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.
Files changed (78) hide show
  1. package/LoaderCanary/index.d.ts +1 -0
  2. package/LoaderCanary/index.js +1 -0
  3. package/__internal__/src/components/Badge/Badge.css +1 -1
  4. package/__internal__/src/components/Badge/Badge.d.ts +1 -1
  5. package/__internal__/src/components/Badge/Badge.js +1 -1
  6. package/__internal__/src/components/Badge/Badge.js.map +1 -1
  7. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateRange/DatePickerFieldTypeDateRange.d.ts +2 -0
  8. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateRange/DatePickerFieldTypeDateRange.js +1 -1
  9. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateRange/DatePickerFieldTypeDateRange.js.map +1 -1
  10. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateRange/helpers.d.ts +3 -1
  11. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateRange/helpers.js.map +1 -1
  12. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTimeRange/DatePickerFieldTypeDateTimeRange.d.ts +2 -0
  13. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTimeRange/DatePickerFieldTypeDateTimeRange.js +1 -1
  14. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTimeRange/DatePickerFieldTypeDateTimeRange.js.map +1 -1
  15. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTimeRange/helpers.d.ts +2 -0
  16. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTimeRange/helpers.js.map +1 -1
  17. package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonthRange/DatePickerFieldTypeMonthRange.d.ts +2 -0
  18. package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonthRange/DatePickerFieldTypeMonthRange.js +1 -1
  19. package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonthRange/DatePickerFieldTypeMonthRange.js.map +1 -1
  20. package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonthRange/helpers.d.ts +2 -0
  21. package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonthRange/helpers.js.map +1 -1
  22. package/__internal__/src/components/DatePicker/DatePickerFieldTypeYearRange/DatePickerFieldTypeYearRange.d.ts +2 -0
  23. package/__internal__/src/components/DatePicker/DatePickerFieldTypeYearRange/DatePickerFieldTypeYearRange.js +1 -1
  24. package/__internal__/src/components/DatePicker/DatePickerFieldTypeYearRange/DatePickerFieldTypeYearRange.js.map +1 -1
  25. package/__internal__/src/components/DatePicker/DatePickerFieldTypeYearRange/helpers.d.ts +2 -0
  26. package/__internal__/src/components/DatePicker/DatePickerFieldTypeYearRange/helpers.js.map +1 -1
  27. package/__internal__/src/components/DatePicker/DatePickerTypeDate/DatePickerTypeDate.js +1 -1
  28. package/__internal__/src/components/DatePicker/DatePickerTypeDate/DatePickerTypeDate.js.map +1 -1
  29. package/__internal__/src/components/DatePicker/DatePickerTypeDateRange/DatePickerTypeDateRange.js +1 -1
  30. package/__internal__/src/components/DatePicker/DatePickerTypeDateRange/DatePickerTypeDateRange.js.map +1 -1
  31. package/__internal__/src/components/DatePicker/DatePickerTypeDateTime/DatePickerTypeDateTime.js +1 -1
  32. package/__internal__/src/components/DatePicker/DatePickerTypeDateTime/DatePickerTypeDateTime.js.map +1 -1
  33. package/__internal__/src/components/DatePicker/DatePickerTypeDateTimeRange/DatePickerTypeDateTimeRange.js +1 -1
  34. package/__internal__/src/components/DatePicker/DatePickerTypeDateTimeRange/DatePickerTypeDateTimeRange.js.map +1 -1
  35. package/__internal__/src/components/DatePicker/DatePickerTypeMonth/DatePickerTypeMonth.js +1 -1
  36. package/__internal__/src/components/DatePicker/DatePickerTypeMonth/DatePickerTypeMonth.js.map +1 -1
  37. package/__internal__/src/components/DatePicker/DatePickerTypeMonthRange/DatePickerTypeMonthRange.js +1 -1
  38. package/__internal__/src/components/DatePicker/DatePickerTypeMonthRange/DatePickerTypeMonthRange.js.map +1 -1
  39. package/__internal__/src/components/DatePicker/DatePickerTypeTime/DatePickerTypeTime.js +1 -1
  40. package/__internal__/src/components/DatePicker/DatePickerTypeTime/DatePickerTypeTime.js.map +1 -1
  41. package/__internal__/src/components/DatePicker/DatePickerTypeYear/DatePickerTypeYear.js +1 -1
  42. package/__internal__/src/components/DatePicker/DatePickerTypeYear/DatePickerTypeYear.js.map +1 -1
  43. package/__internal__/src/components/DatePicker/DatePickerTypeYearRange/DatePickerTypeYearRange.js +1 -1
  44. package/__internal__/src/components/DatePicker/DatePickerTypeYearRange/DatePickerTypeYearRange.js.map +1 -1
  45. package/__internal__/src/components/DatePicker/types.d.ts +3 -0
  46. package/__internal__/src/components/DatePicker/types.js.map +1 -1
  47. package/__internal__/src/components/DatePicker/useCalendarVisible.d.ts +13 -0
  48. package/__internal__/src/components/DatePicker/useCalendarVisible.js +2 -0
  49. package/__internal__/src/components/DatePicker/useCalendarVisible.js.map +1 -0
  50. package/__internal__/src/components/LoaderCanary/Loader.css +3 -0
  51. package/__internal__/src/components/LoaderCanary/LoaderCanary.d.ts +10 -0
  52. package/__internal__/src/components/LoaderCanary/LoaderCanary.js +2 -0
  53. package/__internal__/src/components/LoaderCanary/LoaderCanary.js.map +1 -0
  54. package/__internal__/src/components/LoaderCanary/index.d.ts +1 -0
  55. package/__internal__/src/components/LoaderCanary/index.js +2 -0
  56. package/__internal__/src/components/LoaderCanary/index.js.map +1 -0
  57. package/__internal__/src/components/LoaderCanary/types.d.ts +10 -0
  58. package/__internal__/src/components/LoaderCanary/types.js +2 -0
  59. package/__internal__/src/components/LoaderCanary/types.js.map +1 -0
  60. package/__internal__/src/components/ProgressStepBar/ProgressStepBar.js +1 -1
  61. package/__internal__/src/components/ProgressStepBar/ProgressStepBar.js.map +1 -1
  62. package/__internal__/src/components/ProgressStepBar/helpers.js +1 -1
  63. package/__internal__/src/components/ProgressStepBar/helpers.js.map +1 -1
  64. package/__internal__/src/components/Slider/Slider.js +1 -1
  65. package/__internal__/src/components/Slider/Slider.js.map +1 -1
  66. package/__internal__/src/components/Slider/SliderPoint/SliderPoint.js +1 -1
  67. package/__internal__/src/components/Slider/SliderPoint/SliderPoint.js.map +1 -1
  68. package/__internal__/src/components/Slider/helper.d.ts +5 -0
  69. package/__internal__/src/components/Slider/helper.js.map +1 -1
  70. package/__internal__/src/hooks/useKeysRef/index.d.ts +1 -0
  71. package/__internal__/src/hooks/useKeysRef/index.js +2 -0
  72. package/__internal__/src/hooks/useKeysRef/index.js.map +1 -0
  73. package/__internal__/src/hooks/useKeysRef/useKeysRef.d.ts +13 -0
  74. package/__internal__/src/hooks/useKeysRef/useKeysRef.js +2 -0
  75. package/__internal__/src/hooks/useKeysRef/useKeysRef.js.map +1 -0
  76. package/package.json +1 -1
  77. package/useKeysRef/index.d.ts +1 -0
  78. package/useKeysRef/index.js +1 -0
@@ -1,2 +1,2 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";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{cn}from"../../utils/bem";export var propSize=["s","xs","m"];export var propSizeDefault=propSize[0];export var propDirection=["horizontal","vertical"];export var propDirectionDefault=propDirection[0];export var propStatus=["normal","success","warning","alert"];export var propStatusDefault=propStatus[0];export var pointNumbersMap=[0,1,2,3,4,5,6,7,8,9];export var propPosition=["center","start","end"];export var propPositionDefault=propPosition[0];export var cnProgressStepBar=cn("ProgressStepBar");export var defaultGetItemLabel=function(a){return a.label};export var defaultGetItemTooltipContent=function(a){return a.tooltipContent};export var defaultGetItemPoint=function(a){return a.point};export var defaultGetItemLineStatus=function(a){return a.lineStatus};export var defaultGetItemProgress=function(a){return a.progress};export var defaultGetItemContent=function(a){return a.content};export var defaultGetItemStatus=function(a){return a.status};export var defaultGetItemOnClick=function(a){return a.onClick};export function withDefaultGetters(a){return _objectSpread(_objectSpread({},a),{},{getItemLabel:a.getItemLabel||defaultGetItemLabel,getItemTooltipContent:a.getItemTooltipContent||defaultGetItemTooltipContent,getItemPoint:a.getItemPoint||defaultGetItemPoint,getItemProgress:a.getItemProgress||defaultGetItemProgress,getItemContent:a.getItemContent||defaultGetItemContent,getItemStatus:a.getItemStatus||defaultGetItemStatus,getItemLineStatus:a.getItemLineStatus||defaultGetItemLineStatus,getItemOnClick:a.getItemOnClick||defaultGetItemOnClick})}export var getItemPosition=function(a,b){var c="center";return a===b-1&&(c="end"),0===a&&(c="start"),c};export var getLineSize=function(a,b,c){var d=0;if(a&&a.current&&b&&b.current){var e=a.current.getBoundingClientRect(),f=b.current.getBoundingClientRect();d="vertical"===c?f.y-e.y+f.height:f.x-e.x}return d};var getRefSize=function(a){if(a.current){var b=a.current.getBoundingClientRect(),c=b.width,d=b.height;return[c,d]}return[0,0]};export var calculateLines=function(a,b){var c=[];return a.forEach(function(d,e){if(e!==a.length-1){var f=getRefSize(d),g=getRefSize(a[e+1]),h=0;h=0===e?"horizontal"===b?f[0]+g[0]/2:f[1]:e===a.length-2?"horizontal"===b?f[0]/2+g[0]:f[1]:"horizontal"===b?f[0]/2+g[0]/2:f[1],c.push(h)}}),c};
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";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{cn}from"../../utils/bem";export var propSize=["s","xs","m"];export var propSizeDefault=propSize[0];export var propDirection=["horizontal","vertical"];export var propDirectionDefault=propDirection[0];export var propStatus=["normal","success","warning","alert"];export var propStatusDefault=propStatus[0];export var pointNumbersMap=[0,1,2,3,4,5,6,7,8,9];export var propPosition=["center","start","end"];export var propPositionDefault=propPosition[0];export var cnProgressStepBar=cn("ProgressStepBar");export var defaultGetItemLabel=function(a){return a.label};export var defaultGetItemTooltipContent=function(a){return a.tooltipContent};export var defaultGetItemPoint=function(a){return a.point};export var defaultGetItemLineStatus=function(a){return a.lineStatus};export var defaultGetItemProgress=function(a){return a.progress};export var defaultGetItemContent=function(a){return a.content};export var defaultGetItemStatus=function(a){return a.status};export var defaultGetItemOnClick=function(a){return a.onClick};export function withDefaultGetters(a){return _objectSpread(_objectSpread({},a),{},{getItemLabel:a.getItemLabel||defaultGetItemLabel,getItemTooltipContent:a.getItemTooltipContent||defaultGetItemTooltipContent,getItemPoint:a.getItemPoint||defaultGetItemPoint,getItemProgress:a.getItemProgress||defaultGetItemProgress,getItemContent:a.getItemContent||defaultGetItemContent,getItemStatus:a.getItemStatus||defaultGetItemStatus,getItemLineStatus:a.getItemLineStatus||defaultGetItemLineStatus,getItemOnClick:a.getItemOnClick||defaultGetItemOnClick})}export var getItemPosition=function(a,b){var c="center";return a===b-1&&(c="end"),0===a&&(c="start"),c};export var getLineSize=function(a,b,c){var d=0;if(a&&a.current&&b&&b.current){var e=a.current.getBoundingClientRect(),f=b.current.getBoundingClientRect();d="vertical"===c?f.y-e.y+f.height:f.x-e.x}return d};var getRefSize=function(a){if(a.current){var b=a.current.getBoundingClientRect(),c=b.width,d=b.height;return[c,d]}return[0,0]};export var calculateLines=function(a,b){for(var c=[],d=0;d<a.length-1;d++){var e=a[d],f=getRefSize(e),g=getRefSize(a[d+1]),h=0;h=0==d?"horizontal"===b?f[0]+g[0]/2:f[1]:d===a.length-2?"horizontal"===b?f[0]/2+g[0]:f[1]+2:"horizontal"===b?f[0]/2+g[0]/2:f[1],c.push(h)}return c};
2
2
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["cn","propSize","propSizeDefault","propDirection","propDirectionDefault","propStatus","propStatusDefault","pointNumbersMap","propPosition","propPositionDefault","cnProgressStepBar","defaultGetItemLabel","item","label","defaultGetItemTooltipContent","tooltipContent","defaultGetItemPoint","point","defaultGetItemLineStatus","lineStatus","defaultGetItemProgress","progress","defaultGetItemContent","content","defaultGetItemStatus","status","defaultGetItemOnClick","onClick","withDefaultGetters","props","getItemLabel","getItemTooltipContent","getItemPoint","getItemProgress","getItemContent","getItemStatus","getItemLineStatus","getItemOnClick","getItemPosition","index","lendth","position","getLineSize","container","activeElement","direction","size","current","containerPosition","getBoundingClientRect","activeElementPosition","y","height","x","getRefSize","ref","width","calculateLines","refs","sizes","forEach","length","firstSize","secondSize","push"],"sources":["../../../../../src/components/ProgressStepBar/helpers.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { cn } from '../../utils/bem';\nimport { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';\n\nexport const propSize = ['s', 'xs', 'm'] as const;\nexport type PropSize = typeof propSize[number];\nexport const propSizeDefault = propSize[0];\n\nexport const propDirection = ['horizontal', 'vertical'] as const;\nexport type PropDirection = typeof propDirection[number];\nexport const propDirectionDefault = propDirection[0];\n\nexport const propStatus = ['normal', 'success', 'warning', 'alert'] as const;\nexport type PropStatus = typeof propStatus[number];\nexport const propStatusDefault = propStatus[0];\n\nexport const pointNumbersMap = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] as const;\nexport type PointNumbersMap = typeof pointNumbersMap[number];\n\nexport const propPosition = ['center', 'start', 'end'] as const;\nexport type PropPosition = typeof propPosition[number];\nexport const propPositionDefault: PropPosition = propPosition[0];\n\nexport type PropGetItemLabel<ITEM> = (item: ITEM) => string | undefined;\nexport type PropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type PropGetItemTooltipContent<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type PropGetItemLineStatus<ITEM> = (\n item: ITEM,\n) => PropStatus | undefined;\nexport type PropGetItemPoint<ITEM> = (\n item: ITEM,\n) => PointNumbersMap | IconComponent | undefined;\nexport type PropGetItemProgress<ITEM> = (item: ITEM) => boolean | undefined;\nexport type PropGetItemContent<ITEM> = (\n item: ITEM,\n) => React.ReactNode | undefined;\nexport type PropGetItemStatus<ITEM> = (item: ITEM) => PropStatus | undefined;\nexport type PropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.EventHandler<React.MouseEvent> | undefined;\n\nexport type DefaultItem = {\n label?: string;\n tooltipContent?: string;\n lineStatus?: PropStatus;\n point?: PointNumbersMap | IconComponent;\n status?: PropStatus;\n progress?: boolean;\n content?: React.ReactNode;\n onClick?: React.EventHandler<React.MouseEvent>;\n};\n\nexport type Line = {\n status: PropStatus;\n size: number;\n};\n\nexport type ProgressStepBarProps<ITEM = DefaultItem> =\n PropsWithHTMLAttributesAndRef<\n {\n steps: ITEM[];\n direction?: PropDirection;\n size?: PropSize;\n activeStepIndex?: number;\n onItemClick?: (props: {\n e: React.MouseEvent;\n item: ITEM;\n index: number;\n }) => void;\n getItemLabel?: PropGetItemLabel<ITEM>;\n getItemLineStatus?: PropGetItemLineStatus<ITEM>;\n getItemTooltipContent?: PropGetItemTooltipContent<ITEM>;\n getItemPoint?: PropGetItemPoint<ITEM>;\n getItemProgress?: PropGetItemProgress<ITEM>;\n getItemContent?: PropGetItemContent<ITEM>;\n getItemStatus?: PropGetItemStatus<ITEM>;\n getItemOnClick?: PropGetItemOnClick<ITEM>;\n },\n HTMLDivElement\n > &\n (ITEM extends { label: DefaultItem['label'] }\n ? {}\n : { getItemLabel: PropGetItemLabel<ITEM> });\n\nexport type ProgressStepBarItemProps = {\n content?: React.ReactNode;\n label?: string;\n point?: PointNumbersMap | IconComponent;\n progress?: boolean;\n status?: PropStatus | 'system';\n tooltipContent?: string;\n tooltipZIndex?: number;\n position?: PropPosition;\n direction: PropDirection;\n size: PropSize;\n onClick?: (e: React.MouseEvent) => void;\n pointRef?: React.RefObject<HTMLButtonElement>;\n className?: string;\n};\n\nexport const cnProgressStepBar = cn('ProgressStepBar');\n\nexport const defaultGetItemLabel: PropGetItemLabel<DefaultItem> = (item) =>\n item.label;\nexport const defaultGetItemTooltipContent: PropGetItemTooltipContent<\n DefaultItem\n> = (item) => item.tooltipContent;\nexport const defaultGetItemPoint: PropGetItemPoint<DefaultItem> = (item) =>\n item.point;\nexport const defaultGetItemLineStatus: PropGetItemLineStatus<DefaultItem> = (\n item,\n) => item.lineStatus;\nexport const defaultGetItemProgress: PropGetItemProgress<DefaultItem> = (\n item,\n) => item.progress;\nexport const defaultGetItemContent: PropGetItemContent<DefaultItem> = (item) =>\n item.content;\nexport const defaultGetItemStatus: PropGetItemStatus<DefaultItem> = (item) =>\n item.status;\nexport const defaultGetItemOnClick: PropGetItemOnClick<DefaultItem> = (item) =>\n item.onClick;\n\nexport type ProgressStepBarComponent = <ITEM = DefaultItem>(\n props: ProgressStepBarProps<ITEM>,\n) => React.ReactElement | null;\n\nexport type ProgressStepBarItemComponent = (\n props: PropsWithHTMLAttributesAndRef<\n ProgressStepBarItemProps,\n HTMLDivElement\n >,\n) => React.ReactElement | null;\n\nexport function withDefaultGetters<ITEM>(props: ProgressStepBarProps<ITEM>) {\n return {\n ...props,\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemTooltipContent:\n props.getItemTooltipContent || defaultGetItemTooltipContent,\n getItemPoint: props.getItemPoint || defaultGetItemPoint,\n getItemProgress: props.getItemProgress || defaultGetItemProgress,\n getItemContent: props.getItemContent || defaultGetItemContent,\n getItemStatus: props.getItemStatus || defaultGetItemStatus,\n getItemLineStatus: props.getItemLineStatus || defaultGetItemLineStatus,\n getItemOnClick: props.getItemOnClick || defaultGetItemOnClick,\n };\n}\n\nexport const getItemPosition = (index: number, lendth: number) => {\n let position: PropPosition = 'center';\n if (index === lendth - 1) position = 'end';\n if (index === 0) position = 'start';\n\n return position;\n};\n\nexport const getLineSize: (\n container: React.RefObject<HTMLElement>,\n activeElement: React.RefObject<HTMLElement>,\n direction: PropDirection,\n) => number = (container, activeElement, direction) => {\n let size = 0;\n if (\n container &&\n container.current &&\n activeElement &&\n activeElement.current\n ) {\n const containerPosition = container.current.getBoundingClientRect();\n const activeElementPosition = activeElement.current.getBoundingClientRect();\n if (direction === 'vertical')\n size =\n activeElementPosition.y -\n containerPosition.y +\n activeElementPosition.height;\n else size = activeElementPosition.x - containerPosition.x;\n }\n return size;\n};\n\nconst getRefSize = (ref: React.RefObject<HTMLElement>) => {\n if (ref.current) {\n const { width, height } = ref.current.getBoundingClientRect();\n return [width, height];\n }\n return [0, 0];\n};\n\nexport const calculateLines = (\n refs: React.RefObject<HTMLElement>[],\n direction: PropDirection,\n) => {\n const sizes: number[] = [];\n refs.forEach((ref, index) => {\n if (index !== refs.length - 1) {\n const firstSize = getRefSize(ref);\n const secondSize = getRefSize(refs[index + 1]);\n let size = 0;\n if (index === 0) {\n size =\n direction === 'horizontal'\n ? firstSize[0] + secondSize[0] / 2\n : firstSize[1];\n } else if (index === refs.length - 2) {\n size =\n direction === 'horizontal'\n ? firstSize[0] / 2 + secondSize[0]\n : firstSize[1];\n } else {\n size =\n direction === 'horizontal'\n ? firstSize[0] / 2 + secondSize[0] / 2\n : firstSize[1];\n }\n sizes.push(size);\n }\n });\n return sizes;\n};\n"],"mappings":"qqBAGA,OAASA,EAAT,uBAGA,MAAO,IAAMC,SAAQ,CAAG,CAAC,GAAD,CAAM,IAA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CAgBX,YAAd,GAAAjB,CAAS,CACLiB,CAAS,CAAC,CAAD,CAAT,CAAe,CAAf,CAAmBC,CAAU,CAAC,CAAD,CAAV,CAAgB,CAD9B,CAELD,CAAS,CAAC,CAAD,CAlBY,CAoB7BH,CAAK,CAACK,IAAN,CAAWlB,CAAX,CACD,CACF,CAvBD,CAwBA,CAAOa,CACR,CA9BM"}
1
+ {"version":3,"file":"helpers.js","names":["cn","propSize","propSizeDefault","propDirection","propDirectionDefault","propStatus","propStatusDefault","pointNumbersMap","propPosition","propPositionDefault","cnProgressStepBar","defaultGetItemLabel","item","label","defaultGetItemTooltipContent","tooltipContent","defaultGetItemPoint","point","defaultGetItemLineStatus","lineStatus","defaultGetItemProgress","progress","defaultGetItemContent","content","defaultGetItemStatus","status","defaultGetItemOnClick","onClick","withDefaultGetters","props","getItemLabel","getItemTooltipContent","getItemPoint","getItemProgress","getItemContent","getItemStatus","getItemLineStatus","getItemOnClick","getItemPosition","index","lendth","position","getLineSize","container","activeElement","direction","size","current","containerPosition","getBoundingClientRect","activeElementPosition","y","height","x","getRefSize","ref","width","calculateLines","refs","sizes","i","length","firstSize","secondSize","push"],"sources":["../../../../../src/components/ProgressStepBar/helpers.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { cn } from '../../utils/bem';\nimport { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';\n\nexport const propSize = ['s', 'xs', 'm'] as const;\nexport type PropSize = typeof propSize[number];\nexport const propSizeDefault = propSize[0];\n\nexport const propDirection = ['horizontal', 'vertical'] as const;\nexport type PropDirection = typeof propDirection[number];\nexport const propDirectionDefault = propDirection[0];\n\nexport const propStatus = ['normal', 'success', 'warning', 'alert'] as const;\nexport type PropStatus = typeof propStatus[number];\nexport const propStatusDefault = propStatus[0];\n\nexport const pointNumbersMap = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] as const;\nexport type PointNumbersMap = typeof pointNumbersMap[number];\n\nexport const propPosition = ['center', 'start', 'end'] as const;\nexport type PropPosition = typeof propPosition[number];\nexport const propPositionDefault: PropPosition = propPosition[0];\n\nexport type PropGetItemLabel<ITEM> = (item: ITEM) => string | undefined;\nexport type PropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type PropGetItemTooltipContent<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type PropGetItemLineStatus<ITEM> = (\n item: ITEM,\n) => PropStatus | undefined;\nexport type PropGetItemPoint<ITEM> = (\n item: ITEM,\n) => PointNumbersMap | IconComponent | undefined;\nexport type PropGetItemProgress<ITEM> = (item: ITEM) => boolean | undefined;\nexport type PropGetItemContent<ITEM> = (\n item: ITEM,\n) => React.ReactNode | undefined;\nexport type PropGetItemStatus<ITEM> = (item: ITEM) => PropStatus | undefined;\nexport type PropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.EventHandler<React.MouseEvent> | undefined;\n\nexport type DefaultItem = {\n label?: string;\n tooltipContent?: string;\n lineStatus?: PropStatus;\n point?: PointNumbersMap | IconComponent;\n status?: PropStatus;\n progress?: boolean;\n content?: React.ReactNode;\n onClick?: React.EventHandler<React.MouseEvent>;\n};\n\nexport type Line = {\n status: PropStatus;\n size: number;\n};\n\nexport type ProgressStepBarProps<ITEM = DefaultItem> =\n PropsWithHTMLAttributesAndRef<\n {\n steps: ITEM[];\n direction?: PropDirection;\n size?: PropSize;\n activeStepIndex?: number;\n onItemClick?: (props: {\n e: React.MouseEvent;\n item: ITEM;\n index: number;\n }) => void;\n getItemLabel?: PropGetItemLabel<ITEM>;\n getItemLineStatus?: PropGetItemLineStatus<ITEM>;\n getItemTooltipContent?: PropGetItemTooltipContent<ITEM>;\n getItemPoint?: PropGetItemPoint<ITEM>;\n getItemProgress?: PropGetItemProgress<ITEM>;\n getItemContent?: PropGetItemContent<ITEM>;\n getItemStatus?: PropGetItemStatus<ITEM>;\n getItemOnClick?: PropGetItemOnClick<ITEM>;\n },\n HTMLDivElement\n > &\n (ITEM extends { label: DefaultItem['label'] }\n ? {}\n : { getItemLabel: PropGetItemLabel<ITEM> });\n\nexport type ProgressStepBarItemProps = {\n content?: React.ReactNode;\n label?: string;\n point?: PointNumbersMap | IconComponent;\n progress?: boolean;\n status?: PropStatus | 'system';\n tooltipContent?: string;\n tooltipZIndex?: number;\n position?: PropPosition;\n direction: PropDirection;\n size: PropSize;\n onClick?: (e: React.MouseEvent) => void;\n pointRef?: React.RefObject<HTMLButtonElement>;\n className?: string;\n};\n\nexport const cnProgressStepBar = cn('ProgressStepBar');\n\nexport const defaultGetItemLabel: PropGetItemLabel<DefaultItem> = (item) =>\n item.label;\nexport const defaultGetItemTooltipContent: PropGetItemTooltipContent<\n DefaultItem\n> = (item) => item.tooltipContent;\nexport const defaultGetItemPoint: PropGetItemPoint<DefaultItem> = (item) =>\n item.point;\nexport const defaultGetItemLineStatus: PropGetItemLineStatus<DefaultItem> = (\n item,\n) => item.lineStatus;\nexport const defaultGetItemProgress: PropGetItemProgress<DefaultItem> = (\n item,\n) => item.progress;\nexport const defaultGetItemContent: PropGetItemContent<DefaultItem> = (item) =>\n item.content;\nexport const defaultGetItemStatus: PropGetItemStatus<DefaultItem> = (item) =>\n item.status;\nexport const defaultGetItemOnClick: PropGetItemOnClick<DefaultItem> = (item) =>\n item.onClick;\n\nexport type ProgressStepBarComponent = <ITEM = DefaultItem>(\n props: ProgressStepBarProps<ITEM>,\n) => React.ReactElement | null;\n\nexport type ProgressStepBarItemComponent = (\n props: PropsWithHTMLAttributesAndRef<\n ProgressStepBarItemProps,\n HTMLDivElement\n >,\n) => React.ReactElement | null;\n\nexport function withDefaultGetters<ITEM>(props: ProgressStepBarProps<ITEM>) {\n return {\n ...props,\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemTooltipContent:\n props.getItemTooltipContent || defaultGetItemTooltipContent,\n getItemPoint: props.getItemPoint || defaultGetItemPoint,\n getItemProgress: props.getItemProgress || defaultGetItemProgress,\n getItemContent: props.getItemContent || defaultGetItemContent,\n getItemStatus: props.getItemStatus || defaultGetItemStatus,\n getItemLineStatus: props.getItemLineStatus || defaultGetItemLineStatus,\n getItemOnClick: props.getItemOnClick || defaultGetItemOnClick,\n };\n}\n\nexport const getItemPosition = (index: number, lendth: number) => {\n let position: PropPosition = 'center';\n if (index === lendth - 1) position = 'end';\n if (index === 0) position = 'start';\n\n return position;\n};\n\nexport const getLineSize: (\n container: React.RefObject<HTMLElement>,\n activeElement: React.RefObject<HTMLElement>,\n direction: PropDirection,\n) => number = (container, activeElement, direction) => {\n let size = 0;\n if (\n container &&\n container.current &&\n activeElement &&\n activeElement.current\n ) {\n const containerPosition = container.current.getBoundingClientRect();\n const activeElementPosition = activeElement.current.getBoundingClientRect();\n if (direction === 'vertical')\n size =\n activeElementPosition.y -\n containerPosition.y +\n activeElementPosition.height;\n else size = activeElementPosition.x - containerPosition.x;\n }\n return size;\n};\n\nconst getRefSize = (ref: React.RefObject<HTMLElement>) => {\n if (ref.current) {\n const { width, height } = ref.current.getBoundingClientRect();\n return [width, height];\n }\n return [0, 0];\n};\n\nexport const calculateLines = (\n refs: React.RefObject<HTMLElement>[],\n direction: PropDirection,\n) => {\n const sizes: number[] = [];\n for (let i = 0; i < refs.length - 1; i++) {\n const ref = refs[i];\n const firstSize = getRefSize(ref);\n const secondSize = getRefSize(refs[i + 1]);\n let size = 0;\n if (i === 0) {\n size =\n direction === 'horizontal'\n ? firstSize[0] + secondSize[0] / 2\n : firstSize[1];\n } else if (i === refs.length - 2) {\n size =\n direction === 'horizontal'\n ? firstSize[0] / 2 + secondSize[0]\n : firstSize[1] + 2;\n } else {\n size =\n direction === 'horizontal'\n ? firstSize[0] / 2 + secondSize[0] / 2\n : firstSize[1];\n }\n sizes.push(size);\n }\n\n return sizes;\n};\n"],"mappings":"qqBAGA,OAASA,EAAT,uBAGA,MAAO,IAAMC,SAAQ,CAAG,CAAC,GAAD,CAAM,IAAN,CAAY,GAAZ,CAAjB,CAEP,MAAO,IAAMC,gBAAe,CAAG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CACLiB,CAAS,CAAC,CAAD,CAAT,CAAe,CAAf,CAAmBC,CAAU,CAAC,CAAD,CAAV,CAAgB,CAD9B,CAELD,CAAS,CAAC,CAAD,CAnBuB,CAqBxCH,CAAK,CAACK,IAAN,CAAWlB,CAAX,CACD,CAED,MAAOa,EACR,CA9BM"}
@@ -1,2 +1,2 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["min","max","onChange","onAfterChange","value","step","disabled","size","view","leftSide","rightSide","withTooltip","range","label","labelIcon","status","caption","tooltipFormatter","className","style"];import"./Slider.css";import React,{forwardRef,useRef,useState}from"react";import{usePropsHandler}from"../EventInterceptor/usePropsHandler";import{FieldCaption}from"../FieldCaption";import{FieldLabel}from"../FieldLabel";import{useFlag}from"../../hooks/useFlag";import{useForkRef}from"../../hooks/useForkRef";import{useSortSteps}from"../../hooks/useSortSteps";import{cn}from"../../utils/bem";import{defaultPropSize,defaultTooltipFormatter,getIcon,getMaxForStartField,getMinForEndField,getOnChandgeForInput,getValidStep,getValueForInput,isRangeParams}from"./helper";import{SliderInput}from"./SliderInput/SliderInput";import{SliderLine}from"./SliderLine/SliderLine";import{SliderPoint}from"./SliderPoint/SliderPoint";import{useSlider}from"./useSlider/useSlider";import{useSliderStationing}from"./useSliderStationing";var cnSlider=cn("Slider"),sizeMap={xs:"xs",s:"s",m:"m",l:"m"};export var COMPONENT_NAME="Slider";var SliderRender=function(a,b){var c=useRef(null),d=usePropsHandler(COMPONENT_NAME,a,c),e=d.min,f=void 0===e?0:e,g=d.max,h=void 0===g?100:g,i=d.onChange,j=d.onAfterChange,k=d.value,l=d.step,m=d.disabled,n=void 0!==m&&m,o=d.size,p=void 0===o?defaultPropSize:o,q=d.view,r=void 0===q?"default":q,s=d.leftSide,t=d.rightSide,u=d.withTooltip,v=d.range,w=void 0!==v&&v,x=d.label,y=d.labelIcon,z=d.status,A=d.caption,B=d.tooltipFormatter,C=void 0===B?defaultTooltipFormatter:B,D=d.className,E=d.style,F=_objectWithoutProperties(d,_excluded),G=useState(),H=_slicedToArray(G,2),I=H[0],J=H[1],K=useFlag(!1),L=_slicedToArray(K,2),M=L[0],N=L[1],O=N.on,P=N.off,Q=useRef(null),R=useRef(null),S=useRef(null),T=useSortSteps({step:getValidStep(f,h,l),min:f,max:h}),U=l?T:Math.abs((h-f)/100),V=getIcon(t),W=getIcon(s),X=sizeMap[p],Y=useSlider({disabled:n,range:w,value:k,min:f,max:h,step:U,onChange:i,onAfterChange:j,sliderRef:c,containerRef:Q,buttonRefs:[R,S]}),Z=Y.onKeyPress,$=Y.onFocus,_=Y.handlePress,aa=Y.onSliderClick,ba=Y.popoverPosition,ca=Y.activeButton,da=Y.currentValue,ea=useSliderStationing(1===da.length?da[0]:da,f,h,r,w,U,[R,S],c),fa=ea.lineSizes,ga=ea.buttonPositions,ha={role:"button",tabIndex:0,className:cnSlider("Control"),ref:c,onClick:aa},ia=function(a){a?O():P()};return React.createElement("div",Object.assign({ref:useForkRef([b,Q]),className:cnSlider({size:p},[D]),style:E},F),x&&React.createElement(FieldLabel,{icon:y,className:cnSlider("Label"),size:p},x),React.createElement("div",{className:cnSlider("Container")},("input"===s||W)&&React.createElement("div",{className:cnSlider("Side",{position:"left"})},"input"===s&&React.createElement(SliderInput,{value:getValueForInput(a,0),onFocus:function(){return J(0)},onBlur:function onBlur(){return J(void 0)},onChange:getOnChandgeForInput(a,0),size:p,min:f,inputMode:"numeric",max:getMaxForStartField(a),status:z,step:U,disabled:n}),W&&React.createElement(W,{size:null!==X&&void 0!==X?X:void 0,view:"secondary"})),React.createElement("div",ha,React.createElement(SliderLine,{hovered:M||"number"==typeof ca,onHover:ia,lines:fa,disabled:n,view:r}),da.map(function(a,b){var c=1<da.length&&da[0]===da[1]&&a===h&&0===b;return React.createElement(SliderPoint,{hovered:M||"number"==typeof ca,buttonRef:R,popoverPosition:ba[b],onKeyPress:Z,onFocus:$,handlePress:_,disabled:n,active:c,position:ga[b],focused:ca===b||I===b,buttonLabel:b,withTooltip:u,onHover:ia,tooltipFormatter:C,value:a,role:"slider","aria-valuemin":f,"aria-valuemax":h,"aria-valuenow":a,tooltipZIndex:"number"==typeof(null===E||void 0===E?void 0:E.zIndex)?E.zIndex+1:void 0,key:cnSlider("Point",{index:b})})})),("input"===t||V)&&React.createElement("div",{className:cnSlider("Side",{position:"right"})},"input"===t&&React.createElement(SliderInput,{value:getValueForInput(a,1),onChange:getOnChandgeForInput(a,1),onBlur:function onBlur(){return J(void 0)},size:p,min:getMinForEndField(a),max:h,onFocus:function(){return J(isRangeParams(a)?1:0)},inputMode:"numeric",status:z,step:U,disabled:n}),V&&React.createElement(V,{size:X,view:"secondary"}))),A&&React.createElement(FieldCaption,{className:cnSlider("Caption"),status:z},A))};export var Slider=forwardRef(SliderRender);
1
+ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["min","max","onChange","onAfterChange","value","step","disabled","size","view","leftSide","rightSide","withTooltip","range","label","tooltipDirection","tooltipPossibleDirections","labelIcon","status","caption","tooltipFormatter","className","style"];import"./Slider.css";import React,{forwardRef,useRef,useState}from"react";import{usePropsHandler}from"../EventInterceptor/usePropsHandler";import{FieldCaption}from"../FieldCaption";import{FieldLabel}from"../FieldLabel";import{useFlag}from"../../hooks/useFlag";import{useForkRef}from"../../hooks/useForkRef";import{useSortSteps}from"../../hooks/useSortSteps";import{cn}from"../../utils/bem";import{defaultPropSize,defaultTooltipFormatter,getIcon,getMaxForStartField,getMinForEndField,getOnChandgeForInput,getValidStep,getValueForInput,isRangeParams}from"./helper";import{SliderInput}from"./SliderInput/SliderInput";import{SliderLine}from"./SliderLine/SliderLine";import{SliderPoint}from"./SliderPoint/SliderPoint";import{useSlider}from"./useSlider/useSlider";import{useSliderStationing}from"./useSliderStationing";var cnSlider=cn("Slider"),sizeMap={xs:"xs",s:"s",m:"m",l:"m"};export var COMPONENT_NAME="Slider";var SliderRender=function(a,b){var c=useRef(null),d=usePropsHandler(COMPONENT_NAME,a,c),e=d.min,f=void 0===e?0:e,g=d.max,h=void 0===g?100:g,i=d.onChange,j=d.onAfterChange,k=d.value,l=d.step,m=d.disabled,n=void 0!==m&&m,o=d.size,p=void 0===o?defaultPropSize:o,q=d.view,r=void 0===q?"default":q,s=d.leftSide,t=d.rightSide,u=d.withTooltip,v=d.range,w=void 0!==v&&v,x=d.label,y=d.tooltipDirection,z=d.tooltipPossibleDirections,A=d.labelIcon,B=d.status,C=d.caption,D=d.tooltipFormatter,E=void 0===D?defaultTooltipFormatter:D,F=d.className,G=d.style,H=_objectWithoutProperties(d,_excluded),I=useState(),J=_slicedToArray(I,2),K=J[0],L=J[1],M=useFlag(!1),N=_slicedToArray(M,2),O=N[0],P=N[1],Q=P.on,R=P.off,S=useRef(null),T=useRef(null),U=useRef(null),V=useSortSteps({step:getValidStep(f,h,l),min:f,max:h}),W=l?V:Math.abs((h-f)/100),X=getIcon(t),Y=getIcon(s),Z=sizeMap[p],$=useSlider({disabled:n,range:w,value:k,min:f,max:h,step:W,onChange:i,onAfterChange:j,sliderRef:c,containerRef:S,buttonRefs:[T,U]}),_=$.onKeyPress,aa=$.onFocus,ba=$.handlePress,ca=$.onSliderClick,da=$.popoverPosition,ea=$.activeButton,fa=$.currentValue,ga=useSliderStationing(1===fa.length?fa[0]:fa,f,h,r,w,W,[T,U],c),ha=ga.lineSizes,ia=ga.buttonPositions,ja={role:"button",tabIndex:0,className:cnSlider("Control"),ref:c,onClick:ca},ka=function(a){a?Q():R()};return React.createElement("div",Object.assign({ref:useForkRef([b,S]),className:cnSlider({size:p},[F]),style:G},H),x&&React.createElement(FieldLabel,{icon:A,className:cnSlider("Label"),size:p},x),React.createElement("div",{className:cnSlider("Container")},("input"===s||Y)&&React.createElement("div",{className:cnSlider("Side",{position:"left"})},"input"===s&&React.createElement(SliderInput,{value:getValueForInput(a,0),onFocus:function(){return L(0)},onBlur:function onBlur(){return L(void 0)},onChange:getOnChandgeForInput(a,0),size:p,min:f,inputMode:"numeric",max:getMaxForStartField(a),status:B,step:W,disabled:n}),Y&&React.createElement(Y,{size:null!==Z&&void 0!==Z?Z:void 0,view:"secondary"})),React.createElement("div",ja,React.createElement(SliderLine,{hovered:O||"number"==typeof ea,onHover:ka,lines:ha,disabled:n,view:r}),fa.map(function(a,b){var c=1<fa.length&&fa[0]===fa[1]&&a===h&&0===b;return React.createElement(SliderPoint,{hovered:O||"number"==typeof ea,buttonRef:T,popoverPosition:da[b],onKeyPress:_,onFocus:aa,tooltipDirection:y,tooltipPossibleDirections:z,handlePress:ba,disabled:n,active:c,position:ia[b],focused:ea===b||K===b,buttonLabel:b,withTooltip:u,onHover:ka,tooltipFormatter:E,value:a,role:"slider","aria-valuemin":f,"aria-valuemax":h,"aria-valuenow":a,tooltipZIndex:"number"==typeof(null===G||void 0===G?void 0:G.zIndex)?G.zIndex+1:void 0,key:cnSlider("Point",{index:b})})})),("input"===t||X)&&React.createElement("div",{className:cnSlider("Side",{position:"right"})},"input"===t&&React.createElement(SliderInput,{value:getValueForInput(a,1),onChange:getOnChandgeForInput(a,1),onBlur:function onBlur(){return L(void 0)},size:p,min:getMinForEndField(a),max:h,onFocus:function(){return L(isRangeParams(a)?1:0)},inputMode:"numeric",status:B,step:W,disabled:n}),X&&React.createElement(X,{size:Z,view:"secondary"}))),C&&React.createElement(FieldCaption,{className:cnSlider("Caption"),status:B},C))};export var Slider=forwardRef(SliderRender);
2
2
  //# sourceMappingURL=Slider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Slider.js","names":["React","forwardRef","useRef","useState","usePropsHandler","FieldCaption","FieldLabel","useFlag","useForkRef","useSortSteps","cn","defaultPropSize","defaultTooltipFormatter","getIcon","getMaxForStartField","getMinForEndField","getOnChandgeForInput","getValidStep","getValueForInput","isRangeParams","SliderInput","SliderLine","SliderPoint","useSlider","useSliderStationing","cnSlider","sizeMap","xs","s","m","l","COMPONENT_NAME","SliderRender","props","ref","sliderRef","min","max","onChange","onAfterChange","value","stepProp","step","disabled","size","view","leftSide","rightSide","withTooltip","range","label","labelIcon","status","caption","tooltipFormatter","className","style","otherProps","focusIndex","setFocusIndex","isHovered","on","off","containerRef","leftButtonRef","rightButtonRef","sortedSteps","Math","abs","IconRight","IconLeft","iconSize","buttonRefs","onKeyPress","onFocus","handlePress","onSliderClick","popoverPosition","activeButton","currentValue","length","lineSizes","buttonPositions","containerProps","role","tabIndex","onClick","changeHovered","position","map","val","index","topLayer","zIndex","Slider"],"sources":["../../../../../src/components/Slider/Slider.tsx"],"sourcesContent":["import './Slider.css';\n\nimport { IconPropSize } from '@consta/icons/Icon';\nimport React, { forwardRef, useRef, useState } from 'react';\n\nimport { usePropsHandler } from '##/components/EventInterceptor/usePropsHandler';\nimport { FieldCaption } from '##/components/FieldCaption';\nimport { FieldLabel } from '##/components/FieldLabel';\nimport { useFlag } from '##/hooks/useFlag';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { useSortSteps } from '##/hooks/useSortSteps';\nimport { cn } from '##/utils/bem';\n\nimport {\n defaultPropSize,\n defaultTooltipFormatter,\n getIcon,\n getMaxForStartField,\n getMinForEndField,\n getOnChandgeForInput,\n getValidStep,\n getValueForInput,\n isRangeParams,\n PropSize,\n SliderComponent,\n SliderProps,\n} from './helper';\nimport { SliderInput } from './SliderInput/SliderInput';\nimport { SliderLine } from './SliderLine/SliderLine';\nimport { SliderPoint } from './SliderPoint/SliderPoint';\nimport { ActiveButton } from './useSlider/helper';\nimport { useSlider } from './useSlider/useSlider';\nimport { useSliderStationing } from './useSliderStationing';\n\nconst cnSlider = cn('Slider');\n\nconst sizeMap: Record<PropSize, IconPropSize> = {\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'm',\n};\n\nexport const COMPONENT_NAME = 'Slider' as const;\n\nconst SliderRender = <RANGE extends boolean = false>(\n props: SliderProps<RANGE>,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const sliderRef = useRef<HTMLDivElement>(null);\n\n const {\n min = 0,\n max = 100,\n onChange,\n onAfterChange,\n value,\n step: stepProp,\n disabled = false,\n size = defaultPropSize,\n view = 'default',\n leftSide,\n rightSide,\n withTooltip,\n range = false,\n label,\n labelIcon,\n status,\n caption,\n tooltipFormatter = defaultTooltipFormatter,\n className,\n style,\n ...otherProps\n } = usePropsHandler(COMPONENT_NAME, props, sliderRef);\n\n const [focusIndex, setFocusIndex] = useState<number | undefined>();\n const [isHovered, { on, off }] = useFlag(false);\n const containerRef = useRef<HTMLDivElement>(null);\n const leftButtonRef = useRef<HTMLButtonElement>(null);\n const rightButtonRef = useRef<HTMLButtonElement>(null);\n const sortedSteps = useSortSteps({\n step: getValidStep(min, max, stepProp),\n min,\n max,\n });\n const step = stepProp ? sortedSteps : Math.abs((max - min) / 100);\n const IconRight = getIcon(rightSide);\n const IconLeft = getIcon(leftSide);\n const iconSize = sizeMap[size];\n\n const {\n onKeyPress,\n onFocus,\n handlePress,\n onSliderClick,\n popoverPosition,\n activeButton,\n currentValue,\n } = useSlider({\n disabled,\n range,\n value,\n min,\n max,\n step,\n onChange,\n onAfterChange,\n sliderRef,\n containerRef,\n buttonRefs: [leftButtonRef, rightButtonRef],\n });\n\n const { lineSizes, buttonPositions } = useSliderStationing(\n currentValue.length === 1 ? currentValue[0] : currentValue,\n min,\n max,\n view,\n range,\n step,\n [leftButtonRef, rightButtonRef],\n sliderRef,\n );\n\n const containerProps = {\n role: 'button',\n tabIndex: 0,\n className: cnSlider('Control'),\n ref: sliderRef,\n onClick: onSliderClick,\n };\n\n const changeHovered = (status: boolean) => {\n if (status) on();\n else off();\n };\n\n return (\n <div\n ref={useForkRef([ref, containerRef])}\n className={cnSlider({ size }, [className])}\n style={style}\n {...otherProps}\n >\n {label && (\n <FieldLabel icon={labelIcon} className={cnSlider('Label')} size={size}>\n {label}\n </FieldLabel>\n )}\n <div className={cnSlider('Container')}>\n {(leftSide === 'input' || IconLeft) && (\n <div className={cnSlider('Side', { position: 'left' })}>\n {leftSide === 'input' && (\n <SliderInput\n value={getValueForInput(props, 0)}\n onFocus={() => setFocusIndex(0)}\n onBlur={() => setFocusIndex(undefined)}\n onChange={getOnChandgeForInput(props, 0)}\n size={size}\n min={min}\n inputMode=\"numeric\"\n max={getMaxForStartField(props)}\n status={status}\n step={step}\n disabled={disabled}\n />\n )}\n {IconLeft && (\n <IconLeft size={iconSize ?? undefined} view=\"secondary\" />\n )}\n </div>\n )}\n <div {...containerProps}>\n <SliderLine\n hovered={isHovered || typeof activeButton === 'number'}\n onHover={changeHovered}\n lines={lineSizes}\n disabled={disabled}\n view={view}\n />\n {currentValue.map((val, index) => {\n // let isActive = true;\n // if (\n // currentValue.length > 1 &&\n // currentValue[0] === currentValue[1]\n // ) {\n // if (index === 0 && val === min) {\n // isActive = false;\n // }\n // if (index === 1 && val === max) {\n // isActive = false;\n // }\n // }\n const topLayer =\n currentValue.length > 1 &&\n currentValue[0] === currentValue[1] &&\n val === max &&\n index === 0;\n return (\n <SliderPoint\n hovered={isHovered || typeof activeButton === 'number'}\n buttonRef={leftButtonRef}\n popoverPosition={popoverPosition[index]}\n onKeyPress={onKeyPress}\n onFocus={onFocus}\n handlePress={handlePress}\n disabled={disabled}\n active={topLayer}\n position={buttonPositions[index]}\n focused={activeButton === index || focusIndex === index}\n buttonLabel={index as ActiveButton}\n withTooltip={withTooltip}\n onHover={changeHovered}\n tooltipFormatter={tooltipFormatter}\n value={val}\n role=\"slider\"\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuenow={val}\n tooltipZIndex={\n typeof style?.zIndex === 'number'\n ? style.zIndex + 1\n : undefined\n }\n key={cnSlider('Point', { index })}\n />\n );\n })}\n </div>\n {(rightSide === 'input' || IconRight) && (\n <div className={cnSlider('Side', { position: 'right' })}>\n {rightSide === 'input' && (\n <SliderInput\n value={getValueForInput(props, 1)}\n onChange={getOnChandgeForInput(props, 1)}\n onBlur={() => setFocusIndex(undefined)}\n size={size}\n min={getMinForEndField(props)}\n max={max}\n onFocus={() => setFocusIndex(isRangeParams(props) ? 1 : 0)}\n inputMode=\"numeric\"\n status={status}\n step={step}\n disabled={disabled}\n />\n )}\n {IconRight && <IconRight size={iconSize} view=\"secondary\" />}\n </div>\n )}\n </div>\n {caption && (\n <FieldCaption className={cnSlider('Caption')} status={status}>\n {caption}\n </FieldCaption>\n )}\n </div>\n );\n};\n\nexport const Slider = forwardRef(SliderRender) as SliderComponent;\n"],"mappings":"gXAAA,qBAGA,MAAOA,MAAP,EAAgBC,UAAhB,CAA4BC,MAA5B,CAAoCC,QAApC,KAAoD,OAApD,CAEA,OAASC,eAAT,2CACA,OAASC,YAAT,uBACA,OAASC,UAAT,qBACA,OAASC,OAAT,2BACA,OAASC,UAAT,8BACA,OAASC,YAAT,gCACA,OAASC,EAAT,uBAEA,OACEC,eADF,CAEEC,uBAFF,CAGEC,OAHF,CAIEC,mBAJF,CAKEC,iBALF,CAMEC,oBANF,CAOEC,YAPF,CAQEC,gBARF,CASEC,aATF,gBAcA,OAASC,WAAT,iCACA,OAASC,UAAT,+BACA,OAASC,WAAT,iCAEA,OAASC,SAAT,6BACA,OAASC,mBAAT,6B,GAEMC,SAAQ,CAAGf,EAAE,CAAC,QAAD,C,CAEbgB,OAAuC,CAAG,CAC9CC,EAAE,CAAE,IAD0C,CAE9CC,CAAC,CAAE,GAF2C,CAG9CC,CAAC,CAAE,GAH2C,CAI9CC,CAAC,CAAE,GAJ2C,C,CAOhD,MAAO,IAAMC,eAAc,CAAG,QAAvB,CAEP,GAAMC,aAAY,CAAG,SACnBC,CADmB,CAEnBC,CAFmB,CAGhB,IACGC,EAAS,CAAGjC,MAAM,CAAiB,IAAjB,CADrB,GAyBCE,eAAe,CAAC2B,cAAD,CAAiBE,CAAjB,CAAwBE,CAAxB,CAzBhB,KAIDC,GAJC,CAIDA,CAJC,YAIK,CAJL,OAKDC,GALC,CAKDA,CALC,YAKK,GALL,GAMDC,CANC,GAMDA,QANC,CAODC,CAPC,GAODA,aAP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kE,KAAK,CAALA,CAAF,CAAV,CAzBf,EA4BH,CA/CA,CARH,CAvBF,CAgFG,CAAe,OAAd,GAAA5C,CAAS,EAAgBsB,CAA1B,GACC,2BAAK,SAAS,CAAE5C,QAAQ,CAAC,MAAD,CAAS,CAAE+D,QAAQ,CAAE,OAAZ,CAAT,CAAxB,EACiB,OAAd,GAAAzC,CAAS,EACR,oBAAC,WAAD,EACE,KAAK,CAAE7B,gBAAgB,CAACe,CAAD,CAAQ,CAAR,CADzB,CAEE,QAAQ,CAAEjB,oBAAoB,CAACiB,CAAD,CAAQ,CAAR,CAFhC,CAGE,MAAM,CAAE,wBAAM0B,EAAa,QAAnB,CAHV,CAIE,IAAI,CAAEf,CAJR,CAKE,GAAG,CAAE7B,iBAAiB,CAACkB,CAAD,CALxB,CAME,GAAG,CAAEI,CANP,CAOE,OAAO,CAAE,iBAAMsB,EAAa,CAACxC,aAAa,CAACc,CAAD,CAAb,CAAuB,CAAvB,CAA2B,CAA5B,CAAnB,CAPX,CAQE,SAAS,CAAC,SARZ,CASE,MAAM,CAAEmB,CATV,CAUE,IAAI,CAAEV,CAVR,CAWE,QAAQ,CAAEC,CAXZ,EAFJ,CAgBG0B,CAAS,EAAI,oBAAC,CAAD,EAAW,IAAI,CAAEE,CAAjB,CAA2B,IAAI,CAAC,WAAhC,EAhBhB,CAjFJ,CAXF,CAgHGlB,CAAO,EACN,oBAAC,YAAD,EAAc,SAAS,CAAE5B,QAAQ,CAAC,SAAD,CAAjC,CAA8C,MAAM,CAAE2B,CAAtD,EACGC,CADH,CAjHJ,CAuHH,CAnND,CAqNA,MAAO,IAAMyC,OAAM,CAAG7F,UAAU,CAAC+B,YAAD,CAAzB"}
1
+ {"version":3,"file":"Slider.js","names":["React","forwardRef","useRef","useState","usePropsHandler","FieldCaption","FieldLabel","useFlag","useForkRef","useSortSteps","cn","defaultPropSize","defaultTooltipFormatter","getIcon","getMaxForStartField","getMinForEndField","getOnChandgeForInput","getValidStep","getValueForInput","isRangeParams","SliderInput","SliderLine","SliderPoint","useSlider","useSliderStationing","cnSlider","sizeMap","xs","s","m","l","COMPONENT_NAME","SliderRender","props","ref","sliderRef","min","max","onChange","onAfterChange","value","stepProp","step","disabled","size","view","leftSide","rightSide","withTooltip","range","label","tooltipDirection","tooltipPossibleDirections","labelIcon","status","caption","tooltipFormatter","className","style","otherProps","focusIndex","setFocusIndex","isHovered","on","off","containerRef","leftButtonRef","rightButtonRef","sortedSteps","Math","abs","IconRight","IconLeft","iconSize","buttonRefs","onKeyPress","onFocus","handlePress","onSliderClick","popoverPosition","activeButton","currentValue","length","lineSizes","buttonPositions","containerProps","role","tabIndex","onClick","changeHovered","position","map","val","index","topLayer","zIndex","Slider"],"sources":["../../../../../src/components/Slider/Slider.tsx"],"sourcesContent":["import './Slider.css';\n\nimport { IconPropSize } from '@consta/icons/Icon';\nimport React, { forwardRef, useRef, useState } from 'react';\n\nimport { usePropsHandler } from '##/components/EventInterceptor/usePropsHandler';\nimport { FieldCaption } from '##/components/FieldCaption';\nimport { FieldLabel } from '##/components/FieldLabel';\nimport { useFlag } from '##/hooks/useFlag';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { useSortSteps } from '##/hooks/useSortSteps';\nimport { cn } from '##/utils/bem';\n\nimport {\n defaultPropSize,\n defaultTooltipFormatter,\n getIcon,\n getMaxForStartField,\n getMinForEndField,\n getOnChandgeForInput,\n getValidStep,\n getValueForInput,\n isRangeParams,\n PropSize,\n SliderComponent,\n SliderProps,\n} from './helper';\nimport { SliderInput } from './SliderInput/SliderInput';\nimport { SliderLine } from './SliderLine/SliderLine';\nimport { SliderPoint } from './SliderPoint/SliderPoint';\nimport { ActiveButton } from './useSlider/helper';\nimport { useSlider } from './useSlider/useSlider';\nimport { useSliderStationing } from './useSliderStationing';\n\nconst cnSlider = cn('Slider');\n\nconst sizeMap: Record<PropSize, IconPropSize> = {\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'm',\n};\n\nexport const COMPONENT_NAME = 'Slider' as const;\n\nconst SliderRender = <RANGE extends boolean = false>(\n props: SliderProps<RANGE>,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const sliderRef = useRef<HTMLDivElement>(null);\n\n const {\n min = 0,\n max = 100,\n onChange,\n onAfterChange,\n value,\n step: stepProp,\n disabled = false,\n size = defaultPropSize,\n view = 'default',\n leftSide,\n rightSide,\n withTooltip,\n range = false,\n label,\n tooltipDirection,\n tooltipPossibleDirections,\n labelIcon,\n status,\n caption,\n tooltipFormatter = defaultTooltipFormatter,\n className,\n style,\n ...otherProps\n } = usePropsHandler(COMPONENT_NAME, props, sliderRef);\n\n const [focusIndex, setFocusIndex] = useState<number | undefined>();\n const [isHovered, { on, off }] = useFlag(false);\n const containerRef = useRef<HTMLDivElement>(null);\n const leftButtonRef = useRef<HTMLButtonElement>(null);\n const rightButtonRef = useRef<HTMLButtonElement>(null);\n const sortedSteps = useSortSteps({\n step: getValidStep(min, max, stepProp),\n min,\n max,\n });\n const step = stepProp ? sortedSteps : Math.abs((max - min) / 100);\n const IconRight = getIcon(rightSide);\n const IconLeft = getIcon(leftSide);\n const iconSize = sizeMap[size];\n\n const {\n onKeyPress,\n onFocus,\n handlePress,\n onSliderClick,\n popoverPosition,\n activeButton,\n currentValue,\n } = useSlider({\n disabled,\n range,\n value,\n min,\n max,\n step,\n onChange,\n onAfterChange,\n sliderRef,\n containerRef,\n buttonRefs: [leftButtonRef, rightButtonRef],\n });\n\n const { lineSizes, buttonPositions } = useSliderStationing(\n currentValue.length === 1 ? currentValue[0] : currentValue,\n min,\n max,\n view,\n range,\n step,\n [leftButtonRef, rightButtonRef],\n sliderRef,\n );\n\n const containerProps = {\n role: 'button',\n tabIndex: 0,\n className: cnSlider('Control'),\n ref: sliderRef,\n onClick: onSliderClick,\n };\n\n const changeHovered = (status: boolean) => {\n if (status) on();\n else off();\n };\n\n return (\n <div\n ref={useForkRef([ref, containerRef])}\n className={cnSlider({ size }, [className])}\n style={style}\n {...otherProps}\n >\n {label && (\n <FieldLabel icon={labelIcon} className={cnSlider('Label')} size={size}>\n {label}\n </FieldLabel>\n )}\n <div className={cnSlider('Container')}>\n {(leftSide === 'input' || IconLeft) && (\n <div className={cnSlider('Side', { position: 'left' })}>\n {leftSide === 'input' && (\n <SliderInput\n value={getValueForInput(props, 0)}\n onFocus={() => setFocusIndex(0)}\n onBlur={() => setFocusIndex(undefined)}\n onChange={getOnChandgeForInput(props, 0)}\n size={size}\n min={min}\n inputMode=\"numeric\"\n max={getMaxForStartField(props)}\n status={status}\n step={step}\n disabled={disabled}\n />\n )}\n {IconLeft && (\n <IconLeft size={iconSize ?? undefined} view=\"secondary\" />\n )}\n </div>\n )}\n <div {...containerProps}>\n <SliderLine\n hovered={isHovered || typeof activeButton === 'number'}\n onHover={changeHovered}\n lines={lineSizes}\n disabled={disabled}\n view={view}\n />\n {currentValue.map((val, index) => {\n const topLayer =\n currentValue.length > 1 &&\n currentValue[0] === currentValue[1] &&\n val === max &&\n index === 0;\n return (\n <SliderPoint\n hovered={isHovered || typeof activeButton === 'number'}\n buttonRef={leftButtonRef}\n popoverPosition={popoverPosition[index]}\n onKeyPress={onKeyPress}\n onFocus={onFocus}\n tooltipDirection={tooltipDirection}\n tooltipPossibleDirections={tooltipPossibleDirections}\n handlePress={handlePress}\n disabled={disabled}\n active={topLayer}\n position={buttonPositions[index]}\n focused={activeButton === index || focusIndex === index}\n buttonLabel={index as ActiveButton}\n withTooltip={withTooltip}\n onHover={changeHovered}\n tooltipFormatter={tooltipFormatter}\n value={val}\n role=\"slider\"\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuenow={val}\n tooltipZIndex={\n typeof style?.zIndex === 'number'\n ? style.zIndex + 1\n : undefined\n }\n key={cnSlider('Point', { index })}\n />\n );\n })}\n </div>\n {(rightSide === 'input' || IconRight) && (\n <div className={cnSlider('Side', { position: 'right' })}>\n {rightSide === 'input' && (\n <SliderInput\n value={getValueForInput(props, 1)}\n onChange={getOnChandgeForInput(props, 1)}\n onBlur={() => setFocusIndex(undefined)}\n size={size}\n min={getMinForEndField(props)}\n max={max}\n onFocus={() => setFocusIndex(isRangeParams(props) ? 1 : 0)}\n inputMode=\"numeric\"\n status={status}\n step={step}\n disabled={disabled}\n />\n )}\n {IconRight && <IconRight size={iconSize} view=\"secondary\" />}\n </div>\n )}\n </div>\n {caption && (\n <FieldCaption className={cnSlider('Caption')} status={status}>\n {caption}\n </FieldCaption>\n )}\n </div>\n );\n};\n\nexport const Slider = forwardRef(SliderRender) as SliderComponent;\n"],"mappings":"+ZAAA,qBAGA,MAAOA,MAAP,EAAgBC,UAAhB,CAA4BC,MAA5B,CAAoCC,QAApC,KAAoD,OAApD,CAEA,OAASC,eAAT,2CACA,OAASC,YAAT,uBACA,OAASC,UAAT,qBACA,OAASC,OAAT,2BACA,OAASC,UAAT,8BACA,OAASC,YAAT,gCACA,OAASC,EAAT,uBAEA,OACEC,eADF,CAEEC,uBAFF,CAGEC,OAHF,CAIEC,mBAJF,CAKEC,iBALF,CAMEC,oBANF,CAOEC,YAPF,CAQEC,gBARF,CASEC,aATF,gBAcA,OAASC,WAAT,iCACA,OAASC,UAAT,+BACA,OAASC,WAAT,iCAEA,OAASC,SAAT,6BACA,OAASC,mBAAT,6B,GAEMC,SAAQ,CAAGf,EAAE,CAAC,QAAD,C,CAEbgB,OAAuC,CAAG,CAC9CC,EAAE,CAAE,IAD0C,CAE9CC,CAAC,CAAE,GAF2C,CAG9CC,CAAC,CAAE,GAH2C,CAI9CC,CAAC,CAAE,GAJ2C,C,CAOhD,MAAO,IAAMC,eAAc,CAAG,QAAvB,CAEP,GAAMC,aAAY,CAAG,SACnBC,CADmB,CAEnBC,CAFmB,CAGhB,IACGC,EAAS,CAAGjC,MAAM,CAAiB,IAAjB,CADrB,GA2BCE,eAAe,CAAC2B,cAAD,CAAiBE,CAAjB,CAAwBE,CAAxB,CA3BhB,KAIDC,GAJC,CAIDA,CAJC,YAIK,CAJL,OAKDC,GALC,CAKDA,CALC,YAKK,GALL,G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 +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=["hovered","onHover","value","position","disabled","withTooltip","focused","popoverPosition","buttonRef","active","handlePress","onKeyPress","tooltipFormatter","buttonLabel","onFocus","tooltipZIndex"];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"./SliderPoint.css";import React,{useEffect,useRef}from"react";import{useFlag}from"../../../hooks/useFlag/useFlag";import{useForkRef}from"../../../hooks/useForkRef/useForkRef";import{cnMixFocus}from"../../../mixs/MixFocus/MixFocus";import{cn}from"../../../utils/bem";import{generateThemeClassNames,ThemeContext,useTheme}from"../../Theme/Theme";import{Tooltip}from"../../Tooltip/Tooltip";var cnSliderPoint=cn("SliderPoint"),getTooltipPosition=function(a,b){if(a&&b&&b.current){var c=b.current.getBoundingClientRect(),d=c.y,e=c.height;return{x:Math.round(a.x),y:Math.round(d+e/2)}}return{x:0,y:0}};export var SliderPoint=function(a){var b=a.hovered,c=a.onHover,d=a.value,e=a.position,f=a.disabled,g=a.withTooltip,h=a.focused,i=a.popoverPosition,j=a.buttonRef,k=a.active,l=a.handlePress,m=a.onKeyPress,n=a.tooltipFormatter,o=a.buttonLabel,p=a.onFocus,q=a.tooltipZIndex,r=_objectWithoutProperties(a,_excluded),s=useFlag(!1),t=_slicedToArray(s,2),u=t[0],v=t[1],w=useTheme(),x=w.theme,y=_objectSpread(_objectSpread({},x),{},{color:{primary:x.color.invert,accent:x.color.accent,invert:x.color.primary}}),z=generateThemeClassNames(y),A=function(a){f||(null===p||void 0===p?void 0:p(a,o),v.on())},B=function(a){f||(null===c||void 0===c?void 0:c(a),a&&v.on(),a&&v.on(),!a&&!h&&v.off())},C=useRef(null),D=getTooltipPosition(i,j||C);return useEffect(function(){h?v.on():v.off()},[h]),React.createElement(React.Fragment,null,React.createElement("button",Object.assign({type:"button","aria-label":"".concat(o,"-button"),className:cnSliderPoint({hovered:b,disabled:f,active:k},[f?"":cnMixFocus()]),onMouseOver:function onMouseOver(){return B(!0)},onMouseOut:function onMouseOut(){return B(!1)},onMouseDown:function onMouseDown(){return null===l||void 0===l?void 0:l(o)},onTouchStart:function onTouchStart(){return null===l||void 0===l?void 0:l(o)},onKeyDown:function onKeyDown(a){return null===m||void 0===m?void 0:m(a,o)},onFocus:A,onBlur:function handleBlur(a){f||(null===p||void 0===p?void 0:p(a,null),v.off())},onClick:A,ref:useForkRef([j,C]),tabIndex:0,style:_defineProperty({},"--slider-button-left","".concat(e,"%"))},r)),u&&g&&i&&React.createElement(ThemeContext.Provider,{value:{theme:y,themeClassNames:z}},React.createElement(Tooltip,{position:D,className:cnSliderPoint("Tooltip"),direction:"downCenter",possibleDirections:["leftCenter","rightCenter","downCenter","leftDown","rightDown","upCenter"],style:{zIndex:q},offset:10},n?n(d):d)))};
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["hovered","onHover","value","position","disabled","withTooltip","focused","popoverPosition","buttonRef","active","handlePress","onKeyPress","tooltipFormatter","buttonLabel","onFocus","tooltipDirection","tooltipPossibleDirections","tooltipZIndex"];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"./SliderPoint.css";import React,{useEffect,useRef}from"react";import{useFlag}from"../../../hooks/useFlag/useFlag";import{useForkRef}from"../../../hooks/useForkRef/useForkRef";import{cnMixFocus}from"../../../mixs/MixFocus/MixFocus";import{cn}from"../../../utils/bem";import{generateThemeClassNames,ThemeContext,useTheme}from"../../Theme/Theme";import{Tooltip}from"../../Tooltip/Tooltip";var cnSliderPoint=cn("SliderPoint"),getTooltipPosition=function(a,b){if(a&&b&&b.current){var c=b.current.getBoundingClientRect(),d=c.y,e=c.height;return{x:Math.round(a.x),y:Math.round(d+e/2)}}return{x:0,y:0}},defaultPossibleDirections=["leftCenter","rightCenter","downCenter","leftDown","rightDown","upCenter"];export var SliderPoint=function(a){var b=a.hovered,c=a.onHover,d=a.value,e=a.position,f=a.disabled,g=a.withTooltip,h=a.focused,i=a.popoverPosition,j=a.buttonRef,k=a.active,l=a.handlePress,m=a.onKeyPress,n=a.tooltipFormatter,o=a.buttonLabel,p=a.onFocus,q=a.tooltipDirection,r=void 0===q?"downCenter":q,s=a.tooltipPossibleDirections,t=void 0===s?defaultPossibleDirections:s,u=a.tooltipZIndex,v=_objectWithoutProperties(a,_excluded),w=useFlag(!1),x=_slicedToArray(w,2),y=x[0],z=x[1],A=useTheme(),B=A.theme,C=_objectSpread(_objectSpread({},B),{},{color:{primary:B.color.invert,accent:B.color.accent,invert:B.color.primary}}),D=generateThemeClassNames(C),E=function(a){f||(null===p||void 0===p?void 0:p(a,o),z.on())},F=function(a){f||(null===c||void 0===c?void 0:c(a),a&&z.on(),a&&z.on(),!a&&!h&&z.off())},G=useRef(null),H=getTooltipPosition(i,j||G);return useEffect(function(){h?z.on():z.off()},[h]),React.createElement(React.Fragment,null,React.createElement("button",Object.assign({type:"button","aria-label":"".concat(o,"-button"),className:cnSliderPoint({hovered:b,disabled:f,active:k},[f?"":cnMixFocus()]),onMouseOver:function onMouseOver(){return F(!0)},onMouseOut:function onMouseOut(){return F(!1)},onMouseDown:function onMouseDown(){return null===l||void 0===l?void 0:l(o)},onTouchStart:function onTouchStart(){return null===l||void 0===l?void 0:l(o)},onKeyDown:function onKeyDown(a){return null===m||void 0===m?void 0:m(a,o)},onFocus:E,onBlur:function handleBlur(a){f||(null===p||void 0===p?void 0:p(a,null),z.off())},onClick:E,ref:useForkRef([j,G]),tabIndex:0,style:_defineProperty({},"--slider-button-left","".concat(e,"%"))},v)),y&&g&&i&&React.createElement(ThemeContext.Provider,{value:{theme:C,themeClassNames:D}},React.createElement(Tooltip,{position:H,className:cnSliderPoint("Tooltip"),direction:r,possibleDirections:t,style:{zIndex:u},offset:10},n?n(d):d)))};
2
2
  //# sourceMappingURL=SliderPoint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SliderPoint.js","names":["React","useEffect","useRef","useFlag","useForkRef","cnMixFocus","cn","generateThemeClassNames","ThemeContext","useTheme","Tooltip","cnSliderPoint","getTooltipPosition","popoverPosition","buttonRef","current","getBoundingClientRect","y","height","x","Math","round","SliderPoint","props","hovered","onHover","value","position","disabled","withTooltip","focused","active","handlePress","onKeyPress","tooltipFormatter","buttonLabel","onFocus","tooltipZIndex","otherProps","tooltipVisible","setTooltipVisible","theme","tooltipTheme","color","primary","invert","accent","tooltipThemeClassNames","handleFocus","e","on","handleMouseAction","enter","off","pointRef","tooltipPosition","handleBlur","themeClassNames","zIndex"],"sources":["../../../../../../src/components/Slider/SliderPoint/SliderPoint.tsx"],"sourcesContent":["import './SliderPoint.css';\n\nimport React, { useEffect, useRef } from 'react';\n\nimport { useFlag } from '../../../hooks/useFlag/useFlag';\nimport { useForkRef } from '../../../hooks/useForkRef/useForkRef';\nimport { cnMixFocus } from '../../../mixs/MixFocus/MixFocus';\nimport { cn } from '../../../utils/bem';\nimport {\n generateThemeClassNames,\n ThemeContext,\n useTheme,\n} from '../../Theme/Theme';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { SliderPointProps, TrackPosition } from '../helper';\n\nconst cnSliderPoint = cn('SliderPoint');\n\nconst getTooltipPosition = (\n popoverPosition?: TrackPosition,\n buttonRef?: React.RefObject<HTMLButtonElement>,\n) => {\n if (popoverPosition && buttonRef && buttonRef.current) {\n const { y, height } = buttonRef.current.getBoundingClientRect();\n return {\n x: Math.round(popoverPosition.x),\n y: Math.round(y + height / 2),\n };\n }\n\n return { x: 0, y: 0 };\n};\nexport const SliderPoint = (props: SliderPointProps) => {\n const {\n hovered,\n onHover,\n value,\n position,\n disabled,\n withTooltip,\n focused,\n popoverPosition,\n buttonRef,\n active,\n handlePress,\n onKeyPress,\n tooltipFormatter,\n buttonLabel,\n onFocus,\n tooltipZIndex,\n ...otherProps\n } = props;\n\n const [tooltipVisible, setTooltipVisible] = useFlag(false);\n\n const { theme } = useTheme();\n\n const tooltipTheme = {\n ...theme,\n color: {\n primary: theme.color.invert,\n accent: theme.color.accent,\n invert: theme.color.primary,\n },\n };\n\n const tooltipThemeClassNames = generateThemeClassNames(tooltipTheme);\n\n const handleFocus = (\n e: React.FocusEvent<HTMLButtonElement> | React.MouseEvent,\n ) => {\n if (!disabled) {\n onFocus?.(e, buttonLabel);\n setTooltipVisible.on();\n }\n };\n\n const handleMouseAction = (enter: boolean) => {\n if (!disabled) {\n onHover?.(enter);\n enter && setTooltipVisible.on();\n if (enter) setTooltipVisible.on();\n if (!enter && !focused) setTooltipVisible.off();\n }\n };\n\n const handleBlur = (\n e:\n | React.FocusEvent<HTMLButtonElement>\n | React.MouseEvent<HTMLButtonElement>,\n ) => {\n if (!disabled) {\n onFocus?.(e, null);\n setTooltipVisible.off();\n }\n };\n\n const pointRef = useRef<HTMLButtonElement>(null);\n\n const tooltipPosition = getTooltipPosition(\n popoverPosition,\n buttonRef || pointRef,\n );\n\n useEffect(() => {\n focused ? setTooltipVisible.on() : setTooltipVisible.off();\n }, [focused]);\n\n return (\n <>\n <button\n type=\"button\"\n aria-label={`${buttonLabel}-button`}\n className={cnSliderPoint({ hovered, disabled, active }, [\n !disabled ? cnMixFocus() : '',\n ])}\n onMouseOver={() => handleMouseAction(true)}\n onMouseOut={() => handleMouseAction(false)}\n onMouseDown={() => handlePress?.(buttonLabel)}\n onTouchStart={() => handlePress?.(buttonLabel)}\n onKeyDown={(e) => onKeyPress?.(e, buttonLabel)}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onClick={handleFocus}\n ref={useForkRef([buttonRef, pointRef])}\n tabIndex={0}\n style={{\n ['--slider-button-left' as string]: `${position}%`,\n }}\n {...otherProps}\n />\n {tooltipVisible && withTooltip && popoverPosition && (\n <ThemeContext.Provider\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n value={{\n theme: tooltipTheme,\n themeClassNames: tooltipThemeClassNames,\n }}\n >\n <Tooltip\n position={tooltipPosition}\n className={cnSliderPoint('Tooltip')}\n direction=\"downCenter\"\n possibleDirections={[\n 'leftCenter',\n 'rightCenter',\n 'downCenter',\n 'leftDown',\n 'rightDown',\n 'upCenter',\n ]}\n style={{ zIndex: tooltipZIndex }}\n offset={10}\n >\n {tooltipFormatter ? tooltipFormatter(value) : value}\n </Tooltip>\n </ThemeContext.Provider>\n )}\n </>\n );\n};\n"],"mappings":"khCAAA,0BAEA,MAAOA,MAAP,EAAgBC,SAAhB,CAA2BC,MAA3B,KAAyC,OAAzC,CAEA,OAASC,OAAT,sCACA,OAASC,UAAT,4CACA,OAASC,UAAT,uCACA,OAASC,EAAT,0BACA,OACEC,uBADF,CAEEC,YAFF,CAGEC,QAHF,yBAKA,OAASC,OAAT,6B,GAGMC,cAAa,CAAGL,EAAE,CAAC,aAAD,C,CA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C,OAAD,EACE,QAAQ,CAAEQ,CADZ,CAEE,SAAS,CAAE5C,aAAa,CAAC,SAAD,CAF1B,CAGE,SAAS,CAAC,YAHZ,CAIE,kBAAkB,CAAE,CAClB,YADkB,CAElB,aAFkB,CAGlB,YAHkB,CAIlB,UAJkB,CAKlB,WALkB,CAMlB,UANkB,CAJtB,CAYE,KAAK,CAAE,CAAE+C,MAAM,CAAErB,CAAV,CAZT,CAaE,MAAM,CAAE,EAbV,EAeGH,CAAgB,CAAGA,CAAgB,CAACR,CAAD,CAAnB,CAA6BA,CAfhD,CAPF,CAvBJ,CAmDH,CAhIM"}
1
+ {"version":3,"file":"SliderPoint.js","names":["React","useEffect","useRef","useFlag","useForkRef","cnMixFocus","cn","generateThemeClassNames","ThemeContext","useTheme","Tooltip","cnSliderPoint","getTooltipPosition","popoverPosition","buttonRef","current","getBoundingClientRect","y","height","x","Math","round","defaultPossibleDirections","SliderPoint","props","hovered","onHover","value","position","disabled","withTooltip","focused","active","handlePress","onKeyPress","tooltipFormatter","buttonLabel","onFocus","tooltipDirection","tooltipPossibleDirections","tooltipZIndex","otherProps","tooltipVisible","setTooltipVisible","theme","tooltipTheme","color","primary","invert","accent","tooltipThemeClassNames","handleFocus","e","on","handleMouseAction","enter","off","pointRef","tooltipPosition","handleBlur","themeClassNames","zIndex"],"sources":["../../../../../../src/components/Slider/SliderPoint/SliderPoint.tsx"],"sourcesContent":["import './SliderPoint.css';\n\nimport React, { useEffect, useRef } from 'react';\n\nimport { Direction } from '##/components/Popover';\n\nimport { useFlag } from '../../../hooks/useFlag/useFlag';\nimport { useForkRef } from '../../../hooks/useForkRef/useForkRef';\nimport { cnMixFocus } from '../../../mixs/MixFocus/MixFocus';\nimport { cn } from '../../../utils/bem';\nimport {\n generateThemeClassNames,\n ThemeContext,\n useTheme,\n} from '../../Theme/Theme';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { SliderPointProps, TrackPosition } from '../helper';\n\nconst cnSliderPoint = cn('SliderPoint');\n\nconst getTooltipPosition = (\n popoverPosition?: TrackPosition,\n buttonRef?: React.RefObject<HTMLButtonElement>,\n) => {\n if (popoverPosition && buttonRef && buttonRef.current) {\n const { y, height } = buttonRef.current.getBoundingClientRect();\n return {\n x: Math.round(popoverPosition.x),\n y: Math.round(y + height / 2),\n };\n }\n\n return { x: 0, y: 0 };\n};\n\nconst defaultPossibleDirections: Direction[] = [\n 'leftCenter',\n 'rightCenter',\n 'downCenter',\n 'leftDown',\n 'rightDown',\n 'upCenter',\n];\n\nexport const SliderPoint = (props: SliderPointProps) => {\n const {\n hovered,\n onHover,\n value,\n position,\n disabled,\n withTooltip,\n focused,\n popoverPosition,\n buttonRef,\n active,\n handlePress,\n onKeyPress,\n tooltipFormatter,\n buttonLabel,\n onFocus,\n tooltipDirection = 'downCenter',\n tooltipPossibleDirections = defaultPossibleDirections,\n tooltipZIndex,\n ...otherProps\n } = props;\n\n const [tooltipVisible, setTooltipVisible] = useFlag(false);\n\n const { theme } = useTheme();\n\n const tooltipTheme = {\n ...theme,\n color: {\n primary: theme.color.invert,\n accent: theme.color.accent,\n invert: theme.color.primary,\n },\n };\n\n const tooltipThemeClassNames = generateThemeClassNames(tooltipTheme);\n\n const handleFocus = (\n e: React.FocusEvent<HTMLButtonElement> | React.MouseEvent,\n ) => {\n if (!disabled) {\n onFocus?.(e, buttonLabel);\n setTooltipVisible.on();\n }\n };\n\n const handleMouseAction = (enter: boolean) => {\n if (!disabled) {\n onHover?.(enter);\n enter && setTooltipVisible.on();\n if (enter) setTooltipVisible.on();\n if (!enter && !focused) setTooltipVisible.off();\n }\n };\n\n const handleBlur = (\n e:\n | React.FocusEvent<HTMLButtonElement>\n | React.MouseEvent<HTMLButtonElement>,\n ) => {\n if (!disabled) {\n onFocus?.(e, null);\n setTooltipVisible.off();\n }\n };\n\n const pointRef = useRef<HTMLButtonElement>(null);\n\n const tooltipPosition = getTooltipPosition(\n popoverPosition,\n buttonRef || pointRef,\n );\n\n useEffect(() => {\n focused ? setTooltipVisible.on() : setTooltipVisible.off();\n }, [focused]);\n\n return (\n <>\n <button\n type=\"button\"\n aria-label={`${buttonLabel}-button`}\n className={cnSliderPoint({ hovered, disabled, active }, [\n !disabled ? cnMixFocus() : '',\n ])}\n onMouseOver={() => handleMouseAction(true)}\n onMouseOut={() => handleMouseAction(false)}\n onMouseDown={() => handlePress?.(buttonLabel)}\n onTouchStart={() => handlePress?.(buttonLabel)}\n onKeyDown={(e) => onKeyPress?.(e, buttonLabel)}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onClick={handleFocus}\n ref={useForkRef([buttonRef, pointRef])}\n tabIndex={0}\n style={{\n ['--slider-button-left' as string]: `${position}%`,\n }}\n {...otherProps}\n />\n {tooltipVisible && withTooltip && popoverPosition && (\n <ThemeContext.Provider\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n value={{\n theme: tooltipTheme,\n themeClassNames: tooltipThemeClassNames,\n }}\n >\n <Tooltip\n position={tooltipPosition}\n className={cnSliderPoint('Tooltip')}\n direction={tooltipDirection}\n possibleDirections={tooltipPossibleDirections}\n style={{ zIndex: tooltipZIndex }}\n offset={10}\n >\n {tooltipFormatter ? tooltipFormatter(value) : value}\n </Tooltip>\n </ThemeContext.Provider>\n )}\n </>\n );\n};\n"],"mappings":"ikCAAA,0BAEA,MAAOA,MAAP,EAAgBC,SAAhB,CAA2BC,MAA3B,KAAyC,OAAzC,CAIA,OAASC,OAAT,sCACA,OAASC,UAAT,4CACA,OAASC,UAAT,uCACA,OAASC,EAAT,0BACA,OACEC,uBADF,CAEEC,YAFF,CAGEC,QAHF,yBAKA,OAASC,OAAT,6B,GAGMC,cAAa,CAAGL,EAAE,CAAC,aAAD,C,CAElBM,kBAAkB,CAAG,SACzBC,CADyB,CAEzBC,CAFyB,CAGtB,CACH,GAAID,CAAe,EAAIC,CAAnB,EAAgCA,CAAS,CAACC,OAA9C,CAAuD,CACrD,MAAsBD,CAAS,CAACC,OAAV,CAAkBC,qBAAlB,EAAtB,CA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CAAE,CACL+B,KAAK,CAAEC,CADF,CAELe,eAAe,CAAEV,CAFZ,CAFT,EAOE,oBAAC,OAAD,EACE,QAAQ,CAAEQ,CADZ,CAEE,SAAS,CAAE/C,aAAa,CAAC,SAAD,CAF1B,CAGE,SAAS,CAAE2B,CAHb,CAIE,kBAAkB,CAAEC,CAJtB,CAKE,KAAK,CAAE,CAAEsB,MAAM,CAAErB,CAAV,CALT,CAME,MAAM,CAAE,EANV,EAQGL,CAAgB,CAAGA,CAAgB,CAACR,CAAD,CAAnB,CAA6BA,CARhD,CAPF,CAvBJ,CA4CH,CA3HM"}
@@ -1,6 +1,7 @@
1
1
  import { IconComponent } from '@consta/icons/Icon';
2
2
  import React from 'react';
3
3
  import { PropsWithHTMLAttributes } from '../../utils/types/PropsWithHTMLAttributes';
4
+ import { Direction } from '../Popover';
4
5
  import { ActiveButton } from './useSlider/helper';
5
6
  export declare const propStatus: readonly ["alert", "warning", "success"];
6
7
  export declare type PropStatus = typeof propStatus[number];
@@ -36,6 +37,8 @@ declare type Props<RANGE extends boolean = false> = {
36
37
  leftSide?: Side;
37
38
  tooltipFormatter?: PropToolipFormatter;
38
39
  rightSide?: Side;
40
+ tooltipDirection?: Direction;
41
+ tooltipPossibleDirections?: Direction[];
39
42
  };
40
43
  export declare type Line = {
41
44
  width: number;
@@ -66,6 +69,8 @@ export declare type SliderPointProps = PropsWithHTMLAttributes<{
66
69
  position: number;
67
70
  active?: boolean;
68
71
  tooltipZIndex?: number;
72
+ tooltipDirection?: Direction;
73
+ tooltipPossibleDirections?: Direction[];
69
74
  }, HTMLButtonElement>;
70
75
  export declare type SliderProps<RANGE extends boolean> = PropsWithHTMLAttributes<Props<RANGE>, HTMLDivElement>;
71
76
  export declare type SliderComponent = <RANGE extends boolean = false>(props: SliderProps<RANGE>) => React.ReactElement | null;
@@ -1 +1 @@
1
- {"version":3,"file":"helper.js","names":["propStatus","defaultPropStatus","propSize","defaultPropSize","isRangeParams","params","range","isNotRangeParams","defaultTooltipFormatter","value","toString","getValueForInput","props","field","getOnChandgeForInput","e","onChange","getIcon","side","getMaxForStartField","max","getMinForEndField","min","getValidStep","step","Array","isArray","Math","abs"],"sources":["../../../../../src/components/Slider/helper.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { PropsWithHTMLAttributes } from '../../utils/types/PropsWithHTMLAttributes';\nimport { ActiveButton } from './useSlider/helper';\n\nexport const propStatus = ['alert', 'warning', 'success'] as const;\nexport type PropStatus = typeof propStatus[number];\nexport const defaultPropStatus = propStatus[0];\n\nexport type PropView = 'default' | 'division';\n\nexport const propSize = ['s', 'xs', 'm', 'l'] as const;\nexport type PropSize = typeof propSize[number];\nexport const defaultPropSize: PropSize = propSize[0];\n\nexport type SliderValue<RANGE> = RANGE extends true ? [number, number] : number;\n\nexport type PropOnChange<RANGE> = (prop: {\n e?:\n | Event\n | React.TouchEvent\n | React.MouseEvent\n | React.KeyboardEvent\n | React.ChangeEvent;\n value: SliderValue<RANGE>;\n}) => void;\n\ntype PropToolipFormatter = (value: number | undefined) => string;\n\ntype Side = IconComponent | 'input';\n\ntype Props<RANGE extends boolean = false> = {\n className?: string;\n step?: number | number[];\n view?: PropView;\n disabled?: boolean;\n range?: RANGE;\n withTooltip?: boolean;\n value: SliderValue<RANGE>;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n status?: PropStatus;\n min?: number;\n size?: PropSize;\n max?: number;\n onChange?: PropOnChange<RANGE>;\n onAfterChange?: PropOnChange<RANGE>;\n leftSide?: Side;\n tooltipFormatter?: PropToolipFormatter;\n rightSide?: Side;\n};\n\nexport type Line = {\n width: number;\n active: boolean;\n size?: number[];\n};\n\nexport type SliderLineProps = {\n view?: PropView;\n lines: Line[];\n disabled?: boolean;\n hovered?: boolean;\n onHover?: (hovered: boolean) => void;\n};\n\nexport type SliderPointProps = PropsWithHTMLAttributes<\n {\n value?: number;\n disabled?: boolean;\n focused?: boolean;\n hovered?: boolean;\n withTooltip?: boolean;\n handlePress?: (typeButton: ActiveButton) => void;\n buttonLabel?: ActiveButton;\n buttonRef?: React.RefObject<HTMLButtonElement>;\n popoverPosition?: TrackPosition;\n tooltipFormatter?: PropToolipFormatter;\n onFocus?: (\n e: React.FocusEvent<HTMLButtonElement> | React.MouseEvent,\n button: ActiveButton,\n ) => void;\n onKeyPress?: (e: React.KeyboardEvent, typeButton?: ActiveButton) => void;\n onHover?: (hovered: boolean) => void;\n position: number;\n active?: boolean;\n tooltipZIndex?: number;\n },\n HTMLButtonElement\n>;\n\nexport type SliderProps<RANGE extends boolean> = PropsWithHTMLAttributes<\n Props<RANGE>,\n HTMLDivElement\n>;\n\nexport type SliderComponent = <RANGE extends boolean = false>(\n props: SliderProps<RANGE>,\n) => React.ReactElement | null;\n\nexport const isRangeParams = (\n params: Props<boolean>,\n): params is Props<true> => {\n return !!params.range;\n};\n\nexport const isNotRangeParams = (\n params: Props<boolean>,\n): params is Props<false> => {\n return !params.range;\n};\n\nexport const defaultTooltipFormatter: PropToolipFormatter = (value) =>\n value?.toString() || '';\n\nexport type TrackPosition = {\n x: number;\n y: number;\n} | null;\n\nexport const getValueForInput = (\n props: SliderProps<boolean>,\n field: 0 | 1,\n): number => {\n if (isRangeParams(props)) {\n return props.value[field];\n }\n return props.value as number;\n};\n\ntype GetOnChandgeForInputReturned = (props: {\n e?: React.ChangeEvent | React.MouseEvent | React.KeyboardEvent;\n value: number;\n}) => void;\n\nexport const getOnChandgeForInput =\n (props: SliderProps<boolean>, field: 0 | 1): GetOnChandgeForInputReturned =>\n ({ e, value }) => {\n if (!props.onChange) {\n return;\n }\n if (isNotRangeParams(props)) {\n props.onChange({ e, value });\n }\n if (isRangeParams(props)) {\n props.onChange({\n e,\n value: field ? [props.value[0], value] : [value, props.value[1]],\n });\n }\n };\n\nexport const getIcon = (side?: Side) => {\n if (side !== 'input') {\n return side;\n }\n};\n\nexport const getMaxForStartField = (props: SliderProps<boolean>) => {\n if (isNotRangeParams(props)) {\n return props.max;\n }\n if (isRangeParams(props)) {\n return props.value[1];\n }\n};\n\nexport const getMinForEndField = (props: SliderProps<boolean>) => {\n if (isNotRangeParams(props)) {\n return props.min;\n }\n if (isRangeParams(props)) {\n return props.value[0];\n }\n};\n\nexport const getValidStep = (\n min: number,\n max: number,\n step?: number | number[],\n) => {\n if (step) {\n if (Array.isArray(step)) {\n return step;\n }\n if (step <= 0) {\n return 1;\n }\n return step;\n }\n return Math.abs((max - min) / 100);\n};\n"],"mappings":"AAMA,MAAO,IAAMA,WAAU,CAAG,CAAC,OAAD,CAAU,SAAV,CAAqB,SAArB,CAAnB,CAEP,MAAO,IAAMC,kBAAiB,CAAGD,UAAU,CAAC,CAAD,CAApC,CAIP,MAAO,IAAME,SAAQ,CAAG,CAAC,GAAD,CAAM,IAAN,CAAY,GAAZ,CAAiB,GAAjB,CAAjB,CAEP,MAAO,IAAMC,gBAAyB,CAAGD,QAAQ,CAAC,CAAD,CAA1C,CAwFP,MAAO,IAAME,cAAa,CAAG,SAC3BC,CAD2B,CAED,CAC1B,MAAO,CAAC,CAACA,CAAM,CAACC,KACjB,CAJM,CAMP,MAAO,IAAMC,iBAAgB,CAAG,SAC9BF,CAD8B,CAEH,CAC3B,MAAO,CAACA,CAAM,CAACC,KAChB,CAJM,CAMP,MAAO,IAAME,wBAA4C,CAAG,SAACC,CAAD,QAC1D,QAAAA,CAAK,WAALA,CAAA,QAAAA,CAAK,CAAEC,QAAP,KAAqB,EADqC,CAArD,CAQP,MAAO,IAAMC,iBAAgB,CAAG,SAC9BC,CAD8B,CAE9BC,CAF8B,CAGnB,OACPT,cAAa,CAACQ,CAAD,CADN,CAEFA,CAAK,CAACH,KAAN,CAAYI,CAAZ,CAFE,CAIJD,CAAK,CAACH,KACd,CARM,CAeP,MAAO,IAAMK,qBAAoB,CAC/B,SAACF,CAAD,CAA8BC,CAA9B,QACA,YAAkB,IAAfE,EAAe,GAAfA,CAAe,CAAZN,CAAY,GAAZA,KAAY,CACXG,CAAK,CAACI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
1
+ {"version":3,"file":"helper.js","names":["propStatus","defaultPropStatus","propSize","defaultPropSize","isRangeParams","params","range","isNotRangeParams","defaultTooltipFormatter","value","toString","getValueForInput","props","field","getOnChandgeForInput","e","onChange","getIcon","side","getMaxForStartField","max","getMinForEndField","min","getValidStep","step","Array","isArray","Math","abs"],"sources":["../../../../../src/components/Slider/helper.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { PropsWithHTMLAttributes } from '../../utils/types/PropsWithHTMLAttributes';\nimport { Direction } from '../Popover';\nimport { ActiveButton } from './useSlider/helper';\n\nexport const propStatus = ['alert', 'warning', 'success'] as const;\nexport type PropStatus = typeof propStatus[number];\nexport const defaultPropStatus = propStatus[0];\n\nexport type PropView = 'default' | 'division';\n\nexport const propSize = ['s', 'xs', 'm', 'l'] as const;\nexport type PropSize = typeof propSize[number];\nexport const defaultPropSize: PropSize = propSize[0];\n\nexport type SliderValue<RANGE> = RANGE extends true ? [number, number] : number;\n\nexport type PropOnChange<RANGE> = (prop: {\n e?:\n | Event\n | React.TouchEvent\n | React.MouseEvent\n | React.KeyboardEvent\n | React.ChangeEvent;\n value: SliderValue<RANGE>;\n}) => void;\n\ntype PropToolipFormatter = (value: number | undefined) => string;\n\ntype Side = IconComponent | 'input';\n\ntype Props<RANGE extends boolean = false> = {\n className?: string;\n step?: number | number[];\n view?: PropView;\n disabled?: boolean;\n range?: RANGE;\n withTooltip?: boolean;\n value: SliderValue<RANGE>;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n status?: PropStatus;\n min?: number;\n size?: PropSize;\n max?: number;\n onChange?: PropOnChange<RANGE>;\n onAfterChange?: PropOnChange<RANGE>;\n leftSide?: Side;\n tooltipFormatter?: PropToolipFormatter;\n rightSide?: Side;\n tooltipDirection?: Direction;\n tooltipPossibleDirections?: Direction[];\n};\n\nexport type Line = {\n width: number;\n active: boolean;\n size?: number[];\n};\n\nexport type SliderLineProps = {\n view?: PropView;\n lines: Line[];\n disabled?: boolean;\n hovered?: boolean;\n onHover?: (hovered: boolean) => void;\n};\n\nexport type SliderPointProps = PropsWithHTMLAttributes<\n {\n value?: number;\n disabled?: boolean;\n focused?: boolean;\n hovered?: boolean;\n withTooltip?: boolean;\n handlePress?: (typeButton: ActiveButton) => void;\n buttonLabel?: ActiveButton;\n buttonRef?: React.RefObject<HTMLButtonElement>;\n popoverPosition?: TrackPosition;\n tooltipFormatter?: PropToolipFormatter;\n onFocus?: (\n e: React.FocusEvent<HTMLButtonElement> | React.MouseEvent,\n button: ActiveButton,\n ) => void;\n onKeyPress?: (e: React.KeyboardEvent, typeButton?: ActiveButton) => void;\n onHover?: (hovered: boolean) => void;\n position: number;\n active?: boolean;\n tooltipZIndex?: number;\n tooltipDirection?: Direction;\n tooltipPossibleDirections?: Direction[];\n },\n HTMLButtonElement\n>;\n\nexport type SliderProps<RANGE extends boolean> = PropsWithHTMLAttributes<\n Props<RANGE>,\n HTMLDivElement\n>;\n\nexport type SliderComponent = <RANGE extends boolean = false>(\n props: SliderProps<RANGE>,\n) => React.ReactElement | null;\n\nexport const isRangeParams = (\n params: Props<boolean>,\n): params is Props<true> => {\n return !!params.range;\n};\n\nexport const isNotRangeParams = (\n params: Props<boolean>,\n): params is Props<false> => {\n return !params.range;\n};\n\nexport const defaultTooltipFormatter: PropToolipFormatter = (value) =>\n value?.toString() || '';\n\nexport type TrackPosition = {\n x: number;\n y: number;\n} | null;\n\nexport const getValueForInput = (\n props: SliderProps<boolean>,\n field: 0 | 1,\n): number => {\n if (isRangeParams(props)) {\n return props.value[field];\n }\n return props.value as number;\n};\n\ntype GetOnChandgeForInputReturned = (props: {\n e?: React.ChangeEvent | React.MouseEvent | React.KeyboardEvent;\n value: number;\n}) => void;\n\nexport const getOnChandgeForInput =\n (props: SliderProps<boolean>, field: 0 | 1): GetOnChandgeForInputReturned =>\n ({ e, value }) => {\n if (!props.onChange) {\n return;\n }\n if (isNotRangeParams(props)) {\n props.onChange({ e, value });\n }\n if (isRangeParams(props)) {\n props.onChange({\n e,\n value: field ? [props.value[0], value] : [value, props.value[1]],\n });\n }\n };\n\nexport const getIcon = (side?: Side) => {\n if (side !== 'input') {\n return side;\n }\n};\n\nexport const getMaxForStartField = (props: SliderProps<boolean>) => {\n if (isNotRangeParams(props)) {\n return props.max;\n }\n if (isRangeParams(props)) {\n return props.value[1];\n }\n};\n\nexport const getMinForEndField = (props: SliderProps<boolean>) => {\n if (isNotRangeParams(props)) {\n return props.min;\n }\n if (isRangeParams(props)) {\n return props.value[0];\n }\n};\n\nexport const getValidStep = (\n min: number,\n max: number,\n step?: number | number[],\n) => {\n if (step) {\n if (Array.isArray(step)) {\n return step;\n }\n if (step <= 0) {\n return 1;\n }\n return step;\n }\n return Math.abs((max - min) / 100);\n};\n"],"mappings":"AAOA,MAAO,IAAMA,WAAU,CAAG,CAAC,OAAD,CAAU,SAAV,CAAqB,SAArB,CAAnB,CAEP,MAAO,IAAMC,kBAAiB,CAAGD,UAAU,CAAC,CAAD,CAApC,CAIP,MAAO,IAAME,SAAQ,CAAG,CAAC,GAAD,CAAM,IAAN,CAAY,GAAZ,CAAiB,GAAjB,CAAjB,CAEP,MAAO,IAAMC,gBAAyB,CAAGD,QAAQ,CAAC,CAAD,CAA1C,CA4FP,MAAO,IAAME,cAAa,CAAG,SAC3BC,CAD2B,CAED,CAC1B,MAAO,CAAC,CAACA,CAAM,CAACC,KACjB,CAJM,CAMP,MAAO,IAAMC,iBAAgB,CAAG,SAC9BF,CAD8B,CAEH,CAC3B,MAAO,CAACA,CAAM,CAACC,KAChB,CAJM,CAMP,MAAO,IAAME,wBAA4C,CAAG,SAACC,CAAD,QAC1D,QAAAA,CAAK,WAALA,CAAA,QAAAA,CAAK,CAAEC,QAAP,KAAqB,EADqC,CAArD,CAQP,MAAO,IAAMC,iBAAgB,CAAG,SAC9BC,CAD8B,CAE9BC,CAF8B,CAGnB,OACPT,cAAa,CAACQ,CAAD,CADN,CAEFA,CAAK,CAACH,KAAN,C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EADD,CAEGC,KAAK,CAACC,OAAN,CAAcF,CAAd,CAFH,CAGQA,CAHR,CAKW,CAAR,EAAAA,CALH,CAMQ,CANR,CAQMA,CARN,CAUIG,IAAI,CAACC,GAAL,CAAS,CAACR,CAAG,CAAGE,CAAP,EAAc,GAAvB,CACR,CAfM"}
@@ -0,0 +1 @@
1
+ export * from './useKeysRef';
@@ -0,0 +1,2 @@
1
+ export*from"./useKeysRef";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/hooks/useKeysRef/index.ts"],"sourcesContent":["export * from './useKeysRef';\n"],"mappings":"AAAA"}
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { KeyCode } from "../../utils/types/KeyCode";
3
+ export declare type KeyHandlers = Partial<Record<KeyCode, (e: KeyboardEvent) => void>> & {
4
+ [key: string]: (e: KeyboardEvent) => void;
5
+ };
6
+ declare type UseKeysProps = {
7
+ ref?: React.RefObject<HTMLElement>;
8
+ keys?: KeyHandlers;
9
+ isActive?: boolean;
10
+ eventType?: 'keypress' | 'keydown' | 'keyup';
11
+ };
12
+ export declare const useKeysRef: (params: UseKeysProps) => void;
13
+ export {};
@@ -0,0 +1,2 @@
1
+ import{useCallback,useEffect}from"react";var getKeyHandler=function(a){return function(b){var c;null===(c=a[b.code]||a[b.key])||void 0===c?void 0:c(b)}};export var useKeysRef=function(a){var b=a.ref,c=a.keys,d=a.isActive,f=!(void 0!==d)||d,g=a.eventType,h=void 0===g?"keydown":g,i=useCallback(function(a){if(c&&f){getKeyHandler(c)(a)}},[c,f]);useEffect(function(){var a;return null===b||void 0===b||null===(a=b.current)||void 0===a?void 0:a.addEventListener(h,i),function(){var a;null===b||void 0===b||null===(a=b.current)||void 0===a?void 0:a.removeEventListener(h,i)}},[b,c,f,h])};
2
+ //# sourceMappingURL=useKeysRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeysRef.js","names":["useCallback","useEffect","getKeyHandler","keys","e","code","key","useKeysRef","params","ref","isActive","eventType","onKeyDown","current","addEventListener","removeEventListener"],"sources":["../../../../../src/hooks/useKeysRef/useKeysRef.ts"],"sourcesContent":["import React, { useCallback, useEffect } from 'react';\n\nimport { KeyCode } from '##/utils/types/KeyCode';\n\nexport type KeyHandlers = Partial<\n Record<KeyCode, (e: KeyboardEvent) => void>\n> & {\n [key: string]: (e: KeyboardEvent) => void;\n};\n\ntype UseKeysProps = {\n ref?: React.RefObject<HTMLElement>;\n keys?: KeyHandlers;\n isActive?: boolean;\n eventType?: 'keypress' | 'keydown' | 'keyup';\n};\n\nconst getKeyHandler = (keys: KeyHandlers) => {\n return (e: KeyboardEvent) => {\n (keys[e.code as KeyCode] || keys[e.key as KeyCode])?.(e);\n };\n};\n\nexport const useKeysRef = (params: UseKeysProps) => {\n const { ref, keys, isActive = true, eventType = 'keydown' } = params;\n\n const onKeyDown = useCallback(\n (e: Event) => {\n if (keys && isActive) {\n const event = e as unknown as KeyboardEvent;\n getKeyHandler(keys)(event);\n }\n },\n [keys, isActive],\n );\n\n useEffect(() => {\n ref?.current?.addEventListener(eventType, onKeyDown);\n\n return () => {\n ref?.current?.removeEventListener(eventType, onKeyDown);\n };\n }, [ref, keys, isActive, eventType]);\n};\n"],"mappings":"AAAA,OAAgBA,WAAhB,CAA6BC,SAA7B,KAA8C,OAA9C,CAiBA,GAAMC,cAAa,CAAG,SAACC,CAAD,CAAuB,CAC3C,MAAO,UAACC,CAAD,CAAsB,iBAC1BD,CAAI,CAACC,CAAC,CAACC,IAAH,CAAJ,EAA2BF,CAAI,CAACC,CAAC,CAACE,GAAH,CADL,qBAC3B,EAAsDF,CAAtD,CACD,CACF,CAJD,CAMA,MAAO,IAAMG,WAAU,CAAG,SAACC,CAAD,CAA0B,IAC1CC,EAD0C,CACYD,CADZ,CAC1CC,GAD0C,CACrCN,CADqC,CACYK,CADZ,CACrCL,IADqC,GACYK,CADZ,CAC/BE,QAD+B,CAC/BA,CAD+B,oBACYF,CADZ,CACdG,SADc,CACdA,CADc,YACF,SADE,GAG5CC,CAAS,CAAGZ,WAAW,CAC3B,SAACI,CAAD,CAAc,CACZ,GAAID,CAAI,EAAIO,CAAZ,CAAsB,CAEpBR,aAAa,CAACC,CAAD,CAAb,CADcC,CACd,CACD,CACF,CAN0B,CAO3B,CAACD,CAAD,CAAOO,CAAP,CAP2B,CAHqB,CAalDT,SAAS,CAAC,UAAM,OAGd,cAFAQ,CAEA,WAFAA,CAEA,YAFAA,CAAG,CAAEI,OAEL,qBAFA,EAAcC,gBAAd,CAA+BH,CAA/B,CAA0CC,CAA1C,CAEA,CAAO,UAAM,cACXH,CADW,WACXA,CADW,YACXA,CAAG,CAAEI,OADM,qBACX,EAAcE,mBAAd,CAAkCJ,CAAlC,CAA6CC,CAA7C,CACD,CACF,CANQ,CAMN,CAACH,CAAD,CAAMN,CAAN,CAAYO,CAAZ,CAAsBC,CAAtB,CANM,CAOV,CApBM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@consta/uikit",
3
- "version": "4.26.1",
3
+ "version": "4.27.0",
4
4
  "keywords": [
5
5
  "ui-kit",
6
6
  "design-system",
@@ -0,0 +1 @@
1
+ export * from "../__internal__/src/hooks/useKeysRef";
@@ -0,0 +1 @@
1
+ export * from "../__internal__/src/hooks/useKeysRef";