@consta/uikit 4.14.2 → 4.16.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 (125) hide show
  1. package/__internal__/src/components/AutoCompleteCanary/useAutoComplete.js +1 -1
  2. package/__internal__/src/components/AutoCompleteCanary/useAutoComplete.js.map +1 -1
  3. package/__internal__/src/components/Combobox/Combobox.js +1 -1
  4. package/__internal__/src/components/Combobox/Combobox.js.map +1 -1
  5. package/__internal__/src/components/Combobox/helpers.d.ts +18 -7
  6. package/__internal__/src/components/Combobox/helpers.js.map +1 -1
  7. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/DatePickerFieldTypeDate.d.ts +3 -2
  8. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/DatePickerFieldTypeDate.js +1 -1
  9. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/DatePickerFieldTypeDate.js.map +1 -1
  10. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/helpers.d.ts +2 -0
  11. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/helpers.js +1 -1
  12. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/helpers.js.map +1 -1
  13. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateRange/DatePickerFieldTypeDateRange.js +1 -1
  14. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateRange/DatePickerFieldTypeDateRange.js.map +1 -1
  15. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime.d.ts +3 -2
  16. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime.js +1 -1
  17. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime.js.map +1 -1
  18. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/helpers.d.ts +2 -0
  19. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/helpers.js +1 -1
  20. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/helpers.js.map +1 -1
  21. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTimeRange/DatePickerFieldTypeDateTimeRange.js +1 -1
  22. package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTimeRange/DatePickerFieldTypeDateTimeRange.js.map +1 -1
  23. package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/DatePickerFieldTypeMonth.d.ts +3 -2
  24. package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/DatePickerFieldTypeMonth.js +1 -1
  25. package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/DatePickerFieldTypeMonth.js.map +1 -1
  26. package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/helpers.d.ts +2 -0
  27. package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/helpers.js +1 -1
  28. package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/helpers.js.map +1 -1
  29. package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonthRange/DatePickerFieldTypeMonthRange.js +1 -1
  30. package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonthRange/DatePickerFieldTypeMonthRange.js.map +1 -1
  31. package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/DatePickerFieldTypeTime.d.ts +3 -2
  32. package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/DatePickerFieldTypeTime.js +1 -1
  33. package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/DatePickerFieldTypeTime.js.map +1 -1
  34. package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/helpers.d.ts +2 -0
  35. package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/helpers.js +1 -1
  36. package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/helpers.js.map +1 -1
  37. package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/DatePickerFieldTypeYear.d.ts +3 -2
  38. package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/DatePickerFieldTypeYear.js +1 -1
  39. package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/DatePickerFieldTypeYear.js.map +1 -1
  40. package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/helpers.d.ts +2 -0
  41. package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/helpers.js +1 -1
  42. package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/helpers.js.map +1 -1
  43. package/__internal__/src/components/DatePicker/DatePickerFieldTypeYearRange/DatePickerFieldTypeYearRange.js +1 -1
  44. package/__internal__/src/components/DatePicker/DatePickerFieldTypeYearRange/DatePickerFieldTypeYearRange.js.map +1 -1
  45. package/__internal__/src/components/DatePicker/types.d.ts +1 -0
  46. package/__internal__/src/components/DatePicker/types.js.map +1 -1
  47. package/__internal__/src/components/DateTime/DateTimeTypeDate/DateTimeTypeDate.js +1 -1
  48. package/__internal__/src/components/DateTime/DateTimeTypeDate/DateTimeTypeDate.js.map +1 -1
  49. package/__internal__/src/components/DateTime/DateTimeTypeDateTime/DateTimeTypeDateTime.js +1 -1
  50. package/__internal__/src/components/DateTime/DateTimeTypeDateTime/DateTimeTypeDateTime.js.map +1 -1
  51. package/__internal__/src/components/DateTime/DateTimeTypeMonth/DateTimeTypeMonth.js +1 -1
  52. package/__internal__/src/components/DateTime/DateTimeTypeMonth/DateTimeTypeMonth.js.map +1 -1
  53. package/__internal__/src/components/DateTime/DateTimeTypeTime/DateTimeTypeTime.js +1 -1
  54. package/__internal__/src/components/DateTime/DateTimeTypeTime/DateTimeTypeTime.js.map +1 -1
  55. package/__internal__/src/components/DateTime/DateTimeTypeTime/helpers.d.ts +2 -1
  56. package/__internal__/src/components/DateTime/DateTimeTypeTime/helpers.js +1 -1
  57. package/__internal__/src/components/DateTime/DateTimeTypeTime/helpers.js.map +1 -1
  58. package/__internal__/src/components/DateTime/DateTimeTypeYear/DateTimeTypeYear.js +1 -1
  59. package/__internal__/src/components/DateTime/DateTimeTypeYear/DateTimeTypeYear.js.map +1 -1
  60. package/__internal__/src/components/DateTime/helpers/getDaysOfMonth.d.ts +2 -1
  61. package/__internal__/src/components/DateTime/helpers/getDaysOfMonth.js +1 -1
  62. package/__internal__/src/components/DateTime/helpers/getDaysOfMonth.js.map +1 -1
  63. package/__internal__/src/components/DateTime/helpers/getMonthsOfYear.d.ts +2 -1
  64. package/__internal__/src/components/DateTime/helpers/getMonthsOfYear.js +1 -1
  65. package/__internal__/src/components/DateTime/helpers/getMonthsOfYear.js.map +1 -1
  66. package/__internal__/src/components/DateTime/helpers/getYearsOfDecade.d.ts +2 -1
  67. package/__internal__/src/components/DateTime/helpers/getYearsOfDecade.js +1 -1
  68. package/__internal__/src/components/DateTime/helpers/getYearsOfDecade.js.map +1 -1
  69. package/__internal__/src/components/DateTime/helpers/types.d.ts +2 -0
  70. package/__internal__/src/components/DateTime/helpers/types.js.map +1 -1
  71. package/__internal__/src/components/EventInterceptor/propsHandlers/useTextFieldEventsHandler.d.ts +3 -2
  72. package/__internal__/src/components/FieldLabel/FieldLabel.css +1 -1
  73. package/__internal__/src/components/FieldLabel/FieldLabel.d.ts +2 -0
  74. package/__internal__/src/components/FieldLabel/FieldLabel.js +1 -1
  75. package/__internal__/src/components/FieldLabel/FieldLabel.js.map +1 -1
  76. package/__internal__/src/components/Select/helpers.d.ts +5 -2
  77. package/__internal__/src/components/Select/helpers.js.map +1 -1
  78. package/__internal__/src/components/SelectComponents/Select.css +1 -1
  79. package/__internal__/src/components/SelectComponents/SelectContainer/SelectContainer.d.ts +3 -1
  80. package/__internal__/src/components/SelectComponents/SelectContainer/SelectContainer.js +1 -1
  81. package/__internal__/src/components/SelectComponents/SelectContainer/SelectContainer.js.map +1 -1
  82. package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.d.ts +7 -2
  83. package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.js +1 -1
  84. package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.js.map +1 -1
  85. package/__internal__/src/components/SelectComponents/SelectItem/SelectItem.d.ts +2 -0
  86. package/__internal__/src/components/SelectComponents/SelectItem/SelectItem.js +1 -1
  87. package/__internal__/src/components/SelectComponents/SelectItem/SelectItem.js.map +1 -1
  88. package/__internal__/src/components/SelectComponents/SelectItemAll/SelectItemAll.css +1 -0
  89. package/__internal__/src/components/SelectComponents/SelectItemAll/SelectSelectAll.d.ts +13 -0
  90. package/__internal__/src/components/SelectComponents/SelectItemAll/SelectSelectAll.js +2 -0
  91. package/__internal__/src/components/SelectComponents/SelectItemAll/SelectSelectAll.js.map +1 -0
  92. package/__internal__/src/components/SelectComponents/SelectValueTag/SelectValueTag.css +1 -1
  93. package/__internal__/src/components/SelectComponents/types.d.ts +1 -1
  94. package/__internal__/src/components/SelectComponents/types.js +1 -1
  95. package/__internal__/src/components/SelectComponents/types.js.map +1 -1
  96. package/__internal__/src/components/Slider/Slider.js +1 -1
  97. package/__internal__/src/components/Slider/Slider.js.map +1 -1
  98. package/__internal__/src/components/Slider/helper.d.ts +1 -0
  99. package/__internal__/src/components/Slider/helper.js.map +1 -1
  100. package/__internal__/src/components/TagBase/TagBase.d.ts +1 -1
  101. package/__internal__/src/components/TextField/TextField.css +1 -1
  102. package/__internal__/src/components/TextField/TextField.js +1 -1
  103. package/__internal__/src/components/TextField/TextField.js.map +1 -1
  104. package/__internal__/src/components/TextField/types.d.ts +1 -0
  105. package/__internal__/src/components/TextField/types.js.map +1 -1
  106. package/__internal__/src/components/User/User.js +1 -1
  107. package/__internal__/src/components/User/User.js.map +1 -1
  108. package/__internal__/src/components/UserSelect/helpers.d.ts +5 -2
  109. package/__internal__/src/components/UserSelect/helpers.js.map +1 -1
  110. package/__internal__/src/hooks/useSelect/useSelect.d.ts +5 -2
  111. package/__internal__/src/hooks/useSelect/useSelect.js +1 -1
  112. package/__internal__/src/hooks/useSelect/useSelect.js.map +1 -1
  113. package/__internal__/src/utils/date/index.d.ts +1 -0
  114. package/__internal__/src/utils/date/index.js +1 -1
  115. package/__internal__/src/utils/date/index.js.map +1 -1
  116. package/__internal__/src/utils/date/isDisableDate.d.ts +8 -0
  117. package/__internal__/src/utils/date/isDisableDate.js +2 -0
  118. package/__internal__/src/utils/date/isDisableDate.js.map +1 -0
  119. package/__internal__/src/utils/date/isInMinMaxDade.d.ts +1 -1
  120. package/__internal__/src/utils/date/isInMinMaxDade.js +1 -1
  121. package/__internal__/src/utils/date/isInMinMaxDade.js.map +1 -1
  122. package/__internal__/src/utils/getGroups.d.ts +12 -0
  123. package/__internal__/src/utils/getGroups.js +1 -1
  124. package/__internal__/src/utils/getGroups.js.map +1 -1
  125. package/package.json +1 -1
@@ -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"],"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 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 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\nconst isRangeParams = (params: Props<boolean>): params is Props<true> => {\n return !!params.range;\n};\n\nconst isNotRangeParams = (params: Props<boolean>): 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"],"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,C,GAsFDE,cAAa,CAAG,SAACC,CAAD,CAAmD,CACvE,MAAO,CAAC,CAACA,CAAM,CAACC,KACjB,C,CAEKC,gBAAgB,CAAG,SAACF,CAAD,CAAoD,CAC3E,MAAO,CAACA,CAAM,CAACC,KAChB,C,CAED,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,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ropStatus","propSize","defaultPropSize","isRangeParams","params","range","isNotRangeParams","defaultTooltipFormatter","value","toString","getValueForInput","props","field","getOnChandgeForInput","e","onChange","getIcon","side","getMaxForStartField","max","getMinForEndField","min"],"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 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\nconst isRangeParams = (params: Props<boolean>): params is Props<true> => {\n return !!params.range;\n};\n\nconst isNotRangeParams = (params: Props<boolean>): 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"],"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,C,GAuFDE,cAAa,CAAG,SAACC,CAAD,CAAmD,CACvE,MAAO,CAAC,CAACA,CAAM,CAACC,KACjB,C,CAEKC,gBAAgB,CAAG,SAACF,CAAD,CAAoD,CAC3E,MAAO,CAACA,CAAM,CAACC,KAChB,C,CAED,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,QADK,GAIZT,gBAAgB,CAACK,CAAD,CAJJ,EAKdA,CAAK,CAACI,QAAN,CAAe,CAAED,CAAC,CAADA,CAAF,CAAKN,KAAK,CAALA,CAAL,CAAf,CALc,CAOZL,aAAa,CAACQ,CAAD,CAPD,EAQdA,CAAK,CAACI,QAAN,CAAe,CACbD,CAAC,CAADA,CADa,CAEbN,KAAK,CAAEI,CAAK,CAAG,CAACD,CAAK,CAACH,KAAN,CAAY,CAAZ,CAAD,CAAiBA,CAAjB,CAAH,CAA6B,CAACA,CAAD,CAAQG,CAAK,CAACH,KAAN,CAAY,CAAZ,CAAR,CAF5B,CAAf,CARc,CAajB,CAdD,CADK,CAiBP,MAAO,IAAMQ,QAAO,CAAG,SAACC,CAAD,CAAiB,CACtC,GAAa,OAAT,GAAAA,CAAJ,CACE,MAAOA,EAEV,CAJM,CAMP,MAAO,IAAMC,oBAAmB,CAAG,SAACP,CAAD,CAAiC,OAC9DL,iBAAgB,CAACK,CAAD,CAD8C,CAEzDA,CAAK,CAACQ,GAFmD,CAI9DhB,aAAa,CAACQ,CAAD,CAJiD,CAKzDA,CAAK,CAACH,KAAN,CAAY,CAAZ,CALyD,OAOnE,CAPM,CASP,MAAO,IAAMY,kBAAiB,CAAG,SAACT,CAAD,CAAiC,OAC5DL,iBAAgB,CAACK,CAAD,CAD4C,CAEvDA,CAAK,CAACU,GAFiD,CAI5DlB,aAAa,CAACQ,CAAD,CAJ+C,CAKvDA,CAAK,CAACH,KAAN,CAAY,CAAZ,CALuD,OAOjE,CAPM"}
@@ -6,7 +6,7 @@ export declare const tagBasePropSizeDefault: "m";
6
6
  export declare type TagBasePropSize = typeof tagBasePropSize[number];
7
7
  export declare const tagBasePropGroupNumberValue: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9];
8
8
  export declare const tagBasePropGroupStringValue: readonly ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9
- export declare const tagBasePropGroup: (2 | 1 | "1" | 4 | 3 | 5 | "2" | 7 | "3" | "4" | "5" | 9 | 8 | 6 | "6" | "7" | "8" | "9")[];
9
+ export declare const tagBasePropGroup: (2 | 1 | "1" | 4 | 3 | 5 | "2" | 7 | 9 | "3" | "4" | "5" | "6" | "7" | "8" | 8 | 6 | "9")[];
10
10
  export declare type TagBasePropGroup = typeof tagBasePropGroup[number];
11
11
  export declare const tagBasePropView: readonly ["stroked", "filled"];
12
12
  export declare const tagBasePropViewDefault: "stroked";
@@ -1 +1 @@
1
- .TextField{--caption-margin-left:calc(var(--input-space) + var(--control-border-width));--counter-button-icon-color:var(--color-control-typo-ghost);--counter-button-background:transparent;--clear-button-color:var(--color-control-typo-clear);display:inline-flex;position:relative}.TextField_width_full{width:100%}.TextField_size_xs{--input-height:var(--control-height-xs);--input-font-size:var(--control-text-size-xs);--input-space:calc(var(--control-space-xs)*0.5)}.TextField_size_s{--input-height:var(--control-height-s);--input-font-size:var(--control-text-size-s);--input-space:calc(var(--control-space-s)*0.5)}.TextField_size_m{--input-height:var(--control-height-m);--input-font-size:var(--control-text-size-m);--input-space:calc(var(--control-space-m)*0.5)}.TextField_size_l{--input-height:var(--control-height-l);--input-font-size:var(--control-text-size-l);--input-space:calc(var(--control-space-l)*0.5)}.TextField_labelPosition_top{flex-direction:column}.TextField_labelPosition_top>:not(:last-child){margin-bottom:var(--space-xs)}.TextField_labelPosition_left{flex-direction:row}.TextField_labelPosition_left .TextField-Label{align-items:center;display:inline-flex;height:var(--input-height)}.TextField_labelPosition_left>:not(:last-child){margin-right:var(--space-s)}.TextField-Body{display:inline-flex;flex-direction:column;width:100%}.TextField-Body .TextField-Caption{margin-left:var(--caption-margin-left);margin-top:var(--space-2xs)}.TextField_view_clear .TextField-Caption{--caption-margin-left:0}.TextField-InputContainer{box-sizing:border-box;display:inline-flex;font-family:var(--font-primary);font-weight:var(--font-weight-text-regular);max-width:100%;min-height:var(--input-height);position:relative;transition:border-color .15s,box-shadow .15s,background-color .15s}.TextField-InputContainer_disabled{--counter-button-background:var(--color-control-bg-disable);--counter-button-icon-color:var(--color-control-typo-disable)}.TextField-InputContainer_view_clear,.TextField-InputContainer_view_clear:focus,.TextField-InputContainer_view_clear:hover{color:var(--color-control-typo-default);padding:0}.TextField-InputContainer_view_clear.TextField-InputContainer_disabled .TextField-Input,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled .TextField-Input,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled .TextField-Input{color:var(--color-control-typo-disable);pointer-events:all}.TextField-InputContainer_view_clear.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill,.TextField-InputContainer_view_clear.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill:focus,.TextField-InputContainer_view_clear.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill:hover,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill:focus,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill:hover,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill:focus,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill:hover{-webkit-text-fill-color:var(--color-control-typo-disable)}.TextField-InputContainer_view_clear.TextField-InputContainer_disabled .TextField-Input::-moz-placeholder,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled .TextField-Input::-moz-placeholder,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled .TextField-Input::-moz-placeholder{color:var(--color-control-typo-disable)}.TextField-InputContainer_view_clear.TextField-InputContainer_disabled .TextField-Input::placeholder,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled .TextField-Input::placeholder,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled .TextField-Input::placeholder{color:var(--color-control-typo-disable)}.TextField-InputContainer_view_clear.TextField-InputContainer_disabled .TextField-Side_type_string,.TextField-InputContainer_view_clear.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Side_type_string,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled .TextField-Side_type_string,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Side_type_string,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled .TextField-Side_type_string,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Side_type_string{color:var(--color-control-typo-disable)}.TextField-InputContainer_view_clear.TextField-InputContainer_disabled.TextField-InputContainer .TextField-Icon,.TextField-InputContainer_view_clear.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Icon,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled.TextField-InputContainer .TextField-Icon,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Icon,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled.TextField-InputContainer .TextField-Icon,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Icon{color:var(--color-control-typo-disable)}.TextField-InputContainer_view_default{--container-border-color:var(--color-control-bg-border-default);background:var(--color-control-bg-default);border:var(--control-border-width) solid var(--container-border-color);border-radius:var(--control-radius);color:var(--color-control-typo-default);overflow-x:hidden;padding:0 var(--input-space)}.TextField-InputContainer_view_default:hover{border-color:var(--color-control-bg-border-default-hover)}.TextField-InputContainer_view_default.TextField-InputContainer_status_alert{--container-border-color:var(--color-bg-alert)}.TextField-InputContainer_view_default.TextField-InputContainer_status_success{--container-border-color:var(--color-bg-success)}.TextField-InputContainer_view_default.TextField-InputContainer_status_warning{--container-border-color:var(--color-bg-warning)}.TextField-InputContainer_view_default .TextField-Input{color:var(--color-control-typo-default)}.TextField-InputContainer_view_default .TextField-Input::-moz-placeholder{color:var(--color-control-typo-placeholder)}.TextField-InputContainer_view_default .TextField-Input::placeholder{color:var(--color-control-typo-placeholder)}.TextField-InputContainer_view_default .TextField-Input:-webkit-autofill,.TextField-InputContainer_view_default .TextField-Input:-webkit-autofill:focus,.TextField-InputContainer_view_default .TextField-Input:-webkit-autofill:hover{-webkit-text-fill-color:var(--color-control-typo-default)}.TextField-InputContainer_view_default .TextField-Side_type_string{color:var(--color-control-typo-placeholder)}.TextField-InputContainer_view_default.TextField-InputContainer_focus{border-color:var(--color-control-bg-border-focus);outline:none;z-index:1}.TextField-InputContainer_view_default.TextField-InputContainer_focus.TextField-InputContainer_form_clearClear{box-shadow:var(--control-border-width) 0 var(--color-control-bg-border-focus),calc(var(--control-border-width)*-1) 0 var(--color-control-bg-border-focus)}.TextField-InputContainer_view_default.TextField-InputContainer_focus.TextField-InputContainer_form_brickClear,.TextField-InputContainer_view_default.TextField-InputContainer_focus.TextField-InputContainer_form_defaultClear,.TextField-InputContainer_view_default.TextField-InputContainer_focus.TextField-InputContainer_form_roundClear{box-shadow:var(--control-border-width) 0 var(--color-control-bg-border-focus)}.TextField-InputContainer_view_default.TextField-InputContainer_focus.TextField-InputContainer_form_clearBrick,.TextField-InputContainer_view_default.TextField-InputContainer_focus.TextField-InputContainer_form_clearDefault,.TextField-InputContainer_view_default.TextField-InputContainer_focus.TextField-InputContainer_form_clearRound{box-shadow:calc(var(--control-border-width)*-1) 0 var(--color-control-bg-border-focus)}.TextField-InputContainer_view_default.TextField-InputContainer_disabled{--clear-button-color:var(--color-control-typo-disable);background:var(--color-control-bg-disable);border-color:var(--color-control-bg-border-disable)}.TextField-InputContainer_view_default.TextField-InputContainer_disabled .TextField-Input{color:var(--color-control-typo-disable);pointer-events:all}.TextField-InputContainer_view_default.TextField-InputContainer_disabled .TextField-Input::-moz-placeholder{color:var(--color-control-typo-disable)}.TextField-InputContainer_view_default.TextField-InputContainer_disabled .TextField-Input::placeholder{color:var(--color-control-typo-disable)}.TextField-InputContainer_view_default.TextField-InputContainer_disabled .TextField-Side_type_string,.TextField-InputContainer_view_default.TextField-InputContainer_disabled.TextField-InputContainer .TextField-Icon,.TextField-InputContainer_view_default.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Icon,.TextField-InputContainer_view_default.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Side_type_string{color:var(--color-control-typo-disable)}.TextField-InputContainer_form_defaultClear{border-right-width:0}.TextField-InputContainer_form_defaultBrick,.TextField-InputContainer_form_defaultClear{border-radius:var(--control-radius) 0 0 var(--control-radius)}.TextField-InputContainer_form_round{border-radius:calc(var(--input-height)/2);padding-left:calc(var(--input-space)*1.6);padding-right:calc(var(--input-space)*1.6)}.TextField-InputContainer_form_roundBrick{border-radius:calc(var(--input-height)/2) 0 0 calc(var(--input-height)/2);padding-left:calc(var(--input-space)*1.6)}.TextField-InputContainer_form_roundClear{border-radius:calc(var(--input-height)/2) 0 0 calc(var(--input-height)/2);border-right-width:0;padding-left:calc(var(--input-space)*1.6)}.TextField-InputContainer_form_brick{border-radius:0}.TextField-InputContainer_form_brickDefault{border-radius:0 var(--control-radius) var(--control-radius) 0}.TextField-InputContainer_form_brickRound{border-radius:0 calc(var(--input-height)/2) calc(var(--input-height)/2) 0;padding-right:calc(var(--input-space)*1.6)}.TextField-InputContainer_form_brickClear{border-radius:0;border-right-width:0}.TextField-InputContainer_form_clearDefault{border-left-width:0;border-radius:0 var(--control-radius) var(--control-radius) 0}.TextField-InputContainer_form_clearBrick{border-left-width:0;border-radius:0}.TextField-InputContainer_form_clearRound{border-left-width:0;border-radius:0 calc(var(--input-height)/2) calc(var(--input-height)/2) 0;padding-right:calc(var(--input-space)*1.6)}.TextField-InputContainer_form_clearClear{border-width:0;border-bottom-width:var(--control-border-width);border-radius:0;border-top-width:var(--control-border-width)}.TextField-InputContainer_withValue .TextField-Side.TextField-Side_type_string{color:var(--color-control-typo-default)}.TextField-InputContainer_withValue .TextField-Icon{color:var(--color-typo-secondary)}.TextField-InputContainer_type_number{padding-right:0}.TextField-InputContainer_type_textarea .TextField-Input{display:block;line-height:var(--line-height-text-m);min-width:0;padding-bottom:calc((var(--input-height) - (var(--control-border-width)*2) - var(--line-height-text-m))/2);padding-top:calc((var(--input-height) - (var(--control-border-width)*2) - var(--line-height-text-m))/2);resize:none}.TextField-Counter{display:inline-flex;flex-direction:column;height:calc(var(--input-height) - var(--control-border-width)*2);width:var(--space-xl)}.TextField-CounterButton{align-items:center;background-color:var(--counter-button-background);border:none;color:var(--counter-button-icon-color);cursor:pointer;display:inline-flex;flex:1;flex-direction:column;justify-content:center;margin:0;overflow-y:hidden;padding:0;transition:background-color .15s;width:var(--space-xl)}.TextField-ClearButton,.TextField-EyeButton{background-color:transparent;border:none;cursor:pointer;display:flex;flex-direction:column;height:calc(var(--input-height) - var(--control-border-width)*2);justify-content:center;margin:0;margin-left:var(--input-space);padding:0}.TextField-ClearButton{color:var(--clear-button-color)}.TextField-ClearButton:hover{--clear-button-color:var(--color-control-typo-clear-hover)}.TextField-EyeButton{color:var(--color-control-typo-placeholder)}.TextField-EyeButton:hover{color:var(--color-control-typo-clear-hover)}.TextField-ClearButtonIcon{position:relative;top:1px}.TextField-Input{background:transparent;border:none;color:currentColor;flex:1;font-family:var(--font-primary);font-size:var(--input-font-size);height:calc(var(--input-height) - var(--control-border-width)*2);min-width:80px;outline:none;padding:0;width:100%}.TextField-Input::-webkit-inner-spin-button,.TextField-Input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.TextField-Input[type=password]::-ms-reveal{display:none}.TextField-Input[type=number]{-moz-appearance:textfield}.TextField-Input:focus{outline:none}.TextField-Input:-webkit-autofill,.TextField-Input:-webkit-autofill:focus,.TextField-Input:-webkit-autofill:hover{border:none;-webkit-box-shadow:inset 0 0 0 1000px transparent;-webkit-transition:background-color 5000s ease-in-out 0s;transition:background-color 5000s ease-in-out 0s}.TextField-Side{align-items:center;display:flex;height:calc(var(--input-height) - var(--control-border-width)*2);overflow:hidden}.TextField-Side_position_left{margin-right:var(--input-space)}.TextField-Side_position_right{margin-left:var(--input-space)}.TextField-Side_type_string{font-size:var(--input-font-size);white-space:nowrap}.TextField-Icon{color:var(--color-control-typo-placeholder)}
1
+ .TextField{--caption-margin-left:calc(var(--input-space) + var(--control-border-width));--counter-button-icon-color:var(--color-control-typo-ghost);--counter-button-background:transparent;--counter-offset:0;--clear-button-color:var(--color-control-typo-clear);display:inline-flex;position:relative}.TextField_width_full{width:100%}.TextField_size_xs{--label-offset:var(--space-2xs);--caption-offset:var(--space-2xs);--input-height:var(--control-height-xs);--input-font-size:var(--control-text-size-xs);--input-space:calc(var(--control-space-xs)*0.5)}.TextField_size_xs .TextField-InputContainer_form_brickRound,.TextField_size_xs .TextField-InputContainer_form_clearRound,.TextField_size_xs .TextField-InputContainer_form_round{--counter-offset:calc(var(--space-xs) - var(--space-3xs))}.TextField_size_s{--label-offset:var(--space-2xs);--caption-offset:var(--space-2xs);--input-height:var(--control-height-s);--input-font-size:var(--control-text-size-s);--input-space:calc(var(--control-space-s)*0.5)}.TextField_size_s .TextField-InputContainer_form_brickRound,.TextField_size_s .TextField-InputContainer_form_clearRound,.TextField_size_s .TextField-InputContainer_form_round{--counter-offset:var(--space-xs)}.TextField_size_m{--label-offset:var(--space-xs);--caption-offset:var(--space-xs);--input-height:var(--control-height-m);--input-font-size:var(--control-text-size-m);--input-space:calc(var(--control-space-m)*0.5)}.TextField_size_m .TextField-InputContainer_form_brickRound,.TextField_size_m .TextField-InputContainer_form_clearRound,.TextField_size_m .TextField-InputContainer_form_round{--counter-offset:calc(var(--space-s) - var(--space-3xs))}.TextField_size_l{--label-offset:var(--space-xs);--caption-offset:var(--space-xs);--input-height:var(--control-height-l);--input-font-size:var(--control-text-size-l);--input-space:calc(var(--control-space-l)*0.5)}.TextField_size_l .TextField-InputContainer_form_brickRound,.TextField_size_l .TextField-InputContainer_form_clearRound,.TextField_size_l .TextField-InputContainer_form_round{--counter-offset:var(--space-s)}.TextField_labelPosition_top{flex-direction:column}.TextField_labelPosition_top>:not(:last-child){margin-bottom:var(--label-offset)}.TextField_labelPosition_left{flex-direction:row}.TextField_labelPosition_left .TextField-Label{align-items:center;display:inline-flex;height:var(--input-height)}.TextField_labelPosition_left>:not(:last-child){margin-right:var(--space-s)}.TextField-Body{display:inline-flex;flex-direction:column;width:100%}.TextField-Body .TextField-Caption{margin-left:var(--caption-margin-left);margin-top:var(--caption-offset)}.TextField_view_clear .TextField-Caption{--caption-margin-left:0}.TextField-InputContainer{box-sizing:border-box;display:inline-flex;font-family:var(--font-primary);font-weight:var(--font-weight-text-regular);max-width:100%;min-height:var(--input-height);position:relative;transition:border-color .15s,box-shadow .15s,background-color .15s}.TextField-InputContainer_disabled{--counter-button-background:var(--color-control-bg-disable);--counter-button-icon-color:var(--color-control-typo-disable)}.TextField-InputContainer_view_clear,.TextField-InputContainer_view_clear:focus,.TextField-InputContainer_view_clear:hover{color:var(--color-control-typo-default);padding:0}.TextField-InputContainer_view_clear.TextField-InputContainer_disabled .TextField-Input,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled .TextField-Input,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled .TextField-Input{color:var(--color-control-typo-disable);pointer-events:all}.TextField-InputContainer_view_clear.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill,.TextField-InputContainer_view_clear.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill:focus,.TextField-InputContainer_view_clear.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill:hover,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill:focus,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill:hover,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill:focus,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled .TextField-Input:-webkit-autofill:hover{-webkit-text-fill-color:var(--color-control-typo-disable)}.TextField-InputContainer_view_clear.TextField-InputContainer_disabled .TextField-Input::-moz-placeholder,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled .TextField-Input::-moz-placeholder,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled .TextField-Input::-moz-placeholder{color:var(--color-control-typo-disable)}.TextField-InputContainer_view_clear.TextField-InputContainer_disabled .TextField-Input::placeholder,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled .TextField-Input::placeholder,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled .TextField-Input::placeholder{color:var(--color-control-typo-disable)}.TextField-InputContainer_view_clear.TextField-InputContainer_disabled .TextField-Side_type_string,.TextField-InputContainer_view_clear.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Side_type_string,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled .TextField-Side_type_string,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Side_type_string,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled .TextField-Side_type_string,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Side_type_string{color:var(--color-control-typo-disable)}.TextField-InputContainer_view_clear.TextField-InputContainer_disabled.TextField-InputContainer .TextField-Icon,.TextField-InputContainer_view_clear.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Icon,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled.TextField-InputContainer .TextField-Icon,.TextField-InputContainer_view_clear:focus.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Icon,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled.TextField-InputContainer .TextField-Icon,.TextField-InputContainer_view_clear:hover.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Icon{color:var(--color-control-typo-disable)}.TextField-InputContainer_view_default{--container-border-color:var(--color-control-bg-border-default);background:var(--color-control-bg-default);border:var(--control-border-width) solid var(--container-border-color);border-radius:var(--control-radius);color:var(--color-control-typo-default);overflow-x:hidden;padding:0 var(--input-space)}.TextField-InputContainer_view_default:hover{border-color:var(--color-control-bg-border-default-hover)}.TextField-InputContainer_view_default.TextField-InputContainer_status_alert{--container-border-color:var(--color-bg-alert)}.TextField-InputContainer_view_default.TextField-InputContainer_status_success{--container-border-color:var(--color-bg-success)}.TextField-InputContainer_view_default.TextField-InputContainer_status_warning{--container-border-color:var(--color-bg-warning)}.TextField-InputContainer_view_default .TextField-Input{color:var(--color-control-typo-default)}.TextField-InputContainer_view_default .TextField-Input::-moz-placeholder{color:var(--color-control-typo-placeholder)}.TextField-InputContainer_view_default .TextField-Input::placeholder{color:var(--color-control-typo-placeholder)}.TextField-InputContainer_view_default .TextField-Input:-webkit-autofill,.TextField-InputContainer_view_default .TextField-Input:-webkit-autofill:focus,.TextField-InputContainer_view_default .TextField-Input:-webkit-autofill:hover{-webkit-text-fill-color:var(--color-control-typo-default)}.TextField-InputContainer_view_default .TextField-Side_type_string{color:var(--color-control-typo-placeholder)}.TextField-InputContainer_view_default.TextField-InputContainer_focus{border-color:var(--color-control-bg-border-focus);outline:none;z-index:1}.TextField-InputContainer_view_default.TextField-InputContainer_focus.TextField-InputContainer_form_clearClear{box-shadow:var(--control-border-width) 0 var(--color-control-bg-border-focus),calc(var(--control-border-width)*-1) 0 var(--color-control-bg-border-focus)}.TextField-InputContainer_view_default.TextField-InputContainer_focus.TextField-InputContainer_form_brickClear,.TextField-InputContainer_view_default.TextField-InputContainer_focus.TextField-InputContainer_form_defaultClear,.TextField-InputContainer_view_default.TextField-InputContainer_focus.TextField-InputContainer_form_roundClear{box-shadow:var(--control-border-width) 0 var(--color-control-bg-border-focus)}.TextField-InputContainer_view_default.TextField-InputContainer_focus.TextField-InputContainer_form_clearBrick,.TextField-InputContainer_view_default.TextField-InputContainer_focus.TextField-InputContainer_form_clearDefault,.TextField-InputContainer_view_default.TextField-InputContainer_focus.TextField-InputContainer_form_clearRound{box-shadow:calc(var(--control-border-width)*-1) 0 var(--color-control-bg-border-focus)}.TextField-InputContainer_view_default.TextField-InputContainer_disabled{--clear-button-color:var(--color-control-typo-disable);background:var(--color-control-bg-disable);border-color:var(--color-control-bg-border-disable)}.TextField-InputContainer_view_default.TextField-InputContainer_disabled .TextField-Input{color:var(--color-control-typo-disable);pointer-events:all}.TextField-InputContainer_view_default.TextField-InputContainer_disabled .TextField-Input::-moz-placeholder{color:var(--color-control-typo-disable)}.TextField-InputContainer_view_default.TextField-InputContainer_disabled .TextField-Input::placeholder{color:var(--color-control-typo-disable)}.TextField-InputContainer_view_default.TextField-InputContainer_disabled .TextField-Side_type_string,.TextField-InputContainer_view_default.TextField-InputContainer_disabled.TextField-InputContainer .TextField-Icon,.TextField-InputContainer_view_default.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Icon,.TextField-InputContainer_view_default.TextField-InputContainer_disabled.TextField-InputContainer_withValue .TextField-Side_type_string{color:var(--color-control-typo-disable)}.TextField-InputContainer_form_defaultClear{border-right-width:0}.TextField-InputContainer_form_defaultBrick,.TextField-InputContainer_form_defaultClear{border-radius:var(--control-radius) 0 0 var(--control-radius)}.TextField-InputContainer_form_round{border-radius:calc(var(--input-height)/2);padding-left:calc(var(--input-space)*1.6);padding-right:calc(var(--input-space)*1.6)}.TextField-InputContainer_form_roundBrick{border-radius:calc(var(--input-height)/2) 0 0 calc(var(--input-height)/2);padding-left:calc(var(--input-space)*1.6)}.TextField-InputContainer_form_roundClear{border-radius:calc(var(--input-height)/2) 0 0 calc(var(--input-height)/2);border-right-width:0;padding-left:calc(var(--input-space)*1.6)}.TextField-InputContainer_form_brick{border-radius:0}.TextField-InputContainer_form_brickDefault{border-radius:0 var(--control-radius) var(--control-radius) 0}.TextField-InputContainer_form_brickRound{border-radius:0 calc(var(--input-height)/2) calc(var(--input-height)/2) 0;padding-right:calc(var(--input-space)*1.6)}.TextField-InputContainer_form_brickClear{border-radius:0;border-right-width:0}.TextField-InputContainer_form_clearDefault{border-left-width:0;border-radius:0 var(--control-radius) var(--control-radius) 0}.TextField-InputContainer_form_clearBrick{border-left-width:0;border-radius:0}.TextField-InputContainer_form_clearRound{border-left-width:0;border-radius:0 calc(var(--input-height)/2) calc(var(--input-height)/2) 0;padding-right:calc(var(--input-space)*1.6)}.TextField-InputContainer_form_clearClear{border-width:0;border-bottom-width:var(--control-border-width);border-radius:0;border-top-width:var(--control-border-width)}.TextField-InputContainer_withValue .TextField-Side.TextField-Side_type_string{color:var(--color-control-typo-default)}.TextField-InputContainer_withValue .TextField-Icon{color:var(--color-typo-secondary)}.TextField-InputContainer_type_number{padding-right:0}.TextField-InputContainer_type_textarea .TextField-Input{display:block;line-height:var(--line-height-text-m);min-width:0;padding-bottom:calc((var(--input-height) - (var(--control-border-width)*2) - var(--line-height-text-m))/2);padding-top:calc((var(--input-height) - (var(--control-border-width)*2) - var(--line-height-text-m))/2);resize:none}.TextField-Counter{display:inline-flex;flex-direction:column;height:calc(var(--input-height) - var(--control-border-width)*2);margin-right:var(--counter-offset);width:var(--space-xl)}.TextField-CounterButton{align-items:center;background-color:var(--counter-button-background);border:none;color:var(--counter-button-icon-color);cursor:pointer;display:inline-flex;flex:1;flex-direction:column;justify-content:center;margin:0;overflow-y:hidden;padding:0;transition:background-color .15s;width:var(--space-xl)}.TextField-ClearButton,.TextField-EyeButton{background-color:transparent;border:none;cursor:pointer;display:flex;flex-direction:column;height:calc(var(--input-height) - var(--control-border-width)*2);justify-content:center;margin:0;margin-left:var(--input-space);padding:0}.TextField-ClearButton{color:var(--clear-button-color)}.TextField-ClearButton:hover{--clear-button-color:var(--color-control-typo-clear-hover)}.TextField-EyeButton{color:var(--color-control-typo-placeholder)}.TextField-EyeButton:hover{color:var(--color-control-typo-clear-hover)}.TextField-ClearButtonIcon{position:relative;top:1px}.TextField-Input{background:transparent;border:none;color:currentColor;flex:1;font-family:var(--font-primary);font-size:var(--input-font-size);height:calc(var(--input-height) - var(--control-border-width)*2);min-width:80px;outline:none;padding:0;width:100%}.TextField-Input::-webkit-inner-spin-button,.TextField-Input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.TextField-Input[type=password]::-ms-reveal{display:none}.TextField-Input[type=number]{-moz-appearance:textfield}.TextField-Input:focus{outline:none}.TextField-Input:-webkit-autofill,.TextField-Input:-webkit-autofill:focus,.TextField-Input:-webkit-autofill:hover{border:none;-webkit-box-shadow:inset 0 0 0 1000px transparent;-webkit-transition:background-color 5000s ease-in-out 0s;transition:background-color 5000s ease-in-out 0s}.TextField-Side{align-items:center;display:flex;height:calc(var(--input-height) - var(--control-border-width)*2);overflow:hidden}.TextField-Side_position_left{margin-right:var(--input-space)}.TextField-Side_position_right{margin-left:var(--input-space)}.TextField-Side_type_string{font-size:var(--input-font-size);white-space:nowrap}.TextField-Icon{color:var(--color-control-typo-placeholder)}
@@ -1,2 +1,2 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","type","value","onChange","id","name","rows","cols","minRows","maxRows","inputRef","maxLength","disabled","size","view","form","state","status","width","onBlur","onFocus","autoFocus","placeholder","leftSide","rightSide","autoComplete","withClearButton","incrementButtons","max","min","readOnly","required","step","tabIndex","ariaLabel","label","inputContainerRef","labelPosition","caption","iconSize","focused","onClick","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture"];import"./TextField.css";import{IconClose}from"@consta/icons/IconClose";import{IconEye}from"@consta/icons/IconEye";import{IconEyeClose}from"@consta/icons/IconEyeClose";import{IconSelect}from"@consta/icons/IconSelect";import{IconSelectOpen}from"@consta/icons/IconSelectOpen";import React,{forwardRef,useCallback,useEffect}from"react";import TextAreaAutoSize from"react-textarea-autosize";import{useFlag}from"../../hooks/useFlag/useFlag";import{useForkRef}from"../../hooks/useForkRef/useForkRef";import{useMutableRef}from"../../hooks/useMutableRef/useMutableRef";import{useSortSteps}from"../../hooks/useSortSteps/useSortSteps";import{cn}from"../../utils/bem";import{getByMap}from"../../utils/getByMap";import{isString}from"../../utils/type-guards";import{usePropsHandler}from"../EventInterceptor/usePropsHandler";import{FieldCaption}from"../FieldCaption/FieldCaption";import{FieldLabel}from"../FieldLabel/FieldLabel";import{getIncrementFlag,getTypeForRender,getValueByStep,sizeMap}from"./helpers";import{textFieldPropFormDefault,textFieldPropSizeDefault,textFieldPropViewDefault,textFieldPropWidthDefault}from"./types";export var COMPONENT_NAME="TextField";export var cnTextField=cn("TextField");export var TextFieldRender=function(a,b){var c=React.useRef(null),d=React.useRef(null),e=usePropsHandler(COMPONENT_NAME,a,c),f=e.className,g=e.type,h=void 0===g?"text":g,i=e.value,j=e.onChange,k=e.id,l=e.name,m=e.rows,n=e.cols,o=e.minRows,p=e.maxRows,q=e.inputRef,r=e.maxLength,s=e.disabled,t=e.size,u=void 0===t?textFieldPropSizeDefault:t,v=e.view,w=void 0===v?textFieldPropViewDefault:v,x=e.form,y=void 0===x?textFieldPropFormDefault:x,z=e.state,A=e.status,B=e.width,C=void 0===B?textFieldPropWidthDefault:B,D=e.onBlur,E=e.onFocus,F=e.autoFocus,G=void 0!==F&&F,H=e.placeholder,I=e.leftSide,J=e.rightSide,K=e.autoComplete,L=e.withClearButton,M=e.incrementButtons,N=e.max,O=e.min,P=e.readOnly,Q=e.required,R=e.step,S=void 0===R?1:R,T=e.tabIndex,U=e.ariaLabel,V=e.label,W=e.inputContainerRef,X=e.labelPosition,Y=void 0===X?"top":X,Z=e.caption,$=e.iconSize,_=e.focused,aa=e.onClick,ba=e.onKeyDown,ca=e.onKeyDownCapture,da=e.onKeyPress,ea=e.onKeyPressCapture,fa=e.onKeyUp,ga=e.onKeyUpCapture,ha=_objectWithoutProperties(e,_excluded),ia=useFlag(G),ja=_slicedToArray(ia,2),ka=ja[0],la=ja[1],ma=useFlag(!1),na=_slicedToArray(ma,2),oa=na[0],pa=na[1],qa=useMutableRef(i),ra=useMutableRef(aa),sa=useMutableRef(j),ta=useCallback(function(a){var b;a.stopPropagation(),pa.toggle(),null===(b=d.current)||void 0===b?void 0:b.focus()},[]),ua=I,va=J,wa=isString(I),xa=isString(J),ya=getByMap(sizeMap,u,$),za=useSortSteps({step:S,min:+O,max:+N}),Aa=useCallback(function(a){var b;s||(null===(b=sa.current)||void 0===b?void 0:b.call(sa,{e:a,id:k,name:l,value:a.target.value||null}))},[k,l,s]),Ba=function(a){la.on(),null===E||void 0===E?void 0:E(a)},Ca={className:cnTextField("Input"),value:i||"",onChange:Aa,maxLength:r,disabled:s,onBlur:function handleBlur(a){la.off(),null===D||void 0===D?void 0:D(a)},onFocus:Ba,autoFocus:G,placeholder:H,autoComplete:K,readOnly:P,tabIndex:T,name:l,onKeyDownCapture:ca,onKeyPress:da,onKeyPressCapture:ea,onKeyUp:fa,onKeyUpCapture:ga,id:k?k.toString():"","aria-label":U},Da=oa?IconEyeClose:IconEye,Ea={rows:m,cols:n,minRows:o||m,maxRows:p||m,ref:useForkRef([d,q])},Fa={type:getTypeForRender(h,oa),max:N,min:O,step:Array.isArray(za)?0:za,onKeyDown:function onKeyDown(a){var b=getIncrementFlag(a);null===ba||void 0===ba?void 0:ba(a),"number"!==h||"boolean"!=typeof b||s||(a.preventDefault(),null===j||void 0===j?void 0:j({e:a,value:getValueByStep(za,i,b,O,N)}))},ref:useForkRef([d,q])},Ga=useCallback(function(a){var b;null===(b=sa.current)||void 0===b?void 0:b.call(sa,{e:a,value:null})},[]),Ha=function(a){var b=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];null===j||void 0===j?void 0:j({e:a,value:getValueByStep(za,i,b,O,N)})},Ia={onClick:useCallback(function(a){var b,c;null===(b=d.current)||void 0===b?void 0:b.focus(),null===(c=ra.current)||void 0===c?void 0:c.call(ra,a)},[])};return useEffect(function(){if("password"===h&&d.current){var a;d.current.selectionStart=(null===(a=qa.current)||void 0===a?void 0:a.length)||0}},[oa]),React.createElement("div",Object.assign({className:cnTextField({labelPosition:Y,size:u,view:w,width:C},[f]),ref:useForkRef([b,c])},Ia,ha),V&&React.createElement(FieldLabel,{required:Q,className:cnTextField("Label",{labelPosition:Y}),size:u},V),React.createElement("div",{className:cnTextField("Body")},React.createElement("div",{ref:W,className:cnTextField("InputContainer",{view:w,form:y,status:A||z,disabled:s,type:h,focus:ka||_,withValue:!!i})},ua&&React.createElement("div",{className:cnTextField("Side",{position:"left",type:wa?"string":"icon"}),title:"string"==typeof I?I:void 0},wa?I:React.createElement(ua,{className:cnTextField("Icon"),size:ya})),"textarea"===h?React.createElement(TextAreaAutoSize,Object.assign({},Ca,Ea)):React.createElement("input",Object.assign({},Ca,Fa)),"number"===h&&(void 0===M||M)&&React.createElement("div",{className:cnTextField("Counter")},React.createElement("button",{onFocus:Ba,onClick:function(a){return Ha(a,!0)},type:"button",className:cnTextField("CounterButton")},React.createElement(IconSelectOpen,{size:"xs"})),React.createElement("button",{onFocus:Ba,onClick:function(a){return Ha(a,!1)},type:"button",className:cnTextField("CounterButton")},React.createElement(IconSelect,{size:"xs"}))),i&&L&&"number"!==h&&React.createElement("button",{type:"button",disabled:s,onClick:Ga,className:cnTextField("ClearButton")},React.createElement(IconClose,{size:"xs",className:cnTextField("ClearButtonIcon")})),"password"===h&&i&&React.createElement("button",{className:cnTextField("ClearButton"),type:"button",onClick:ta},React.createElement(Da,{className:cnTextField("Icon"),size:ya})),va&&"number"!==h&&"password"!==h&&React.createElement("div",{className:cnTextField("Side",{position:"right",type:xa?"string":"icon"}),title:"string"==typeof J?J:void 0},xa?J:React.createElement(va,{className:cnTextField("Icon"),size:ya}))),Z&&React.createElement(FieldCaption,{className:cnTextField("Caption"),status:A||z},Z)))};export var TextField=forwardRef(TextFieldRender);export*from"./types";
1
+ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","type","value","onChange","id","name","rows","cols","minRows","maxRows","inputRef","maxLength","disabled","size","view","form","state","status","width","onBlur","onFocus","autoFocus","placeholder","leftSide","rightSide","autoComplete","withClearButton","incrementButtons","max","min","readOnly","required","step","tabIndex","ariaLabel","label","labelIcon","inputContainerRef","labelPosition","caption","iconSize","focused","onClick","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture"];import"./TextField.css";import{IconClose}from"@consta/icons/IconClose";import{IconEye}from"@consta/icons/IconEye";import{IconEyeClose}from"@consta/icons/IconEyeClose";import{IconSelect}from"@consta/icons/IconSelect";import{IconSelectOpen}from"@consta/icons/IconSelectOpen";import React,{forwardRef,useCallback,useEffect}from"react";import TextAreaAutoSize from"react-textarea-autosize";import{useFlag}from"../../hooks/useFlag/useFlag";import{useForkRef}from"../../hooks/useForkRef/useForkRef";import{useMutableRef}from"../../hooks/useMutableRef/useMutableRef";import{useSortSteps}from"../../hooks/useSortSteps/useSortSteps";import{cn}from"../../utils/bem";import{getByMap}from"../../utils/getByMap";import{isString}from"../../utils/type-guards";import{usePropsHandler}from"../EventInterceptor/usePropsHandler";import{FieldCaption}from"../FieldCaption/FieldCaption";import{FieldLabel}from"../FieldLabel/FieldLabel";import{getIncrementFlag,getTypeForRender,getValueByStep,sizeMap}from"./helpers";import{textFieldPropFormDefault,textFieldPropSizeDefault,textFieldPropViewDefault,textFieldPropWidthDefault}from"./types";export var COMPONENT_NAME="TextField";export var cnTextField=cn("TextField");export var TextFieldRender=function(a,b){var c=React.useRef(null),d=React.useRef(null),e=usePropsHandler(COMPONENT_NAME,a,c),f=e.className,g=e.type,h=void 0===g?"text":g,i=e.value,j=e.onChange,k=e.id,l=e.name,m=e.rows,n=e.cols,o=e.minRows,p=e.maxRows,q=e.inputRef,r=e.maxLength,s=e.disabled,t=e.size,u=void 0===t?textFieldPropSizeDefault:t,v=e.view,w=void 0===v?textFieldPropViewDefault:v,x=e.form,y=void 0===x?textFieldPropFormDefault:x,z=e.state,A=e.status,B=e.width,C=void 0===B?textFieldPropWidthDefault:B,D=e.onBlur,E=e.onFocus,F=e.autoFocus,G=void 0!==F&&F,H=e.placeholder,I=e.leftSide,J=e.rightSide,K=e.autoComplete,L=e.withClearButton,M=e.incrementButtons,N=e.max,O=e.min,P=e.readOnly,Q=e.required,R=e.step,S=void 0===R?1:R,T=e.tabIndex,U=e.ariaLabel,V=e.label,W=e.labelIcon,X=e.inputContainerRef,Y=e.labelPosition,Z=void 0===Y?"top":Y,$=e.caption,_=e.iconSize,aa=e.focused,ba=e.onClick,ca=e.onKeyDown,da=e.onKeyDownCapture,ea=e.onKeyPress,fa=e.onKeyPressCapture,ga=e.onKeyUp,ha=e.onKeyUpCapture,ia=_objectWithoutProperties(e,_excluded),ja=useFlag(G),ka=_slicedToArray(ja,2),la=ka[0],ma=ka[1],na=useFlag(!1),oa=_slicedToArray(na,2),pa=oa[0],qa=oa[1],ra=useMutableRef(i),sa=useMutableRef(ba),ta=useMutableRef(j),ua=useCallback(function(a){var b;a.stopPropagation(),qa.toggle(),null===(b=d.current)||void 0===b?void 0:b.focus()},[]),va=I,wa=J,xa=isString(I),ya=isString(J),za=getByMap(sizeMap,u,_),Aa=useSortSteps({step:S,min:+O,max:+N}),Ba=useCallback(function(a){var b;s||(null===(b=ta.current)||void 0===b?void 0:b.call(ta,{e:a,id:k,name:l,value:a.target.value||null}))},[k,l,s]),Ca=function(a){ma.on(),null===E||void 0===E?void 0:E(a)},Da={className:cnTextField("Input"),value:i||"",onChange:Ba,maxLength:r,disabled:s,onBlur:function handleBlur(a){ma.off(),null===D||void 0===D?void 0:D(a)},onFocus:Ca,autoFocus:G,placeholder:H,autoComplete:K,readOnly:P,tabIndex:T,name:l,onKeyDownCapture:da,onKeyPress:ea,onKeyPressCapture:fa,onKeyUp:ga,onKeyUpCapture:ha,id:k?k.toString():"","aria-label":U},Ea=pa?IconEyeClose:IconEye,Fa={rows:m,cols:n,minRows:o||m,maxRows:p||m,ref:useForkRef([d,q])},Ga={type:getTypeForRender(h,pa),max:N,min:O,step:Array.isArray(Aa)?0:Aa,onKeyDown:function onKeyDown(a){var b=getIncrementFlag(a);null===ca||void 0===ca?void 0:ca(a),"number"!==h||"boolean"!=typeof b||s||(a.preventDefault(),null===j||void 0===j?void 0:j({e:a,value:getValueByStep(Aa,i,b,O,N)}))},ref:useForkRef([d,q])},Ha=useCallback(function(a){var b;null===(b=ta.current)||void 0===b?void 0:b.call(ta,{e:a,value:null})},[]),Ia=function(a){var b=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];null===j||void 0===j?void 0:j({e:a,value:getValueByStep(Aa,i,b,O,N)})},Ja={onClick:useCallback(function(a){var b,c;null===(b=d.current)||void 0===b?void 0:b.focus(),null===(c=sa.current)||void 0===c?void 0:c.call(sa,a)},[])};return useEffect(function(){if("password"===h&&d.current){var a;d.current.selectionStart=(null===(a=ra.current)||void 0===a?void 0:a.length)||0}},[pa]),React.createElement("div",Object.assign({className:cnTextField({labelPosition:Z,size:u,view:w,width:C},[f]),ref:useForkRef([b,c])},Ja,ia),V&&React.createElement(FieldLabel,{icon:W,required:Q,className:cnTextField("Label",{labelPosition:Z}),size:u},V),React.createElement("div",{className:cnTextField("Body")},React.createElement("div",{ref:X,className:cnTextField("InputContainer",{view:w,form:y,status:A||z,disabled:s,type:h,focus:la||aa,withValue:!!i})},va&&React.createElement("div",{className:cnTextField("Side",{position:"left",type:xa?"string":"icon"}),title:"string"==typeof I?I:void 0},xa?I:React.createElement(va,{className:cnTextField("Icon"),size:za})),"textarea"===h?React.createElement(TextAreaAutoSize,Object.assign({},Da,Fa)):React.createElement("input",Object.assign({},Da,Ga)),"number"===h&&(void 0===M||M)&&React.createElement("div",{className:cnTextField("Counter")},React.createElement("button",{onFocus:Ca,onClick:function(a){return Ia(a,!0)},type:"button",className:cnTextField("CounterButton")},React.createElement(IconSelectOpen,{size:"xs"})),React.createElement("button",{onFocus:Ca,onClick:function(a){return Ia(a,!1)},type:"button",className:cnTextField("CounterButton")},React.createElement(IconSelect,{size:"xs"}))),i&&L&&"number"!==h&&React.createElement("button",{type:"button",disabled:s,onClick:Ha,className:cnTextField("ClearButton")},React.createElement(IconClose,{size:"xs",className:cnTextField("ClearButtonIcon")})),"password"===h&&i&&React.createElement("button",{className:cnTextField("ClearButton"),type:"button",onClick:ua},React.createElement(Ea,{className:cnTextField("Icon"),size:za})),wa&&"number"!==h&&"password"!==h&&React.createElement("div",{className:cnTextField("Side",{position:"right",type:ya?"string":"icon"}),title:"string"==typeof J?J:void 0},ya?J:React.createElement(wa,{className:cnTextField("Icon"),size:za}))),$&&React.createElement(FieldCaption,{className:cnTextField("Caption"),status:A||z},$)))};export var TextField=forwardRef(TextFieldRender);export*from"./types";
2
2
  //# sourceMappingURL=TextField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextField.js","names":["IconClose","IconEye","IconEyeClose","IconSelect","IconSelectOpen","React","forwardRef","useCallback","useEffect","TextAreaAutoSize","useFlag","useForkRef","useMutableRef","useSortSteps","cn","getByMap","isString","usePropsHandler","FieldCaption","FieldLabel","getIncrementFlag","getTypeForRender","getValueByStep","sizeMap","textFieldPropFormDefault","textFieldPropSizeDefault","textFieldPropViewDefault","textFieldPropWidthDefault","COMPONENT_NAME","cnTextField","TextFieldRender","props","ref","textFieldRef","useRef","inputRef","className","type","value","onChange","id","name","rows","cols","minRows","maxRows","inputRefProp","maxLength","disabled","size","view","form","state","status","width","onBlur","onFocus","autoFocus","placeholder","leftSide","rightSide","autoComplete","withClearButton","incrementButtons","max","min","readOnly","required","step","tabIndex","ariaLabel","label","inputContainerRef","labelPosition","caption","iconSizeProp","iconSize","focused","onClick","onKeyDownProp","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","otherProps","focus","setFocus","passwordVisible","setPasswordVisuble","valueRef","onClickRef","onChangeRef","handleEyeClick","e","stopPropagation","toggle","current","LeftIcon","RightIcon","leftSideIsString","rightSideIsString","sortedSteps","handleChange","target","handleFocus","on","commonProps","handleBlur","off","toString","Eye","textareaProps","inputProps","Array","isArray","flag","preventDefault","handleClear","changeNumberValue","isIncrement","rootProps","selectionStart","length","withValue","position","TextField"],"sources":["../../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import './TextField.css';\n\nimport { IconClose } from '@consta/icons/IconClose';\nimport { IconEye } from '@consta/icons/IconEye';\nimport { IconEyeClose } from '@consta/icons/IconEyeClose';\nimport { IconSelect } from '@consta/icons/IconSelect';\nimport { IconSelectOpen } from '@consta/icons/IconSelectOpen';\nimport React, { forwardRef, useCallback, useEffect } from 'react';\nimport TextAreaAutoSize from 'react-textarea-autosize';\n\nimport { useFlag } from '../../hooks/useFlag/useFlag';\nimport { useForkRef } from '../../hooks/useForkRef/useForkRef';\nimport { useMutableRef } from '../../hooks/useMutableRef/useMutableRef';\nimport { useSortSteps } from '../../hooks/useSortSteps/useSortSteps';\nimport { cn } from '../../utils/bem';\nimport { getByMap } from '../../utils/getByMap';\nimport { isString } from '../../utils/type-guards';\nimport { usePropsHandler } from '../EventInterceptor/usePropsHandler';\nimport { FieldCaption } from '../FieldCaption/FieldCaption';\nimport { FieldLabel } from '../FieldLabel/FieldLabel';\nimport {\n getIncrementFlag,\n getTypeForRender,\n getValueByStep,\n sizeMap,\n} from './helpers';\nimport {\n TextFieldComponent,\n textFieldPropFormDefault,\n TextFieldProps,\n textFieldPropSizeDefault,\n textFieldPropViewDefault,\n textFieldPropWidthDefault,\n} from './types';\n\nexport const COMPONENT_NAME = 'TextField' as const;\nexport const cnTextField = cn(COMPONENT_NAME);\n\nexport const TextFieldRender = <TYPE extends string>(\n props: TextFieldProps<TYPE>,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const textFieldRef = React.useRef<HTMLDivElement>(null);\n const inputRef = React.useRef<HTMLInputElement | HTMLTextAreaElement>(null);\n\n const {\n className,\n type = 'text',\n value,\n onChange,\n id,\n name,\n rows,\n cols,\n minRows,\n maxRows,\n inputRef: inputRefProp,\n maxLength,\n disabled,\n size = textFieldPropSizeDefault,\n view = textFieldPropViewDefault,\n form = textFieldPropFormDefault,\n state,\n status,\n width = textFieldPropWidthDefault,\n onBlur,\n onFocus,\n autoFocus = false,\n placeholder,\n leftSide,\n rightSide,\n autoComplete,\n withClearButton,\n incrementButtons = true,\n max,\n min,\n readOnly,\n required,\n step = 1,\n tabIndex,\n ariaLabel,\n label,\n inputContainerRef,\n labelPosition = 'top',\n caption,\n iconSize: iconSizeProp,\n focused,\n onClick,\n // onkey props\n onKeyDown: onKeyDownProp,\n onKeyDownCapture,\n onKeyPress,\n onKeyPressCapture,\n onKeyUp,\n onKeyUpCapture,\n ...otherProps\n } = usePropsHandler(COMPONENT_NAME, props, textFieldRef);\n const [focus, setFocus] = useFlag(autoFocus);\n const [passwordVisible, setPasswordVisuble] = useFlag(false);\n\n const valueRef = useMutableRef(value);\n const onClickRef = useMutableRef(onClick);\n const onChangeRef = useMutableRef(onChange);\n\n const handleEyeClick = useCallback(\n (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n e.stopPropagation();\n setPasswordVisuble.toggle();\n inputRef.current?.focus();\n },\n [],\n );\n\n const textarea = type === 'textarea';\n const LeftIcon = leftSide;\n const RightIcon = rightSide;\n const leftSideIsString = isString(leftSide);\n const rightSideIsString = isString(rightSide);\n const iconSize = getByMap(sizeMap, size, iconSizeProp);\n\n const sortedSteps = useSortSteps({\n step,\n min: Number(min),\n max: Number(max),\n });\n\n const handleChange: React.ChangeEventHandler<\n HTMLInputElement | HTMLTextAreaElement\n > = useCallback(\n (e) => {\n !disabled &&\n onChangeRef.current?.({ e, id, name, value: e.target.value || null });\n },\n [id, name, disabled],\n );\n\n const handleBlur: React.FocusEventHandler<HTMLElement> = (e) => {\n setFocus.off();\n onBlur?.(e);\n };\n\n const handleFocus: React.FocusEventHandler<HTMLElement> = (e) => {\n setFocus.on();\n onFocus?.(e);\n };\n\n const commonProps = {\n 'className': cnTextField('Input'),\n 'value': value || '',\n 'onChange': handleChange,\n maxLength,\n disabled,\n 'onBlur': handleBlur,\n 'onFocus': handleFocus,\n autoFocus,\n placeholder,\n autoComplete,\n readOnly,\n tabIndex,\n name,\n onKeyDownCapture,\n onKeyPress,\n onKeyPressCapture,\n onKeyUp,\n onKeyUpCapture,\n 'id': id ? id.toString() : '',\n 'aria-label': ariaLabel,\n };\n\n const Eye = passwordVisible ? IconEyeClose : IconEye;\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n const flag = getIncrementFlag(e);\n onKeyDownProp?.(e);\n if (type === 'number' && typeof flag === 'boolean' && !disabled) {\n e.preventDefault();\n onChange?.({\n e,\n value: getValueByStep(sortedSteps, value, flag, min, max),\n });\n }\n };\n\n const textareaProps = {\n rows,\n cols,\n minRows: minRows || rows,\n maxRows: maxRows || rows,\n ref: useForkRef([inputRef, inputRefProp]) as (\n node: HTMLTextAreaElement,\n ) => void,\n };\n\n const inputProps = {\n type: getTypeForRender(type, passwordVisible),\n max,\n min,\n step: !Array.isArray(sortedSteps) ? sortedSteps : 0,\n onKeyDown,\n ref: useForkRef([\n inputRef,\n inputRefProp,\n ]) as React.RefCallback<HTMLInputElement>,\n };\n\n const handleClear = useCallback((e: React.MouseEvent<HTMLButtonElement>) => {\n onChangeRef.current?.({\n e,\n value: null,\n });\n }, []);\n\n const changeNumberValue = (\n e: React.MouseEvent<HTMLButtonElement>,\n isIncrement = true,\n ) => {\n onChange?.({\n e,\n value: getValueByStep(sortedSteps, value, isIncrement, min, max),\n });\n };\n\n const rootProps = {\n onClick: useCallback((e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n inputRef.current?.focus();\n onClickRef.current?.(e);\n }, []),\n };\n\n // при смене passwordVible, перемещаем курсор в конец строки\n useEffect(() => {\n if (type === 'password' && inputRef.current) {\n inputRef.current.selectionStart = valueRef.current?.length || 0;\n }\n }, [passwordVisible]);\n\n return (\n <div\n className={cnTextField({ labelPosition, size, view, width }, [className])}\n ref={useForkRef([ref, textFieldRef])}\n {...rootProps}\n {...otherProps}\n >\n {label && (\n <FieldLabel\n required={required}\n className={cnTextField('Label', { labelPosition })}\n size={size}\n >\n {label}\n </FieldLabel>\n )}\n <div className={cnTextField('Body')}>\n <div\n ref={inputContainerRef}\n className={cnTextField('InputContainer', {\n view,\n form,\n status: status || state,\n disabled,\n type,\n focus: focus || focused,\n withValue: !!value,\n })}\n >\n {LeftIcon && (\n <div\n className={cnTextField('Side', {\n position: 'left',\n type: leftSideIsString ? 'string' : 'icon',\n })}\n title={typeof leftSide === 'string' ? leftSide : undefined}\n >\n {leftSideIsString ? (\n leftSide\n ) : (\n <LeftIcon className={cnTextField('Icon')} size={iconSize} />\n )}\n </div>\n )}\n {textarea ? (\n <TextAreaAutoSize {...commonProps} {...textareaProps} />\n ) : (\n <input {...commonProps} {...inputProps} />\n )}\n\n {type === 'number' && incrementButtons && (\n <div className={cnTextField('Counter')}>\n <button\n onFocus={handleFocus}\n onClick={(e) => changeNumberValue(e, true)}\n type=\"button\"\n className={cnTextField('CounterButton')}\n >\n <IconSelectOpen size=\"xs\" />\n </button>\n <button\n onFocus={handleFocus}\n onClick={(e) => changeNumberValue(e, false)}\n type=\"button\"\n className={cnTextField('CounterButton')}\n >\n <IconSelect size=\"xs\" />\n </button>\n </div>\n )}\n\n {value && withClearButton && type !== 'number' && (\n <button\n type=\"button\"\n disabled={disabled}\n onClick={handleClear}\n className={cnTextField('ClearButton')}\n >\n <IconClose size=\"xs\" className={cnTextField('ClearButtonIcon')} />\n </button>\n )}\n\n {type === 'password' && value && (\n <button\n className={cnTextField('ClearButton')}\n type=\"button\"\n onClick={handleEyeClick}\n >\n <Eye className={cnTextField('Icon')} size={iconSize} />\n </button>\n )}\n\n {RightIcon && type !== 'number' && type !== 'password' && (\n <div\n className={cnTextField('Side', {\n position: 'right',\n type: rightSideIsString ? 'string' : 'icon',\n })}\n title={typeof rightSide === 'string' ? rightSide : undefined}\n >\n {rightSideIsString ? (\n rightSide\n ) : (\n <RightIcon className={cnTextField('Icon')} size={iconSize} />\n )}\n </div>\n )}\n </div>\n {caption && (\n <FieldCaption\n className={cnTextField('Caption')}\n status={status || state}\n >\n {caption}\n </FieldCaption>\n )}\n </div>\n </div>\n );\n};\n\nexport const TextField = forwardRef(TextFieldRender) as TextFieldComponent;\nexport * from './types';\n"],"m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conEye","IconEyeClose","IconSelect","IconSelectOpen","React","forwardRef","useCallback","useEffect","TextAreaAutoSize","useFlag","useForkRef","useMutableRef","useSortSteps","cn","getByMap","isString","usePropsHandler","FieldCaption","FieldLabel","getIncrementFlag","getTypeForRender","getValueByStep","sizeMap","textFieldPropFormDefault","textFieldPropSizeDefault","textFieldPropViewDefault","textFieldPropWidthDefault","COMPONENT_NAME","cnTextField","TextFieldRender","props","ref","textFieldRef","useRef","inputRef","className","type","value","onChange","id","name","rows","cols","minRows","maxRows","inputRefProp","maxLength","disabled","size","view","form","state","status","width","onBlur","onFocus","autoFocus","placeholder","leftSide","rightSide","autoComplete","withClearButton","incrementButtons","max","min","readOnly","required","step","tabIndex","ariaLabel","label","labelIcon","inputContainerRef","labelPosition","caption","iconSizeProp","iconSize","focused","onClick","onKeyDownProp","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","otherProps","focus","setFocus","passwordVisible","setPasswordVisuble","valueRef","onClickRef","onChangeRef","handleEyeClick","e","stopPropagation","toggle","current","LeftIcon","RightIcon","leftSideIsString","rightSideIsString","sortedSteps","handleChange","target","handleFocus","on","commonProps","handleBlur","off","toString","Eye","textareaProps","inputProps","Array","isArray","flag","preventDefault","handleClear","changeNumberValue","isIncrement","rootProps","selectionStart","length","withValue","position","TextField"],"sources":["../../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import './TextField.css';\n\nimport { IconClose } from '@consta/icons/IconClose';\nimport { IconEye } from '@consta/icons/IconEye';\nimport { IconEyeClose } from '@consta/icons/IconEyeClose';\nimport { IconSelect } from '@consta/icons/IconSelect';\nimport { IconSelectOpen } from '@consta/icons/IconSelectOpen';\nimport React, { forwardRef, useCallback, useEffect } from 'react';\nimport TextAreaAutoSize from 'react-textarea-autosize';\n\nimport { useFlag } from '../../hooks/useFlag/useFlag';\nimport { useForkRef } from '../../hooks/useForkRef/useForkRef';\nimport { useMutableRef } from '../../hooks/useMutableRef/useMutableRef';\nimport { useSortSteps } from '../../hooks/useSortSteps/useSortSteps';\nimport { cn } from '../../utils/bem';\nimport { getByMap } from '../../utils/getByMap';\nimport { isString } from '../../utils/type-guards';\nimport { usePropsHandler } from '../EventInterceptor/usePropsHandler';\nimport { FieldCaption } from '../FieldCaption/FieldCaption';\nimport { FieldLabel } from '../FieldLabel/FieldLabel';\nimport {\n getIncrementFlag,\n getTypeForRender,\n getValueByStep,\n sizeMap,\n} from './helpers';\nimport {\n TextFieldComponent,\n textFieldPropFormDefault,\n TextFieldProps,\n textFieldPropSizeDefault,\n textFieldPropViewDefault,\n textFieldPropWidthDefault,\n} from './types';\n\nexport const COMPONENT_NAME = 'TextField' as const;\nexport const cnTextField = cn(COMPONENT_NAME);\n\nexport const TextFieldRender = <TYPE extends string>(\n props: TextFieldProps<TYPE>,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const textFieldRef = React.useRef<HTMLDivElement>(null);\n const inputRef = React.useRef<HTMLInputElement | HTMLTextAreaElement>(null);\n\n const {\n className,\n type = 'text',\n value,\n onChange,\n id,\n name,\n rows,\n cols,\n minRows,\n maxRows,\n inputRef: inputRefProp,\n maxLength,\n disabled,\n size = textFieldPropSizeDefault,\n view = textFieldPropViewDefault,\n form = textFieldPropFormDefault,\n state,\n status,\n width = textFieldPropWidthDefault,\n onBlur,\n onFocus,\n autoFocus = false,\n placeholder,\n leftSide,\n rightSide,\n autoComplete,\n withClearButton,\n incrementButtons = true,\n max,\n min,\n readOnly,\n required,\n step = 1,\n tabIndex,\n ariaLabel,\n label,\n labelIcon,\n inputContainerRef,\n labelPosition = 'top',\n caption,\n iconSize: iconSizeProp,\n focused,\n onClick,\n // onkey props\n onKeyDown: onKeyDownProp,\n onKeyDownCapture,\n onKeyPress,\n onKeyPressCapture,\n onKeyUp,\n onKeyUpCapture,\n ...otherProps\n } = usePropsHandler(COMPONENT_NAME, props, textFieldRef);\n const [focus, setFocus] = useFlag(autoFocus);\n const [passwordVisible, setPasswordVisuble] = useFlag(false);\n\n const valueRef = useMutableRef(value);\n const onClickRef = useMutableRef(onClick);\n const onChangeRef = useMutableRef(onChange);\n\n const handleEyeClick = useCallback(\n (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n e.stopPropagation();\n setPasswordVisuble.toggle();\n inputRef.current?.focus();\n },\n [],\n );\n\n const textarea = type === 'textarea';\n const LeftIcon = leftSide;\n const RightIcon = rightSide;\n const leftSideIsString = isString(leftSide);\n const rightSideIsString = isString(rightSide);\n const iconSize = getByMap(sizeMap, size, iconSizeProp);\n\n const sortedSteps = useSortSteps({\n step,\n min: Number(min),\n max: Number(max),\n });\n\n const handleChange: React.ChangeEventHandler<\n HTMLInputElement | HTMLTextAreaElement\n > = useCallback(\n (e) => {\n !disabled &&\n onChangeRef.current?.({ e, id, name, value: e.target.value || null });\n },\n [id, name, disabled],\n );\n\n const handleBlur: React.FocusEventHandler<HTMLElement> = (e) => {\n setFocus.off();\n onBlur?.(e);\n };\n\n const handleFocus: React.FocusEventHandler<HTMLElement> = (e) => {\n setFocus.on();\n onFocus?.(e);\n };\n\n const commonProps = {\n 'className': cnTextField('Input'),\n 'value': value || '',\n 'onChange': handleChange,\n maxLength,\n disabled,\n 'onBlur': handleBlur,\n 'onFocus': handleFocus,\n autoFocus,\n placeholder,\n autoComplete,\n readOnly,\n tabIndex,\n name,\n onKeyDownCapture,\n onKeyPress,\n onKeyPressCapture,\n onKeyUp,\n onKeyUpCapture,\n 'id': id ? id.toString() : '',\n 'aria-label': ariaLabel,\n };\n\n const Eye = passwordVisible ? IconEyeClose : IconEye;\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n const flag = getIncrementFlag(e);\n onKeyDownProp?.(e);\n if (type === 'number' && typeof flag === 'boolean' && !disabled) {\n e.preventDefault();\n onChange?.({\n e,\n value: getValueByStep(sortedSteps, value, flag, min, max),\n });\n }\n };\n\n const textareaProps = {\n rows,\n cols,\n minRows: minRows || rows,\n maxRows: maxRows || rows,\n ref: useForkRef([inputRef, inputRefProp]) as (\n node: HTMLTextAreaElement,\n ) => void,\n };\n\n const inputProps = {\n type: getTypeForRender(type, passwordVisible),\n max,\n min,\n step: !Array.isArray(sortedSteps) ? sortedSteps : 0,\n onKeyDown,\n ref: useForkRef([\n inputRef,\n inputRefProp,\n ]) as React.RefCallback<HTMLInputElement>,\n };\n\n const handleClear = useCallback((e: React.MouseEvent<HTMLButtonElement>) => {\n onChangeRef.current?.({\n e,\n value: null,\n });\n }, []);\n\n const changeNumberValue = (\n e: React.MouseEvent<HTMLButtonElement>,\n isIncrement = true,\n ) => {\n onChange?.({\n e,\n value: getValueByStep(sortedSteps, value, isIncrement, min, max),\n });\n };\n\n const rootProps = {\n onClick: useCallback((e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n inputRef.current?.focus();\n onClickRef.current?.(e);\n }, []),\n };\n\n // при смене passwordVible, перемещаем курсор в конец строки\n useEffect(() => {\n if (type === 'password' && inputRef.current) {\n inputRef.current.selectionStart = valueRef.current?.length || 0;\n }\n }, [passwordVisible]);\n\n return (\n <div\n className={cnTextField({ labelPosition, size, view, width }, [className])}\n ref={useForkRef([ref, textFieldRef])}\n {...rootProps}\n {...otherProps}\n >\n {label && (\n <FieldLabel\n icon={labelIcon}\n required={required}\n className={cnTextField('Label', { labelPosition })}\n size={size}\n >\n {label}\n </FieldLabel>\n )}\n <div className={cnTextField('Body')}>\n <div\n ref={inputContainerRef}\n className={cnTextField('InputContainer', {\n view,\n form,\n status: status || state,\n disabled,\n type,\n focus: focus || focused,\n withValue: !!value,\n })}\n >\n {LeftIcon && (\n <div\n className={cnTextField('Side', {\n position: 'left',\n type: leftSideIsString ? 'string' : 'icon',\n })}\n title={typeof leftSide === 'string' ? leftSide : undefined}\n >\n {leftSideIsString ? (\n leftSide\n ) : (\n <LeftIcon className={cnTextField('Icon')} size={iconSize} />\n )}\n </div>\n )}\n {textarea ? (\n <TextAreaAutoSize {...commonProps} {...textareaProps} />\n ) : (\n <input {...commonProps} {...inputProps} />\n )}\n\n {type === 'number' && incrementButtons && (\n <div className={cnTextField('Counter')}>\n <button\n onFocus={handleFocus}\n onClick={(e) => changeNumberValue(e, true)}\n type=\"button\"\n className={cnTextField('CounterButton')}\n >\n <IconSelectOpen size=\"xs\" />\n </button>\n <button\n onFocus={handleFocus}\n onClick={(e) => changeNumberValue(e, false)}\n type=\"button\"\n className={cnTextField('CounterButton')}\n >\n <IconSelect size=\"xs\" />\n </button>\n </div>\n )}\n\n {value && withClearButton && type !== 'number' && (\n <button\n type=\"button\"\n disabled={disabled}\n onClick={handleClear}\n className={cnTextField('ClearButton')}\n >\n <IconClose size=\"xs\" className={cnTextField('ClearButtonIcon')} />\n </button>\n )}\n\n {type === 'password' && value && (\n <button\n className={cnTextField('ClearButton')}\n type=\"button\"\n onClick={handleEyeClick}\n >\n <Eye className={cnTextField('Icon')} size={iconSize} />\n </button>\n )}\n\n {RightIcon && type !== 'number' && type !== 'password' && (\n <div\n className={cnTextField('Side', {\n position: 'right',\n type: rightSideIsString ? 'string' : 'icon',\n })}\n title={typeof rightSide === 'string' ? rightSide : undefined}\n >\n {rightSideIsString ? (\n rightSide\n ) : (\n <RightIcon className={cnTextField('Icon')} size={iconSize} />\n )}\n </div>\n )}\n </div>\n {caption && (\n <FieldCaption\n className={cnTextField('Caption')}\n status={status || state}\n >\n {caption}\n </FieldCaption>\n )}\n </div>\n </div>\n );\n};\n\nexport const TextField = forwardRef(TextFieldRender) as TextFieldComponent;\nexport * from './types';\n"],"mappings":"8rBAAA,wBAEA,OAASA,SAAT,KAA0B,yBAA1B,CACA,OAASC,OAAT,KAAwB,uBAAxB,CACA,OAASC,YAAT,KAA6B,4BAA7B,CACA,OAASC,UAAT,KAA2B,0BAA3B,CACA,OAASC,cAAT,KAA+B,8BAA/B,CACA,MAAOC,MAAP,EAAgBC,UAAhB,CAA4BC,WAA5B,CAAyCC,SAAzC,KAA0D,OAA1D,CACA,MAAOC,iBAAP,KAA6B,yBAA7B,CAEA,OAASC,OAAT,mCACA,OA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W,CAAC,iBAAD,CAA3C,EANF,CAvDJ,CAiEY,UAAT,GAAAQ,CAAI,EAAmBC,CAAvB,EACC,8BACE,SAAS,CAAET,WAAW,CAAC,aAAD,CADxB,CAEE,IAAI,CAAC,QAFP,CAGE,OAAO,CAAEkE,EAHX,EAKE,oBAAC,EAAD,EAAK,SAAS,CAAElE,WAAW,CAAC,MAAD,CAA3B,CAAqC,IAAI,CAAEgD,EAA3C,EALF,CAlEJ,CA2EGwB,EAAS,EAAa,QAAT,GAAAhE,CAAb,EAA2C,UAAT,GAAAA,CAAlC,EACC,2BACE,SAAS,CAAER,WAAW,CAAC,MAAD,CAAS,CAC7BkG,QAAQ,CAAE,OADmB,CAE7B1F,IAAI,CAAEkE,EAAiB,CAAG,QAAH,CAAc,MAFR,CAAT,CADxB,CAKE,KAAK,CAAuB,QAArB,QAAO3C,EAAP,CAAgCA,CAAhC,OALT,EAOG2C,EAAiB,CAChB3C,CADgB,CAGhB,oBAAC,EAAD,EAAW,SAAS,CAAE/B,WAAW,CAAC,MAAD,CAAjC,CAA2C,IAAI,CAAEgD,EAAjD,EAVJ,CA5EJ,CADF,CA4FGF,CAAO,EACN,oBAAC,YAAD,EACE,SAAS,CAAE9C,WAAW,CAAC,SAAD,CADxB,CAEE,MAAM,CAAEwB,CAAM,EAAID,CAFpB,EAIGuB,CAJH,CA7FJ,CAhBF,CAuHH,CA/TM,CAiUP,MAAO,IAAMqD,UAAS,CAAG1H,UAAU,CAACwB,eAAD,CAA5B,CACP"}
@@ -81,6 +81,7 @@ export declare type TextFieldProps<TYPE extends string> = PropsWithHTMLAttribute
81
81
  iconSize?: IconPropSize;
82
82
  children?: never;
83
83
  label?: string;
84
+ labelIcon?: IconComponent;
84
85
  caption?: string;
85
86
  labelPosition?: 'top' | 'left';
86
87
  focused?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["textFieldPropSize","textFieldPropSizeDefault","textFieldPropView","textFieldPropViewDefault","textFieldPropForm","textFieldPropFormDefault","textFieldPropStatus","textFieldPropWidth","textFieldPropWidthDefault"],"sources":["../../../../../src/components/TextField/types.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { AutoCompete } from '../../utils/types/AutoComplete';\nimport { PropsWithHTMLAttributes } from '../../utils/types/PropsWithHTMLAttributes';\n\nexport type TextFieldPropValue = string | null;\nexport type TextFieldPropName = string;\nexport type TextFieldPropId = string | number;\n\nexport const textFieldPropSize = ['m', 'xs', 's', 'l'] as const;\nexport type TextFieldPropSize = typeof textFieldPropSize[number];\nexport const textFieldPropSizeDefault: TextFieldPropSize = textFieldPropSize[0];\n\nexport type TextFieldPropOnChange = (args: TextFieldOnChangeArguments) => void;\nexport type TextFieldOnChangeArguments = {\n e: React.ChangeEvent | React.MouseEvent | React.KeyboardEvent;\n id?: TextFieldPropId;\n name?: TextFieldPropName;\n value: TextFieldPropValue;\n};\n\nexport const textFieldPropView = ['default', 'clear'] as const;\nexport type TextFieldPropView = typeof textFieldPropView[number];\nexport const textFieldPropViewDefault: TextFieldPropView = textFieldPropView[0];\n\nexport const textFieldPropForm = [\n 'default',\n 'defaultClear',\n 'defaultBrick',\n 'brick',\n 'brickDefault',\n 'brickClear',\n 'brickRound',\n 'round',\n 'roundClear',\n 'roundBrick',\n 'clearRound',\n 'clearDefault',\n 'clearBrick',\n 'clearClear',\n] as const;\nexport type TextFieldPropForm = typeof textFieldPropForm[number];\nexport const textFieldPropFormDefault: TextFieldPropForm = textFieldPropForm[0];\n\nexport const textFieldPropStatus = ['alert', 'success', 'warning'] as const;\nexport type TextFieldPropStatus = typeof textFieldPropStatus[number];\n\nexport const textFieldPropWidth = ['default', 'full'] as const;\nexport type TextFieldPropWidth = typeof textFieldPropWidth[number];\nexport const textFieldPropWidthDefault: TextFieldPropWidth =\n textFieldPropWidth[0];\n\nexport type TextFieldPropsTextareaType<TYPE> = TYPE extends 'textarea'\n ?\n | {\n minRows?: never;\n maxRows?: never;\n rows?: number;\n }\n | {\n rows?: never;\n minRows?: number;\n maxRows?: number;\n }\n : {\n rows?: never;\n minRows?: never;\n maxRows?: never;\n };\n\nexport type TextFieldPropRightSide<TYPE extends string> = TYPE extends\n | 'number'\n | 'password'\n ? {\n rightSide?: never;\n }\n : {\n rightSide?: string | IconComponent;\n };\n\nexport type TextFieldProps<TYPE extends string> = PropsWithHTMLAttributes<\n {\n className?: string;\n value?: TextFieldPropValue;\n cols?: number;\n onChange?: TextFieldPropOnChange;\n id?: TextFieldPropId;\n name?: TextFieldPropName;\n type?: TYPE;\n disabled?: boolean;\n maxLength?: number;\n size?: TextFieldPropSize;\n view?: TextFieldPropView;\n form?: TextFieldPropForm;\n state?: TextFieldPropStatus;\n status?: TextFieldPropStatus;\n width?: TextFieldPropWidth;\n onFocus?: React.FocusEventHandler<HTMLElement>;\n onBlur?: React.FocusEventHandler<HTMLElement>;\n incrementButtons?: boolean;\n autoFocus?: boolean;\n placeholder?: string;\n leftSide?: string | IconComponent;\n rightSide?: string | IconComponent;\n withClearButton?: boolean;\n autoComplete?: AutoCompete;\n max?: number | string;\n min?: number | string;\n readOnly?: boolean;\n required?: boolean;\n step?: number | string | number[];\n tabIndex?: number;\n inputContainerRef?: React.Ref<HTMLDivElement>;\n inputRef?: React.Ref<HTMLTextAreaElement | HTMLInputElement>;\n ariaLabel?: string;\n iconSize?: IconPropSize;\n children?: never;\n label?: string;\n caption?: string;\n labelPosition?: 'top' | 'left';\n focused?: boolean;\n onKeyDownCapture?: React.KeyboardEventHandler;\n onKeyPress?: React.KeyboardEventHandler;\n onKeyPressCapture?: React.KeyboardEventHandler;\n onKeyUp?: React.KeyboardEventHandler;\n onKeyUpCapture?: React.KeyboardEventHandler;\n onKeyDown?: React.KeyboardEventHandler;\n },\n HTMLDivElement\n> &\n TextFieldPropsTextareaType<TYPE> &\n TextFieldPropRightSide<TYPE>;\n\nexport type TextFieldComponent = <TYPE extends string>(\n props: TextFieldProps<TYPE> & React.RefAttributes<HTMLElement>,\n) => React.ReactElement | null;\n"],"mappings":"AAUA,MAAO,IAAMA,kBAAiB,CAAG,CAAC,GAAD,CAAM,IAAN,CAAY,GAAZ,CAAiB,GAAjB,CAA1B,CAEP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAUP,MAAO,IAAME,kBAAiB,CAAG,CAAC,SAAD,CAAY,OAAZ,CAA1B,CAEP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAEP,MAAO,IAAME,kBAAiB,CAAG,CAC/B,SAD+B,CAE/B,cAF+B,CAG/B,cAH+B,CAI/B,OAJ+B,CAK/B,cAL+B,CAM/B,YAN+B,CAO/B,YAP+B,CAQ/B,OAR+B,CAS/B,YAT+B,CAU/B,YAV+B,CAW/B,YAX+B,CAY/B,cAZ+B,CAa/B,YAb+B,CAc/B,YAd+B,CAA1B,CAiBP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAEP,MAAO,IAAME,oBAAmB,CAAG,CAAC,OAAD,CAAU,SAAV,CAAqB,SAArB,CAA5B,CAGP,MAAO,IAAMC,mBAAkB,CAAG,CAAC,SAAD,CAAY,MAAZ,CAA3B,CAEP,MAAO,IAAMC,0BAA6C,CACxDD,kBAAkB,CAAC,CAAD,CADb"}
1
+ {"version":3,"file":"types.js","names":["textFieldPropSize","textFieldPropSizeDefault","textFieldPropView","textFieldPropViewDefault","textFieldPropForm","textFieldPropFormDefault","textFieldPropStatus","textFieldPropWidth","textFieldPropWidthDefault"],"sources":["../../../../../src/components/TextField/types.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { AutoCompete } from '../../utils/types/AutoComplete';\nimport { PropsWithHTMLAttributes } from '../../utils/types/PropsWithHTMLAttributes';\n\nexport type TextFieldPropValue = string | null;\nexport type TextFieldPropName = string;\nexport type TextFieldPropId = string | number;\n\nexport const textFieldPropSize = ['m', 'xs', 's', 'l'] as const;\nexport type TextFieldPropSize = typeof textFieldPropSize[number];\nexport const textFieldPropSizeDefault: TextFieldPropSize = textFieldPropSize[0];\n\nexport type TextFieldPropOnChange = (args: TextFieldOnChangeArguments) => void;\nexport type TextFieldOnChangeArguments = {\n e: React.ChangeEvent | React.MouseEvent | React.KeyboardEvent;\n id?: TextFieldPropId;\n name?: TextFieldPropName;\n value: TextFieldPropValue;\n};\n\nexport const textFieldPropView = ['default', 'clear'] as const;\nexport type TextFieldPropView = typeof textFieldPropView[number];\nexport const textFieldPropViewDefault: TextFieldPropView = textFieldPropView[0];\n\nexport const textFieldPropForm = [\n 'default',\n 'defaultClear',\n 'defaultBrick',\n 'brick',\n 'brickDefault',\n 'brickClear',\n 'brickRound',\n 'round',\n 'roundClear',\n 'roundBrick',\n 'clearRound',\n 'clearDefault',\n 'clearBrick',\n 'clearClear',\n] as const;\nexport type TextFieldPropForm = typeof textFieldPropForm[number];\nexport const textFieldPropFormDefault: TextFieldPropForm = textFieldPropForm[0];\n\nexport const textFieldPropStatus = ['alert', 'success', 'warning'] as const;\nexport type TextFieldPropStatus = typeof textFieldPropStatus[number];\n\nexport const textFieldPropWidth = ['default', 'full'] as const;\nexport type TextFieldPropWidth = typeof textFieldPropWidth[number];\nexport const textFieldPropWidthDefault: TextFieldPropWidth =\n textFieldPropWidth[0];\n\nexport type TextFieldPropsTextareaType<TYPE> = TYPE extends 'textarea'\n ?\n | {\n minRows?: never;\n maxRows?: never;\n rows?: number;\n }\n | {\n rows?: never;\n minRows?: number;\n maxRows?: number;\n }\n : {\n rows?: never;\n minRows?: never;\n maxRows?: never;\n };\n\nexport type TextFieldPropRightSide<TYPE extends string> = TYPE extends\n | 'number'\n | 'password'\n ? {\n rightSide?: never;\n }\n : {\n rightSide?: string | IconComponent;\n };\n\nexport type TextFieldProps<TYPE extends string> = PropsWithHTMLAttributes<\n {\n className?: string;\n value?: TextFieldPropValue;\n cols?: number;\n onChange?: TextFieldPropOnChange;\n id?: TextFieldPropId;\n name?: TextFieldPropName;\n type?: TYPE;\n disabled?: boolean;\n maxLength?: number;\n size?: TextFieldPropSize;\n view?: TextFieldPropView;\n form?: TextFieldPropForm;\n state?: TextFieldPropStatus;\n status?: TextFieldPropStatus;\n width?: TextFieldPropWidth;\n onFocus?: React.FocusEventHandler<HTMLElement>;\n onBlur?: React.FocusEventHandler<HTMLElement>;\n incrementButtons?: boolean;\n autoFocus?: boolean;\n placeholder?: string;\n leftSide?: string | IconComponent;\n rightSide?: string | IconComponent;\n withClearButton?: boolean;\n autoComplete?: AutoCompete;\n max?: number | string;\n min?: number | string;\n readOnly?: boolean;\n required?: boolean;\n step?: number | string | number[];\n tabIndex?: number;\n inputContainerRef?: React.Ref<HTMLDivElement>;\n inputRef?: React.Ref<HTMLTextAreaElement | HTMLInputElement>;\n ariaLabel?: string;\n iconSize?: IconPropSize;\n children?: never;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n labelPosition?: 'top' | 'left';\n focused?: boolean;\n onKeyDownCapture?: React.KeyboardEventHandler;\n onKeyPress?: React.KeyboardEventHandler;\n onKeyPressCapture?: React.KeyboardEventHandler;\n onKeyUp?: React.KeyboardEventHandler;\n onKeyUpCapture?: React.KeyboardEventHandler;\n onKeyDown?: React.KeyboardEventHandler;\n },\n HTMLDivElement\n> &\n TextFieldPropsTextareaType<TYPE> &\n TextFieldPropRightSide<TYPE>;\n\nexport type TextFieldComponent = <TYPE extends string>(\n props: TextFieldProps<TYPE> & React.RefAttributes<HTMLElement>,\n) => React.ReactElement | null;\n"],"mappings":"AAUA,MAAO,IAAMA,kBAAiB,CAAG,CAAC,GAAD,CAAM,IAAN,CAAY,GAAZ,CAAiB,GAAjB,CAA1B,CAEP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAUP,MAAO,IAAME,kBAAiB,CAAG,CAAC,SAAD,CAAY,OAAZ,CAA1B,CAEP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAEP,MAAO,IAAME,kBAAiB,CAAG,CAC/B,SAD+B,CAE/B,cAF+B,CAG/B,cAH+B,CAI/B,OAJ+B,CAK/B,cAL+B,CAM/B,YAN+B,CAO/B,YAP+B,CAQ/B,OAR+B,CAS/B,YAT+B,CAU/B,YAV+B,CAW/B,YAX+B,CAY/B,cAZ+B,CAa/B,YAb+B,CAc/B,YAd+B,CAA1B,CAiBP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAEP,MAAO,IAAME,oBAAmB,CAAG,CAAC,OAAD,CAAU,SAAV,CAAqB,SAArB,CAA5B,CAGP,MAAO,IAAMC,mBAAkB,CAAG,CAAC,SAAD,CAAY,MAAZ,CAA3B,CAEP,MAAO,IAAMC,0BAA6C,CACxDD,kBAAkB,CAAC,CAAD,CADb"}
@@ -1,2 +1,2 @@
1
- import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["as","className","size","avatarUrl","name","view","width","onlyAvatar","withArrow","iconRight","onIconRightClick","info","status"];import"./User.css";import{IconSelect}from"@consta/icons/IconSelect";import React from"react";import{cn}from"../../utils/bem";import{getByMap}from"../../utils/getByMap";import{forwardRefWithAs}from"../../utils/types/PropsWithAsAttributes";import{Avatar}from"../Avatar/Avatar";import{Button}from"../Button/Button";import{Text}from"../Text/Text";export var userPropSize=["m","s","l"];export var userPropSizeDefault=userPropSize[0];export var userPropView=["clear","ghost"];export var userPropViewDefault=userPropView[0];export var userPropWidth=["default","full"];export var userPropWidthDefault=userPropWidth[0];export var userPropStatus=["available","remote","out"];export var cnUser=cn("User");var infoSizeMap={s:"2xs",m:"2xs",l:"xs"},iconSizeMap={s:"xs",m:"xs",l:"s"},avatarSizeMap={s:"xs",m:"s",l:"m"},buttonSizeMap={s:"xs",m:"xs",l:"s"};export var User=forwardRefWithAs(function(a,b){var c=a.as,d=void 0===c?"div":c,e=a.className,f=a.size,g=void 0===f?userPropSizeDefault:f,h=a.avatarUrl,i=a.name,j=a.view,k=void 0===j?userPropViewDefault:j,l=a.width,m=void 0===l?userPropWidthDefault:l,n=a.onlyAvatar,o=a.withArrow,p=a.iconRight,q=a.onIconRightClick,r=a.info,s=a.status,t=_objectWithoutProperties(a,_excluded),u=n||!i&&!r,v=p;return React.createElement(d,Object.assign({},t,{className:cnUser({size:g,view:k,width:m,withArrow:o,minified:u},[e]),ref:b}),React.createElement("div",{className:cnUser("AvatarWrapper",{status:s})},React.createElement(Avatar,{size:getByMap(avatarSizeMap,g),url:h,name:i})),!u&&(i||r)&&React.createElement("div",{className:cnUser("Block")},i&&React.createElement(Text,{className:cnUser("Name"),size:g,view:"primary",lineHeight:"2xs"},i),r&&"s"!==g&&React.createElement(Text,{className:cnUser("Info"),size:getByMap(infoSizeMap,g),view:"secondary",lineHeight:"2xs"},r)),o&&React.createElement(IconSelect,{className:cnUser("Icon"),size:getByMap(iconSizeMap,g),view:"secondary"}),v&&!q&&React.createElement(v,{className:cnUser("Icon"),size:getByMap(iconSizeMap,g),view:"secondary"}),v&&q&&React.createElement(Button,{className:cnUser("IconRightButton"),onClick:q,iconRight:v,onlyIcon:!0,type:"button",view:"clear",size:getByMap(buttonSizeMap,g),form:"round"}))});
1
+ import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["as","className","size","avatarUrl","name","view","width","onlyAvatar","withArrow","iconRight","onIconRightClick","info","status"];import"./User.css";import{IconSelect}from"@consta/icons/IconSelect";import React from"react";import{cn}from"../../utils/bem";import{getByMap}from"../../utils/getByMap";import{forwardRefWithAs}from"../../utils/types/PropsWithAsAttributes";import{Avatar}from"../Avatar/Avatar";import{Button}from"../Button/Button";import{Text}from"../Text/Text";export var userPropSize=["m","s","l"];export var userPropSizeDefault=userPropSize[0];export var userPropView=["clear","ghost"];export var userPropViewDefault=userPropView[0];export var userPropWidth=["default","full"];export var userPropWidthDefault=userPropWidth[0];export var userPropStatus=["available","remote","out"];export var cnUser=cn("User");var infoSizeMap={s:"2xs",m:"2xs",l:"xs"},iconSizeMap={s:"xs",m:"xs",l:"s"},avatarSizeMap={s:"xs",m:"s",l:"m"},buttonSizeMap={s:"xs",m:"xs",l:"s"},nameSizeMap={s:"xs",m:"s",l:"m"};export var User=forwardRefWithAs(function(a,b){var c=a.as,d=void 0===c?"div":c,e=a.className,f=a.size,g=void 0===f?userPropSizeDefault:f,h=a.avatarUrl,i=a.name,j=a.view,k=void 0===j?userPropViewDefault:j,l=a.width,m=void 0===l?userPropWidthDefault:l,n=a.onlyAvatar,o=a.withArrow,p=a.iconRight,q=a.onIconRightClick,r=a.info,s=a.status,t=_objectWithoutProperties(a,_excluded),u=n||!i&&!r,v=p;return React.createElement(d,Object.assign({},t,{className:cnUser({size:g,view:k,width:m,withArrow:o,minified:u},[e]),ref:b}),React.createElement("div",{className:cnUser("AvatarWrapper",{status:s})},React.createElement(Avatar,{size:getByMap(avatarSizeMap,g),url:h,name:i})),!u&&(i||r)&&React.createElement("div",{className:cnUser("Block")},i&&React.createElement(Text,{className:cnUser("Name"),size:nameSizeMap[g],view:"primary",lineHeight:"2xs"},i),r&&"s"!==g&&React.createElement(Text,{className:cnUser("Info"),size:getByMap(infoSizeMap,g),view:"secondary",lineHeight:"2xs"},r)),o&&React.createElement(IconSelect,{className:cnUser("Icon"),size:getByMap(iconSizeMap,g),view:"secondary"}),v&&!q&&React.createElement(v,{className:cnUser("Icon"),size:getByMap(iconSizeMap,g),view:"secondary"}),v&&q&&React.createElement(Button,{className:cnUser("IconRightButton"),onClick:q,iconRight:v,onlyIcon:!0,type:"button",view:"clear",size:getByMap(buttonSizeMap,g),form:"round"}))});
2
2
  //# sourceMappingURL=User.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"User.js","names":["IconSelect","React","cn","getByMap","forwardRefWithAs","Avatar","Button","Text","userPropSize","userPropSizeDefault","userPropView","userPropViewDefault","userPropWidth","userPropWidthDefault","userPropStatus","cnUser","infoSizeMap","s","m","l","iconSizeMap","avatarSizeMap","buttonSizeMap","User","props","ref","as","className","size","avatarUrl","name","view","width","propOnlyAvatar","onlyAvatar","withArrow","iconRight","onIconRightClick","info","status","otherProps","IconRight","minified"],"sources":["../../../../../src/components/User/User.tsx"],"sourcesContent":["import './User.css';\n\nimport { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport { IconSelect } from '@consta/icons/IconSelect';\nimport React from 'react';\n\nimport { cn } from '../../utils/bem';\nimport { getByMap } from '../../utils/getByMap';\nimport { forwardRefWithAs } from '../../utils/types/PropsWithAsAttributes';\nimport { Avatar } from '../Avatar/Avatar';\nimport { Button, ButtonPropSize } from '../Button/Button';\nimport { Text, TextPropSize } from '../Text/Text';\n\nexport const userPropSize = ['m', 's', 'l'] as const;\nexport type UserPropSize = typeof userPropSize[number];\nexport const userPropSizeDefault: UserPropSize = userPropSize[0];\n\nexport const userPropView = ['clear', 'ghost'] as const;\nexport type UserPropView = typeof userPropView[number];\nexport const userPropViewDefault: UserPropView = userPropView[0];\n\nexport const userPropWidth = ['default', 'full'] as const;\nexport type UserPropWidth = typeof userPropWidth[number];\nexport const userPropWidthDefault: UserPropWidth = userPropWidth[0];\n\nexport const userPropStatus = ['available', 'remote', 'out'] as const;\nexport type UserPropStatus = typeof userPropStatus[number];\n\ntype Props = {\n avatarUrl?: string;\n name?: string;\n size?: UserPropSize;\n view?: UserPropView;\n width?: UserPropWidth;\n status?: UserPropStatus;\n onlyAvatar?: boolean;\n info?: string;\n children?: never;\n} & (\n | {\n withArrow?: boolean;\n iconRight?: never;\n onIconRightClick?: never;\n }\n | {\n withArrow?: never;\n iconRight?: IconComponent;\n onIconRightClick?: (e: React.SyntheticEvent) => void;\n }\n);\n\nexport const cnUser = cn('User');\n\nconst infoSizeMap: Record<UserPropSize, TextPropSize> = {\n s: '2xs',\n m: '2xs',\n l: 'xs',\n};\n\nconst iconSizeMap: Record<UserPropSize, IconPropSize> = {\n s: 'xs',\n m: 'xs',\n l: 's',\n};\n\nconst avatarSizeMap: Record<UserPropSize, IconPropSize> = {\n s: 'xs',\n m: 's',\n l: 'm',\n};\n\nconst buttonSizeMap: Record<UserPropSize, ButtonPropSize> = {\n s: 'xs',\n m: 'xs',\n l: 's',\n};\n\nexport const User = forwardRefWithAs<Props>((props, ref) => {\n const {\n as = 'div',\n className,\n size = userPropSizeDefault,\n avatarUrl,\n name,\n view = userPropViewDefault,\n width = userPropWidthDefault,\n onlyAvatar: propOnlyAvatar,\n withArrow,\n iconRight,\n onIconRightClick,\n info,\n status,\n ...otherProps\n } = props;\n const Tag = as as string;\n const onlyAvatar = propOnlyAvatar || (!name && !info);\n const IconRight = iconRight;\n\n return (\n <Tag\n {...otherProps}\n className={cnUser(\n { size, view, width, withArrow, minified: onlyAvatar },\n [className],\n )}\n ref={ref}\n >\n <div className={cnUser('AvatarWrapper', { status })}>\n <Avatar\n size={getByMap(avatarSizeMap, size)}\n url={avatarUrl}\n name={name}\n />\n </div>\n {!onlyAvatar && (name || info) && (\n <div className={cnUser('Block')}>\n {name && (\n <Text\n className={cnUser('Name')}\n size={size}\n view=\"primary\"\n lineHeight=\"2xs\"\n >\n {name}\n </Text>\n )}\n {info && size !== 's' && (\n <Text\n className={cnUser('Info')}\n size={getByMap(infoSizeMap, size)}\n view=\"secondary\"\n lineHeight=\"2xs\"\n >\n {info}\n </Text>\n )}\n </div>\n )}\n {withArrow && (\n <IconSelect\n className={cnUser('Icon')}\n size={getByMap(iconSizeMap, size)}\n view=\"secondary\"\n />\n )}\n {IconRight && !onIconRightClick && (\n <IconRight\n className={cnUser('Icon')}\n size={getByMap(iconSizeMap, size)}\n view=\"secondary\"\n />\n )}\n {IconRight && onIconRightClick && (\n <Button\n className={cnUser('IconRightButton')}\n onClick={onIconRightClick}\n iconRight={IconRight}\n onlyIcon\n type=\"button\"\n view=\"clear\"\n size={getByMap(buttonSizeMap, size)}\n form=\"round\"\n />\n )}\n </Tag>\n );\n});\n"],"mappings":"uOAAA,mBAGA,OAASA,UAAT,KAA2B,0BAA3B,CACA,MAAOC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conSelect","React","cn","getByMap","forwardRefWithAs","Avatar","Button","Text","userPropSize","userPropSizeDefault","userPropView","userPropViewDefault","userPropWidth","userPropWidthDefault","userPropStatus","cnUser","infoSizeMap","s","m","l","iconSizeMap","avatarSizeMap","buttonSizeMap","nameSizeMap","User","props","ref","as","className","size","avatarUrl","name","view","width","propOnlyAvatar","onlyAvatar","withArrow","iconRight","onIconRightClick","info","status","otherProps","IconRight","minified"],"sources":["../../../../../src/components/User/User.tsx"],"sourcesContent":["import './User.css';\n\nimport { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport { IconSelect } from '@consta/icons/IconSelect';\nimport React from 'react';\n\nimport { cn } from '../../utils/bem';\nimport { getByMap } from '../../utils/getByMap';\nimport { forwardRefWithAs } from '../../utils/types/PropsWithAsAttributes';\nimport { Avatar } from '../Avatar/Avatar';\nimport { Button, ButtonPropSize } from '../Button/Button';\nimport { Text, TextPropSize } from '../Text/Text';\n\nexport const userPropSize = ['m', 's', 'l'] as const;\nexport type UserPropSize = typeof userPropSize[number];\nexport const userPropSizeDefault: UserPropSize = userPropSize[0];\n\nexport const userPropView = ['clear', 'ghost'] as const;\nexport type UserPropView = typeof userPropView[number];\nexport const userPropViewDefault: UserPropView = userPropView[0];\n\nexport const userPropWidth = ['default', 'full'] as const;\nexport type UserPropWidth = typeof userPropWidth[number];\nexport const userPropWidthDefault: UserPropWidth = userPropWidth[0];\n\nexport const userPropStatus = ['available', 'remote', 'out'] as const;\nexport type UserPropStatus = typeof userPropStatus[number];\n\ntype Props = {\n avatarUrl?: string;\n name?: string;\n size?: UserPropSize;\n view?: UserPropView;\n width?: UserPropWidth;\n status?: UserPropStatus;\n onlyAvatar?: boolean;\n info?: string;\n children?: never;\n} & (\n | {\n withArrow?: boolean;\n iconRight?: never;\n onIconRightClick?: never;\n }\n | {\n withArrow?: never;\n iconRight?: IconComponent;\n onIconRightClick?: (e: React.SyntheticEvent) => void;\n }\n);\n\nexport const cnUser = cn('User');\n\nconst infoSizeMap: Record<UserPropSize, TextPropSize> = {\n s: '2xs',\n m: '2xs',\n l: 'xs',\n};\n\nconst iconSizeMap: Record<UserPropSize, IconPropSize> = {\n s: 'xs',\n m: 'xs',\n l: 's',\n};\n\nconst avatarSizeMap: Record<UserPropSize, IconPropSize> = {\n s: 'xs',\n m: 's',\n l: 'm',\n};\n\nconst buttonSizeMap: Record<UserPropSize, ButtonPropSize> = {\n s: 'xs',\n m: 'xs',\n l: 's',\n};\n\nconst nameSizeMap: Record<UserPropSize, TextPropSize> = {\n s: 'xs',\n m: 's',\n l: 'm',\n};\n\nexport const User = forwardRefWithAs<Props>((props, ref) => {\n const {\n as = 'div',\n className,\n size = userPropSizeDefault,\n avatarUrl,\n name,\n view = userPropViewDefault,\n width = userPropWidthDefault,\n onlyAvatar: propOnlyAvatar,\n withArrow,\n iconRight,\n onIconRightClick,\n info,\n status,\n ...otherProps\n } = props;\n const Tag = as as string;\n const onlyAvatar = propOnlyAvatar || (!name && !info);\n const IconRight = iconRight;\n\n return (\n <Tag\n {...otherProps}\n className={cnUser(\n { size, view, width, withArrow, minified: onlyAvatar },\n [className],\n )}\n ref={ref}\n >\n <div className={cnUser('AvatarWrapper', { status })}>\n <Avatar\n size={getByMap(avatarSizeMap, size)}\n url={avatarUrl}\n name={name}\n />\n </div>\n {!onlyAvatar && (name || info) && (\n <div className={cnUser('Block')}>\n {name && (\n <Text\n className={cnUser('Name')}\n size={nameSizeMap[size]}\n view=\"primary\"\n lineHeight=\"2xs\"\n >\n {name}\n </Text>\n )}\n {info && size !== 's' && (\n <Text\n className={cnUser('Info')}\n size={getByMap(infoSizeMap, size)}\n view=\"secondary\"\n lineHeight=\"2xs\"\n >\n {info}\n </Text>\n )}\n </div>\n )}\n {withArrow && (\n <IconSelect\n className={cnUser('Icon')}\n size={getByMap(iconSizeMap, size)}\n view=\"secondary\"\n />\n )}\n {IconRight && !onIconRightClick && (\n <IconRight\n className={cnUser('Icon')}\n size={getByMap(iconSizeMap, size)}\n view=\"secondary\"\n />\n )}\n {IconRight && onIconRightClick && (\n <Button\n className={cnUser('IconRightButton')}\n onClick={onIconRightClick}\n iconRight={IconRight}\n onlyIcon\n type=\"button\"\n view=\"clear\"\n size={getByMap(buttonSizeMap, size)}\n form=\"round\"\n />\n )}\n </Tag>\n );\n});\n"],"mappings":"uOAAA,mBAGA,OAASA,UAAT,KAA2B,0BAA3B,CACA,MAAOC,MAAP,KAAkB,OAAlB,CAEA,OAASC,EAAT,uBACA,OAASC,QAAT,4BACA,OAASC,gBAAT,+CACA,OAASC,MAAT,wBACA,OAASC,MAAT,wBACA,OAASC,IAAT,oBAEA,MAAO,IAAMC,aAAY,CAAG,CAAC,GAAD,CAAM,GAAN,CAAW,GAAX,CAArB,CAEP,MAAO,IAAMC,oBAAiC,CAAGD,YAAY,CAAC,CAAD,CAAtD,CAEP,MAAO,IAAME,aAAY,CAAG,CAAC,OAAD,CAAU,OAAV,CAArB,CAEP,MAAO,IAAMC,oBAAiC,CAAGD,YAAY,CAAC,CAAD,CAAtD,CAEP,MAAO,IAAME,cAAa,CAAG,CAAC,SAAD,CAAY,MAAZ,CAAtB,CAEP,MAAO,IAAMC,qBAAmC,CAAGD,aAAa,CAAC,CAAD,CAAzD,CAEP,MAAO,IAAME,eAAc,CAAG,CAAC,WAAD,CAAc,QAAd,CAAwB,KAAxB,CAAvB,CA0BP,MAAO,IAAMC,OAAM,CAAGb,EAAE,CAAC,MAAD,CAAjB,C,GAEDc,YAA+C,CAAG,CACtDC,CAAC,CAAE,KADmD,CAEtDC,CAAC,CAAE,KAFmD,CAGtDC,CAAC,CAAE,IAHmD,C,CAMlDC,WAA+C,CAAG,CACtDH,CAAC,CAAE,IADmD,CAEtDC,CAAC,CAAE,IAFmD,CAGtDC,CAAC,CAAE,GAHmD,C,CAMlDE,aAAiD,CAAG,CACxDJ,CAAC,CAAE,IADqD,CAExDC,CAAC,CAAE,GAFqD,CAGxDC,CAAC,CAAE,GAHqD,C,CAMpDG,aAAmD,CAAG,CAC1D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AHP,EA/CJ,CAqDGa,CAAS,EAAIJ,CAAb,EACC,oBAAC,MAAD,EACE,SAAS,CAAEvB,MAAM,CAAC,iBAAD,CADnB,CAEE,OAAO,CAAEuB,CAFX,CAGE,SAAS,CAAEI,CAHb,CAIE,QAAQ,GAJV,CAKE,IAAI,CAAC,QALP,CAME,IAAI,CAAC,OANP,CAOE,IAAI,CAAEvC,QAAQ,CAACmB,aAAD,CAAgBO,CAAhB,CAPhB,CAQE,IAAI,CAAC,OARP,EAtDJ,CAmEH,CAzFmC,CAA7B"}
@@ -1,3 +1,4 @@
1
+ import { IconComponent } from '@consta/icons/Icon';
1
2
  import React from 'react';
2
3
  import { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';
3
4
  import { PropForm, PropSize, PropStatus, PropView, RenderItemProps } from '../SelectComponents/types';
@@ -75,6 +76,7 @@ export declare type UserSelectProps<ITEM = DefaultItem, GROUP = DefaultGroup, MU
75
76
  getGroupLabel?: PropGetGroupLabel<GROUP>;
76
77
  getGroupKey?: PropGetGroupKey<GROUP>;
77
78
  label?: string;
79
+ labelIcon?: IconComponent;
78
80
  caption?: string;
79
81
  labelPosition?: 'top' | 'left';
80
82
  }, HTMLDivElement> & (ITEM extends {
@@ -107,7 +109,7 @@ export declare const isMultipleParams: <ITEM, GROUP>(params: UserSelectProps<ITE
107
109
  export declare const isNotMultipleParams: <ITEM, GROUP>(params: UserSelectProps<ITEM, GROUP, boolean>) => params is UserSelectProps<ITEM, GROUP, false>;
108
110
  export declare function withDefaultGetters<ITEM = DefaultItem, GROUP = DefaultGroup, MULTIPLE extends boolean = false>(props: UserSelectProps<ITEM, GROUP, MULTIPLE>): {
109
111
  disabled?: boolean | undefined;
110
- form?: "default" | "round" | "brick" | "clearRound" | "roundClear" | "clearDefault" | "defaultClear" | "defaultBrick" | "brickDefault" | "brickClear" | "clearBrick" | "clearClear" | undefined;
112
+ form?: "default" | "round" | "defaultClear" | "defaultBrick" | "brick" | "brickDefault" | "brickClear" | "brickRound" | "roundClear" | "roundBrick" | "clearRound" | "clearDefault" | "clearBrick" | "clearClear" | undefined;
111
113
  size?: "m" | "s" | "l" | undefined;
112
114
  view?: "default" | "clear" | undefined;
113
115
  dropdownForm?: "default" | "round" | "brick" | undefined;
@@ -147,9 +149,10 @@ export declare function withDefaultGetters<ITEM = DefaultItem, GROUP = DefaultGr
147
149
  getGroupLabel?: PropGetGroupLabel<GROUP> | undefined;
148
150
  getGroupKey?: PropGetGroupKey<GROUP> | undefined;
149
151
  label?: string | undefined;
152
+ labelIcon?: IconComponent | undefined;
150
153
  caption?: string | undefined;
151
154
  labelPosition?: "left" | "top" | undefined;
152
- } & Omit<React.HTMLAttributes<HTMLDivElement>, "css" | "placeholder" | "onFocus" | "onBlur" | "onChange" | "size" | "caption" | "form" | "label" | "view" | "status" | "name" | "disabled" | "value" | "multiple" | "required" | "inputRef" | "items" | "dropdownForm" | "ariaLabel" | "dropdownClassName" | "dropdownRef" | "isLoading" | "labelForEmptyItems" | "renderItem" | "renderValue" | "groups" | "getItemLabel" | "getItemKey" | "getItemGroupKey" | "getItemDisabled" | "getGroupLabel" | "getGroupKey" | "labelPosition" | "searchFunction" | "searchValue" | "labelForCreate" | "labelForNotFound" | "onCreate" | "getItemSubLabel" | "getItemAvatarUrl"> & React.RefAttributes<HTMLDivElement> & (ITEM extends {
155
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "css" | "placeholder" | "onFocus" | "onBlur" | "onChange" | "size" | "caption" | "form" | "label" | "view" | "status" | "name" | "disabled" | "value" | "multiple" | "required" | "inputRef" | "items" | "dropdownForm" | "ariaLabel" | "dropdownClassName" | "dropdownRef" | "isLoading" | "labelForEmptyItems" | "renderItem" | "renderValue" | "groups" | "getItemLabel" | "getItemKey" | "getItemGroupKey" | "getItemDisabled" | "getGroupLabel" | "getGroupKey" | "labelIcon" | "labelPosition" | "searchFunction" | "searchValue" | "labelForCreate" | "labelForNotFound" | "onCreate" | "getItemSubLabel" | "getItemAvatarUrl"> & React.RefAttributes<HTMLDivElement> & (ITEM extends {
153
156
  label: string;
154
157
  } ? {} : {
155
158
  getItemLabel: PropGetItemLabel<ITEM>;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["defaultGetItemKey","item","id","defaultGetItemLabel","label","defaultGetItemSubLabel","subLabel","defaultGetItemAvatarUrl","avatarUrl","defaultGetItemGroupKey","groupId","defaultGetItemDisabled","disabled","defaultGetGroupKey","group","defaultGetGroupLabel","isMultipleParams","params","multiple","isNotMultipleParams","withDefaultGetters","props","getItemLabel","getItemKey","getItemGroupKey","getItemDisabled","getGroupLabel","getGroupKey","getItemSubLabel","getItemAvatarUrl","searchCompare","searchValue","compare","toLocaleLowerCase","indexOf"],"sources":["../../../../../src/components/UserSelect/helpers.ts"],"sourcesContent":["import React from 'react';\n\nimport { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';\nimport {\n PropForm,\n PropSize,\n PropStatus,\n PropView,\n RenderItemProps,\n} from '../SelectComponents/types';\n\nexport type DefaultItem = {\n label: string;\n id: string | number;\n subLabel?: string;\n avatarUrl?: string;\n groupId?: string | number;\n disabled?: boolean;\n};\n\nexport type DefaultGroup = {\n label: string;\n id: string | number;\n};\n\ntype RenderValueProps<ITEM> = {\n item: ITEM;\n handleRemove?: (e: React.SyntheticEvent) => void;\n};\n\nexport type PropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type PropGetItemSubLabel<ITEM> = (item: ITEM) => string | undefined;\nexport type PropGetItemAvatarUrl<ITEM> = (item: ITEM) => string | undefined;\nexport type PropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type PropGetItemGroupKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\nexport type PropGetItemDisabled<ITEM> = (item: ITEM) => boolean | undefined;\nexport type PropGetGroupKey<GROUP> = (group: GROUP) => string | number;\nexport type PropGetGroupLabel<GROUP> = (group: GROUP) => string;\n\ntype PropSearchFunction<ITEM> = (item: ITEM, searchValue: string) => boolean;\ntype PropOnChange<ITEM, MULTIPLE extends boolean> = (props: {\n value: (MULTIPLE extends true ? ITEM[] : ITEM) | null;\n e: React.SyntheticEvent;\n}) => void;\ntype PropValue<ITEM, MULTIPLE extends boolean> =\n | (MULTIPLE extends true ? ITEM[] : ITEM)\n | null\n | undefined;\n\nexport type PropRenderItem<ITEM> = (\n props: RenderItemProps<ITEM>,\n) => React.ReactElement | null;\nexport type PropRenderValue<ITEM> = (\n props: RenderValueProps<ITEM>,\n) => React.ReactElement | null;\n\nexport type UserSelectProps<\n ITEM = DefaultItem,\n GROUP = DefaultGroup,\n MULTIPLE extends boolean = false,\n> = PropsWithHTMLAttributesAndRef<\n {\n disabled?: boolean;\n form?: PropForm;\n size?: Exclude<PropSize, 'xs'>;\n view?: PropView;\n dropdownForm?: 'default' | 'brick' | 'round';\n placeholder?: string;\n ariaLabel?: string;\n dropdownClassName?: string;\n status?: PropStatus;\n dropdownRef?: React.RefObject<HTMLDivElement>;\n name?: string;\n items: ITEM[];\n required?: boolean;\n isLoading?: boolean;\n renderItem?: PropRenderItem<ITEM>;\n renderValue?: PropRenderValue<ITEM>;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n onCreate?: (props: { e: React.SyntheticEvent; label: string }) => void;\n inputRef?: React.RefObject<HTMLInputElement>;\n labelForNotFound?: string;\n labelForCreate?: string;\n labelForEmptyItems?: string;\n searchFunction?: PropSearchFunction<ITEM>;\n searchValue?: string;\n multiple?: MULTIPLE;\n value?: PropValue<ITEM, MULTIPLE>;\n onChange: PropOnChange<ITEM, MULTIPLE>;\n groups?: GROUP[];\n getItemLabel?: PropGetItemLabel<ITEM>;\n getItemSubLabel?: PropGetItemSubLabel<ITEM>;\n getItemAvatarUrl?: PropGetItemAvatarUrl<ITEM>;\n getItemKey?: PropGetItemKey<ITEM>;\n getItemGroupKey?: PropGetItemGroupKey<ITEM>;\n getItemDisabled?: PropGetItemDisabled<ITEM>;\n getGroupLabel?: PropGetGroupLabel<GROUP>;\n getGroupKey?: PropGetGroupKey<GROUP>;\n label?: string;\n caption?: string;\n labelPosition?: 'top' | 'left';\n },\n HTMLDivElement\n> &\n (ITEM extends { label: DefaultItem['label'] }\n ? {}\n : { getItemLabel: PropGetItemLabel<ITEM> }) &\n (ITEM extends { id: DefaultItem['id'] }\n ? {}\n : { getItemKey: PropGetItemKey<ITEM> }) &\n (GROUP extends { label: DefaultGroup['label'] }\n ? {}\n : { getGroupLabel: PropGetGroupLabel<GROUP> }) &\n (GROUP extends { id: DefaultGroup['id'] }\n ? {}\n : { getGroupKey: PropGetGroupKey<GROUP> });\n\nexport type UserSelectComponent = <\n ITEM = DefaultItem,\n GROUP = DefaultGroup,\n MULTIPLE extends boolean = false,\n>(\n props: UserSelectProps<ITEM, GROUP, MULTIPLE>,\n) => React.ReactElement | null;\n\nexport const defaultGetItemKey: PropGetItemKey<DefaultItem> = (item) => item.id;\nexport const defaultGetItemLabel: PropGetItemLabel<DefaultItem> = (item) =>\n item.label;\nexport const defaultGetItemSubLabel: PropGetItemSubLabel<DefaultItem> = (\n item,\n) => item.subLabel;\nexport const defaultGetItemAvatarUrl: PropGetItemAvatarUrl<DefaultItem> = (\n item,\n) => item.avatarUrl;\nexport const defaultGetItemGroupKey: PropGetItemGroupKey<DefaultItem> = (\n item,\n) => item.groupId;\nexport const defaultGetItemDisabled: PropGetItemDisabled<DefaultItem> = (\n item,\n) => item.disabled;\n\nexport const defaultGetGroupKey: PropGetGroupKey<DefaultGroup> = (group) =>\n group.id;\nexport const defaultGetGroupLabel: PropGetGroupLabel<DefaultGroup> = (group) =>\n group.label;\n\nexport const isMultipleParams = <ITEM, GROUP>(\n params: UserSelectProps<ITEM, GROUP, boolean>,\n): params is UserSelectProps<ITEM, GROUP, true> => {\n return !!params.multiple;\n};\n\nexport const isNotMultipleParams = <ITEM, GROUP>(\n params: UserSelectProps<ITEM, GROUP, boolean>,\n): params is UserSelectProps<ITEM, GROUP, false> => {\n return !params.multiple;\n};\n\nexport function withDefaultGetters<\n ITEM = DefaultItem,\n GROUP = DefaultGroup,\n MULTIPLE extends boolean = false,\n>(props: UserSelectProps<ITEM, GROUP, MULTIPLE>) {\n return {\n ...props,\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemKey: props.getItemKey || defaultGetItemKey,\n getItemGroupKey: props.getItemGroupKey || defaultGetItemGroupKey,\n getItemDisabled: props.getItemDisabled || defaultGetItemDisabled,\n getGroupLabel: props.getGroupLabel || defaultGetGroupLabel,\n getGroupKey: props.getGroupKey || defaultGetGroupKey,\n getItemSubLabel: props.getItemSubLabel || defaultGetItemSubLabel,\n getItemAvatarUrl: props.getItemAvatarUrl || defaultGetItemAvatarUrl,\n };\n}\n\nexport const searchCompare = (\n searchValue: string,\n compare?: string,\n): boolean => {\n if (!compare) {\n return false;\n }\n\n return (\n compare.toLocaleLowerCase().indexOf(searchValue.toLocaleLowerCase()) !== -1\n );\n};\n"],"mappings":"qqBAgIA,MAAO,IAAMA,kBAA8C,CAAG,SAACC,CAAD,QAAUA,EAAI,CAACC,EAAf,CAAvD,CACP,MAAO,IAAMC,oBAAkD,CAAG,SAACF,CAAD,QAChEA,EAAI,CAACG,KAD2D,CAA3D,CAEP,MAAO,IAAMC,uBAAwD,CAAG,SACtEJ,CADsE,QAEnEA,EAAI,CAACK,QAF8D,CAAjE,CAGP,MAAO,IAAMC,wBAA0D,CAAG,SACxEN,CADwE,QAErEA,EAAI,CAACO,SAFgE,CAAnE,CAGP,MAAO,IAAMC,uBAAwD,CAAG,SACtER,CADsE,QAEnEA,EAAI,CAACS,OAF8D,CAAjE,CAGP,MAAO,IAAMC,uBAAwD,CAAG,SACtEV,CADsE,QAEnEA,EAAI,CAACW,QAF8D,CAAjE,CAIP,MAAO,IAAMC,mBAAiD,CAAG,SAACC,CAAD,QAC/DA,EAAK,CAACZ,EADyD,CAA1D,CAEP,MAAO,IAAMa,qBAAqD,CAAG,SAACD,CAAD,QACnEA,EAAK,CAACV,KAD6D,CAA9D,CAGP,MAAO,IAAMY,iBAAgB,CAAG,SAC9BC,CAD8B,CAEmB,CACjD,MAAO,CAAC,CAACA,CAAM,CAACC,QACjB,CAJM,CAMP,MAAO,IAAMC,oBAAmB,CAAG,SACjCF,CADiC,CAEiB,CAClD,MAAO,CAACA,CAAM,CAACC,QAChB,CAJM,CAMP,MAAO,SAASE,mBAAT,CAILC,CAJK,CAI0C,CAC/C,sCACKA,CADL,MAEEC,YAAY,CAAED,CAAK,CAACC,YAAN,EAAsBnB,mBAFtC,CAGEoB,UAAU,CAAEF,CAAK,CAACE,UAAN,EAAoBvB,iBAHlC,CAIEwB,eAAe,CAAEH,CAAK,CAACG,eAAN,EAAyBf,sBAJ5C,CAKEgB,eAAe,CAAEJ,CAAK,CAACI,eAAN,EAAyBd,sBAL5C,CAMEe,aAAa,CAAEL,CAAK,CAACK,aAAN,EAAuBX,oBANxC,CAOEY,WAAW,CAAEN,CAAK,CAACM,WAAN,EAAqBd,kBAPpC,CAQEe,eAAe,CAAEP,CAAK,CAACO,eAAN,EAAyBvB,sBAR5C,CASEwB,gBAAgB,CAAER,CAAK,CAACQ,gBAAN,EAA0BtB,uBAT9C,EAWD,CAED,MAAO,IAAMuB,cAAa,CAAG,SAC3BC,CAD2B,CAE3BC,CAF2B,CAGf,SACPA,CADO,EAM+D,CAAC,CAA1E,GAAAA,CAAO,CAACC,iBAAR,GAA4BC,OAA5B,CAAoCH,CAAW,CAACE,iBAAZ,EAApC,CAEH,CAXM"}
1
+ {"version":3,"file":"helpers.js","names":["defaultGetItemKey","item","id","defaultGetItemLabel","label","defaultGetItemSubLabel","subLabel","defaultGetItemAvatarUrl","avatarUrl","defaultGetItemGroupKey","groupId","defaultGetItemDisabled","disabled","defaultGetGroupKey","group","defaultGetGroupLabel","isMultipleParams","params","multiple","isNotMultipleParams","withDefaultGetters","props","getItemLabel","getItemKey","getItemGroupKey","getItemDisabled","getGroupLabel","getGroupKey","getItemSubLabel","getItemAvatarUrl","searchCompare","searchValue","compare","toLocaleLowerCase","indexOf"],"sources":["../../../../../src/components/UserSelect/helpers.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';\nimport {\n PropForm,\n PropSize,\n PropStatus,\n PropView,\n RenderItemProps,\n} from '../SelectComponents/types';\n\nexport type DefaultItem = {\n label: string;\n id: string | number;\n subLabel?: string;\n avatarUrl?: string;\n groupId?: string | number;\n disabled?: boolean;\n};\n\nexport type DefaultGroup = {\n label: string;\n id: string | number;\n};\n\ntype RenderValueProps<ITEM> = {\n item: ITEM;\n handleRemove?: (e: React.SyntheticEvent) => void;\n};\n\nexport type PropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type PropGetItemSubLabel<ITEM> = (item: ITEM) => string | undefined;\nexport type PropGetItemAvatarUrl<ITEM> = (item: ITEM) => string | undefined;\nexport type PropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type PropGetItemGroupKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\nexport type PropGetItemDisabled<ITEM> = (item: ITEM) => boolean | undefined;\nexport type PropGetGroupKey<GROUP> = (group: GROUP) => string | number;\nexport type PropGetGroupLabel<GROUP> = (group: GROUP) => string;\n\ntype PropSearchFunction<ITEM> = (item: ITEM, searchValue: string) => boolean;\ntype PropOnChange<ITEM, MULTIPLE extends boolean> = (props: {\n value: (MULTIPLE extends true ? ITEM[] : ITEM) | null;\n e: React.SyntheticEvent;\n}) => void;\ntype PropValue<ITEM, MULTIPLE extends boolean> =\n | (MULTIPLE extends true ? ITEM[] : ITEM)\n | null\n | undefined;\n\nexport type PropRenderItem<ITEM> = (\n props: RenderItemProps<ITEM>,\n) => React.ReactElement | null;\nexport type PropRenderValue<ITEM> = (\n props: RenderValueProps<ITEM>,\n) => React.ReactElement | null;\n\nexport type UserSelectProps<\n ITEM = DefaultItem,\n GROUP = DefaultGroup,\n MULTIPLE extends boolean = false,\n> = PropsWithHTMLAttributesAndRef<\n {\n disabled?: boolean;\n form?: PropForm;\n size?: Exclude<PropSize, 'xs'>;\n view?: PropView;\n dropdownForm?: 'default' | 'brick' | 'round';\n placeholder?: string;\n ariaLabel?: string;\n dropdownClassName?: string;\n status?: PropStatus;\n dropdownRef?: React.RefObject<HTMLDivElement>;\n name?: string;\n items: ITEM[];\n required?: boolean;\n isLoading?: boolean;\n renderItem?: PropRenderItem<ITEM>;\n renderValue?: PropRenderValue<ITEM>;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n onCreate?: (props: { e: React.SyntheticEvent; label: string }) => void;\n inputRef?: React.RefObject<HTMLInputElement>;\n labelForNotFound?: string;\n labelForCreate?: string;\n labelForEmptyItems?: string;\n searchFunction?: PropSearchFunction<ITEM>;\n searchValue?: string;\n multiple?: MULTIPLE;\n value?: PropValue<ITEM, MULTIPLE>;\n onChange: PropOnChange<ITEM, MULTIPLE>;\n groups?: GROUP[];\n getItemLabel?: PropGetItemLabel<ITEM>;\n getItemSubLabel?: PropGetItemSubLabel<ITEM>;\n getItemAvatarUrl?: PropGetItemAvatarUrl<ITEM>;\n getItemKey?: PropGetItemKey<ITEM>;\n getItemGroupKey?: PropGetItemGroupKey<ITEM>;\n getItemDisabled?: PropGetItemDisabled<ITEM>;\n getGroupLabel?: PropGetGroupLabel<GROUP>;\n getGroupKey?: PropGetGroupKey<GROUP>;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n labelPosition?: 'top' | 'left';\n },\n HTMLDivElement\n> &\n (ITEM extends { label: DefaultItem['label'] }\n ? {}\n : { getItemLabel: PropGetItemLabel<ITEM> }) &\n (ITEM extends { id: DefaultItem['id'] }\n ? {}\n : { getItemKey: PropGetItemKey<ITEM> }) &\n (GROUP extends { label: DefaultGroup['label'] }\n ? {}\n : { getGroupLabel: PropGetGroupLabel<GROUP> }) &\n (GROUP extends { id: DefaultGroup['id'] }\n ? {}\n : { getGroupKey: PropGetGroupKey<GROUP> });\n\nexport type UserSelectComponent = <\n ITEM = DefaultItem,\n GROUP = DefaultGroup,\n MULTIPLE extends boolean = false,\n>(\n props: UserSelectProps<ITEM, GROUP, MULTIPLE>,\n) => React.ReactElement | null;\n\nexport const defaultGetItemKey: PropGetItemKey<DefaultItem> = (item) => item.id;\nexport const defaultGetItemLabel: PropGetItemLabel<DefaultItem> = (item) =>\n item.label;\nexport const defaultGetItemSubLabel: PropGetItemSubLabel<DefaultItem> = (\n item,\n) => item.subLabel;\nexport const defaultGetItemAvatarUrl: PropGetItemAvatarUrl<DefaultItem> = (\n item,\n) => item.avatarUrl;\nexport const defaultGetItemGroupKey: PropGetItemGroupKey<DefaultItem> = (\n item,\n) => item.groupId;\nexport const defaultGetItemDisabled: PropGetItemDisabled<DefaultItem> = (\n item,\n) => item.disabled;\n\nexport const defaultGetGroupKey: PropGetGroupKey<DefaultGroup> = (group) =>\n group.id;\nexport const defaultGetGroupLabel: PropGetGroupLabel<DefaultGroup> = (group) =>\n group.label;\n\nexport const isMultipleParams = <ITEM, GROUP>(\n params: UserSelectProps<ITEM, GROUP, boolean>,\n): params is UserSelectProps<ITEM, GROUP, true> => {\n return !!params.multiple;\n};\n\nexport const isNotMultipleParams = <ITEM, GROUP>(\n params: UserSelectProps<ITEM, GROUP, boolean>,\n): params is UserSelectProps<ITEM, GROUP, false> => {\n return !params.multiple;\n};\n\nexport function withDefaultGetters<\n ITEM = DefaultItem,\n GROUP = DefaultGroup,\n MULTIPLE extends boolean = false,\n>(props: UserSelectProps<ITEM, GROUP, MULTIPLE>) {\n return {\n ...props,\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemKey: props.getItemKey || defaultGetItemKey,\n getItemGroupKey: props.getItemGroupKey || defaultGetItemGroupKey,\n getItemDisabled: props.getItemDisabled || defaultGetItemDisabled,\n getGroupLabel: props.getGroupLabel || defaultGetGroupLabel,\n getGroupKey: props.getGroupKey || defaultGetGroupKey,\n getItemSubLabel: props.getItemSubLabel || defaultGetItemSubLabel,\n getItemAvatarUrl: props.getItemAvatarUrl || defaultGetItemAvatarUrl,\n };\n}\n\nexport const searchCompare = (\n searchValue: string,\n compare?: string,\n): boolean => {\n if (!compare) {\n return false;\n }\n\n return (\n compare.toLocaleLowerCase().indexOf(searchValue.toLocaleLowerCase()) !== -1\n );\n};\n"],"mappings":"qqBAkIA,MAAO,IAAMA,kBAA8C,CAAG,SAACC,CAAD,QAAUA,EAAI,CAACC,EAAf,CAAvD,CACP,MAAO,IAAMC,oBAAkD,CAAG,SAACF,CAAD,QAChEA,EAAI,CAACG,KAD2D,CAA3D,CAEP,MAAO,IAAMC,uBAAwD,CAAG,SACtEJ,CADsE,QAEnEA,EAAI,CAACK,QAF8D,CAAjE,CAGP,MAAO,IAAMC,wBAA0D,CAAG,SACxEN,CADwE,QAErEA,EAAI,CAACO,SAFgE,CAAnE,CAGP,MAAO,IAAMC,uBAAwD,CAAG,SACtER,CADsE,QAEnEA,EAAI,CAACS,OAF8D,CAAjE,CAGP,MAAO,IAAMC,uBAAwD,CAAG,SACtEV,CADsE,QAEnEA,EAAI,CAACW,QAF8D,CAAjE,CAIP,MAAO,IAAMC,mBAAiD,CAAG,SAACC,CAAD,QAC/DA,EAAK,CAACZ,EADyD,CAA1D,CAEP,MAAO,IAAMa,qBAAqD,CAAG,SAACD,CAAD,QACnEA,EAAK,CAACV,KAD6D,CAA9D,CAGP,MAAO,IAAMY,iBAAgB,CAAG,SAC9BC,CAD8B,CAEmB,CACjD,MAAO,CAAC,CAACA,CAAM,CAACC,QACjB,CAJM,CAMP,MAAO,IAAMC,oBAAmB,CAAG,SACjCF,CADiC,CAEiB,CAClD,MAAO,CAACA,CAAM,CAACC,QAChB,CAJM,CAMP,MAAO,SAASE,mBAAT,CAILC,CAJK,CAI0C,CAC/C,sCACKA,CADL,MAEEC,YAAY,CAAED,CAAK,CAACC,YAAN,EAAsBnB,mBAFtC,CAGEoB,UAAU,CAAEF,CAAK,CAACE,UAAN,EAAoBvB,iBAHlC,CAIEwB,eAAe,CAAEH,CAAK,CAACG,eAAN,EAAyBf,sBAJ5C,CAKEgB,eAAe,CAAEJ,CAAK,CAACI,eAAN,EAAyBd,sBAL5C,CAMEe,aAAa,CAAEL,CAAK,CAACK,aAAN,EAAuBX,oBANxC,CAOEY,WAAW,CAAEN,CAAK,CAACM,WAAN,EAAqBd,kBAPpC,CAQEe,eAAe,CAAEP,CAAK,CAACO,eAAN,EAAyBvB,sBAR5C,CASEwB,gBAAgB,CAAER,CAAK,CAACQ,gBAAN,EAA0BtB,uBAT9C,EAWD,CAED,MAAO,IAAMuB,cAAa,CAAG,SAC3BC,CAD2B,CAE3BC,CAF2B,CAGf,SACPA,CADO,EAM+D,CAAC,CAA1E,GAAAA,CAAO,CAACC,iBAAR,GAA4BC,OAA5B,CAAoCH,CAAW,CAACE,iBAAZ,EAApC,CAEH,CAXM"}
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { CountedGroup, SelectAllItem } from '../../utils/getGroups';
2
3
  declare type IndexForHighlight = number | ((oldIndex: number) => number);
3
4
  declare type Group<ITEM, GROUP> = {
4
5
  items: ITEM[];
@@ -26,6 +27,7 @@ export declare type SelectProps<ITEM, GROUP, MULTIPLE extends boolean> = {
26
27
  dropdownRef: React.MutableRefObject<HTMLDivElement | null>;
27
28
  controlRef: React.MutableRefObject<HTMLDivElement | null>;
28
29
  disabled?: boolean;
30
+ selectAll?: boolean;
29
31
  getItemLabel: (item: ITEM) => string;
30
32
  getItemKey: (item: ITEM) => string | number;
31
33
  getItemDisabled?: (item: ITEM) => boolean | undefined;
@@ -44,7 +46,7 @@ export declare type SelectProps<ITEM, GROUP, MULTIPLE extends boolean> = {
44
46
  };
45
47
  export declare type OptionProps<ITEM> = {
46
48
  index: number;
47
- item: ITEM | OptionForCreate;
49
+ item: ITEM | OptionForCreate | SelectAllItem;
48
50
  };
49
51
  export declare type GetOptionPropsResult = {
50
52
  onClick: (e: React.SyntheticEvent) => void;
@@ -54,11 +56,12 @@ export declare type GetOptionPropsResult = {
54
56
  key: string | number;
55
57
  };
56
58
  export declare const isOptionForCreate: <ITEM, GROUP>(params: OptionForCreate | ITEM | Group<ITEM, GROUP>) => params is OptionForCreate;
59
+ export declare const isOptionForSelectAll: <ITEM, GROUP>(params: SelectAllItem | ITEM | Group<ITEM, GROUP>) => params is SelectAllItem;
57
60
  export declare function useSelect<ITEM, GROUP, MULTIPLE extends boolean>(params: SelectProps<ITEM, GROUP, MULTIPLE>): {
58
61
  isOpen: boolean;
59
62
  isFocused: boolean;
60
63
  highlightedIndex: number;
61
- visibleItems: (OptionForCreate | import("../../utils/getGroups").Group<ITEM, GROUP>)[];
64
+ visibleItems: (OptionForCreate | CountedGroup<ITEM, GROUP>)[];
62
65
  highlightIndex: (indexForHighlight: IndexForHighlight, scrollToHighlighted: boolean) => void;
63
66
  getOptionProps: ({ index, item, }: OptionProps<ITEM>) => GetOptionPropsResult;
64
67
  handleInputFocus: (e: React.FocusEvent<HTMLInputElement>) => void;
@@ -1,2 +1,2 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";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}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){function b(){return a.apply(this,arguments)}return b.toString=function(){return a.toString()},b}(function(a){throw a}),f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function(a){function b(){return a.apply(this,arguments)}return b.toString=function(){return a.toString()},b}(function(a){h=!0,f=a}),f:function f(){try{g||null==c["return"]||c["return"]()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}import React,{useEffect,useMemo,useRef,useState}from"react";import{getGroups}from"../../utils/getGroups";import{useClickOutside}from"../useClickOutside/useClickOutside";import{useDebounce}from"../useDebounce/useDebounce";import{useKeys}from"../useKeys/useKeys";import{usePrevious}from"../usePrevious/usePrevious";import{scrollToIndex,useHoistedState}from"./helpers";var isMultipleParams=function(a){return a.multiple},isNotMultipleParams=function(a){return!a.multiple},actions={setOpen:"setOpen",setSearch:"setSearch",highlightIndex:"highlightIndex"},initialState={searchValue:"",resolvedSearchValue:"",isOpen:!1,highlightedIndex:0,scrollToHighlighted:!1};export var isOptionForCreate=function(a){return a&&Object.prototype.hasOwnProperty.call(a,"__optionForCreate")};export function useSelect(a){var b=a.items,c=a.dropdownRef,d=a.controlRef,e=a.disabled,f=void 0!==e&&e,g=a.multiple,h=void 0!==g&&g,i=a.getItemLabel,j=a.getItemKey,k=a.searchFunction,l=a.getItemGroupKey,m=a.groups,n=a.getGroupKey,o=a.sortGroups,p=a.getItemDisabled,q=a.onFocus,r=a.onBlur,s=a.searchValue,t=a.withoutClearSearch,u=useRef(null),v=useState(!1),w=_slicedToArray(v,2),x=w[0],y=w[1],z=a.value&&(Array.isArray(a.value)?a.value:[a.value])||[],A=useHoistedState(initialState),B=_slicedToArray(A,2),C=B[0],D=C.searchValue,E=C.isOpen,F=C.highlightedIndex,G=C.resolvedSearchValue,H=C.scrollToHighlighted,I=B[1],J=function(a,b){return-1!==i(a).toLocaleLowerCase().indexOf(b.toLocaleLowerCase())},K=React.useMemo(function(){if(G&&""!==G){var c=b.filter(function(a){return k?k(a,G):J(a,G)}),d=!!b.find(function(a){return i(a).toString().toLowerCase()===G.toLocaleLowerCase()});return[c,a.onCreate&&!d?{label:D,__optionForCreate:!0}:void 0]}return[b,void 0]},[b,G]),L=_slicedToArray(K,2),M=L[0],N=L[1],O=useMemo(function(){var a=getGroups(M,null!==m&&void 0!==m&&m.length?l:void 0,m,n,o);return N?[N].concat(_toConsumableArray(a)):a},[M,m,l,n,o,N]),P=useMemo(function(){var b=!1;return 0<D.length&&(b=0===O.filter(function(a){return isOptionForCreate(a)||0<a.items.length||a.group}).length&&!a.onCreate),b},[O]),Q=0!==b.length,R=function(){var a=0;if(0<z.length){var b,c=_createForOfIteratorHelper(O);try{for(c.s();!(b=c.n()).done;){var f=b.value;if(isOptionForCreate(f)){a++;continue}var d,e=_createForOfIteratorHelper(f.items);try{for(e.s();!(d=e.n()).done;){var g=d.value;if(j(g)===j(z[0]))return a;a++}}catch(a){e.e(a)}finally{e.f()}}}catch(a){c.e(a)}finally{c.f()}}return 0},S=React.useCallback(function(a){I(function(b){return _objectSpread(_objectSpread({},b),{},{isOpen:a})},actions.setOpen)},[I]),T=useDebounce(function(a){I(function(b){return _objectSpread(_objectSpread({},b),{},{resolvedSearchValue:a})},actions.setSearch)},300),U=React.useCallback(function(a){I(function(b){return _objectSpread(_objectSpread({},b),{},{searchValue:a})},actions.setSearch),T(a)},[I,T]),V=usePrevious(E);React.useLayoutEffect(function(){if(null!==z&&!V&&E){var a=R();0<M.length&&scrollToIndex(a,c)}});var W=React.useCallback(function(a,b){I(function(c){return _objectSpread(_objectSpread({},c),{},{highlightedIndex:Math.min(Math.max(0,"function"==typeof a?a(c.highlightedIndex):a),N?M.length:M.length-1),scrollToHighlighted:b})},actions.highlightIndex)},[M,I,N]),X=function(b,c){if(b.stopPropagation(),isMultipleParams(a)){var d,e=null===(d=a.value)||void 0===d?void 0:d.filter(function(a){return j(a)!==j(c)});a.onChange({e:b,value:null!==e&&void 0!==e&&e.length?e:null})}},Y=function(b,c){if(!(p&&p(c))){if(isMultipleParams(a)){var d=z.some(function(a){return j(a)===j(c)})?z.filter(function(a){return j(a)!==j(c)}):[].concat(_toConsumableArray(z),[c]);a.onChange({value:d.length?d:null,e:b})}isNotMultipleParams(a)&&(a.onChange({value:c,e:b}),S(!1)),t||U("")}},Z=function(b,c){a.onCreate&&a.onCreate({e:b,label:c}),S(!1),t||U("")},$=function(b){if(t||U(""),isMultipleParams(a)){var c=null===z||void 0===z?void 0:z.filter(function(a){return null===p||void 0===p?void 0:p(a)});a.onChange({value:c&&0<c.length?c:null,e:b})}isNotMultipleParams(a)&&a.onChange({value:null,e:b})},_=function(a,b){b.preventDefault(),f||S(!0),W(function(a){return a-1},!0)},aa=function(a,b){b.preventDefault(),f||S(!0),W(function(a){return a+1},!0)},ba=useKeys({ArrowUp:_,ArrowDown:aa,PageUp:_,PageDown:aa,Home:_,End:aa,Enter:function Enter(a,b){if(E){(D||M[F])&&b.preventDefault();var c=function(a){var b,c=0,d=_createForOfIteratorHelper(O);try{for(d.s();!(b=d.n()).done;){var e=b.value;if(isOptionForCreate(e))return c++,e;if(e.items.length+c>a)return e.items[a-c];c+=e.items.length}}catch(a){d.e(a)}finally{d.f()}},d=c(F);if(isOptionForCreate(d))return void Z(b,d.label);d&&Y(b,d)}},Escape:function Escape(){S(!1)},Tab:function Tab(){S(!1)},Backspace:function Backspace(a,b){D||(h?X(b,z[z.length-1]):$(b))}});useClickOutside({isActive:E,ignoreClicksInsideRefs:[c,d],handler:function handler(){S(!1)}}),React.useEffect(function(){f&&S(!1)},[f]),React.useEffect(function(){var a=R();W(a,!0)},[W]),React.useEffect(function(){0<M.length&&H&&scrollToIndex(F,c)},[F]);return useEffect(function(){s&&U(s)},[s]),{isOpen:E,isFocused:x,highlightedIndex:F,visibleItems:O,highlightIndex:W,getOptionProps:function getOptionProps(a){var b=a.index,c=a.item;if(isOptionForCreate(c))return{onClick:function onClick(a){Z(a,c.label)},onMouseEnter:function onMouseEnter(){W(b,!1)},active:!1,hovered:b===F,key:"__optionForCreate"};var d=j(c);return{onClick:function onClick(a){Y(a,c)},onMouseEnter:function onMouseEnter(){W(b,!1)},active:!!z.find(function(a){return j(a)===d}),hovered:b===F,key:d}},handleInputFocus:function handleInputFocus(a){f||(!x&&y(!0),"function"==typeof q&&q(a))},handleInputBlur:function handleInputBlur(a){if(E){var b;return void(null===(b=u.current)||void 0===b?void 0:b.focus())}x&&y(!1),"function"==typeof r&&r(a)},handleToggleDropdown:function handleToggleDropdown(){if(E)S(!1),y(!1);else{var a;S(!0),y(!0),null===(a=u.current)||void 0===a?void 0:a.focus()}},handleInputClick:function handleInputClick(){if(f||S(!E),h){var a;null===(a=u.current)||void 0===a?void 0:a.focus(),t||U("")}},inputRef:u,getKeyProps:ba,handleInputChange:function handleInputChange(a){f||!h&&0<z.length||U(a.target.value)},searchValue:D,clearValue:$,getHandleRemoveValue:function getHandleRemoveValue(a){return function(b){return X(b,a)}},notFound:P,hasItems:Q}}
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";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}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){function b(){return a.apply(this,arguments)}return b.toString=function(){return a.toString()},b}(function(a){throw a}),f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function(a){function b(){return a.apply(this,arguments)}return b.toString=function(){return a.toString()},b}(function(a){h=!0,f=a}),f:function f(){try{g||null==c["return"]||c["return"]()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}import React,{useEffect,useMemo,useRef,useState}from"react";import{getCountedGroups,getGroups}from"../../utils/getGroups";import{useClickOutside}from"../useClickOutside/useClickOutside";import{useDebounce}from"../useDebounce/useDebounce";import{useKeys}from"../useKeys/useKeys";import{usePrevious}from"../usePrevious/usePrevious";import{scrollToIndex,useHoistedState}from"./helpers";var isMultipleParams=function(a){return a.multiple},isNotMultipleParams=function(a){return!a.multiple},actions={setOpen:"setOpen",setSearch:"setSearch",highlightIndex:"highlightIndex"},initialState={searchValue:"",resolvedSearchValue:"",isOpen:!1,highlightedIndex:0,scrollToHighlighted:!1};export var isOptionForCreate=function(a){return a&&Object.prototype.hasOwnProperty.call(a,"__optionForCreate")};export var isOptionForSelectAll=function(a){return a&&Object.prototype.hasOwnProperty.call(a,"__optionSelctAll")};export function useSelect(a){var b=a.items,c=a.dropdownRef,d=a.controlRef,e=a.disabled,f=void 0!==e&&e,g=a.multiple,h=void 0!==g&&g,i=a.getItemLabel,j=a.getItemKey,k=a.searchFunction,l=a.getItemGroupKey,m=a.groups,n=a.selectAll,o=void 0!==n&&n,p=a.getGroupKey,q=a.sortGroups,r=a.getItemDisabled,s=a.onFocus,t=a.onBlur,u=a.searchValue,v=a.withoutClearSearch,w=useRef(null),x=useState(!1),y=_slicedToArray(x,2),z=y[0],A=y[1],B=a.value&&(Array.isArray(a.value)?a.value:[a.value])||[],C=useHoistedState(initialState),D=_slicedToArray(C,2),E=D[0],F=E.searchValue,G=E.isOpen,H=E.highlightedIndex,I=E.resolvedSearchValue,J=E.scrollToHighlighted,K=D[1],L=function(a,b){return-1!==i(a).toLocaleLowerCase().indexOf(b.toLocaleLowerCase())},M=React.useMemo(function(){if(I&&""!==I){var c=b.filter(function(a){return k?k(a,I):L(a,I)}),d=!!b.find(function(a){return i(a).toString().toLowerCase()===I.toLocaleLowerCase()});return[c,a.onCreate&&!d?{label:F,__optionForCreate:!0}:void 0]}return[b,void 0]},[b,I]),N=_slicedToArray(M,2),O=N[0],P=N[1],Q=useMemo(function(){var b=getCountedGroups(getGroups(O,null!==m&&void 0!==m&&m.length?l:void 0,m,p,q),isMultipleParams(a)?a.value:[],o,j,r);return P?[P].concat(_toConsumableArray(b)):b},[B,o,O,m,l,r,p,q,P]),R=useMemo(function(){var b=!1;return 0<F.length&&(b=0===Q.filter(function(a){return isOptionForCreate(a)||0<a.items.length||a.group}).length&&!a.onCreate),b},[Q]),S=0!==b.length,T=function(){var a=0;if(0<B.length){var b,c=_createForOfIteratorHelper(Q);try{for(c.s();!(b=c.n()).done;){var f=b.value;if(isOptionForCreate(f)){a++;continue}var d,e=_createForOfIteratorHelper(f.items);try{for(e.s();!(d=e.n()).done;){var g=d.value;if(isOptionForSelectAll(g))return a;if(j(g)===j(B[0]))return a;a++}}catch(a){e.e(a)}finally{e.f()}}}catch(a){c.e(a)}finally{c.f()}}return 0},U=React.useCallback(function(a){K(function(b){return _objectSpread(_objectSpread({},b),{},{isOpen:a})},actions.setOpen)},[K]),V=useDebounce(function(a){K(function(b){return _objectSpread(_objectSpread({},b),{},{resolvedSearchValue:a})},actions.setSearch)},300),W=React.useCallback(function(a){K(function(b){return _objectSpread(_objectSpread({},b),{},{searchValue:a})},actions.setSearch),V(a)},[K,V]),X=usePrevious(G);React.useLayoutEffect(function(){if(null!==B&&!X&&G){var a=T();0<O.length&&scrollToIndex(a,c)}});var Y=React.useCallback(function(a,b){K(function(c){return _objectSpread(_objectSpread({},c),{},{highlightedIndex:Math.min(Math.max(0,"function"==typeof a?a(c.highlightedIndex):a),P?O.length:O.length-1),scrollToHighlighted:b})},actions.highlightIndex)},[O,K,P]),Z=function(b,c){if(b.stopPropagation(),isMultipleParams(a)){var d,e=null===(d=a.value)||void 0===d?void 0:d.filter(function(a){return j(a)!==j(c)});a.onChange({e:b,value:null!==e&&void 0!==e&&e.length?e:null})}},$=function(b,c){if(!(r&&r(c))){if(isMultipleParams(a)){var d=B.some(function(a){return j(a)===j(c)})?B.filter(function(a){return j(a)!==j(c)}):[].concat(_toConsumableArray(B),[c]);a.onChange({value:d.length?d:null,e:b})}isNotMultipleParams(a)&&(a.onChange({value:c,e:b}),U(!1)),v||W("")}},_=function(b){var c=b.e,d=b.items;if(isMultipleParams(a)){var e=r?d.filter(function(a){return!r(a)}):d,f=[],g=[];B.forEach(function(a){e.find(function(b){return j(a)===j(b)})?f.push(a):g.push(a)}),f.length===e.length?a.onChange({value:g,e:c}):a.onChange({e:c,value:[].concat(g,_toConsumableArray(e))})}},aa=function(b,c){a.onCreate&&a.onCreate({e:b,label:c}),U(!1),v||W("")},ba=function(b){if(v||W(""),isMultipleParams(a)){var c=null===B||void 0===B?void 0:B.filter(function(a){return null===r||void 0===r?void 0:r(a)});a.onChange({value:c&&0<c.length?c:null,e:b})}isNotMultipleParams(a)&&a.onChange({value:null,e:b})},ca=function(a,b){b.preventDefault(),f||U(!0),Y(function(a){return a-1},!0)},da=function(a,b){b.preventDefault(),f||U(!0),Y(function(a){return a+1},!0)},ea=useKeys({ArrowUp:ca,ArrowDown:da,PageUp:ca,PageDown:da,Home:ca,End:da,Enter:function Enter(a,b){if(G){(F||O[H])&&b.preventDefault();var c=function(a){var b,c=0,d=_createForOfIteratorHelper(Q);try{for(d.s();!(b=d.n()).done;){var e=b.value;if(isOptionForCreate(e))return c++,[void 0,e];if(e.items.length+c>a)return[e,e.items[a-c]];c+=e.items.length}}catch(a){d.e(a)}finally{d.f()}return[void 0,void 0]},d=c(H),e=_slicedToArray(d,2),f=e[0],g=e[1];if(isOptionForCreate(g))return void aa(b,g.label);if(isOptionForSelectAll(g)){var h;return void _({e:b,items:null!==(h=null===f||void 0===f?void 0:f.items.filter(function(a){return!isOptionForSelectAll(a)}))&&void 0!==h?h:[]})}g&&$(b,g)}},Escape:function Escape(){U(!1)},Tab:function Tab(){U(!1)},Backspace:function Backspace(a,b){F||(h?Z(b,B[B.length-1]):ba(b))}});useClickOutside({isActive:G,ignoreClicksInsideRefs:[c,d],handler:function handler(){U(!1)}}),React.useEffect(function(){f&&U(!1)},[f]),React.useEffect(function(){var a=T();Y(a,!0)},[Y]),React.useEffect(function(){0<O.length&&J&&scrollToIndex(H,c)},[H]);return useEffect(function(){u&&W(u)},[u]),{isOpen:G,isFocused:z,highlightedIndex:H,visibleItems:Q,highlightIndex:Y,getOptionProps:function getOptionProps(a){var b=a.index,c=a.item;if(isOptionForCreate(c))return{onClick:function onClick(a){aa(a,c.label)},onMouseEnter:function onMouseEnter(){Y(b,!1)},active:!1,hovered:b===H,key:"__optionForCreate"};if(isOptionForSelectAll(c)){var f=function(){var a,b=_createForOfIteratorHelper(Q);try{for(b.s();!(a=b.n()).done;){var e=a.value;if(isOptionForCreate(e))break;if(e.key===c.groupKey){var d;return null!==(d=null===e||void 0===e?void 0:e.items.filter(function(a){return!isOptionForSelectAll(a)}))&&void 0!==d?d:[]}}}catch(a){b.e(a)}finally{b.f()}return[]};return{onClick:function onClick(a){_({e:a,items:f()})},onMouseEnter:function onMouseEnter(){Y(b,!1)},active:!1,hovered:b===H,key:"__optionForSelectAll"}}var d=j(c);return{onClick:function onClick(a){$(a,c)},onMouseEnter:function onMouseEnter(){Y(b,!1)},active:!!B.find(function(a){return j(a)===d}),hovered:b===H,key:d}},handleInputFocus:function handleInputFocus(a){f||(!z&&A(!0),"function"==typeof s&&s(a))},handleInputBlur:function handleInputBlur(a){if(G){var b;return void(null===(b=w.current)||void 0===b?void 0:b.focus())}z&&A(!1),"function"==typeof t&&t(a)},handleToggleDropdown:function handleToggleDropdown(){if(G)U(!1),A(!1);else{var a;U(!0),A(!0),null===(a=w.current)||void 0===a?void 0:a.focus()}},handleInputClick:function handleInputClick(){if(f||U(!G),h){var a;null===(a=w.current)||void 0===a?void 0:a.focus(),v||W("")}},inputRef:w,getKeyProps:ea,handleInputChange:function handleInputChange(a){f||!h&&0<B.length||W(a.target.value)},searchValue:F,clearValue:ba,getHandleRemoveValue:function getHandleRemoveValue(a){return function(b){return Z(b,a)}},notFound:R,hasItems:S}}
2
2
  //# sourceMappingURL=useSelect.js.map