mirror of
https://github.com/strapi/strapi.git
synced 2025-11-10 15:19:00 +00:00
[i18n] add filters from the start (#9796)
This commit is contained in:
parent
932da387be
commit
e293243da9
@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Label } from '@buffetjs/core';
|
import { Label } from '@buffetjs/core';
|
||||||
import { Inputs } from '@buffetjs/custom';
|
import { Inputs } from '@buffetjs/custom';
|
||||||
import Select from 'react-select';
|
import Select, { createFilter } from 'react-select';
|
||||||
import { Col, Row } from 'reactstrap';
|
import { Col, Row } from 'reactstrap';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import { useTheme } from 'styled-components';
|
import { useTheme } from 'styled-components';
|
||||||
@ -10,6 +10,12 @@ import { BaselineAlignment, selectStyles, DropdownIndicator } from 'strapi-helpe
|
|||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import { getTrad } from '../../utils';
|
import { getTrad } from '../../utils';
|
||||||
|
|
||||||
|
const reactSelectLocaleFilter = createFilter({
|
||||||
|
ignoreCase: true,
|
||||||
|
ignoreAccents: true,
|
||||||
|
matchFrom: 'start',
|
||||||
|
});
|
||||||
|
|
||||||
const BaseForm = ({ options, defaultOption }) => {
|
const BaseForm = ({ options, defaultOption }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
@ -34,6 +40,7 @@ const BaseForm = ({ options, defaultOption }) => {
|
|||||||
aria-labelledby="locale-code"
|
aria-labelledby="locale-code"
|
||||||
options={options}
|
options={options}
|
||||||
defaultValue={defaultOption}
|
defaultValue={defaultOption}
|
||||||
|
filterOption={reactSelectLocaleFilter}
|
||||||
onChange={selection => {
|
onChange={selection => {
|
||||||
setFieldValue('displayName', selection.value);
|
setFieldValue('displayName', selection.value);
|
||||||
setFieldValue('code', selection.label);
|
setFieldValue('code', selection.label);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user