@gravity-ui/blog-constructor 6.4.3 → 6.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,8 @@ type RenderSwitcherType = ({ initial, list, defaultLabel, }: {
6
6
  list: CustomSwitcherProps['list'];
7
7
  defaultLabel: string;
8
8
  }) => SelectProps['renderControl'];
9
+ type RenderFilterType = SelectProps['renderFilter'];
9
10
  export declare const renderSwitcher: RenderSwitcherType;
10
- export declare const renderFilter: SelectProps['renderFilter'];
11
+ export declare const renderFilter: RenderFilterType;
11
12
  export declare const renderOption: (option: SelectOption) => React.JSX.Element;
12
13
  export {};
@@ -11,9 +11,15 @@ const CustomSwitcher_1 = require("../CustomSwitcher/CustomSwitcher");
11
11
  const b = (0, cn_1.block)('feed-controls');
12
12
  const renderSwitcher = ({ initial, list, defaultLabel }) =>
13
13
  // eslint-disable-next-line react/display-name
14
- ({ onClick, ref, onKeyDown, open, renderClear, popupId, activeIndex }) => (react_1.default.createElement(CustomSwitcher_1.CustomSwitcher, { initial: initial, defaultLabel: defaultLabel, list: list, controlRef: ref, onClick: onClick, onKeyDown: onKeyDown, renderClear: renderClear, open: open, popupId: popupId, activeIndex: activeIndex }));
14
+ (_a) => {
15
+ var { ref, renderClear } = _a, _b = _a.triggerProps, { id, disabled, type, onClick, onKeyDown } = _b, a11yProps = tslib_1.__rest(_b, ["id", "disabled", "type", "onClick", "onKeyDown"]);
16
+ return (react_1.default.createElement(CustomSwitcher_1.CustomSwitcher, { id: id, disabled: disabled, type: type, initial: initial, defaultLabel: defaultLabel, list: list, controlRef: ref, onClick: onClick, onKeyDown: onKeyDown, renderClear: renderClear, a11yProps: a11yProps }));
17
+ };
15
18
  exports.renderSwitcher = renderSwitcher;
16
- const renderFilter = ({ value, onChange, onKeyDown }) => (react_1.default.createElement(uikit_1.TextInput, { controlProps: { size: 1 }, value: value, view: "clear", placeholder: (0, i18n_1.i18n)(i18n_1.Keyset.Search), onUpdate: onChange, onKeyDown: onKeyDown, className: b('popup-filter') }));
19
+ const renderFilter = (_a) => {
20
+ var { ref, onChange } = _a, _b = _a.inputProps, { value, onKeyDown, onChange: _, size: __, placeholder: ___ } = _b, a11yProps = tslib_1.__rest(_b, ["value", "onKeyDown", "onChange", "size", "placeholder"]);
21
+ return (react_1.default.createElement(uikit_1.TextInput, { value: value, view: "clear", placeholder: (0, i18n_1.i18n)(i18n_1.Keyset.Search), onUpdate: onChange, onKeyDown: onKeyDown, className: b('popup-filter'), controlRef: ref, controlProps: Object.assign({ size: 1 }, a11yProps) }));
22
+ };
17
23
  exports.renderFilter = renderFilter;
18
24
  const renderOption = (option) => (react_1.default.createElement(CustomSelectOption_1.CustomSelectOption, { data: option }));
19
25
  exports.renderOption = renderOption;
@@ -2,11 +2,17 @@ import React from 'react';
2
2
  import { SelectProps } from '@gravity-ui/uikit';
3
3
  import { SelectItem } from '../Controls/Controls';
4
4
  type RenderControlParameters = Partial<Parameters<Required<SelectProps>['renderControl']>[0]>;
5
+ type TriggerProps = Required<RenderControlParameters>['triggerProps'];
6
+ type A11yKeys = {
7
+ [K in keyof TriggerProps]-?: K extends `aria-${string}` | 'role' ? K : never;
8
+ }[keyof TriggerProps];
9
+ type RenderControlA11yProps = Pick<TriggerProps, A11yKeys>;
5
10
  export type CustomSwitcherProps = {
6
11
  initial: (string | number | null)[];
7
12
  defaultLabel: string;
8
13
  list: SelectItem[];
9
14
  controlRef: RenderControlParameters['ref'];
10
- } & Omit<RenderControlParameters, 'ref'>;
11
- export declare const CustomSwitcher: ({ initial, defaultLabel, list, onClick, controlRef, onKeyDown, open, renderClear, popupId, activeIndex, }: CustomSwitcherProps) => React.JSX.Element;
15
+ a11yProps: RenderControlA11yProps;
16
+ } & Omit<RenderControlParameters, 'ref'> & Pick<TriggerProps, 'id' | 'disabled' | 'type'>;
17
+ export declare const CustomSwitcher: ({ id, disabled, type, initial, defaultLabel, list, onClick, controlRef, onKeyDown, renderClear, a11yProps, }: CustomSwitcherProps) => React.JSX.Element;
12
18
  export {};
@@ -10,7 +10,7 @@ const cn_1 = require("../../../../utils/cn");
10
10
  const b = (0, cn_1.block)('feed-custom-switcher');
11
11
  const ICON_SIZE = 12;
12
12
  const CLEAR_ICON_SIZE = 11;
13
- const CustomSwitcher = ({ initial, defaultLabel, list, onClick, controlRef, onKeyDown, open, renderClear, popupId, activeIndex, }) => {
13
+ const CustomSwitcher = ({ id, disabled, type, initial, defaultLabel, list, onClick, controlRef, onKeyDown, renderClear, a11yProps, }) => {
14
14
  const itemsNames = (0, react_1.useMemo)(() => {
15
15
  const items = list
16
16
  .filter((item) => initial.includes(item.value))
@@ -20,7 +20,7 @@ const CustomSwitcher = ({ initial, defaultLabel, list, onClick, controlRef, onKe
20
20
  const hasCounter = itemsNames.length > 1;
21
21
  const contentElementId = (0, uikit_1.useUniqId)();
22
22
  return (react_1.default.createElement("div", { className: b('custom-switcher'), ref: controlRef },
23
- react_1.default.createElement("button", { onClick: onClick, className: b('custom-switcher-element', { overlay: true }), onKeyDown: onKeyDown, "aria-expanded": open, "aria-labelledby": contentElementId, "aria-activedescendant": activeIndex === undefined ? undefined : `${popupId}-item-${activeIndex}` }),
23
+ react_1.default.createElement("button", Object.assign({ id: id, disabled: disabled, type: type, onClick: onClick, className: b('custom-switcher-element', { overlay: true }), onKeyDown: onKeyDown }, a11yProps, { "aria-labelledby": contentElementId })),
24
24
  react_1.default.createElement("div", { id: contentElementId, className: b('custom-switcher-element', { content: true }), "aria-hidden": true }, itemsNames === null || itemsNames === void 0 ? void 0 : itemsNames.join(', ')),
25
25
  renderClear &&
26
26
  renderClear({
@@ -7,7 +7,8 @@ type RenderSwitcherType = ({ initial, list, defaultLabel, }: {
7
7
  list: CustomSwitcherProps['list'];
8
8
  defaultLabel: string;
9
9
  }) => SelectProps['renderControl'];
10
+ type RenderFilterType = SelectProps['renderFilter'];
10
11
  export declare const renderSwitcher: RenderSwitcherType;
11
- export declare const renderFilter: SelectProps['renderFilter'];
12
+ export declare const renderFilter: RenderFilterType;
12
13
  export declare const renderOption: (option: SelectOption) => React.JSX.Element;
13
14
  export {};
@@ -1,3 +1,4 @@
1
+ import { __rest } from "tslib";
1
2
  import React from 'react';
2
3
  import { TextInput } from '@gravity-ui/uikit';
3
4
  import { Keyset, i18n } from '../../../../i18n';
@@ -8,6 +9,12 @@ import './Controls.css';
8
9
  const b = block('feed-controls');
9
10
  export const renderSwitcher = ({ initial, list, defaultLabel }) =>
10
11
  // eslint-disable-next-line react/display-name
11
- ({ onClick, ref, onKeyDown, open, renderClear, popupId, activeIndex }) => (React.createElement(CustomSwitcher, { initial: initial, defaultLabel: defaultLabel, list: list, controlRef: ref, onClick: onClick, onKeyDown: onKeyDown, renderClear: renderClear, open: open, popupId: popupId, activeIndex: activeIndex }));
12
- export const renderFilter = ({ value, onChange, onKeyDown }) => (React.createElement(TextInput, { controlProps: { size: 1 }, value: value, view: "clear", placeholder: i18n(Keyset.Search), onUpdate: onChange, onKeyDown: onKeyDown, className: b('popup-filter') }));
12
+ (_a) => {
13
+ var { ref, renderClear } = _a, _b = _a.triggerProps, { id, disabled, type, onClick, onKeyDown } = _b, a11yProps = __rest(_b, ["id", "disabled", "type", "onClick", "onKeyDown"]);
14
+ return (React.createElement(CustomSwitcher, { id: id, disabled: disabled, type: type, initial: initial, defaultLabel: defaultLabel, list: list, controlRef: ref, onClick: onClick, onKeyDown: onKeyDown, renderClear: renderClear, a11yProps: a11yProps }));
15
+ };
16
+ export const renderFilter = (_a) => {
17
+ var { ref, onChange } = _a, _b = _a.inputProps, { value, onKeyDown, onChange: _, size: __, placeholder: ___ } = _b, a11yProps = __rest(_b, ["value", "onKeyDown", "onChange", "size", "placeholder"]);
18
+ return (React.createElement(TextInput, { value: value, view: "clear", placeholder: i18n(Keyset.Search), onUpdate: onChange, onKeyDown: onKeyDown, className: b('popup-filter'), controlRef: ref, controlProps: Object.assign({ size: 1 }, a11yProps) }));
19
+ };
13
20
  export const renderOption = (option) => (React.createElement(CustomSelectOption, { data: option }));
@@ -3,11 +3,17 @@ import { SelectProps } from '@gravity-ui/uikit';
3
3
  import { SelectItem } from '../Controls/Controls';
4
4
  import './CustomSwitcher.css';
5
5
  type RenderControlParameters = Partial<Parameters<Required<SelectProps>['renderControl']>[0]>;
6
+ type TriggerProps = Required<RenderControlParameters>['triggerProps'];
7
+ type A11yKeys = {
8
+ [K in keyof TriggerProps]-?: K extends `aria-${string}` | 'role' ? K : never;
9
+ }[keyof TriggerProps];
10
+ type RenderControlA11yProps = Pick<TriggerProps, A11yKeys>;
6
11
  export type CustomSwitcherProps = {
7
12
  initial: (string | number | null)[];
8
13
  defaultLabel: string;
9
14
  list: SelectItem[];
10
15
  controlRef: RenderControlParameters['ref'];
11
- } & Omit<RenderControlParameters, 'ref'>;
12
- export declare const CustomSwitcher: ({ initial, defaultLabel, list, onClick, controlRef, onKeyDown, open, renderClear, popupId, activeIndex, }: CustomSwitcherProps) => React.JSX.Element;
16
+ a11yProps: RenderControlA11yProps;
17
+ } & Omit<RenderControlParameters, 'ref'> & Pick<TriggerProps, 'id' | 'disabled' | 'type'>;
18
+ export declare const CustomSwitcher: ({ id, disabled, type, initial, defaultLabel, list, onClick, controlRef, onKeyDown, renderClear, a11yProps, }: CustomSwitcherProps) => React.JSX.Element;
13
19
  export {};
@@ -7,7 +7,7 @@ import './CustomSwitcher.css';
7
7
  const b = block('feed-custom-switcher');
8
8
  const ICON_SIZE = 12;
9
9
  const CLEAR_ICON_SIZE = 11;
10
- export const CustomSwitcher = ({ initial, defaultLabel, list, onClick, controlRef, onKeyDown, open, renderClear, popupId, activeIndex, }) => {
10
+ export const CustomSwitcher = ({ id, disabled, type, initial, defaultLabel, list, onClick, controlRef, onKeyDown, renderClear, a11yProps, }) => {
11
11
  const itemsNames = useMemo(() => {
12
12
  const items = list
13
13
  .filter((item) => initial.includes(item.value))
@@ -17,7 +17,7 @@ export const CustomSwitcher = ({ initial, defaultLabel, list, onClick, controlRe
17
17
  const hasCounter = itemsNames.length > 1;
18
18
  const contentElementId = useUniqId();
19
19
  return (React.createElement("div", { className: b('custom-switcher'), ref: controlRef },
20
- React.createElement("button", { onClick: onClick, className: b('custom-switcher-element', { overlay: true }), onKeyDown: onKeyDown, "aria-expanded": open, "aria-labelledby": contentElementId, "aria-activedescendant": activeIndex === undefined ? undefined : `${popupId}-item-${activeIndex}` }),
20
+ React.createElement("button", Object.assign({ id: id, disabled: disabled, type: type, onClick: onClick, className: b('custom-switcher-element', { overlay: true }), onKeyDown: onKeyDown }, a11yProps, { "aria-labelledby": contentElementId })),
21
21
  React.createElement("div", { id: contentElementId, className: b('custom-switcher-element', { content: true }), "aria-hidden": true }, itemsNames === null || itemsNames === void 0 ? void 0 : itemsNames.join(', ')),
22
22
  renderClear &&
23
23
  renderClear({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/blog-constructor",
3
- "version": "6.4.3",
3
+ "version": "6.5.0",
4
4
  "description": "Gravity UI Blog Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -79,7 +79,7 @@
79
79
  "peerDependencies": {
80
80
  "@diplodoc/transform": "^4.10.7",
81
81
  "@gravity-ui/page-constructor": "^5.0.0",
82
- "@gravity-ui/uikit": "^6.1.1",
82
+ "@gravity-ui/uikit": "^6.26.0",
83
83
  "react": "^16.0.0 || ^17.0.0 || ^18.0.0"
84
84
  },
85
85
  "devDependencies": {
@@ -93,7 +93,7 @@
93
93
  "@gravity-ui/prettier-config": "^1.1.0",
94
94
  "@gravity-ui/stylelint-config": "^4.0.1",
95
95
  "@gravity-ui/tsconfig": "^1.0.0",
96
- "@gravity-ui/uikit": "^6.22.0",
96
+ "@gravity-ui/uikit": "^6.26.0",
97
97
  "@jest/environment": "^29.7.0",
98
98
  "@playwright/experimental-ct-react": "^1.45.3",
99
99
  "@playwright/test": "^1.45.3",