@consta/uikit 4.27.0 → 4.28.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 (104) hide show
  1. package/ChipsCanary/index.d.ts +1 -0
  2. package/ChipsCanary/index.js +1 -0
  3. package/__internal__/src/components/BadgeGroup/BadgeGroup.js +1 -1
  4. package/__internal__/src/components/BadgeGroup/BadgeGroup.js.map +1 -1
  5. package/__internal__/src/components/BadgeGroup/helper.d.ts +0 -1
  6. package/__internal__/src/components/BadgeGroup/helper.js +1 -1
  7. package/__internal__/src/components/BadgeGroup/helper.js.map +1 -1
  8. package/__internal__/src/components/Button/Button.css +1 -1
  9. package/__internal__/src/components/CheckboxGroup/CheckboxGroup.js +1 -1
  10. package/__internal__/src/components/CheckboxGroup/CheckboxGroup.js.map +1 -1
  11. package/__internal__/src/components/CheckboxGroup/helper.d.ts +3 -1
  12. package/__internal__/src/components/CheckboxGroup/helper.js +1 -1
  13. package/__internal__/src/components/CheckboxGroup/helper.js.map +1 -1
  14. package/__internal__/src/components/CheckboxGroup/types.d.ts +9 -1
  15. package/__internal__/src/components/CheckboxGroup/types.js.map +1 -1
  16. package/__internal__/src/components/ChipsCanary/Chips.css +1 -0
  17. package/__internal__/src/components/ChipsCanary/ChipsCanary.d.ts +3 -0
  18. package/__internal__/src/components/ChipsCanary/ChipsCanary.js +2 -0
  19. package/__internal__/src/components/ChipsCanary/ChipsCanary.js.map +1 -0
  20. package/__internal__/src/components/ChipsCanary/ChipsChoice/ChipsChoice.d.ts +4 -0
  21. package/__internal__/src/components/ChipsCanary/ChipsChoice/ChipsChoice.js +2 -0
  22. package/__internal__/src/components/ChipsCanary/ChipsChoice/ChipsChoice.js.map +1 -0
  23. package/__internal__/src/components/ChipsCanary/ChipsChoice/index.d.ts +2 -0
  24. package/__internal__/src/components/ChipsCanary/ChipsChoice/index.js +2 -0
  25. package/__internal__/src/components/ChipsCanary/ChipsChoice/index.js.map +1 -0
  26. package/__internal__/src/components/ChipsCanary/ChipsChoice/types.d.ts +29 -0
  27. package/__internal__/src/components/ChipsCanary/ChipsChoice/types.js +2 -0
  28. package/__internal__/src/components/ChipsCanary/ChipsChoice/types.js.map +1 -0
  29. package/__internal__/src/components/ChipsCanary/ChipsItem/ChipsItem.css +3 -0
  30. package/__internal__/src/components/ChipsCanary/ChipsItem/ChipsItem.d.ts +3 -0
  31. package/__internal__/src/components/ChipsCanary/ChipsItem/ChipsItem.js +2 -0
  32. package/__internal__/src/components/ChipsCanary/ChipsItem/ChipsItem.js.map +1 -0
  33. package/__internal__/src/components/ChipsCanary/ChipsItem/index.d.ts +1 -0
  34. package/__internal__/src/components/ChipsCanary/ChipsItem/index.js +2 -0
  35. package/__internal__/src/components/ChipsCanary/ChipsItem/index.js.map +1 -0
  36. package/__internal__/src/components/ChipsCanary/helpers.d.ts +39 -0
  37. package/__internal__/src/components/ChipsCanary/helpers.js +2 -0
  38. package/__internal__/src/components/ChipsCanary/helpers.js.map +1 -0
  39. package/__internal__/src/components/ChipsCanary/index.d.ts +4 -0
  40. package/__internal__/src/components/ChipsCanary/index.js +2 -0
  41. package/__internal__/src/components/ChipsCanary/index.js.map +1 -0
  42. package/__internal__/src/components/ChipsCanary/types.d.ts +62 -0
  43. package/__internal__/src/components/ChipsCanary/types.js +2 -0
  44. package/__internal__/src/components/ChipsCanary/types.js.map +1 -0
  45. package/__internal__/src/components/ChoiceGroup/ChoiceGroup.js +1 -1
  46. package/__internal__/src/components/ChoiceGroup/ChoiceGroup.js.map +1 -1
  47. package/__internal__/src/components/ChoiceGroup/Item/ChoiceGroup-Item.d.ts +7 -9
  48. package/__internal__/src/components/ChoiceGroup/Item/ChoiceGroup-Item.js +1 -1
  49. package/__internal__/src/components/ChoiceGroup/Item/ChoiceGroup-Item.js.map +1 -1
  50. package/__internal__/src/components/ChoiceGroup/helper.d.ts +3 -1
  51. package/__internal__/src/components/ChoiceGroup/helper.js +1 -1
  52. package/__internal__/src/components/ChoiceGroup/helper.js.map +1 -1
  53. package/__internal__/src/components/ChoiceGroup/types.d.ts +7 -1
  54. package/__internal__/src/components/ChoiceGroup/types.js.map +1 -1
  55. package/__internal__/src/components/ComboboxCanary/ComboboxCanary.js +1 -1
  56. package/__internal__/src/components/ComboboxCanary/ComboboxCanary.js.map +1 -1
  57. package/__internal__/src/components/ComboboxCanary/helpers.d.ts +4 -0
  58. package/__internal__/src/components/ComboboxCanary/helpers.js.map +1 -1
  59. package/__internal__/src/components/DatePicker/DatePickerTypeDate/DatePickerTypeDate.js +1 -1
  60. package/__internal__/src/components/DatePicker/DatePickerTypeDate/DatePickerTypeDate.js.map +1 -1
  61. package/__internal__/src/components/DatePicker/DatePickerTypeDateRange/DatePickerTypeDateRange.js +1 -1
  62. package/__internal__/src/components/DatePicker/DatePickerTypeDateRange/DatePickerTypeDateRange.js.map +1 -1
  63. package/__internal__/src/components/DatePicker/DatePickerTypeDateTime/DatePickerTypeDateTime.js +1 -1
  64. package/__internal__/src/components/DatePicker/DatePickerTypeDateTime/DatePickerTypeDateTime.js.map +1 -1
  65. package/__internal__/src/components/DatePicker/DatePickerTypeDateTimeRange/DatePickerTypeDateTimeRange.js +1 -1
  66. package/__internal__/src/components/DatePicker/DatePickerTypeDateTimeRange/DatePickerTypeDateTimeRange.js.map +1 -1
  67. package/__internal__/src/components/DatePicker/DatePickerTypeMonth/DatePickerTypeMonth.js +1 -1
  68. package/__internal__/src/components/DatePicker/DatePickerTypeMonth/DatePickerTypeMonth.js.map +1 -1
  69. package/__internal__/src/components/DatePicker/DatePickerTypeMonthRange/DatePickerTypeMonthRange.js +1 -1
  70. package/__internal__/src/components/DatePicker/DatePickerTypeMonthRange/DatePickerTypeMonthRange.js.map +1 -1
  71. package/__internal__/src/components/DatePicker/DatePickerTypeTime/DatePickerTypeTime.js +1 -1
  72. package/__internal__/src/components/DatePicker/DatePickerTypeTime/DatePickerTypeTime.js.map +1 -1
  73. package/__internal__/src/components/DatePicker/DatePickerTypeYear/DatePickerTypeYear.js +1 -1
  74. package/__internal__/src/components/DatePicker/DatePickerTypeYear/DatePickerTypeYear.js.map +1 -1
  75. package/__internal__/src/components/DatePicker/DatePickerTypeYearRange/DatePickerTypeYearRange.js +1 -1
  76. package/__internal__/src/components/DatePicker/DatePickerTypeYearRange/DatePickerTypeYearRange.js.map +1 -1
  77. package/__internal__/src/components/DatePicker/useCalendarVisible.js +1 -1
  78. package/__internal__/src/components/DatePicker/useCalendarVisible.js.map +1 -1
  79. package/__internal__/src/components/EventInterceptor/propsHandlers/useTextFieldEventsHandler.d.ts +1 -54
  80. package/__internal__/src/components/SelectComponentsCanary/Select.css +1 -1
  81. package/__internal__/src/components/SelectComponentsCanary/useSelect/useSelect.d.ts +1 -0
  82. package/__internal__/src/components/SelectComponentsCanary/useSelect/useSelect.js +1 -1
  83. package/__internal__/src/components/SelectComponentsCanary/useSelect/useSelect.js.map +1 -1
  84. package/__internal__/src/components/TextField/types.d.ts +2 -2
  85. package/__internal__/src/components/TextField/types.js.map +1 -1
  86. package/__internal__/src/hooks/useChoiceGroup/useChoiceGroup.d.ts +2 -2
  87. package/__internal__/src/hooks/useChoiceGroup/useChoiceGroup.js.map +1 -1
  88. package/__internal__/src/hooks/useGlobalKeys/useGlobalKeys.d.ts +1 -1
  89. package/__internal__/src/hooks/useGlobalKeys/useGlobalKeys.js.map +1 -1
  90. package/__internal__/src/hooks/useKeysCanary/index.d.ts +1 -0
  91. package/__internal__/src/hooks/useKeysCanary/index.js +2 -0
  92. package/__internal__/src/hooks/useKeysCanary/index.js.map +1 -0
  93. package/__internal__/src/hooks/useKeysCanary/useKeysCanary.d.ts +12 -0
  94. package/__internal__/src/hooks/useKeysCanary/useKeysCanary.js +2 -0
  95. package/__internal__/src/hooks/useKeysCanary/useKeysCanary.js.map +1 -0
  96. package/__internal__/src/hooks/useKeysRef/useKeysRef.d.ts +2 -1
  97. package/__internal__/src/hooks/useKeysRef/useKeysRef.js +1 -1
  98. package/__internal__/src/hooks/useKeysRef/useKeysRef.js.map +1 -1
  99. package/__internal__/src/utils/stand.d.ts +1 -0
  100. package/__internal__/src/utils/stand.js +2 -0
  101. package/__internal__/src/utils/stand.js.map +1 -0
  102. package/package.json +1 -1
  103. package/useKeysCanary/index.d.ts +1 -0
  104. package/useKeysCanary/index.js +1 -0
@@ -91,5 +91,5 @@ export declare type TextFieldProps<TYPE extends string> = PropsWithHTMLAttribute
91
91
  onKeyUp?: React.KeyboardEventHandler;
92
92
  onKeyUpCapture?: React.KeyboardEventHandler;
93
93
  onKeyDown?: React.KeyboardEventHandler;
94
- }, HTMLDivElement> & TextFieldPropsTextareaType<TYPE> & TextFieldPropRightSide<TYPE>;
95
- export declare type TextFieldComponent = <TYPE extends string>(props: TextFieldProps<TYPE> & React.RefAttributes<HTMLElement>) => React.ReactElement | null;
94
+ }, HTMLDivElement> & TextFieldPropsTextareaType<TYPE> & TextFieldPropRightSide<TYPE> & React.RefAttributes<HTMLDivElement>;
95
+ export declare type TextFieldComponent = <TYPE extends string>(props: TextFieldProps<TYPE>) => React.ReactElement | null;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["textFieldPropSize","textFieldPropSizeDefault","textFieldPropView","textFieldPropViewDefault","textFieldPropForm","textFieldPropFormDefault","textFieldPropStatus","textFieldPropWidth","textFieldPropWidthDefault"],"sources":["../../../../../src/components/TextField/types.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { AutoCompete } from '../../utils/types/AutoComplete';\nimport { PropsWithHTMLAttributes } from '../../utils/types/PropsWithHTMLAttributes';\n\nexport type TextFieldPropValue = string | null;\nexport type TextFieldPropName = string;\nexport type TextFieldPropId = string | number;\n\nexport const textFieldPropSize = ['m', 'xs', 's', 'l'] as const;\nexport type TextFieldPropSize = typeof textFieldPropSize[number];\nexport const textFieldPropSizeDefault: TextFieldPropSize = textFieldPropSize[0];\n\nexport type TextFieldPropOnChange = (args: TextFieldOnChangeArguments) => void;\nexport type TextFieldOnChangeArguments = {\n e: React.ChangeEvent | React.MouseEvent | React.KeyboardEvent;\n id?: TextFieldPropId;\n name?: TextFieldPropName;\n value: TextFieldPropValue;\n};\n\nexport const textFieldPropView = ['default', 'clear'] as const;\nexport type TextFieldPropView = typeof textFieldPropView[number];\nexport const textFieldPropViewDefault: TextFieldPropView = textFieldPropView[0];\n\nexport const textFieldPropForm = [\n 'default',\n 'defaultClear',\n 'defaultBrick',\n 'brick',\n 'brickDefault',\n 'brickClear',\n 'brickRound',\n 'round',\n 'roundClear',\n 'roundBrick',\n 'clearRound',\n 'clearDefault',\n 'clearBrick',\n 'clearClear',\n] as const;\nexport type TextFieldPropForm = typeof textFieldPropForm[number];\nexport const textFieldPropFormDefault: TextFieldPropForm = textFieldPropForm[0];\n\nexport const textFieldPropStatus = ['alert', 'success', 'warning'] as const;\nexport type TextFieldPropStatus = typeof textFieldPropStatus[number];\n\nexport const textFieldPropWidth = ['default', 'full'] as const;\nexport type TextFieldPropWidth = typeof textFieldPropWidth[number];\nexport const textFieldPropWidthDefault: TextFieldPropWidth =\n textFieldPropWidth[0];\n\nexport type TextFieldPropsTextareaType<TYPE> = TYPE extends 'textarea'\n ?\n | {\n minRows?: never;\n maxRows?: never;\n rows?: number;\n }\n | {\n rows?: never;\n minRows?: number;\n maxRows?: number;\n }\n : {\n rows?: never;\n minRows?: never;\n maxRows?: never;\n };\n\nexport type TextFieldPropRightSide<TYPE extends string> = TYPE extends\n | 'number'\n | 'password'\n ? {\n rightSide?: never;\n }\n : {\n rightSide?: string | IconComponent;\n };\n\nexport type TextFieldProps<TYPE extends string> = PropsWithHTMLAttributes<\n {\n className?: string;\n value?: TextFieldPropValue;\n cols?: number;\n onChange?: TextFieldPropOnChange;\n id?: TextFieldPropId;\n name?: TextFieldPropName;\n type?: TYPE;\n disabled?: boolean;\n maxLength?: number;\n size?: TextFieldPropSize;\n view?: TextFieldPropView;\n form?: TextFieldPropForm;\n state?: TextFieldPropStatus;\n status?: TextFieldPropStatus;\n width?: TextFieldPropWidth;\n onFocus?: React.FocusEventHandler<HTMLElement>;\n onBlur?: React.FocusEventHandler<HTMLElement>;\n incrementButtons?: boolean;\n autoFocus?: boolean;\n placeholder?: string;\n leftSide?: string | IconComponent;\n rightSide?: string | IconComponent;\n withClearButton?: boolean;\n autoComplete?: AutoCompete;\n max?: number | string;\n min?: number | string;\n readOnly?: boolean;\n required?: boolean;\n step?: number | string | number[];\n tabIndex?: number;\n inputContainerRef?: React.Ref<HTMLDivElement>;\n inputRef?: React.Ref<HTMLTextAreaElement | HTMLInputElement>;\n ariaLabel?: string;\n iconSize?: IconPropSize;\n children?: never;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n labelPosition?: 'top' | 'left';\n focused?: boolean;\n onKeyDownCapture?: React.KeyboardEventHandler;\n onKeyPress?: React.KeyboardEventHandler;\n onKeyPressCapture?: React.KeyboardEventHandler;\n onKeyUp?: React.KeyboardEventHandler;\n onKeyUpCapture?: React.KeyboardEventHandler;\n onKeyDown?: React.KeyboardEventHandler;\n },\n HTMLDivElement\n> &\n TextFieldPropsTextareaType<TYPE> &\n TextFieldPropRightSide<TYPE>;\n\nexport type TextFieldComponent = <TYPE extends string>(\n props: TextFieldProps<TYPE> & React.RefAttributes<HTMLElement>,\n) => React.ReactElement | null;\n"],"mappings":"AAUA,MAAO,IAAMA,kBAAiB,CAAG,CAAC,GAAD,CAAM,IAAN,CAAY,GAAZ,CAAiB,GAAjB,CAA1B,CAEP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAUP,MAAO,IAAME,kBAAiB,CAAG,CAAC,SAAD,CAAY,OAAZ,CAA1B,CAEP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAEP,MAAO,IAAME,kBAAiB,CAAG,CAC/B,SAD+B,CAE/B,cAF+B,CAG/B,cAH+B,CAI/B,OAJ+B,CAK/B,cAL+B,CAM/B,YAN+B,CAO/B,YAP+B,CAQ/B,OAR+B,CAS/B,YAT+B,CAU/B,YAV+B,CAW/B,YAX+B,CAY/B,cAZ+B,CAa/B,YAb+B,CAc/B,YAd+B,CAA1B,CAiBP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAEP,MAAO,IAAME,oBAAmB,CAAG,CAAC,OAAD,CAAU,SAAV,CAAqB,SAArB,CAA5B,CAGP,MAAO,IAAMC,mBAAkB,CAAG,CAAC,SAAD,CAAY,MAAZ,CAA3B,CAEP,MAAO,IAAMC,0BAA6C,CACxDD,kBAAkB,CAAC,CAAD,CADb"}
1
+ {"version":3,"file":"types.js","names":["textFieldPropSize","textFieldPropSizeDefault","textFieldPropView","textFieldPropViewDefault","textFieldPropForm","textFieldPropFormDefault","textFieldPropStatus","textFieldPropWidth","textFieldPropWidthDefault"],"sources":["../../../../../src/components/TextField/types.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { AutoCompete } from '../../utils/types/AutoComplete';\nimport { PropsWithHTMLAttributes } from '../../utils/types/PropsWithHTMLAttributes';\n\nexport type TextFieldPropValue = string | null;\nexport type TextFieldPropName = string;\nexport type TextFieldPropId = string | number;\n\nexport const textFieldPropSize = ['m', 'xs', 's', 'l'] as const;\nexport type TextFieldPropSize = typeof textFieldPropSize[number];\nexport const textFieldPropSizeDefault: TextFieldPropSize = textFieldPropSize[0];\n\nexport type TextFieldPropOnChange = (args: TextFieldOnChangeArguments) => void;\nexport type TextFieldOnChangeArguments = {\n e: React.ChangeEvent | React.MouseEvent | React.KeyboardEvent;\n id?: TextFieldPropId;\n name?: TextFieldPropName;\n value: TextFieldPropValue;\n};\n\nexport const textFieldPropView = ['default', 'clear'] as const;\nexport type TextFieldPropView = typeof textFieldPropView[number];\nexport const textFieldPropViewDefault: TextFieldPropView = textFieldPropView[0];\n\nexport const textFieldPropForm = [\n 'default',\n 'defaultClear',\n 'defaultBrick',\n 'brick',\n 'brickDefault',\n 'brickClear',\n 'brickRound',\n 'round',\n 'roundClear',\n 'roundBrick',\n 'clearRound',\n 'clearDefault',\n 'clearBrick',\n 'clearClear',\n] as const;\nexport type TextFieldPropForm = typeof textFieldPropForm[number];\nexport const textFieldPropFormDefault: TextFieldPropForm = textFieldPropForm[0];\n\nexport const textFieldPropStatus = ['alert', 'success', 'warning'] as const;\nexport type TextFieldPropStatus = typeof textFieldPropStatus[number];\n\nexport const textFieldPropWidth = ['default', 'full'] as const;\nexport type TextFieldPropWidth = typeof textFieldPropWidth[number];\nexport const textFieldPropWidthDefault: TextFieldPropWidth =\n textFieldPropWidth[0];\n\nexport type TextFieldPropsTextareaType<TYPE> = TYPE extends 'textarea'\n ?\n | {\n minRows?: never;\n maxRows?: never;\n rows?: number;\n }\n | {\n rows?: never;\n minRows?: number;\n maxRows?: number;\n }\n : {\n rows?: never;\n minRows?: never;\n maxRows?: never;\n };\n\nexport type TextFieldPropRightSide<TYPE extends string> = TYPE extends\n | 'number'\n | 'password'\n ? {\n rightSide?: never;\n }\n : {\n rightSide?: string | IconComponent;\n };\n\nexport type TextFieldProps<TYPE extends string> = PropsWithHTMLAttributes<\n {\n className?: string;\n value?: TextFieldPropValue;\n cols?: number;\n onChange?: TextFieldPropOnChange;\n id?: TextFieldPropId;\n name?: TextFieldPropName;\n type?: TYPE;\n disabled?: boolean;\n maxLength?: number;\n size?: TextFieldPropSize;\n view?: TextFieldPropView;\n form?: TextFieldPropForm;\n state?: TextFieldPropStatus;\n status?: TextFieldPropStatus;\n width?: TextFieldPropWidth;\n onFocus?: React.FocusEventHandler<HTMLElement>;\n onBlur?: React.FocusEventHandler<HTMLElement>;\n incrementButtons?: boolean;\n autoFocus?: boolean;\n placeholder?: string;\n leftSide?: string | IconComponent;\n rightSide?: string | IconComponent;\n withClearButton?: boolean;\n autoComplete?: AutoCompete;\n max?: number | string;\n min?: number | string;\n readOnly?: boolean;\n required?: boolean;\n step?: number | string | number[];\n tabIndex?: number;\n inputContainerRef?: React.Ref<HTMLDivElement>;\n inputRef?: React.Ref<HTMLTextAreaElement | HTMLInputElement>;\n ariaLabel?: string;\n iconSize?: IconPropSize;\n children?: never;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n labelPosition?: 'top' | 'left';\n focused?: boolean;\n onKeyDownCapture?: React.KeyboardEventHandler;\n onKeyPress?: React.KeyboardEventHandler;\n onKeyPressCapture?: React.KeyboardEventHandler;\n onKeyUp?: React.KeyboardEventHandler;\n onKeyUpCapture?: React.KeyboardEventHandler;\n onKeyDown?: React.KeyboardEventHandler;\n },\n HTMLDivElement\n> &\n TextFieldPropsTextareaType<TYPE> &\n TextFieldPropRightSide<TYPE> &\n React.RefAttributes<HTMLDivElement>;\n\nexport type TextFieldComponent = <TYPE extends string>(\n props: TextFieldProps<TYPE>,\n) => React.ReactElement | null;\n"],"mappings":"AAUA,MAAO,IAAMA,kBAAiB,CAAG,CAAC,GAAD,CAAM,IAAN,CAAY,GAAZ,CAAiB,GAAjB,CAA1B,CAEP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAUP,MAAO,IAAME,kBAAiB,CAAG,CAAC,SAAD,CAAY,OAAZ,CAA1B,CAEP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAEP,MAAO,IAAME,kBAAiB,CAAG,CAC/B,SAD+B,CAE/B,cAF+B,CAG/B,cAH+B,CAI/B,OAJ+B,CAK/B,cAL+B,CAM/B,YAN+B,CAO/B,YAP+B,CAQ/B,OAR+B,CAS/B,YAT+B,CAU/B,YAV+B,CAW/B,YAX+B,CAY/B,cAZ+B,CAa/B,YAb+B,CAc/B,YAd+B,CAA1B,CAiBP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAEP,MAAO,IAAME,oBAAmB,CAAG,CAAC,OAAD,CAAU,SAAV,CAAqB,SAArB,CAA5B,CAGP,MAAO,IAAMC,mBAAkB,CAAG,CAAC,SAAD,CAAY,MAAZ,CAA3B,CAEP,MAAO,IAAMC,0BAA6C,CACxDD,kBAAkB,CAAC,CAAD,CADb"}
@@ -5,11 +5,11 @@ declare type UseChoiceGroupValues<ITEM, EVENT> = {
5
5
  getOnChange: GetOnChange<ITEM, EVENT>;
6
6
  getChecked: GetChecked<ITEM>;
7
7
  };
8
- declare type CallbackWithMultiple<ITEM, EVENT> = (props: {
8
+ export declare type CallbackWithMultiple<ITEM, EVENT> = (props: {
9
9
  e: EVENT;
10
10
  value: ITEM[] | null;
11
11
  }) => void;
12
- declare type CallbackWithoutMultiple<ITEM, EVENT> = (props: {
12
+ export declare type CallbackWithoutMultiple<ITEM, EVENT> = (props: {
13
13
  e: EVENT;
14
14
  value: ITEM;
15
15
  }) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"useChoiceGroup.js","names":["isNotNil","isMultiple","params","multiple","isNotMultiple","formatValue","valueProp","getKey","valueByKey","Array","isArray","value","length","item","useChoiceGroup","props","formatedValue","getChecked","Object","prototype","hasOwnProperty","call","getOnChange","selectedItem","e","newValue","filter","push","callBack"],"sources":["../../../../../src/hooks/useChoiceGroup/useChoiceGroup.tsx"],"sourcesContent":["import { isNotNil } from '##/utils/type-guards';\n\ntype GetKey<ITEM> = (item: ITEM) => string | number;\n\ntype GetOnChange<ITEM, EVENT> = (item: ITEM) => (e: EVENT) => void;\n\ntype GetChecked<ITEM> = (item: ITEM) => boolean;\n\ntype UseChoiceGroupValues<ITEM, EVENT> = {\n getOnChange: GetOnChange<ITEM, EVENT>;\n getChecked: GetChecked<ITEM>;\n};\n\ntype CallbackWithMultiple<ITEM, EVENT> = (props: {\n e: EVENT;\n value: ITEM[] | null;\n}) => void;\n\ntype CallbackWithoutMultiple<ITEM, EVENT> = (props: {\n e: EVENT;\n value: ITEM;\n}) => void;\n\ntype PropsWithMultiple<ITEM, EVENT> = {\n multiple: true;\n value: ITEM[] | null;\n callBack: CallbackWithMultiple<ITEM, EVENT>;\n};\n\ntype PropsWithoutMultiple<ITEM, EVENT> = {\n multiple: false;\n value: ITEM | null;\n callBack: CallbackWithoutMultiple<ITEM, EVENT>;\n};\n\ntype CommonProps<ITEM> = {\n getKey: GetKey<ITEM>;\n};\n\ntype UseChoiceGroupProps<ITEM, EVENT> = CommonProps<ITEM> &\n (PropsWithMultiple<ITEM, EVENT> | PropsWithoutMultiple<ITEM, EVENT>);\n\ntype FormatedItems<ITEM> = { [value: string]: ITEM };\n\nfunction isMultiple<ITEM, EVENT>(\n params: UseChoiceGroupProps<ITEM, EVENT>,\n): params is CommonProps<ITEM> & PropsWithMultiple<ITEM, EVENT> {\n return params.multiple;\n}\n\nfunction isNotMultiple<ITEM, EVENT>(\n params: UseChoiceGroupProps<ITEM, EVENT>,\n): params is CommonProps<ITEM> & PropsWithoutMultiple<ITEM, EVENT> {\n return !params.multiple;\n}\n\nfunction formatValue<ITEM>(\n valueProp: ITEM | ITEM[] | null,\n getKey: GetKey<ITEM>,\n multiple?: boolean,\n) {\n const valueByKey: FormatedItems<ITEM> = {};\n if (!isNotNil(valueProp) && !Array.isArray(valueProp)) {\n return valueByKey;\n }\n const value = multiple ? (valueProp as ITEM[]) : [valueProp as ITEM];\n if (value && value.length > 0) {\n for (const item of value) {\n valueByKey[getKey(item)] = item;\n }\n }\n return valueByKey;\n}\n\nexport function useChoiceGroup<ITEM, EVENT>(\n props: UseChoiceGroupProps<ITEM, EVENT>,\n): UseChoiceGroupValues<ITEM, EVENT> {\n const formatedValue = formatValue(props.value, props.getKey, props.multiple);\n\n const getChecked: GetChecked<ITEM> = (item) =>\n Object.prototype.hasOwnProperty.call(formatedValue, props.getKey(item));\n\n const getOnChange: GetOnChange<ITEM, EVENT> = (selectedItem) => (e) => {\n if (isMultiple(props)) {\n let newValue: ITEM[] | null;\n\n if (getChecked(selectedItem)) {\n const value = props.value || [];\n newValue = value.filter(\n (item) => props.getKey(item) !== props.getKey(selectedItem),\n );\n if (newValue.length === 0) {\n newValue = null;\n }\n } else {\n newValue = props.value ? [...props.value] : [];\n newValue.push(selectedItem);\n }\n props.callBack({ e, value: newValue });\n }\n\n if (isNotMultiple(props)) {\n props.callBack({ e, value: selectedItem });\n }\n };\n\n return {\n getOnChange,\n getChecked,\n };\n}\n"],"mappings":"s7CAAA,OAASA,QAAT,+BA4CA,QAASC,WAAT,CACEC,CADF,CAEgE,CAC9D,MAAOA,EAAM,CAACC,QACf,CAED,QAASC,cAAT,CACEF,CADF,CAEmE,CACjE,MAAO,CAACA,CAAM,CAACC,QAChB,CAED,QAASE,YAAT,CACEC,CADF,CAEEC,CAFF,CAGEJ,CAHF,CAIE,CACA,GAAMK,EAA+B,CAAG,EAAxC,CACA,GAAI,CAACR,QAAQ,CAACM,CAAD,CAAT,EAAwB,CAACG,KAAK,CAACC,OAAN,CAAcJ,CAAd,CAA7B,CACE,MAAOE,EAAP,CAEF,GAAMG,EAAK,CAAGR,CAAQ,CAAIG,CAAJ,CAA2B,CAACA,CAAD,CAAjD,CACA,GAAIK,CAAK,EAAmB,CAAf,CAAAA,CAAK,CAACC,MAAnB,CAA+B,oCACVD,CADU,MAC7B,2BAA0B,IAAfE,EAAe,SACxBL,CAAU,CAACD,CAAM,CAACM,CAAD,CAAP,CAAV,CAA2BA,CAC5B,CAH4B,+BAI9B,CACD,MAAOL,EACR,CAED,MAAO,SAASM,eAAT,CACLC,CADK,CAE8B,IAC7BC,EAAa,CAAGX,WAAW,CAACU,CAAK,CAACJ,KAAP,CAAcI,CAAK,CAACR,MAApB,CAA4BQ,CAAK,CAACZ,QAAlC,CADE,CAG7Bc,CAA4B,CAAG,SAACJ,CAAD,QACnCK,OAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCL,CAArC,CAAoDD,CAAK,CAACR,MAAN,CAAaM,CAAb,CAApD,CADmC,CAHF,CA8BnC,MAAO,CACLS,WAAW,CAzBiC,QAAxCA,YAAwC,CAACC,CAAD,QAAkB,UAACC,CAAD,CAAO,CACrE,GAAIvB,UAAU,CAACc,CAAD,CAAd,CAAuB,CACrB,GAAIU,EAAJ,CAEA,GAAIR,CAAU,CAACM,CAAD,CAAd,CAA8B,CAC5B,GAAMZ,EAAK,CAAGI,CAAK,CAACJ,KAAN,EAAe,EAA7B,CACAc,CAAQ,CAAGd,CAAK,CAACe,MAAN,CACT,SAACb,CAAD,QAAUE,EAAK,CAACR,MAAN,CAAaM,CAAb,IAAuBE,CAAK,CAACR,MAAN,CAAagB,CAAb,CAAjC,CADS,CAFiB,CAKJ,CAApB,GAAAE,CAAQ,CAACb,MALe,GAM1Ba,CAAQ,CAAG,IANe,CAQ7B,CARD,IASEA,EAAQ,CAAGV,CAAK,CAACJ,KAAN,oBAAkBI,CAAK,CAACJ,KAAxB,EAAiC,EAT9C,CAUEc,CAAQ,CAACE,IAAT,CAAcJ,CAAd,CAVF,CAYAR,CAAK,CAACa,QAAN,CAAe,CAAEJ,CAAC,CAADA,CAAF,CAAKb,KAAK,CAAEc,CAAZ,CAAf,CACD,CAEGrB,aAAa,CAACW,CAAD,CAnBoD,EAoBnEA,CAAK,CAACa,QAAN,CAAe,CAAEJ,CAAC,CAADA,CAAF,CAAKb,KAAK,CAAEY,CAAZ,CAAf,CAEH,CAtB6C,CAwBvC,CAELN,UAAU,CAAVA,CAFK,CAIR"}
1
+ {"version":3,"file":"useChoiceGroup.js","names":["isNotNil","isMultiple","params","multiple","isNotMultiple","formatValue","valueProp","getKey","valueByKey","Array","isArray","value","length","item","useChoiceGroup","props","formatedValue","getChecked","Object","prototype","hasOwnProperty","call","getOnChange","selectedItem","e","newValue","filter","push","callBack"],"sources":["../../../../../src/hooks/useChoiceGroup/useChoiceGroup.tsx"],"sourcesContent":["import { isNotNil } from '##/utils/type-guards';\n\ntype GetKey<ITEM> = (item: ITEM) => string | number;\n\ntype GetOnChange<ITEM, EVENT> = (item: ITEM) => (e: EVENT) => void;\n\ntype GetChecked<ITEM> = (item: ITEM) => boolean;\n\ntype UseChoiceGroupValues<ITEM, EVENT> = {\n getOnChange: GetOnChange<ITEM, EVENT>;\n getChecked: GetChecked<ITEM>;\n};\n\nexport type CallbackWithMultiple<ITEM, EVENT> = (props: {\n e: EVENT;\n value: ITEM[] | null;\n}) => void;\n\nexport type CallbackWithoutMultiple<ITEM, EVENT> = (props: {\n e: EVENT;\n value: ITEM;\n}) => void;\n\ntype PropsWithMultiple<ITEM, EVENT> = {\n multiple: true;\n value: ITEM[] | null;\n callBack: CallbackWithMultiple<ITEM, EVENT>;\n};\n\ntype PropsWithoutMultiple<ITEM, EVENT> = {\n multiple: false;\n value: ITEM | null;\n callBack: CallbackWithoutMultiple<ITEM, EVENT>;\n};\n\ntype CommonProps<ITEM> = {\n getKey: GetKey<ITEM>;\n};\n\ntype UseChoiceGroupProps<ITEM, EVENT> = CommonProps<ITEM> &\n (PropsWithMultiple<ITEM, EVENT> | PropsWithoutMultiple<ITEM, EVENT>);\n\ntype FormatedItems<ITEM> = { [value: string]: ITEM };\n\nfunction isMultiple<ITEM, EVENT>(\n params: UseChoiceGroupProps<ITEM, EVENT>,\n): params is CommonProps<ITEM> & PropsWithMultiple<ITEM, EVENT> {\n return params.multiple;\n}\n\nfunction isNotMultiple<ITEM, EVENT>(\n params: UseChoiceGroupProps<ITEM, EVENT>,\n): params is CommonProps<ITEM> & PropsWithoutMultiple<ITEM, EVENT> {\n return !params.multiple;\n}\n\nfunction formatValue<ITEM>(\n valueProp: ITEM | ITEM[] | null,\n getKey: GetKey<ITEM>,\n multiple?: boolean,\n) {\n const valueByKey: FormatedItems<ITEM> = {};\n if (!isNotNil(valueProp) && !Array.isArray(valueProp)) {\n return valueByKey;\n }\n const value = multiple ? (valueProp as ITEM[]) : [valueProp as ITEM];\n if (value && value.length > 0) {\n for (const item of value) {\n valueByKey[getKey(item)] = item;\n }\n }\n return valueByKey;\n}\n\nexport function useChoiceGroup<ITEM, EVENT>(\n props: UseChoiceGroupProps<ITEM, EVENT>,\n): UseChoiceGroupValues<ITEM, EVENT> {\n const formatedValue = formatValue(props.value, props.getKey, props.multiple);\n\n const getChecked: GetChecked<ITEM> = (item) =>\n Object.prototype.hasOwnProperty.call(formatedValue, props.getKey(item));\n\n const getOnChange: GetOnChange<ITEM, EVENT> = (selectedItem) => (e) => {\n if (isMultiple(props)) {\n let newValue: ITEM[] | null;\n\n if (getChecked(selectedItem)) {\n const value = props.value || [];\n newValue = value.filter(\n (item) => props.getKey(item) !== props.getKey(selectedItem),\n );\n if (newValue.length === 0) {\n newValue = null;\n }\n } else {\n newValue = props.value ? [...props.value] : [];\n newValue.push(selectedItem);\n }\n props.callBack({ e, value: newValue });\n }\n\n if (isNotMultiple(props)) {\n props.callBack({ e, value: selectedItem });\n }\n };\n\n return {\n getOnChange,\n getChecked,\n };\n}\n"],"mappings":"s7CAAA,OAASA,QAAT,+BA4CA,QAASC,WAAT,CACEC,CADF,CAEgE,CAC9D,MAAOA,EAAM,CAACC,QACf,CAED,QAASC,cAAT,CACEF,CADF,CAEmE,CACjE,MAAO,CAACA,CAAM,CAACC,QAChB,CAED,QAASE,YAAT,CACEC,CADF,CAEEC,CAFF,CAGEJ,CAHF,CAIE,CACA,GAAMK,EAA+B,CAAG,EAAxC,CACA,GAAI,CAACR,QAAQ,CAACM,CAAD,CAAT,EAAwB,CAACG,KAAK,CAACC,OAAN,CAAcJ,CAAd,CAA7B,CACE,MAAOE,EAAP,CAEF,GAAMG,EAAK,CAAGR,CAAQ,CAAIG,CAAJ,CAA2B,CAACA,CAAD,CAAjD,CACA,GAAIK,CAAK,EAAmB,CAAf,CAAAA,CAAK,CAACC,MAAnB,CAA+B,oCACVD,CADU,MAC7B,2BAA0B,IAAfE,EAAe,SACxBL,CAAU,CAACD,CAAM,CAACM,CAAD,CAAP,CAAV,CAA2BA,CAC5B,CAH4B,+BAI9B,CACD,MAAOL,EACR,CAED,MAAO,SAASM,eAAT,CACLC,CADK,CAE8B,IAC7BC,EAAa,CAAGX,WAAW,CAACU,CAAK,CAACJ,KAAP,CAAcI,CAAK,CAACR,MAApB,CAA4BQ,CAAK,CAACZ,QAAlC,CADE,CAG7Bc,CAA4B,CAAG,SAACJ,CAAD,QACnCK,OAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCL,CAArC,CAAoDD,CAAK,CAACR,MAAN,CAAaM,CAAb,CAApD,CADmC,CAHF,CA8BnC,MAAO,CACLS,WAAW,CAzBiC,QAAxCA,YAAwC,CAACC,CAAD,QAAkB,UAACC,CAAD,CAAO,CACrE,GAAIvB,UAAU,CAACc,CAAD,CAAd,CAAuB,CACrB,GAAIU,EAAJ,CAEA,GAAIR,CAAU,CAACM,CAAD,CAAd,CAA8B,CAC5B,GAAMZ,EAAK,CAAGI,CAAK,CAACJ,KAAN,EAAe,EAA7B,CACAc,CAAQ,CAAGd,CAAK,CAACe,MAAN,CACT,SAACb,CAAD,QAAUE,EAAK,CAACR,MAAN,CAAaM,CAAb,IAAuBE,CAAK,CAACR,MAAN,CAAagB,CAAb,CAAjC,CADS,CAFiB,CAKJ,CAApB,GAAAE,CAAQ,CAACb,MALe,GAM1Ba,CAAQ,CAAG,IANe,CAQ7B,CARD,IASEA,EAAQ,CAAGV,CAAK,CAACJ,KAAN,oBAAkBI,CAAK,CAACJ,KAAxB,EAAiC,EAT9C,CAUEc,CAAQ,CAACE,IAAT,CAAcJ,CAAd,CAVF,CAYAR,CAAK,CAACa,QAAN,CAAe,CAAEJ,CAAC,CAADA,CAAF,CAAKb,KAAK,CAAEc,CAAZ,CAAf,CACD,CAEGrB,aAAa,CAACW,CAAD,CAnBoD,EAoBnEA,CAAK,CAACa,QAAN,CAAe,CAAEJ,CAAC,CAADA,CAAF,CAAKb,KAAK,CAAEY,CAAZ,CAAf,CAEH,CAtB6C,CAwBvC,CAELN,UAAU,CAAVA,CAFK,CAIR"}
@@ -1,4 +1,4 @@
1
- import { KeyCode } from '../../utils/types/KeyCode';
1
+ import { KeyCode } from "../../utils/types/KeyCode";
2
2
  export declare type KeyHandlers = Partial<Record<KeyCode, (e: KeyboardEvent) => void>> & {
3
3
  [key: string]: (e: KeyboardEvent) => void;
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useGlobalKeys.js","names":["useEffect","useRef","useGlobalKeys","keyHandlers","eventType","keyHandlersRef","current","handler","e","userHandler","code","key","document","addEventListener","removeEventListener"],"sources":["../../../../../src/hooks/useGlobalKeys/useGlobalKeys.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nimport { KeyCode } from '../../utils/types/KeyCode';\n\nexport type KeyHandlers = Partial<\n Record<KeyCode, (e: KeyboardEvent) => void>\n> & {\n [key: string]: (e: KeyboardEvent) => void;\n};\n\nexport type EventType = 'keyup' | 'keydown';\n\nexport const useGlobalKeys = (\n keyHandlers: KeyHandlers,\n eventType: EventType = 'keyup',\n) => {\n const keyHandlersRef = useRef<KeyHandlers>({});\n\n useEffect(() => {\n keyHandlersRef.current = keyHandlers;\n }, [keyHandlers]);\n\n useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n const { current } = keyHandlersRef;\n\n const userHandler =\n current[e.code as KeyCode] || current[e.key as KeyCode];\n userHandler && userHandler(e);\n };\n\n document.addEventListener(eventType, handler);\n\n return () => {\n document.removeEventListener(eventType, handler);\n };\n }, [eventType]);\n};\n"],"mappings":"AAAA,OAASA,SAAT,CAAoBC,MAApB,KAAkC,OAAlC,CAYA,MAAO,IAAMC,cAAa,CAAG,SAC3BC,CAD2B,CAGxB,IADHC,EACG,wDADoB,OACpB,CACGC,CAAc,CAAGJ,MAAM,CAAc,EAAd,CAD1B,CAGHD,SAAS,CAAC,UAAM,CACdK,CAAc,CAACC,OAAf,CAAyBH,CAC1B,CAFQ,CAEN,CAACA,CAAD,CAFM,CAHN,CAOHH,SAAS,CAAC,UAAM,CACd,GAAMO,EAAO,CAAG,SAACC,CAAD,CAAsB,IAC5BF,EAD4B,CAChBD,CADgB,CAC5BC,OAD4B,CAG9BG,CAAW,CACfH,CAAO,CAACE,CAAC,CAACE,IAAH,CAAP,EAA8BJ,CAAO,CAACE,CAAC,CAACG,GAAH,CAJH,CAKpCF,CAAW,EAAIA,CAAW,CAACD,CAAD,CAC3B,CAND,CAUA,MAFAI,SAAQ,CAACC,gBAAT,CAA0BT,CAA1B,CAAqCG,CAArC,CAEA,CAAO,UAAM,CACXK,QAAQ,CAACE,mBAAT,CAA6BV,CAA7B,CAAwCG,CAAxC,CACD,CACF,CAdQ,CAcN,CAACH,CAAD,CAdM,CAeV,CAzBM"}
1
+ {"version":3,"file":"useGlobalKeys.js","names":["useEffect","useRef","useGlobalKeys","keyHandlers","eventType","keyHandlersRef","current","handler","e","userHandler","code","key","document","addEventListener","removeEventListener"],"sources":["../../../../../src/hooks/useGlobalKeys/useGlobalKeys.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nimport { KeyCode } from '##/utils/types/KeyCode';\n\nexport type KeyHandlers = Partial<\n Record<KeyCode, (e: KeyboardEvent) => void>\n> & {\n [key: string]: (e: KeyboardEvent) => void;\n};\n\nexport type EventType = 'keyup' | 'keydown';\n\nexport const useGlobalKeys = (\n keyHandlers: KeyHandlers,\n eventType: EventType = 'keyup',\n) => {\n const keyHandlersRef = useRef<KeyHandlers>({});\n\n useEffect(() => {\n keyHandlersRef.current = keyHandlers;\n }, [keyHandlers]);\n\n useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n const { current } = keyHandlersRef;\n\n const userHandler =\n current[e.code as KeyCode] || current[e.key as KeyCode];\n userHandler && userHandler(e);\n };\n\n document.addEventListener(eventType, handler);\n\n return () => {\n document.removeEventListener(eventType, handler);\n };\n }, [eventType]);\n};\n"],"mappings":"AAAA,OAASA,SAAT,CAAoBC,MAApB,KAAkC,OAAlC,CAYA,MAAO,IAAMC,cAAa,CAAG,SAC3BC,CAD2B,CAGxB,IADHC,EACG,wDADoB,OACpB,CACGC,CAAc,CAAGJ,MAAM,CAAc,EAAd,CAD1B,CAGHD,SAAS,CAAC,UAAM,CACdK,CAAc,CAACC,OAAf,CAAyBH,CAC1B,CAFQ,CAEN,CAACA,CAAD,CAFM,CAHN,CAOHH,SAAS,CAAC,UAAM,CACd,GAAMO,EAAO,CAAG,SAACC,CAAD,CAAsB,IAC5BF,EAD4B,CAChBD,CADgB,CAC5BC,OAD4B,CAG9BG,CAAW,CACfH,CAAO,CAACE,CAAC,CAACE,IAAH,CAAP,EAA8BJ,CAAO,CAACE,CAAC,CAACG,GAAH,CAJH,CAKpCF,CAAW,EAAIA,CAAW,CAACD,CAAD,CAC3B,CAND,CAUA,MAFAI,SAAQ,CAACC,gBAAT,CAA0BT,CAA1B,CAAqCG,CAArC,CAEA,CAAO,UAAM,CACXK,QAAQ,CAACE,mBAAT,CAA6BV,CAA7B,CAAwCG,CAAxC,CACD,CACF,CAdQ,CAcN,CAACH,CAAD,CAdM,CAeV,CAzBM"}
@@ -0,0 +1 @@
1
+ export * from './useKeysCanary';
@@ -0,0 +1,2 @@
1
+ export*from"./useKeysCanary";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/hooks/useKeysCanary/index.ts"],"sourcesContent":["export * from './useKeysCanary';\n"],"mappings":"AAAA"}
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { KeyCode } from "../../utils/types/KeyCode";
3
+ declare type KeyHandlers = Partial<Record<KeyCode, React.KeyboardEventHandler>> & {
4
+ [key: string]: React.KeyboardEventHandler;
5
+ };
6
+ declare type UseKeysProps = {
7
+ keys: KeyHandlers;
8
+ onEvent?: React.KeyboardEventHandler;
9
+ isActive: boolean;
10
+ };
11
+ export declare const useKeys: (props: UseKeysProps) => React.KeyboardEventHandler;
12
+ export {};
@@ -0,0 +1,2 @@
1
+ import{useCallback}from"react";import{useMutableRef}from"../useMutableRef";export var useKeys=function(a){var b=useMutableRef(a);return useCallback(function(a){var c=b.current,d=c.isActive,e=c.keys,f=c.onEvent;if(d){var g;null===(g=e[a.code]||e[a.key])||void 0===g?void 0:g(a)}null===f||void 0===f?void 0:f(a)},[])};
2
+ //# sourceMappingURL=useKeysCanary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeysCanary.js","names":["useCallback","useMutableRef","useKeys","props","propsRef","e","current","isActive","keys","onEvent","code","key"],"sources":["../../../../../src/hooks/useKeysCanary/useKeysCanary.ts"],"sourcesContent":["import { useCallback } from 'react';\n\nimport { useMutableRef } from '##/hooks/useMutableRef';\nimport { KeyCode } from '##/utils/types/KeyCode';\n\ntype KeyHandlers = Partial<Record<KeyCode, React.KeyboardEventHandler>> & {\n [key: string]: React.KeyboardEventHandler;\n};\n\ntype UseKeysProps = {\n keys: KeyHandlers;\n onEvent?: React.KeyboardEventHandler;\n isActive: boolean;\n};\n\nexport const useKeys = (props: UseKeysProps): React.KeyboardEventHandler => {\n const propsRef = useMutableRef(props);\n return useCallback((e) => {\n const { isActive, keys, onEvent } = propsRef.current;\n if (isActive) {\n (keys[e.code as KeyCode] || keys[e.key as KeyCode])?.(e);\n }\n onEvent?.(e);\n }, []);\n};\n"],"mappings":"AAAA,OAASA,WAAT,KAA4B,OAA5B,CAEA,OAASC,aAAT,wBAaA,MAAO,IAAMC,QAAO,CAAG,SAACC,CAAD,CAAqD,CAC1E,GAAMC,EAAQ,CAAGH,aAAa,CAACE,CAAD,CAA9B,CACA,MAAOH,YAAW,CAAC,SAACK,CAAD,CAAO,CACxB,MAAoCD,CAAQ,CAACE,OAA7C,CAAQC,CAAR,GAAQA,QAAR,CAAkBC,CAAlB,GAAkBA,IAAlB,CAAwBC,CAAxB,GAAwBA,OAAxB,CACA,GAAIF,CAAJ,CAAc,iBACXC,CAAI,CAACH,CAAC,CAACK,IAAH,CAAJ,EAA2BF,CAAI,CAACH,CAAC,CAACM,GAAH,CADpB,qBACZ,EAAsDN,CAAtD,CACD,CAJuB,OAKxBI,CALwB,WAKxBA,CALwB,QAKxBA,CAAO,CAAGJ,CAAH,CACR,CANiB,CAMf,EANe,CAOnB,CATM"}
@@ -5,8 +5,9 @@ export declare type KeyHandlers = Partial<Record<KeyCode, (e: KeyboardEvent) =>
5
5
  };
6
6
  declare type UseKeysProps = {
7
7
  ref?: React.RefObject<HTMLElement>;
8
- keys?: KeyHandlers;
8
+ keys: KeyHandlers;
9
9
  isActive?: boolean;
10
+ eventHandler?: (event: KeyboardEvent) => void;
10
11
  eventType?: 'keypress' | 'keydown' | 'keyup';
11
12
  };
12
13
  export declare const useKeysRef: (params: UseKeysProps) => void;
@@ -1,2 +1,2 @@
1
- import{useCallback,useEffect}from"react";var getKeyHandler=function(a){return function(b){var c;null===(c=a[b.code]||a[b.key])||void 0===c?void 0:c(b)}};export var useKeysRef=function(a){var b=a.ref,c=a.keys,d=a.isActive,f=!(void 0!==d)||d,g=a.eventType,h=void 0===g?"keydown":g,i=useCallback(function(a){if(c&&f){getKeyHandler(c)(a)}},[c,f]);useEffect(function(){var a;return null===b||void 0===b||null===(a=b.current)||void 0===a?void 0:a.addEventListener(h,i),function(){var a;null===b||void 0===b||null===(a=b.current)||void 0===a?void 0:a.removeEventListener(h,i)}},[b,c,f,h])};
1
+ import{useEffect}from"react";import{useMutableRef}from"../useMutableRef";export var useKeysRef=function(a){var b=a.ref,c=a.keys,d=a.isActive,e=a.eventType,f=void 0===e?"keydown":e,g=useMutableRef(function(a){if(void 0!==d&&d){var b;null===(b=c[a.code]||c[a.key])||void 0===b?void 0:b(a)}});useEffect(function(){var a;return null===b||void 0===b||null===(a=b.current)||void 0===a?void 0:a.addEventListener(f,g.current),function(){var a;null===b||void 0===b||null===(a=b.current)||void 0===a?void 0:a.removeEventListener(f,g.current)}},[null===b||void 0===b?void 0:b.current,f])};
2
2
  //# sourceMappingURL=useKeysRef.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useKeysRef.js","names":["useCallback","useEffect","getKeyHandler","keys","e","code","key","useKeysRef","params","ref","isActive","eventType","onKeyDown","current","addEventListener","removeEventListener"],"sources":["../../../../../src/hooks/useKeysRef/useKeysRef.ts"],"sourcesContent":["import React, { useCallback, useEffect } from 'react';\n\nimport { KeyCode } from '##/utils/types/KeyCode';\n\nexport type KeyHandlers = Partial<\n Record<KeyCode, (e: KeyboardEvent) => void>\n> & {\n [key: string]: (e: KeyboardEvent) => void;\n};\n\ntype UseKeysProps = {\n ref?: React.RefObject<HTMLElement>;\n keys?: KeyHandlers;\n isActive?: boolean;\n eventType?: 'keypress' | 'keydown' | 'keyup';\n};\n\nconst getKeyHandler = (keys: KeyHandlers) => {\n return (e: KeyboardEvent) => {\n (keys[e.code as KeyCode] || keys[e.key as KeyCode])?.(e);\n };\n};\n\nexport const useKeysRef = (params: UseKeysProps) => {\n const { ref, keys, isActive = true, eventType = 'keydown' } = params;\n\n const onKeyDown = useCallback(\n (e: Event) => {\n if (keys && isActive) {\n const event = e as unknown as KeyboardEvent;\n getKeyHandler(keys)(event);\n }\n },\n [keys, isActive],\n );\n\n useEffect(() => {\n ref?.current?.addEventListener(eventType, onKeyDown);\n\n return () => {\n ref?.current?.removeEventListener(eventType, onKeyDown);\n };\n }, [ref, keys, isActive, eventType]);\n};\n"],"mappings":"AAAA,OAAgBA,WAAhB,CAA6BC,SAA7B,KAA8C,OAA9C,CAiBA,GAAMC,cAAa,CAAG,SAACC,CAAD,CAAuB,CAC3C,MAAO,UAACC,CAAD,CAAsB,iBAC1BD,CAAI,CAACC,CAAC,CAACC,IAAH,CAAJ,EAA2BF,CAAI,CAACC,CAAC,CAACE,GAAH,CADL,qBAC3B,EAAsDF,CAAtD,CACD,CACF,CAJD,CAMA,MAAO,IAAMG,WAAU,CAAG,SAACC,CAAD,CAA0B,IAC1CC,EAD0C,CACYD,CADZ,CAC1CC,GAD0C,CACrCN,CADqC,CACYK,CADZ,CACrCL,IADqC,GACYK,CADZ,CAC/BE,QAD+B,CAC/BA,CAD+B,oBACYF,CADZ,CACdG,SADc,CACdA,CADc,YACF,SADE,GAG5CC,CAAS,CAAGZ,WAAW,CAC3B,SAACI,CAAD,CAAc,CACZ,GAAID,CAAI,EAAIO,CAAZ,CAAsB,CAEpBR,aAAa,CAACC,CAAD,CAAb,CADcC,CACd,CACD,CACF,CAN0B,CAO3B,CAACD,CAAD,CAAOO,CAAP,CAP2B,CAHqB,CAalDT,SAAS,CAAC,UAAM,OAGd,cAFAQ,CAEA,WAFAA,CAEA,YAFAA,CAAG,CAAEI,OAEL,qBAFA,EAAcC,gBAAd,CAA+BH,CAA/B,CAA0CC,CAA1C,CAEA,CAAO,UAAM,cACXH,CADW,WACXA,CADW,YACXA,CAAG,CAAEI,OADM,qBACX,EAAcE,mBAAd,CAAkCJ,CAAlC,CAA6CC,CAA7C,CACD,CACF,CANQ,CAMN,CAACH,CAAD,CAAMN,CAAN,CAAYO,CAAZ,CAAsBC,CAAtB,CANM,CAOV,CApBM"}
1
+ {"version":3,"file":"useKeysRef.js","names":["useEffect","useMutableRef","useKeysRef","params","ref","keys","isActive","eventType","fn","e","code","key","current","addEventListener","removeEventListener"],"sources":["../../../../../src/hooks/useKeysRef/useKeysRef.ts"],"sourcesContent":["import React, { useEffect } from 'react';\n\nimport { useMutableRef } from '##/hooks/useMutableRef';\nimport { KeyCode } from '##/utils/types/KeyCode';\n\nexport type KeyHandlers = Partial<\n Record<KeyCode, (e: KeyboardEvent) => void>\n> & {\n [key: string]: (e: KeyboardEvent) => void;\n};\n\ntype UseKeysProps = {\n ref?: React.RefObject<HTMLElement>;\n keys: KeyHandlers;\n isActive?: boolean;\n eventHandler?: (event: KeyboardEvent) => void;\n eventType?: 'keypress' | 'keydown' | 'keyup';\n};\n\nexport const useKeysRef = (params: UseKeysProps) => {\n const { ref, keys, isActive = false, eventType = 'keydown' } = params;\n\n const fn = useMutableRef((e: KeyboardEvent) => {\n if (isActive) {\n (keys[e.code as KeyCode] || keys[e.key as KeyCode])?.(e);\n }\n });\n\n useEffect(() => {\n ref?.current?.addEventListener(eventType, fn.current);\n\n return () => {\n ref?.current?.removeEventListener(eventType, fn.current);\n };\n }, [ref?.current, eventType]);\n};\n"],"mappings":"AAAA,OAAgBA,SAAhB,KAAiC,OAAjC,CAEA,OAASC,aAAT,wBAiBA,MAAO,IAAMC,WAAU,CAAG,SAACC,CAAD,CAA0B,IAC1CC,EAD0C,CACaD,CADb,CAC1CC,GAD0C,CACrCC,CADqC,CACaF,CADb,CACrCE,IADqC,GACaF,CADb,CAC/BG,QAD+B,GACaH,CADb,CACbI,SADa,CACbA,CADa,YACD,SADC,GAG5CC,CAAE,CAAGP,aAAa,CAAC,SAACQ,CAAD,CAAsB,CAC7C,iBAAc,iBACXJ,CAAI,CAACI,CAAC,CAACC,IAAH,CAAJ,EAA2BL,CAAI,CAACI,CAAC,CAACE,GAAH,CADpB,qBACZ,EAAsDF,CAAtD,CACD,CACF,CAJuB,CAH0B,CASlDT,SAAS,CAAC,UAAM,OAGd,cAFAI,CAEA,WAFAA,CAEA,YAFAA,CAAG,CAAEQ,OAEL,qBAFA,EAAcC,gBAAd,CAA+BN,CAA/B,CAA0CC,CAAE,CAACI,OAA7C,CAEA,CAAO,UAAM,cACXR,CADW,WACXA,CADW,YACXA,CAAG,CAAEQ,OADM,qBACX,EAAcE,mBAAd,CAAkCP,CAAlC,CAA6CC,CAAE,CAACI,OAAhD,CACD,CACF,CANQ,CAMN,QAACR,CAAD,WAACA,CAAD,QAACA,CAAG,CAAEQ,OAAN,CAAeL,CAAf,CANM,CAOV,CAhBM"}
@@ -0,0 +1 @@
1
+ export declare const useDefaultGetter: (name: string, value?: boolean, isActive?: boolean) => (() => undefined) | undefined;
@@ -0,0 +1,2 @@
1
+ import{useBoolean}from"@consta/stand";var getUndefined=function(){};export var useDefaultGetter=function(a,b,c){return useBoolean(a,b,c)?void 0:getUndefined};
2
+ //# sourceMappingURL=stand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stand.js","names":["useBoolean","getUndefined","useDefaultGetter","name","value","isActive"],"sources":["../../../../src/utils/stand.ts"],"sourcesContent":["import { useBoolean } from '@consta/stand';\n\nconst getUndefined = () => undefined;\n\nexport const useDefaultGetter = (\n name: string,\n value?: boolean,\n isActive?: boolean,\n) => (useBoolean(name, value, isActive) ? undefined : getUndefined);\n"],"mappings":"AAAA,OAASA,UAAT,KAA2B,eAA3B,CAEA,GAAMC,aAAY,CAAG,YAArB,CAEA,MAAO,IAAMC,iBAAgB,CAAG,SAC9BC,CAD8B,CAE9BC,CAF8B,CAG9BC,CAH8B,QAI1BL,WAAU,CAACG,CAAD,CAAOC,CAAP,CAAcC,CAAd,CAAV,QAAgDJ,YAJtB,CAAzB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@consta/uikit",
3
- "version": "4.27.0",
3
+ "version": "4.28.0",
4
4
  "keywords": [
5
5
  "ui-kit",
6
6
  "design-system",
@@ -0,0 +1 @@
1
+ export * from "../__internal__/src/hooks/useKeysCanary";
@@ -0,0 +1 @@
1
+ export * from "../__internal__/src/hooks/useKeysCanary";