@consta/uikit 5.4.0 → 5.4.1

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 (26) hide show
  1. package/__internal__/src/components/AutoComplete/helpers.d.ts +1 -1
  2. package/__internal__/src/components/AutoComplete/types.d.ts +1 -1
  3. package/__internal__/src/components/AutoComplete/types.js.map +1 -1
  4. package/__internal__/src/components/Combobox/helpers.d.ts +2 -2
  5. package/__internal__/src/components/Combobox/helpers.js.map +1 -1
  6. package/__internal__/src/components/DatePicker/DatePickerMixRangeField/DatePickerMixRangeField.css +1 -1
  7. package/__internal__/src/components/Picture/Picture.js +1 -1
  8. package/__internal__/src/components/Picture/Picture.js.map +1 -1
  9. package/__internal__/src/components/Select/helpers.d.ts +2 -2
  10. package/__internal__/src/components/Select/helpers.js.map +1 -1
  11. package/__internal__/src/components/SelectComponents/Select.css +1 -1
  12. package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.d.ts +1 -1
  13. package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.js +1 -1
  14. package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.js.map +1 -1
  15. package/__internal__/src/components/SelectComponents/useSelect/useSelect.d.ts +1 -1
  16. package/__internal__/src/components/SelectComponents/useSelect/useSelect.js.map +1 -1
  17. package/__internal__/src/components/TextField/TextField.css +1 -1
  18. package/__internal__/src/components/UserSelect/helpers.d.ts +2 -2
  19. package/__internal__/src/components/UserSelect/helpers.js.map +1 -1
  20. package/__internal__/src/hooks/useVirtualScroll/hellpers.d.ts +16 -3
  21. package/__internal__/src/hooks/useVirtualScroll/hellpers.js +1 -1
  22. package/__internal__/src/hooks/useVirtualScroll/hellpers.js.map +1 -1
  23. package/__internal__/src/hooks/useVirtualScroll/useVirtualScroll.d.ts +1 -13
  24. package/__internal__/src/hooks/useVirtualScroll/useVirtualScroll.js +1 -1
  25. package/__internal__/src/hooks/useVirtualScroll/useVirtualScroll.js.map +1 -1
  26. package/package.json +1 -1
@@ -21,7 +21,7 @@ export declare function withDefaultGetters<TYPE extends string, ITEM = AutoCompl
21
21
  getGroupKey?: AutoCompletePropGetGroupId<GROUP> | undefined;
22
22
  onChange?: import("./types").AutoCompletePropOnChange | undefined;
23
23
  virtualScroll?: boolean | undefined;
24
- onScrollToBottom?: (() => void) | undefined;
24
+ onScrollToBottom?: ((lenght: number) => void) | undefined;
25
25
  onDropdownOpen?: ((isOpen: boolean) => void) | undefined;
26
26
  dropdownOpen?: boolean | undefined;
27
27
  ignoreOutsideClicksRefs?: readonly import("react").RefObject<HTMLElement>[] | undefined;
@@ -38,7 +38,7 @@ export declare type AutoCompleteProps<TYPE extends string, ITEM = AutoCompleteIt
38
38
  getGroupKey?: AutoCompletePropGetGroupId<GROUP>;
39
39
  onChange?: AutoCompletePropOnChange;
40
40
  virtualScroll?: boolean;
41
- onScrollToBottom?: () => void;
41
+ onScrollToBottom?: (lenght: number) => void;
42
42
  onDropdownOpen?: (isOpen: boolean) => void;
43
43
  dropdownOpen?: boolean;
44
44
  ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/components/AutoComplete/types.ts"],"sourcesContent":["import React from 'react';\n\nimport { PropRenderItem } from '##/components/Select';\nimport { TextFieldProps } from '##/components/TextField';\n\nexport type AutoCompleteItemDefault = {\n id: string | number;\n label: string;\n groupId?: number;\n};\n\nexport type AutoCompleteGroupDefault = {\n label: string;\n id: number | string;\n};\n\nexport type AutoCompletePropDropdownForm = 'default' | 'brick' | 'round';\n\nexport type AutoCompletePropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type AutoCompletePropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type AutoCompletePropGetItemGroupId<ITEM> = (\n item: ITEM,\n) => number | undefined;\nexport type AutoCompletePropGetGroupLabel<GROUP> = (group: GROUP) => string;\nexport type AutoCompletePropGetGroupId<GROUP> = (\n group: GROUP,\n) => number | string;\n\nexport type AutoCompletePropSearchFunction<ITEM> = (\n item: ITEM,\n searchValue: string,\n) => boolean;\n\nexport type AutoCompletePropOnChange = (\n value: string | null,\n props: {\n e: React.ChangeEvent | React.MouseEvent | React.KeyboardEvent;\n id?: string;\n name?: string;\n },\n) => void;\n\nexport type AutoCompleteProps<\n TYPE extends string,\n ITEM = AutoCompleteItemDefault,\n GROUP = AutoCompleteGroupDefault,\n> = {\n items: ITEM[];\n groups?: GROUP[];\n renderItem?: PropRenderItem<ITEM>;\n dropdownClassName?: string;\n dropdownForm?: AutoCompletePropDropdownForm;\n isLoading?: boolean;\n searchFunction?: AutoCompletePropSearchFunction<ITEM>;\n dropdownRef?: React.RefObject<HTMLDivElement>;\n getItemLabel?: AutoCompletePropGetItemLabel<ITEM>;\n getItemKey?: AutoCompletePropGetItemKey<ITEM>;\n getItemGroupKey?: AutoCompletePropGetItemGroupId<ITEM>;\n getGroupLabel?: AutoCompletePropGetGroupLabel<GROUP>;\n getGroupKey?: AutoCompletePropGetGroupId<GROUP>;\n onChange?: AutoCompletePropOnChange;\n virtualScroll?: boolean;\n onScrollToBottom?: () => void;\n onDropdownOpen?: (isOpen: boolean) => void;\n dropdownOpen?: boolean;\n ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n} & Omit<\n TextFieldProps<TYPE>,\n 'max' | 'min' | 'step' | 'incrementButtons' | 'onChange' | 'width'\n> &\n (ITEM extends { label: AutoCompleteItemDefault['label'] }\n ? {}\n : {\n getItemLabel: AutoCompletePropGetItemLabel<ITEM>;\n }) &\n (ITEM extends { id: AutoCompleteItemDefault['id'] }\n ? {}\n : { getItemKey: AutoCompletePropGetItemKey<ITEM> }) &\n (GROUP extends { label: AutoCompleteGroupDefault['label'] }\n ? {}\n : { getGroupLabel: AutoCompletePropGetGroupLabel<GROUP> }) &\n (GROUP extends { id: AutoCompleteGroupDefault['id'] }\n ? {}\n : { getGroupKey: AutoCompletePropGetGroupId<GROUP> });\n\nexport type AutoCompleteComponent = <\n TYPE extends string,\n ITEM = AutoCompleteItemDefault,\n GROUP = AutoCompleteGroupDefault,\n>(\n props: AutoCompleteProps<TYPE, ITEM, GROUP>,\n) => React.ReactElement | null;\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/components/AutoComplete/types.ts"],"sourcesContent":["import React from 'react';\n\nimport { PropRenderItem } from '##/components/Select';\nimport { TextFieldProps } from '##/components/TextField';\n\nexport type AutoCompleteItemDefault = {\n id: string | number;\n label: string;\n groupId?: number;\n};\n\nexport type AutoCompleteGroupDefault = {\n label: string;\n id: number | string;\n};\n\nexport type AutoCompletePropDropdownForm = 'default' | 'brick' | 'round';\n\nexport type AutoCompletePropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type AutoCompletePropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type AutoCompletePropGetItemGroupId<ITEM> = (\n item: ITEM,\n) => number | undefined;\nexport type AutoCompletePropGetGroupLabel<GROUP> = (group: GROUP) => string;\nexport type AutoCompletePropGetGroupId<GROUP> = (\n group: GROUP,\n) => number | string;\n\nexport type AutoCompletePropSearchFunction<ITEM> = (\n item: ITEM,\n searchValue: string,\n) => boolean;\n\nexport type AutoCompletePropOnChange = (\n value: string | null,\n props: {\n e: React.ChangeEvent | React.MouseEvent | React.KeyboardEvent;\n id?: string;\n name?: string;\n },\n) => void;\n\nexport type AutoCompleteProps<\n TYPE extends string,\n ITEM = AutoCompleteItemDefault,\n GROUP = AutoCompleteGroupDefault,\n> = {\n items: ITEM[];\n groups?: GROUP[];\n renderItem?: PropRenderItem<ITEM>;\n dropdownClassName?: string;\n dropdownForm?: AutoCompletePropDropdownForm;\n isLoading?: boolean;\n searchFunction?: AutoCompletePropSearchFunction<ITEM>;\n dropdownRef?: React.RefObject<HTMLDivElement>;\n getItemLabel?: AutoCompletePropGetItemLabel<ITEM>;\n getItemKey?: AutoCompletePropGetItemKey<ITEM>;\n getItemGroupKey?: AutoCompletePropGetItemGroupId<ITEM>;\n getGroupLabel?: AutoCompletePropGetGroupLabel<GROUP>;\n getGroupKey?: AutoCompletePropGetGroupId<GROUP>;\n onChange?: AutoCompletePropOnChange;\n virtualScroll?: boolean;\n onScrollToBottom?: (lenght: number) => void;\n onDropdownOpen?: (isOpen: boolean) => void;\n dropdownOpen?: boolean;\n ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n} & Omit<\n TextFieldProps<TYPE>,\n 'max' | 'min' | 'step' | 'incrementButtons' | 'onChange' | 'width'\n> &\n (ITEM extends { label: AutoCompleteItemDefault['label'] }\n ? {}\n : {\n getItemLabel: AutoCompletePropGetItemLabel<ITEM>;\n }) &\n (ITEM extends { id: AutoCompleteItemDefault['id'] }\n ? {}\n : { getItemKey: AutoCompletePropGetItemKey<ITEM> }) &\n (GROUP extends { label: AutoCompleteGroupDefault['label'] }\n ? {}\n : { getGroupLabel: AutoCompletePropGetGroupLabel<GROUP> }) &\n (GROUP extends { id: AutoCompleteGroupDefault['id'] }\n ? {}\n : { getGroupKey: AutoCompletePropGetGroupId<GROUP> });\n\nexport type AutoCompleteComponent = <\n TYPE extends string,\n ITEM = AutoCompleteItemDefault,\n GROUP = AutoCompleteGroupDefault,\n>(\n props: AutoCompleteProps<TYPE, ITEM, GROUP>,\n) => React.ReactElement | null;\n"],"mappings":""}
@@ -73,7 +73,7 @@ export declare type ComboboxProps<ITEM = ComboboxItemDefault, GROUP = ComboboxGr
73
73
  caption?: string;
74
74
  labelPosition?: 'top' | 'left';
75
75
  virtualScroll?: boolean;
76
- onScrollToBottom?: () => void;
76
+ onScrollToBottom?: (lenght: number) => void;
77
77
  onSearchValueChange?: (value: string) => void;
78
78
  onDropdownOpen?: (isOpen: boolean) => void;
79
79
  dropdownOpen?: boolean;
@@ -151,7 +151,7 @@ export declare function withDefaultGetters<ITEM = ComboboxItemDefault, GROUP = C
151
151
  caption?: string | undefined;
152
152
  labelPosition?: "left" | "top" | undefined;
153
153
  virtualScroll?: boolean | undefined;
154
- onScrollToBottom?: (() => void) | undefined;
154
+ onScrollToBottom?: ((lenght: number) => void) | undefined;
155
155
  onSearchValueChange?: ((value: string) => void) | undefined;
156
156
  onDropdownOpen?: ((isOpen: boolean) => void) | undefined;
157
157
  dropdownOpen?: boolean | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["defaultGetItemKey","item","id","defaultGetItemLabel","label","defaultGetItemGroupKey","groupId","defaultGetItemDisabled","disabled","defaultGetGroupKey","group","defaultGetGroupLabel","isMultipleParams","params","multiple","isNotMultipleParams","withDefaultGetters","props","getItemLabel","getItemKey","getItemGroupKey","getItemDisabled","getGroupLabel","getGroupKey","clearSizeMap","xs","s","m","l","iconSizeMap"],"sources":["../../../../../src/components/Combobox/helpers.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport {\n PropForm,\n PropSize,\n PropStatus,\n PropView,\n RenderItemProps,\n} from '##/components/SelectComponents/types';\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport type ComboboxItemDefault = {\n label: string;\n id: string | number;\n groupId?: string | number;\n disabled?: boolean;\n};\n\nexport type ComboboxGroupDefault = {\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 ComboboxPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type ComboboxPropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type ComboboxPropGetItemGroupKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\nexport type ComboboxPropGetItemDisabled<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\nexport type ComboboxPropGetGroupKey<GROUP> = (group: GROUP) => string | number;\nexport type ComboboxPropGetGroupLabel<GROUP> = (group: GROUP) => string;\ntype ComboboxPropSearchFunction<ITEM> = (\n item: ITEM,\n searchValue: string,\n) => boolean;\ntype ComboboxPropOnChange<ITEM, MULTIPLE extends boolean> = (\n value: (MULTIPLE extends true ? ITEM[] : ITEM) | null,\n props: {\n e: React.SyntheticEvent;\n },\n) => void;\ntype ComboboxPropValue<ITEM, MULTIPLE extends boolean> =\n | (MULTIPLE extends true ? ITEM[] : ITEM)\n | null\n | undefined;\n\nexport type ComboboxPropRenderItem<ITEM> = (\n props: RenderItemProps<ITEM>,\n) => React.ReactElement | null;\nexport type ComboboxPropRenderValue<ITEM> = (\n props: RenderValueProps<ITEM>,\n) => React.ReactElement | null;\n\ntype ComboboxPropOnCreate = (\n label: string,\n props: { e: React.SyntheticEvent },\n) => void;\n\nexport type ComboboxProps<\n ITEM = ComboboxItemDefault,\n GROUP = ComboboxGroupDefault,\n MULTIPLE extends boolean = false,\n> = PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n onChange: ComboboxPropOnChange<ITEM, MULTIPLE>;\n disabled?: boolean;\n form?: PropForm;\n dropdownForm?: 'default' | 'brick' | 'round';\n size?: PropSize;\n view?: PropView;\n placeholder?: string;\n ariaLabel?: string;\n status?: PropStatus;\n isLoading?: boolean;\n dropdownClassName?: string;\n dropdownRef?: React.Ref<HTMLDivElement>;\n name?: string;\n renderItem?: ComboboxPropRenderItem<ITEM>;\n renderValue?: ComboboxPropRenderValue<ITEM>;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n onCreate?: ComboboxPropOnCreate;\n inputRef?: React.Ref<HTMLInputElement>;\n labelForNotFound?: string;\n required?: boolean;\n labelForCreate?: string;\n labelForEmptyItems?: string;\n searchFunction?: ComboboxPropSearchFunction<ITEM>;\n searchValue?: string;\n multiple?: MULTIPLE;\n value?: ComboboxPropValue<ITEM, MULTIPLE>;\n groups?: GROUP[];\n getItemLabel?: ComboboxPropGetItemLabel<ITEM>;\n getItemKey?: ComboboxPropGetItemKey<ITEM>;\n getItemGroupKey?: ComboboxPropGetItemGroupKey<ITEM>;\n getItemDisabled?: ComboboxPropGetItemDisabled<ITEM>;\n getGroupLabel?: ComboboxPropGetGroupLabel<GROUP>;\n getGroupKey?: ComboboxPropGetGroupKey<GROUP>;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n labelPosition?: 'top' | 'left';\n virtualScroll?: boolean;\n onScrollToBottom?: () => void;\n onSearchValueChange?: (value: string) => void;\n onDropdownOpen?: (isOpen: boolean) => void;\n dropdownOpen?: boolean;\n ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n },\n HTMLDivElement\n> &\n (MULTIPLE extends true\n ? {\n selectAll?: boolean;\n allSelectedAllLabel?: string;\n }\n : {\n selectAll?: never;\n allSelectedAllLabel?: never;\n }) &\n (ITEM extends { label: ComboboxItemDefault['label'] }\n ? {}\n : { getItemLabel: ComboboxPropGetItemLabel<ITEM> }) &\n (ITEM extends { id: ComboboxItemDefault['id'] }\n ? {}\n : { getItemKey: ComboboxPropGetItemKey<ITEM> }) &\n (GROUP extends { label: ComboboxGroupDefault['label'] }\n ? {}\n : { getGroupLabel: ComboboxPropGetGroupLabel<GROUP> }) &\n (GROUP extends { id: ComboboxGroupDefault['id'] }\n ? {}\n : { getGroupKey: ComboboxPropGetGroupKey<GROUP> });\n\nexport type ComboboxComponent = <\n ITEM = ComboboxItemDefault,\n GROUP = ComboboxGroupDefault,\n MULTIPLE extends boolean = false,\n>(\n props: ComboboxProps<ITEM, GROUP, MULTIPLE>,\n) => React.ReactElement | null;\n\nexport const defaultGetItemKey: ComboboxPropGetItemKey<ComboboxItemDefault> = (\n item,\n) => item.id;\nexport const defaultGetItemLabel: ComboboxPropGetItemLabel<\n ComboboxItemDefault\n> = (item) => item.label;\nexport const defaultGetItemGroupKey: ComboboxPropGetItemGroupKey<\n ComboboxItemDefault\n> = (item) => item.groupId;\nexport const defaultGetItemDisabled: ComboboxPropGetItemDisabled<\n ComboboxItemDefault\n> = (item) => item.disabled;\n\nexport const defaultGetGroupKey: ComboboxPropGetGroupKey<\n ComboboxGroupDefault\n> = (group) => group.id;\nexport const defaultGetGroupLabel: ComboboxPropGetGroupLabel<\n ComboboxGroupDefault\n> = (group) => group.label;\n\nexport const isMultipleParams = <ITEM, GROUP>(\n params: ComboboxProps<ITEM, GROUP, boolean>,\n): params is ComboboxProps<ITEM, GROUP, true> => {\n return !!params.multiple;\n};\n\nexport const isNotMultipleParams = <ITEM, GROUP>(\n params: ComboboxProps<ITEM, GROUP, boolean>,\n): params is ComboboxProps<ITEM, GROUP, false> => {\n return !params.multiple;\n};\n\nexport function withDefaultGetters<\n ITEM = ComboboxItemDefault,\n GROUP = ComboboxGroupDefault,\n MULTIPLE extends boolean = false,\n>(props: ComboboxProps<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 };\n}\n\nexport const clearSizeMap: Record<PropSize, IconPropSize> = {\n xs: 'xs',\n s: 's',\n m: 's',\n l: 'm',\n};\n\nexport const iconSizeMap: Record<PropSize, IconPropSize> = {\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'm',\n};\n"],"mappings":"qqBAsJA,MAAO,IAAMA,kBAA8D,CAAG,SAC5EC,CAD4E,QAEzEA,EAAI,CAACC,EAFoE,CAAvE,CAGP,MAAO,IAAMC,oBAEZ,CAAG,SAACF,CAAD,QAAUA,EAAI,CAACG,KAAf,CAFG,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACJ,CAAD,QAAUA,EAAI,CAACK,OAAf,CAFG,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACN,CAAD,QAAUA,EAAI,CAACO,QAAf,CAFG,CAIP,MAAO,IAAMC,mBAEZ,CAAG,SAACC,CAAD,QAAWA,EAAK,CAACR,EAAjB,CAFG,CAGP,MAAO,IAAMS,qBAEZ,CAAG,SAACD,CAAD,QAAWA,EAAK,CAACN,KAAjB,CAFG,CAIP,MAAO,IAAMQ,iBAAgB,CAAG,SAC9BC,CAD8B,CAEiB,CAC/C,MAAO,CAAC,CAACA,CAAM,CAACC,QACjB,CAJM,CAMP,MAAO,IAAMC,oBAAmB,CAAG,SACjCF,CADiC,CAEe,CAChD,MAAO,CAACA,CAAM,CAACC,QAChB,CAJM,CAMP,MAAO,SAASE,mBAAT,CAILC,CAJK,CAIwC,CAC7C,sCACKA,CADL,MAEEC,YAAY,CAAED,CAAK,CAACC,YAAN,EAAsBf,mBAFtC,CAGEgB,UAAU,CAAEF,CAAK,CAACE,UAAN,EAAoBnB,iBAHlC,CAIEoB,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,EASD,CAED,MAAO,IAAMe,aAA4C,CAAG,CAC1DC,EAAE,CAAE,IADsD,CAE1DC,CAAC,CAAE,GAFuD,CAG1DC,CAAC,CAAE,GAHuD,CAI1DC,CAAC,CAAE,GAJuD,CAArD,CAOP,MAAO,IAAMC,YAA2C,CAAG,CACzDJ,EAAE,CAAE,IADqD,CAEzDC,CAAC,CAAE,GAFsD,CAGzDC,CAAC,CAAE,GAHsD,CAIzDC,CAAC,CAAE,GAJsD,CAApD"}
1
+ {"version":3,"file":"helpers.js","names":["defaultGetItemKey","item","id","defaultGetItemLabel","label","defaultGetItemGroupKey","groupId","defaultGetItemDisabled","disabled","defaultGetGroupKey","group","defaultGetGroupLabel","isMultipleParams","params","multiple","isNotMultipleParams","withDefaultGetters","props","getItemLabel","getItemKey","getItemGroupKey","getItemDisabled","getGroupLabel","getGroupKey","clearSizeMap","xs","s","m","l","iconSizeMap"],"sources":["../../../../../src/components/Combobox/helpers.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport {\n PropForm,\n PropSize,\n PropStatus,\n PropView,\n RenderItemProps,\n} from '##/components/SelectComponents/types';\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport type ComboboxItemDefault = {\n label: string;\n id: string | number;\n groupId?: string | number;\n disabled?: boolean;\n};\n\nexport type ComboboxGroupDefault = {\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 ComboboxPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type ComboboxPropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type ComboboxPropGetItemGroupKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\nexport type ComboboxPropGetItemDisabled<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\nexport type ComboboxPropGetGroupKey<GROUP> = (group: GROUP) => string | number;\nexport type ComboboxPropGetGroupLabel<GROUP> = (group: GROUP) => string;\ntype ComboboxPropSearchFunction<ITEM> = (\n item: ITEM,\n searchValue: string,\n) => boolean;\ntype ComboboxPropOnChange<ITEM, MULTIPLE extends boolean> = (\n value: (MULTIPLE extends true ? ITEM[] : ITEM) | null,\n props: {\n e: React.SyntheticEvent;\n },\n) => void;\ntype ComboboxPropValue<ITEM, MULTIPLE extends boolean> =\n | (MULTIPLE extends true ? ITEM[] : ITEM)\n | null\n | undefined;\n\nexport type ComboboxPropRenderItem<ITEM> = (\n props: RenderItemProps<ITEM>,\n) => React.ReactElement | null;\nexport type ComboboxPropRenderValue<ITEM> = (\n props: RenderValueProps<ITEM>,\n) => React.ReactElement | null;\n\ntype ComboboxPropOnCreate = (\n label: string,\n props: { e: React.SyntheticEvent },\n) => void;\n\nexport type ComboboxProps<\n ITEM = ComboboxItemDefault,\n GROUP = ComboboxGroupDefault,\n MULTIPLE extends boolean = false,\n> = PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n onChange: ComboboxPropOnChange<ITEM, MULTIPLE>;\n disabled?: boolean;\n form?: PropForm;\n dropdownForm?: 'default' | 'brick' | 'round';\n size?: PropSize;\n view?: PropView;\n placeholder?: string;\n ariaLabel?: string;\n status?: PropStatus;\n isLoading?: boolean;\n dropdownClassName?: string;\n dropdownRef?: React.Ref<HTMLDivElement>;\n name?: string;\n renderItem?: ComboboxPropRenderItem<ITEM>;\n renderValue?: ComboboxPropRenderValue<ITEM>;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n onCreate?: ComboboxPropOnCreate;\n inputRef?: React.Ref<HTMLInputElement>;\n labelForNotFound?: string;\n required?: boolean;\n labelForCreate?: string;\n labelForEmptyItems?: string;\n searchFunction?: ComboboxPropSearchFunction<ITEM>;\n searchValue?: string;\n multiple?: MULTIPLE;\n value?: ComboboxPropValue<ITEM, MULTIPLE>;\n groups?: GROUP[];\n getItemLabel?: ComboboxPropGetItemLabel<ITEM>;\n getItemKey?: ComboboxPropGetItemKey<ITEM>;\n getItemGroupKey?: ComboboxPropGetItemGroupKey<ITEM>;\n getItemDisabled?: ComboboxPropGetItemDisabled<ITEM>;\n getGroupLabel?: ComboboxPropGetGroupLabel<GROUP>;\n getGroupKey?: ComboboxPropGetGroupKey<GROUP>;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n labelPosition?: 'top' | 'left';\n virtualScroll?: boolean;\n onScrollToBottom?: (lenght: number) => void;\n onSearchValueChange?: (value: string) => void;\n onDropdownOpen?: (isOpen: boolean) => void;\n dropdownOpen?: boolean;\n ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n },\n HTMLDivElement\n> &\n (MULTIPLE extends true\n ? {\n selectAll?: boolean;\n allSelectedAllLabel?: string;\n }\n : {\n selectAll?: never;\n allSelectedAllLabel?: never;\n }) &\n (ITEM extends { label: ComboboxItemDefault['label'] }\n ? {}\n : { getItemLabel: ComboboxPropGetItemLabel<ITEM> }) &\n (ITEM extends { id: ComboboxItemDefault['id'] }\n ? {}\n : { getItemKey: ComboboxPropGetItemKey<ITEM> }) &\n (GROUP extends { label: ComboboxGroupDefault['label'] }\n ? {}\n : { getGroupLabel: ComboboxPropGetGroupLabel<GROUP> }) &\n (GROUP extends { id: ComboboxGroupDefault['id'] }\n ? {}\n : { getGroupKey: ComboboxPropGetGroupKey<GROUP> });\n\nexport type ComboboxComponent = <\n ITEM = ComboboxItemDefault,\n GROUP = ComboboxGroupDefault,\n MULTIPLE extends boolean = false,\n>(\n props: ComboboxProps<ITEM, GROUP, MULTIPLE>,\n) => React.ReactElement | null;\n\nexport const defaultGetItemKey: ComboboxPropGetItemKey<ComboboxItemDefault> = (\n item,\n) => item.id;\nexport const defaultGetItemLabel: ComboboxPropGetItemLabel<\n ComboboxItemDefault\n> = (item) => item.label;\nexport const defaultGetItemGroupKey: ComboboxPropGetItemGroupKey<\n ComboboxItemDefault\n> = (item) => item.groupId;\nexport const defaultGetItemDisabled: ComboboxPropGetItemDisabled<\n ComboboxItemDefault\n> = (item) => item.disabled;\n\nexport const defaultGetGroupKey: ComboboxPropGetGroupKey<\n ComboboxGroupDefault\n> = (group) => group.id;\nexport const defaultGetGroupLabel: ComboboxPropGetGroupLabel<\n ComboboxGroupDefault\n> = (group) => group.label;\n\nexport const isMultipleParams = <ITEM, GROUP>(\n params: ComboboxProps<ITEM, GROUP, boolean>,\n): params is ComboboxProps<ITEM, GROUP, true> => {\n return !!params.multiple;\n};\n\nexport const isNotMultipleParams = <ITEM, GROUP>(\n params: ComboboxProps<ITEM, GROUP, boolean>,\n): params is ComboboxProps<ITEM, GROUP, false> => {\n return !params.multiple;\n};\n\nexport function withDefaultGetters<\n ITEM = ComboboxItemDefault,\n GROUP = ComboboxGroupDefault,\n MULTIPLE extends boolean = false,\n>(props: ComboboxProps<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 };\n}\n\nexport const clearSizeMap: Record<PropSize, IconPropSize> = {\n xs: 'xs',\n s: 's',\n m: 's',\n l: 'm',\n};\n\nexport const iconSizeMap: Record<PropSize, IconPropSize> = {\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'm',\n};\n"],"mappings":"qqBAsJA,MAAO,IAAMA,kBAA8D,CAAG,SAC5EC,CAD4E,QAEzEA,EAAI,CAACC,EAFoE,CAAvE,CAGP,MAAO,IAAMC,oBAEZ,CAAG,SAACF,CAAD,QAAUA,EAAI,CAACG,KAAf,CAFG,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACJ,CAAD,QAAUA,EAAI,CAACK,OAAf,CAFG,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACN,CAAD,QAAUA,EAAI,CAACO,QAAf,CAFG,CAIP,MAAO,IAAMC,mBAEZ,CAAG,SAACC,CAAD,QAAWA,EAAK,CAACR,EAAjB,CAFG,CAGP,MAAO,IAAMS,qBAEZ,CAAG,SAACD,CAAD,QAAWA,EAAK,CAACN,KAAjB,CAFG,CAIP,MAAO,IAAMQ,iBAAgB,CAAG,SAC9BC,CAD8B,CAEiB,CAC/C,MAAO,CAAC,CAACA,CAAM,CAACC,QACjB,CAJM,CAMP,MAAO,IAAMC,oBAAmB,CAAG,SACjCF,CADiC,CAEe,CAChD,MAAO,CAACA,CAAM,CAACC,QAChB,CAJM,CAMP,MAAO,SAASE,mBAAT,CAILC,CAJK,CAIwC,CAC7C,sCACKA,CADL,MAEEC,YAAY,CAAED,CAAK,CAACC,YAAN,EAAsBf,mBAFtC,CAGEgB,UAAU,CAAEF,CAAK,CAACE,UAAN,EAAoBnB,iBAHlC,CAIEoB,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,EASD,CAED,MAAO,IAAMe,aAA4C,CAAG,CAC1DC,EAAE,CAAE,IADsD,CAE1DC,CAAC,CAAE,GAFuD,CAG1DC,CAAC,CAAE,GAHuD,CAI1DC,CAAC,CAAE,GAJuD,CAArD,CAOP,MAAO,IAAMC,YAA2C,CAAG,CACzDJ,EAAE,CAAE,IADqD,CAEzDC,CAAC,CAAE,GAFsD,CAGzDC,CAAC,CAAE,GAHsD,CAIzDC,CAAC,CAAE,GAJsD,CAApD"}
@@ -1 +1 @@
1
- .DatePickerMixRangeField{--caption-margin-left:calc(var(--input-space) + var(--control-border-width));display:flex}.DatePickerMixRangeField_size_xs{--input-height:var(--control-height-xs);--input-space:calc(var(--control-space-xs)*0.5)}.DatePickerMixRangeField_size_s{--input-height:var(--control-height-s);--input-space:calc(var(--control-space-s)*0.5)}.DatePickerMixRangeField_size_m{--input-height:var(--control-height-m);--input-space:calc(var(--control-space-m)*0.5)}.DatePickerMixRangeField_size_l{--input-height:var(--control-height-l);--input-space:calc(var(--control-space-l)*0.5)}.DatePickerMixRangeField_view_clear{--caption-margin-left:0}.DatePickerMixRangeField_width_full{width:100%}.DatePickerMixRangeField-Field{flex:1}.DatePickerMixRangeField-Fields{display:flex}.DatePickerMixRangeField_labelPosition_top{flex-direction:column}.DatePickerMixRangeField_labelPosition_top>:not(:last-child){margin-bottom:var(--space-xs)}.DatePickerMixRangeField_labelPosition_left{flex-direction:row}.DatePickerMixRangeField_labelPosition_left .DatePickerFieldTypeDateRange-Label{align-items:center;display:inline-flex;height:var(--input-height)}.DatePickerMixRangeField_labelPosition_left>:not(:last-child){margin-right:var(--space-s)}.DatePickerMixRangeField-Body{display:inline-flex;flex-direction:column;width:100%}.DatePickerMixRangeField-Caption{margin-left:var(--caption-margin-left);margin-top:var(--space-2xs)}
1
+ .DatePickerMixRangeField{--caption-margin-left:var(--control-border-width);display:flex}.DatePickerMixRangeField_size_xs{--input-height:var(--control-height-xs);--input-space:calc(var(--control-space-xs)*0.5)}.DatePickerMixRangeField_size_s{--input-height:var(--control-height-s);--input-space:calc(var(--control-space-s)*0.5)}.DatePickerMixRangeField_size_m{--input-height:var(--control-height-m);--input-space:calc(var(--control-space-m)*0.5)}.DatePickerMixRangeField_size_l{--input-height:var(--control-height-l);--input-space:calc(var(--control-space-l)*0.5)}.DatePickerMixRangeField_view_clear{--caption-margin-left:0}.DatePickerMixRangeField_width_full{width:100%}.DatePickerMixRangeField-Field{flex:1}.DatePickerMixRangeField-Fields{display:flex}.DatePickerMixRangeField_labelPosition_top{flex-direction:column}.DatePickerMixRangeField_labelPosition_top>:not(:last-child){margin-bottom:var(--space-xs)}.DatePickerMixRangeField_labelPosition_left{flex-direction:row}.DatePickerMixRangeField_labelPosition_left .DatePickerFieldTypeDateRange-Label{align-items:center;display:inline-flex;height:var(--input-height)}.DatePickerMixRangeField_labelPosition_left>:not(:last-child){margin-right:var(--space-s)}.DatePickerMixRangeField-Body{display:inline-flex;flex-direction:column;width:100%}.DatePickerMixRangeField-Caption{margin-left:var(--caption-margin-left);margin-top:var(--space-2xs)}
@@ -1,2 +1,2 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["alt","src","getImageSettings","subscribeToRef"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import React,{forwardRef,useMemo}from"react";import{getLastPoint,useBreakpoints}from"../../hooks/useBreakpoints";import{useTheme}from"../Theme";import{defaultGetImageSettings,getConvertedImages,getSrcHash}from"./helper";export var Picture=forwardRef(function(a,b){var c,d=a.alt,e=void 0===d?"":d,f=a.src,g=a.getImageSettings,h=void 0===g?defaultGetImageSettings:g,i=a.subscribeToRef,j=_objectWithoutProperties(a,_excluded),k=useTheme(),l=k.theme,m=useMemo(function(){var a=getConvertedImages(f,h);return[a,a.reduce(function(b,a){var c=a.size,d=void 0===c?0:c;return _objectSpread(_objectSpread({},b),{},_defineProperty({},d,d))},{})]},[getSrcHash(f)]),n=_slicedToArray(m,2),o=n[0],p=n[1],q=+(null!==(c=getLastPoint(useBreakpoints({map:p,isActive:!0,ref:i})))&&void 0!==c?c:-1),r=useMemo(function(){return o.filter(function(a){var b=a.size,c=a.theme;return(!c||l.color.primary===c)&&("number"!=typeof b||q===b)}).sort(function(c,a){return c.descriptor&&a.descriptor?+c.descriptor.replace(/[^0-9.]+/g,"")<+a.descriptor.replace(/[^0-9.]+/g,"")?-1:1:0})},[q,l,o]),s=useMemo(function(){var a;if(0===r.length)return[];if(1<r.length){var b;return[null===(b=r[0])||void 0===b?void 0:b.src,r.map(function(a){var b=a.src,c=a.descriptor;return"".concat(b," ").concat(c)}).join(",")]}return[null===(a=r[0])||void 0===a?void 0:a.src]},[r]),t=_slicedToArray(s,2),u=t[0],v=t[1];return u?React.createElement("img",Object.assign({},j,{ref:b,alt:e,src:u,srcSet:v})):null});
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["alt","src","getImageSettings","subscribeToRef"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import React,{forwardRef,useMemo}from"react";import{getLastPoint,useBreakpoints}from"../../hooks/useBreakpoints";import{useTheme}from"../Theme";import{defaultGetImageSettings,getConvertedImages,getSrcHash}from"./helper";export var Picture=forwardRef(function(a,b){var c,d=a.alt,e=void 0===d?"":d,f=a.src,g=a.getImageSettings,h=void 0===g?defaultGetImageSettings:g,i=a.subscribeToRef,j=_objectWithoutProperties(a,_excluded),k=useTheme(),l=k.theme,m=useMemo(function(){var a=getConvertedImages(f,h);return[a,a.reduce(function(b,a){var c=a.size,d=void 0===c?0:c;return _objectSpread(_objectSpread({},b),{},_defineProperty({},d,d))},{})]},[getSrcHash(f)]),n=_slicedToArray(m,2),o=n[0],p=n[1];console.log(o,p);var q=+(null!==(c=getLastPoint(useBreakpoints({map:p,isActive:!0,ref:i})))&&void 0!==c?c:-1),r=useMemo(function(){return o.filter(function(a){var b=a.size,c=a.theme;return(!c||l.color.primary===c)&&("number"!=typeof b||q===b)}).sort(function(c,a){return c.descriptor&&a.descriptor?+c.descriptor.replace(/[^0-9.]+/g,"")<+a.descriptor.replace(/[^0-9.]+/g,"")?-1:1:0})},[q,l,o]),s=useMemo(function(){var a;if(0===r.length)return[];if(1<r.length){var b;return[encodeURI(null===(b=r[0])||void 0===b?void 0:b.src),r.map(function(a){var b=a.src,c=a.descriptor;return"".concat(encodeURI(b)," ").concat(c)}).join(",")]}return[null===(a=r[0])||void 0===a?void 0:a.src]},[r]),t=_slicedToArray(s,2),u=t[0],v=t[1];return u?React.createElement("img",Object.assign({},j,{ref:b,alt:e,src:u,srcSet:v})):null});
2
2
  //# sourceMappingURL=Picture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Picture.js","names":["React","forwardRef","useMemo","getLastPoint","useBreakpoints","useTheme","defaultGetImageSettings","getConvertedImages","getSrcHash","Picture","props","ref","alt","srcProp","src","getImageSettings","subscribeToRef","otherProps","theme","images","reduce","a","size","convertedImages","sizes","activeImageSize","map","isActive","suitableImages","filter","targetTheme","color","primary","sort","b","descriptor","replace","length","join","srcSet"],"sources":["../../../../../src/components/Picture/Picture.tsx"],"sourcesContent":["import React, { forwardRef, useMemo } from 'react';\n\nimport { getLastPoint, useBreakpoints } from '##/hooks/useBreakpoints';\n\nimport { useTheme } from '../Theme';\nimport {\n defaultGetImageSettings,\n getConvertedImages,\n getSrcHash,\n} from './helper';\nimport { PictureProps } from './types';\n\nexport const Picture = forwardRef<HTMLImageElement, PictureProps>(\n (props, ref) => {\n const {\n alt = '',\n src: srcProp,\n getImageSettings = defaultGetImageSettings,\n subscribeToRef,\n ...otherProps\n } = props;\n\n const { theme } = useTheme();\n\n const [convertedImages, sizes]: [\n Array<{\n theme?: string;\n descriptor?: string;\n src: string;\n key: string;\n size?: number;\n }>,\n Record<string, number>,\n ] = useMemo(() => {\n const images = getConvertedImages(srcProp, getImageSettings);\n return [\n images,\n images.reduce((a, { size = 0 }) => ({ ...a, [size]: size }), {}),\n ];\n }, [getSrcHash(srcProp)]);\n\n const activeImageSize = Number(\n getLastPoint(\n useBreakpoints({\n map: sizes,\n isActive: true,\n ref: subscribeToRef,\n }),\n ) ?? -1,\n );\n\n const suitableImages = useMemo(() => {\n return convertedImages\n .filter(\n ({ size, theme: targetTheme }) =>\n (!targetTheme || theme.color.primary === targetTheme) &&\n (typeof size !== 'number' || activeImageSize === size),\n )\n .sort((a, b) => {\n if (a.descriptor && b.descriptor) {\n return Number(a.descriptor.replace(/[^0-9.]+/g, '')) <\n Number(b.descriptor.replace(/[^0-9.]+/g, ''))\n ? -1\n : 1;\n }\n return 0;\n });\n }, [activeImageSize, theme, convertedImages]);\n\n const [src, srcSet] = useMemo(() => {\n if (suitableImages.length === 0) {\n return [];\n }\n if (suitableImages.length > 1) {\n return [\n suitableImages[0]?.src,\n suitableImages\n .map(({ src, descriptor }) => `${src} ${descriptor}`)\n .join(','),\n ];\n }\n return [suitableImages[0]?.src];\n }, [suitableImages]);\n\n return src ? (\n <img {...otherProps} ref={ref} alt={alt} src={src} srcSet={srcSet} />\n ) : null;\n },\n);\n"],"mappings":"23BAAA,MAAOA,MAAP,EAAgBC,UAAhB,CAA4BC,OAA5B,KAA2C,OAA3C,CAEA,OAASC,YAAT,CAAuBC,cAAvB,kCAEA,OAASC,QAAT,gBACA,OACEC,uBADF,CAEEC,kBAFF,CAGEC,UAHF,gBAOA,MAAO,IAAMC,QAAO,CAAGR,UAAU,CAC/B,SAACS,CAAD,CAAQC,CAAR,CAAgB,SAOVD,CAPU,CAEZE,GAFY,CAEZA,CAFY,YAEN,EAFM,GAGPC,CAHO,CAOVH,CAPU,CAGZI,GAHY,GAOVJ,CAPU,CAIZK,gBAJY,CAIZA,CAJY,YAIOT,uBAJP,GAKZU,CALY,CAOVN,CAPU,CAKZM,cALY,CAMTC,CANS,0BAOVP,CAPU,cASIL,QAAQ,EATZ,CASNa,CATM,GASNA,KATM,GAoBVhB,OAAO,CAAC,UAAM,CAChB,GAAMiB,EAAM,CAAGZ,kBAAkB,CAACM,CAAD,CAAUE,CAAV,CAAjC,CACA,MAAO,CACLI,CADK,CAELA,CAAM,CAACC,MAAP,CAAc,SAACC,CAA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GADd,CAELc,CAAc,CACXF,GADH,CACO,eAAGZ,EAAH,GAAGA,GAAH,CAAQqB,CAAR,GAAQA,UAAR,iBAA4BrB,CAA5B,aAAmCqB,CAAnC,EADP,EAEGG,IAFH,CAEQ,GAFR,CAFK,CAMR,CACD,MAAO,WAACV,CAAc,CAAC,CAAD,CAAf,qBAAC,EAAmBd,GAApB,CACR,CAb4B,CAa1B,CAACc,CAAD,CAb0B,CAxDf,uBAwDPd,CAxDO,MAwDFyB,CAxDE,MAuEd,MAAOzB,EAAG,CACR,2CAASG,CAAT,EAAqB,GAAG,CAAEN,CAA1B,CAA+B,GAAG,CAAEC,CAApC,CAAyC,GAAG,CAAEE,CAA9C,CAAmD,MAAM,CAAEyB,CAA3D,GADQ,CAEN,IACL,CA3E8B,CAA1B"}
1
+ {"version":3,"file":"Picture.js","names":["React","forwardRef","useMemo","getLastPoint","useBreakpoints","useTheme","defaultGetImageSettings","getConvertedImages","getSrcHash","Picture","props","ref","alt","srcProp","src","getImageSettings","subscribeToRef","otherProps","theme","images","reduce","a","size","convertedImages","sizes","console","log","activeImageSize","map","isActive","suitableImages","filter","targetTheme","color","primary","sort","b","descriptor","replace","length","encodeURI","join","srcSet"],"sources":["../../../../../src/components/Picture/Picture.tsx"],"sourcesContent":["import React, { forwardRef, useMemo } from 'react';\n\nimport { getLastPoint, useBreakpoints } from '##/hooks/useBreakpoints';\n\nimport { useTheme } from '../Theme';\nimport {\n defaultGetImageSettings,\n getConvertedImages,\n getSrcHash,\n} from './helper';\nimport { PictureProps } from './types';\n\nexport const Picture = forwardRef<HTMLImageElement, PictureProps>(\n (props, ref) => {\n const {\n alt = '',\n src: srcProp,\n getImageSettings = defaultGetImageSettings,\n subscribeToRef,\n ...otherProps\n } = props;\n\n const { theme } = useTheme();\n\n const [convertedImages, sizes]: [\n Array<{\n theme?: string;\n descriptor?: string;\n src: string;\n key: string;\n size?: number;\n }>,\n Record<string, number>,\n ] = useMemo(() => {\n const images = getConvertedImages(srcProp, getImageSettings);\n return [\n images,\n images.reduce((a, { size = 0 }) => ({ ...a, [size]: size }), {}),\n ];\n }, [getSrcHash(srcProp)]);\n\n console.log(convertedImages, sizes);\n\n const activeImageSize = Number(\n getLastPoint(\n useBreakpoints({\n map: sizes,\n isActive: true,\n ref: subscribeToRef,\n }),\n ) ?? -1,\n );\n\n const suitableImages = useMemo(() => {\n return convertedImages\n .filter(\n ({ size, theme: targetTheme }) =>\n (!targetTheme || theme.color.primary === targetTheme) &&\n (typeof size !== 'number' || activeImageSize === size),\n )\n .sort((a, b) => {\n if (a.descriptor && b.descriptor) {\n return Number(a.descriptor.replace(/[^0-9.]+/g, '')) <\n Number(b.descriptor.replace(/[^0-9.]+/g, ''))\n ? -1\n : 1;\n }\n return 0;\n });\n }, [activeImageSize, theme, convertedImages]);\n\n const [src, srcSet] = useMemo(() => {\n if (suitableImages.length === 0) {\n return [];\n }\n if (suitableImages.length > 1) {\n return [\n encodeURI(suitableImages[0]?.src),\n suitableImages\n .map(({ src, descriptor }) => `${encodeURI(src)} ${descriptor}`)\n .join(','),\n ];\n }\n return [suitableImages[0]?.src];\n }, [suitableImages]);\n\n return src ? (\n <img {...otherProps} ref={ref} alt={alt} src={src} srcSet={srcSet} />\n ) : null;\n },\n);\n"],"mappings":"23BAAA,MAAOA,MAAP,EAAgBC,UAAhB,CAA4BC,OAA5B,KAA2C,OAA3C,CAEA,OAASC,YAAT,CAAuBC,cAAvB,kCAEA,OAASC,QAAT,gBACA,OACEC,uBADF,CAEEC,kBAFF,CAGEC,UAHF,gBAOA,MAAO,IAAMC,QAAO,CAAGR,UAAU,CAC/B,SAACS,CAAD,CAAQC,CAAR,CAAgB,SAOVD,CAPU,CAEZE,GAFY,CAEZA,CAFY,YAEN,EAFM,GAGPC,CAHO,CAOVH,CAPU,CAGZI,GAHY,GAOVJ,CAPU,CAIZK,gBAJY,CAIZA,CAJY,YAIOT,uBAJP,GAKZU,CALY,CAOVN,CAPU,CAKZM,cALY,CAMTC,CANS,0BA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B6B,CAgB3B,CAACX,CAAD,CAAkBT,CAAlB,CAAyBK,CAAzB,CAhB2B,CAxChB,GA0DQrB,OAAO,CAAC,UAAM,OAClC,GAA8B,CAA1B,GAAA4B,CAAc,CAACS,MAAnB,CACE,MAAO,EAAP,CAEF,GAA4B,CAAxB,CAAAT,CAAc,CAACS,MAAnB,CAA+B,OAC7B,MAAO,CACLC,SAAS,WAACV,CAAc,CAAC,CAAD,CAAf,qBAAC,EAAmBhB,GAApB,CADJ,CAELgB,CAAc,CACXF,GADH,CACO,eAAGd,EAAH,GAAGA,GAAH,CAAQuB,CAAR,GAAQA,UAAR,iBAA4BG,SAAS,CAAC1B,CAAD,CAArC,aAA8CuB,CAA9C,EADP,EAEGI,IAFH,CAEQ,GAFR,CAFK,CAMR,CACD,MAAO,WAACX,CAAc,CAAC,CAAD,CAAf,qBAAC,EAAmBhB,GAApB,CACR,CAb4B,CAa1B,CAACgB,CAAD,CAb0B,CA1Df,uBA0DPhB,CA1DO,MA0DF4B,CA1DE,MAyEd,MAAO5B,EAAG,CACR,2CAASG,CAAT,EAAqB,GAAG,CAAEN,CAA1B,CAA+B,GAAG,CAAEC,CAApC,CAAyC,GAAG,CAAEE,CAA9C,CAAmD,MAAM,CAAE4B,CAA3D,GADQ,CAEN,IACL,CA7E8B,CAA1B"}
@@ -63,7 +63,7 @@ export declare type SelectProps<ITEM = SelectItemDefault, GROUP = SelectGroupDef
63
63
  labelPosition?: 'top' | 'left';
64
64
  caption?: string;
65
65
  virtualScroll?: boolean;
66
- onScrollToBottom?: () => void;
66
+ onScrollToBottom?: (lenght: number) => void;
67
67
  onDropdownOpen?: (isOpen: boolean) => void;
68
68
  dropdownOpen?: boolean;
69
69
  ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;
@@ -127,7 +127,7 @@ export declare function withDefaultGetters<ITEM, GROUP>(props: SelectProps<ITEM,
127
127
  labelPosition?: "left" | "top" | undefined;
128
128
  caption?: string | undefined;
129
129
  virtualScroll?: boolean | undefined;
130
- onScrollToBottom?: (() => void) | undefined;
130
+ onScrollToBottom?: ((lenght: number) => void) | undefined;
131
131
  onDropdownOpen?: ((isOpen: boolean) => void) | undefined;
132
132
  dropdownOpen?: boolean | undefined;
133
133
  ignoreOutsideClicksRefs?: readonly React.RefObject<HTMLElement>[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["defaultGetItemKey","item","id","defaultGetItemLabel","label","defaultGetItemGroupKey","groupId","defaultGetItemDisabled","disabled","defaultGetGroupKey","group","defaultGetGroupLabel","withDefaultGetters","props","getItemLabel","getItemKey","getItemGroupKey","getItemDisabled","getGroupLabel","getGroupKey","iconSizeMap","xs","s","m","l"],"sources":["../../../../../src/components/Select/helpers.ts"],"sourcesContent":["import { IconComponent, IconPropSize } 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 SelectItemDefault = {\n label: string;\n id: string | number;\n groupId?: string | number;\n disabled?: boolean;\n};\n\nexport type SelectGroupDefault = {\n label: string;\n id: string | number;\n};\n\ntype SelectPropValue<ITEM> = ITEM | null | undefined;\n\ntype SelectRenderValueProps<ITEM> = {\n item: ITEM;\n};\n\nexport type SelectPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type SelectPropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type SelectPropGetItemGroupKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\nexport type SelectPropGetItemDisabled<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\nexport type SelectPropGetGroupKey<GROUP> = (group: GROUP) => string | number;\nexport type SelectPropGetGroupLabel<GROUP> = (group: GROUP) => string;\nexport type PropRenderItem<ITEM> = (\n props: RenderItemProps<ITEM>,\n) => React.ReactElement | null;\nexport type PropRenderValue<ITEM> = (\n props: SelectRenderValueProps<ITEM>,\n) => React.ReactElement | null;\n\nexport type SelectPropOnChange<ITEM> = (\n value: ITEM | null,\n props: { e: React.SyntheticEvent },\n) => void;\n\nexport type SelectProps<\n ITEM = SelectItemDefault,\n GROUP = SelectGroupDefault,\n> = PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n onChange: SelectPropOnChange<ITEM>;\n disabled?: boolean;\n form?: PropForm;\n dropdownForm?: 'default' | 'brick' | 'round';\n size?: PropSize;\n view?: PropView;\n status?: PropStatus;\n focused?: boolean;\n placeholder?: string;\n ariaLabel?: string;\n dropdownClassName?: string;\n dropdownRef?: React.RefObject<HTMLDivElement>;\n required?: boolean;\n name?: string;\n isLoading?: boolean;\n labelForEmptyItems?: string;\n value?: SelectPropValue<ITEM>;\n renderItem?: PropRenderItem<ITEM>;\n renderValue?: PropRenderValue<ITEM>;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n inputRef?: React.RefObject<HTMLInputElement>;\n groups?: GROUP[];\n getItemLabel?: SelectPropGetItemLabel<ITEM>;\n getItemKey?: SelectPropGetItemKey<ITEM>;\n getItemGroupKey?: SelectPropGetItemGroupKey<ITEM>;\n getItemDisabled?: SelectPropGetItemDisabled<ITEM>;\n getGroupLabel?: SelectPropGetGroupLabel<GROUP>;\n getGroupKey?: SelectPropGetGroupKey<GROUP>;\n label?: string;\n labelIcon?: IconComponent;\n labelPosition?: 'top' | 'left';\n caption?: string;\n virtualScroll?: boolean;\n onScrollToBottom?: () => void;\n onDropdownOpen?: (isOpen: boolean) => void;\n dropdownOpen?: boolean;\n ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n },\n HTMLDivElement\n> &\n (ITEM extends { label: SelectItemDefault['label'] }\n ? {}\n : { getItemLabel: SelectPropGetItemLabel<ITEM> }) &\n (ITEM extends { id: SelectItemDefault['id'] }\n ? {}\n : { getItemKey: SelectPropGetItemKey<ITEM> }) &\n (GROUP extends { label: SelectGroupDefault['label'] }\n ? {}\n : { getGroupLabel: SelectPropGetGroupLabel<GROUP> }) &\n (GROUP extends { id: SelectGroupDefault['id'] }\n ? {}\n : { getGroupKey: SelectPropGetGroupKey<GROUP> });\n\nexport type SelectComponent = <\n ITEM = SelectItemDefault,\n GROUP = SelectGroupDefault,\n>(\n props: SelectProps<ITEM, GROUP>,\n) => React.ReactElement | null;\n\nexport const defaultGetItemKey: SelectPropGetItemKey<SelectItemDefault> = (\n item,\n) => item.id;\nexport const defaultGetItemLabel: SelectPropGetItemLabel<SelectItemDefault> = (\n item,\n) => item.label;\nexport const defaultGetItemGroupKey: SelectPropGetItemGroupKey<\n SelectItemDefault\n> = (item) => item.groupId;\nexport const defaultGetItemDisabled: SelectPropGetItemDisabled<\n SelectItemDefault\n> = (item) => item.disabled;\n\nexport const defaultGetGroupKey: SelectPropGetGroupKey<SelectGroupDefault> = (\n group,\n) => group.id;\nexport const defaultGetGroupLabel: SelectPropGetGroupLabel<\n SelectGroupDefault\n> = (group) => group.label;\n\nexport function withDefaultGetters<ITEM, GROUP>(\n props: SelectProps<ITEM, GROUP>,\n) {\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 };\n}\n\nexport const iconSizeMap: Record<PropSize, IconPropSize> = {\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'm',\n};\n"],"mappings":"qqBAuHA,MAAO,IAAMA,kBAA0D,CAAG,SACxEC,CADwE,QAErEA,EAAI,CAACC,EAFgE,CAAnE,CAGP,MAAO,IAAMC,oBAA8D,CAAG,SAC5EF,CAD4E,QAEzEA,EAAI,CAACG,KAFoE,CAAvE,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACJ,CAAD,QAAUA,EAAI,CAACK,OAAf,CAFG,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACN,CAAD,QAAUA,EAAI,CAACO,QAAf,CAFG,CAIP,MAAO,IAAMC,mBAA6D,CAAG,SAC3EC,CAD2E,QAExEA,EAAK,CAACR,EAFkE,CAAtE,CAGP,MAAO,IAAMS,qBAEZ,CAAG,SAACD,CAAD,QAAWA,EAAK,CAACN,KAAjB,CAFG,CAIP,MAAO,SAASQ,mBAAT,CACLC,CADK,CAEL,CACA,sCACKA,CADL,MAEEC,YAAY,CAAED,CAAK,CAACC,YAAN,EAAsBX,mBAFtC,CAGEY,UAAU,CAAEF,CAAK,CAACE,UAAN,EAAoBf,iBAHlC,CAIEgB,eAAe,CAAEH,CAAK,CAACG,eAAN,EAAyBX,sBAJ5C,CAKEY,eAAe,CAAEJ,CAAK,CAACI,eAAN,EAAyBV,sBAL5C,CAMEW,aAAa,CAAEL,CAAK,CAACK,aAAN,EAAuBP,oBANxC,CAOEQ,WAAW,CAAEN,CAAK,CAACM,WAAN,EAAqBV,kBAPpC,EASD,CAED,MAAO,IAAMW,YAA2C,CAAG,CACzDC,EAAE,CAAE,IADqD,CAEzDC,CAAC,CAAE,GAFsD,CAGzDC,CAAC,CAAE,GAHsD,CAIzDC,CAAC,CAAE,GAJsD,CAApD"}
1
+ {"version":3,"file":"helpers.js","names":["defaultGetItemKey","item","id","defaultGetItemLabel","label","defaultGetItemGroupKey","groupId","defaultGetItemDisabled","disabled","defaultGetGroupKey","group","defaultGetGroupLabel","withDefaultGetters","props","getItemLabel","getItemKey","getItemGroupKey","getItemDisabled","getGroupLabel","getGroupKey","iconSizeMap","xs","s","m","l"],"sources":["../../../../../src/components/Select/helpers.ts"],"sourcesContent":["import { IconComponent, IconPropSize } 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 SelectItemDefault = {\n label: string;\n id: string | number;\n groupId?: string | number;\n disabled?: boolean;\n};\n\nexport type SelectGroupDefault = {\n label: string;\n id: string | number;\n};\n\ntype SelectPropValue<ITEM> = ITEM | null | undefined;\n\ntype SelectRenderValueProps<ITEM> = {\n item: ITEM;\n};\n\nexport type SelectPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type SelectPropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type SelectPropGetItemGroupKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\nexport type SelectPropGetItemDisabled<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\nexport type SelectPropGetGroupKey<GROUP> = (group: GROUP) => string | number;\nexport type SelectPropGetGroupLabel<GROUP> = (group: GROUP) => string;\nexport type PropRenderItem<ITEM> = (\n props: RenderItemProps<ITEM>,\n) => React.ReactElement | null;\nexport type PropRenderValue<ITEM> = (\n props: SelectRenderValueProps<ITEM>,\n) => React.ReactElement | null;\n\nexport type SelectPropOnChange<ITEM> = (\n value: ITEM | null,\n props: { e: React.SyntheticEvent },\n) => void;\n\nexport type SelectProps<\n ITEM = SelectItemDefault,\n GROUP = SelectGroupDefault,\n> = PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n onChange: SelectPropOnChange<ITEM>;\n disabled?: boolean;\n form?: PropForm;\n dropdownForm?: 'default' | 'brick' | 'round';\n size?: PropSize;\n view?: PropView;\n status?: PropStatus;\n focused?: boolean;\n placeholder?: string;\n ariaLabel?: string;\n dropdownClassName?: string;\n dropdownRef?: React.RefObject<HTMLDivElement>;\n required?: boolean;\n name?: string;\n isLoading?: boolean;\n labelForEmptyItems?: string;\n value?: SelectPropValue<ITEM>;\n renderItem?: PropRenderItem<ITEM>;\n renderValue?: PropRenderValue<ITEM>;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n inputRef?: React.RefObject<HTMLInputElement>;\n groups?: GROUP[];\n getItemLabel?: SelectPropGetItemLabel<ITEM>;\n getItemKey?: SelectPropGetItemKey<ITEM>;\n getItemGroupKey?: SelectPropGetItemGroupKey<ITEM>;\n getItemDisabled?: SelectPropGetItemDisabled<ITEM>;\n getGroupLabel?: SelectPropGetGroupLabel<GROUP>;\n getGroupKey?: SelectPropGetGroupKey<GROUP>;\n label?: string;\n labelIcon?: IconComponent;\n labelPosition?: 'top' | 'left';\n caption?: string;\n virtualScroll?: boolean;\n onScrollToBottom?: (lenght: number) => void;\n onDropdownOpen?: (isOpen: boolean) => void;\n dropdownOpen?: boolean;\n ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n },\n HTMLDivElement\n> &\n (ITEM extends { label: SelectItemDefault['label'] }\n ? {}\n : { getItemLabel: SelectPropGetItemLabel<ITEM> }) &\n (ITEM extends { id: SelectItemDefault['id'] }\n ? {}\n : { getItemKey: SelectPropGetItemKey<ITEM> }) &\n (GROUP extends { label: SelectGroupDefault['label'] }\n ? {}\n : { getGroupLabel: SelectPropGetGroupLabel<GROUP> }) &\n (GROUP extends { id: SelectGroupDefault['id'] }\n ? {}\n : { getGroupKey: SelectPropGetGroupKey<GROUP> });\n\nexport type SelectComponent = <\n ITEM = SelectItemDefault,\n GROUP = SelectGroupDefault,\n>(\n props: SelectProps<ITEM, GROUP>,\n) => React.ReactElement | null;\n\nexport const defaultGetItemKey: SelectPropGetItemKey<SelectItemDefault> = (\n item,\n) => item.id;\nexport const defaultGetItemLabel: SelectPropGetItemLabel<SelectItemDefault> = (\n item,\n) => item.label;\nexport const defaultGetItemGroupKey: SelectPropGetItemGroupKey<\n SelectItemDefault\n> = (item) => item.groupId;\nexport const defaultGetItemDisabled: SelectPropGetItemDisabled<\n SelectItemDefault\n> = (item) => item.disabled;\n\nexport const defaultGetGroupKey: SelectPropGetGroupKey<SelectGroupDefault> = (\n group,\n) => group.id;\nexport const defaultGetGroupLabel: SelectPropGetGroupLabel<\n SelectGroupDefault\n> = (group) => group.label;\n\nexport function withDefaultGetters<ITEM, GROUP>(\n props: SelectProps<ITEM, GROUP>,\n) {\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 };\n}\n\nexport const iconSizeMap: Record<PropSize, IconPropSize> = {\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'm',\n};\n"],"mappings":"qqBAuHA,MAAO,IAAMA,kBAA0D,CAAG,SACxEC,CADwE,QAErEA,EAAI,CAACC,EAFgE,CAAnE,CAGP,MAAO,IAAMC,oBAA8D,CAAG,SAC5EF,CAD4E,QAEzEA,EAAI,CAACG,KAFoE,CAAvE,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACJ,CAAD,QAAUA,EAAI,CAACK,OAAf,CAFG,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACN,CAAD,QAAUA,EAAI,CAACO,QAAf,CAFG,CAIP,MAAO,IAAMC,mBAA6D,CAAG,SAC3EC,CAD2E,QAExEA,EAAK,CAACR,EAFkE,CAAtE,CAGP,MAAO,IAAMS,qBAEZ,CAAG,SAACD,CAAD,QAAWA,EAAK,CAACN,KAAjB,CAFG,CAIP,MAAO,SAASQ,mBAAT,CACLC,CADK,CAEL,CACA,sCACKA,CADL,MAEEC,YAAY,CAAED,CAAK,CAACC,YAAN,EAAsBX,mBAFtC,CAGEY,UAAU,CAAEF,CAAK,CAACE,UAAN,EAAoBf,iBAHlC,CAIEgB,eAAe,CAAEH,CAAK,CAACG,eAAN,EAAyBX,sBAJ5C,CAKEY,eAAe,CAAEJ,CAAK,CAACI,eAAN,EAAyBV,sBAL5C,CAMEW,aAAa,CAAEL,CAAK,CAACK,aAAN,EAAuBP,oBANxC,CAOEQ,WAAW,CAAEN,CAAK,CAACM,WAAN,EAAqBV,kBAPpC,EASD,CAED,MAAO,IAAMW,YAA2C,CAAG,CACzDC,EAAE,CAAE,IADqD,CAEzDC,CAAC,CAAE,GAFsD,CAGzDC,CAAC,CAAE,GAHsD,CAIzDC,CAAC,CAAE,GAJsD,CAApD"}
@@ -1 +1 @@
1
- .Select{--caption-margin-left:calc(var(--input-space) + var(--control-border-width));--clear-button-color:var(--color-control-typo-clear);align-items:flex-start;display:flex;justify-content:flex-start;position:relative;width:100%}.Select_type_userselect.Select_size_s{--select-element-height:var(--space-xl)}.Select_type_userselect.Select_size_m{--select-element-height:calc(var(--space-2xl) - var(--space-3xs))}.Select_type_userselect.Select_size_l{--select-element-height:calc(var(--space-3xl) - var(--space-2xs))}.Select_type_combobox.Select_size_xs{--select-element-height:calc(var(--space-m) + var(--space-3xs))}.Select_type_combobox.Select_size_s{--select-element-height:var(--space-xl)}.Select_type_combobox.Select_size_m{--select-element-height:calc(var(--space-2xl) - var(--space-2xs))}.Select_type_combobox.Select_size_l{--select-element-height:var(--space-2xl)}.Select_type_select.Select_size_xs{--select-element-height:calc(var(--space-m) + var(--space-3xs))}.Select_type_select.Select_size_s{--select-element-height:var(--space-xl)}.Select_type_select.Select_size_m{--select-element-height:calc(var(--space-2xl) - var(--space-2xs))}.Select_type_select.Select_size_l{--select-element-height:var(--space-2xl)}.Select_size_xs{--label-offset:var(--space-2xs);--caption-offset:var(--space-2xs);--round-offset:calc(var(--space-3xs) + var(--space-2xs));--input-height:var(--control-height-xs);--input-space:calc(var(--control-space-xs)*0.5);--input-font-size:var(--control-text-size-xs);--tag-space:calc((var(--space-xs) - 1px)/2 - var(--control-border-width));--input-max-height:calc(var(--tag-space)*4 + var(--select-element-height)*4.5)}.Select_size_s{--label-offset:var(--space-2xs);--caption-offset:var(--space-2xs);--round-offset:calc(var(--space-2xs));--input-height:var(--control-height-s);--input-space:calc(var(--control-space-s)*0.5);--input-font-size:var(--control-text-size-s);--tag-space:calc(var(--space-xs)/2 - var(--control-border-width));--input-max-height:calc(var(--tag-space)*4 + var(--select-element-height)*4.5)}.Select_size_m{--label-offset:var(--space-xs);--caption-offset:var(--space-xs);--round-offset:calc(var(--space-3xs) + var(--space-2xs));--input-height:var(--control-height-m);--input-space:calc(var(--control-space-m)*0.5);--input-font-size:var(--control-text-size-m);--tag-space:calc(var(--space-s)/2 - var(--control-border-width));--input-max-height:calc(var(--tag-space)*4 + var(--space-2xl)*4.5 - var(--space-2xs)*4.5)}.Select_size_l{--label-offset:var(--space-xs);--caption-offset:var(--space-xs);--round-offset:calc(var(--space-xs));--input-height:var(--control-height-l);--input-space:calc(var(--control-space-l)*0.5);--input-font-size:var(--control-text-size-l);--tag-space:calc(var(--space-m)/2 - var(--control-border-width));--input-max-height:calc(var(--tag-space)*4 + var(--space-2xl)*4.5)}.Select_labelPosition_top{flex-direction:column}.Select_labelPosition_top>:not(:last-child){margin-bottom:var(--label-offset)}.Select_labelPosition_left{flex-direction:row}.Select_labelPosition_left .Select-Label{align-items:center;display:inline-flex;height:var(--input-height)}.Select_labelPosition_left>:not(:last-child){margin-right:var(--space-s)}.Select-Body{display:inline-flex;flex-direction:column;width:100%}.Select-Body .Select-Caption{margin-left:var(--caption-margin-left);margin-top:var(--caption-offset)}.Select-SelectContainer{--container-border-color:var(--color-control-bg-border-default);display:flex;position:relative;width:100%}.Select-SelectContainer_status_alert{--container-border-color:var(--color-bg-alert)}.Select-SelectContainer_status_success{--container-border-color:var(--color-bg-success)}.Select-SelectContainer_status_warning{--container-border-color:var(--color-bg-warning)}.Select-SelectContainer_view_default .Select-Control{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);padding:0}.Select-SelectContainer_view_default .Select-Control:hover{border-color:var(--color-control-bg-border-default-hover)}.Select-SelectContainer_view_default.Select-SelectContainer_focused .Select-Control{border-color:var(--color-control-bg-border-focus);outline:none}.Select-SelectContainer_multiple .Select-Control{height:auto;min-height:var(--input-height)}.Select-SelectContainer_form_round .Select-Control{border-radius:calc(var(--input-height)/2);padding-left:var(--round-offset)}.Select-SelectContainer_form_brick .Select-Control{border-radius:0}.Select-SelectContainer_form_clear .Select-Control{border-width:0;border-bottom-width:var(--control-border-width);border-radius:0}.Select-SelectContainer_form_defaultClear .Select-Control{border-radius:var(--control-radius) 0 0 var(--control-radius);border-right-width:0}.Select-SelectContainer_form_clearDefault .Select-Control{border-left-width:0;border-radius:0 var(--control-radius) var(--control-radius) 0}.Select-SelectContainer_form_defaultBrick .Select-Control{border-radius:var(--control-radius) 0 0 var(--control-radius)}.Select-SelectContainer_form_brickDefault .Select-Control{border-radius:0 var(--control-radius) var(--control-radius) 0}.Select-SelectContainer_form_roundBrick .Select-Control{border-radius:calc(var(--input-height)/2) 0 0 calc(var(--input-height)/2);padding-left:var(--round-offset)}.Select-SelectContainer_form_brickRound .Select-Control{border-radius:0 calc(var(--input-height)/2) calc(var(--input-height)/2) 0}.Select-SelectContainer_form_brickClear .Select-Control{border-radius:0;border-right-width:0}.Select-SelectContainer_form_clearBrick .Select-Control{border-left-width:0;border-radius:0}.Select-SelectContainer_form_clearRound .Select-Control{border-left-width:0;border-radius:0 calc(var(--input-height)/2) calc(var(--input-height)/2) 0}.Select-SelectContainer_form_roundClear .Select-Control{border-radius:calc(var(--input-height)/2) 0 0 calc(var(--input-height)/2);border-right-width:0;padding-left:var(--round-offset)}.Select-SelectContainer_form_clearClear .Select-Control{border-width:0;border-bottom-width:var(--control-border-width);border-radius:0;border-top-width:var(--control-border-width)}.Select-SelectContainer_view_default.Select-SelectContainer_form_clear.Select-SelectContainer_focused .Select-Control,.Select-SelectContainer_view_default.Select-SelectContainer_form_clearClear.Select-SelectContainer_focused .Select-Control{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)}.Select-SelectContainer_view_default.Select-SelectContainer_form_brickClear.Select-SelectContainer_focused .Select-Control,.Select-SelectContainer_view_default.Select-SelectContainer_form_defaultClear.Select-SelectContainer_focused .Select-Control,.Select-SelectContainer_view_default.Select-SelectContainer_form_roundClear.Select-SelectContainer_focused .Select-Control{box-shadow:var(--control-border-width) 0 var(--color-control-bg-border-focus)}.Select-SelectContainer_view_default.Select-SelectContainer_form_clearBrick.Select-SelectContainer_focused .Select-Control,.Select-SelectContainer_view_default.Select-SelectContainer_form_clearDefault.Select-SelectContainer_focused .Select-Control,.Select-SelectContainer_view_default.Select-SelectContainer_form_clearRound.Select-SelectContainer_focused .Select-Control{box-shadow:calc(var(--control-border-width)*-1) 0 var(--color-control-bg-border-focus)}.Select-SelectContainer_view_default.Select-SelectContainer_disabled .Select-Control{--clear-button-color:var(--color-control-typo-disable);background:var(--color-control-bg-disable);border-color:var(--color-control-bg-border-disable);color:var(--color-control-typo-disable);pointer-events:none}.Select-SelectContainer_view_clear .Select-Control,.Select-SelectContainer_view_clear .Select-Control:focus,.Select-SelectContainer_view_clear .Select-Control:hover{color:var(--color-control-typo-default);padding:0}.Select-SelectContainer_view_clear .Select-Control.Select-SelectContainer_disabled,.Select-SelectContainer_view_clear .Select-Control:focus.Select-SelectContainer_disabled,.Select-SelectContainer_view_clear .Select-Control:hover.Select-SelectContainer_disabled{pointer-events:none}.Select-SelectContainer_view_clear .Select-Control.Select-SelectContainer_disabled .Select-Control,.Select-SelectContainer_view_clear .Select-Control:focus.Select-SelectContainer_disabled .Select-Control,.Select-SelectContainer_view_clear .Select-Control:hover.Select-SelectContainer_disabled .Select-Control{color:var(--color-control-typo-disable)}.Select-SelectContainer_view_clear.Select-SelectContainer_disabled .Select-Control{pointer-events:none}.Select-SelectContainer_view_default .Select-ControlValueContainer{padding:0 0 0 var(--input-space)}.Select-SelectContainer_form_round .Select-SelectContainer-IndicatorsDropdown{border-radius:0 calc(var(--input-height)/2) calc(var(--input-height)/2) 0}.Select-SelectContainer_multiple .Select-ControlValueContainer{box-sizing:border-box;display:flex;line-height:1;padding-bottom:0;padding-top:0;position:relative}.Select-SelectContainer_multiple .Select-ControlValue{-ms-overflow-style:none;max-height:calc(var(--tag-space)*4 + var(--select-element-height)*4.5);overflow-x:visible;overflow-y:auto;padding-top:calc(var(--tag-space) - var(--control-border-width));scrollbar-width:none;white-space:normal}.Select-SelectContainer_multiple .Select-ControlValue::-webkit-scrollbar{display:none}.Select-SelectContainer_multiple .Select-ControlValue_isUserSelect{display:flex;flex-wrap:wrap;padding-top:calc(var(--space-s)/4)}.Select_view_clear{--caption-margin-left:0}.Select-Delimiter{background-color:var(--color-control-bg-border-default);width:1px}.Select-Control{background:transparent;border:none;box-sizing:border-box;color:currentColor;cursor:pointer;display:inline-flex;font-family:var(--font-primary);font-weight:var(--font-weight-text-regular);height:var(--input-height);line-height:calc(var(--input-height) - var(--control-border-width));outline:none;padding:0;transition:border-color .15s,box-shadow .15s,background-color .15s;width:100%}.Select-Control:focus{outline:none}.Select-SelectAll.Text{line-height:calc(var(--input-height) - var(--space-3xs))}.Select-Indicators{display:flex;height:100%}.Select-IndicatorsDropdown{background-color:transparent;border:none;color:var(--color-control-typo-placeholder);cursor:pointer;display:block;margin:0;padding:0;text-align:center;width:var(--input-height)}.Select-IndicatorsDropdown:focus{outline:none}.Select-ControlInner{position:relative;width:100%}.Select-ControlValueContainer{background-color:transparent;border:none;bottom:0;color:inherit;font-size:var(--input-font-size);left:0;line-height:calc(var(--input-height) - 2px);margin:0;min-height:calc(var(--input-height) - 2px);padding:0;position:absolute;right:0;text-align:left;top:0}.Select-ControlValueContainer:focus{outline:none}.Select-Control[aria-expanded=true] .Select-IndicatorsDropdown{transform:rotate(180deg)}.Select-ControlValue,.Select-Placeholder{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.Select-Placeholder{color:var(--color-control-typo-placeholder);font-size:var(--input-font-size);padding-right:var(--input-space);pointer-events:none;text-align:left}.Select-Placeholder_isHidden{opacity:0;visibility:hidden}.Select-Control_hasInput .Select-Placeholder{background-color:transparent;line-height:calc(var(--input-height) - 2px);position:absolute;top:0;width:calc(100% - var(--input-space))}.Select-DropdownIndicatorIcon{position:relative;top:1px}.Select-ClearIndicator{background-color:transparent;border:none;color:var(--clear-button-color);cursor:pointer;display:flex;flex-direction:column;height:100%;justify-content:center;margin:0;min-height:calc(var(--input-height) - var(--control-border-width)*2);padding:0 var(--space-xs)}.Select-ClearIndicator:hover{--clear-button-color:var(--color-control-typo-clear-hover)}.Select-ClearIndicatorIcon{color:var(--color-control-typo-placeholder);position:relative;top:1px}.Select-Input{background-color:transparent;border:none;color:inherit;font-family:inherit;font-size:inherit;line-height:calc(var(--input-height) - 2px);margin:0;outline:none;padding:0;position:relative;width:100%}.Select-Input_hide{bottom:0;left:0;opacity:0;position:absolute;top:0;width:100%}.Select-Input_multiple{display:inline-flex;height:calc(var(--input-height) - var(--control-border-width)*2);line-height:1;line-height:calc(var(--input-height) - var(--control-border-width)*2);margin-top:calc(var(--tag-space)*-1);min-width:10px}.Select-Input_multiple.Select-Input_isUserSelect{margin-top:calc(var(--space-s)/4*-1)}.Select-FakeField{bottom:0;left:0;opacity:0;position:absolute;top:0;width:100%}.Select-HelperInputFakeElement{display:inline-block;font-size:var(--input-font-size);height:0;overflow:hidden;position:absolute;top:0;visibility:hidden;white-space:nowrap}
1
+ .Select{--caption-margin-left:var(--control-border-width);--clear-button-color:var(--color-control-typo-clear);align-items:flex-start;display:flex;justify-content:flex-start;position:relative;width:100%}.Select_type_userselect.Select_size_s{--select-element-height:var(--space-xl)}.Select_type_userselect.Select_size_m{--select-element-height:calc(var(--space-2xl) - var(--space-3xs))}.Select_type_userselect.Select_size_l{--select-element-height:calc(var(--space-3xl) - var(--space-2xs))}.Select_type_combobox.Select_size_xs{--select-element-height:calc(var(--space-m) + var(--space-3xs))}.Select_type_combobox.Select_size_s{--select-element-height:var(--space-xl)}.Select_type_combobox.Select_size_m{--select-element-height:calc(var(--space-2xl) - var(--space-2xs))}.Select_type_combobox.Select_size_l{--select-element-height:var(--space-2xl)}.Select_type_select.Select_size_xs{--select-element-height:calc(var(--space-m) + var(--space-3xs))}.Select_type_select.Select_size_s{--select-element-height:var(--space-xl)}.Select_type_select.Select_size_m{--select-element-height:calc(var(--space-2xl) - var(--space-2xs))}.Select_type_select.Select_size_l{--select-element-height:var(--space-2xl)}.Select_size_xs{--label-offset:var(--space-2xs);--caption-offset:var(--space-2xs);--round-offset:calc(var(--space-3xs) + var(--space-2xs));--input-height:var(--control-height-xs);--input-space:calc(var(--control-space-xs)*0.5);--input-font-size:var(--control-text-size-xs);--tag-space:calc((var(--space-xs) - 1px)/2 - var(--control-border-width));--input-max-height:calc(var(--tag-space)*4 + var(--select-element-height)*4.5)}.Select_size_s{--label-offset:var(--space-2xs);--caption-offset:var(--space-2xs);--round-offset:calc(var(--space-2xs));--input-height:var(--control-height-s);--input-space:calc(var(--control-space-s)*0.5);--input-font-size:var(--control-text-size-s);--tag-space:calc(var(--space-xs)/2 - var(--control-border-width));--input-max-height:calc(var(--tag-space)*4 + var(--select-element-height)*4.5)}.Select_size_m{--label-offset:var(--space-xs);--caption-offset:var(--space-xs);--round-offset:calc(var(--space-3xs) + var(--space-2xs));--input-height:var(--control-height-m);--input-space:calc(var(--control-space-m)*0.5);--input-font-size:var(--control-text-size-m);--tag-space:calc(var(--space-s)/2 - var(--control-border-width));--input-max-height:calc(var(--tag-space)*4 + var(--space-2xl)*4.5 - var(--space-2xs)*4.5)}.Select_size_l{--label-offset:var(--space-xs);--caption-offset:var(--space-xs);--round-offset:calc(var(--space-xs));--input-height:var(--control-height-l);--input-space:calc(var(--control-space-l)*0.5);--input-font-size:var(--control-text-size-l);--tag-space:calc(var(--space-m)/2 - var(--control-border-width));--input-max-height:calc(var(--tag-space)*4 + var(--space-2xl)*4.5)}.Select_labelPosition_top{flex-direction:column}.Select_labelPosition_top>:not(:last-child){margin-bottom:var(--label-offset)}.Select_labelPosition_left{flex-direction:row}.Select_labelPosition_left .Select-Label{align-items:center;display:inline-flex;height:var(--input-height)}.Select_labelPosition_left>:not(:last-child){margin-right:var(--space-s)}.Select-Body{display:inline-flex;flex-direction:column;width:100%}.Select-Body .Select-Caption{margin-left:var(--caption-margin-left);margin-top:var(--caption-offset)}.Select-SelectContainer{--container-border-color:var(--color-control-bg-border-default);display:flex;position:relative;width:100%}.Select-SelectContainer_status_alert{--container-border-color:var(--color-bg-alert)}.Select-SelectContainer_status_success{--container-border-color:var(--color-bg-success)}.Select-SelectContainer_status_warning{--container-border-color:var(--color-bg-warning)}.Select-SelectContainer_view_default .Select-Control{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);padding:0}.Select-SelectContainer_view_default .Select-Control:hover{border-color:var(--color-control-bg-border-default-hover)}.Select-SelectContainer_view_default.Select-SelectContainer_focused .Select-Control{border-color:var(--color-control-bg-border-focus);outline:none}.Select-SelectContainer_multiple .Select-Control{height:auto;min-height:var(--input-height)}.Select-SelectContainer_form_round .Select-Control{border-radius:calc(var(--input-height)/2);padding-left:var(--round-offset)}.Select-SelectContainer_form_brick .Select-Control{border-radius:0}.Select-SelectContainer_form_clear .Select-Control{border-width:0;border-bottom-width:var(--control-border-width);border-radius:0}.Select-SelectContainer_form_defaultClear .Select-Control{border-radius:var(--control-radius) 0 0 var(--control-radius);border-right-width:0}.Select-SelectContainer_form_clearDefault .Select-Control{border-left-width:0;border-radius:0 var(--control-radius) var(--control-radius) 0}.Select-SelectContainer_form_defaultBrick .Select-Control{border-radius:var(--control-radius) 0 0 var(--control-radius)}.Select-SelectContainer_form_brickDefault .Select-Control{border-radius:0 var(--control-radius) var(--control-radius) 0}.Select-SelectContainer_form_roundBrick .Select-Control{border-radius:calc(var(--input-height)/2) 0 0 calc(var(--input-height)/2);padding-left:var(--round-offset)}.Select-SelectContainer_form_brickRound .Select-Control{border-radius:0 calc(var(--input-height)/2) calc(var(--input-height)/2) 0}.Select-SelectContainer_form_brickClear .Select-Control{border-radius:0;border-right-width:0}.Select-SelectContainer_form_clearBrick .Select-Control{border-left-width:0;border-radius:0}.Select-SelectContainer_form_clearRound .Select-Control{border-left-width:0;border-radius:0 calc(var(--input-height)/2) calc(var(--input-height)/2) 0}.Select-SelectContainer_form_roundClear .Select-Control{border-radius:calc(var(--input-height)/2) 0 0 calc(var(--input-height)/2);border-right-width:0;padding-left:var(--round-offset)}.Select-SelectContainer_form_clearClear .Select-Control{border-width:0;border-bottom-width:var(--control-border-width);border-radius:0;border-top-width:var(--control-border-width)}.Select-SelectContainer_view_default.Select-SelectContainer_form_clear.Select-SelectContainer_focused .Select-Control,.Select-SelectContainer_view_default.Select-SelectContainer_form_clearClear.Select-SelectContainer_focused .Select-Control{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)}.Select-SelectContainer_view_default.Select-SelectContainer_form_brickClear.Select-SelectContainer_focused .Select-Control,.Select-SelectContainer_view_default.Select-SelectContainer_form_defaultClear.Select-SelectContainer_focused .Select-Control,.Select-SelectContainer_view_default.Select-SelectContainer_form_roundClear.Select-SelectContainer_focused .Select-Control{box-shadow:var(--control-border-width) 0 var(--color-control-bg-border-focus)}.Select-SelectContainer_view_default.Select-SelectContainer_form_clearBrick.Select-SelectContainer_focused .Select-Control,.Select-SelectContainer_view_default.Select-SelectContainer_form_clearDefault.Select-SelectContainer_focused .Select-Control,.Select-SelectContainer_view_default.Select-SelectContainer_form_clearRound.Select-SelectContainer_focused .Select-Control{box-shadow:calc(var(--control-border-width)*-1) 0 var(--color-control-bg-border-focus)}.Select-SelectContainer_view_default.Select-SelectContainer_disabled .Select-Control{--clear-button-color:var(--color-control-typo-disable);background:var(--color-control-bg-disable);border-color:var(--color-control-bg-border-disable);color:var(--color-control-typo-disable);pointer-events:none}.Select-SelectContainer_view_clear .Select-Control,.Select-SelectContainer_view_clear .Select-Control:focus,.Select-SelectContainer_view_clear .Select-Control:hover{color:var(--color-control-typo-default);padding:0}.Select-SelectContainer_view_clear .Select-Control.Select-SelectContainer_disabled,.Select-SelectContainer_view_clear .Select-Control:focus.Select-SelectContainer_disabled,.Select-SelectContainer_view_clear .Select-Control:hover.Select-SelectContainer_disabled{pointer-events:none}.Select-SelectContainer_view_clear .Select-Control.Select-SelectContainer_disabled .Select-Control,.Select-SelectContainer_view_clear .Select-Control:focus.Select-SelectContainer_disabled .Select-Control,.Select-SelectContainer_view_clear .Select-Control:hover.Select-SelectContainer_disabled .Select-Control{color:var(--color-control-typo-disable)}.Select-SelectContainer_view_clear.Select-SelectContainer_disabled .Select-Control{pointer-events:none}.Select-SelectContainer_view_default .Select-ControlValueContainer{padding:0 0 0 var(--input-space)}.Select-SelectContainer_form_round .Select-SelectContainer-IndicatorsDropdown{border-radius:0 calc(var(--input-height)/2) calc(var(--input-height)/2) 0}.Select-SelectContainer_multiple .Select-ControlValueContainer{box-sizing:border-box;display:flex;line-height:1;padding-bottom:0;padding-top:0;position:relative}.Select-SelectContainer_multiple .Select-ControlValue{-ms-overflow-style:none;max-height:calc(var(--tag-space)*4 + var(--select-element-height)*4.5);overflow-x:visible;overflow-y:auto;padding-top:calc(var(--tag-space) - var(--control-border-width));scrollbar-width:none;white-space:normal}.Select-SelectContainer_multiple .Select-ControlValue::-webkit-scrollbar{display:none}.Select-SelectContainer_multiple .Select-ControlValue_isUserSelect{display:flex;flex-wrap:wrap;padding-top:calc(var(--space-s)/4)}.Select_view_clear{--caption-margin-left:0}.Select-Delimiter{background-color:var(--color-control-bg-border-default);width:1px}.Select-Control{background:transparent;border:none;box-sizing:border-box;color:currentColor;cursor:pointer;display:inline-flex;font-family:var(--font-primary);font-weight:var(--font-weight-text-regular);height:var(--input-height);line-height:calc(var(--input-height) - var(--control-border-width));outline:none;padding:0;transition:border-color .15s,box-shadow .15s,background-color .15s;width:100%}.Select-Control:focus{outline:none}.Select-SelectAll.Text{line-height:calc(var(--input-height) - var(--space-3xs))}.Select-Indicators{display:flex;height:100%}.Select-IndicatorsDropdown{background-color:transparent;border:none;color:var(--color-control-typo-placeholder);cursor:pointer;display:block;margin:0;padding:0;text-align:center;width:var(--input-height)}.Select-IndicatorsDropdown:focus{outline:none}.Select-ControlInner{position:relative;width:100%}.Select-ControlValueContainer{background-color:transparent;border:none;bottom:0;color:inherit;font-size:var(--input-font-size);left:0;line-height:calc(var(--input-height) - 2px);margin:0;min-height:calc(var(--input-height) - 2px);padding:0;position:absolute;right:0;text-align:left;top:0}.Select-ControlValueContainer:focus{outline:none}.Select-Control[aria-expanded=true] .Select-IndicatorsDropdown{transform:rotate(180deg)}.Select-ControlValue,.Select-Placeholder{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.Select-Placeholder{color:var(--color-control-typo-placeholder);font-size:var(--input-font-size);padding-right:var(--input-space);pointer-events:none;text-align:left}.Select-Placeholder_isHidden{opacity:0;visibility:hidden}.Select-Control_hasInput .Select-Placeholder{background-color:transparent;line-height:calc(var(--input-height) - 2px);position:absolute;top:0;width:calc(100% - var(--input-space))}.Select-DropdownIndicatorIcon{position:relative;top:1px}.Select-ClearIndicator{background-color:transparent;border:none;color:var(--clear-button-color);cursor:pointer;display:flex;flex-direction:column;height:100%;justify-content:center;margin:0;min-height:calc(var(--input-height) - var(--control-border-width)*2);padding:0 var(--space-xs)}.Select-ClearIndicator:hover{--clear-button-color:var(--color-control-typo-clear-hover)}.Select-ClearIndicatorIcon{color:var(--color-control-typo-placeholder);position:relative;top:1px}.Select-Input{background-color:transparent;border:none;color:inherit;font-family:inherit;font-size:inherit;line-height:calc(var(--input-height) - 2px);margin:0;outline:none;padding:0;position:relative;width:100%}.Select-Input_hide{bottom:0;left:0;opacity:0;position:absolute;top:0;width:100%}.Select-Input_multiple{display:inline-flex;height:calc(var(--input-height) - var(--control-border-width)*2);line-height:1;line-height:calc(var(--input-height) - var(--control-border-width)*2);margin-top:calc(var(--tag-space)*-1);min-width:10px}.Select-Input_multiple.Select-Input_isUserSelect{margin-top:calc(var(--space-s)/4*-1)}.Select-FakeField{bottom:0;left:0;opacity:0;position:absolute;top:0;width:100%}.Select-HelperInputFakeElement{display:inline-block;font-size:var(--input-font-size);height:0;overflow:hidden;position:absolute;top:0;visibility:hidden;white-space:nowrap}
@@ -34,7 +34,7 @@ declare type Props<ITEM, GROUP> = PropsWithJsxAttributes<{
34
34
  hasItems?: boolean;
35
35
  itemsRefs: React.RefObject<HTMLDivElement>[];
36
36
  virtualScroll?: boolean;
37
- onScrollToBottom?: () => void;
37
+ onScrollToBottom?: (lenght: number) => void;
38
38
  }>;
39
39
  declare type SelectDropdown = <ITEM, GROUP>(props: Props<ITEM, GROUP>) => React.ReactElement | null;
40
40
  export declare const SelectDropdown: SelectDropdown;
@@ -1,2 +1,2 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["controlRef","size","getOptionProps","dropdownRef","labelForCreate","className","labelForNotFound","labelForEmptyItems","hasItems","form","isOpen","offset","renderItem","visibleItems","isLoading","getGroupLabel","notFound","itemsRefs","virtualScroll","onScrollToBottom"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./SelectDropdown.css";import React,{Fragment,useEffect,useMemo,useRef}from"react";import{Transition}from"react-transition-group";import{cnListBox,ListItem,ListLoader,mapVerticalSpase}from"../../ListCanary";import{Popover}from"../../Popover";import{useDebounce}from"../../../hooks/useDebounce";import{useFlag}from"../../../hooks/useFlag";import{forkRef,useForkRef}from"../../../hooks/useForkRef";import{useVirtualScroll}from"../../../hooks/useVirtualScroll";import{animateTimeout,cnMixPopoverAnimate}from"../../../mixs/MixPopoverAnimate/MixPopoverAnimate";import{cnMixScrollBar}from"../../../mixs/MixScrollBar";import{cnMixSpace}from"../../../mixs/MixSpace";import{cn}from"../../../utils/bem";import{fabricIndex}from"../../../utils/fabricIndex";import{SelectCreateButton}from"../SelectCreateButton/SelectCreateButton";import{SelectGroupLabel}from"../SelectGroupLabel/SelectGroupLabel";import{SelectItemAll}from"../SelectItemAll/SelectItemAll";import{SelectLoader}from"../SelectLoader/SelectLoader";import{isNotOptionForCreate,isOptionForCreate,isOptionForSelectAll}from"../useSelect";export var selectDropdownform=["default","brick","round"];export var defaultSelectDropdownPropForm=selectDropdownform[0];var cnSelectDropdown=cn("SelectDropdown"),getLenghtElements=function(a){for(var b,c=1>=a.length?0:a.length,d=0;d<a.length;d++)b=a[d],isNotOptionForCreate(b)&&b.items.length&&(c+=b.items.length);return c},isVisible=function(a,b){return b>=a[0]&&b<a[1]};export var SelectDropdown=function(a){var b=a.controlRef,c=a.size,d=a.getOptionProps,e=a.dropdownRef,f=a.labelForCreate,g=a.className,h=a.labelForNotFound,i=a.labelForEmptyItems,j=a.hasItems,k=void 0===j||j,l=a.form,m=a.isOpen,n=a.offset,o=void 0===n?"none":n,p=a.renderItem,q=a.visibleItems,r=a.isLoading,s=a.getGroupLabel,t=a.notFound,u=a.itemsRefs,v=a.virtualScroll,w=a.onScrollToBottom,x=_objectWithoutProperties(a,_excluded),y="round"===l?"increased":"normal",z=useMemo(function(){return 0<q.filter(function(a){return isOptionForCreate(a)||Array.isArray(a.items)&&0<a.items.length}).length},[q]),A="none"===o?void 0:o,B=useMemo(function(){return getLenghtElements(q)},[q]),C=useVirtualScroll({length:B,isActive:v&&m,onScrollToBottom:w}),D=C.spaceTop,E=C.slice,F=C.listRefs,G=C.scrollElementRef,H=0===E[0]&&v?[0,50]:E,I=useRef(null),J=useForkRef([G,e]),K=useFlag(),L=_slicedToArray(K,2),M=L[0],N=L[1],O=useDebounce(N.off,100);return useEffect(function(){var a,b=function(){N.on(),O()};return null===(a=G.current)||void 0===a?void 0:a.addEventListener("scroll",b),function(){var a;null===(a=G.current)||void 0===a?void 0:a.removeEventListener("scroll",b)}},[G.current]),React.createElement(Transition,{in:m,unmountOnExit:!0,nodeRef:I,timeout:animateTimeout},function(a){var e=fabricIndex(),j=fabricIndex();return React.createElement(Popover,Object.assign({},x,{anchorRef:b,direction:"downStartLeft",possibleDirections:["downStartLeft","upStartLeft","downStartRight","upStartRight"],offset:A,ref:I,role:"listbox",className:cnSelectDropdown(null,[cnListBox({size:c,form:l,border:!0,shadow:!0}),cnMixPopoverAnimate({animate:a}),g]),equalAnchorWidth:!0}),React.createElement("div",{className:cnSelectDropdown("ScrollContainer",[cnMixSpace({pV:mapVerticalSpase[c]}),cnMixScrollBar()]),ref:J},r&&!z&&React.createElement(SelectLoader,null),React.createElement("div",{className:cnSelectDropdown("List",{scrolled:M}),style:{marginTop:D}},q.map(function(a){if(isOptionForCreate(a)){var g=e();return React.createElement(SelectCreateButton,Object.assign({size:c,labelForCreate:f,inputValue:a.label,indent:y,ref:u[g]},d({index:g,item:a,keyPrefix:D})))}var b=1<q.length?j():0;return React.createElement(Fragment,{key:a.key},a.group&&s&&isVisible(H,b)&&React.createElement(SelectGroupLabel,{label:s(a.group),size:c,indent:y,ref:F[b],key:"group".concat(a.key).concat(D)}),a.items.map(function(b,f){if(isOptionForSelectAll(b)){var g=j(),h=e();if(isVisible(H,g))return React.createElement(SelectItemAll,Object.assign({ref:forkRef([F[g],u[h]]),indent:y,size:c},d({index:h,item:b,keyPrefix:D}),{intermediate:!!(b.checkedCount&&b.totalCount)&&b.checkedCount!==b.totalCount,checked:b.checkedCount===b.totalCount,countItems:b.checkedCount,total:b.totalCount}))}else{var i=j(),k=e();if(isVisible(H,i))return React.createElement(Fragment,{key:"".concat(a.key,"-").concat(f)},p(_objectSpread({ref:forkRef([F[i],u[k]]),item:b},d({index:k,item:b,keyPrefix:D}))))}}))}),r&&z&&React.createElement(ListLoader,{size:c,innerOffset:y})),!r&&k&&t&&h&&React.createElement(ListItem,{size:c,label:h,innerOffset:y},h),!r&&!k&&i&&React.createElement(ListItem,{size:c,label:i,innerOffset:y},i)))})};
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["controlRef","size","getOptionProps","dropdownRef","labelForCreate","className","labelForNotFound","labelForEmptyItems","hasItems","form","isOpen","offset","renderItem","visibleItems","isLoading","getGroupLabel","notFound","itemsRefs","virtualScroll","onScrollToBottom"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./SelectDropdown.css";import React,{Fragment,useEffect,useMemo,useRef}from"react";import{Transition}from"react-transition-group";import{cnListBox,ListItem,ListLoader,mapVerticalSpase}from"../../ListCanary";import{Popover}from"../../Popover";import{useDebounce}from"../../../hooks/useDebounce";import{useFlag}from"../../../hooks/useFlag";import{forkRef,useForkRef}from"../../../hooks/useForkRef";import{useVirtualScroll}from"../../../hooks/useVirtualScroll";import{animateTimeout,cnMixPopoverAnimate}from"../../../mixs/MixPopoverAnimate/MixPopoverAnimate";import{cnMixScrollBar}from"../../../mixs/MixScrollBar";import{cnMixSpace}from"../../../mixs/MixSpace";import{cn}from"../../../utils/bem";import{fabricIndex}from"../../../utils/fabricIndex";import{SelectCreateButton}from"../SelectCreateButton/SelectCreateButton";import{SelectGroupLabel}from"../SelectGroupLabel/SelectGroupLabel";import{SelectItemAll}from"../SelectItemAll/SelectItemAll";import{SelectLoader}from"../SelectLoader/SelectLoader";import{isNotOptionForCreate,isOptionForCreate,isOptionForSelectAll}from"../useSelect";export var selectDropdownform=["default","brick","round"];export var defaultSelectDropdownPropForm=selectDropdownform[0];var cnSelectDropdown=cn("SelectDropdown"),getLenghtElements=function(a){for(var b,c=1>=a.length?0:a.length,d=0;d<a.length;d++)b=a[d],isNotOptionForCreate(b)&&b.items.length&&(c+=b.items.length);return c},isVisible=function(a,b){return b>=a[0]&&b<a[1]};export var SelectDropdown=function(a){var b=a.controlRef,c=a.size,d=a.getOptionProps,e=a.dropdownRef,f=a.labelForCreate,g=a.className,h=a.labelForNotFound,i=a.labelForEmptyItems,j=a.hasItems,k=void 0===j||j,l=a.form,m=a.isOpen,n=a.offset,o=void 0===n?"none":n,p=a.renderItem,q=a.visibleItems,r=a.isLoading,s=a.getGroupLabel,t=a.notFound,u=a.itemsRefs,v=a.virtualScroll,w=a.onScrollToBottom,x=_objectWithoutProperties(a,_excluded),y="round"===l?"increased":"normal",z=useMemo(function(){return 0<q.filter(function(a){return isOptionForCreate(a)||Array.isArray(a.items)&&0<a.items.length}).length},[q]),A="none"===o?void 0:o,B=useMemo(function(){return getLenghtElements(q)},[q]),C=useVirtualScroll({length:B,isActive:v&&m,onScrollToBottom:w}),D=C.spaceTop,E=C.slice,F=C.listRefs,G=C.scrollElementRef,H=0===E[0]&&v?[0,50]:E,I=useRef(null),J=useForkRef([G,e]),K=useFlag(),L=_slicedToArray(K,2),M=L[0],N=L[1],O=useDebounce(N.off,100);return useEffect(function(){var a,b=function(){N.on(),O()};return null===(a=G.current)||void 0===a?void 0:a.addEventListener("scroll",b),function(){var a;null===(a=G.current)||void 0===a?void 0:a.removeEventListener("scroll",b)}},[G.current]),React.createElement(Transition,{in:m,unmountOnExit:!0,nodeRef:I,timeout:animateTimeout},function(a){var e=fabricIndex(),j=fabricIndex();return React.createElement(Popover,Object.assign({},x,{anchorRef:b,direction:"downStartLeft",possibleDirections:["downStartLeft","upStartLeft","downStartRight","upStartRight"],offset:A,ref:I,role:"listbox",className:cnSelectDropdown(null,[cnListBox({size:c,form:l,border:!0,shadow:!0}),cnMixPopoverAnimate({animate:a}),g]),equalAnchorWidth:!0}),React.createElement("div",{className:cnSelectDropdown("ScrollContainer",[cnMixSpace({pV:mapVerticalSpase[c]}),cnMixScrollBar()]),ref:J},r&&!z&&React.createElement(SelectLoader,null),React.createElement("div",{className:cnSelectDropdown("List",{scrolled:M}),style:{marginTop:D}},q.map(function(a,b){if(isOptionForCreate(a)){var h=e();return React.createElement(SelectCreateButton,Object.assign({size:c,labelForCreate:f,inputValue:a.label,indent:y,ref:u[h]},d({index:h,item:a,keyPrefix:b})))}var g=1<q.length?j():0;return React.createElement(Fragment,{key:a.key},a.group&&s&&isVisible(H,g)&&React.createElement(SelectGroupLabel,{label:s(a.group),size:c,indent:y,ref:F[g],key:"group-".concat(a.key)}),a.items.map(function(b,f){if(isOptionForSelectAll(b)){var g=j(),h=e();if(isVisible(H,g))return React.createElement(SelectItemAll,Object.assign({ref:forkRef([F[g],u[h]]),indent:y,size:c},d({index:h,item:b,keyPrefix:f}),{intermediate:!!(b.checkedCount&&b.totalCount)&&b.checkedCount!==b.totalCount,checked:b.checkedCount===b.totalCount,countItems:b.checkedCount,total:b.totalCount}))}else{var i=j(),k=e();if(isVisible(H,i))return React.createElement(Fragment,{key:"".concat(a.key,"-").concat(f)},p(_objectSpread({ref:forkRef([F[i],u[k]]),item:b},d({index:k,item:b,keyPrefix:f}))))}}))}),r&&z&&React.createElement(ListLoader,{size:c,innerOffset:y})),!r&&k&&t&&h&&React.createElement(ListItem,{size:c,label:h,innerOffset:y},h),!r&&!k&&i&&React.createElement(ListItem,{size:c,label:i,innerOffset:y},i)))})};
2
2
  //# sourceMappingURL=SelectDropdown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectDropdown.js","names":["React","Fragment","useEffect","useMemo","useRef","Transition","cnListBox","ListItem","ListLoader","mapVerticalSpase","Popover","useDebounce","useFlag","forkRef","useForkRef","useVirtualScroll","animateTimeout","cnMixPopoverAnimate","cnMixScrollBar","cnMixSpace","cn","fabricIndex","SelectCreateButton","SelectGroupLabel","SelectItemAll","SelectLoader","isNotOptionForCreate","isOptionForCreate","isOptionForSelectAll","selectDropdownform","defaultSelectDropdownPropForm","cnSelectDropdown","getLenghtElements","elements","element","lenght","length","index","items","isVisible","slise","SelectDropdown","props","controlRef","size","getOptionProps","dropdownRefProp","dropdownRef","labelForCreate","className","labelForNotFound","labelForEmptyItems","hasItems","form","isOpen","offset","offsetProp","renderItem","visibleItems","isLoading","getGroupLabel","notFound","itemsRefs","virtualScroll","onScrollToBottom","otherProps","indent","isListShowed","filter","group","Array","isArray","lengthForVirtualScroll","isActive","spaceTop","sliceHookProp","slice","listRefs","scrollElementRef","popoverRef","scrolled","setScroled","setScroledOffDebouns","off","fn","on","current","addEventListener","removeEventListener","animate","getIndex","getVirtualIndex","border","shadow","pV","marginTop","map","label","item","keyPrefix","virtualIndex","key","i","checkedCount","totalCount","ref"],"sources":["../../../../../../src/components/SelectComponents/SelectDropdown/SelectDropdown.tsx"],"sourcesContent":["import './SelectDropdown.css';\n\nimport React, { Fragment, useEffect, useMemo, useRef } from 'react';\nimport { Transition } from 'react-transition-group';\n\nimport {\n cnListBox,\n ListItem,\n ListLoader,\n mapVerticalSpase,\n} from '##/components/ListCanary';\nimport { Popover, PopoverPropOffset } from '##/components/Popover';\nimport { useDebounce } from '##/hooks/useDebounce';\nimport { useFlag } from '##/hooks/useFlag';\nimport { forkRef, useForkRef } from '##/hooks/useForkRef';\nimport { useVirtualScroll } from '##/hooks/useVirtualScroll';\nimport {\n animateTimeout,\n cnMixPopoverAnimate,\n} from '##/mixs/MixPopoverAnimate/MixPopoverAnimate';\nimport { cnMixScrollBar } from '##/mixs/MixScrollBar';\nimport { cnMixSpace } from '##/mixs/MixSpace';\nimport { cn } from '##/utils/bem';\nimport { fabricIndex } from '##/utils/fabricIndex';\nimport { SelectAllItem } from '##/utils/getGroups';\nimport { PropsWithJsxAttributes } from '##/utils/types/PropsWithJsxAttributes';\n\nimport { SelectCreateButton } from '../SelectCreateButton/SelectCreateButton';\nimport { SelectGroupLabel } from '../SelectGroupLabel/SelectGroupLabel';\nimport { SelectItemAll } from '../SelectItemAll/SelectItemAll';\nimport { SelectLoader } from '../SelectLoader/SelectLoader';\nimport { PropSize, RenderItemProps } from '../types';\nimport {\n GetOptionPropsResult,\n isNotOptionForCreate,\n isOptionForCreate,\n isOptionForSelectAll,\n OptionForCreate,\n OptionProps,\n} from '../useSelect';\n\nexport const selectDropdownform = ['default', 'brick', 'round'] as const;\nexport type SelectDropdownPropForm = typeof selectDropdownform[number];\nexport const defaultSelectDropdownPropForm = selectDropdownform[0];\n\ntype Props<ITEM, GROUP> = PropsWithJsxAttributes<{\n size: PropSize;\n controlRef: React.MutableRefObject<HTMLDivElement | null>;\n dropdownRef: React.Ref<HTMLDivElement>;\n getOptionProps(props: OptionProps<ITEM>): GetOptionPropsResult;\n form: SelectDropdownPropForm;\n isOpen: boolean;\n offset?: PopoverPropOffset | 'none';\n isLoading?: boolean;\n renderItem: (props: RenderItemProps<ITEM>) => JSX.Element | null;\n visibleItems: (\n | OptionForCreate\n | {\n items: Array<SelectAllItem | ITEM>;\n key: string | number;\n group?: GROUP;\n groupIndex: number;\n checkedCount?: number;\n totalCount?: number;\n }\n )[];\n getGroupLabel?: (group: GROUP) => string;\n labelForCreate?: string;\n labelForNotFound?: string;\n labelForEmptyItems?: string;\n notFound?: boolean;\n hasItems?: boolean;\n itemsRefs: React.RefObject<HTMLDivElement>[];\n virtualScroll?: boolean;\n onScrollToBottom?: () => void;\n}>;\n\ntype SelectDropdown = <ITEM, GROUP>(\n props: Props<ITEM, GROUP>,\n) => React.ReactElement | null;\n\nconst cnSelectDropdown = cn('SelectDropdown');\n\nconst getLenghtElements = <ITEM, GROUP>(\n elements: (\n | OptionForCreate\n | {\n items: Array<SelectAllItem | ITEM>;\n key: string | number;\n group?: GROUP;\n groupIndex: number;\n checkedCount?: number;\n totalCount?: number;\n }\n )[],\n) => {\n let lenght = elements.length <= 1 ? 0 : elements.length;\n\n for (let index = 0; index < elements.length; index++) {\n const element = elements[index];\n\n if (isNotOptionForCreate(element) && element.items.length) {\n lenght += element.items.length;\n }\n }\n\n return lenght;\n};\n\nconst isVisible = (slise: [number, number], index: number) => {\n return index >= slise[0] && index < slise[1];\n};\n\nexport const SelectDropdown: SelectDropdown = (props) => {\n const {\n controlRef,\n size,\n getOptionProps,\n dropdownRef: dropdownRefProp,\n labelForCreate,\n className,\n labelForNotFound,\n labelForEmptyItems,\n hasItems = true,\n form,\n isOpen,\n offset: offsetProp = 'none',\n renderItem,\n visibleItems,\n isLoading,\n getGroupLabel,\n notFound,\n itemsRefs,\n virtualScroll,\n onScrollToBottom,\n ...otherProps\n } = props;\n\n const indent = form === 'round' ? 'increased' : 'normal';\n\n const isListShowed = useMemo(() => {\n return (\n visibleItems.filter(\n (group) =>\n isOptionForCreate(group) ||\n (Array.isArray(group.items) && group.items.length > 0),\n ).length > 0\n );\n }, [visibleItems]);\n\n const offset = offsetProp === 'none' ? undefined : offsetProp;\n\n const lengthForVirtualScroll = useMemo(\n () => getLenghtElements(visibleItems),\n [visibleItems],\n );\n\n const {\n spaceTop,\n slice: sliceHookProp,\n listRefs,\n scrollElementRef,\n } = useVirtualScroll({\n length: lengthForVirtualScroll,\n isActive: virtualScroll && isOpen,\n onScrollToBottom,\n });\n\n const slice: [number, number] =\n sliceHookProp[0] === 0 && virtualScroll ? [0, 50] : sliceHookProp;\n\n const popoverRef = useRef<HTMLDivElement>(null);\n const dropdownRef = useForkRef([scrollElementRef, dropdownRefProp]);\n const [scrolled, setScroled] = useFlag();\n const setScroledOffDebouns = useDebounce(setScroled.off, 100);\n\n useEffect(() => {\n const fn = () => {\n setScroled.on();\n setScroledOffDebouns();\n };\n\n scrollElementRef.current?.addEventListener('scroll', fn);\n\n return () => {\n scrollElementRef.current?.removeEventListener('scroll', fn);\n };\n }, [scrollElementRef.current]);\n\n return (\n <Transition\n in={isOpen}\n unmountOnExit\n nodeRef={popoverRef}\n timeout={animateTimeout}\n >\n {(animate) => {\n const getIndex = fabricIndex();\n const getVirtualIndex = fabricIndex();\n\n return (\n <Popover\n {...otherProps}\n anchorRef={controlRef}\n direction=\"downStartLeft\"\n possibleDirections={[\n 'downStartLeft',\n 'upStartLeft',\n 'downStartRight',\n 'upStartRight',\n ]}\n offset={offset}\n ref={popoverRef}\n role=\"listbox\"\n className={cnSelectDropdown(null, [\n cnListBox({ size, form, border: true, shadow: true }),\n cnMixPopoverAnimate({ animate }),\n className,\n ])}\n equalAnchorWidth\n >\n <div\n className={cnSelectDropdown('ScrollContainer', [\n cnMixSpace({\n pV: mapVerticalSpase[size],\n }),\n cnMixScrollBar(),\n ])}\n ref={dropdownRef}\n >\n {isLoading && !isListShowed && <SelectLoader />}\n <div\n className={cnSelectDropdown('List', { scrolled })}\n style={{ marginTop: spaceTop }}\n >\n {visibleItems.map((group) => {\n if (isOptionForCreate(group)) {\n const index = getIndex();\n return (\n <SelectCreateButton\n size={size}\n labelForCreate={labelForCreate}\n inputValue={group.label}\n indent={indent}\n ref={itemsRefs[index]}\n {...getOptionProps({\n index,\n item: group,\n keyPrefix: spaceTop,\n })}\n />\n );\n }\n\n const virtualIndex =\n visibleItems.length > 1 ? getVirtualIndex() : 0;\n\n return (\n <Fragment key={group.key}>\n {group.group &&\n getGroupLabel &&\n isVisible(slice, virtualIndex) && (\n <SelectGroupLabel\n label={getGroupLabel(group.group)}\n size={size}\n indent={indent}\n ref={listRefs[virtualIndex]}\n key={`group${group.key}${spaceTop}`}\n />\n )}\n {group.items.map((item, i) => {\n if (isOptionForSelectAll(item)) {\n const virtualIndex = getVirtualIndex();\n const index = getIndex();\n\n if (isVisible(slice, virtualIndex)) {\n return (\n <SelectItemAll\n ref={forkRef([\n listRefs[virtualIndex],\n itemsRefs[index],\n ])}\n indent={indent}\n size={size}\n {...getOptionProps({\n index,\n item,\n keyPrefix: spaceTop,\n })}\n intermediate={\n item.checkedCount && item.totalCount\n ? item.checkedCount !== item.totalCount\n : false\n }\n checked={item.checkedCount === item.totalCount}\n countItems={item.checkedCount}\n total={item.totalCount}\n />\n );\n }\n } else {\n const virtualIndex = getVirtualIndex();\n const index = getIndex();\n if (isVisible(slice, virtualIndex)) {\n return (\n <Fragment key={`${group.key}-${i}`}>\n {renderItem({\n ref: forkRef([\n listRefs[virtualIndex],\n itemsRefs[index],\n ]),\n item,\n ...getOptionProps({\n index,\n item,\n keyPrefix: spaceTop,\n }),\n })}\n </Fragment>\n );\n }\n }\n })}\n </Fragment>\n );\n })}\n {isLoading && isListShowed && (\n <ListLoader size={size} innerOffset={indent} />\n )}\n </div>\n {!isLoading && hasItems && notFound && labelForNotFound && (\n <ListItem\n size={size}\n label={labelForNotFound}\n innerOffset={indent}\n >\n {labelForNotFound}\n </ListItem>\n )}\n {!isLoading && !hasItems && labelForEmptyItems && (\n <ListItem\n size={size}\n label={labelForEmptyItems}\n innerOffset={indent}\n >\n {labelForEmptyItems}\n </ListItem>\n )}\n </div>\n </Popover>\n );\n }}\n </Transition>\n );\n};\n"],"mappings":"ylCAAA,6BAEA,MAAOA,MAAP,EAAgBC,QAAhB,CAA0BC,SAA1B,CAAqCC,OAArC,CAA8CC,MAA9C,KAA4D,OAA5D,CACA,OAASC,UAAT,KAA2B,wBAA3B,CAEA,OACEC,SADF,CAEEC,QAFF,CAGEC,UAHF,CAIEC,gBAJF,wBAMA,OAASC,OAAT,qBACA,OAASC,WAAT,kCACA,OAASC,OAAT,8BACA,OAASC,OAAT,CAAkBC,UAAlB,iCACA,OAASC,gBAAT,uCACA,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C,QAAD,EACE,IAAI,CAAEN,CADR,CAEE,KAAK,CAAEM,CAFT,CAGE,WAAW,CAAEgB,CAHf,EAKGhB,CALH,CA9GJ,CAsHG,CAACS,CAAD,EAAc,CAACP,CAAf,EAA2BD,CAA3B,EACC,oBAAC,QAAD,EACE,IAAI,CAAEP,CADR,CAEE,KAAK,CAAEO,CAFT,CAGE,WAAW,CAAEe,CAHf,EAKGf,CALH,CAvHJ,CApBF,CAsJH,CAjKH,CAoKH,CAjPM"}
1
+ {"version":3,"file":"SelectDropdown.js","names":["React","Fragment","useEffect","useMemo","useRef","Transition","cnListBox","ListItem","ListLoader","mapVerticalSpase","Popover","useDebounce","useFlag","forkRef","useForkRef","useVirtualScroll","animateTimeout","cnMixPopoverAnimate","cnMixScrollBar","cnMixSpace","cn","fabricIndex","SelectCreateButton","SelectGroupLabel","SelectItemAll","SelectLoader","isNotOptionForCreate","isOptionForCreate","isOptionForSelectAll","selectDropdownform","defaultSelectDropdownPropForm","cnSelectDropdown","getLenghtElements","elements","element","lenght","length","index","items","isVisible","slise","SelectDropdown","props","controlRef","size","getOptionProps","dropdownRefProp","dropdownRef","labelForCreate","className","labelForNotFound","labelForEmptyItems","hasItems","form","isOpen","offset","offsetProp","renderItem","visibleItems","isLoading","getGroupLabel","notFound","itemsRefs","virtualScroll","onScrollToBottom","otherProps","indent","isListShowed","filter","group","Array","isArray","lengthForVirtualScroll","isActive","spaceTop","sliceHookProp","slice","listRefs","scrollElementRef","popoverRef","scrolled","setScroled","setScroledOffDebouns","off","fn","on","current","addEventListener","removeEventListener","animate","getIndex","getVirtualIndex","border","shadow","pV","marginTop","map","groupIndex","label","item","keyPrefix","virtualIndex","key","i","checkedCount","totalCount","ref"],"sources":["../../../../../../src/components/SelectComponents/SelectDropdown/SelectDropdown.tsx"],"sourcesContent":["import './SelectDropdown.css';\n\nimport React, { Fragment, useEffect, useMemo, useRef } from 'react';\nimport { Transition } from 'react-transition-group';\n\nimport {\n cnListBox,\n ListItem,\n ListLoader,\n mapVerticalSpase,\n} from '##/components/ListCanary';\nimport { Popover, PopoverPropOffset } from '##/components/Popover';\nimport { useDebounce } from '##/hooks/useDebounce';\nimport { useFlag } from '##/hooks/useFlag';\nimport { forkRef, useForkRef } from '##/hooks/useForkRef';\nimport { useVirtualScroll } from '##/hooks/useVirtualScroll';\nimport {\n animateTimeout,\n cnMixPopoverAnimate,\n} from '##/mixs/MixPopoverAnimate/MixPopoverAnimate';\nimport { cnMixScrollBar } from '##/mixs/MixScrollBar';\nimport { cnMixSpace } from '##/mixs/MixSpace';\nimport { cn } from '##/utils/bem';\nimport { fabricIndex } from '##/utils/fabricIndex';\nimport { SelectAllItem } from '##/utils/getGroups';\nimport { PropsWithJsxAttributes } from '##/utils/types/PropsWithJsxAttributes';\n\nimport { SelectCreateButton } from '../SelectCreateButton/SelectCreateButton';\nimport { SelectGroupLabel } from '../SelectGroupLabel/SelectGroupLabel';\nimport { SelectItemAll } from '../SelectItemAll/SelectItemAll';\nimport { SelectLoader } from '../SelectLoader/SelectLoader';\nimport { PropSize, RenderItemProps } from '../types';\nimport {\n GetOptionPropsResult,\n isNotOptionForCreate,\n isOptionForCreate,\n isOptionForSelectAll,\n OptionForCreate,\n OptionProps,\n} from '../useSelect';\n\nexport const selectDropdownform = ['default', 'brick', 'round'] as const;\nexport type SelectDropdownPropForm = typeof selectDropdownform[number];\nexport const defaultSelectDropdownPropForm = selectDropdownform[0];\n\ntype Props<ITEM, GROUP> = PropsWithJsxAttributes<{\n size: PropSize;\n controlRef: React.MutableRefObject<HTMLDivElement | null>;\n dropdownRef: React.Ref<HTMLDivElement>;\n getOptionProps(props: OptionProps<ITEM>): GetOptionPropsResult;\n form: SelectDropdownPropForm;\n isOpen: boolean;\n offset?: PopoverPropOffset | 'none';\n isLoading?: boolean;\n renderItem: (props: RenderItemProps<ITEM>) => JSX.Element | null;\n visibleItems: (\n | OptionForCreate\n | {\n items: Array<SelectAllItem | ITEM>;\n key: string | number;\n group?: GROUP;\n groupIndex: number;\n checkedCount?: number;\n totalCount?: number;\n }\n )[];\n getGroupLabel?: (group: GROUP) => string;\n labelForCreate?: string;\n labelForNotFound?: string;\n labelForEmptyItems?: string;\n notFound?: boolean;\n hasItems?: boolean;\n itemsRefs: React.RefObject<HTMLDivElement>[];\n virtualScroll?: boolean;\n onScrollToBottom?: (lenght: number) => void;\n}>;\n\ntype SelectDropdown = <ITEM, GROUP>(\n props: Props<ITEM, GROUP>,\n) => React.ReactElement | null;\n\nconst cnSelectDropdown = cn('SelectDropdown');\n\nconst getLenghtElements = <ITEM, GROUP>(\n elements: (\n | OptionForCreate\n | {\n items: Array<SelectAllItem | ITEM>;\n key: string | number;\n group?: GROUP;\n groupIndex: number;\n checkedCount?: number;\n totalCount?: number;\n }\n )[],\n) => {\n let lenght = elements.length <= 1 ? 0 : elements.length;\n\n for (let index = 0; index < elements.length; index++) {\n const element = elements[index];\n\n if (isNotOptionForCreate(element) && element.items.length) {\n lenght += element.items.length;\n }\n }\n\n return lenght;\n};\n\nconst isVisible = (slise: [number, number], index: number) => {\n return index >= slise[0] && index < slise[1];\n};\n\nexport const SelectDropdown: SelectDropdown = (props) => {\n const {\n controlRef,\n size,\n getOptionProps,\n dropdownRef: dropdownRefProp,\n labelForCreate,\n className,\n labelForNotFound,\n labelForEmptyItems,\n hasItems = true,\n form,\n isOpen,\n offset: offsetProp = 'none',\n renderItem,\n visibleItems,\n isLoading,\n getGroupLabel,\n notFound,\n itemsRefs,\n virtualScroll,\n onScrollToBottom,\n ...otherProps\n } = props;\n\n const indent = form === 'round' ? 'increased' : 'normal';\n\n const isListShowed = useMemo(() => {\n return (\n visibleItems.filter(\n (group) =>\n isOptionForCreate(group) ||\n (Array.isArray(group.items) && group.items.length > 0),\n ).length > 0\n );\n }, [visibleItems]);\n\n const offset = offsetProp === 'none' ? undefined : offsetProp;\n\n const lengthForVirtualScroll = useMemo(\n () => getLenghtElements(visibleItems),\n [visibleItems],\n );\n\n const {\n spaceTop,\n slice: sliceHookProp,\n listRefs,\n scrollElementRef,\n } = useVirtualScroll({\n length: lengthForVirtualScroll,\n isActive: virtualScroll && isOpen,\n onScrollToBottom,\n });\n\n const slice: [number, number] =\n sliceHookProp[0] === 0 && virtualScroll ? [0, 50] : sliceHookProp;\n\n const popoverRef = useRef<HTMLDivElement>(null);\n const dropdownRef = useForkRef([scrollElementRef, dropdownRefProp]);\n const [scrolled, setScroled] = useFlag();\n const setScroledOffDebouns = useDebounce(setScroled.off, 100);\n\n useEffect(() => {\n const fn = () => {\n setScroled.on();\n setScroledOffDebouns();\n };\n\n scrollElementRef.current?.addEventListener('scroll', fn);\n\n return () => {\n scrollElementRef.current?.removeEventListener('scroll', fn);\n };\n }, [scrollElementRef.current]);\n\n return (\n <Transition\n in={isOpen}\n unmountOnExit\n nodeRef={popoverRef}\n timeout={animateTimeout}\n >\n {(animate) => {\n const getIndex = fabricIndex();\n const getVirtualIndex = fabricIndex();\n\n return (\n <Popover\n {...otherProps}\n anchorRef={controlRef}\n direction=\"downStartLeft\"\n possibleDirections={[\n 'downStartLeft',\n 'upStartLeft',\n 'downStartRight',\n 'upStartRight',\n ]}\n offset={offset}\n ref={popoverRef}\n role=\"listbox\"\n className={cnSelectDropdown(null, [\n cnListBox({ size, form, border: true, shadow: true }),\n cnMixPopoverAnimate({ animate }),\n className,\n ])}\n equalAnchorWidth\n >\n <div\n className={cnSelectDropdown('ScrollContainer', [\n cnMixSpace({\n pV: mapVerticalSpase[size],\n }),\n cnMixScrollBar(),\n ])}\n ref={dropdownRef}\n >\n {isLoading && !isListShowed && <SelectLoader />}\n <div\n className={cnSelectDropdown('List', { scrolled })}\n style={{ marginTop: spaceTop }}\n >\n {visibleItems.map((group, groupIndex) => {\n if (isOptionForCreate(group)) {\n const index = getIndex();\n return (\n <SelectCreateButton\n size={size}\n labelForCreate={labelForCreate}\n inputValue={group.label}\n indent={indent}\n ref={itemsRefs[index]}\n {...getOptionProps({\n index,\n item: group,\n keyPrefix: groupIndex,\n })}\n />\n );\n }\n\n const virtualIndex =\n visibleItems.length > 1 ? getVirtualIndex() : 0;\n\n return (\n <Fragment key={group.key}>\n {group.group &&\n getGroupLabel &&\n isVisible(slice, virtualIndex) && (\n <SelectGroupLabel\n label={getGroupLabel(group.group)}\n size={size}\n indent={indent}\n ref={listRefs[virtualIndex]}\n key={`group-${group.key}`}\n />\n )}\n {group.items.map((item, i) => {\n if (isOptionForSelectAll(item)) {\n const virtualIndex = getVirtualIndex();\n const index = getIndex();\n\n if (isVisible(slice, virtualIndex)) {\n return (\n <SelectItemAll\n ref={forkRef([\n listRefs[virtualIndex],\n itemsRefs[index],\n ])}\n indent={indent}\n size={size}\n {...getOptionProps({\n index,\n item,\n keyPrefix: i,\n })}\n intermediate={\n item.checkedCount && item.totalCount\n ? item.checkedCount !== item.totalCount\n : false\n }\n checked={item.checkedCount === item.totalCount}\n countItems={item.checkedCount}\n total={item.totalCount}\n />\n );\n }\n } else {\n const virtualIndex = getVirtualIndex();\n const index = getIndex();\n if (isVisible(slice, virtualIndex)) {\n return (\n <Fragment key={`${group.key}-${i}`}>\n {renderItem({\n ref: forkRef([\n listRefs[virtualIndex],\n itemsRefs[index],\n ]),\n item,\n ...getOptionProps({\n index,\n item,\n keyPrefix: i,\n }),\n })}\n </Fragment>\n );\n }\n }\n })}\n </Fragment>\n );\n })}\n {isLoading && isListShowed && (\n <ListLoader size={size} innerOffset={indent} />\n )}\n </div>\n {!isLoading && hasItems && notFound && labelForNotFound && (\n <ListItem\n size={size}\n label={labelForNotFound}\n innerOffset={indent}\n >\n {labelForNotFound}\n </ListItem>\n )}\n {!isLoading && !hasItems && labelForEmptyItems && (\n <ListItem\n size={size}\n label={labelForEmptyItems}\n innerOffset={indent}\n >\n {labelForEmptyItems}\n </ListItem>\n )}\n </div>\n </Popover>\n );\n }}\n </Transition>\n );\n};\n"],"mappings":"ylCAAA,6BAEA,MAAOA,MAAP,EAAgBC,QAAhB,CAA0BC,SAA1B,CAAqCC,OAArC,CAA8CC,MAA9C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ZH,CAmEH,CA1FA,CAJH,CA+FG5C,CAAS,EAAIQ,CAAb,EACC,oBAAC,UAAD,EAAY,IAAI,CAAEvB,CAAlB,CAAwB,WAAW,CAAEsB,CAArC,EAhGJ,CAVF,CA6GG,CAACP,CAAD,EAAcP,CAAd,EAA0BS,CAA1B,EAAsCX,CAAtC,EACC,oBAAC,QAAD,EACE,IAAI,CAAEN,CADR,CAEE,KAAK,CAAEM,CAFT,CAGE,WAAW,CAAEgB,CAHf,EAKGhB,CALH,CA9GJ,CAsHG,CAACS,CAAD,EAAc,CAACP,CAAf,EAA2BD,CAA3B,EACC,oBAAC,QAAD,EACE,IAAI,CAAEP,CADR,CAEE,KAAK,CAAEO,CAFT,CAGE,WAAW,CAAEe,CAHf,EAKGf,CALH,CAvHJ,CApBF,CAsJH,CAjKH,CAoKH,CAjPM"}
@@ -49,7 +49,7 @@ export declare type SelectProps<ITEM, GROUP, MULTIPLE extends boolean> = {
49
49
  export declare type OptionProps<ITEM> = {
50
50
  index: number;
51
51
  item: ITEM | OptionForCreate | SelectAllItem;
52
- keyPrefix: number;
52
+ keyPrefix: string | number;
53
53
  };
54
54
  export declare type GetOptionPropsResult = {
55
55
  onClick: (e: React.SyntheticEvent) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"useSelect.js","names":["useCallback","useEffect","useLayoutEffect","useMemo","useRef","useState","useClickOutside","useDebounce","useKeys","useMutableRef","usePrevious","useRefs","getCountedGroups","getGroups","scrollToIndex","useHoistedState","isMultipleParams","params","multiple","isNotMultipleParams","actions","setOpen","setSearch","highlightIndex","initialState","searchValue","resolvedSearchValue","isOpen","highlightedIndex","scrollToHighlighted","isOptionForCreate","Object","prototype","hasOwnProperty","call","isNotOptionForCreate","isOptionForSelectAll","useSelect","items","dropdownRef","controlRef","disabled","getItemLabel","getItemKey","searchFunction","getItemGroupKey","groups","selectAll","getGroupKey","sortGroups","getItemDisabled","onFocus","onBlur","searchValueProp","onDropdownOpen","onSearchValueChange","dropdownOpen","ignoreOutsideClicksRefs","inputRef","isFocused","setIsFocused","value","Array","isArray","setState","onSearchValueChangeRef","searchFunctionDefault","item","toLocaleLowerCase","indexOf","fiteredOptions","filter","onCreate","length","label","__optionForCreate","filteredOptions","optionForCreate","visibleItems","resultGroups","maxHighlightIndex","optionsRefs","notFound","flag","group","hasItems","allItemsSelected","el","find","getSelectedOptionIndex","index","newIsOpen","old","setResolvedSearch","prevIsOpen","indexForHighlight","newIndex","Math","min","max","currentHighlightIndex","removeValue","e","valueItem","stopPropagation","newValue","val","onChange","some","onChangeAll","parametrs","nonDisabledItems","currentGroupValues","withoutGroupValues","forEach","push","clearValue","results","ArrowUp","_","preventDefault","ArrowDown","getKeyProps","PageUp","PageDown","Home","End","Enter","getData","couter","Escape","Tab","Backspace","isActive","ignoreClicksInsideRefs","handler","current","scrollTo","top","getOptionProps","keyPrefix","onClick","onMouseEnter","active","hovered","key","getItems","groupKey","handleInputFocus","handleInputBlur","focus","handleToggleDropdown","handleInputClick","handleInputChange","target","getHandleRemoveValue"],"sources":["../../../../../../src/components/SelectComponents/useSelect/useSelect.ts"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useClickOutside } from '##/hooks/useClickOutside';\nimport { useDebounce } from '##/hooks/useDebounce';\nimport { KeyHandler, useKeys } from '##/hooks/useKeysDepricated';\nimport { useMutableRef } from '##/hooks/useMutableRef';\nimport { usePrevious } from '##/hooks/usePrevious';\nimport { useRefs } from '##/hooks/useRefs';\nimport {\n CountedGroup,\n getCountedGroups,\n getGroups,\n SelectAllItem,\n} from '##/utils/getGroups';\n\nimport { scrollToIndex, useHoistedState } from './helpers';\n\ntype IndexForHighlight = number | ((oldIndex: number) => number);\n\ntype Group<ITEM, GROUP> = {\n items: ITEM[];\n key: string | number;\n group?: GROUP;\n};\ntype GetItemGroupKey<ITEM> = (item: ITEM) => string | number | undefined;\ntype GetGroupKey<GROUP> = (item: GROUP) => string | number | undefined;\ntype SortGroups<ITEM, GROUP> = (\n a: Group<ITEM, GROUP>,\n b: Group<ITEM, GROUP>,\n) => number;\n\ntype OnChangeProp<ITEM, MULTIPLE extends boolean> = (\n value: (MULTIPLE extends true ? ITEM[] : ITEM) | null,\n props: {\n e: React.SyntheticEvent;\n },\n) => void;\n\ntype ValueProp<ITEM, MULTIPLE extends boolean> =\n | (MULTIPLE extends true ? ITEM[] : ITEM)\n | null\n | undefined;\n\nexport type OptionForCreate = {\n label: string;\n __optionForCreate: boolean;\n};\n\nexport type SelectProps<ITEM, GROUP, MULTIPLE extends boolean> = {\n getItemGroupKey?: GetItemGroupKey<ITEM> | undefined;\n getGroupKey?: GetGroupKey<GROUP>;\n sortGroups?: SortGroups<ITEM, GROUP>;\n groups?: GROUP[];\n items: ITEM[];\n dropdownRef: React.MutableRefObject<HTMLDivElement | null>;\n controlRef: React.MutableRefObject<HTMLDivElement | null>;\n disabled?: boolean;\n selectAll?: boolean;\n getItemLabel: (item: ITEM) => string;\n getItemKey: (item: ITEM) => string | number;\n getItemDisabled?: (item: ITEM) => boolean | undefined;\n searchFunction?: (item: ITEM, searchValue: string) => boolean;\n onCreate?: (\n label: string,\n props: { e: React.SyntheticEvent; label: string },\n ) => void;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n multiple: boolean;\n searchValue?: string;\n onChange: OnChangeProp<ITEM, MULTIPLE>;\n value: ValueProp<ITEM, MULTIPLE>;\n dropdownOpen?: boolean;\n onDropdownOpen?: (isOpen: boolean) => void;\n onSearchValueChange?: (value: string) => void;\n ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n};\n\nexport type OptionProps<ITEM> = {\n index: number;\n item: ITEM | OptionForCreate | SelectAllItem;\n keyPrefix: number;\n};\n\nexport type GetOptionPropsResult = {\n onClick: (e: React.SyntheticEvent) => void;\n onMouseEnter: (e: React.SyntheticEvent) => void;\n active: boolean;\n hovered: boolean;\n key: string | number;\n};\n\nconst isMultipleParams = <ITEM, GROUP>(\n params: SelectProps<ITEM, GROUP, boolean>,\n): params is SelectProps<ITEM, GROUP, true> => {\n return params.multiple;\n};\n\nconst isNotMultipleParams = <ITEM, GROUP>(\n params: SelectProps<ITEM, GROUP, boolean>,\n): params is SelectProps<ITEM, GROUP, false> => {\n return !params.multiple;\n};\n\nconst actions = {\n setOpen: 'setOpen',\n setSearch: 'setSearch',\n highlightIndex: 'highlightIndex',\n};\n\nconst initialState = {\n searchValue: '',\n resolvedSearchValue: '',\n isOpen: false,\n highlightedIndex: 0,\n scrollToHighlighted: false,\n};\n\nexport const isOptionForCreate = <ITEM, GROUP>(\n params: OptionForCreate | Group<ITEM, GROUP> | ITEM,\n): params is OptionForCreate => {\n return (\n params && Object.prototype.hasOwnProperty.call(params, '__optionForCreate')\n );\n};\n\nexport const isNotOptionForCreate = <ITEM, GROUP>(\n params: OptionForCreate | Group<ITEM, GROUP>,\n): params is Group<ITEM, GROUP> => {\n return (\n params && !Object.prototype.hasOwnProperty.call(params, '__optionForCreate')\n );\n};\n\nexport const isOptionForSelectAll = <ITEM>(\n params: SelectAllItem | ITEM,\n): params is SelectAllItem => {\n return (\n params && Object.prototype.hasOwnProperty.call(params, '__optionSelctAll')\n );\n};\n\nexport function useSelect<ITEM, GROUP, MULTIPLE extends boolean>(\n params: SelectProps<ITEM, GROUP, MULTIPLE>,\n) {\n const {\n items,\n dropdownRef,\n controlRef,\n disabled = false,\n multiple = false,\n getItemLabel,\n getItemKey,\n searchFunction,\n getItemGroupKey,\n groups,\n selectAll = false,\n getGroupKey,\n sortGroups,\n getItemDisabled,\n onFocus,\n onBlur,\n searchValue: searchValueProp,\n onDropdownOpen,\n onSearchValueChange,\n dropdownOpen,\n ignoreOutsideClicksRefs,\n } = params;\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const [isFocused, setIsFocused] = useState(false);\n\n const value = useMemo(\n () =>\n (params.value &&\n (Array.isArray(params.value) ? params.value : [params.value])) ||\n [],\n [params.value],\n );\n\n const [\n {\n searchValue,\n isOpen,\n highlightedIndex,\n resolvedSearchValue,\n scrollToHighlighted,\n },\n setState,\n ] = useHoistedState(initialState);\n\n const onSearchValueChangeRef = useMutableRef(onSearchValueChange);\n\n const searchFunctionDefault = (item: ITEM, searchValue: string) =>\n getItemLabel(item)\n .toLocaleLowerCase()\n .indexOf(searchValue.toLocaleLowerCase()) !== -1;\n\n const [filteredOptions, optionForCreate] = useMemo(() => {\n if (resolvedSearchValue && resolvedSearchValue !== '') {\n const fiteredOptions = items.filter((item) =>\n searchFunction\n ? searchFunction(item, resolvedSearchValue)\n : searchFunctionDefault(item, resolvedSearchValue),\n );\n\n const optionForCreate: OptionForCreate = {\n label: searchValue,\n __optionForCreate: true,\n };\n\n return [\n fiteredOptions,\n params.onCreate && !fiteredOptions.length ? optionForCreate : undefined,\n ] as const;\n }\n return [items, undefined] as const;\n }, [items, resolvedSearchValue]);\n\n const visibleItems = useMemo(() => {\n const resultGroups = getCountedGroups(\n getGroups(\n filteredOptions,\n groups?.length ? getItemGroupKey : undefined,\n groups,\n getGroupKey,\n sortGroups,\n ),\n isMultipleParams(params) ? params.value : [],\n selectAll,\n getItemKey,\n getItemDisabled,\n );\n\n return optionForCreate ? [optionForCreate, ...resultGroups] : resultGroups;\n }, [\n value,\n selectAll,\n filteredOptions,\n groups,\n getItemGroupKey,\n getItemDisabled,\n getGroupKey,\n sortGroups,\n optionForCreate,\n ]);\n\n const maxHighlightIndex =\n // колличество опций\n filteredOptions.length +\n // кнопка для создания\n (optionForCreate ? 1 : 0) +\n // кнопки выбрать все\n (selectAll ? visibleItems.length : 0);\n\n const optionsRefs = useRefs<HTMLDivElement>(maxHighlightIndex, [isOpen]);\n\n const notFound = useMemo(() => {\n let flag = false;\n if (searchValue.length > 0) {\n flag =\n visibleItems.filter(\n (group) =>\n isOptionForCreate(group) || group.items.length > 0 || group.group,\n ).length === 0 && !params.onCreate;\n }\n return flag;\n }, [visibleItems]);\n\n const hasItems = items.length !== 0;\n\n const allItemsSelected = useMemo(() => {\n if (isNotMultipleParams(params)) {\n return false;\n }\n if (selectAll) {\n return (\n items.filter((el) =>\n value.find((item) => getItemKey(item) === getItemKey(el)),\n ).length === items.length\n );\n }\n\n return false;\n }, [selectAll, multiple, value, items]);\n\n const getSelectedOptionIndex = (): number => {\n let index = 0;\n if (value.length > 0) {\n for (const group of visibleItems) {\n if (isOptionForCreate(group)) {\n index++;\n // eslint-disable-next-line no-continue\n continue;\n }\n for (const item of group.items) {\n if (isOptionForSelectAll(item)) {\n return index;\n }\n if (getItemKey(item) === getItemKey(value[0])) {\n return index;\n }\n index++;\n }\n }\n }\n\n return 0;\n };\n\n // Actions\n\n const setOpen = useCallback(\n (newIsOpen: boolean) => {\n setState(\n (old) => ({\n ...old,\n isOpen: newIsOpen,\n }),\n actions.setOpen,\n );\n },\n [setState],\n );\n\n const setResolvedSearch = useDebounce((value: string) => {\n setState((old) => {\n if (old.resolvedSearchValue === value) {\n return old;\n }\n return {\n ...old,\n resolvedSearchValue: value,\n };\n }, actions.setSearch);\n }, 300);\n\n const setSearch = useCallback(\n (value: string | undefined) => {\n setState((old) => {\n if (old.searchValue === value) {\n return old;\n }\n return {\n ...old,\n searchValue: value || '',\n };\n }, actions.setSearch);\n setResolvedSearch(value || '');\n },\n [setState, setResolvedSearch],\n );\n\n const prevIsOpen = usePrevious(isOpen);\n\n const highlightIndex = useCallback(\n (indexForHighlight: IndexForHighlight, scrollToHighlighted: boolean) => {\n setState((old) => {\n const newIndex = Math.min(\n Math.max(\n 0,\n typeof indexForHighlight === 'function'\n ? indexForHighlight(old.highlightedIndex)\n : indexForHighlight,\n ),\n maxHighlightIndex - 1,\n );\n\n if (old.highlightedIndex === newIndex) {\n return old;\n }\n\n return {\n ...old,\n highlightedIndex: newIndex,\n scrollToHighlighted,\n };\n }, actions.highlightIndex);\n },\n [filteredOptions, setState, optionForCreate],\n );\n\n useLayoutEffect(() => {\n if (value !== null && !prevIsOpen && isOpen) {\n const currentHighlightIndex = getSelectedOptionIndex();\n if (filteredOptions.length > 0) {\n scrollToIndex(currentHighlightIndex, dropdownRef, optionsRefs, () =>\n highlightIndex(0, false),\n );\n }\n }\n });\n\n const removeValue = (e: React.SyntheticEvent, valueItem: ITEM) => {\n e.stopPropagation();\n if (isMultipleParams(params)) {\n const newValue = params.value?.filter(\n (item) => getItemKey(item) !== getItemKey(valueItem),\n );\n const val = newValue?.length ? newValue : null;\n params.onChange(val, {\n e,\n });\n }\n };\n\n const onChange = (e: React.SyntheticEvent, item: ITEM) => {\n if (getItemDisabled && getItemDisabled(item)) {\n return;\n }\n if (isMultipleParams(params)) {\n const newValue = value.some(\n (value) => getItemKey(value) === getItemKey(item),\n )\n ? value.filter((value) => getItemKey(value) !== getItemKey(item))\n : [...value, item];\n const val = newValue?.length ? newValue : null;\n params.onChange(val, { e });\n }\n if (isNotMultipleParams(params)) {\n params.onChange(item, { e });\n setOpen(false);\n setSearch('');\n }\n };\n\n const onChangeAll = (parametrs: {\n e: React.SyntheticEvent;\n items: ITEM[];\n }) => {\n const { e, items } = parametrs;\n if (isMultipleParams(params)) {\n const nonDisabledItems = getItemDisabled\n ? items.filter((item) => !getItemDisabled(item))\n : items;\n\n const currentGroupValues: ITEM[] = [];\n const withoutGroupValues: ITEM[] = [];\n value.forEach((el) => {\n if (\n nonDisabledItems.find((item) => getItemKey(el) === getItemKey(item))\n ) {\n currentGroupValues.push(el);\n } else {\n withoutGroupValues.push(el);\n }\n });\n if (currentGroupValues.length === nonDisabledItems.length) {\n params.onChange(withoutGroupValues, { e });\n } else {\n const val = [...withoutGroupValues, ...nonDisabledItems];\n params.onChange(val, {\n e,\n });\n }\n }\n };\n\n const onCreate = (e: React.SyntheticEvent, label: string) => {\n params.onCreate && params.onCreate(label, { e, label });\n setOpen(false);\n setSearch('');\n };\n\n // Handlers\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>): void => {\n if (!disabled && !(!multiple && value.length > 0)) {\n setSearch(e.target.value);\n setOpen(true);\n }\n };\n\n const handleInputClick = (): void => {\n !disabled && setOpen(!isOpen);\n\n if (multiple) {\n inputRef.current?.focus();\n }\n };\n\n const clearValue = (e: React.SyntheticEvent) => {\n if (isMultipleParams(params)) {\n const results = value?.filter((item) => getItemDisabled?.(item));\n const val = results && results.length > 0 ? results : null;\n params.onChange(val, {\n e,\n });\n }\n if (isNotMultipleParams(params)) {\n params.onChange(null, { e });\n }\n setSearch('');\n };\n\n const getHandleRemoveValue = (item: ITEM) => (e: React.SyntheticEvent) =>\n removeValue(e, item);\n\n // Prop Getters\n\n const ArrowUp: KeyHandler = (_, e): void => {\n e.preventDefault();\n !disabled && setOpen(true);\n highlightIndex((old) => old - 1, true);\n };\n\n const ArrowDown: KeyHandler = (_, e): void => {\n e.preventDefault();\n !disabled && setOpen(true);\n highlightIndex((old) => old + 1, true);\n };\n\n const Enter: KeyHandler = (_, e): void => {\n if (isOpen) {\n if (searchValue || filteredOptions[highlightedIndex]) {\n e.preventDefault();\n }\n\n const getData = (\n index: number,\n ): [\n CountedGroup<ITEM, GROUP> | undefined,\n SelectAllItem | OptionForCreate | ITEM | undefined,\n ] => {\n let couter = 0;\n for (const group of visibleItems) {\n if (isOptionForCreate(group)) {\n couter++;\n return [undefined, group];\n }\n if (group.items.length + couter > index) {\n return [group, group.items[index - couter]];\n }\n couter += group.items.length;\n }\n return [undefined, undefined];\n };\n\n const [group, item] = getData(highlightedIndex);\n\n if (isOptionForCreate(item)) {\n onCreate(e, item.label);\n return;\n }\n\n if (isOptionForSelectAll(item)) {\n onChangeAll({\n e,\n items:\n (group?.items.filter(\n (el) => !isOptionForSelectAll(el),\n ) as ITEM[]) ?? [],\n });\n return;\n }\n\n if (item) {\n onChange(e, item);\n }\n } else {\n setOpen(true);\n }\n };\n\n const Escape: KeyHandler = (): void => {\n setOpen(false);\n };\n\n const Tab: KeyHandler = (_, e): void => {\n if (isOpen) {\n e.preventDefault();\n setOpen(false);\n }\n };\n\n const Backspace: KeyHandler = (_, e): void => {\n if (searchValue) {\n return;\n }\n if (multiple) {\n removeValue(e, value[value.length - 1]);\n } else {\n clearValue(e);\n }\n };\n\n const getKeyProps = useKeys({\n ArrowUp,\n ArrowDown,\n PageUp: ArrowUp,\n PageDown: ArrowDown,\n Home: ArrowUp,\n End: ArrowDown,\n Enter,\n Escape,\n Tab,\n Backspace,\n });\n\n const getOptionProps = ({\n index,\n item,\n keyPrefix,\n }: OptionProps<ITEM>): GetOptionPropsResult => {\n if (isOptionForCreate(item)) {\n return {\n onClick: (e: React.SyntheticEvent) => {\n onCreate(e, item.label);\n },\n onMouseEnter: () => {\n highlightIndex(index, false);\n },\n active: false,\n hovered: index === highlightedIndex,\n key: `${keyPrefix}__optionForCreate`,\n };\n }\n if (isOptionForSelectAll(item)) {\n const getItems = (): ITEM[] => {\n for (const group of visibleItems) {\n if (isOptionForCreate(group)) {\n break;\n }\n if (group.key === item.groupKey) {\n return (\n (group?.items.filter(\n (el) => !isOptionForSelectAll(el),\n ) as ITEM[]) ?? []\n );\n }\n }\n return [];\n };\n return {\n onClick: (e: React.SyntheticEvent) => {\n onChangeAll({ e, items: getItems() });\n },\n onMouseEnter: () => {\n highlightIndex(index, false);\n },\n active: false,\n hovered: index === highlightedIndex,\n key: `${keyPrefix}__optionForSelectAll`,\n };\n }\n const key = getItemKey(item);\n return {\n onClick: (e: React.SyntheticEvent) => {\n onChange(e, item);\n },\n onMouseEnter: () => {\n highlightIndex(index, false);\n },\n active: Boolean(value.find((item) => getItemKey(item) === key)),\n hovered: index === highlightedIndex,\n key: `${keyPrefix}${key}`,\n };\n };\n\n useClickOutside({\n isActive: isOpen,\n ignoreClicksInsideRefs: [\n dropdownRef,\n controlRef,\n ...(ignoreOutsideClicksRefs || []),\n ],\n handler: () => {\n setOpen(false);\n },\n });\n\n useEffect(() => {\n if (disabled) {\n setOpen(false);\n }\n }, [disabled]);\n\n useEffect(() => {\n const currentHighlightIndex = getSelectedOptionIndex();\n highlightIndex(currentHighlightIndex, true);\n }, [highlightIndex]);\n\n useEffect(() => {\n if (filteredOptions.length > 0 && scrollToHighlighted) {\n scrollToIndex(highlightedIndex, dropdownRef, optionsRefs, () =>\n highlightIndex(0, false),\n );\n }\n }, [highlightedIndex]);\n\n const handleInputFocus = (e: React.FocusEvent<HTMLInputElement>): void => {\n if (!disabled) {\n if (!isFocused) {\n setIsFocused(true);\n }\n if (typeof onFocus === 'function') {\n onFocus(e);\n }\n }\n };\n\n const handleInputBlur = (e: React.FocusEvent<HTMLInputElement>): void => {\n if (isOpen) {\n inputRef.current?.focus();\n return;\n }\n\n if (isFocused) {\n setIsFocused(false);\n }\n\n if (typeof onBlur === 'function') {\n onBlur(e);\n }\n };\n\n const handleToggleDropdown = (): void => {\n if (isOpen) {\n setOpen(false);\n setIsFocused(false);\n } else {\n setOpen(true);\n setIsFocused(true);\n inputRef.current?.focus();\n }\n };\n\n useEffect(() => {\n setSearch(searchValueProp);\n }, [searchValueProp]);\n\n useEffect(() => {\n dropdownRef.current?.scrollTo({ top: 0 });\n }, [resolvedSearchValue]);\n\n useEffect(() => {\n onDropdownOpen?.(isOpen);\n }, [isOpen]);\n\n useEffect(() => {\n onSearchValueChangeRef.current?.(searchValue);\n }, [searchValue]);\n\n useEffect(() => {\n setOpen(dropdownOpen || false);\n }, [dropdownOpen]);\n\n return {\n isOpen,\n isFocused,\n highlightedIndex,\n visibleItems,\n highlightIndex,\n getOptionProps,\n handleInputFocus,\n handleInputBlur,\n handleToggleDropdown,\n handleInputClick,\n inputRef,\n getKeyProps,\n handleInputChange,\n searchValue,\n clearValue,\n getHandleRemoveValue,\n notFound,\n hasItems,\n allItemsSelected,\n optionsRefs,\n };\n}\n"],"mappings":"4pEAAA,OACEA,WADF,CAEEC,SAFF,CAGEC,eAHF,CAIEC,OAJF,CAKEC,MALF,CAMEC,QANF,KAOO,OAPP,CASA,OAASC,eAAT,sCACA,OAASC,WAAT,kCACA,OAAqBC,OAArB,wCACA,OAASC,aAA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AAF,CAAS7F,KAAV,CAF+D,CAGxExC,EAAO,IAHiE,CAK3E,CAoRM,CAcLI,WAAW,CAAXA,CAdK,CAeL2F,UAAU,CAAVA,EAfK,CAgBLuC,oBAAoB,CA5QO,QAAvBA,qBAAuB,CAACxF,CAAD,QAAgB,UAACmC,CAAD,QAC3CD,GAAW,CAACC,CAAD,CAAInC,CAAJ,CADgC,CAAhB,CA4PtB,CAiBLe,QAAQ,CAARA,CAjBK,CAkBLG,QAAQ,CAARA,CAlBK,CAmBLC,gBAAgB,CAAhBA,CAnBK,CAoBLL,WAAW,CAAXA,CApBK,CAsBR"}
1
+ {"version":3,"file":"useSelect.js","names":["useCallback","useEffect","useLayoutEffect","useMemo","useRef","useState","useClickOutside","useDebounce","useKeys","useMutableRef","usePrevious","useRefs","getCountedGroups","getGroups","scrollToIndex","useHoistedState","isMultipleParams","params","multiple","isNotMultipleParams","actions","setOpen","setSearch","highlightIndex","initialState","searchValue","resolvedSearchValue","isOpen","highlightedIndex","scrollToHighlighted","isOptionForCreate","Object","prototype","hasOwnProperty","call","isNotOptionForCreate","isOptionForSelectAll","useSelect","items","dropdownRef","controlRef","disabled","getItemLabel","getItemKey","searchFunction","getItemGroupKey","groups","selectAll","getGroupKey","sortGroups","getItemDisabled","onFocus","onBlur","searchValueProp","onDropdownOpen","onSearchValueChange","dropdownOpen","ignoreOutsideClicksRefs","inputRef","isFocused","setIsFocused","value","Array","isArray","setState","onSearchValueChangeRef","searchFunctionDefault","item","toLocaleLowerCase","indexOf","fiteredOptions","filter","onCreate","length","label","__optionForCreate","filteredOptions","optionForCreate","visibleItems","resultGroups","maxHighlightIndex","optionsRefs","notFound","flag","group","hasItems","allItemsSelected","el","find","getSelectedOptionIndex","index","newIsOpen","old","setResolvedSearch","prevIsOpen","indexForHighlight","newIndex","Math","min","max","currentHighlightIndex","removeValue","e","valueItem","stopPropagation","newValue","val","onChange","some","onChangeAll","parametrs","nonDisabledItems","currentGroupValues","withoutGroupValues","forEach","push","clearValue","results","ArrowUp","_","preventDefault","ArrowDown","getKeyProps","PageUp","PageDown","Home","End","Enter","getData","couter","Escape","Tab","Backspace","isActive","ignoreClicksInsideRefs","handler","current","scrollTo","top","getOptionProps","keyPrefix","onClick","onMouseEnter","active","hovered","key","getItems","groupKey","handleInputFocus","handleInputBlur","focus","handleToggleDropdown","handleInputClick","handleInputChange","target","getHandleRemoveValue"],"sources":["../../../../../../src/components/SelectComponents/useSelect/useSelect.ts"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useClickOutside } from '##/hooks/useClickOutside';\nimport { useDebounce } from '##/hooks/useDebounce';\nimport { KeyHandler, useKeys } from '##/hooks/useKeysDepricated';\nimport { useMutableRef } from '##/hooks/useMutableRef';\nimport { usePrevious } from '##/hooks/usePrevious';\nimport { useRefs } from '##/hooks/useRefs';\nimport {\n CountedGroup,\n getCountedGroups,\n getGroups,\n SelectAllItem,\n} from '##/utils/getGroups';\n\nimport { scrollToIndex, useHoistedState } from './helpers';\n\ntype IndexForHighlight = number | ((oldIndex: number) => number);\n\ntype Group<ITEM, GROUP> = {\n items: ITEM[];\n key: string | number;\n group?: GROUP;\n};\ntype GetItemGroupKey<ITEM> = (item: ITEM) => string | number | undefined;\ntype GetGroupKey<GROUP> = (item: GROUP) => string | number | undefined;\ntype SortGroups<ITEM, GROUP> = (\n a: Group<ITEM, GROUP>,\n b: Group<ITEM, GROUP>,\n) => number;\n\ntype OnChangeProp<ITEM, MULTIPLE extends boolean> = (\n value: (MULTIPLE extends true ? ITEM[] : ITEM) | null,\n props: {\n e: React.SyntheticEvent;\n },\n) => void;\n\ntype ValueProp<ITEM, MULTIPLE extends boolean> =\n | (MULTIPLE extends true ? ITEM[] : ITEM)\n | null\n | undefined;\n\nexport type OptionForCreate = {\n label: string;\n __optionForCreate: boolean;\n};\n\nexport type SelectProps<ITEM, GROUP, MULTIPLE extends boolean> = {\n getItemGroupKey?: GetItemGroupKey<ITEM> | undefined;\n getGroupKey?: GetGroupKey<GROUP>;\n sortGroups?: SortGroups<ITEM, GROUP>;\n groups?: GROUP[];\n items: ITEM[];\n dropdownRef: React.MutableRefObject<HTMLDivElement | null>;\n controlRef: React.MutableRefObject<HTMLDivElement | null>;\n disabled?: boolean;\n selectAll?: boolean;\n getItemLabel: (item: ITEM) => string;\n getItemKey: (item: ITEM) => string | number;\n getItemDisabled?: (item: ITEM) => boolean | undefined;\n searchFunction?: (item: ITEM, searchValue: string) => boolean;\n onCreate?: (\n label: string,\n props: { e: React.SyntheticEvent; label: string },\n ) => void;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n multiple: boolean;\n searchValue?: string;\n onChange: OnChangeProp<ITEM, MULTIPLE>;\n value: ValueProp<ITEM, MULTIPLE>;\n dropdownOpen?: boolean;\n onDropdownOpen?: (isOpen: boolean) => void;\n onSearchValueChange?: (value: string) => void;\n ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n};\n\nexport type OptionProps<ITEM> = {\n index: number;\n item: ITEM | OptionForCreate | SelectAllItem;\n keyPrefix: string | number;\n};\n\nexport type GetOptionPropsResult = {\n onClick: (e: React.SyntheticEvent) => void;\n onMouseEnter: (e: React.SyntheticEvent) => void;\n active: boolean;\n hovered: boolean;\n key: string | number;\n};\n\nconst isMultipleParams = <ITEM, GROUP>(\n params: SelectProps<ITEM, GROUP, boolean>,\n): params is SelectProps<ITEM, GROUP, true> => {\n return params.multiple;\n};\n\nconst isNotMultipleParams = <ITEM, GROUP>(\n params: SelectProps<ITEM, GROUP, boolean>,\n): params is SelectProps<ITEM, GROUP, false> => {\n return !params.multiple;\n};\n\nconst actions = {\n setOpen: 'setOpen',\n setSearch: 'setSearch',\n highlightIndex: 'highlightIndex',\n};\n\nconst initialState = {\n searchValue: '',\n resolvedSearchValue: '',\n isOpen: false,\n highlightedIndex: 0,\n scrollToHighlighted: false,\n};\n\nexport const isOptionForCreate = <ITEM, GROUP>(\n params: OptionForCreate | Group<ITEM, GROUP> | ITEM,\n): params is OptionForCreate => {\n return (\n params && Object.prototype.hasOwnProperty.call(params, '__optionForCreate')\n );\n};\n\nexport const isNotOptionForCreate = <ITEM, GROUP>(\n params: OptionForCreate | Group<ITEM, GROUP>,\n): params is Group<ITEM, GROUP> => {\n return (\n params && !Object.prototype.hasOwnProperty.call(params, '__optionForCreate')\n );\n};\n\nexport const isOptionForSelectAll = <ITEM>(\n params: SelectAllItem | ITEM,\n): params is SelectAllItem => {\n return (\n params && Object.prototype.hasOwnProperty.call(params, '__optionSelctAll')\n );\n};\n\nexport function useSelect<ITEM, GROUP, MULTIPLE extends boolean>(\n params: SelectProps<ITEM, GROUP, MULTIPLE>,\n) {\n const {\n items,\n dropdownRef,\n controlRef,\n disabled = false,\n multiple = false,\n getItemLabel,\n getItemKey,\n searchFunction,\n getItemGroupKey,\n groups,\n selectAll = false,\n getGroupKey,\n sortGroups,\n getItemDisabled,\n onFocus,\n onBlur,\n searchValue: searchValueProp,\n onDropdownOpen,\n onSearchValueChange,\n dropdownOpen,\n ignoreOutsideClicksRefs,\n } = params;\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const [isFocused, setIsFocused] = useState(false);\n\n const value = useMemo(\n () =>\n (params.value &&\n (Array.isArray(params.value) ? params.value : [params.value])) ||\n [],\n [params.value],\n );\n\n const [\n {\n searchValue,\n isOpen,\n highlightedIndex,\n resolvedSearchValue,\n scrollToHighlighted,\n },\n setState,\n ] = useHoistedState(initialState);\n\n const onSearchValueChangeRef = useMutableRef(onSearchValueChange);\n\n const searchFunctionDefault = (item: ITEM, searchValue: string) =>\n getItemLabel(item)\n .toLocaleLowerCase()\n .indexOf(searchValue.toLocaleLowerCase()) !== -1;\n\n const [filteredOptions, optionForCreate] = useMemo(() => {\n if (resolvedSearchValue && resolvedSearchValue !== '') {\n const fiteredOptions = items.filter((item) =>\n searchFunction\n ? searchFunction(item, resolvedSearchValue)\n : searchFunctionDefault(item, resolvedSearchValue),\n );\n\n const optionForCreate: OptionForCreate = {\n label: searchValue,\n __optionForCreate: true,\n };\n\n return [\n fiteredOptions,\n params.onCreate && !fiteredOptions.length ? optionForCreate : undefined,\n ] as const;\n }\n return [items, undefined] as const;\n }, [items, resolvedSearchValue]);\n\n const visibleItems = useMemo(() => {\n const resultGroups = getCountedGroups(\n getGroups(\n filteredOptions,\n groups?.length ? getItemGroupKey : undefined,\n groups,\n getGroupKey,\n sortGroups,\n ),\n isMultipleParams(params) ? params.value : [],\n selectAll,\n getItemKey,\n getItemDisabled,\n );\n\n return optionForCreate ? [optionForCreate, ...resultGroups] : resultGroups;\n }, [\n value,\n selectAll,\n filteredOptions,\n groups,\n getItemGroupKey,\n getItemDisabled,\n getGroupKey,\n sortGroups,\n optionForCreate,\n ]);\n\n const maxHighlightIndex =\n // колличество опций\n filteredOptions.length +\n // кнопка для создания\n (optionForCreate ? 1 : 0) +\n // кнопки выбрать все\n (selectAll ? visibleItems.length : 0);\n\n const optionsRefs = useRefs<HTMLDivElement>(maxHighlightIndex, [isOpen]);\n\n const notFound = useMemo(() => {\n let flag = false;\n if (searchValue.length > 0) {\n flag =\n visibleItems.filter(\n (group) =>\n isOptionForCreate(group) || group.items.length > 0 || group.group,\n ).length === 0 && !params.onCreate;\n }\n return flag;\n }, [visibleItems]);\n\n const hasItems = items.length !== 0;\n\n const allItemsSelected = useMemo(() => {\n if (isNotMultipleParams(params)) {\n return false;\n }\n if (selectAll) {\n return (\n items.filter((el) =>\n value.find((item) => getItemKey(item) === getItemKey(el)),\n ).length === items.length\n );\n }\n\n return false;\n }, [selectAll, multiple, value, items]);\n\n const getSelectedOptionIndex = (): number => {\n let index = 0;\n if (value.length > 0) {\n for (const group of visibleItems) {\n if (isOptionForCreate(group)) {\n index++;\n // eslint-disable-next-line no-continue\n continue;\n }\n for (const item of group.items) {\n if (isOptionForSelectAll(item)) {\n return index;\n }\n if (getItemKey(item) === getItemKey(value[0])) {\n return index;\n }\n index++;\n }\n }\n }\n\n return 0;\n };\n\n // Actions\n\n const setOpen = useCallback(\n (newIsOpen: boolean) => {\n setState(\n (old) => ({\n ...old,\n isOpen: newIsOpen,\n }),\n actions.setOpen,\n );\n },\n [setState],\n );\n\n const setResolvedSearch = useDebounce((value: string) => {\n setState((old) => {\n if (old.resolvedSearchValue === value) {\n return old;\n }\n return {\n ...old,\n resolvedSearchValue: value,\n };\n }, actions.setSearch);\n }, 300);\n\n const setSearch = useCallback(\n (value: string | undefined) => {\n setState((old) => {\n if (old.searchValue === value) {\n return old;\n }\n return {\n ...old,\n searchValue: value || '',\n };\n }, actions.setSearch);\n setResolvedSearch(value || '');\n },\n [setState, setResolvedSearch],\n );\n\n const prevIsOpen = usePrevious(isOpen);\n\n const highlightIndex = useCallback(\n (indexForHighlight: IndexForHighlight, scrollToHighlighted: boolean) => {\n setState((old) => {\n const newIndex = Math.min(\n Math.max(\n 0,\n typeof indexForHighlight === 'function'\n ? indexForHighlight(old.highlightedIndex)\n : indexForHighlight,\n ),\n maxHighlightIndex - 1,\n );\n\n if (old.highlightedIndex === newIndex) {\n return old;\n }\n\n return {\n ...old,\n highlightedIndex: newIndex,\n scrollToHighlighted,\n };\n }, actions.highlightIndex);\n },\n [filteredOptions, setState, optionForCreate],\n );\n\n useLayoutEffect(() => {\n if (value !== null && !prevIsOpen && isOpen) {\n const currentHighlightIndex = getSelectedOptionIndex();\n if (filteredOptions.length > 0) {\n scrollToIndex(currentHighlightIndex, dropdownRef, optionsRefs, () =>\n highlightIndex(0, false),\n );\n }\n }\n });\n\n const removeValue = (e: React.SyntheticEvent, valueItem: ITEM) => {\n e.stopPropagation();\n if (isMultipleParams(params)) {\n const newValue = params.value?.filter(\n (item) => getItemKey(item) !== getItemKey(valueItem),\n );\n const val = newValue?.length ? newValue : null;\n params.onChange(val, {\n e,\n });\n }\n };\n\n const onChange = (e: React.SyntheticEvent, item: ITEM) => {\n if (getItemDisabled && getItemDisabled(item)) {\n return;\n }\n if (isMultipleParams(params)) {\n const newValue = value.some(\n (value) => getItemKey(value) === getItemKey(item),\n )\n ? value.filter((value) => getItemKey(value) !== getItemKey(item))\n : [...value, item];\n const val = newValue?.length ? newValue : null;\n params.onChange(val, { e });\n }\n if (isNotMultipleParams(params)) {\n params.onChange(item, { e });\n setOpen(false);\n setSearch('');\n }\n };\n\n const onChangeAll = (parametrs: {\n e: React.SyntheticEvent;\n items: ITEM[];\n }) => {\n const { e, items } = parametrs;\n if (isMultipleParams(params)) {\n const nonDisabledItems = getItemDisabled\n ? items.filter((item) => !getItemDisabled(item))\n : items;\n\n const currentGroupValues: ITEM[] = [];\n const withoutGroupValues: ITEM[] = [];\n value.forEach((el) => {\n if (\n nonDisabledItems.find((item) => getItemKey(el) === getItemKey(item))\n ) {\n currentGroupValues.push(el);\n } else {\n withoutGroupValues.push(el);\n }\n });\n if (currentGroupValues.length === nonDisabledItems.length) {\n params.onChange(withoutGroupValues, { e });\n } else {\n const val = [...withoutGroupValues, ...nonDisabledItems];\n params.onChange(val, {\n e,\n });\n }\n }\n };\n\n const onCreate = (e: React.SyntheticEvent, label: string) => {\n params.onCreate && params.onCreate(label, { e, label });\n setOpen(false);\n setSearch('');\n };\n\n // Handlers\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>): void => {\n if (!disabled && !(!multiple && value.length > 0)) {\n setSearch(e.target.value);\n setOpen(true);\n }\n };\n\n const handleInputClick = (): void => {\n !disabled && setOpen(!isOpen);\n\n if (multiple) {\n inputRef.current?.focus();\n }\n };\n\n const clearValue = (e: React.SyntheticEvent) => {\n if (isMultipleParams(params)) {\n const results = value?.filter((item) => getItemDisabled?.(item));\n const val = results && results.length > 0 ? results : null;\n params.onChange(val, {\n e,\n });\n }\n if (isNotMultipleParams(params)) {\n params.onChange(null, { e });\n }\n setSearch('');\n };\n\n const getHandleRemoveValue = (item: ITEM) => (e: React.SyntheticEvent) =>\n removeValue(e, item);\n\n // Prop Getters\n\n const ArrowUp: KeyHandler = (_, e): void => {\n e.preventDefault();\n !disabled && setOpen(true);\n highlightIndex((old) => old - 1, true);\n };\n\n const ArrowDown: KeyHandler = (_, e): void => {\n e.preventDefault();\n !disabled && setOpen(true);\n highlightIndex((old) => old + 1, true);\n };\n\n const Enter: KeyHandler = (_, e): void => {\n if (isOpen) {\n if (searchValue || filteredOptions[highlightedIndex]) {\n e.preventDefault();\n }\n\n const getData = (\n index: number,\n ): [\n CountedGroup<ITEM, GROUP> | undefined,\n SelectAllItem | OptionForCreate | ITEM | undefined,\n ] => {\n let couter = 0;\n for (const group of visibleItems) {\n if (isOptionForCreate(group)) {\n couter++;\n return [undefined, group];\n }\n if (group.items.length + couter > index) {\n return [group, group.items[index - couter]];\n }\n couter += group.items.length;\n }\n return [undefined, undefined];\n };\n\n const [group, item] = getData(highlightedIndex);\n\n if (isOptionForCreate(item)) {\n onCreate(e, item.label);\n return;\n }\n\n if (isOptionForSelectAll(item)) {\n onChangeAll({\n e,\n items:\n (group?.items.filter(\n (el) => !isOptionForSelectAll(el),\n ) as ITEM[]) ?? [],\n });\n return;\n }\n\n if (item) {\n onChange(e, item);\n }\n } else {\n setOpen(true);\n }\n };\n\n const Escape: KeyHandler = (): void => {\n setOpen(false);\n };\n\n const Tab: KeyHandler = (_, e): void => {\n if (isOpen) {\n e.preventDefault();\n setOpen(false);\n }\n };\n\n const Backspace: KeyHandler = (_, e): void => {\n if (searchValue) {\n return;\n }\n if (multiple) {\n removeValue(e, value[value.length - 1]);\n } else {\n clearValue(e);\n }\n };\n\n const getKeyProps = useKeys({\n ArrowUp,\n ArrowDown,\n PageUp: ArrowUp,\n PageDown: ArrowDown,\n Home: ArrowUp,\n End: ArrowDown,\n Enter,\n Escape,\n Tab,\n Backspace,\n });\n\n const getOptionProps = ({\n index,\n item,\n keyPrefix,\n }: OptionProps<ITEM>): GetOptionPropsResult => {\n if (isOptionForCreate(item)) {\n return {\n onClick: (e: React.SyntheticEvent) => {\n onCreate(e, item.label);\n },\n onMouseEnter: () => {\n highlightIndex(index, false);\n },\n active: false,\n hovered: index === highlightedIndex,\n key: `${keyPrefix}__optionForCreate`,\n };\n }\n if (isOptionForSelectAll(item)) {\n const getItems = (): ITEM[] => {\n for (const group of visibleItems) {\n if (isOptionForCreate(group)) {\n break;\n }\n if (group.key === item.groupKey) {\n return (\n (group?.items.filter(\n (el) => !isOptionForSelectAll(el),\n ) as ITEM[]) ?? []\n );\n }\n }\n return [];\n };\n return {\n onClick: (e: React.SyntheticEvent) => {\n onChangeAll({ e, items: getItems() });\n },\n onMouseEnter: () => {\n highlightIndex(index, false);\n },\n active: false,\n hovered: index === highlightedIndex,\n key: `${keyPrefix}__optionForSelectAll`,\n };\n }\n const key = getItemKey(item);\n return {\n onClick: (e: React.SyntheticEvent) => {\n onChange(e, item);\n },\n onMouseEnter: () => {\n highlightIndex(index, false);\n },\n active: Boolean(value.find((item) => getItemKey(item) === key)),\n hovered: index === highlightedIndex,\n key: `${keyPrefix}${key}`,\n };\n };\n\n useClickOutside({\n isActive: isOpen,\n ignoreClicksInsideRefs: [\n dropdownRef,\n controlRef,\n ...(ignoreOutsideClicksRefs || []),\n ],\n handler: () => {\n setOpen(false);\n },\n });\n\n useEffect(() => {\n if (disabled) {\n setOpen(false);\n }\n }, [disabled]);\n\n useEffect(() => {\n const currentHighlightIndex = getSelectedOptionIndex();\n highlightIndex(currentHighlightIndex, true);\n }, [highlightIndex]);\n\n useEffect(() => {\n if (filteredOptions.length > 0 && scrollToHighlighted) {\n scrollToIndex(highlightedIndex, dropdownRef, optionsRefs, () =>\n highlightIndex(0, false),\n );\n }\n }, [highlightedIndex]);\n\n const handleInputFocus = (e: React.FocusEvent<HTMLInputElement>): void => {\n if (!disabled) {\n if (!isFocused) {\n setIsFocused(true);\n }\n if (typeof onFocus === 'function') {\n onFocus(e);\n }\n }\n };\n\n const handleInputBlur = (e: React.FocusEvent<HTMLInputElement>): void => {\n if (isOpen) {\n inputRef.current?.focus();\n return;\n }\n\n if (isFocused) {\n setIsFocused(false);\n }\n\n if (typeof onBlur === 'function') {\n onBlur(e);\n }\n };\n\n const handleToggleDropdown = (): void => {\n if (isOpen) {\n setOpen(false);\n setIsFocused(false);\n } else {\n setOpen(true);\n setIsFocused(true);\n inputRef.current?.focus();\n }\n };\n\n useEffect(() => {\n setSearch(searchValueProp);\n }, [searchValueProp]);\n\n useEffect(() => {\n dropdownRef.current?.scrollTo({ top: 0 });\n }, [resolvedSearchValue]);\n\n useEffect(() => {\n onDropdownOpen?.(isOpen);\n }, [isOpen]);\n\n useEffect(() => {\n onSearchValueChangeRef.current?.(searchValue);\n }, [searchValue]);\n\n useEffect(() => {\n setOpen(dropdownOpen || false);\n }, [dropdownOpen]);\n\n return {\n isOpen,\n isFocused,\n highlightedIndex,\n visibleItems,\n highlightIndex,\n getOptionProps,\n handleInputFocus,\n handleInputBlur,\n handleToggleDropdown,\n handleInputClick,\n inputRef,\n getKeyProps,\n handleInputChange,\n searchValue,\n clearValue,\n getHandleRemoveValue,\n notFound,\n hasItems,\n allItemsSelected,\n optionsRefs,\n };\n}\n"],"mappings":"4pEAAA,OACEA,WADF,CAEEC,SAFF,CAGEC,eAHF,CAIEC,OAJF,CAKEC,MALF,CAMEC,QANF,KAOO,OAPP,CASA,OAASC,eAAT,sCACA,OAASC,WAAT,kCACA,OAAqBC,OAArB,wCACA,OAASC,aAAT,oCACA,OAASC,WAAT,kCACA,OAASC,OAAT,8BACA,OAEEC,gBAFF,CAGEC,SAHF,gCAOA,OAASC,aAAT,CAAwBC,eAAxB,iB,GA6EMC,iBAAgB,CAAG,SACvBC,CADuB,CAEsB,CAC7C,MAAOA,EAAM,CAACC,QACf,C,CAEKC,mBAAmB,CAAG,SAC1BF,CAD0B,CAEoB,CAC9C,MAAO,CAACA,CAAM,CAACC,QAChB,C,CAEKE,OAAO,CAAG,CACdC,OAAO,CAAE,SADK,CAEdC,SAAS,CAAE,WAFG,CAGdC,cAAc,CAAE,gBAHF,C,CAMVC,YAAY,CAAG,CAC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+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;--counter-offset:0;--clear-button-color:var(--color-control-typo-clear);display:inline-flex;position:relative;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_icon,.TextField-InputContainer_withValue .TextField-Side.TextField-Side_type_string{color:var(--color-typo-secondary)}.TextField-InputContainer_incrementButtons{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{height:calc(var(--input-height) - var(--control-border-width)*2);margin-right:var(--counter-offset)}.TextField-Counter,.TextField-CounterButton{display:inline-flex;flex-direction:column;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;flex:1;justify-content:center;margin:0;overflow-y:hidden;padding:0;transition:background-color .15s}.TextField-CounterButton_fn_increment{transform:rotate(180deg)}.TextField-ClearButton,.TextField-EyeButton{align-items:center;background-color:transparent;border:none;cursor:pointer;display:flex;flex-direction:row;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{color:var(--color-control-typo-placeholder)}.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: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;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_icon,.TextField-InputContainer_withValue .TextField-Side.TextField-Side_type_string{color:var(--color-typo-secondary)}.TextField-InputContainer_incrementButtons{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{height:calc(var(--input-height) - var(--control-border-width)*2);margin-right:var(--counter-offset)}.TextField-Counter,.TextField-CounterButton{display:inline-flex;flex-direction:column;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;flex:1;justify-content:center;margin:0;overflow-y:hidden;padding:0;transition:background-color .15s}.TextField-CounterButton_fn_increment{transform:rotate(180deg)}.TextField-ClearButton,.TextField-EyeButton{align-items:center;background-color:transparent;border:none;cursor:pointer;display:flex;flex-direction:row;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{color:var(--color-control-typo-placeholder)}.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)}
@@ -78,7 +78,7 @@ export declare type UserSelectProps<ITEM = UserSelectItemDefault, GROUP = UserSe
78
78
  caption?: string;
79
79
  labelPosition?: 'top' | 'left';
80
80
  virtualScroll?: boolean;
81
- onScrollToBottom?: () => void;
81
+ onScrollToBottom?: (lenght: number) => void;
82
82
  onSearchValueChange?: (value: string) => void;
83
83
  onDropdownOpen?: (isOpen: boolean) => void;
84
84
  dropdownOpen?: boolean;
@@ -156,7 +156,7 @@ export declare function withDefaultGetters<ITEM = UserSelectItemDefault, GROUP =
156
156
  caption?: string | undefined;
157
157
  labelPosition?: "left" | "top" | undefined;
158
158
  virtualScroll?: boolean | undefined;
159
- onScrollToBottom?: (() => void) | undefined;
159
+ onScrollToBottom?: ((lenght: number) => void) | undefined;
160
160
  onSearchValueChange?: ((value: string) => void) | undefined;
161
161
  onDropdownOpen?: ((isOpen: boolean) => void) | undefined;
162
162
  dropdownOpen?: boolean | undefined;
@@ -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","clearSizeMap","xs","s","m","l","iconSizeMap"],"sources":["../../../../../src/components/UserSelect/helpers.ts"],"sourcesContent":["import { IconComponent, IconPropSize } 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 UserSelectItemDefault = {\n label: string;\n id: string | number;\n subLabel?: string;\n avatarUrl?: string;\n groupId?: string | number;\n disabled?: boolean;\n};\n\nexport type UserSelectGroupDefault = {\n label: string;\n id: string | number;\n};\n\ntype UserSelectRenderValueProps<ITEM> = {\n item: ITEM;\n handleRemove?: (e: React.SyntheticEvent) => void;\n};\n\nexport type UserSelectPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type UserSelectPropGetItemSubLabel<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type UserSelectPropGetItemAvatarUrl<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type UserSelectPropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type UserSelectPropGetItemGroupKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\nexport type UserSelectPropGetItemDisabled<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\nexport type UserSelectPropGetGroupKey<GROUP> = (\n group: GROUP,\n) => string | number;\nexport type UserSelectPropGetGroupLabel<GROUP> = (group: GROUP) => string;\n\ntype UserSelectPropSearchFunction<ITEM> = (\n item: ITEM,\n searchValue: string,\n) => boolean;\ntype UserSelectPropOnChange<ITEM, MULTIPLE extends boolean> = (\n value: (MULTIPLE extends true ? ITEM[] : ITEM) | null,\n props: {\n e: React.SyntheticEvent;\n },\n) => void;\ntype UserSelectPropValue<ITEM, MULTIPLE extends boolean> =\n | (MULTIPLE extends true ? ITEM[] : ITEM)\n | null\n | undefined;\n\nexport type UserSelectPropRenderItem<ITEM> = (\n props: RenderItemProps<ITEM>,\n) => React.ReactElement | null;\nexport type UserSelectPropRenderValue<ITEM> = (\n props: UserSelectRenderValueProps<ITEM>,\n) => React.ReactElement | null;\n\nexport type UserSelectProps<\n ITEM = UserSelectItemDefault,\n GROUP = UserSelectGroupDefault,\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?: UserSelectPropRenderItem<ITEM>;\n renderValue?: UserSelectPropRenderValue<ITEM>;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n onCreate?: (label: string, props: { e: React.SyntheticEvent }) => void;\n inputRef?: React.RefObject<HTMLInputElement>;\n labelForNotFound?: string;\n labelForCreate?: string;\n labelForEmptyItems?: string;\n searchFunction?: UserSelectPropSearchFunction<ITEM>;\n searchValue?: string;\n multiple?: MULTIPLE;\n value?: UserSelectPropValue<ITEM, MULTIPLE>;\n onChange: UserSelectPropOnChange<ITEM, MULTIPLE>;\n groups?: GROUP[];\n getItemLabel?: UserSelectPropGetItemLabel<ITEM>;\n getItemSubLabel?: UserSelectPropGetItemSubLabel<ITEM>;\n getItemAvatarUrl?: UserSelectPropGetItemAvatarUrl<ITEM>;\n getItemKey?: UserSelectPropGetItemKey<ITEM>;\n getItemGroupKey?: UserSelectPropGetItemGroupKey<ITEM>;\n getItemDisabled?: UserSelectPropGetItemDisabled<ITEM>;\n getGroupLabel?: UserSelectPropGetGroupLabel<GROUP>;\n getGroupKey?: UserSelectPropGetGroupKey<GROUP>;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n labelPosition?: 'top' | 'left';\n virtualScroll?: boolean;\n onScrollToBottom?: () => void;\n onSearchValueChange?: (value: string) => void;\n onDropdownOpen?: (isOpen: boolean) => void;\n dropdownOpen?: boolean;\n ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n },\n HTMLDivElement\n> &\n (ITEM extends { label: UserSelectItemDefault['label'] }\n ? {}\n : { getItemLabel: UserSelectPropGetItemLabel<ITEM> }) &\n (ITEM extends { id: UserSelectItemDefault['id'] }\n ? {}\n : { getItemKey: UserSelectPropGetItemKey<ITEM> }) &\n (GROUP extends { label: UserSelectGroupDefault['label'] }\n ? {}\n : { getGroupLabel: UserSelectPropGetGroupLabel<GROUP> }) &\n (GROUP extends { id: UserSelectGroupDefault['id'] }\n ? {}\n : { getGroupKey: UserSelectPropGetGroupKey<GROUP> });\n\nexport type UserSelectComponent = <\n ITEM = UserSelectItemDefault,\n GROUP = UserSelectGroupDefault,\n MULTIPLE extends boolean = false,\n>(\n props: UserSelectProps<ITEM, GROUP, MULTIPLE>,\n) => React.ReactElement | null;\n\nexport const defaultGetItemKey: UserSelectPropGetItemKey<\n UserSelectItemDefault\n> = (item) => item.id;\nexport const defaultGetItemLabel: UserSelectPropGetItemLabel<\n UserSelectItemDefault\n> = (item) => item.label;\nexport const defaultGetItemSubLabel: UserSelectPropGetItemSubLabel<\n UserSelectItemDefault\n> = (item) => item.subLabel;\nexport const defaultGetItemAvatarUrl: UserSelectPropGetItemAvatarUrl<\n UserSelectItemDefault\n> = (item) => item.avatarUrl;\nexport const defaultGetItemGroupKey: UserSelectPropGetItemGroupKey<\n UserSelectItemDefault\n> = (item) => item.groupId;\nexport const defaultGetItemDisabled: UserSelectPropGetItemDisabled<\n UserSelectItemDefault\n> = (item) => item.disabled;\n\nexport const defaultGetGroupKey: UserSelectPropGetGroupKey<\n UserSelectGroupDefault\n> = (group) => group.id;\nexport const defaultGetGroupLabel: UserSelectPropGetGroupLabel<\n UserSelectGroupDefault\n> = (group) => 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 = UserSelectItemDefault,\n GROUP = UserSelectGroupDefault,\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\nexport const clearSizeMap: Record<PropSize, IconPropSize> = {\n xs: 'xs',\n s: 's',\n m: 's',\n l: 'm',\n};\n\nexport const iconSizeMap: Record<PropSize, IconPropSize> = {\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'm',\n};\n"],"mappings":"qqBAqJA,MAAO,IAAMA,kBAEZ,CAAG,SAACC,CAAD,QAAUA,EAAI,CAACC,EAAf,CAFG,CAGP,MAAO,IAAMC,oBAEZ,CAAG,SAACF,CAAD,QAAUA,EAAI,CAACG,KAAf,CAFG,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACJ,CAAD,QAAUA,EAAI,CAACK,QAAf,CAFG,CAGP,MAAO,IAAMC,wBAEZ,CAAG,SAACN,CAAD,QAAUA,EAAI,CAACO,SAAf,CAFG,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACR,CAAD,QAAUA,EAAI,CAACS,OAAf,CAFG,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACV,CAAD,QAAUA,EAAI,CAACW,QAAf,CAFG,CAIP,MAAO,IAAMC,mBAEZ,CAAG,SAACC,CAAD,QAAWA,EAAK,CAACZ,EAAjB,CAFG,CAGP,MAAO,IAAMa,qBAEZ,CAAG,SAACD,CAAD,QAAWA,EAAK,CAACV,KAAjB,CAFG,CAIP,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,CAaP,MAAO,IAAME,aAA4C,CAAG,CAC1DC,EAAE,CAAE,IADsD,CAE1DC,CAAC,CAAE,GAFuD,CAG1DC,CAAC,CAAE,GAHuD,CAI1DC,CAAC,CAAE,GAJuD,CAArD,CAOP,MAAO,IAAMC,YAA2C,CAAG,CACzDJ,EAAE,CAAE,IADqD,CAEzDC,CAAC,CAAE,GAFsD,CAGzDC,CAAC,CAAE,GAHsD,CAIzDC,CAAC,CAAE,GAJsD,CAApD"}
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","clearSizeMap","xs","s","m","l","iconSizeMap"],"sources":["../../../../../src/components/UserSelect/helpers.ts"],"sourcesContent":["import { IconComponent, IconPropSize } 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 UserSelectItemDefault = {\n label: string;\n id: string | number;\n subLabel?: string;\n avatarUrl?: string;\n groupId?: string | number;\n disabled?: boolean;\n};\n\nexport type UserSelectGroupDefault = {\n label: string;\n id: string | number;\n};\n\ntype UserSelectRenderValueProps<ITEM> = {\n item: ITEM;\n handleRemove?: (e: React.SyntheticEvent) => void;\n};\n\nexport type UserSelectPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type UserSelectPropGetItemSubLabel<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type UserSelectPropGetItemAvatarUrl<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type UserSelectPropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type UserSelectPropGetItemGroupKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\nexport type UserSelectPropGetItemDisabled<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\nexport type UserSelectPropGetGroupKey<GROUP> = (\n group: GROUP,\n) => string | number;\nexport type UserSelectPropGetGroupLabel<GROUP> = (group: GROUP) => string;\n\ntype UserSelectPropSearchFunction<ITEM> = (\n item: ITEM,\n searchValue: string,\n) => boolean;\ntype UserSelectPropOnChange<ITEM, MULTIPLE extends boolean> = (\n value: (MULTIPLE extends true ? ITEM[] : ITEM) | null,\n props: {\n e: React.SyntheticEvent;\n },\n) => void;\ntype UserSelectPropValue<ITEM, MULTIPLE extends boolean> =\n | (MULTIPLE extends true ? ITEM[] : ITEM)\n | null\n | undefined;\n\nexport type UserSelectPropRenderItem<ITEM> = (\n props: RenderItemProps<ITEM>,\n) => React.ReactElement | null;\nexport type UserSelectPropRenderValue<ITEM> = (\n props: UserSelectRenderValueProps<ITEM>,\n) => React.ReactElement | null;\n\nexport type UserSelectProps<\n ITEM = UserSelectItemDefault,\n GROUP = UserSelectGroupDefault,\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?: UserSelectPropRenderItem<ITEM>;\n renderValue?: UserSelectPropRenderValue<ITEM>;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n onCreate?: (label: string, props: { e: React.SyntheticEvent }) => void;\n inputRef?: React.RefObject<HTMLInputElement>;\n labelForNotFound?: string;\n labelForCreate?: string;\n labelForEmptyItems?: string;\n searchFunction?: UserSelectPropSearchFunction<ITEM>;\n searchValue?: string;\n multiple?: MULTIPLE;\n value?: UserSelectPropValue<ITEM, MULTIPLE>;\n onChange: UserSelectPropOnChange<ITEM, MULTIPLE>;\n groups?: GROUP[];\n getItemLabel?: UserSelectPropGetItemLabel<ITEM>;\n getItemSubLabel?: UserSelectPropGetItemSubLabel<ITEM>;\n getItemAvatarUrl?: UserSelectPropGetItemAvatarUrl<ITEM>;\n getItemKey?: UserSelectPropGetItemKey<ITEM>;\n getItemGroupKey?: UserSelectPropGetItemGroupKey<ITEM>;\n getItemDisabled?: UserSelectPropGetItemDisabled<ITEM>;\n getGroupLabel?: UserSelectPropGetGroupLabel<GROUP>;\n getGroupKey?: UserSelectPropGetGroupKey<GROUP>;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n labelPosition?: 'top' | 'left';\n virtualScroll?: boolean;\n onScrollToBottom?: (lenght: number) => void;\n onSearchValueChange?: (value: string) => void;\n onDropdownOpen?: (isOpen: boolean) => void;\n dropdownOpen?: boolean;\n ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n },\n HTMLDivElement\n> &\n (ITEM extends { label: UserSelectItemDefault['label'] }\n ? {}\n : { getItemLabel: UserSelectPropGetItemLabel<ITEM> }) &\n (ITEM extends { id: UserSelectItemDefault['id'] }\n ? {}\n : { getItemKey: UserSelectPropGetItemKey<ITEM> }) &\n (GROUP extends { label: UserSelectGroupDefault['label'] }\n ? {}\n : { getGroupLabel: UserSelectPropGetGroupLabel<GROUP> }) &\n (GROUP extends { id: UserSelectGroupDefault['id'] }\n ? {}\n : { getGroupKey: UserSelectPropGetGroupKey<GROUP> });\n\nexport type UserSelectComponent = <\n ITEM = UserSelectItemDefault,\n GROUP = UserSelectGroupDefault,\n MULTIPLE extends boolean = false,\n>(\n props: UserSelectProps<ITEM, GROUP, MULTIPLE>,\n) => React.ReactElement | null;\n\nexport const defaultGetItemKey: UserSelectPropGetItemKey<\n UserSelectItemDefault\n> = (item) => item.id;\nexport const defaultGetItemLabel: UserSelectPropGetItemLabel<\n UserSelectItemDefault\n> = (item) => item.label;\nexport const defaultGetItemSubLabel: UserSelectPropGetItemSubLabel<\n UserSelectItemDefault\n> = (item) => item.subLabel;\nexport const defaultGetItemAvatarUrl: UserSelectPropGetItemAvatarUrl<\n UserSelectItemDefault\n> = (item) => item.avatarUrl;\nexport const defaultGetItemGroupKey: UserSelectPropGetItemGroupKey<\n UserSelectItemDefault\n> = (item) => item.groupId;\nexport const defaultGetItemDisabled: UserSelectPropGetItemDisabled<\n UserSelectItemDefault\n> = (item) => item.disabled;\n\nexport const defaultGetGroupKey: UserSelectPropGetGroupKey<\n UserSelectGroupDefault\n> = (group) => group.id;\nexport const defaultGetGroupLabel: UserSelectPropGetGroupLabel<\n UserSelectGroupDefault\n> = (group) => 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 = UserSelectItemDefault,\n GROUP = UserSelectGroupDefault,\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\nexport const clearSizeMap: Record<PropSize, IconPropSize> = {\n xs: 'xs',\n s: 's',\n m: 's',\n l: 'm',\n};\n\nexport const iconSizeMap: Record<PropSize, IconPropSize> = {\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'm',\n};\n"],"mappings":"qqBAqJA,MAAO,IAAMA,kBAEZ,CAAG,SAACC,CAAD,QAAUA,EAAI,CAACC,EAAf,CAFG,CAGP,MAAO,IAAMC,oBAEZ,CAAG,SAACF,CAAD,QAAUA,EAAI,CAACG,KAAf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AC3BC,CAD2B,CAE3BC,CAF2B,CAGf,SACPA,CADO,EAM+D,CAAC,CAA1E,GAAAA,CAAO,CAACC,iBAAR,GAA4BC,OAA5B,CAAoCH,CAAW,CAACE,iBAAZ,EAApC,CAEH,CAXM,CAaP,MAAO,IAAME,aAA4C,CAAG,CAC1DC,EAAE,CAAE,IADsD,CAE1DC,CAAC,CAAE,GAFuD,CAG1DC,CAAC,CAAE,GAHuD,CAI1DC,CAAC,CAAE,GAJuD,CAArD,CAOP,MAAO,IAAMC,YAA2C,CAAG,CACzDJ,EAAE,CAAE,IADqD,CAEzDC,CAAC,CAAE,GAFsD,CAGzDC,CAAC,CAAE,GAHsD,CAIzDC,CAAC,CAAE,GAJsD,CAApD"}
@@ -1,8 +1,21 @@
1
1
  import { RefObject } from 'react';
2
+ export declare type UseVirtualScrollProps = {
3
+ length: number;
4
+ isActive?: boolean;
5
+ onScrollToBottom?: (index: number) => void;
6
+ };
7
+ export declare type UseVirtualScrollReturn<ITEM_ELEMENT, SCROLL_ELEMENT> = {
8
+ listRefs: React.RefObject<ITEM_ELEMENT>[];
9
+ scrollElementRef: React.RefObject<SCROLL_ELEMENT>;
10
+ slice: [number, number];
11
+ spaceTop: number;
12
+ };
13
+ export declare type Bounds = [[number, number], [number, number]];
2
14
  export declare const defaultItemsCalculationCount = 5;
15
+ export declare const arraysIsEq: (arr1: number[], arr2: number[]) => boolean;
3
16
  export declare const useScroll: (ref: RefObject<HTMLElement>, fn: () => void, isActive: boolean) => void;
4
17
  export declare const getElementHeight: (el: HTMLElement | SVGGraphicsElement | null) => number;
5
- export declare const getVisiblePosition: (top: number, height: number) => [number, number];
18
+ export declare const getVisiblePosition: (top: number, height: number, elementMaxSize: number) => [number, number];
6
19
  export declare const calculateSavedSizes: (savedSizes: number[], sizes: number[]) => number[];
7
- export declare const useCalculateVisiblePosition: (scrollElement: HTMLElement | null, set: (value: React.SetStateAction<[number, number]>) => void) => () => void;
8
- export declare const calculateBounds: (savedSize: number[], size: number[], visiblePosition: [number, number], length: number) => [number, number][];
20
+ export declare const useCalculateVisiblePosition: (scrollElement: HTMLElement | null, set: (value: React.SetStateAction<[number, number]>) => void, elementsSizes: number[]) => () => void;
21
+ export declare const calculateBounds: (savedSizes: number[], sizes: number[], visiblePosition: [number, number], length: number) => Bounds;
@@ -1,2 +1,2 @@
1
- import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import{useCallback,useEffect}from"react";import{getElementSize}from"../useComponentSize";export var defaultItemsCalculationCount=5;var visualGap=200;export var useScroll=function(a,b,c){useEffect(function(){return c?b():void 0},[a.current,b,c]),useEffect(function(){if(c){var d;null===(d=a.current)||void 0===d?void 0:d.addEventListener("scroll",b)}return function(){var c;null===(c=a.current)||void 0===c?void 0:c.removeEventListener("scroll",b)}},[a.current,b,c])};export var getElementHeight=function(a){return getElementSize(a).height};var roundPositionByGap=function(a,b){return 0>=a?0:Math.ceil(a/b)*b};export var getVisiblePosition=function(a,b){var c=Math.ceil(roundPositionByGap(0>a-b?0:a-b,b)-visualGap);return[0>=c?0:c,Math.ceil(roundPositionByGap(0===a?b:a,b)+b+visualGap)]};export var calculateSavedSizes=function(a,b){for(var c,d=_toConsumableArray(a),e=0;e<b.length;e++)c=b[e],0<c&&(d[e]=c);return d};export var useCalculateVisiblePosition=function(a,b){return useCallback(function(){if(a){var c=getVisiblePosition(a.scrollTop,getElementHeight(a));b(function(a){return c[0]!==a[0]||c[1]!==a[1]?c:a})}},[a,b])};var addCount=function(a,b,c){for(var d=c.slice(-50),e=d.reduce(function(c,a){return c+a},0)/d.length,f=defaultItemsCalculationCount;b[1]>a[1]+f*e;)f+=defaultItemsCalculationCount;return f};export var calculateBounds=function(a,b,c,d){for(var e=[0,0],f=[0,0],g=0;g<a.length;g++)c[0]>e[0]&&(e[0]+=a[g],f[0]=g),c[1]>e[1]&&(e[1]+=a[g],f[1]=g);return 0===f[0]&&0===f[1]&&(f[1]=defaultItemsCalculationCount),a.length-1>=f[1]&&b.length!==a.length&&(f[1]+=addCount(e,c,a)),f[1]-1>d&&(f[1]=d-1),[e,f]};
1
+ import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import{useCallback,useEffect}from"react";import{getElementSize}from"../useComponentSize";import{useMutableRef}from"../useMutableRef";export var defaultItemsCalculationCount=5;export var arraysIsEq=function(a,b){return a.join("-")===b.join("-")};export var useScroll=function(a,b,c){useEffect(function(){if(c){var d;null===(d=a.current)||void 0===d?void 0:d.addEventListener("scroll",b)}return function(){var c;null===(c=a.current)||void 0===c?void 0:c.removeEventListener("scroll",b)}},[a.current,b,c])};export var getElementHeight=function(a){return getElementSize(a).height};var roundPositionByGap=function(a,b){return 0>=a?0:Math.ceil(a/b)*b};export var getVisiblePosition=function(a,b,c){var d=b>c*defaultItemsCalculationCount?1.5*b:c*defaultItemsCalculationCount,e=[Math.ceil(roundPositionByGap(a-d,b)),Math.ceil(roundPositionByGap(0===a?d:a+d,b))];return e};export var calculateSavedSizes=function(a,b){for(var c,d=_toConsumableArray(a),e=0;e<b.length;e++)c=b[e],0<c&&(d[e]=c);return d};export var useCalculateVisiblePosition=function(a,b,c){var d=useMutableRef(Math.max.apply(null,c));return useCallback(function(){if(a){var c=getVisiblePosition(a.scrollTop,getElementHeight(a),d.current);b(function(a){return c[0]!==a[0]||c[1]!==a[1]?c:a})}},[a,b])};var addCount=function(a,b,c){for(var d=c.slice(-50),e=d.reduce(function(c,a){return c+a},0)/d.length,f=defaultItemsCalculationCount;b[1]>=a[1]+f*e;)f+=defaultItemsCalculationCount;return f};export var calculateBounds=function(a,b,c,d){for(var e=[0,0],f=[0,0],g=0;g<a.length;g++)c[0]>e[0]&&(e[0]+=a[g],f[0]=g+1),c[1]>e[1]&&(e[1]+=a[g],f[1]=g+1);return 0===f[0]&&0===f[1]&&(f[1]=defaultItemsCalculationCount),b.length!==a.length&&(f[1]+=addCount(e,c,a)),f[1]>d&&(f[1]=d),[e,f]};
2
2
  //# sourceMappingURL=hellpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hellpers.js","names":["useCallback","useEffect","getElementSize","defaultItemsCalculationCount","visualGap","useScroll","ref","fn","isActive","current","addEventListener","removeEventListener","getElementHeight","el","height","roundPositionByGap","position","gap","Math","ceil","getVisiblePosition","top","first","calculateSavedSizes","savedSizes","sizes","element","newSavedSizes","index","length","useCalculateVisiblePosition","scrollElement","set","visiblePosition","scrollTop","state","addCount","pxs","savedSize","lastSavedSize","slice","average","reduce","a","b","add","calculateBounds","size","indexs"],"sources":["../../../../../src/hooks/useVirtualScroll/hellpers.ts"],"sourcesContent":["import { RefObject, useCallback, useEffect } from 'react';\n\nimport { getElementSize } from '##/hooks/useComponentSize';\n\nexport const defaultItemsCalculationCount = 5;\nconst visualGap = 200;\n\nexport const useScroll = (\n ref: RefObject<HTMLElement>,\n fn: () => void,\n isActive: boolean,\n) => {\n useEffect(() => (isActive ? fn() : undefined), [ref.current, fn, isActive]);\n useEffect(() => {\n if (isActive) {\n ref.current?.addEventListener('scroll', fn);\n }\n\n return () => {\n ref.current?.removeEventListener('scroll', fn);\n };\n }, [ref.current, fn, isActive]);\n};\n\nexport const getElementHeight = (el: HTMLElement | SVGGraphicsElement | null) =>\n getElementSize(el).height;\n\nconst roundPositionByGap = (position: number, gap: number) => {\n if (position <= 0) {\n return 0;\n }\n return Math.ceil(position / gap) * gap;\n};\n\nexport const getVisiblePosition = (\n top: number,\n height: number,\n): [number, number] => {\n const first = Math.ceil(\n roundPositionByGap(top - height < 0 ? 0 : top - height, height) - visualGap,\n );\n\n return [\n first <= 0 ? 0 : first,\n Math.ceil(\n roundPositionByGap(top === 0 ? height : top, height) + height + visualGap,\n ),\n ];\n};\n\nexport const calculateSavedSizes = (savedSizes: number[], sizes: number[]) => {\n const newSavedSizes = [...savedSizes];\n for (let index = 0; index < sizes.length; index++) {\n const element = sizes[index];\n if (element > 0) {\n newSavedSizes[index] = element;\n }\n }\n return newSavedSizes;\n};\n\nexport const useCalculateVisiblePosition = (\n scrollElement: HTMLElement | null,\n set: (value: React.SetStateAction<[number, number]>) => void,\n) =>\n useCallback(() => {\n if (!scrollElement) {\n return;\n }\n\n const visiblePosition = getVisiblePosition(\n scrollElement.scrollTop,\n getElementHeight(scrollElement),\n );\n\n set((state) => {\n if (visiblePosition[0] !== state[0] || visiblePosition[1] !== state[1]) {\n return visiblePosition;\n }\n\n return state;\n });\n }, [scrollElement, set]);\n\nconst addCount = (\n pxs: [number, number],\n visiblePosition: [number, number],\n savedSize: number[],\n) => {\n const lastSavedSize = savedSize.slice(-50);\n const average =\n lastSavedSize.reduce((a, b) => a + b, 0) / lastSavedSize.length;\n\n let add = defaultItemsCalculationCount;\n\n while (visiblePosition[1] > pxs[1] + add * average) {\n add += defaultItemsCalculationCount;\n }\n\n return add;\n};\n\nexport const calculateBounds = (\n savedSize: number[],\n size: number[],\n visiblePosition: [number, number],\n length: number,\n) => {\n const pxs: [number, number] = [0, 0];\n const indexs: [number, number] = [0, 0];\n\n for (let index = 0; index < savedSize.length; index++) {\n if (visiblePosition[0] > pxs[0]) {\n pxs[0] += savedSize[index];\n indexs[0] = index;\n }\n\n if (visiblePosition[1] > pxs[1]) {\n pxs[1] += savedSize[index];\n indexs[1] = index;\n }\n }\n\n if (indexs[0] === 0 && indexs[1] === 0) {\n indexs[1] = defaultItemsCalculationCount;\n }\n\n if (savedSize.length - 1 >= indexs[1] && size.length !== savedSize.length) {\n indexs[1] += addCount(pxs, visiblePosition, savedSize);\n }\n\n if (indexs[1] - 1 > length) {\n indexs[1] = length - 1;\n }\n\n return [pxs, indexs];\n};\n"],"mappings":"yEAAA,OAAoBA,WAApB,CAAiCC,SAAjC,KAAkD,OAAlD,CAEA,OAASC,cAAT,2BAEA,MAAO,IAAMC,6BAA4B,CAAG,CAArC,CACP,GAAMC,UAAS,CAAG,GAAlB,CAEA,MAAO,IAAMC,UAAS,CAAG,SACvBC,CADuB,CAEvBC,CAFuB,CAGvBC,CAHuB,CAIpB,CACHP,SAAS,CAAC,iBAAOO,EAAQ,CAAGD,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js","names":["useCallback","useEffect","getElementSize","useMutableRef","defaultItemsCalculationCount","arraysIsEq","arr1","arr2","join","useScroll","ref","fn","isActive","current","addEventListener","removeEventListener","getElementHeight","el","height","roundPositionByGap","position","gap","Math","ceil","getVisiblePosition","top","elementMaxSize","visiblePosition","calculateSavedSizes","savedSizes","sizes","element","newSavedSizes","index","length","useCalculateVisiblePosition","scrollElement","set","elementsSizes","elementMaxSizeRef","max","apply","scrollTop","state","addCount","pxs","savedSize","lastSavedSize","slice","average","reduce","a","b","add","calculateBounds","indexs"],"sources":["../../../../../src/hooks/useVirtualScroll/hellpers.ts"],"sourcesContent":["import { RefObject, useCallback, useEffect } from 'react';\n\nimport { getElementSize } from '##/hooks/useComponentSize';\nimport { useMutableRef } from '##/hooks/useMutableRef';\n\nexport type UseVirtualScrollProps = {\n length: number;\n isActive?: boolean;\n onScrollToBottom?: (index: number) => void;\n};\n\nexport type UseVirtualScrollReturn<ITEM_ELEMENT, SCROLL_ELEMENT> = {\n listRefs: React.RefObject<ITEM_ELEMENT>[];\n scrollElementRef: React.RefObject<SCROLL_ELEMENT>;\n slice: [number, number];\n spaceTop: number;\n};\n\nexport type Bounds = [[number, number], [number, number]];\n\nexport const defaultItemsCalculationCount = 5;\n\nexport const arraysIsEq = (arr1: number[], arr2: number[]) =>\n arr1.join('-') === arr2.join('-');\n\nexport const useScroll = (\n ref: RefObject<HTMLElement>,\n fn: () => void,\n isActive: boolean,\n) => {\n useEffect(() => {\n if (isActive) {\n ref.current?.addEventListener('scroll', fn);\n }\n\n return () => {\n ref.current?.removeEventListener('scroll', fn);\n };\n }, [ref.current, fn, isActive]);\n};\n\nexport const getElementHeight = (el: HTMLElement | SVGGraphicsElement | null) =>\n getElementSize(el).height;\n\nconst roundPositionByGap = (position: number, gap: number) => {\n if (position <= 0) {\n return 0;\n }\n return Math.ceil(position / gap) * gap;\n};\n\nexport const getVisiblePosition = (\n top: number,\n height: number,\n elementMaxSize: number,\n): [number, number] => {\n const gap =\n height > elementMaxSize * defaultItemsCalculationCount\n ? height * 1.5\n : elementMaxSize * defaultItemsCalculationCount;\n\n const visiblePosition: [number, number] = [\n Math.ceil(roundPositionByGap(top - gap, height)),\n Math.ceil(roundPositionByGap(top === 0 ? gap : top + gap, height)),\n ];\n\n return visiblePosition;\n};\n\nexport const calculateSavedSizes = (savedSizes: number[], sizes: number[]) => {\n const newSavedSizes = [...savedSizes];\n for (let index = 0; index < sizes.length; index++) {\n const element = sizes[index];\n if (element > 0) {\n newSavedSizes[index] = element;\n }\n }\n return newSavedSizes;\n};\n\nexport const useCalculateVisiblePosition = (\n scrollElement: HTMLElement | null,\n set: (value: React.SetStateAction<[number, number]>) => void,\n elementsSizes: number[],\n) => {\n const elementMaxSizeRef = useMutableRef(Math.max.apply(null, elementsSizes));\n\n return useCallback(() => {\n if (!scrollElement) {\n return;\n }\n\n const visiblePosition = getVisiblePosition(\n scrollElement.scrollTop,\n getElementHeight(scrollElement),\n elementMaxSizeRef.current,\n );\n\n set((state) => {\n if (visiblePosition[0] !== state[0] || visiblePosition[1] !== state[1]) {\n return visiblePosition;\n }\n\n return state;\n });\n }, [scrollElement, set]);\n};\n\nconst addCount = (\n pxs: [number, number],\n visiblePosition: [number, number],\n savedSize: number[],\n) => {\n const lastSavedSize = savedSize.slice(-50);\n const average =\n lastSavedSize.reduce((a, b) => a + b, 0) / lastSavedSize.length;\n\n let add = defaultItemsCalculationCount;\n\n while (visiblePosition[1] >= pxs[1] + add * average) {\n add += defaultItemsCalculationCount;\n }\n\n return add;\n};\n\nexport const calculateBounds = (\n savedSizes: number[],\n sizes: number[],\n visiblePosition: [number, number],\n length: number,\n): Bounds => {\n const pxs: [number, number] = [0, 0];\n const indexs: [number, number] = [0, 0];\n\n for (let index = 0; index < savedSizes.length; index++) {\n if (visiblePosition[0] > pxs[0]) {\n pxs[0] += savedSizes[index];\n indexs[0] = index + 1;\n }\n\n if (visiblePosition[1] > pxs[1]) {\n pxs[1] += savedSizes[index];\n indexs[1] = index + 1;\n }\n }\n\n if (indexs[0] === 0 && indexs[1] === 0) {\n indexs[1] = defaultItemsCalculationCount;\n }\n\n if (sizes.length !== savedSizes.length) {\n indexs[1] += addCount(pxs, visiblePosition, savedSizes);\n }\n\n if (indexs[1] > length) {\n indexs[1] = length;\n }\n\n return [pxs, indexs];\n};\n"],"mappings":"yEAAA,OAAoBA,WAApB,CAAiCC,SAAjC,KAAkD,OAAlD,CAEA,OAASC,cAAT,2BACA,OAASC,aAAT,wBAiBA,MAAO,IAAMC,6BAA4B,CAAG,CAArC,CAEP,MAAO,IAAMC,WAAU,CAAG,SAACC,CAAD,CAAiBC,CAAjB,QACxBD,EAAI,CAACE,IAAL,CAAU,GAAV,IAAmBD,CAAI,CAACC,IAAL,CAAU,GAAV,CADK,CAAnB,CAGP,MAAO,IAAMC,UAAS,CAAG,SACvBC,CADuB,CAEvBC,CAFuB,CAGvBC,CAHuB,CAIpB,CACHX,SAAS,CAAC,UAAM,CACd,GAAIW,CAAJ,CAAc,iBACZF,CAAG,CAACG,OADQ,qBACZ,EAAaC,gBAAb,CAA8B,QAA9B,CAAwCH,CAAxC,CACD,CAED,MAAO,WAAM,iBACXD,CAAG,CAACG,OADO,qBACX,EAAaE,mBAAb,CAAiC,QAAjC,CAA2CJ,CAA3C,CACD,CACF,CARQ,CAQN,CAACD,CAAG,CAACG,OAAL,CAAcF,CAAd,CAAkBC,CAAlB,CARM,CASV,CAdM,CAgBP,MAAO,IAAMI,iBAAgB,CAAG,SAACC,CAAD,QAC9Bf,eAAc,CAACe,CAAD,CAAd,CAAmBC,MADW,CAAzB,CAGP,GAAMC,mBAAkB,CAAG,SAACC,CAAD,CAAmBC,CAAnB,CAAmC,OAC5C,EAAZ,EAAAD,CADwD,CAEnD,CAFmD,CAIrDE,IAAI,CAACC,IAAL,CAAUH,CAAQ,CAAGC,CAArB,EAA4BA,CACpC,CALD,CAOA,MAAO,IAAMG,mBAAkB,CAAG,SAChCC,CADgC,CAEhCP,CAFgC,CAGhCQ,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,CAAC,CAAD,CAAH,EAAUhB,CAAU,CAACI,CAAD,CAPxB,CAQIsB,CAAM,CAAC,CAAD,CAAN,CAAYtB,CAAK,CAAG,CARxB,EAwBA,MAZkB,EAAd,GAAAsB,CAAM,CAAC,CAAD,CAAN,EAAiC,CAAd,GAAAA,CAAM,CAAC,CAAD,CAY7B,GAXEA,CAAM,CAAC,CAAD,CAAN,CAAYnD,4BAWd,EARI0B,CAAK,CAACI,MAAN,GAAiBL,CAAU,CAACK,MAQhC,GAPEqB,CAAM,CAAC,CAAD,CAAN,EAAaX,QAAQ,CAACC,CAAD,CAAMlB,CAAN,CAAuBE,CAAvB,CAOvB,EAJI0B,CAAM,CAAC,CAAD,CAAN,CAAYrB,CAIhB,GAHEqB,CAAM,CAAC,CAAD,CAAN,CAAYrB,CAGd,EAAO,CAACW,CAAD,CAAMU,CAAN,CACR,CAlCM"}
@@ -1,14 +1,2 @@
1
- /// <reference types="react" />
2
- declare type UseVirtualScrollProps = {
3
- length: number;
4
- isActive?: boolean;
5
- onScrollToBottom?: (index: number) => void;
6
- };
7
- declare type UseVirtualScrollReturn<ITEM_ELEMENT, SCROLL_ELEMENT> = {
8
- listRefs: React.RefObject<ITEM_ELEMENT>[];
9
- scrollElementRef: React.RefObject<SCROLL_ELEMENT>;
10
- slice: [number, number];
11
- spaceTop: number;
12
- };
1
+ import { UseVirtualScrollProps, UseVirtualScrollReturn } from './hellpers';
13
2
  export declare const useVirtualScroll: <ITEM_ELEMENT extends HTMLElement = HTMLDivElement, SCROLL_ELEMENT extends HTMLElement = HTMLDivElement>({ length, onScrollToBottom, isActive, }: UseVirtualScrollProps) => UseVirtualScrollReturn<ITEM_ELEMENT, SCROLL_ELEMENT>;
14
- export {};
@@ -1,2 +1,2 @@
1
- import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{useEffect,useRef,useState}from"react";import{useMutableRef}from"../useMutableRef";import{useRefs}from"../useRefs";import{useResizeObserved}from"../useResizeObserved";import{calculateBounds,calculateSavedSizes,defaultItemsCalculationCount,getElementHeight,useCalculateVisiblePosition,useScroll}from"./hellpers";export var useVirtualScroll=function(a){var b=a.length,c=a.onScrollToBottom,d=a.isActive,e=void 0!==d&&d,f=useState([0,0]),g=_slicedToArray(f,2),h=g[0],i=g[1],j=useState([[0,0],[0,e?defaultItemsCalculationCount:b]]),k=_slicedToArray(j,2),l=k[0],m=k[1],n=useRefs(b,h),o=useRef(null),p=useResizeObserved(n,getElementHeight),q=useRef(calculateSavedSizes([],p)),r=useMutableRef(c);return useScroll(o,useCalculateVisiblePosition(o.current,i),e),useEffect(function(){e?(q.current=calculateSavedSizes(q.current,p),m(calculateBounds(q.current,p,h,b))):m([[0,0],[0,b]])},[].concat(_toConsumableArray(h),[p,b,e])),useEffect(function(){r.current&&e&&l[1][1]+1>=b&&r.current(b)},[l[1][1],b,e]),{listRefs:n,scrollElementRef:o,slice:[0===l[1][0]?0:l[1][0]+1,0===l[1][1]?0:l[1][1]+1],spaceTop:l[0][0]}};
1
+ import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{useEffect,useMemo,useRef,useState}from"react";import{useMutableRef}from"../useMutableRef";import{useRefs}from"../useRefs";import{useResizeObserved}from"../useResizeObserved";import{arraysIsEq,calculateBounds,calculateSavedSizes,defaultItemsCalculationCount,getElementHeight,useCalculateVisiblePosition,useScroll}from"./hellpers";export var useVirtualScroll=function(a){var b=a.length,c=a.onScrollToBottom,d=a.isActive,e=void 0!==d&&d,f=useState([0,0]),g=_slicedToArray(f,2),h=g[0],i=g[1],j=useState([[0,0],[0,e?defaultItemsCalculationCount:b]]),k=_slicedToArray(j,2),l=k[0],m=k[1],n=useRefs(b,h),o=useRef(null),p=useResizeObserved(n,getElementHeight),q=useRef(calculateSavedSizes([],p)),r=useMutableRef(c),s=useResizeObserved(useMemo(function(){return[o]},[o]),getElementHeight),t=_slicedToArray(s,1),u=t[0],v=useCalculateVisiblePosition(o.current,i,p);return useScroll(o,v,e),useEffect(function(){e&&v()},[u,e]),useEffect(function(){e?(q.current=calculateSavedSizes(q.current,p),m(calculateBounds(q.current,p,h,b))):m([[0,0],[0,b]])},[].concat(_toConsumableArray(h),[p,b,e])),useEffect(function(){e&&r.current&&l[1][1]+1>=b&&r.current(b)},[l[1][1],e]),useEffect(function(){var a=[0,0],c=[[0,0],[0,e?defaultItemsCalculationCount:b]];m(function(a){return arraysIsEq(a[0],c[0])&&arraysIsEq(a[1],c[1])?a:c}),i(function(b){return arraysIsEq(b,a)?b:a})},[e]),{listRefs:n,scrollElementRef:o,slice:l[1],spaceTop:l[0][0]}};
2
2
  //# sourceMappingURL=useVirtualScroll.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useVirtualScroll.js","names":["useEffect","useRef","useState","useMutableRef","useRefs","useResizeObserved","calculateBounds","calculateSavedSizes","defaultItemsCalculationCount","getElementHeight","useCalculateVisiblePosition","useScroll","useVirtualScroll","length","onScrollToBottom","isActive","visiblePosition","setVisiblePosition","bounds","setBounds","listRefs","scrollElementRef","sizes","savedSizesRef","onScrollToBottomRef","current","slice","spaceTop"],"sources":["../../../../../src/hooks/useVirtualScroll/useVirtualScroll.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport { useMutableRef } from '##/hooks/useMutableRef';\nimport { useRefs } from '##/hooks/useRefs';\nimport { useResizeObserved } from '##/hooks/useResizeObserved';\n\nimport {\n calculateBounds,\n calculateSavedSizes,\n defaultItemsCalculationCount,\n getElementHeight,\n useCalculateVisiblePosition,\n useScroll,\n} from './hellpers';\n\ntype UseVirtualScrollProps = {\n length: number;\n isActive?: boolean;\n onScrollToBottom?: (index: number) => void;\n};\n\ntype UseVirtualScrollReturn<ITEM_ELEMENT, SCROLL_ELEMENT> = {\n listRefs: React.RefObject<ITEM_ELEMENT>[];\n scrollElementRef: React.RefObject<SCROLL_ELEMENT>;\n slice: [number, number];\n spaceTop: number;\n};\n\nexport const useVirtualScroll = <\n ITEM_ELEMENT extends HTMLElement = HTMLDivElement,\n SCROLL_ELEMENT extends HTMLElement = HTMLDivElement,\n>({\n length,\n onScrollToBottom,\n isActive = false,\n}: UseVirtualScrollProps): UseVirtualScrollReturn<\n ITEM_ELEMENT,\n SCROLL_ELEMENT\n> => {\n const [visiblePosition, setVisiblePosition] = useState<[number, number]>([\n 0, 0,\n ]);\n const [bounds, setBounds] = useState<number[][]>([\n [0, 0],\n [0, isActive ? defaultItemsCalculationCount : length],\n ]);\n const listRefs = useRefs<ITEM_ELEMENT>(length, visiblePosition);\n const scrollElementRef = useRef<SCROLL_ELEMENT>(null);\n const sizes = useResizeObserved(listRefs, getElementHeight);\n const savedSizesRef = useRef(calculateSavedSizes([], sizes));\n const onScrollToBottomRef = useMutableRef(onScrollToBottom);\n\n useScroll(\n scrollElementRef,\n useCalculateVisiblePosition(scrollElementRef.current, setVisiblePosition),\n isActive,\n );\n\n useEffect(() => {\n if (isActive) {\n savedSizesRef.current = calculateSavedSizes(savedSizesRef.current, sizes);\n setBounds(\n calculateBounds(savedSizesRef.current, sizes, visiblePosition, length),\n );\n } else {\n setBounds([\n [0, 0],\n [0, length],\n ]);\n }\n }, [...visiblePosition, sizes, length, isActive]);\n\n useEffect(() => {\n if (onScrollToBottomRef.current && isActive && bounds[1][1] + 1 >= length) {\n onScrollToBottomRef.current(length);\n }\n }, [bounds[1][1], length, isActive]);\n\n return {\n listRefs,\n scrollElementRef,\n slice: [\n bounds[1][0] === 0 ? 0 : bounds[1][0] + 1,\n bounds[1][1] === 0 ? 0 : bounds[1][1] + 1,\n ],\n spaceTop: bounds[0][0],\n };\n};\n"],"mappings":"0IAAA,OAASA,SAAT,CAAoBC,MAApB,CAA4BC,QAA5B,KAA4C,OAA5C,CAEA,OAASC,aAAT,wBACA,OAASC,OAAT,kBACA,OAASC,iBAAT,4BAEA,OACEC,eADF,CAEEC,mBAFF,CAGEC,4BAHF,CAIEC,gBAJF,CAKEC,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Z9B,GAoBT,CANAf,SAAS,CAAC,UAAM,CACVwB,CAAmB,CAACC,OAApB,EAA+BV,CAA/B,EAA2CG,CAAM,CAAC,CAAD,CAAN,CAAU,CAAV,EAAe,CAAf,EAAoBL,CADrD,EAEZW,CAAmB,CAACC,OAApB,CAA4BZ,CAA5B,CAEH,CAJQ,CAIN,CAACK,CAAM,CAAC,CAAD,CAAN,CAAU,CAAV,CAAD,CAAeL,CAAf,CAAuBE,CAAvB,CAJM,CAMT,CAAO,CACLK,QAAQ,CAARA,CADK,CAELC,gBAAgB,CAAhBA,CAFK,CAGLK,KAAK,CAAE,CACY,CAAjB,GAAAR,CAAM,CAAC,CAAD,CAAN,CAAU,CAAV,EAAqB,CAArB,CAAyBA,CAAM,CAAC,CAAD,CAAN,CAAU,CAAV,EAAe,CADnC,CAEY,CAAjB,GAAAA,CAAM,CAAC,CAAD,CAAN,CAAU,CAAV,EAAqB,CAArB,CAAyBA,CAAM,CAAC,CAAD,CAAN,CAAU,CAAV,EAAe,CAFnC,CAHF,CAOLS,QAAQ,CAAET,CAAM,CAAC,CAAD,CAAN,CAAU,CAAV,CAPL,CASR,CA3DM"}
1
+ {"version":3,"file":"useVirtualScroll.js","names":["useEffect","useMemo","useRef","useState","useMutableRef","useRefs","useResizeObserved","arraysIsEq","calculateBounds","calculateSavedSizes","defaultItemsCalculationCount","getElementHeight","useCalculateVisiblePosition","useScroll","useVirtualScroll","length","onScrollToBottom","isActive","visiblePosition","setVisiblePosition","bounds","setBounds","listRefs","scrollElementRef","sizes","savedSizesRef","onScrollToBottomRef","scrollElementRefHeight","calculateVisiblePosition","current","resetVisiblePosition","resetBounds","state","slice","spaceTop"],"sources":["../../../../../src/hooks/useVirtualScroll/useVirtualScroll.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\n\nimport { useMutableRef } from '##/hooks/useMutableRef';\nimport { useRefs } from '##/hooks/useRefs';\nimport { useResizeObserved } from '##/hooks/useResizeObserved';\n\nimport {\n arraysIsEq,\n Bounds,\n calculateBounds,\n calculateSavedSizes,\n defaultItemsCalculationCount,\n getElementHeight,\n useCalculateVisiblePosition,\n useScroll,\n UseVirtualScrollProps,\n UseVirtualScrollReturn,\n} from './hellpers';\n\nexport const useVirtualScroll = <\n ITEM_ELEMENT extends HTMLElement = HTMLDivElement,\n SCROLL_ELEMENT extends HTMLElement = HTMLDivElement,\n>({\n length,\n onScrollToBottom,\n isActive = false,\n}: UseVirtualScrollProps): UseVirtualScrollReturn<\n ITEM_ELEMENT,\n SCROLL_ELEMENT\n> => {\n const [visiblePosition, setVisiblePosition] = useState<[number, number]>([\n 0, 0,\n ]);\n const [bounds, setBounds] = useState<Bounds>([\n [0, 0],\n [0, isActive ? defaultItemsCalculationCount : length],\n ]);\n const listRefs = useRefs<ITEM_ELEMENT>(length, visiblePosition);\n const scrollElementRef = useRef<SCROLL_ELEMENT>(null);\n const sizes = useResizeObserved(listRefs, getElementHeight);\n const savedSizesRef = useRef(calculateSavedSizes([], sizes));\n const onScrollToBottomRef = useMutableRef(onScrollToBottom);\n const [scrollElementRefHeight] = useResizeObserved(\n useMemo(() => {\n return [scrollElementRef];\n }, [scrollElementRef]),\n getElementHeight,\n );\n const calculateVisiblePosition = useCalculateVisiblePosition(\n scrollElementRef.current,\n setVisiblePosition,\n sizes,\n );\n\n useScroll(scrollElementRef, calculateVisiblePosition, isActive);\n\n useEffect(() => {\n if (isActive) {\n calculateVisiblePosition();\n }\n }, [scrollElementRefHeight, isActive]);\n\n useEffect(() => {\n if (isActive) {\n savedSizesRef.current = calculateSavedSizes(savedSizesRef.current, sizes);\n setBounds(\n calculateBounds(savedSizesRef.current, sizes, visiblePosition, length),\n );\n } else {\n setBounds([\n [0, 0],\n [0, length],\n ]);\n }\n }, [...visiblePosition, sizes, length, isActive]);\n\n useEffect(() => {\n if (isActive && onScrollToBottomRef.current && bounds[1][1] + 1 >= length) {\n onScrollToBottomRef.current(length);\n }\n }, [bounds[1][1], isActive]);\n\n useEffect(() => {\n const resetVisiblePosition: [number, number] = [0, 0];\n const resetBounds: Bounds = [\n [0, 0],\n [0, isActive ? defaultItemsCalculationCount : length],\n ];\n\n setBounds((state) =>\n arraysIsEq(state[0], resetBounds[0]) &&\n arraysIsEq(state[1], resetBounds[1])\n ? state\n : resetBounds,\n );\n\n setVisiblePosition((state) =>\n arraysIsEq(state, resetVisiblePosition) ? state : resetVisiblePosition,\n );\n }, [isActive]);\n\n return {\n listRefs,\n scrollElementRef,\n slice: bounds[1],\n spaceTop: bounds[0][0],\n };\n};\n"],"mappings":"0IAAA,OAASA,SAAT,CAAoBC,OAApB,CAA6BC,MAA7B,CAAqCC,QAArC,KAAqD,OAArD,CAEA,OAASC,aAAT,wBACA,OAASC,OAAT,kBACA,OAASC,iBAAT,4BAEA,OACEC,UADF,CAGEC,eAHF,CAIEC,mBAJF,CAKEC,4BALF,CAMEC,gBANF,CAOEC,2BAPF,CAQEC,SARF,kBAaA,MAAO,IAAMC,iBAAgB,CAAG,WAU3B,IANHC,EAMG,GANHA,MAMG,CALHC,CAKG,GALHA,gBAKG,KAJHC,QAIG,CAJHA,CAIG,iBAC2Cd,QAAQ,CAAmB,CACvE,CADuE,CACpE,CADoE,CAAnB,CADnD,uBACIe,CADJ,MACqBC,CADrB,QAIyBhB,QAAQ,CAAS,CAC3C,CAAC,CAAD,CAAI,CAAJ,CAD2C,CAE3C,CAAC,CAAD,CAAIc,CAAQ,CAAGP,4BAAH,CAAkCK,CAA9C,CAF2C,CAAT,CAJjC,uBAIIK,CAJJ,MAIYC,CAJZ,MAQGC,CAAQ,CAAGjB,OAAO,CAAeU,CAAf,CAAuBG,CAAvB,CARrB,CASGK,CAAgB,CAAGrB,MAAM,CAAiB,IAAjB,CAT5B,CAUGsB,CAAK,CAAGlB,iBAAiB,CAACgB,CAAD,CAAWX,gBAAX,CAV5B,CAWGc,CAAa,CAAGvB,MAAM,CAACO,mBAAmB,CAAC,EAAD,CAAKe,CAAL,CAApB,CAXzB,CAYGE,CAAmB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