@bpmn-io/form-js-viewer 0.8.0-alpha.1 → 0.9.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.
- package/dist/index.cjs +35 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +35 -32
- package/dist/index.es.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1809,7 +1809,7 @@ Select.keyed = true;
|
|
|
1809
1809
|
Select.emptyValue = null;
|
|
1810
1810
|
Select.sanitizeValue = sanitizeSingleSelectValue;
|
|
1811
1811
|
|
|
1812
|
-
function _extends() { _extends = Object.assign
|
|
1812
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
1813
1813
|
var CloseIcon = (({
|
|
1814
1814
|
styles = {},
|
|
1815
1815
|
...props
|
|
@@ -1958,35 +1958,30 @@ function Taglist(props) {
|
|
|
1958
1958
|
formId
|
|
1959
1959
|
} = hooks.useContext(FormContext);
|
|
1960
1960
|
const [filter, setFilter] = hooks.useState('');
|
|
1961
|
-
const [
|
|
1962
|
-
const [filteredValues, setFilteredValues] = hooks.useState([]);
|
|
1961
|
+
const [filteredOptions, setFilteredOptions] = hooks.useState([]);
|
|
1963
1962
|
const [isDropdownExpanded, setIsDropdownExpanded] = hooks.useState(false);
|
|
1964
|
-
const [
|
|
1963
|
+
const [hasOptionsLeft, setHasOptionsLeft] = hooks.useState(true);
|
|
1965
1964
|
const [isEscapeClosed, setIsEscapeClose] = hooks.useState(false);
|
|
1966
1965
|
const searchbarRef = hooks.useRef();
|
|
1967
1966
|
const {
|
|
1968
1967
|
state: loadState,
|
|
1969
1968
|
values: options
|
|
1970
|
-
} = useValuesAsync(field); //
|
|
1969
|
+
} = useValuesAsync(field); // We cache a map of option values to their index so that we don't need to search the whole options array every time to correlate the label
|
|
1970
|
+
|
|
1971
|
+
const valueToOptionMap = hooks.useMemo(() => Object.assign({}, ...options.map((o, x) => ({
|
|
1972
|
+
[o.value]: options[x]
|
|
1973
|
+
}))), [options]); // Usage of stringify is necessary here because we want this effect to only trigger when there is a value change to the array
|
|
1971
1974
|
|
|
1972
1975
|
hooks.useEffect(() => {
|
|
1973
1976
|
if (loadState === LOAD_STATES.LOADED) {
|
|
1974
|
-
|
|
1975
|
-
setSelectedValues(selectedValues);
|
|
1976
|
-
} else {
|
|
1977
|
-
setSelectedValues([]);
|
|
1978
|
-
}
|
|
1979
|
-
}, [JSON.stringify(values), options, loadState]);
|
|
1980
|
-
hooks.useEffect(() => {
|
|
1981
|
-
if (loadState === LOAD_STATES.LOADED) {
|
|
1982
|
-
setFilteredValues(options.filter(o => o.label && o.value && o.label.toLowerCase().includes(filter.toLowerCase()) && !values.includes(o.value)));
|
|
1977
|
+
setFilteredOptions(options.filter(o => o.label && o.value && o.label.toLowerCase().includes(filter.toLowerCase()) && !values.includes(o.value)));
|
|
1983
1978
|
} else {
|
|
1984
|
-
|
|
1979
|
+
setFilteredOptions([]);
|
|
1985
1980
|
}
|
|
1986
|
-
}, [filter, JSON.stringify(values), options]);
|
|
1981
|
+
}, [filter, JSON.stringify(values), options, loadState]);
|
|
1987
1982
|
hooks.useEffect(() => {
|
|
1988
|
-
|
|
1989
|
-
}, [
|
|
1983
|
+
setHasOptionsLeft(options.length > values.length);
|
|
1984
|
+
}, [options.length, values.length]);
|
|
1990
1985
|
|
|
1991
1986
|
const onFilterChange = ({
|
|
1992
1987
|
target
|
|
@@ -1995,17 +1990,25 @@ function Taglist(props) {
|
|
|
1995
1990
|
setFilter(target.value);
|
|
1996
1991
|
};
|
|
1997
1992
|
|
|
1998
|
-
const selectValue =
|
|
1999
|
-
|
|
1993
|
+
const selectValue = value => {
|
|
1994
|
+
if (filter) {
|
|
1995
|
+
setFilter('');
|
|
1996
|
+
} // Ensure values cannot be double selected due to latency
|
|
1997
|
+
|
|
1998
|
+
|
|
1999
|
+
if (values.at(-1) === value) {
|
|
2000
|
+
return;
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2000
2003
|
props.onChange({
|
|
2001
|
-
value: [...values,
|
|
2004
|
+
value: [...values, value],
|
|
2002
2005
|
field
|
|
2003
2006
|
});
|
|
2004
2007
|
};
|
|
2005
2008
|
|
|
2006
|
-
const deselectValue =
|
|
2009
|
+
const deselectValue = value => {
|
|
2007
2010
|
props.onChange({
|
|
2008
|
-
value: values.filter(v => v !=
|
|
2011
|
+
value: values.filter(v => v != value),
|
|
2009
2012
|
field
|
|
2010
2013
|
});
|
|
2011
2014
|
};
|
|
@@ -2019,8 +2022,8 @@ function Taglist(props) {
|
|
|
2019
2022
|
break;
|
|
2020
2023
|
|
|
2021
2024
|
case 'Backspace':
|
|
2022
|
-
if (!filter &&
|
|
2023
|
-
deselectValue(
|
|
2025
|
+
if (!filter && values.length) {
|
|
2026
|
+
deselectValue(values[values.length - 1]);
|
|
2024
2027
|
}
|
|
2025
2028
|
|
|
2026
2029
|
break;
|
|
@@ -2047,16 +2050,16 @@ function Taglist(props) {
|
|
|
2047
2050
|
class: classNames__default['default']('fjs-taglist', {
|
|
2048
2051
|
'disabled': disabled
|
|
2049
2052
|
}),
|
|
2050
|
-
children: [!disabled && loadState === LOAD_STATES.LOADED &&
|
|
2053
|
+
children: [!disabled && loadState === LOAD_STATES.LOADED && values.map(v => {
|
|
2051
2054
|
return jsxRuntime.jsxs("div", {
|
|
2052
2055
|
class: "fjs-taglist-tag",
|
|
2053
2056
|
onMouseDown: e => e.preventDefault(),
|
|
2054
2057
|
children: [jsxRuntime.jsx("span", {
|
|
2055
2058
|
class: "fjs-taglist-tag-label",
|
|
2056
|
-
children:
|
|
2059
|
+
children: valueToOptionMap[v] ? valueToOptionMap[v].label : `unexpected value{${v}}`
|
|
2057
2060
|
}), jsxRuntime.jsx("span", {
|
|
2058
2061
|
class: "fjs-taglist-tag-remove",
|
|
2059
|
-
onMouseDown: () => deselectValue(
|
|
2062
|
+
onMouseDown: () => deselectValue(v),
|
|
2060
2063
|
children: jsxRuntime.jsx(CloseIcon, {})
|
|
2061
2064
|
})]
|
|
2062
2065
|
});
|
|
@@ -2081,10 +2084,10 @@ function Taglist(props) {
|
|
|
2081
2084
|
}), jsxRuntime.jsx("div", {
|
|
2082
2085
|
class: "fjs-taglist-anchor",
|
|
2083
2086
|
children: !disabled && loadState === LOAD_STATES.LOADED && isDropdownExpanded && !isEscapeClosed && jsxRuntime.jsx(DropdownList, {
|
|
2084
|
-
values:
|
|
2085
|
-
getLabel:
|
|
2086
|
-
onValueSelected:
|
|
2087
|
-
emptyListMessage:
|
|
2087
|
+
values: filteredOptions,
|
|
2088
|
+
getLabel: o => o.label,
|
|
2089
|
+
onValueSelected: o => selectValue(o.value),
|
|
2090
|
+
emptyListMessage: hasOptionsLeft ? 'No results' : 'All values selected',
|
|
2088
2091
|
listenerElement: searchbarRef.current
|
|
2089
2092
|
})
|
|
2090
2093
|
}), jsxRuntime.jsx(Description, {
|