Skip to content

Commit

Permalink
Merge master to develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bpmn-io-bot committed Jan 3, 2024
2 parents a4f7a4b + 571c67a commit 7c40821
Show file tree
Hide file tree
Showing 15 changed files with 499 additions and 103 deletions.
110 changes: 77 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/form-js-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"feelin": "^3.0.0",
"flatpickr": "^4.6.13",
"ids": "^1.0.0",
"lodash.isequal": "^4.5.0",
"min-dash": "^4.0.0",
"preact": "^10.5.14",
"preact-markup": "^2.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { useRef } from 'preact/hooks';
import useOptionsAsync, { LOAD_STATES } from '../../hooks/useOptionsAsync';
import useCleanupMultiSelectValues from '../../hooks/useCleanupMultiSelectValues';
import classNames from 'classnames';
import isEqual from 'lodash/isEqual';

import Description from '../Description';
import Errors from '../Errors';
import Label from '../Label';

import { sanitizeMultiSelectValue } from '../util/sanitizerUtil';
import { sanitizeMultiSelectValue, hasEqualValue } from '../util/sanitizerUtil';

import { createEmptyOptions } from '../util/optionsUtil';

Expand Down Expand Up @@ -41,19 +42,15 @@ export default function Checklist(props) {

const { required } = validate;

const toggleCheckbox = (v) => {
const toggleCheckbox = (toggledValue) => {

let newValue = [ ...values ];

if (!newValue.includes(v)) {
newValue.push(v);
} else {
newValue = newValue.filter(x => x != v);
}
const newValues = hasEqualValue(toggledValue, values)
? values.filter(value => !isEqual(value, toggledValue))
: [ ...values, toggledValue ];

props.onChange({
field,
value: newValue,
value: newValues,
});
};

Expand Down Expand Up @@ -96,17 +93,18 @@ export default function Checklist(props) {
loadState == LOAD_STATES.LOADED && options.map((o, index) => {

const itemDomId = `${domId}-${index}`;
const isChecked = hasEqualValue(o.value, values);

return (
<Label
id={ itemDomId }
label={ o.label }
class={ classNames({
'fjs-checked': values.includes(o.value)
'fjs-checked': isChecked
}) }
required={ false }>
<input
checked={ values.includes(o.value) }
checked={ isChecked }
class="fjs-input"
disabled={ disabled }
readOnly={ readonly }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useRef } from 'preact/hooks';
import isEqual from 'lodash/isEqual';
import useOptionsAsync, { LOAD_STATES } from '../../hooks/useOptionsAsync';
import useCleanupSingleSelectValue from '../../hooks/useCleanupSingleSelectValue';
import classNames from 'classnames';
Expand Down Expand Up @@ -85,16 +86,17 @@ export default function Radio(props) {
loadState == LOAD_STATES.LOADED && options.map((option, index) => {

const itemDomId = `${domId}-${index}`;
const isChecked = isEqual(option.value, value);

return (
<Label
id={ itemDomId }
key={ index }
label={ option.label }
class={ classNames({ 'fjs-checked': option.value === value }) }
class={ classNames({ 'fjs-checked': isChecked }) }
required={ false }>
<input
checked={ option.value === value }
checked={ isChecked }
class="fjs-input"
disabled={ disabled }
readOnly={ readonly }
Expand Down
Loading

0 comments on commit 7c40821

Please sign in to comment.