@carto/meridian-ds 2.1.0-alpha-copiable-input-text.3 → 2.1.1-alpha-copiable-input-text.4
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
CHANGED
|
@@ -6,9 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
## 2.0
|
|
8
8
|
|
|
9
|
+
### 2.1.1
|
|
10
|
+
|
|
11
|
+
- MultipleSelectField: select all filter is not working from empty state [#231](https://github.com/CartoDB/meridian-ds/pull/231)
|
|
12
|
+
|
|
9
13
|
### 2.1.0
|
|
10
14
|
|
|
11
|
-
- New Link
|
|
15
|
+
- New Link component and Button with externalLink behavior [#202](https://github.com/CartoDB/meridian-ds/pull/202)
|
|
12
16
|
|
|
13
17
|
### 2.0.2
|
|
14
18
|
|
|
@@ -305,20 +305,33 @@ function useMultipleSelectField({
|
|
|
305
305
|
onChange
|
|
306
306
|
}) {
|
|
307
307
|
const [currentOptions, setCurrentOptions] = React.useState(selectedOptions ?? []);
|
|
308
|
-
const
|
|
309
|
-
const areAnySelected = currentOptions.length > 0;
|
|
308
|
+
const isInternalUpdate = React.useRef(false);
|
|
310
309
|
React.useEffect(() => {
|
|
311
|
-
if (
|
|
312
|
-
setCurrentOptions(
|
|
310
|
+
if (!isInternalUpdate.current) {
|
|
311
|
+
setCurrentOptions(selectedOptions ?? []);
|
|
313
312
|
}
|
|
313
|
+
isInternalUpdate.current = false;
|
|
314
314
|
}, [selectedOptions]);
|
|
315
|
+
const enabledOptions = React.useMemo(
|
|
316
|
+
() => options.filter(({ disabled }) => !disabled),
|
|
317
|
+
[options]
|
|
318
|
+
);
|
|
319
|
+
const enabledOptionValues = React.useMemo(
|
|
320
|
+
() => enabledOptions.map(({ value }) => value),
|
|
321
|
+
[enabledOptions]
|
|
322
|
+
);
|
|
323
|
+
const areAllSelected = enabledOptionValues.length > 0 && enabledOptionValues.every((value) => currentOptions.includes(value));
|
|
324
|
+
const areAnySelected = currentOptions.length > 0;
|
|
315
325
|
const handleChange = (event) => {
|
|
326
|
+
if (isInternalUpdate.current) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
316
329
|
const {
|
|
317
330
|
target: { value }
|
|
318
331
|
} = event;
|
|
319
|
-
const
|
|
320
|
-
setCurrentOptions(
|
|
321
|
-
onChange(
|
|
332
|
+
const newOptions = typeof value === "string" ? value.split(",") : value.filter((v) => v !== void 0);
|
|
333
|
+
setCurrentOptions(newOptions);
|
|
334
|
+
onChange(newOptions);
|
|
322
335
|
};
|
|
323
336
|
const selectAll = () => {
|
|
324
337
|
const optionsValues = options == null ? void 0 : options.filter(({ disabled }) => !disabled).map(({ value }) => value);
|
|
@@ -326,18 +339,17 @@ function useMultipleSelectField({
|
|
|
326
339
|
const allSelected = optionsValues.every(
|
|
327
340
|
(value) => currentOptions.includes(value)
|
|
328
341
|
);
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
setCurrentOptions(optionsValues);
|
|
334
|
-
onChange(optionsValues);
|
|
335
|
-
}
|
|
342
|
+
const newValue = allSelected ? [] : optionsValues;
|
|
343
|
+
isInternalUpdate.current = true;
|
|
344
|
+
setCurrentOptions(newValue);
|
|
345
|
+
onChange(newValue);
|
|
336
346
|
}
|
|
337
347
|
};
|
|
338
348
|
const unselectAll = () => {
|
|
339
|
-
|
|
340
|
-
|
|
349
|
+
const newValue = [];
|
|
350
|
+
isInternalUpdate.current = true;
|
|
351
|
+
setCurrentOptions(newValue);
|
|
352
|
+
onChange(newValue);
|
|
341
353
|
};
|
|
342
354
|
return {
|
|
343
355
|
areAllSelected,
|
package/dist/components/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import React, { forwardRef, useState, useEffect, useMemo,
|
|
2
|
+
import React, { forwardRef, useState, useRef, useEffect, useMemo, createElement, Fragment as Fragment$1, useCallback, useImperativeHandle } from "react";
|
|
3
3
|
import { useIntl } from "react-intl";
|
|
4
4
|
import { styled, Menu as Menu$2, MenuList as MenuList$1, Link, Checkbox, Select, MenuItem as MenuItem$1, FormControl, Box, InputLabel, FormHelperText, InputAdornment, IconButton, ListItemText, Tooltip, TextField, CircularProgress, Button as Button$1, Autocomplete as Autocomplete$1, Divider, ListItemIcon, createFilterOptions, Accordion, AccordionSummary, AccordionDetails, Avatar as Avatar$1, Snackbar as Snackbar$1, Portal, Fade, Slide, Popper, Grow, Paper, ClickAwayListener, ButtonGroup as ButtonGroup$1, ToggleButtonGroup as ToggleButtonGroup$1, alpha, useTheme, Toolbar, AppBar as AppBar$1, Dialog as Dialog$1, DialogTitle as DialogTitle$1, Chip, DialogContent as DialogContent$1, DialogActions as DialogActions$1 } from "@mui/material";
|
|
5
5
|
import { Cancel, AddCircleOutlineOutlined, CloseOutlined, ContentCopyOutlined, VisibilityOutlined, VisibilityOffOutlined, OpenInNewOutlined, MenuOutlined, HelpOutline, TodayOutlined, MoreVertOutlined, ErrorOutline, Check } from "@mui/icons-material";
|
|
@@ -305,20 +305,33 @@ function useMultipleSelectField({
|
|
|
305
305
|
onChange
|
|
306
306
|
}) {
|
|
307
307
|
const [currentOptions, setCurrentOptions] = useState(selectedOptions ?? []);
|
|
308
|
-
const
|
|
309
|
-
const areAnySelected = currentOptions.length > 0;
|
|
308
|
+
const isInternalUpdate = useRef(false);
|
|
310
309
|
useEffect(() => {
|
|
311
|
-
if (
|
|
312
|
-
setCurrentOptions(
|
|
310
|
+
if (!isInternalUpdate.current) {
|
|
311
|
+
setCurrentOptions(selectedOptions ?? []);
|
|
313
312
|
}
|
|
313
|
+
isInternalUpdate.current = false;
|
|
314
314
|
}, [selectedOptions]);
|
|
315
|
+
const enabledOptions = useMemo(
|
|
316
|
+
() => options.filter(({ disabled }) => !disabled),
|
|
317
|
+
[options]
|
|
318
|
+
);
|
|
319
|
+
const enabledOptionValues = useMemo(
|
|
320
|
+
() => enabledOptions.map(({ value }) => value),
|
|
321
|
+
[enabledOptions]
|
|
322
|
+
);
|
|
323
|
+
const areAllSelected = enabledOptionValues.length > 0 && enabledOptionValues.every((value) => currentOptions.includes(value));
|
|
324
|
+
const areAnySelected = currentOptions.length > 0;
|
|
315
325
|
const handleChange = (event) => {
|
|
326
|
+
if (isInternalUpdate.current) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
316
329
|
const {
|
|
317
330
|
target: { value }
|
|
318
331
|
} = event;
|
|
319
|
-
const
|
|
320
|
-
setCurrentOptions(
|
|
321
|
-
onChange(
|
|
332
|
+
const newOptions = typeof value === "string" ? value.split(",") : value.filter((v) => v !== void 0);
|
|
333
|
+
setCurrentOptions(newOptions);
|
|
334
|
+
onChange(newOptions);
|
|
322
335
|
};
|
|
323
336
|
const selectAll = () => {
|
|
324
337
|
const optionsValues = options == null ? void 0 : options.filter(({ disabled }) => !disabled).map(({ value }) => value);
|
|
@@ -326,18 +339,17 @@ function useMultipleSelectField({
|
|
|
326
339
|
const allSelected = optionsValues.every(
|
|
327
340
|
(value) => currentOptions.includes(value)
|
|
328
341
|
);
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
setCurrentOptions(optionsValues);
|
|
334
|
-
onChange(optionsValues);
|
|
335
|
-
}
|
|
342
|
+
const newValue = allSelected ? [] : optionsValues;
|
|
343
|
+
isInternalUpdate.current = true;
|
|
344
|
+
setCurrentOptions(newValue);
|
|
345
|
+
onChange(newValue);
|
|
336
346
|
}
|
|
337
347
|
};
|
|
338
348
|
const unselectAll = () => {
|
|
339
|
-
|
|
340
|
-
|
|
349
|
+
const newValue = [];
|
|
350
|
+
isInternalUpdate.current = true;
|
|
351
|
+
setCurrentOptions(newValue);
|
|
352
|
+
onChange(newValue);
|
|
341
353
|
};
|
|
342
354
|
return {
|
|
343
355
|
areAllSelected,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMultipleSelectField.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/MultipleSelectField/useMultipleSelectField.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,KAAK,EACV,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAE9B,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,eAAe,EACf,OAAO,EACP,QAAQ,GACT,EAAE,IAAI,CACL,QAAQ,CAAC,wBAAwB,CAAC,EAClC,iBAAiB,GAAG,SAAS,GAAG,UAAU,CAC3C;;;;
|
|
1
|
+
{"version":3,"file":"useMultipleSelectField.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/MultipleSelectField/useMultipleSelectField.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,KAAK,EACV,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAE9B,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,eAAe,EACf,OAAO,EACP,QAAQ,GACT,EAAE,IAAI,CACL,QAAQ,CAAC,wBAAwB,CAAC,EAClC,iBAAiB,GAAG,SAAS,GAAG,UAAU,CAC3C;;;;0BA4BU,iBAAiB,CAAC,yBAAyB,CAAC,OAAO,CAAC,EAAE,CAAC;;;EAsDjE"}
|