Skip to content

Commit 4345acb

Browse files
committed
chore: removed uuid dependency
Related to #1103
1 parent f809482 commit 4345acb

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/form-js-viewer/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@
5858
"lodash": "^4.5.0",
5959
"marked": "^12.0.1",
6060
"min-dash": "^4.2.1",
61-
"preact": "^10.5.14",
62-
"uuid": "^9.0.1"
61+
"preact": "^10.5.14"
6362
},
6463
"sideEffects": [
6564
"*.css"

packages/form-js-viewer/src/render/components/form-fields/JSFunctionField.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
33
import { useExpressionEvaluation, useDeepCompareMemoize, usePrevious } from '../../hooks';
44
import { isObject } from 'min-dash';
55
import { isEqual } from 'lodash';
6-
import { v4 as uuidv4 } from 'uuid';
76

87
export function JSFunctionField(props) {
9-
const { field, onChange, value } = props;
8+
9+
const {
10+
field,
11+
onChange,
12+
value,
13+
domId
14+
} = props;
15+
1016
const {
1117
jsFunction: functionDefinition,
1218
functionParameters: paramsDefinition,
@@ -16,7 +22,6 @@ export function JSFunctionField(props) {
1622

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

2227
const paramsEval = useExpressionEvaluation(paramsDefinition);
@@ -103,7 +108,7 @@ export function JSFunctionField(props) {
103108
`;
104109

105110
const _sandbox = Sandbox.create(hostAPI, {
106-
frameContainer: `#${iframeContainerId}`,
111+
frameContainer: `#${domId}`,
107112
frameClassName: 'fjs-sandbox-iframe'
108113
});
109114

@@ -119,7 +124,7 @@ export function JSFunctionField(props) {
119124
return () => {
120125
_sandbox.destroy();
121126
};
122-
}, [ clearValue, functionDefinition, iframeContainerId, safeSetValue, sandboxError ]);
127+
}, [ clearValue, functionDefinition, domId, safeSetValue, sandboxError ]);
123128

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

153158
return (
154-
<div ref={ iframeContainerRef } id={ iframeContainerId } className="fjs-sandbox-iframe-container"></div>
159+
<div ref={ iframeContainerRef } id={ domId } className="fjs-sandbox-iframe-container"></div>
155160
);
156161
}
157162

packages/form-js-viewer/test/spec/render/components/form-fields/JSFunctionField.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ function createJSFunctionField({ services, ...restOptions } = {}) {
154154
options={ options }>
155155
<JSFunctionField
156156
field={ options.field }
157+
domId={ 'testId' }
157158
onChange={ options.onChange } />
158159
</MockFormContext>, {
159160
container: options.container || container.querySelector('.fjs-form')

0 commit comments

Comments
 (0)