@mtes-mct/monitor-ui 3.2.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/fields/Search.d.ts +22 -0
- package/formiks/FormikSearch.d.ts +3 -0
- package/index.d.ts +4 -4
- package/index.js +52 -11
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/fields/AutoComplete.d.ts +0 -19
- package/formiks/FormikAutoComplete.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
# [3.3.0](https://github.com/MTES-MCT/monitor-ui/compare/v3.2.0...v3.3.0) (2023-02-27)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **fields:** fix crash when custom type is given ([57117d9](https://github.com/MTES-MCT/monitor-ui/commit/57117d9d06fe33020abce79260964fe82ed21405))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **fields:** Add generic type, rename and style search input ([2fd516c](https://github.com/MTES-MCT/monitor-ui/commit/2fd516cf93cf6f9d89c3b33ef08b1ef2390a9189))
|
|
12
|
+
|
|
13
|
+
# [3.2.0](https://github.com/MTES-MCT/monitor-ui/compare/v3.1.1...v3.2.0) (2023-02-24)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **fields:** use baseContainer document for active elements in DatePicker & DateRangePicker ([753bd1b](https://github.com/MTES-MCT/monitor-ui/commit/753bd1be2b14c843bf25082e280031a0e1a78ac6))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* **cypress:** add first commands ([b685093](https://github.com/MTES-MCT/monitor-ui/commit/b685093ed178b0e409ff1ef8b1d683f254e098f3))
|
|
24
|
+
* **icons:** update ([ebd4fc3](https://github.com/MTES-MCT/monitor-ui/commit/ebd4fc3a6c17a22701c62d886dec5bf10fb464cc))
|
|
25
|
+
|
|
1
26
|
## [3.1.1](https://github.com/MTES-MCT/monitor-ui/compare/v3.1.0...v3.1.1) (2023-02-23)
|
|
2
27
|
|
|
3
28
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Option } from '../types';
|
|
3
|
+
import type { AutoCompleteProps as RsuiteAutoCompleteProps } from 'rsuite';
|
|
4
|
+
import type { Promisable } from 'type-fest';
|
|
5
|
+
export type SearchProps<T = string> = Omit<RsuiteAutoCompleteProps, 'as' | 'container' | 'data' | 'defaultValue' | 'id' | 'onChange' | 'open' | 'onSelect' | 'value'> & {
|
|
6
|
+
MenuItem?: React.ElementType | undefined;
|
|
7
|
+
/** Used to pass something else than `window.document` as a base container to attach global events listeners. */
|
|
8
|
+
baseContainer?: Document | HTMLDivElement | null | undefined;
|
|
9
|
+
defaultValue?: T | undefined;
|
|
10
|
+
error?: string | undefined;
|
|
11
|
+
isLabelHidden?: boolean | undefined;
|
|
12
|
+
isLight?: boolean | undefined;
|
|
13
|
+
isSearchIconHidden?: boolean | undefined;
|
|
14
|
+
label: string;
|
|
15
|
+
name: string;
|
|
16
|
+
onChange?: ((nextValue: T | undefined) => Promisable<void>) | undefined;
|
|
17
|
+
onQuery?: ((nextQuery: string | undefined) => Promisable<void>) | undefined;
|
|
18
|
+
options?: Option<T>[] | undefined;
|
|
19
|
+
queryMap?: ((record: Record<string, any>) => Option<T>) | undefined;
|
|
20
|
+
queryUrl?: string | undefined;
|
|
21
|
+
};
|
|
22
|
+
export declare function Search<T = string>({ baseContainer, defaultValue, error, isLabelHidden, isLight, isSearchIconHidden, label, MenuItem, onChange, onQuery, options, queryMap, queryUrl, ...originalProps }: SearchProps<T>): JSX.Element;
|
package/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { Label } from './elements/Label';
|
|
|
13
13
|
export { Legend } from './elements/Legend';
|
|
14
14
|
export { Tag } from './elements/Tag';
|
|
15
15
|
export { TagGroup } from './elements/TagGroup';
|
|
16
|
-
export {
|
|
16
|
+
export { Search } from './fields/Search';
|
|
17
17
|
export { Checkbox } from './fields/Checkbox';
|
|
18
18
|
export { DatePicker } from './fields/DatePicker';
|
|
19
19
|
export { DateRangePicker } from './fields/DateRangePicker';
|
|
@@ -26,7 +26,7 @@ export { CoordinatesInput } from './fields/CoordinatesInput';
|
|
|
26
26
|
export { Select } from './fields/Select';
|
|
27
27
|
export { Textarea } from './fields/Textarea';
|
|
28
28
|
export { TextInput } from './fields/TextInput';
|
|
29
|
-
export {
|
|
29
|
+
export { FormikSearch } from './formiks/FormikSearch';
|
|
30
30
|
export { FormikCheckbox } from './formiks/FormikCheckbox';
|
|
31
31
|
export { FormikCoordinatesInput } from './formiks/FormikCoordinatesInput';
|
|
32
32
|
export { FormikDatePicker } from './formiks/FormikDatePicker';
|
|
@@ -63,7 +63,7 @@ export type { LabelProps } from './elements/Label';
|
|
|
63
63
|
export type { LegendProps } from './elements/Legend';
|
|
64
64
|
export type { TagProps } from './elements/Tag';
|
|
65
65
|
export type { TagGroupProps } from './elements/TagGroup';
|
|
66
|
-
export type {
|
|
66
|
+
export type { SearchProps } from './fields/Search';
|
|
67
67
|
export type { CheckboxProps } from './fields/Checkbox';
|
|
68
68
|
export type { DatePickerWithDateDateProps, DatePickerWithStringDateProps } from './fields/DatePicker';
|
|
69
69
|
export type { DateRangePickerWithDateDateProps, DateRangePickerWithStringDateProps } from './fields/DateRangePicker';
|
|
@@ -76,7 +76,7 @@ export type { CoordinatesInputProps } from './fields/CoordinatesInput';
|
|
|
76
76
|
export type { SelectProps } from './fields/Select';
|
|
77
77
|
export type { TextareaProps } from './fields/Textarea';
|
|
78
78
|
export type { TextInputProps } from './fields/TextInput';
|
|
79
|
-
export type {
|
|
79
|
+
export type { FormikSearchProps } from './formiks/FormikSearch';
|
|
80
80
|
export type { FormikCheckboxProps } from './formiks/FormikCheckbox';
|
|
81
81
|
export type { FormikCoordinatesInputProps } from './formiks/FormikCoordinatesInput';
|
|
82
82
|
export type { FormikDatePickerWithDateDateProps, FormikDatePickerWithStringDateProps } from './formiks/FormikDatePicker';
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled, { createGlobalStyle, ThemeProvider as ThemeProvider$1, css } from 'styled-components';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import React, { useMemo, useCallback, useEffect, useReducer, useRef, useState, forwardRef, useImperativeHandle } from 'react';
|
|
4
|
-
import { Dropdown as Dropdown$1, AutoComplete
|
|
4
|
+
import { Dropdown as Dropdown$1, AutoComplete, Checkbox as Checkbox$1, DatePicker as DatePicker$1, DateRangePicker as DateRangePicker$1, TagPicker, Radio, Input, SelectPicker } from 'rsuite';
|
|
5
5
|
import { useField, useFormikContext } from 'formik';
|
|
6
6
|
|
|
7
7
|
var Accent;
|
|
@@ -2582,7 +2582,7 @@ function Save({ color, size, ...nativeProps }) {
|
|
|
2582
2582
|
return (jsx(IconBox, { "$color": color, "$size": size, children: jsxs("svg", { height: "20", viewBox: "0 0 20 20", width: "20", ...nativeProps, children: [jsx("path", { d: "M14.444,2H2V18H18V5.556ZM10,16.222a2.667,2.667,0,1,1,2.667-2.667h0a2.663,2.663,0,0,1-2.659,2.667Zm2.667-8.889H3.778V3.778h8.889Z", fill: "currentColor" }), jsx("rect", { fill: "none", height: "20", width: "20" })] }) }));
|
|
2583
2583
|
}
|
|
2584
2584
|
|
|
2585
|
-
function Search({ color, size, ...nativeProps }) {
|
|
2585
|
+
function Search$1({ color, size, ...nativeProps }) {
|
|
2586
2586
|
return (jsx(IconBox, { "$color": color, "$size": size, children: jsx("svg", { height: "20", viewBox: "0 0 20 20", width: "20", ...nativeProps, children: jsxs("g", { transform: "translate(200 -41)", children: [jsxs("g", { fill: "none", strokeMiterlimit: "10", children: [jsx("path", { d: "M-181.262,58.262l-5.111-5.111A6.958,6.958,0,0,0-185,49a7,7,0,0,0-7-7,7,7,0,0,0-7,7,7,7,0,0,0,7,7,6.958,6.958,0,0,0,4.151-1.373l5.111,5.111ZM-197,49a5.006,5.006,0,0,1,5-5,5.006,5.006,0,0,1,5,5,5.006,5.006,0,0,1-5,5A5.006,5.006,0,0,1-197,49Z", stroke: "none" }), jsx("path", { d: "M -182.7380065917969 59.73799896240234 L -187.8489990234375 54.62699890136719 C -189.0110015869141 55.48600006103516 -190.4440002441406 56 -192 56 C -195.8659973144531 56 -199 52.86600112915039 -199 49 C -199 45.13399887084961 -195.8659973144531 42 -192 42 C -188.1340026855469 42 -185 45.13399887084961 -185 49 C -185 50.55599975585938 -185.5140075683594 51.98899841308594 -186.3730010986328 53.1510009765625 L -181.2619934082031 58.26200103759766 L -182.7380065917969 59.73799896240234 Z M -192 44 C -194.7570037841797 44 -197 46.24300003051758 -197 49 C -197 51.75699996948242 -194.7570037841797 54 -192 54 C -189.2429962158203 54 -187 51.75699996948242 -187 49 C -187 46.24300003051758 -189.2429962158203 44 -192 44 Z", fill: "currentColor", stroke: "none" })] }), jsx("rect", { fill: "none", height: "20", transform: "translate(-200 41)", width: "20" })] }) }) }));
|
|
2587
2587
|
}
|
|
2588
2588
|
|
|
@@ -2695,7 +2695,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
2695
2695
|
Plus: Plus,
|
|
2696
2696
|
Reject: Reject,
|
|
2697
2697
|
Save: Save,
|
|
2698
|
-
Search: Search,
|
|
2698
|
+
Search: Search$1,
|
|
2699
2699
|
SelectCircle: SelectCircle,
|
|
2700
2700
|
SelectPolygon: SelectPolygon,
|
|
2701
2701
|
SelectRectangle: SelectRectangle,
|
|
@@ -3928,11 +3928,12 @@ function normalizeString(text) {
|
|
|
3928
3928
|
return cleanText.length > 0 ? cleanText : undefined;
|
|
3929
3929
|
}
|
|
3930
3930
|
|
|
3931
|
-
function
|
|
3931
|
+
function Search({ baseContainer, defaultValue, error, isLabelHidden, isLight = false, isSearchIconHidden = false, label, MenuItem, onChange, onQuery, options, queryMap, queryUrl, ...originalProps }) {
|
|
3932
3932
|
// eslint-disable-next-line no-null/no-null
|
|
3933
3933
|
const boxRef = useRef(null);
|
|
3934
3934
|
const queryRef = useRef(undefined);
|
|
3935
3935
|
const prevDefaultValuePropRef = useRef(defaultValue);
|
|
3936
|
+
const [inputValue, setInputValue] = useState(undefined);
|
|
3936
3937
|
const [autoGeneratedOptions, setAutoGeneratedOptions] = useState([]);
|
|
3937
3938
|
const [controlledDefaultValue, setDefaultControlledValue] = useState(defaultValue);
|
|
3938
3939
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -3951,7 +3952,15 @@ function AutoComplete({ baseContainer, defaultValue, error, isLabelHidden, isLig
|
|
|
3951
3952
|
const close = useCallback(() => {
|
|
3952
3953
|
setIsOpen(false);
|
|
3953
3954
|
}, []);
|
|
3955
|
+
const clean = useCallback(() => {
|
|
3956
|
+
setInputValue('');
|
|
3957
|
+
setIsOpen(false);
|
|
3958
|
+
}, []);
|
|
3954
3959
|
const handleChange = useCallback(async (nextQuery) => {
|
|
3960
|
+
if (!(typeof nextQuery === 'string')) {
|
|
3961
|
+
return;
|
|
3962
|
+
}
|
|
3963
|
+
setInputValue(nextQuery);
|
|
3955
3964
|
queryRef.current = normalizeString(nextQuery);
|
|
3956
3965
|
if (queryUrl && queryMap && queryRef.current) {
|
|
3957
3966
|
const url = queryUrl.replace('%s', queryRef.current);
|
|
@@ -3990,20 +3999,52 @@ function AutoComplete({ baseContainer, defaultValue, error, isLabelHidden, isLig
|
|
|
3990
3999
|
useEffect(() => {
|
|
3991
4000
|
forceUpdate();
|
|
3992
4001
|
}, [forceUpdate]);
|
|
3993
|
-
return (jsxs(Field$2, { children: [jsx(Label, { disabled: originalProps.disabled, hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }),
|
|
4002
|
+
return (jsxs(Field$2, { children: [jsx(Label, { disabled: originalProps.disabled, hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsxs(Box$c, { ref: boxRef, isLight: isLight, onClick: open, children: [boxRef.current && (jsx(StyledAutoComplete, { "$isLight": isLight, container: boxRef.current, data: controlledOptions, defaultValue: controlledValueAsLabel, id: originalProps.name, onChange: handleChange, onSelect: handleSelect, open: isOpen, renderMenuItem: (itemLabel, item) => MenuItem ? jsx(MenuItem, { item: item.value }) : itemLabel, value: inputValue, ...originalProps }, key)), inputValue && (jsxs(Fragment, { children: [jsx(StyledCloseButton, { accent: Accent.TERTIARY, color: THEME.color.slateGray, Icon: Close, isSearchIconHidden: isSearchIconHidden, onClick: clean, size: Size.SMALL }), !isSearchIconHidden && jsx(Separator, { children: "|" })] })), !isSearchIconHidden && (jsx(StyledSearchButton, { accent: Accent.TERTIARY, color: THEME.color.slateGray, Icon: Search$1, size: Size.NORMAL }))] }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
3994
4003
|
}
|
|
3995
|
-
const
|
|
4004
|
+
const StyledCloseButton = styled(IconButton) `
|
|
4005
|
+
cursor: pointer;
|
|
4006
|
+
height: 30px;
|
|
4007
|
+
margin: 5px ${p => (p.isSearchIconHidden ? 5 : 0)}px 5px 5px;
|
|
4008
|
+
padding: 8px;
|
|
4009
|
+
width: 30px;
|
|
4010
|
+
`;
|
|
4011
|
+
const StyledSearchButton = styled(IconButton) `
|
|
4012
|
+
border: unset;
|
|
4013
|
+
cursor: pointer;
|
|
4014
|
+
margin: 10px 10px 10px 8px;
|
|
4015
|
+
padding: 0px;
|
|
4016
|
+
`;
|
|
4017
|
+
const Separator = styled.div `
|
|
4018
|
+
height: 40px;
|
|
4019
|
+
font-weight: 300;
|
|
4020
|
+
color: ${p => p.theme.color.lightGray};
|
|
4021
|
+
padding-top: 3px;
|
|
4022
|
+
font-size: 20.5px;
|
|
4023
|
+
`;
|
|
4024
|
+
const StyledAutoComplete = styled(AutoComplete) `
|
|
3996
4025
|
font-size: 13px;
|
|
4026
|
+
flex-grow: 1;
|
|
3997
4027
|
|
|
3998
4028
|
> input {
|
|
3999
4029
|
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
4000
|
-
border: 0;
|
|
4030
|
+
border-width: 0 0 1px;
|
|
4031
|
+
border-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
4001
4032
|
font-size: 13px;
|
|
4002
4033
|
width: 100%;
|
|
4034
|
+
height: 40px;
|
|
4035
|
+
padding: 11px 16px;
|
|
4036
|
+
|
|
4037
|
+
:focus {
|
|
4038
|
+
outline: unset;
|
|
4039
|
+
border-color: ${p => p.theme.color.blueGray['100']};
|
|
4040
|
+
}
|
|
4003
4041
|
}
|
|
4004
4042
|
`;
|
|
4005
4043
|
const Box$c = styled.div `
|
|
4044
|
+
background-color: ${p => (p.isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
4006
4045
|
position: relative;
|
|
4046
|
+
width: 100%;
|
|
4047
|
+
display: flex;
|
|
4007
4048
|
|
|
4008
4049
|
> .rs-picker-select {
|
|
4009
4050
|
> .rs-picker-toggle {
|
|
@@ -15978,16 +16019,16 @@ const StyledInput = styled(Input) `
|
|
|
15978
16019
|
}
|
|
15979
16020
|
`;
|
|
15980
16021
|
|
|
15981
|
-
function
|
|
16022
|
+
function FormikSearch({ name, ...originalProps }) {
|
|
15982
16023
|
const [field, meta, helpers] = useField(name);
|
|
15983
16024
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15984
16025
|
const defaultValue = useMemo(() => field.value, []);
|
|
15985
16026
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15986
16027
|
const handleChange = useMemo(() => helpers.setValue, []);
|
|
15987
16028
|
if (!defaultValue) {
|
|
15988
|
-
return jsx(
|
|
16029
|
+
return jsx(Search, { name: name, onChange: helpers.setValue, ...originalProps });
|
|
15989
16030
|
}
|
|
15990
|
-
return (jsx(
|
|
16031
|
+
return (jsx(Search, { defaultValue: defaultValue, error: meta.error, name: name, onChange: handleChange, ...originalProps }));
|
|
15991
16032
|
}
|
|
15992
16033
|
|
|
15993
16034
|
function FormikCheckbox({ name, ...originalProps }) {
|
|
@@ -16104,5 +16145,5 @@ function FormikTextInput({ name, ...originalProps }) {
|
|
|
16104
16145
|
return (jsx(TextInput, { defaultValue: defaultValue, error: meta.error, name: name, onChange: handleChange, ...originalProps }));
|
|
16105
16146
|
}
|
|
16106
16147
|
|
|
16107
|
-
export { Accent,
|
|
16148
|
+
export { Accent, Button, Checkbox, CoordinatesFormat, CoordinatesInput, DatePicker, DateRangePicker, Dropdown, Field$2 as Field, Fieldset, FormikCheckbox, FormikCoordinatesInput, FormikDatePicker, FormikDateRangePicker, FormikEffect, FormikMultiCheckbox, FormikMultiRadio, FormikMultiSelect, FormikNumberInput, FormikSearch, FormikSelect, FormikTextInput, FormikTextarea, GlobalStyle, index as Icon, IconButton, Label, Legend, MultiCheckbox, MultiRadio, MultiSelect, MultiZoneEditor, NumberInput, OPENLAYERS_PROJECTION, OnlyFontGlobalStyle, Search, Select, SingleTag, Size, THEME, Tag, TagBullet, TagGroup, TextInput, Textarea, ThemeProvider, WSG84_PROJECTION, coordinatesAreDistinct, dayjs, getCoordinates, getLocalizedDayjs, getUtcizedDayjs, isNumeric, noop, stopMouseEventPropagation, useClickOutsideEffect, useForceUpdate, useKey, usePrevious };
|
|
16108
16149
|
//# sourceMappingURL=index.js.map
|