@consta/uikit 4.0.1 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +9 -9
  2. package/__internal__/src/components/AutoCompleteCanary/AutoCompleteCanary.d.ts +3 -0
  3. package/__internal__/src/components/AutoCompleteCanary/AutoCompleteCanary.js +2 -0
  4. package/__internal__/src/components/AutoCompleteCanary/AutoCompleteCanary.js.map +1 -0
  5. package/__internal__/src/components/AutoCompleteCanary/helpers.d.ts +44 -0
  6. package/__internal__/src/components/AutoCompleteCanary/helpers.js +2 -0
  7. package/__internal__/src/components/AutoCompleteCanary/helpers.js.map +1 -0
  8. package/__internal__/src/components/AutoCompleteCanary/types.d.ts +51 -0
  9. package/__internal__/src/components/AutoCompleteCanary/types.js +2 -0
  10. package/__internal__/src/components/AutoCompleteCanary/types.js.map +1 -0
  11. package/__internal__/src/components/AutoCompleteCanary/useAutoComplete.d.ts +50 -0
  12. package/__internal__/src/components/AutoCompleteCanary/useAutoComplete.js +2 -0
  13. package/__internal__/src/components/AutoCompleteCanary/useAutoComplete.js.map +1 -0
  14. package/__internal__/src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.js +1 -1
  15. package/__internal__/src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.js.map +1 -1
  16. package/__internal__/src/components/ContextMenu/helpers.d.ts +2 -2
  17. package/__internal__/src/components/ContextMenu/types.d.ts +1 -1
  18. package/__internal__/src/components/ContextMenu/types.js.map +1 -1
  19. package/__internal__/src/components/SelectComponents/SelectItem/SelectItem.css +1 -1
  20. package/__internal__/src/components/Table/RowsCollapse/TableRowsCollapse.js +1 -1
  21. package/__internal__/src/components/Table/RowsCollapse/TableRowsCollapse.js.map +1 -1
  22. package/__internal__/src/components/Table/Table.d.ts +2 -0
  23. package/__internal__/src/components/Table/Table.js +1 -1
  24. package/__internal__/src/components/Table/Table.js.map +1 -1
  25. package/__internal__/src/components/TagBase/TagBase.d.ts +1 -1
  26. package/__internal__/src/docs/aboutConsta/components/AboutData/AboutData.css +1 -1
  27. package/__internal__/src/docs/aboutConsta/components/AboutData/AboutData.js +1 -1
  28. package/__internal__/src/docs/aboutConsta/components/AboutData/AboutData.js.map +1 -1
  29. package/__internal__/src/docs/tableComparison/components/AboutData/AboutData.css +1 -0
  30. package/__internal__/src/docs/tableComparison/components/AboutData/AboutData.d.ts +2 -0
  31. package/__internal__/src/docs/tableComparison/components/AboutData/AboutData.js +2 -0
  32. package/__internal__/src/docs/tableComparison/components/AboutData/AboutData.js.map +1 -0
  33. package/__internal__/src/docs/tableComparison/tableComparison.stand.d.ts +2 -0
  34. package/__internal__/src/docs/tableComparison/tableComparison.stand.js +2 -0
  35. package/__internal__/src/docs/tableComparison/tableComparison.stand.js.map +1 -0
  36. package/__internal__/src/hooks/useSelect/useSelect.d.ts +2 -0
  37. package/__internal__/src/hooks/useSelect/useSelect.js +1 -1
  38. package/__internal__/src/hooks/useSelect/useSelect.js.map +1 -1
  39. package/__internal__/src/uiKit/components/ComponentsGridWithData/data/additionalData.js +1 -1
  40. package/__internal__/src/uiKit/components/ComponentsGridWithData/data/additionalData.js.map +1 -1
  41. package/__internal__/src/utils/bem.d.ts +2 -0
  42. package/__internal__/src/utils/bem.js +1 -1
  43. package/__internal__/src/utils/bem.js.map +1 -1
  44. package/package.json +1 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # [Дизайн-система Consta](http://consta.gazprom-neft.ru/) | Библиотека интерфейсных компонентов
2
2
 
3
- Consta — дизайн-система для разработки интерфейсов, написана на [React](https://reactjs.org/), сделана и поддерживается в «Газпром нефти».
3
+ Consta — дизайн-система для разработки интерфейсов, написана на [React](https://reactjs.org/).
4
4
 
5
5
  В дизайн-систему входит несколько библиотек. **Здесь — библиотека интерфейсных компонентов:** простые контролы, сложные блоки, темы и хуки. Все библиотеки представлены в виде компонентов и макетов в Figma.
6
6
 
@@ -8,17 +8,17 @@ Consta — дизайн-система для разработки интерф
8
8
 
9
9
  ### Библиотека компонентов
10
10
 
11
- [Репозиторий](https://github.com/consta-design-system/uikit) | [NPM](https://www.npmjs.com/package/@consta/uikit) | [Документация и стенд](http://uikit.gizeasy.ru/?path=/story/common-about--page) | [Макеты](https://www.figma.com/community/file/853774806786762374)
11
+ [Репозиторий](https://github.com/consta-design-system/uikit) | [NPM](https://www.npmjs.com/package/@consta/uikit) | [Документация и стенд](http://uikit.consta.design/) | [Макеты](https://www.figma.com/community/file/853774806786762374)
12
12
 
13
13
  ### Библиотека графиков
14
14
 
15
- [Репозиторий](https://github.com/consta-design-system/charts) | [NPM](https://www.npmjs.com/package/@consta/charts) | [Документация и стенд](http://charts.gizeasy.ru) | [Макеты](https://www.figma.com/community/file/982611119114314434)
15
+ [Репозиторий](https://github.com/consta-design-system/charts) | [NPM](https://www.npmjs.com/package/@consta/charts) | [Документация и стенд](http://charts.consta.design) | [Макеты](https://www.figma.com/community/file/982611119114314434)
16
16
 
17
- [>> Посмотреть все библиотеки](http://uikit.gizeasy.ru/?path=/docs/common-about-github--page)
17
+ [>> Посмотреть все библиотеки](https://github.com/consta-design-system)
18
18
 
19
19
  <hr>
20
20
 
21
- Подробности — на [на сайте дизайн-системы Consta](http://consta.gazprom-neft.ru/)
21
+ Подробности — на [на сайте дизайн-системы Consta](http://consta.design/)
22
22
 
23
23
  Следите за новостями и релизами в [телеграм-канале дизайн-системы](https://t.me/consta_ui_releases)
24
24
 
@@ -46,18 +46,18 @@ const App = () => (
46
46
  );
47
47
  ```
48
48
 
49
- [Что такое темы и как с ними работать](http://uikit.gizeasy.ru/?path=/docs/thematization-what-are-themes--page)
49
+ [Что такое темы и как с ними работать](http://uikit.consta.design/?path=/docs/thematization-what-are-themes--page)
50
50
 
51
51
  ## Документация и стенд
52
52
 
53
53
  На стенде можно менять параметры и смотреть, как меняются компоненты. Документация — во вкладке у каждого компонента.
54
54
 
55
- [Вперёд, к стенду](http://uikit.gizeasy.ru/)
55
+ [Вперёд, к стенду](http://uikit.consta.design/)
56
56
 
57
57
  ## Контрибьюторам
58
58
 
59
- Будем рады, если вы захотите принять участие в разработке дизайн-системы =) Но сначала прочитайте [инструкцию для контрибьюторов](http://uikit.gizeasy.ru/?path=/docs/common-develop-contributors--page).
59
+ Будем рады, если вы захотите принять участие в разработке дизайн-системы =) Но сначала прочитайте [инструкцию для контрибьюторов](https://uikit.consta.design/libs/uikit/custom-contribute).
60
60
 
61
61
  ## Лицензия
62
62
 
63
- Дизайн-систему можно использовать бесплатно, она распространяется ПАО «Газпром нефть» на условиях открытой [лицензии MIT](https://consta.gazprom-neft.ru/static/licence_mit.pdf).
63
+ Дизайн-систему можно использовать бесплатно, она распространяется на условиях открытой [лицензии MIT](https://consta.gazprom-neft.ru/static/licence_mit.pdf).
@@ -0,0 +1,3 @@
1
+ import { AutoCompleteComponent } from './types';
2
+ export declare const AutoComplete: AutoCompleteComponent;
3
+ export * from './types';
@@ -0,0 +1,2 @@
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["items","groups","disabled","getItemLabel","getItemKey","isLoading","getItemGroupKey","getGroupKey","getGroupLabel","onBlur","inputRef","onFocus","dropdownRef","dropdownClassName","dropdownForm","value","form","view","size","onChange","inputContainerRef","style","renderItem","searchFunction","id","name","className"];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,{useRef}from"react";import{SelectDropdown}from"../SelectComponents/SelectDropdown/SelectDropdown";import{SelectItem}from"../SelectComponents/SelectItem/SelectItem";import{defaultPropForm,defaultPropSize,defaultPropView}from"../SelectComponents/types";import{TextField}from"../TextField/TextField";import{useForkRef}from"../../hooks/useForkRef";import{cnCanary}from"../../utils/bem";import{withDefaultGetters}from"./helpers";import{useAutoComplete}from"./useAutoComplete";var cnAutoComplete=cnCanary("AutoComplete"),AutoCompleteRender=function(a,b){var c=useRef(null),d=useRef(null),e=useRef(null),f=withDefaultGetters(a),g=f.items,h=f.groups,i=void 0===h?[]:h,j=f.disabled,k=f.getItemLabel,l=f.getItemKey,m=f.isLoading,n=f.getItemGroupKey,o=f.getGroupKey,p=f.getGroupLabel,q=f.onBlur,r=f.inputRef,s=f.onFocus,t=f.dropdownRef,u=void 0===t?c:t,v=f.dropdownClassName,w=f.dropdownForm,x=void 0===w?"default":w,y=f.value,z=f.form,A=void 0===z?defaultPropForm:z,B=f.view,C=void 0===B?defaultPropView:B,D=f.size,E=void 0===D?defaultPropSize:D,F=f.onChange,G=f.inputContainerRef,H=f.style,I=f.renderItem,J=f.searchFunction,K=f.id,L=f.name,M=f.className,N=_objectWithoutProperties(f,_excluded),O=function(a){var b=a.e,c=a.value,d=_objectSpread({},b),e=c?k(c):c;null===F||void 0===F?void 0:F({e:d,value:e,id:K,name:L})},P=useAutoComplete({items:g,groups:i,onChange:function(a){var b=a.e,c=a.value;return O({e:b,value:Array.isArray(c)?c[0]:c})},dropdownRef:u,controlRef:d,disabled:j,searchValue:null!==y&&void 0!==y?y:"",getItemLabel:k,getItemKey:l,getItemGroupKey:n,getGroupKey:o,onBlur:q,onFocus:s,searchFunction:J}),Q=P.getOptionProps,R=P.isOpen,S=P.getKeyProps,T=P.visibleItems,U=P.handleInputFocus,V=P.handleInputBlur,W=P.inputRef;return React.createElement(React.Fragment,null,React.createElement(TextField,Object.assign({},S(),{form:A,view:C,id:K,className:cnAutoComplete(null,[M]),name:L,disabled:j,ref:useForkRef([d,b]),inputRef:useForkRef([r,W]),onBlur:V,inputContainerRef:useForkRef([e,G]),onFocus:U,onChange:F,value:y,style:H},N)),React.createElement(SelectDropdown,{isOpen:R,size:E,controlRef:e,getOptionProps:Q,dropdownRef:u,form:x,className:cnAutoComplete("List",[v]),renderItem:I||function renderItemDefault(a){var b=a.item,c=a.active,d=a.hovered,e=a.onClick,f=a.onMouseEnter;return React.createElement(SelectItem,{label:k(b),active:c,hovered:d,multiple:!1,disabled:j,size:E,indent:"round"===x?"increased":"normal",onClick:e,onMouseEnter:f})},getGroupLabel:p,visibleItems:T,isLoading:m,hasItems:0!==g.length,style:"number"==typeof(null===H||void 0===H?void 0:H.zIndex)?{zIndex:H.zIndex+1}:void 0}))};export var AutoComplete=React.forwardRef(AutoCompleteRender);export*from"./types";
2
+ //# sourceMappingURL=AutoCompleteCanary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoCompleteCanary.js","names":["React","useRef","SelectDropdown","SelectItem","defaultPropForm","defaultPropSize","defaultPropView","TextField","useForkRef","cnCanary","withDefaultGetters","useAutoComplete","cnAutoComplete","AutoCompleteRender","props","ref","defaultDropdownRef","controlRef","containerRef","items","groups","disabled","getItemLabel","getItemKey","isLoading","getItemGroupKey","getGroupKey","getGroupLabel","onBlur","inputRef","onFocus","dropdownRef","dropdownClassName","dropdownForm","value","form","view","size","onChange","inputContainerRef","style","renderItem","searchFunction","id","name","className","otherProps","handleSelectChange","e","copyEvent","newValue","Array","isArray","searchValue","getOptionProps","isOpen","getKeyProps","visibleItems","handleInputFocus","handleInputBlur","inputControlRef","renderItemDefault","item","active","hovered","onClick","onMouseEnter","length","zIndex","AutoComplete","forwardRef"],"sources":["../../../../../src/components/AutoCompleteCanary/AutoCompleteCanary.tsx"],"sourcesContent":["import React, { useRef } from 'react';\n\nimport { PropRenderItem } from '##/components/Select';\nimport { SelectDropdown } from '##/components/SelectComponents/SelectDropdown/SelectDropdown';\nimport { SelectItem } from '##/components/SelectComponents/SelectItem/SelectItem';\nimport {\n defaultPropForm,\n defaultPropSize,\n defaultPropView,\n} from '##/components/SelectComponents/types';\nimport { TextField } from '##/components/TextField/TextField';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { cnCanary } from '##/utils/bem';\n\nimport { withDefaultGetters } from './helpers';\nimport {\n AutoCompleteComponent,\n AutoCompleteGroupDefault,\n AutoCompleteItemDefault,\n AutoCompleteProps,\n} from './types';\nimport { useAutoComplete } from './useAutoComplete';\n\nconst cnAutoComplete = cnCanary('AutoComplete');\n\nconst AutoCompleteRender = <\n TYPE extends string,\n ITEM = AutoCompleteItemDefault,\n GROUP = AutoCompleteGroupDefault,\n>(\n props: AutoCompleteProps<TYPE, ITEM, GROUP>,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const defaultDropdownRef = useRef<HTMLDivElement | null>(null);\n const controlRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n\n const {\n items,\n groups = [],\n disabled,\n getItemLabel,\n getItemKey,\n isLoading,\n getItemGroupKey,\n getGroupKey,\n getGroupLabel,\n onBlur,\n inputRef,\n onFocus,\n dropdownRef = defaultDropdownRef,\n dropdownClassName,\n dropdownForm = 'default',\n value,\n form = defaultPropForm,\n view = defaultPropView,\n size = defaultPropSize,\n onChange,\n inputContainerRef,\n style,\n renderItem,\n searchFunction,\n id,\n name,\n className,\n ...otherProps\n } = withDefaultGetters(props);\n\n const handleSelectChange = ({\n e,\n value,\n }: {\n value: ITEM | null;\n e: React.SyntheticEvent;\n }) => {\n const copyEvent = { ...e } as React.KeyboardEvent;\n const newValue = (value ? getItemLabel(value) : value) as string;\n onChange?.({ e: copyEvent, value: newValue, id, name });\n };\n\n const {\n getOptionProps,\n isOpen,\n getKeyProps,\n visibleItems,\n handleInputFocus,\n handleInputBlur,\n inputRef: inputControlRef,\n } = useAutoComplete({\n items,\n groups,\n onChange: ({ e, value }) =>\n handleSelectChange({ e, value: Array.isArray(value) ? value[0] : value }),\n dropdownRef,\n controlRef,\n disabled,\n searchValue: value ?? '',\n getItemLabel,\n getItemKey,\n getItemGroupKey,\n getGroupKey,\n onBlur,\n onFocus,\n searchFunction,\n });\n\n const renderItemDefault: PropRenderItem<ITEM> = (props) => {\n const { item, active, hovered, onClick, onMouseEnter } = props;\n\n return (\n <SelectItem\n label={getItemLabel(item)}\n active={active}\n hovered={hovered}\n multiple={false}\n disabled={disabled}\n size={size}\n indent={dropdownForm === 'round' ? 'increased' : 'normal'}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n />\n );\n };\n\n return (\n <>\n <TextField\n {...getKeyProps()}\n form={form}\n view={view}\n id={id}\n className={cnAutoComplete(null, [className])}\n name={name}\n disabled={disabled}\n ref={useForkRef([controlRef, ref])}\n inputRef={useForkRef([inputRef, inputControlRef])}\n onBlur={handleInputBlur}\n inputContainerRef={useForkRef([containerRef, inputContainerRef])}\n onFocus={handleInputFocus}\n onChange={onChange}\n value={value}\n style={style}\n {...otherProps}\n />\n <SelectDropdown\n isOpen={isOpen}\n size={size}\n controlRef={containerRef}\n getOptionProps={getOptionProps}\n dropdownRef={dropdownRef}\n form={dropdownForm}\n className={cnAutoComplete('List', [dropdownClassName])}\n renderItem={renderItem || renderItemDefault}\n getGroupLabel={getGroupLabel}\n visibleItems={visibleItems}\n isLoading={isLoading}\n hasItems={items.length !== 0}\n style={\n typeof style?.zIndex === 'number'\n ? { zIndex: style.zIndex + 1 }\n : undefined\n }\n />\n </>\n );\n};\n\nexport const AutoComplete = React.forwardRef(\n AutoCompleteRender,\n) as AutoCompleteComponent;\n\nexport * from './types';\n"],"mappings":"ukCAAA,MAAOA,MAAP,EAAgBC,MAAhB,KAA8B,OAA9B,CAGA,OAASC,cAAT,yDACA,OAASC,UAAT,iDACA,OACEC,eADF,CAEEC,eAFF,CAGEC,eAHF,iCAKA,OAASC,SAAT,8BACA,OAASC,UAAT,8BACA,OAASC,QAAT,uBAEA,OAASC,kBAAT,iBAOA,OAASC,eAAT,yB,GAEMC,eA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AGE,OAAO,CAAEC,CAHX,CAIE,QAAQ,GAJV,CAKE,QAAQ,CAAE3C,CALZ,CAME,IAAI,CAAEgB,CANR,CAOE,MAAM,CAAmB,OAAjB,GAAAJ,CAAY,CAAe,WAAf,CAA6B,QAPnD,CAQE,OAAO,CAAEgC,CARX,CASE,YAAY,CAAEC,CAThB,EAYH,CAsBG,CASE,aAAa,CAAEvC,CATjB,CAUE,YAAY,CAAE8B,CAVhB,CAWE,SAAS,CAAEjC,CAXb,CAYE,QAAQ,CAAmB,CAAjB,GAAAL,CAAK,CAACgD,MAZlB,CAaE,KAAK,CACsB,QAAzB,gBAAO3B,CAAP,WAAOA,CAAP,QAAOA,CAAK,CAAE4B,MAAd,EACI,CAAEA,MAAM,CAAE5B,CAAK,CAAC4B,MAAN,CAAe,CAAzB,CADJ,OAdJ,EAnBF,CAwCH,C,CAED,MAAO,IAAMC,aAAY,CAAGrE,KAAK,CAACsE,UAAN,CAC1BzD,kBAD0B,CAArB,CAIP"}
@@ -0,0 +1,44 @@
1
+ /// <reference types="react" />
2
+ import { AutoCompleteGroupDefault, AutoCompleteItemDefault, AutoCompletePropGetGroupId, AutoCompletePropGetGroupLabel, AutoCompletePropGetItemGroupId, AutoCompletePropGetItemKey, AutoCompletePropGetItemLabel, AutoCompleteProps } from './types';
3
+ export declare const defaultGetItemKey: AutoCompletePropGetItemKey<AutoCompleteItemDefault>;
4
+ export declare const defaultGetItemLabel: AutoCompletePropGetItemLabel<AutoCompleteItemDefault>;
5
+ export declare const defaultGetItemGroupKey: AutoCompletePropGetItemGroupId<AutoCompleteItemDefault>;
6
+ export declare const defaultGetGroupKey: AutoCompletePropGetGroupId<AutoCompleteGroupDefault>;
7
+ export declare const defaultGetGroupLabel: AutoCompletePropGetGroupLabel<AutoCompleteGroupDefault>;
8
+ export declare function withDefaultGetters<TYPE extends string, ITEM = AutoCompleteItemDefault, GROUP = AutoCompleteGroupDefault>(props: AutoCompleteProps<TYPE, ITEM, GROUP>): {
9
+ items: ITEM[];
10
+ groups?: GROUP[] | undefined;
11
+ renderItem?: import("../Select").PropRenderItem<ITEM> | undefined;
12
+ dropdownClassName?: string | undefined;
13
+ dropdownForm?: import("./types").AutoCompletePropDropdownForm | undefined;
14
+ isLoading?: boolean | undefined;
15
+ searchFunction?: import("./types").AutoCompletePropSearchFunction<ITEM> | undefined;
16
+ dropdownRef?: import("react").RefObject<HTMLDivElement> | undefined;
17
+ getItemLabel?: AutoCompletePropGetItemLabel<ITEM> | undefined;
18
+ getItemKey?: AutoCompletePropGetItemKey<ITEM> | undefined;
19
+ getItemGroupKey?: AutoCompletePropGetItemGroupId<ITEM> | undefined;
20
+ getGroupLabel?: AutoCompletePropGetGroupLabel<GROUP> | undefined;
21
+ getGroupKey?: AutoCompletePropGetGroupId<GROUP> | undefined;
22
+ } & Omit<import("../TextField").TextFieldProps<TYPE>, "step" | "max" | "min" | "incrementButtons"> & (ITEM extends {
23
+ label: string;
24
+ } ? {} : {
25
+ getItemLabel: AutoCompletePropGetItemLabel<ITEM>;
26
+ }) & (ITEM extends {
27
+ id: string | number;
28
+ } ? {} : {
29
+ getItemKey: AutoCompletePropGetItemKey<ITEM>;
30
+ }) & (GROUP extends {
31
+ label: string;
32
+ } ? {} : {
33
+ getGroupLabel: AutoCompletePropGetGroupLabel<GROUP>;
34
+ }) & (GROUP extends {
35
+ id: string | number;
36
+ } ? {} : {
37
+ getGroupKey: AutoCompletePropGetGroupId<GROUP>;
38
+ }) & {
39
+ getItemLabel: AutoCompletePropGetItemLabel<AutoCompleteItemDefault> | AutoCompletePropGetItemLabel<ITEM>;
40
+ getItemKey: AutoCompletePropGetItemKey<AutoCompleteItemDefault> | AutoCompletePropGetItemKey<ITEM>;
41
+ getItemGroupKey: AutoCompletePropGetItemGroupId<AutoCompleteItemDefault> | AutoCompletePropGetItemGroupId<ITEM>;
42
+ getGroupLabel: AutoCompletePropGetGroupLabel<AutoCompleteGroupDefault> | AutoCompletePropGetGroupLabel<GROUP>;
43
+ getGroupKey: AutoCompletePropGetGroupId<AutoCompleteGroupDefault> | AutoCompletePropGetGroupId<GROUP>;
44
+ };
@@ -0,0 +1,2 @@
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}export var defaultGetItemKey=function(a){return a.id};export var defaultGetItemLabel=function(a){return a.label};export var defaultGetItemGroupKey=function(a){return a.groupId};export var defaultGetGroupKey=function(a){return a.id};export var defaultGetGroupLabel=function(a){return a.label};export function withDefaultGetters(a){return _objectSpread(_objectSpread({},a),{},{getItemLabel:a.getItemLabel||defaultGetItemLabel,getItemKey:a.getItemKey||defaultGetItemKey,getItemGroupKey:a.getItemGroupKey||defaultGetItemGroupKey,getGroupLabel:a.getGroupLabel||defaultGetGroupLabel,getGroupKey:a.getGroupKey||defaultGetGroupKey})}
2
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","names":["defaultGetItemKey","item","id","defaultGetItemLabel","label","defaultGetItemGroupKey","groupId","defaultGetGroupKey","group","defaultGetGroupLabel","withDefaultGetters","props","getItemLabel","getItemKey","getItemGroupKey","getGroupLabel","getGroupKey"],"sources":["../../../../../src/components/AutoCompleteCanary/helpers.ts"],"sourcesContent":["import {\n AutoCompleteGroupDefault,\n AutoCompleteItemDefault,\n AutoCompletePropGetGroupId,\n AutoCompletePropGetGroupLabel,\n AutoCompletePropGetItemGroupId,\n AutoCompletePropGetItemKey,\n AutoCompletePropGetItemLabel,\n AutoCompleteProps,\n} from './types';\n\nexport const defaultGetItemKey: AutoCompletePropGetItemKey<\n AutoCompleteItemDefault\n> = (item) => item.id;\nexport const defaultGetItemLabel: AutoCompletePropGetItemLabel<\n AutoCompleteItemDefault\n> = (item) => item.label;\nexport const defaultGetItemGroupKey: AutoCompletePropGetItemGroupId<\n AutoCompleteItemDefault\n> = (item) => item.groupId;\n\nexport const defaultGetGroupKey: AutoCompletePropGetGroupId<\n AutoCompleteGroupDefault\n> = (group) => group.id;\nexport const defaultGetGroupLabel: AutoCompletePropGetGroupLabel<\n AutoCompleteGroupDefault\n> = (group) => group.label;\n\nexport function withDefaultGetters<\n TYPE extends string,\n ITEM = AutoCompleteItemDefault,\n GROUP = AutoCompleteGroupDefault,\n>(props: AutoCompleteProps<TYPE, ITEM, GROUP>) {\n return {\n ...props,\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemKey: props.getItemKey || defaultGetItemKey,\n getItemGroupKey: props.getItemGroupKey || defaultGetItemGroupKey,\n getGroupLabel: props.getGroupLabel || defaultGetGroupLabel,\n getGroupKey: props.getGroupKey || defaultGetGroupKey,\n };\n}\n"],"mappings":"qqBAWA,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,OAAf,CAFG,CAIP,MAAO,IAAMC,mBAEZ,CAAG,SAACC,CAAD,QAAWA,EAAK,CAACN,EAAjB,CAFG,CAGP,MAAO,IAAMO,qBAEZ,CAAG,SAACD,CAAD,QAAWA,EAAK,CAACJ,KAAjB,CAFG,CAIP,MAAO,SAASM,mBAAT,CAILC,CAJK,CAIwC,CAC7C,sCACKA,CADL,MAEEC,YAAY,CAAED,CAAK,CAACC,YAAN,EAAsBT,mBAFtC,CAGEU,UAAU,CAAEF,CAAK,CAACE,UAAN,EAAoBb,iBAHlC,CAIEc,eAAe,CAAEH,CAAK,CAACG,eAAN,EAAyBT,sBAJ5C,CAKEU,aAAa,CAAEJ,CAAK,CAACI,aAAN,EAAuBN,oBALxC,CAMEO,WAAW,CAAEL,CAAK,CAACK,WAAN,EAAqBT,kBANpC,EAQD"}
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import { PropRenderItem } from "../Select";
3
+ import { TextFieldProps } from "../TextField";
4
+ export declare type AutoCompleteItemDefault = {
5
+ id: string | number;
6
+ label: string;
7
+ groupId?: number;
8
+ };
9
+ export declare type AutoCompleteGroupDefault = {
10
+ label: string;
11
+ id: number | string;
12
+ };
13
+ export declare type AutoCompletePropDropdownForm = 'default' | 'brick' | 'round';
14
+ export declare type AutoCompletePropGetItemLabel<ITEM> = (item: ITEM) => string;
15
+ export declare type AutoCompletePropGetItemKey<ITEM> = (item: ITEM) => string | number;
16
+ export declare type AutoCompletePropGetItemGroupId<ITEM> = (item: ITEM) => number | undefined;
17
+ export declare type AutoCompletePropGetGroupLabel<GROUP> = (group: GROUP) => string;
18
+ export declare type AutoCompletePropGetGroupId<GROUP> = (group: GROUP) => number | string;
19
+ export declare type AutoCompletePropSearchFunction<ITEM> = (item: ITEM, searchValue: string) => boolean;
20
+ export declare type AutoCompleteProps<TYPE extends string, ITEM = AutoCompleteItemDefault, GROUP = AutoCompleteGroupDefault> = {
21
+ items: ITEM[];
22
+ groups?: GROUP[];
23
+ renderItem?: PropRenderItem<ITEM>;
24
+ dropdownClassName?: string;
25
+ dropdownForm?: AutoCompletePropDropdownForm;
26
+ isLoading?: boolean;
27
+ searchFunction?: AutoCompletePropSearchFunction<ITEM>;
28
+ dropdownRef?: React.RefObject<HTMLDivElement>;
29
+ getItemLabel?: AutoCompletePropGetItemLabel<ITEM>;
30
+ getItemKey?: AutoCompletePropGetItemKey<ITEM>;
31
+ getItemGroupKey?: AutoCompletePropGetItemGroupId<ITEM>;
32
+ getGroupLabel?: AutoCompletePropGetGroupLabel<GROUP>;
33
+ getGroupKey?: AutoCompletePropGetGroupId<GROUP>;
34
+ } & Omit<TextFieldProps<TYPE>, 'max' | 'min' | 'step' | 'incrementButtons'> & (ITEM extends {
35
+ label: AutoCompleteItemDefault['label'];
36
+ } ? {} : {
37
+ getItemLabel: AutoCompletePropGetItemLabel<ITEM>;
38
+ }) & (ITEM extends {
39
+ id: AutoCompleteItemDefault['id'];
40
+ } ? {} : {
41
+ getItemKey: AutoCompletePropGetItemKey<ITEM>;
42
+ }) & (GROUP extends {
43
+ label: AutoCompleteGroupDefault['label'];
44
+ } ? {} : {
45
+ getGroupLabel: AutoCompletePropGetGroupLabel<GROUP>;
46
+ }) & (GROUP extends {
47
+ id: AutoCompleteGroupDefault['id'];
48
+ } ? {} : {
49
+ getGroupKey: AutoCompletePropGetGroupId<GROUP>;
50
+ });
51
+ export declare type AutoCompleteComponent = <TYPE extends string, ITEM = AutoCompleteItemDefault, GROUP = AutoCompleteGroupDefault>(props: AutoCompleteProps<TYPE, ITEM, GROUP>) => React.ReactElement | null;
@@ -0,0 +1,2 @@
1
+ export{};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/components/AutoCompleteCanary/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 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} & Omit<TextFieldProps<TYPE>, 'max' | 'min' | 'step' | 'incrementButtons'> &\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":""}
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ declare type GetItemGroupKey<ITEM> = (item: ITEM) => string | number | undefined;
3
+ declare type GetGroupKey<GROUP> = (item: GROUP) => string | number | undefined;
4
+ declare type OnChangeProp<ITEM> = (props: {
5
+ value: ITEM | null;
6
+ e: React.SyntheticEvent;
7
+ }) => void;
8
+ declare type UseAutoCompleteProps<ITEM, GROUP> = {
9
+ getItemGroupKey?: GetItemGroupKey<ITEM> | undefined;
10
+ getGroupKey?: GetGroupKey<GROUP>;
11
+ groups?: GROUP[];
12
+ items: ITEM[];
13
+ dropdownRef: React.MutableRefObject<HTMLDivElement | null>;
14
+ controlRef: React.MutableRefObject<HTMLDivElement | null>;
15
+ disabled?: boolean;
16
+ getItemLabel: (item: ITEM) => string;
17
+ getItemKey: (item: ITEM) => string | number;
18
+ searchFunction?: (item: ITEM, searchValue: string) => boolean;
19
+ onFocus?: React.FocusEventHandler<HTMLInputElement>;
20
+ onBlur?: React.FocusEventHandler<HTMLInputElement>;
21
+ searchValue?: string;
22
+ onChange: OnChangeProp<ITEM>;
23
+ };
24
+ declare type OptionProps<ITEM> = {
25
+ index: number;
26
+ item: ITEM;
27
+ };
28
+ declare type GetOptionPropsResult = {
29
+ onClick: (e: React.SyntheticEvent) => void;
30
+ onMouseEnter: (e: React.SyntheticEvent) => void;
31
+ active: boolean;
32
+ hovered: boolean;
33
+ key: string | number;
34
+ };
35
+ export declare function useAutoComplete<ITEM, GROUP>(params: UseAutoCompleteProps<ITEM, GROUP>): {
36
+ isOpen: boolean;
37
+ visibleItems: {
38
+ items: ITEM[];
39
+ key: string | number;
40
+ group?: GROUP | undefined;
41
+ groupIndex: number;
42
+ }[];
43
+ getOptionProps: ({ index, item, }: OptionProps<ITEM>) => GetOptionPropsResult;
44
+ handleInputFocus: (e: React.FocusEvent<HTMLInputElement>) => void;
45
+ handleInputBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
46
+ inputRef: React.RefObject<HTMLInputElement>;
47
+ getKeyProps: (rest?: import("../../hooks/useKeys").KeyProps | undefined) => import("../../hooks/useKeys").KeyProps;
48
+ hasItems: boolean;
49
+ };
50
+ export {};
@@ -0,0 +1,2 @@
1
+ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){function b(){return a.apply(this,arguments)}return b.toString=function(){return a.toString()},b}(function(a){throw a}),f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function(a){function b(){return a.apply(this,arguments)}return b.toString=function(){return a.toString()},b}(function(a){h=!0,f=a}),f:function f(){try{g||null==c["return"]||c["return"]()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{useClickOutside}from"../../hooks/useClickOutside";import{useFlag}from"../../hooks/useFlag";import{useKeys}from"../../hooks/useKeys";import{getGroups}from"../../utils/getGroups";export function useAutoComplete(a){var b=a.items,c=a.dropdownRef,d=a.controlRef,e=a.disabled,f=void 0!==e&&e,g=a.getItemLabel,h=a.getItemKey,i=a.searchFunction,j=a.getItemGroupKey,k=a.groups,l=a.getGroupKey,m=a.onFocus,n=a.onBlur,o=a.searchValue,p=useRef(null),q=useFlag(),r=_slicedToArray(q,2),s=r[0],t=r[1],u=useState(0),v=_slicedToArray(u,2),w=v[0],x=v[1],y=function(a,b){return-1!==g(a).toLocaleLowerCase().indexOf(b.toLocaleLowerCase())},z=useMemo(function(){if(o&&""!==o.trim()){var a=b.filter(function(a){return i?i(a,o):y(a,o)});return a}return b},[b,o]),A=useMemo(function(){var a=getGroups(z,null!==k&&void 0!==k&&k.length?j:void 0,k,l,void 0);return a},[z,k,j,l]),B=useMemo(function(){return!!A.find(function(a){return 0<a.items.length})},[A]),C=useCallback(function(a){x(Math.min(Math.max(0,"function"==typeof a?a(w):a),z.length-1))},[z,w]),D=function(b,c){f||a.onChange({value:c,e:b})},E=function(a,b){b.preventDefault(),C(function(a){return a-1})},F=function(a,b){b.preventDefault(),C(function(a){return a+1})},G=useKeys({ArrowUp:E,ArrowDown:F,PageUp:E,PageDown:F,Home:E,End:F,Enter:function Enter(a,b){if(s){(o||z[w])&&b.preventDefault();var c=function(a){var b,c=0,d=_createForOfIteratorHelper(A);try{for(d.s();!(b=d.n()).done;){var e=b.value;if(e.items.length+c>a)return e.items[a-c];c+=e.items.length}}catch(a){d.e(a)}finally{d.f()}},d=c(w);d&&D(b,d)}},Escape:function Escape(){t.off()},Tab:function Tab(){t.off()}});useClickOutside({isActive:s,ignoreClicksInsideRefs:[c,d],handler:function handler(){t.off()}}),useEffect(function(){if(f){var a;t.off(),null===(a=p.current)||void 0===a?void 0:a.blur()}},[f]);return{isOpen:s&&B,visibleItems:A,getOptionProps:function getOptionProps(a){var b=a.index,c=a.item,d=h(c);return{onClick:function onClick(a){D(a,c)},onMouseEnter:function onMouseEnter(){C(b)},active:!1,hovered:b===w,key:d}},handleInputFocus:function handleInputFocus(a){f||(!s&&t.on(),"function"==typeof m&&m(a))},handleInputBlur:function handleInputBlur(a){if(s){var b;return void(null===(b=p.current)||void 0===b?void 0:b.focus())}"function"==typeof n&&n(a)},inputRef:p,getKeyProps:G,hasItems:B}}
2
+ //# sourceMappingURL=useAutoComplete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAutoComplete.js","names":["useCallback","useEffect","useMemo","useRef","useState","useClickOutside","useFlag","useKeys","getGroups","useAutoComplete","params","items","dropdownRef","controlRef","disabled","getItemLabel","getItemKey","searchFunction","getItemGroupKey","groups","getGroupKey","onFocus","onBlur","searchValue","inputRef","isOpen","setIsOpen","highlightedIndex","setHighlightedIndex","searchFunctionDefault","item","toLocaleLowerCase","indexOf","filteredOptions","trim","fiteredOptions","filter","visibleItems","resultGroups","length","hasItems","find","group","highlightIndex","indexForHighlight","Math","min","max","onChange","e","value","ArrowUp","_","preventDefault","old","ArrowDown","getKeyProps","PageUp","PageDown","Home","End","Enter","getItem","index","couter","Escape","off","Tab","isActive","ignoreClicksInsideRefs","handler","current","blur","getOptionProps","key","onClick","onMouseEnter","active","hovered","handleInputFocus","on","handleInputBlur","focus"],"sources":["../../../../../src/components/AutoCompleteCanary/useAutoComplete.ts"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useClickOutside } from '##/hooks/useClickOutside';\nimport { useFlag } from '##/hooks/useFlag';\nimport { KeyHandler, useKeys } from '##/hooks/useKeys';\nimport { getGroups } from '##/utils/getGroups';\n\ntype IndexForHighlight = number | ((oldIndex: number) => number);\n\ntype GetItemGroupKey<ITEM> = (item: ITEM) => string | number | undefined;\ntype GetGroupKey<GROUP> = (item: GROUP) => string | number | undefined;\n\ntype OnChangeProp<ITEM> = (props: {\n value: ITEM | null;\n e: React.SyntheticEvent;\n}) => void;\n\ntype UseAutoCompleteProps<ITEM, GROUP> = {\n getItemGroupKey?: GetItemGroupKey<ITEM> | undefined;\n getGroupKey?: GetGroupKey<GROUP>;\n groups?: GROUP[];\n items: ITEM[];\n dropdownRef: React.MutableRefObject<HTMLDivElement | null>;\n controlRef: React.MutableRefObject<HTMLDivElement | null>;\n disabled?: boolean;\n getItemLabel: (item: ITEM) => string;\n getItemKey: (item: ITEM) => string | number;\n searchFunction?: (item: ITEM, searchValue: string) => boolean;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n searchValue?: string;\n onChange: OnChangeProp<ITEM>;\n};\n\ntype OptionProps<ITEM> = {\n index: number;\n item: ITEM;\n};\n\ntype 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\nexport function useAutoComplete<ITEM, GROUP>(\n params: UseAutoCompleteProps<ITEM, GROUP>,\n) {\n const {\n items,\n dropdownRef,\n controlRef,\n disabled = false,\n getItemLabel,\n getItemKey,\n searchFunction,\n getItemGroupKey,\n groups,\n getGroupKey,\n onFocus,\n onBlur,\n searchValue,\n } = params;\n\n const inputRef = useRef<HTMLInputElement>(null);\n const [isOpen, setIsOpen] = useFlag();\n const [highlightedIndex, setHighlightedIndex] = useState<number>(0);\n\n const searchFunctionDefault = (item: ITEM, searchValue: string) =>\n getItemLabel(item)\n .toLocaleLowerCase()\n .indexOf(searchValue.toLocaleLowerCase()) !== -1;\n\n const filteredOptions = useMemo(() => {\n if (searchValue && searchValue.trim() !== '') {\n const fiteredOptions = items.filter((item) =>\n searchFunction\n ? searchFunction(item, searchValue)\n : searchFunctionDefault(item, searchValue),\n );\n\n return fiteredOptions;\n }\n return items;\n }, [items, searchValue]);\n\n const visibleItems = useMemo(() => {\n const resultGroups = getGroups(\n filteredOptions,\n groups?.length ? getItemGroupKey : undefined,\n groups,\n getGroupKey,\n undefined,\n );\n\n return resultGroups;\n }, [filteredOptions, groups, getItemGroupKey, getGroupKey]);\n\n const hasItems = useMemo(() => {\n return !!visibleItems.find((group) => group.items.length > 0);\n }, [visibleItems]);\n\n const highlightIndex = useCallback(\n (indexForHighlight: IndexForHighlight) => {\n setHighlightedIndex(\n Math.min(\n Math.max(\n 0,\n typeof indexForHighlight === 'function'\n ? indexForHighlight(highlightedIndex)\n : indexForHighlight,\n ),\n filteredOptions.length - 1,\n ),\n );\n },\n [filteredOptions, highlightedIndex],\n );\n\n const onChange = (e: React.SyntheticEvent, item: ITEM) => {\n if (!disabled) {\n params.onChange({ value: item, e });\n }\n };\n\n // Prop Getters\n\n const ArrowUp: KeyHandler = (_, e): void => {\n e.preventDefault();\n highlightIndex((old) => old - 1);\n };\n\n const ArrowDown: KeyHandler = (_, e): void => {\n e.preventDefault();\n highlightIndex((old) => old + 1);\n };\n\n const Enter: KeyHandler = (_, e): void => {\n if (isOpen) {\n if (searchValue || filteredOptions[highlightedIndex]) {\n e.preventDefault();\n }\n\n const getItem = (index: number) => {\n let couter = 0;\n for (const group of visibleItems) {\n if (group.items.length + couter > index) {\n return group.items[index - couter];\n }\n couter += group.items.length;\n }\n return undefined;\n };\n\n const item = getItem(highlightedIndex);\n\n if (item) {\n onChange(e, item);\n }\n }\n };\n\n const Escape = (): void => {\n setIsOpen.off();\n };\n\n const Tab = (): void => {\n setIsOpen.off();\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 });\n\n const getOptionProps = ({\n index,\n item,\n }: OptionProps<ITEM>): GetOptionPropsResult => {\n const key = getItemKey(item);\n return {\n onClick: (e: React.SyntheticEvent) => {\n onChange(e, item);\n },\n onMouseEnter: () => {\n highlightIndex(index);\n },\n active: false,\n hovered: index === highlightedIndex,\n key,\n };\n };\n\n useClickOutside({\n isActive: isOpen,\n ignoreClicksInsideRefs: [dropdownRef, controlRef],\n handler: () => {\n setIsOpen.off();\n },\n });\n\n useEffect(() => {\n if (disabled) {\n setIsOpen.off();\n inputRef.current?.blur();\n }\n }, [disabled]);\n\n const handleInputFocus = (e: React.FocusEvent<HTMLInputElement>): void => {\n if (!disabled) {\n if (!isOpen) {\n setIsOpen.on();\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 (typeof onBlur === 'function') {\n onBlur(e);\n }\n };\n\n return {\n isOpen: isOpen && hasItems,\n visibleItems,\n getOptionProps,\n handleInputFocus,\n handleInputBlur,\n inputRef,\n getKeyProps,\n hasItems,\n };\n}\n"],"mappings":"86CAAA,OACEA,WADF,CAEEC,SAFF,CAGEC,OAHF,CAIEC,MAJF,CAKEC,QALF,KAMO,OANP,CAQA,OAASC,eAAT,mCACA,OAASC,OAAT,2BACA,OAAqBC,OAArB,2BACA,OAASC,SAAT,6BA0CA,MAAO,SAASC,gBAAT,CACLC,CADK,CAEL,IAEEC,EAFF,CAeID,CAfJ,CAEEC,KAFF,CAGEC,CAHF,CAeIF,CAfJ,CAGEE,WAHF,CAIEC,CAJF,CAeIH,CAfJ,CAIEG,UAJF,GAeIH,CAfJ,CAKEI,QALF,CAKEA,CALF,eAMEC,CANF,CAeIL,CAfJ,CAMEK,YANF,CAOEC,CAPF,CAeIN,CAfJ,CAOEM,UAPF,CAQEC,CARF,CAeIP,CAfJ,CAQEO,cARF,CASEC,CATF,CAeIR,CAfJ,CASEQ,eATF,CAUEC,CAVF,CAeIT,CAfJ,CAUES,MAVF,CAWEC,CAXF,CAeIV,CAfJ,CAWEU,WAXF,CAYEC,CAZF,CAeIX,CAfJ,CAYEW,OAZF,CAaEC,CAbF,CAeIZ,CAfJ,CAaEY,MAbF,CAcEC,CAdF,CAeIb,CAfJ,CAcEa,WAdF,CAiBMC,CAAQ,CAAGrB,MAAM,CAAmB,IAAnB,CAjBvB,GAkB4BG,OAAO,EAlBnC,uBAkBOmB,CAlBP,MAkBeC,CAlBf,QAmBgDtB,QAAQ,CAAS,CAAT,CAnBxD,uBAmBOuB,CAnBP,MAmByBC,CAnBzB,MAqBMC,CAAqB,CAAG,SAACC,CAAD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AM,GAPD,CAQLC,OAAO,CAAEf,CAAK,GAAKpC,CARd,CASL+C,GAAG,CAAHA,CATK,CAWR,CAuCM,CAILK,gBAAgB,CA1BO,QAAnBA,iBAAmB,CAAC9B,CAAD,CAAiD,CACnEnC,CADmE,GAElE,CAACW,CAFiE,EAGpEC,CAAS,CAACsD,EAAV,EAHoE,CAK/C,UAAnB,QAAO3D,EAL2D,EAMpEA,CAAO,CAAC4B,CAAD,CAN6D,CASzE,CAaM,CAKLgC,eAAe,CAhBO,QAAlBA,gBAAkB,CAAChC,CAAD,CAAiD,CACvE,GAAIxB,CAAJ,CAAY,OAEV,sBADAD,CAAQ,CAAC+C,OACT,qBADA,EAAkBW,KAAlB,EACA,CACD,CAEqB,UAAlB,QAAO5D,EAN4D,EAOrEA,CAAM,CAAC2B,CAAD,CAET,CAEM,CAMLzB,QAAQ,CAARA,CANK,CAOLgC,WAAW,CAAXA,CAPK,CAQLhB,QAAQ,CAARA,CARK,CAUR"}
@@ -1,2 +1,2 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["items","anchorRef","position","direction","possibleDirections","offset","onClickOutside","getItemKey","getItemLabel","getItemSubMenu","style","spareDirection","subMenuDirection"];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,{useEffect,useState}from"react";import{useClickOutside}from"../../../hooks/useClickOutside/useClickOutside";import{useForkRef}from"../../../hooks/useForkRef/useForkRef";import{useRefs}from"../../../hooks/useRefs/useRefs";import{directions}from"../../Popover/Popover";import{clearTimers,ContextMenuLevel}from"../ContextMenuLevel/ContextMenuLevel";import{getLevels,withDefaultGetters}from"../helpers";import{contextMenuPropDefaultSubMenuDirection,contextMenuPropSubMenuDirections}from"../types";var ContextMenuLevelsRender=function(a,b){var c=withDefaultGetters(a),d=c.items,e=c.anchorRef,f=c.position,g=c.direction,h=c.possibleDirections,i=void 0===h?directions:h,j=c.offset,k=c.onClickOutside,l=c.getItemKey,m=c.getItemLabel,n=c.getItemSubMenu,o=c.style,p=c.spareDirection,q=c.subMenuDirection,r=void 0===q?contextMenuPropDefaultSubMenuDirection:q,s=_objectWithoutProperties(c,_excluded),t=useState([{items:d,anchorRef:e,position:f,direction:g,possibleDirections:i,offset:j}]),u=_slicedToArray(t,2),v=u[0],w=u[1],x=useState(r),y=_slicedToArray(x,2),z=y[0],A=y[1],B=useState(-1),C=_slicedToArray(B,2),D=C[0],E=C[1],F=useRefs(v.length),G=function(a){var b=a.level,c=a.items,d=a.anchorRef,e=a.activeItem,f=_toConsumableArray(v),g=f[b]&&1<f.length-b?f[b].direction:void 0;f[b]&&1<f.length-b&&g&&A(g),f[b-1].activeItem=e,f.splice(b),f.push({items:c,anchorRef:d,direction:g||z,possibleDirections:contextMenuPropSubMenuDirections,position:void 0}),w(f)},H=function(a){var b=_toConsumableArray(v);b.splice(a),b[a-1]=_objectSpread(_objectSpread({},b[a-1]),{},{activeItem:void 0}),w(b)};useClickOutside({isActive:!!k,ignoreClicksInsideRefs:[].concat(_toConsumableArray(F),[e||{current:null}]),handler:function handler(a){return null===k||void 0===k?void 0:k(a)}}),useEffect(function(){return clearTimers(),w(getLevels({levels:v,items:d,getItemKey:l,getItemSubMenu:n})),function(){return clearTimers()}},[d]);var I=useForkRef([F[0],b]);return React.createElement(React.Fragment,null,v.map(function(a,b){return React.createElement(ContextMenuLevel,Object.assign({},s,a,{key:"ContextMenu-".concat(b),style:_objectSpread(_objectSpread({},o),{zIndex:"number"==typeof(null===o||void 0===o?void 0:o.zIndex)?o.zIndex+1:void 0}),levelDepth:b,getItemLabel:m,addLevel:G,deleteLevel:H,onSetDirection:0<b?A:c.onSetDirection,hoveredParenLevel:D,setHoveredParenLevel:E,getItemSubMenu:n,getItemKey:l,ref:0===b?I:F[b],spareDirection:0===b?p:"rightStartUp"}))}))};export var ContextMenuLevels=React.forwardRef(ContextMenuLevelsRender);
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["items","anchorRef","position","direction","possibleDirections","offset","onClickOutside","getItemKey","getItemLabel","getItemSubMenu","style","spareDirection","subMenuDirection"];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,{useEffect,useState}from"react";import{useClickOutside}from"../../../hooks/useClickOutside/useClickOutside";import{useForkRef}from"../../../hooks/useForkRef/useForkRef";import{useRefs}from"../../../hooks/useRefs/useRefs";import{directions}from"../../Popover/Popover";import{clearTimers,ContextMenuLevel}from"../ContextMenuLevel/ContextMenuLevel";import{getLevels,withDefaultGetters}from"../helpers";import{contextMenuPropDefaultSubMenuDirection,contextMenuPropSubMenuDirections}from"../types";var ContextMenuLevelsRender=function(a,b){var c=withDefaultGetters(a),d=c.items,e=c.anchorRef,f=c.position,g=c.direction,h=c.possibleDirections,i=void 0===h?directions:h,j=c.offset,k=c.onClickOutside,l=c.getItemKey,m=c.getItemLabel,n=c.getItemSubMenu,o=c.style,p=c.spareDirection,q=c.subMenuDirection,r=void 0===q?contextMenuPropDefaultSubMenuDirection:q,s=_objectWithoutProperties(c,_excluded),t=[{items:d,anchorRef:e,position:f,direction:g,possibleDirections:i,offset:j}],u=useState(t),v=_slicedToArray(u,2),w=v[0],x=v[1],y=useState(r),z=_slicedToArray(y,2),A=z[0],B=z[1],C=useState(-1),D=_slicedToArray(C,2),E=D[0],F=D[1],G=useRefs(w.length),H=function(a){var b=a.level,c=a.items,d=a.anchorRef,e=a.activeItem,f=_toConsumableArray(w),g=f[b]&&1<f.length-b?f[b].direction:void 0;f[b]&&1<f.length-b&&g&&B(g),f[b-1].activeItem=e,f.splice(b),f.push({items:c,anchorRef:d,direction:g||A,possibleDirections:contextMenuPropSubMenuDirections,position:void 0}),x(f)},I=function(a){var b=_toConsumableArray(w);b.splice(a),b[a-1]=_objectSpread(_objectSpread({},b[a-1]),{},{activeItem:void 0}),x(b)};useClickOutside({isActive:!!k,ignoreClicksInsideRefs:[].concat(_toConsumableArray(G),[e||{current:null}]),handler:function handler(a){return null===k||void 0===k?void 0:k(a)}}),useEffect(function(){return clearTimers(),x(getLevels({levels:w,items:d,getItemKey:l,getItemSubMenu:n})),function(){return clearTimers()}},[d]);var J=useForkRef([G[0],b]);return useEffect(function(){x(t)},[f]),React.createElement(React.Fragment,null,w.map(function(a,b){return React.createElement(ContextMenuLevel,Object.assign({},s,a,{key:"ContextMenu-".concat(b),style:_objectSpread(_objectSpread({},o),{zIndex:"number"==typeof(null===o||void 0===o?void 0:o.zIndex)?o.zIndex+1:void 0}),levelDepth:b,getItemLabel:m,addLevel:H,deleteLevel:I,onSetDirection:0<b?B:c.onSetDirection,hoveredParenLevel:E,setHoveredParenLevel:F,getItemSubMenu:n,getItemKey:l,ref:0===b?J:G[b],spareDirection:0===b?p:"rightStartUp"}))}))};export var ContextMenuLevels=React.forwardRef(ContextMenuLevelsRender);
2
2
  //# sourceMappingURL=ContextMenuLevels.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenuLevels.js","names":["React","useEffect","useState","useClickOutside","useForkRef","useRefs","directions","clearTimers","ContextMenuLevel","getLevels","withDefaultGetters","contextMenuPropDefaultSubMenuDirection","contextMenuPropSubMenuDirections","ContextMenuLevelsRender","propsComponent","ref","props","items","anchorRef","position","direction","possibleDirections","offset","onClickOutside","getItemKey","getItemLabel","getItemSubMenu","style","spareDirection","subMenuDirection","subMenuDirectionProp","otherProps","levels","setLevels","setSubMenuDirection","hoveredParenLevel","setHoveredParenLevel","levelsRefs","length","addLevel","level","activeItem","newLevels","oldDirection","splice","push","deleteLevel","isActive","ignoreClicksInsideRefs","current","handler","e","firstLevelRef","map","index","zIndex","onSetDirection","ContextMenuLevels","forwardRef"],"sources":["../../../../../../src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\n\nimport { useClickOutside } from '../../../hooks/useClickOutside/useClickOutside';\nimport { useForkRef } from '../../../hooks/useForkRef/useForkRef';\nimport { useRefs } from '../../../hooks/useRefs/useRefs';\nimport { Direction, directions } from '../../Popover/Popover';\nimport {\n clearTimers,\n ContextMenuLevel,\n} from '../ContextMenuLevel/ContextMenuLevel';\nimport { getLevels, withDefaultGetters } from '../helpers';\nimport {\n AddLevel,\n ContextMenuComponent,\n contextMenuPropDefaultSubMenuDirection,\n ContextMenuProps,\n contextMenuPropSubMenuDirections,\n Level,\n} from '../types';\n\nconst ContextMenuLevelsRender = (\n propsComponent: ContextMenuProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const props = withDefaultGetters(propsComponent);\n const {\n items,\n anchorRef,\n position,\n direction,\n possibleDirections = directions,\n offset,\n onClickOutside,\n getItemKey,\n getItemLabel,\n getItemSubMenu,\n style,\n spareDirection,\n subMenuDirection:\n subMenuDirectionProp = contextMenuPropDefaultSubMenuDirection,\n ...otherProps\n } = props;\n\n type Item = typeof items[number];\n\n const defaultLevels = [\n {\n items,\n anchorRef,\n position,\n direction,\n possibleDirections,\n offset,\n },\n ] as Level<Item>[];\n\n const [levels, setLevels] = useState<Level<Item>[]>(defaultLevels);\n const [subMenuDirection, setSubMenuDirection] =\n useState<Direction>(subMenuDirectionProp);\n const [hoveredParenLevel, setHoveredParenLevel] = useState<number>(-1);\n\n const levelsRefs = useRefs<HTMLDivElement>(levels.length);\n\n const addLevel: AddLevel<Item> = ({\n level,\n items,\n anchorRef,\n activeItem,\n }) => {\n const newLevels = [...levels];\n const oldDirection =\n newLevels[level] && newLevels.length - level > 1\n ? newLevels[level].direction\n : undefined;\n\n if (newLevels[level] && newLevels.length - level > 1 && oldDirection) {\n setSubMenuDirection(oldDirection);\n }\n\n newLevels[level - 1].activeItem = activeItem;\n newLevels.splice(level);\n newLevels.push({\n items,\n anchorRef,\n direction: oldDirection || subMenuDirection,\n possibleDirections: contextMenuPropSubMenuDirections,\n position: undefined,\n });\n setLevels(newLevels);\n };\n\n const deleteLevel = (level: number) => {\n const newLevels = [...levels];\n newLevels.splice(level);\n newLevels[level - 1] = { ...newLevels[level - 1], activeItem: undefined };\n setLevels(newLevels);\n };\n\n useClickOutside({\n isActive: !!onClickOutside,\n ignoreClicksInsideRefs: [...levelsRefs, anchorRef || { current: null }],\n handler: (e) => onClickOutside?.(e),\n });\n\n useEffect(() => {\n clearTimers();\n setLevels(\n getLevels({\n levels,\n items,\n getItemKey,\n getItemSubMenu,\n }),\n );\n return () => clearTimers();\n }, [items]);\n\n const firstLevelRef = useForkRef([levelsRefs[0], ref]);\n\n return (\n <>\n {levels.map((level, index) => (\n <ContextMenuLevel\n {...otherProps}\n {...level}\n key={`ContextMenu-${index}`}\n style={{\n ...style,\n ...{\n zIndex:\n typeof style?.zIndex === 'number'\n ? style.zIndex + 1\n : undefined,\n },\n }}\n levelDepth={index}\n getItemLabel={getItemLabel}\n addLevel={addLevel}\n deleteLevel={deleteLevel}\n onSetDirection={\n index > 0 ? setSubMenuDirection : props.onSetDirection\n }\n hoveredParenLevel={hoveredParenLevel}\n setHoveredParenLevel={setHoveredParenLevel}\n getItemSubMenu={getItemSubMenu}\n getItemKey={getItemKey}\n ref={index === 0 ? firstLevelRef : levelsRefs[index]}\n spareDirection={index === 0 ? spareDirection : 'rightStartUp'}\n />\n ))}\n </>\n );\n};\n\nexport const ContextMenuLevels = React.forwardRef(\n ContextMenuLevelsRender,\n) as ContextMenuComponent;\n"],"mappings":"ukCAAA,MAAOA,MAAP,EAAgBC,SAAhB,CAA2BC,QAA3B,KAA2C,OAA3C,CAEA,OAASC,eAAT,sDACA,OAASC,UAAT,4CACA,OAASC,OAAT,sCACA,OAAoBC,UAApB,6BACA,OACEC,WADF,CAEEC,gBAFF,4CAIA,OAASC,SAAT,CAAoBC,kBAApB,kBACA,OAGEC,sCAHF,CAKEC,gCALF,gBASA,GAAMC,wBAAuB,CAAG,SAC9BC,CAD8B,CAE9BC,CAF8B,CAG3B,IACGC,EAAK,CAAGN,kBAAkB,CAACI,CAAD,CAD7B,CAGDG,CAHC,CAkBCD,CAlBD,CAGDC,KAHC,CAIDC,CAJC,CAkBCF,CAlBD,CAIDE,SAJC,CAKDC,CALC,CAkBCH,CAlBD,CAKDG,QALC,CAMDC,CANC,CAkBCJ,CAlBD,CAMDI,SANC,GAkBCJ,CAlBD,CAODK,kBAPC,CAODA,CAPC,YAOoBf,UAPpB,GAQDgB,CARC,CAkBCN,CAlBD,CAQDM,MARC,CASDC,CATC,CAkBCP,CAlBD,CASDO,cATC,CAUDC,CAVC,CAkBCR,CAlBD,CAUDQ,UAVC,CAWDC,CAXC,CAkBCT,CAlBD,CAWDS,YAXC,CAYDC,CAZC,CAkBCV,CAlBD,CAYDU,cAZC,CAa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N,CAEMS,CAFN,EAGE,GAAG,uBAAiBc,CAAjB,CAHL,CAIE,KAAK,gCACA3B,CADA,EAEA,CACD4B,MAAM,CACqB,QAAzB,gBAAO5B,CAAP,WAAOA,CAAP,QAAOA,CAAK,CAAE4B,MAAd,EACI5B,CAAK,CAAC4B,MAAN,CAAe,CADnB,OAFD,CAFA,CAJP,CAaE,UAAU,CAAED,CAbd,CAcE,YAAY,CAAE7B,CAdhB,CAeE,QAAQ,CAAEc,CAfZ,CAgBE,WAAW,CAAEO,CAhBf,CAiBE,cAAc,CACJ,CAAR,CAAAQ,CAAK,CAAOpB,CAAP,CAA6BlB,CAAK,CAACwC,cAlB5C,CAoBE,iBAAiB,CAAErB,CApBrB,CAqBE,oBAAoB,CAAEC,CArBxB,CAsBE,cAAc,CAAEV,CAtBlB,CAuBE,UAAU,CAAEF,CAvBd,CAwBE,GAAG,CAAY,CAAV,GAAA8B,CAAK,CAASF,CAAT,CAAyBf,CAAU,CAACiB,CAAD,CAxB/C,CAyBE,cAAc,CAAY,CAAV,GAAAA,CAAK,CAAS1B,CAAT,CAA0B,cAzBjD,GADU,CAAX,CADH,CAgCH,CApID,CAsIA,MAAO,IAAM6B,kBAAiB,CAAGzD,KAAK,CAAC0D,UAAN,CAC/B7C,uBAD+B,CAA1B"}
1
+ {"version":3,"file":"ContextMenuLevels.js","names":["React","useEffect","useState","useClickOutside","useForkRef","useRefs","directions","clearTimers","ContextMenuLevel","getLevels","withDefaultGetters","contextMenuPropDefaultSubMenuDirection","contextMenuPropSubMenuDirections","ContextMenuLevelsRender","propsComponent","ref","props","items","anchorRef","position","direction","possibleDirections","offset","onClickOutside","getItemKey","getItemLabel","getItemSubMenu","style","spareDirection","subMenuDirection","subMenuDirectionProp","otherProps","defaultLevels","levels","setLevels","setSubMenuDirection","hoveredParenLevel","setHoveredParenLevel","levelsRefs","length","addLevel","level","activeItem","newLevels","oldDirection","splice","push","deleteLevel","isActive","ignoreClicksInsideRefs","current","handler","e","firstLevelRef","map","index","zIndex","onSetDirection","ContextMenuLevels","forwardRef"],"sources":["../../../../../../src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\n\nimport { useClickOutside } from '../../../hooks/useClickOutside/useClickOutside';\nimport { useForkRef } from '../../../hooks/useForkRef/useForkRef';\nimport { useRefs } from '../../../hooks/useRefs/useRefs';\nimport { Direction, directions } from '../../Popover/Popover';\nimport {\n clearTimers,\n ContextMenuLevel,\n} from '../ContextMenuLevel/ContextMenuLevel';\nimport { getLevels, withDefaultGetters } from '../helpers';\nimport {\n AddLevel,\n ContextMenuComponent,\n contextMenuPropDefaultSubMenuDirection,\n ContextMenuProps,\n contextMenuPropSubMenuDirections,\n Level,\n} from '../types';\n\nconst ContextMenuLevelsRender = (\n propsComponent: ContextMenuProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const props = withDefaultGetters(propsComponent);\n const {\n items,\n anchorRef,\n position,\n direction,\n possibleDirections = directions,\n offset,\n onClickOutside,\n getItemKey,\n getItemLabel,\n getItemSubMenu,\n style,\n spareDirection,\n subMenuDirection:\n subMenuDirectionProp = contextMenuPropDefaultSubMenuDirection,\n ...otherProps\n } = props;\n\n type Item = typeof items[number];\n\n const defaultLevels: Level<Item>[] = [\n {\n items,\n anchorRef,\n position,\n direction,\n possibleDirections,\n offset,\n } as Level<Item>,\n ];\n\n const [levels, setLevels] = useState<Level<Item>[]>(defaultLevels);\n const [subMenuDirection, setSubMenuDirection] =\n useState<Direction>(subMenuDirectionProp);\n const [hoveredParenLevel, setHoveredParenLevel] = useState<number>(-1);\n\n const levelsRefs = useRefs<HTMLDivElement>(levels.length);\n\n const addLevel: AddLevel<Item> = ({\n level,\n items,\n anchorRef,\n activeItem,\n }) => {\n const newLevels = [...levels];\n const oldDirection =\n newLevels[level] && newLevels.length - level > 1\n ? newLevels[level].direction\n : undefined;\n\n if (newLevels[level] && newLevels.length - level > 1 && oldDirection) {\n setSubMenuDirection(oldDirection);\n }\n\n newLevels[level - 1].activeItem = activeItem;\n newLevels.splice(level);\n newLevels.push({\n items,\n anchorRef,\n direction: oldDirection || subMenuDirection,\n possibleDirections: contextMenuPropSubMenuDirections,\n position: undefined,\n });\n setLevels(newLevels);\n };\n\n const deleteLevel = (level: number) => {\n const newLevels = [...levels];\n newLevels.splice(level);\n newLevels[level - 1] = { ...newLevels[level - 1], activeItem: undefined };\n setLevels(newLevels);\n };\n\n useClickOutside({\n isActive: !!onClickOutside,\n ignoreClicksInsideRefs: [...levelsRefs, anchorRef || { current: null }],\n handler: (e) => onClickOutside?.(e),\n });\n\n useEffect(() => {\n clearTimers();\n setLevels(\n getLevels({\n levels,\n items,\n getItemKey,\n getItemSubMenu,\n }),\n );\n return () => clearTimers();\n }, [items]);\n\n const firstLevelRef = useForkRef([levelsRefs[0], ref]);\n\n useEffect(() => {\n setLevels(defaultLevels);\n }, [position]);\n\n return (\n <>\n {levels.map((level, index) => (\n <ContextMenuLevel\n {...otherProps}\n {...level}\n key={`ContextMenu-${index}`}\n style={{\n ...style,\n ...{\n zIndex:\n typeof style?.zIndex === 'number'\n ? style.zIndex + 1\n : undefined,\n },\n }}\n levelDepth={index}\n getItemLabel={getItemLabel}\n addLevel={addLevel}\n deleteLevel={deleteLevel}\n onSetDirection={\n index > 0 ? setSubMenuDirection : props.onSetDirection\n }\n hoveredParenLevel={hoveredParenLevel}\n setHoveredParenLevel={setHoveredParenLevel}\n getItemSubMenu={getItemSubMenu}\n getItemKey={getItemKey}\n ref={index === 0 ? firstLevelRef : levelsRefs[index]}\n spareDirection={index === 0 ? spareDirection : 'rightStartUp'}\n />\n ))}\n </>\n );\n};\n\nexport const ContextMenuLevels = React.forwardRef(\n ContextMenuLevelsRender,\n) as ContextMenuComponent;\n"],"mappings":"ukCAAA,MAAOA,MAAP,EAAgBC,SAAhB,CAA2BC,QAA3B,KAA2C,OAA3C,CAEA,OAASC,eAAT,sDACA,OAASC,UAAT,4CACA,OAASC,OAAT,sCACA,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rB,CAqBE,oBAAoB,CAAEC,CArBxB,CAsBE,cAAc,CAAEX,CAtBlB,CAuBE,UAAU,CAAEF,CAvBd,CAwBE,GAAG,CAAY,CAAV,GAAA+B,CAAK,CAASF,CAAT,CAAyBf,CAAU,CAACiB,CAAD,CAxB/C,CAyBE,cAAc,CAAY,CAAV,GAAAA,CAAK,CAAS3B,CAAT,CAA0B,cAzBjD,GADU,CAAX,CADH,CAgCH,CAxID,CA0IA,MAAO,IAAM8B,kBAAiB,CAAG1D,KAAK,CAAC2D,UAAN,CAC/B9C,uBAD+B,CAA1B"}
@@ -19,7 +19,7 @@ export declare function withDefaultGetters<ITEM, GROUP>(props: ContextMenuProps<
19
19
  } & import("./types").MappersItem<ITEM> & MappersGroup<GROUP> & {
20
20
  anchorRef: import("react").RefObject<HTMLElement>;
21
21
  position?: undefined;
22
- } & Omit<import("react").HTMLAttributes<HTMLDivElement>, "css" | "size" | "direction" | "offset" | "items" | "groups" | "position" | "possibleDirections" | "spareDirection" | "onClickOutside" | "onSetDirection" | "anchorRef" | "sortGroup" | "onItemClick" | "subMenuDirection" | "isOpen" | keyof import("./types").MappersItem<ITEM_1> | keyof MappersGroup<GROUP_1>> & import("react").RefAttributes<HTMLDivElement> & (GROUP extends {
22
+ } & Omit<import("react").HTMLAttributes<HTMLDivElement>, "css" | "size" | "direction" | "offset" | "items" | "groups" | "position" | "isOpen" | "possibleDirections" | "spareDirection" | "onClickOutside" | "onSetDirection" | "anchorRef" | "sortGroup" | "onItemClick" | "subMenuDirection" | keyof import("./types").MappersItem<ITEM_1> | keyof MappersGroup<GROUP_1>> & import("react").RefAttributes<HTMLDivElement> & (GROUP extends {
23
23
  id: unknown;
24
24
  } ? {} : {
25
25
  getGroupId: ContextMenuPropGetGroupId<GROUP>;
@@ -60,7 +60,7 @@ export declare function withDefaultGetters<ITEM, GROUP>(props: ContextMenuProps<
60
60
  } & import("./types").MappersItem<ITEM> & MappersGroup<GROUP> & {
61
61
  anchorRef?: undefined;
62
62
  position: import("../Popover").Position;
63
- } & Omit<import("react").HTMLAttributes<HTMLDivElement>, "css" | "size" | "direction" | "offset" | "items" | "groups" | "position" | "possibleDirections" | "spareDirection" | "onClickOutside" | "onSetDirection" | "anchorRef" | "sortGroup" | "onItemClick" | "subMenuDirection" | "isOpen" | keyof import("./types").MappersItem<ITEM_1> | keyof MappersGroup<GROUP_1>> & import("react").RefAttributes<HTMLDivElement> & (GROUP extends {
63
+ } & Omit<import("react").HTMLAttributes<HTMLDivElement>, "css" | "size" | "direction" | "offset" | "items" | "groups" | "position" | "isOpen" | "possibleDirections" | "spareDirection" | "onClickOutside" | "onSetDirection" | "anchorRef" | "sortGroup" | "onItemClick" | "subMenuDirection" | keyof import("./types").MappersItem<ITEM_1> | keyof MappersGroup<GROUP_1>> & import("react").RefAttributes<HTMLDivElement> & (GROUP extends {
64
64
  id: unknown;
65
65
  } ? {} : {
66
66
  getGroupId: ContextMenuPropGetGroupId<GROUP>;
@@ -83,7 +83,7 @@ export declare type Level<ITEM> = {
83
83
  activeItem?: string;
84
84
  direction?: Direction;
85
85
  possibleDirections?: readonly Direction[];
86
- offset?: number;
86
+ offset?: PopoverPropOffset;
87
87
  } & PositioningProps;
88
88
  export declare type AddLevel<ITEM> = (params: {
89
89
  level: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["contextMenuSizes","contextMenuDefaultSize","contextMenuStatus","contextMenuDefaultStatus","contextMenuPropSubMenuDirections","contextMenuPropDefaultSubMenuDirection"],"sources":["../../../../../src/components/ContextMenu/types.ts"],"sourcesContent":["import { ClickOutsideHandler } from '../../hooks/useClickOutside/useClickOutside';\nimport { IconComponent } from '../../icons/Icon/Icon';\nimport { PropsWithAsAttributes } from '../../utils/types/PropsWithAsAttributes';\nimport { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';\nimport { Direction, PopoverPropOffset, Position } from '../Popover/Popover';\n\nexport const contextMenuSizes = ['m', 'xs', 's', 'l'] as const;\nexport type ContextMenuPropSize = typeof contextMenuSizes[number];\nexport const contextMenuDefaultSize: ContextMenuPropSize = contextMenuSizes[0];\n\nexport const contextMenuStatus = ['alert', 'success', 'warning'] as const;\nexport type ContextMenuStatus = typeof contextMenuStatus[number];\nexport const contextMenuDefaultStatus: ContextMenuStatus = contextMenuStatus[0];\n\nexport const contextMenuPropSubMenuDirections = [\n 'rightStartUp',\n 'rightStartDown',\n 'leftStartUp',\n 'leftStartDown',\n] as const;\nexport type ContextMenuPropSubMenuDirection =\n typeof contextMenuPropSubMenuDirections[number];\nexport const contextMenuPropDefaultSubMenuDirection: ContextMenuPropSubMenuDirection =\n contextMenuPropSubMenuDirections[0];\n\nexport type ContextMenuPropOnClick<ITEM> = (params: {\n e: React.MouseEvent<HTMLDivElement>;\n item: ITEM;\n}) => void;\n\nexport type ContextMenuGroupDefault = {\n label?: string;\n id: number;\n};\n\nexport type ContextMenuItemDefault = {\n label: string | number;\n key?: string | number;\n rightSide?: React.ReactNode;\n rightIcon?: IconComponent;\n leftSide?: React.ReactNode;\n leftIcon?: IconComponent;\n subMenu?: ContextMenuItemDefault[];\n status?: ContextMenuStatus;\n disabled?: boolean;\n groupId?: number;\n onClick?: ContextMenuPropOnClick<ContextMenuItemDefault>;\n as?: keyof JSX.IntrinsicElements;\n attributes?: JSX.IntrinsicElements[keyof JSX.IntrinsicElements];\n};\n\nexport type ContextMenuPropSortGroup = (\n a: string | number,\n b: string | number,\n) => number;\n\nexport type ContextMenuPropGetItemLabel<ITEM> = (item: ITEM) => string | number;\nexport type ContextMenuPropGetItemRightSide<ITEM> = (\n item: ITEM,\n) => React.ReactNode | undefined;\nexport type ContextMenuPropGetItemLeftSide<ITEM> = (\n item: ITEM,\n) => React.ReactNode | undefined;\nexport type ContextMenuPropGetItemSubMenu<ITEM> = (\n item: ITEM,\n) => ITEM[] | undefined;\nexport type ContextMenuPropGetItemStatus<ITEM> = (\n item: ITEM,\n) => ContextMenuStatus | undefined;\nexport type ContextMenuPropGetItemKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\nexport type ContextMenuPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => ContextMenuPropOnClick<ITEM> | undefined;\nexport type ContextMenuPropGetItemDisabled<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\nexport type ContextMenuPropGetItemAs<ITEM> = (\n item: ITEM,\n) => keyof JSX.IntrinsicElements | undefined;\nexport type ContextMenuPropGetItemAttributes<ITEM> = (\n item: ITEM,\n) => JSX.IntrinsicElements[keyof JSX.IntrinsicElements] | undefined;\nexport type ContextMenuPropGetItemGroupId<ITEM> = (\n item: ITEM,\n) => number | undefined;\nexport type ContextMenuPropGetItemRightIcon<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\nexport type ContextMenuPropGetItemLeftIcon<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\n\nexport type ContextMenuPropGetGroupLabel<GROUP> = (\n group: GROUP,\n) => string | undefined;\nexport type ContextMenuPropGetGroupId<GROUP> = (group: GROUP) => number;\n\ntype PositioningProps =\n | {\n anchorRef: React.RefObject<HTMLElement>;\n position?: never;\n }\n | {\n anchorRef?: never;\n position: Position;\n };\n\nexport type MappersItem<ITEM> = {\n getItemLabel?: ContextMenuPropGetItemLabel<ITEM>;\n getItemRightSide?: ContextMenuPropGetItemRightSide<ITEM>;\n getItemLeftSide?: ContextMenuPropGetItemLeftSide<ITEM>;\n getItemSubMenu?: ContextMenuPropGetItemSubMenu<ITEM>;\n getItemStatus?: ContextMenuPropGetItemStatus<ITEM>;\n getItemDisabled?: ContextMenuPropGetItemDisabled<ITEM>;\n getItemKey?: ContextMenuPropGetItemKey<ITEM>;\n getItemOnClick?: ContextMenuPropGetItemOnClick<ITEM>;\n getItemAs?: ContextMenuPropGetItemAs<ITEM>;\n getItemAttributes?: ContextMenuPropGetItemAttributes<ITEM>;\n getItemGroupId?: ContextMenuPropGetItemGroupId<ITEM>;\n getItemLeftIcon?: ContextMenuPropGetItemLeftIcon<ITEM>;\n getItemRightIcon?: ContextMenuPropGetItemRightIcon<ITEM>;\n};\n\nexport type MappersGroup<GROUP> = {\n getGroupLabel?: ContextMenuPropGetGroupLabel<GROUP>;\n getGroupId?: ContextMenuPropGetGroupId<GROUP>;\n};\n\nexport type Level<ITEM> = {\n items: ITEM[];\n activeItem?: string;\n direction?: Direction;\n possibleDirections?: readonly Direction[];\n offset?: number;\n} & PositioningProps;\n\nexport type AddLevel<ITEM> = (params: {\n level: number;\n items: ITEM[];\n anchorRef?: React.RefObject<HTMLElement>;\n activeItem: string;\n}) => void;\n\nexport type ContextMenuProps<\n ITEM = ContextMenuItemDefault,\n GROUP = ContextMenuGroupDefault,\n> = PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n size?: ContextMenuPropSize;\n direction?: Direction;\n offset?: PopoverPropOffset;\n groups?: GROUP[];\n sortGroup?: ContextMenuPropSortGroup;\n onItemClick?: ContextMenuPropOnClick<ITEM>;\n possibleDirections?: readonly Direction[];\n subMenuDirection?: ContextMenuPropSubMenuDirection;\n spareDirection?: Direction;\n onSetDirection?: (direction: Direction) => void;\n onClickOutside?: ClickOutsideHandler;\n isOpen?: boolean;\n } & MappersItem<ITEM> &\n MappersGroup<GROUP> &\n PositioningProps,\n HTMLDivElement\n> &\n (GROUP extends { id: ContextMenuGroupDefault['id'] | unknown }\n ? {}\n : { getGroupId: ContextMenuPropGetGroupId<GROUP> }) &\n (ITEM extends { label: ContextMenuItemDefault['label'] }\n ? {}\n : { getItemLabel: ContextMenuPropGetItemLabel<ITEM> });\n\nexport type ContextMenuComponent = <\n ITEM = ContextMenuItemDefault,\n GROUP = ContextMenuGroupDefault,\n>(\n props: ContextMenuProps<ITEM, GROUP>,\n) => React.ReactElement | null;\n\nexport type ContextMenuLevelProps<ITEM, GROUP> = Omit<\n ContextMenuProps<ITEM, GROUP>,\n | 'subMenuDirection'\n | 'onClickOutside'\n | keyof MappersItem<ITEM>\n | keyof MappersGroup<GROUP>\n> & {\n levelDepth: number;\n addLevel: AddLevel<ITEM>;\n deleteLevel: (level: number) => void;\n activeItem?: string;\n onSetDirection?: (direction: Direction) => void;\n hoveredParenLevel: number;\n setHoveredParenLevel: (level: number) => void;\n} & Required<MappersItem<ITEM>> &\n Required<MappersGroup<GROUP>>;\n\nexport type ContextMenuLevelComponent = <ITEM, GROUP>(\n props: ContextMenuLevelProps<ITEM, GROUP>,\n ref: React.Ref<HTMLElement>,\n) => React.ReactElement | null;\n\nexport type ContextMenuItemProps<\n AS extends keyof JSX.IntrinsicElements = 'div',\n> = PropsWithAsAttributes<\n Omit<ContextMenuItemDefault, 'onClick' | 'attributes' | 'key'> & {\n size?: ContextMenuPropSize;\n active: boolean;\n withSubMenu: boolean;\n },\n AS\n> &\n React.RefAttributes<HTMLDivElement>;\n\nexport type ContextMenuItemComponent = <\n AS extends keyof JSX.IntrinsicElements = 'div',\n>(\n props: ContextMenuItemProps<AS>,\n ref: React.Ref<HTMLElement>,\n) => React.ReactElement | null;\n\nexport type GetLevelsParams<ITEM> = {\n levels: Level<ITEM>[];\n items: ITEM[];\n getItemSubMenu: ContextMenuPropGetItemSubMenu<ITEM>;\n getItemKey: ContextMenuPropGetItemKey<ITEM>;\n};\n"],"mappings":"AAMA,MAAO,IAAMA,iBAAgB,CAAG,CAAC,GAAD,CAAM,IAAN,CAAY,GAAZ,CAAiB,GAAjB,CAAzB,CAEP,MAAO,IAAMC,uBAA2C,CAAGD,gBAAgB,CAAC,CAAD,CAApE,CAEP,MAAO,IAAME,kBAAiB,CAAG,CAAC,OAAD,CAAU,SAAV,CAAqB,SAArB,CAA1B,CAEP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAEP,MAAO,IAAME,iCAAgC,CAAG,CAC9C,cAD8C,CAE9C,gBAF8C,CAG9C,aAH8C,CAI9C,eAJ8C,CAAzC,CAQP,MAAO,IAAMC,uCAAuE,CAClFD,gCAAgC,CAAC,CAAD,CAD3B"}
1
+ {"version":3,"file":"types.js","names":["contextMenuSizes","contextMenuDefaultSize","contextMenuStatus","contextMenuDefaultStatus","contextMenuPropSubMenuDirections","contextMenuPropDefaultSubMenuDirection"],"sources":["../../../../../src/components/ContextMenu/types.ts"],"sourcesContent":["import { ClickOutsideHandler } from '../../hooks/useClickOutside/useClickOutside';\nimport { IconComponent } from '../../icons/Icon/Icon';\nimport { PropsWithAsAttributes } from '../../utils/types/PropsWithAsAttributes';\nimport { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';\nimport { Direction, PopoverPropOffset, Position } from '../Popover/Popover';\n\nexport const contextMenuSizes = ['m', 'xs', 's', 'l'] as const;\nexport type ContextMenuPropSize = typeof contextMenuSizes[number];\nexport const contextMenuDefaultSize: ContextMenuPropSize = contextMenuSizes[0];\n\nexport const contextMenuStatus = ['alert', 'success', 'warning'] as const;\nexport type ContextMenuStatus = typeof contextMenuStatus[number];\nexport const contextMenuDefaultStatus: ContextMenuStatus = contextMenuStatus[0];\n\nexport const contextMenuPropSubMenuDirections = [\n 'rightStartUp',\n 'rightStartDown',\n 'leftStartUp',\n 'leftStartDown',\n] as const;\nexport type ContextMenuPropSubMenuDirection =\n typeof contextMenuPropSubMenuDirections[number];\nexport const contextMenuPropDefaultSubMenuDirection: ContextMenuPropSubMenuDirection =\n contextMenuPropSubMenuDirections[0];\n\nexport type ContextMenuPropOnClick<ITEM> = (params: {\n e: React.MouseEvent<HTMLDivElement>;\n item: ITEM;\n}) => void;\n\nexport type ContextMenuGroupDefault = {\n label?: string;\n id: number;\n};\n\nexport type ContextMenuItemDefault = {\n label: string | number;\n key?: string | number;\n rightSide?: React.ReactNode;\n rightIcon?: IconComponent;\n leftSide?: React.ReactNode;\n leftIcon?: IconComponent;\n subMenu?: ContextMenuItemDefault[];\n status?: ContextMenuStatus;\n disabled?: boolean;\n groupId?: number;\n onClick?: ContextMenuPropOnClick<ContextMenuItemDefault>;\n as?: keyof JSX.IntrinsicElements;\n attributes?: JSX.IntrinsicElements[keyof JSX.IntrinsicElements];\n};\n\nexport type ContextMenuPropSortGroup = (\n a: string | number,\n b: string | number,\n) => number;\n\nexport type ContextMenuPropGetItemLabel<ITEM> = (item: ITEM) => string | number;\nexport type ContextMenuPropGetItemRightSide<ITEM> = (\n item: ITEM,\n) => React.ReactNode | undefined;\nexport type ContextMenuPropGetItemLeftSide<ITEM> = (\n item: ITEM,\n) => React.ReactNode | undefined;\nexport type ContextMenuPropGetItemSubMenu<ITEM> = (\n item: ITEM,\n) => ITEM[] | undefined;\nexport type ContextMenuPropGetItemStatus<ITEM> = (\n item: ITEM,\n) => ContextMenuStatus | undefined;\nexport type ContextMenuPropGetItemKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\nexport type ContextMenuPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => ContextMenuPropOnClick<ITEM> | undefined;\nexport type ContextMenuPropGetItemDisabled<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\nexport type ContextMenuPropGetItemAs<ITEM> = (\n item: ITEM,\n) => keyof JSX.IntrinsicElements | undefined;\nexport type ContextMenuPropGetItemAttributes<ITEM> = (\n item: ITEM,\n) => JSX.IntrinsicElements[keyof JSX.IntrinsicElements] | undefined;\nexport type ContextMenuPropGetItemGroupId<ITEM> = (\n item: ITEM,\n) => number | undefined;\nexport type ContextMenuPropGetItemRightIcon<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\nexport type ContextMenuPropGetItemLeftIcon<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\n\nexport type ContextMenuPropGetGroupLabel<GROUP> = (\n group: GROUP,\n) => string | undefined;\nexport type ContextMenuPropGetGroupId<GROUP> = (group: GROUP) => number;\n\ntype PositioningProps =\n | {\n anchorRef: React.RefObject<HTMLElement>;\n position?: never;\n }\n | {\n anchorRef?: never;\n position: Position;\n };\n\nexport type MappersItem<ITEM> = {\n getItemLabel?: ContextMenuPropGetItemLabel<ITEM>;\n getItemRightSide?: ContextMenuPropGetItemRightSide<ITEM>;\n getItemLeftSide?: ContextMenuPropGetItemLeftSide<ITEM>;\n getItemSubMenu?: ContextMenuPropGetItemSubMenu<ITEM>;\n getItemStatus?: ContextMenuPropGetItemStatus<ITEM>;\n getItemDisabled?: ContextMenuPropGetItemDisabled<ITEM>;\n getItemKey?: ContextMenuPropGetItemKey<ITEM>;\n getItemOnClick?: ContextMenuPropGetItemOnClick<ITEM>;\n getItemAs?: ContextMenuPropGetItemAs<ITEM>;\n getItemAttributes?: ContextMenuPropGetItemAttributes<ITEM>;\n getItemGroupId?: ContextMenuPropGetItemGroupId<ITEM>;\n getItemLeftIcon?: ContextMenuPropGetItemLeftIcon<ITEM>;\n getItemRightIcon?: ContextMenuPropGetItemRightIcon<ITEM>;\n};\n\nexport type MappersGroup<GROUP> = {\n getGroupLabel?: ContextMenuPropGetGroupLabel<GROUP>;\n getGroupId?: ContextMenuPropGetGroupId<GROUP>;\n};\n\nexport type Level<ITEM> = {\n items: ITEM[];\n activeItem?: string;\n direction?: Direction;\n possibleDirections?: readonly Direction[];\n offset?: PopoverPropOffset;\n} & PositioningProps;\n\nexport type AddLevel<ITEM> = (params: {\n level: number;\n items: ITEM[];\n anchorRef?: React.RefObject<HTMLElement>;\n activeItem: string;\n}) => void;\n\nexport type ContextMenuProps<\n ITEM = ContextMenuItemDefault,\n GROUP = ContextMenuGroupDefault,\n> = PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n size?: ContextMenuPropSize;\n direction?: Direction;\n offset?: PopoverPropOffset;\n groups?: GROUP[];\n sortGroup?: ContextMenuPropSortGroup;\n onItemClick?: ContextMenuPropOnClick<ITEM>;\n possibleDirections?: readonly Direction[];\n subMenuDirection?: ContextMenuPropSubMenuDirection;\n spareDirection?: Direction;\n onSetDirection?: (direction: Direction) => void;\n onClickOutside?: ClickOutsideHandler;\n isOpen?: boolean;\n } & MappersItem<ITEM> &\n MappersGroup<GROUP> &\n PositioningProps,\n HTMLDivElement\n> &\n (GROUP extends { id: ContextMenuGroupDefault['id'] | unknown }\n ? {}\n : { getGroupId: ContextMenuPropGetGroupId<GROUP> }) &\n (ITEM extends { label: ContextMenuItemDefault['label'] }\n ? {}\n : { getItemLabel: ContextMenuPropGetItemLabel<ITEM> });\n\nexport type ContextMenuComponent = <\n ITEM = ContextMenuItemDefault,\n GROUP = ContextMenuGroupDefault,\n>(\n props: ContextMenuProps<ITEM, GROUP>,\n) => React.ReactElement | null;\n\nexport type ContextMenuLevelProps<ITEM, GROUP> = Omit<\n ContextMenuProps<ITEM, GROUP>,\n | 'subMenuDirection'\n | 'onClickOutside'\n | keyof MappersItem<ITEM>\n | keyof MappersGroup<GROUP>\n> & {\n levelDepth: number;\n addLevel: AddLevel<ITEM>;\n deleteLevel: (level: number) => void;\n activeItem?: string;\n onSetDirection?: (direction: Direction) => void;\n hoveredParenLevel: number;\n setHoveredParenLevel: (level: number) => void;\n} & Required<MappersItem<ITEM>> &\n Required<MappersGroup<GROUP>>;\n\nexport type ContextMenuLevelComponent = <ITEM, GROUP>(\n props: ContextMenuLevelProps<ITEM, GROUP>,\n ref: React.Ref<HTMLElement>,\n) => React.ReactElement | null;\n\nexport type ContextMenuItemProps<\n AS extends keyof JSX.IntrinsicElements = 'div',\n> = PropsWithAsAttributes<\n Omit<ContextMenuItemDefault, 'onClick' | 'attributes' | 'key'> & {\n size?: ContextMenuPropSize;\n active: boolean;\n withSubMenu: boolean;\n },\n AS\n> &\n React.RefAttributes<HTMLDivElement>;\n\nexport type ContextMenuItemComponent = <\n AS extends keyof JSX.IntrinsicElements = 'div',\n>(\n props: ContextMenuItemProps<AS>,\n ref: React.Ref<HTMLElement>,\n) => React.ReactElement | null;\n\nexport type GetLevelsParams<ITEM> = {\n levels: Level<ITEM>[];\n items: ITEM[];\n getItemSubMenu: ContextMenuPropGetItemSubMenu<ITEM>;\n getItemKey: ContextMenuPropGetItemKey<ITEM>;\n};\n"],"mappings":"AAMA,MAAO,IAAMA,iBAAgB,CAAG,CAAC,GAAD,CAAM,IAAN,CAAY,GAAZ,CAAiB,GAAjB,CAAzB,CAEP,MAAO,IAAMC,uBAA2C,CAAGD,gBAAgB,CAAC,CAAD,CAApE,CAEP,MAAO,IAAME,kBAAiB,CAAG,CAAC,OAAD,CAAU,SAAV,CAAqB,SAArB,CAA1B,CAEP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAEP,MAAO,IAAME,iCAAgC,CAAG,CAC9C,cAD8C,CAE9C,gBAF8C,CAG9C,aAH8C,CAI9C,eAJ8C,CAAzC,CAQP,MAAO,IAAMC,uCAAuE,CAClFD,gCAAgC,CAAC,CAAD,CAD3B"}
@@ -1 +1 @@
1
- .SelectItem{--text-color:var(--color-control-typo-default);word-wrap:break-word;background-color:var(--color-control-bg-clear);color:var(--text-color);cursor:pointer;font-size:var(--font-size);padding:var(--vertical-space) var(--horizontal-space);position:relative}.SelectItem_size_xs{--horizontal-space:calc(var(--control-space-xs)*0.5);--vertical-space:calc(var(--control-space-s)*0.25);--font-size:var(--control-text-size-xs)}.SelectItem_size_s{--horizontal-space:calc(var(--control-space-s)*0.5);--vertical-space:calc(var(--control-space-s)*0.25);--font-size:var(--control-text-size-s)}.SelectItem_size_m{--horizontal-space:calc(var(--control-space-m)*0.5);--vertical-space:calc(var(--control-space-s)*0.5);--font-size:var(--control-text-size-m)}.SelectItem_size_l{--horizontal-space:calc(var(--control-space-l)*0.5);--vertical-space:calc(var(--control-space-s)*0.5);--font-size:var(--control-text-size-l)}.SelectItem_hovered{background-color:var(--color-control-bg-clear-hover)}.SelectItem_active{--text-color:var(--color-control-typo-secondary)}.SelectItem_disabled{--text-color:var(--color-control-typo-disable)}.SelectItem_multiple{align-items:center;display:flex}.SelectItem_indent_increased{padding-left:calc(var(--horizontal-space)*2.6)}.SelectItem:not(.SelectItem_multiple):before{background-color:transparent;bottom:0;content:"";left:0;position:absolute;top:0;transition:background-color .2s ease-in;width:2px}.SelectItem:not(.SelectItem_multiple).SelectItem_active:before{background-color:var(--text-color)}.SelectItem-Checkbox{margin-right:var(--space-xs)}
1
+ .SelectItem{--text-color:var(--color-control-typo-default);word-wrap:break-word;background-color:var(--color-control-bg-clear);color:var(--text-color);cursor:pointer;font-size:var(--font-size);min-height:calc(var(--vertical-space)*2 + var(--font-size)*1.2);padding:var(--vertical-space) var(--horizontal-space);position:relative}.SelectItem_size_xs{--horizontal-space:calc(var(--control-space-xs)*0.5);--vertical-space:calc(var(--control-space-s)*0.25);--font-size:var(--control-text-size-xs)}.SelectItem_size_s{--horizontal-space:calc(var(--control-space-s)*0.5);--vertical-space:calc(var(--control-space-s)*0.25);--font-size:var(--control-text-size-s)}.SelectItem_size_m{--horizontal-space:calc(var(--control-space-m)*0.5);--vertical-space:calc(var(--control-space-s)*0.5);--font-size:var(--control-text-size-m)}.SelectItem_size_l{--horizontal-space:calc(var(--control-space-l)*0.5);--vertical-space:calc(var(--control-space-s)*0.5);--font-size:var(--control-text-size-l)}.SelectItem_hovered{background-color:var(--color-control-bg-clear-hover)}.SelectItem_active{--text-color:var(--color-control-typo-secondary)}.SelectItem_disabled{--text-color:var(--color-control-typo-disable)}.SelectItem_multiple{align-items:center;display:flex}.SelectItem_indent_increased{padding-left:calc(var(--horizontal-space)*2.6)}.SelectItem:not(.SelectItem_multiple):before{background-color:transparent;bottom:0;content:"";left:0;position:absolute;top:0;transition:background-color .2s ease-in;width:2px}.SelectItem:not(.SelectItem_multiple).SelectItem_active:before{background-color:var(--text-color)}.SelectItem-Checkbox{margin-right:var(--space-xs)}
@@ -1,2 +1,2 @@
1
- import"./TableRowsCollapse.css";import React from"react";import{IconArrowDown}from"../../../icons/IconArrowDown/IconArrowDown";import{IconArrowUp}from"../../../icons/IconArrowUp/IconArrowUp";import{cn}from"../../../utils/bem";import{Button}from"../../Button/Button";export var cnTableRowsCollapse=cn("TableRowsCollapse");export var TableRowsCollapse=function(a){var b=a.level,c=a.children,d=a.isExpanded,e=a.toggleCollapse,f=a.withCollapseButton,g=a.isExpandedByDefault;return React.createElement("div",{style:{"--nesting-level":b},className:cnTableRowsCollapse(),onClick:e,onKeyDown:e},!g&&f&&React.createElement("div",{className:cnTableRowsCollapse("buttonContainer")},React.createElement(Button,{"aria-expanded":d,iconLeft:d?IconArrowUp:IconArrowDown,iconSize:"s",size:"xs",onlyIcon:!0,view:"clear"})),React.createElement("div",{className:cnTableRowsCollapse("cellContainer",{withExpanderPadding:!g})},c))};
1
+ import"./TableRowsCollapse.css";import React from"react";import{IconArrowDown}from"../../../icons/IconArrowDown/IconArrowDown";import{IconArrowUp}from"../../../icons/IconArrowUp/IconArrowUp";import{cn}from"../../../utils/bem";import{Button}from"../../Button/Button";export var cnTableRowsCollapse=cn("TableRowsCollapse");export var TableRowsCollapse=function(a){var b=a.level,c=a.children,d=a.isExpanded,e=a.toggleCollapse,f=a.withCollapseButton,g=a.isExpandedByDefault;return React.createElement("div",{style:{"--nesting-level":b},className:cnTableRowsCollapse(),onClick:e},!g&&f&&React.createElement("div",{className:cnTableRowsCollapse("buttonContainer")},React.createElement(Button,{"aria-expanded":d,iconLeft:d?IconArrowUp:IconArrowDown,iconSize:"s",size:"xs",onlyIcon:!0,view:"clear"})),React.createElement("div",{className:cnTableRowsCollapse("cellContainer",{withExpanderPadding:!g})},c))};
2
2
  //# sourceMappingURL=TableRowsCollapse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TableRowsCollapse.js","names":["React","IconArrowDown","IconArrowUp","cn","Button","cnTableRowsCollapse","TableRowsCollapse","props","level","children","isExpanded","toggleCollapse","withCollapseButton","isExpandedByDefault","withExpanderPadding"],"sources":["../../../../../../src/components/Table/RowsCollapse/TableRowsCollapse.tsx"],"sourcesContent":["import './TableRowsCollapse.css';\n\nimport React from 'react';\n\nimport { IconArrowDown } from '../../../icons/IconArrowDown/IconArrowDown';\nimport { IconArrowUp } from '../../../icons/IconArrowUp/IconArrowUp';\nimport { cn } from '../../../utils/bem';\nimport { Button } from '../../Button/Button';\n\nexport type Props = {\n level: number;\n isExpandedByDefault?: boolean;\n toggleCollapse?: (e: React.SyntheticEvent) => void;\n isExpanded?: boolean;\n withCollapseButton?: boolean;\n children?: React.ReactNode;\n};\n\nexport const cnTableRowsCollapse = cn('TableRowsCollapse');\n\nexport const TableRowsCollapse: React.FC<Props> = (props) => {\n const {\n level,\n children,\n isExpanded,\n toggleCollapse,\n withCollapseButton,\n isExpandedByDefault,\n } = props;\n\n const style: React.CSSProperties & {\n '--nesting-level': number;\n } = { '--nesting-level': level };\n\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div\n style={style}\n className={cnTableRowsCollapse()}\n onClick={toggleCollapse}\n onKeyDown={toggleCollapse}\n >\n {!isExpandedByDefault && withCollapseButton && (\n <div className={cnTableRowsCollapse('buttonContainer')}>\n <Button\n aria-expanded={isExpanded}\n iconLeft={isExpanded ? IconArrowUp : IconArrowDown}\n iconSize=\"s\"\n size=\"xs\"\n onlyIcon\n view=\"clear\"\n />\n </div>\n )}\n <div\n className={cnTableRowsCollapse('cellContainer', {\n withExpanderPadding: !isExpandedByDefault,\n })}\n >\n {children}\n </div>\n </div>\n );\n};\n"],"mappings":"AAAA,gCAEA,MAAOA,MAAP,KAAkB,OAAlB,CAEA,OAASC,aAAT,kDACA,OAASC,WAAT,8CACA,OAASC,EAAT,0BACA,OAASC,MAAT,2BAWA,MAAO,IAAMC,oBAAmB,CAAGF,EAAE,CAAC,mBAAD,CAA9B,CAEP,MAAO,IAAMG,kBAAkC,CAAG,SAACC,CAAD,CAAW,IAEzDC,EAFyD,CAQvDD,CARuD,CAEzDC,KAFyD,CAGzDC,CAHyD,CAQvDF,CARuD,CAGzDE,QAHyD,CAIzDC,CAJyD,CAQvDH,CARuD,CAIzDG,UAJyD,CAKzDC,CALyD,CAQvDJ,CARuD,CAKzDI,cALyD,CAMzDC,CANyD,CAQvDL,CARuD,CAMzDK,kBANyD,CAOzDC,CAPyD,CAQvDN,CARuD,CAOzDM,mBAPyD,CAc3D,MAEE,4BACE,KAAK,CALL,CAAE,kBAAmBL,CAArB,CAIF,CAEE,SAAS,CAAEH,mBAAmB,EAFhC,CAGE,OAAO,CAAEM,CAHX,CAIE,SAAS,CAAEA,CAJb,EAMG,CAACE,CAAD,EAAwBD,CAAxB,EACC,2BAAK,SAAS,CAAEP,mBAAmB,CAAC,iBAAD,CAAnC,EACE,oBAAC,MAAD,EACE,gBAAeK,CADjB,CAEE,QAAQ,CAAEA,CAAU,CAAGR,WAAH,CAAiBD,aAFvC,CAGE,QAAQ,CAAC,GAHX,CAIE,IAAI,CAAC,IAJP,CAKE,QAAQ,GALV,CAME,IAAI,CAAC,OANP,EADF,CAPJ,CAkBE,2BACE,SAAS,CAAEI,mBAAmB,CAAC,eAAD,CAAkB,CAC9CS,mBAAmB,CAAE,CAACD,CADwB,CAAlB,CADhC,EAKGJ,CALH,CAlBF,CA2BH,CA3CM"}
1
+ {"version":3,"file":"TableRowsCollapse.js","names":["React","IconArrowDown","IconArrowUp","cn","Button","cnTableRowsCollapse","TableRowsCollapse","props","level","children","isExpanded","toggleCollapse","withCollapseButton","isExpandedByDefault","withExpanderPadding"],"sources":["../../../../../../src/components/Table/RowsCollapse/TableRowsCollapse.tsx"],"sourcesContent":["import './TableRowsCollapse.css';\n\nimport React from 'react';\n\nimport { IconArrowDown } from '../../../icons/IconArrowDown/IconArrowDown';\nimport { IconArrowUp } from '../../../icons/IconArrowUp/IconArrowUp';\nimport { cn } from '../../../utils/bem';\nimport { Button } from '../../Button/Button';\n\nexport type Props = {\n level: number;\n isExpandedByDefault?: boolean;\n toggleCollapse?: (e: React.SyntheticEvent) => void;\n isExpanded?: boolean;\n withCollapseButton?: boolean;\n children?: React.ReactNode;\n};\n\nexport const cnTableRowsCollapse = cn('TableRowsCollapse');\n\nexport const TableRowsCollapse: React.FC<Props> = (props) => {\n const {\n level,\n children,\n isExpanded,\n toggleCollapse,\n withCollapseButton,\n isExpandedByDefault,\n } = props;\n\n const style: React.CSSProperties & {\n '--nesting-level': number;\n } = { '--nesting-level': level };\n\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events\n <div\n style={style}\n className={cnTableRowsCollapse()}\n onClick={toggleCollapse}\n >\n {!isExpandedByDefault && withCollapseButton && (\n <div className={cnTableRowsCollapse('buttonContainer')}>\n <Button\n aria-expanded={isExpanded}\n iconLeft={isExpanded ? IconArrowUp : IconArrowDown}\n iconSize=\"s\"\n size=\"xs\"\n onlyIcon\n view=\"clear\"\n />\n </div>\n )}\n <div\n className={cnTableRowsCollapse('cellContainer', {\n withExpanderPadding: !isExpandedByDefault,\n })}\n >\n {children}\n </div>\n </div>\n );\n};\n"],"mappings":"AAAA,gCAEA,MAAOA,MAAP,KAAkB,OAAlB,CAEA,OAASC,aAAT,kDACA,OAASC,WAAT,8CACA,OAASC,EAAT,0BACA,OAASC,MAAT,2BAWA,MAAO,IAAMC,oBAAmB,CAAGF,EAAE,CAAC,mBAAD,CAA9B,CAEP,MAAO,IAAMG,kBAAkC,CAAG,SAACC,CAAD,CAAW,IAEzDC,EAFyD,CAQvDD,CARuD,CAEzDC,KAFyD,CAGzDC,CAHyD,CAQvDF,CARuD,CAGzDE,QAHyD,CAIzDC,CAJyD,CAQvDH,CARuD,CAIzDG,UAJyD,CAKzDC,CALyD,CAQvDJ,CARuD,CAKzDI,cALyD,CAMzDC,CANyD,CAQvDL,CARuD,CAMzDK,kBANyD,CAOzDC,CAPyD,CAQvDN,CARuD,CAOzDM,mBAPyD,CAc3D,MAEE,4BACE,KAAK,CALL,CAAE,kBAAmBL,CAArB,CAIF,CAEE,SAAS,CAAEH,mBAAmB,EAFhC,CAGE,OAAO,CAAEM,CAHX,EAKG,CAACE,CAAD,EAAwBD,CAAxB,EACC,2BAAK,SAAS,CAAEP,mBAAmB,CAAC,iBAAD,CAAnC,EACE,oBAAC,MAAD,EACE,gBAAeK,CADjB,CAEE,QAAQ,CAAEA,CAAU,CAAGR,WAAH,CAAiBD,aAFvC,CAGE,QAAQ,CAAC,GAHX,CAIE,IAAI,CAAC,IAJP,CAKE,QAAQ,GALV,CAME,IAAI,CAAC,OANP,EADF,CANJ,CAiBE,2BACE,SAAS,CAAEI,mBAAmB,CAAC,eAAD,CAAkB,CAC9CS,mBAAmB,CAAE,CAACD,CADwB,CAAlB,CADhC,EAKGJ,CALH,CAjBF,CA0BH,CA1CM"}
@@ -48,6 +48,7 @@ export declare type onCellClick = ({ e, type, rowId, columnIdx, ref, }: {
48
48
  }) => void;
49
49
  export declare type TableRow = {
50
50
  id: string;
51
+ defaultExpand?: boolean;
51
52
  rows?: TableRow[];
52
53
  };
53
54
  export declare type TableTreeRow<T extends TableRow> = {
@@ -109,6 +110,7 @@ export declare type TableProps<T extends TableRow> = {
109
110
  headerVerticalAlign?: HeaderVerticalAlign;
110
111
  zebraStriped?: ZebraStriped;
111
112
  borderBetweenRows?: boolean;
113
+ defaultExpandAll?: boolean;
112
114
  borderBetweenColumns?: boolean;
113
115
  emptyRowsPlaceholder?: React.ReactNode;
114
116
  className?: string;