Skip to content

Commit

Permalink
chore: removed uuid dependency
Browse files Browse the repository at this point in the history
Related to #1103
  • Loading branch information
Skaiir committed Apr 8, 2024
1 parent f809482 commit 4345acb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions packages/form-js-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
"lodash": "^4.5.0",
"marked": "^12.0.1",
"min-dash": "^4.2.1",
"preact": "^10.5.14",
"uuid": "^9.0.1"
"preact": "^10.5.14"
},
"sideEffects": [
"*.css"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
import { useExpressionEvaluation, useDeepCompareMemoize, usePrevious } from '../../hooks';
import { isObject } from 'min-dash';
import { isEqual } from 'lodash';
import { v4 as uuidv4 } from 'uuid';

export function JSFunctionField(props) {
const { field, onChange, value } = props;

const {
field,
onChange,
value,
domId
} = props;

const {
jsFunction: functionDefinition,
functionParameters: paramsDefinition,
Expand All @@ -16,7 +22,6 @@ export function JSFunctionField(props) {

const [ sandbox, setSandbox ] = useState(null);
const [ hasRunLoad, setHasRunLoad ] = useState(false);
const [ iframeContainerId ] = useState(`fjs-sandbox-iframe-container_${uuidv4()}`);
const iframeContainerRef = useRef(null);

const paramsEval = useExpressionEvaluation(paramsDefinition);
Expand Down Expand Up @@ -103,7 +108,7 @@ export function JSFunctionField(props) {
`;

const _sandbox = Sandbox.create(hostAPI, {
frameContainer: `#${iframeContainerId}`,
frameContainer: `#${domId}`,
frameClassName: 'fjs-sandbox-iframe'
});

Expand All @@ -119,7 +124,7 @@ export function JSFunctionField(props) {
return () => {
_sandbox.destroy();
};
}, [ clearValue, functionDefinition, iframeContainerId, safeSetValue, sandboxError ]);
}, [ clearValue, functionDefinition, domId, safeSetValue, sandboxError ]);

const prevParams = usePrevious(params);
const prevSandbox = usePrevious(sandbox);
Expand Down Expand Up @@ -151,7 +156,7 @@ export function JSFunctionField(props) {
}, [ params, prevParams, sandbox, prevSandbox, field, computeOn, hasRunLoad, interval, clearValue, safeSetValue ]);

return (
<div ref={ iframeContainerRef } id={ iframeContainerId } className="fjs-sandbox-iframe-container"></div>
<div ref={ iframeContainerRef } id={ domId } className="fjs-sandbox-iframe-container"></div>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ function createJSFunctionField({ services, ...restOptions } = {}) {
options={ options }>
<JSFunctionField
field={ options.field }
domId={ 'testId' }
onChange={ options.onChange } />
</MockFormContext>, {
container: options.container || container.querySelector('.fjs-form')
Expand Down

0 comments on commit 4345acb

Please sign in to comment.