@bpmn-io/form-js-viewer
Advanced tools
Comparing version 0.8.0-alpha.1 to 0.8.0
@@ -1800,3 +1800,3 @@ import Ids from 'ids'; | ||
function _extends() { _extends = Object.assign || 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); } | ||
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); } | ||
var CloseIcon = (({ | ||
@@ -1950,6 +1950,5 @@ styles = {}, | ||
const [filter, setFilter] = useState(''); | ||
const [selectedValues, setSelectedValues] = useState([]); | ||
const [filteredValues, setFilteredValues] = useState([]); | ||
const [filteredOptions, setFilteredOptions] = useState([]); | ||
const [isDropdownExpanded, setIsDropdownExpanded] = useState(false); | ||
const [hasValuesLeft, setHasValuesLeft] = useState(true); | ||
const [hasOptionsLeft, setHasOptionsLeft] = useState(true); | ||
const [isEscapeClosed, setIsEscapeClose] = useState(false); | ||
@@ -1960,22 +1959,18 @@ const searchbarRef = useRef(); | ||
values: options | ||
} = useValuesAsync(field); // Usage of stringify is necessary here because we want this effect to only trigger when there is a value change to the array | ||
} = 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 | ||
const valueToOptionMap = useMemo(() => Object.assign({}, ...options.map((o, x) => ({ | ||
[o.value]: options[x] | ||
}))), [options]); // Usage of stringify is necessary here because we want this effect to only trigger when there is a value change to the array | ||
useEffect(() => { | ||
if (loadState === LOAD_STATES.LOADED) { | ||
const selectedValues = values.map(v => options.find(o => o.value === v)).filter(v => v !== undefined); | ||
setSelectedValues(selectedValues); | ||
setFilteredOptions(options.filter(o => o.label && o.value && o.label.toLowerCase().includes(filter.toLowerCase()) && !values.includes(o.value))); | ||
} else { | ||
setSelectedValues([]); | ||
setFilteredOptions([]); | ||
} | ||
}, [JSON.stringify(values), options, loadState]); | ||
}, [filter, JSON.stringify(values), options, loadState]); | ||
useEffect(() => { | ||
if (loadState === LOAD_STATES.LOADED) { | ||
setFilteredValues(options.filter(o => o.label && o.value && o.label.toLowerCase().includes(filter.toLowerCase()) && !values.includes(o.value))); | ||
} else { | ||
setFilteredValues([]); | ||
} | ||
}, [filter, JSON.stringify(values), options]); | ||
useEffect(() => { | ||
setHasValuesLeft(selectedValues.length < options.length); | ||
}, [selectedValues.length, options.length]); | ||
setHasOptionsLeft(options.length > values.length); | ||
}, [options.length, values.length]); | ||
@@ -1989,6 +1984,14 @@ const onFilterChange = ({ | ||
const selectValue = option => { | ||
setFilter(''); | ||
const selectValue = value => { | ||
if (filter) { | ||
setFilter(''); | ||
} // Ensure values cannot be double selected due to latency | ||
if (values.at(-1) === value) { | ||
return; | ||
} | ||
props.onChange({ | ||
value: [...values, option.value], | ||
value: [...values, value], | ||
field | ||
@@ -1998,5 +2001,5 @@ }); | ||
const deselectValue = option => { | ||
const deselectValue = value => { | ||
props.onChange({ | ||
value: values.filter(v => v != option.value), | ||
value: values.filter(v => v != value), | ||
field | ||
@@ -2015,4 +2018,4 @@ }); | ||
case 'Backspace': | ||
if (!filter && selectedValues.length) { | ||
deselectValue(selectedValues[selectedValues.length - 1]); | ||
if (!filter && values.length) { | ||
deselectValue(values[values.length - 1]); | ||
} | ||
@@ -2044,3 +2047,3 @@ | ||
}), | ||
children: [!disabled && loadState === LOAD_STATES.LOADED && selectedValues.map(sv => { | ||
children: [!disabled && loadState === LOAD_STATES.LOADED && values.map(v => { | ||
return jsxs("div", { | ||
@@ -2051,6 +2054,6 @@ class: "fjs-taglist-tag", | ||
class: "fjs-taglist-tag-label", | ||
children: sv.label | ||
children: valueToOptionMap[v] ? valueToOptionMap[v].label : `unexpected value{${v}}` | ||
}), jsx("span", { | ||
class: "fjs-taglist-tag-remove", | ||
onMouseDown: () => deselectValue(sv), | ||
onMouseDown: () => deselectValue(v), | ||
children: jsx(CloseIcon, {}) | ||
@@ -2080,6 +2083,6 @@ })] | ||
children: !disabled && loadState === LOAD_STATES.LOADED && isDropdownExpanded && !isEscapeClosed && jsx(DropdownList, { | ||
values: filteredValues, | ||
getLabel: v => v.label, | ||
onValueSelected: v => selectValue(v), | ||
emptyListMessage: hasValuesLeft ? 'No results' : 'All values selected', | ||
values: filteredOptions, | ||
getLabel: o => o.label, | ||
onValueSelected: o => selectValue(o.value), | ||
emptyListMessage: hasOptionsLeft ? 'No results' : 'All values selected', | ||
listenerElement: searchbarRef.current | ||
@@ -2086,0 +2089,0 @@ }) |
export {}; |
@@ -0,0 +0,0 @@ declare class FormFieldRegistry { |
@@ -0,0 +0,0 @@ export { FormFieldRegistry }; |
@@ -0,0 +0,0 @@ declare class Validator { |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ declare class Importer { |
@@ -0,0 +0,0 @@ declare namespace _default { |
@@ -0,0 +0,0 @@ /** |
export default function Description(props: any): import("preact").JSX.Element; |
export default function Errors(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Button(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Checkbox(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Checklist(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Default(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Number(props: any): import("preact").JSX.Element; |
export default function DropdownList(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Radio(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Select(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Taglist(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Text(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ declare function Textfield(props: any): import("preact").JSX.Element; |
export default function FormComponent(props: any): import("preact").JSX.Element; |
export default function FormField(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ export const formFields: (typeof Button | typeof Default | typeof Radio | typeof Text)[]; |
export default function Label(props: any): import("preact").JSX.Element; |
export default function PoweredBy(props: any): import("preact").JSX.Element; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ export function formFieldClasses(type: any, errors?: any[]): string; |
@@ -0,0 +0,0 @@ export default FormContext; |
@@ -0,0 +0,0 @@ export default FormRenderContext; |
export { default as FormRenderContext } from "./FormRenderContext"; | ||
export { default as FormContext } from "./FormContext"; |
@@ -0,0 +0,0 @@ export default class FormFields { |
export default function useKeyDownAction(targetKey: any, action: any, listenerElement?: Window & typeof globalThis): void; |
export default function _default(type: any, strict: any): any; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ export { FormFields }; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import { Injector } from 'didi'; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ export function findErrors(errors: any, path: any): any; |
export function createInjector(bootstrapModules: any): Injector; | ||
import { Injector } from "didi"; |
{ | ||
"name": "@bpmn-io/form-js-viewer", | ||
"version": "0.8.0-alpha.1", | ||
"version": "0.8.0", | ||
"description": "View forms - powered by bpmn.io", | ||
@@ -45,3 +45,3 @@ "exports": { | ||
"ids": "^1.0.0", | ||
"min-dash": "^3.7.0", | ||
"min-dash": "^3.8.1", | ||
"preact": "^10.5.14", | ||
@@ -56,3 +56,3 @@ "preact-markup": "^2.1.1" | ||
], | ||
"gitHead": "2be914efeefa050fb4692ac1a644557fc424917f" | ||
"gitHead": "0d9bff2b98491fb96944135e78106cbf807c580a" | ||
} |
@@ -0,0 +0,0 @@ # @bpmn-io/form-js-viewer |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
426688
5514
1
Updatedmin-dash@^3.8.1