directual-web-components-v2 3.11.338 → 3.11.340

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.
@@ -1252,7 +1252,7 @@ function _objectWithoutPropertiesLoose(r, e) {
1252
1252
 
1253
1253
  var styles$3 = {"spacingWrapper":"_304HY","margin":"_1SqPJ","padding":"_6BebN","spacingTitle":"_31Oiv","label":"_1SA5-","input":"_1hinn","marginTop":"_70d7V","paddingTop":"_2UkZi","marginBottom":"_e8TuC","paddingBottom":"_30kaH","marginRight":"_2p5k-","paddingRight":"_WRztC","marginLeft":"_16ulN","paddingLeft":"_2yRNg","disabled":"_E8UOy","inputMarginWrapper":"_20AEO","spaceWrapper":"_1UV7S","hor":"_Aav1B","space":"_2lVa9","block":"_1fgLs","vert":"_3phN1"};
1254
1254
 
1255
- var styles$4 = {"input_wrapper":"_3bMpu","field_wrapper":"_1Yv6j","field_wrapper_additional":"_2B-KO","hor":"_2UlKm","input_icon_wrapper":"_2oMSY","field":"_2Q8VF","clear":"_1LMpi","plus":"_3IGqs","minus":"_jR7St","disabled":"_2xfws","ok":"_13tTH","error":"_2Tk7C","warning":"_2R_GP","code":"_3e2YR","addonAfter":"_3G71r","addonBefore":"_1W5zA","preSelect":"_1n5eL","addonAfterInput":"_Y4qJ8","addonBeforeInput":"_3uvz4","icon":"_vQGcE","description":"_34_if","status":"_2emj2","slider_field_wrapper":"_1fvXO","slider_values":"_3QTWu","input_group":"_3iO5y","input_row":"_25ABj","column":"_245Qh","fieldUnitsWrapper":"_3R0U6","unitName":"_12RC6","checkbox_wrapper":"_1RGf_","checkbox_clearOption":"_IMG1h","input_label_tooltip":"_1Ewcw","tooltip":"_271Bk"};
1255
+ var styles$4 = {"input_wrapper":"_3bMpu","field_wrapper":"_1Yv6j","field_wrapper_additional":"_2B-KO","hor":"_2UlKm","input_icon_wrapper":"_2oMSY","field":"_2Q8VF","clear":"_1LMpi","plus":"_3IGqs","minus":"_jR7St","disabled":"_2xfws","ok":"_13tTH","error":"_2Tk7C","warning":"_2R_GP","code":"_3e2YR","addonAfter":"_3G71r","addonBefore":"_1W5zA","preSelect":"_1n5eL","addonAfterInput":"_Y4qJ8","addonBeforeInput":"_3uvz4","icon":"_vQGcE","description":"_34_if","status":"_2emj2","slider_field_wrapper":"_1fvXO","slider_values":"_3QTWu","input_group":"_3iO5y","input_row":"_25ABj","column":"_245Qh","fieldUnitsWrapper":"_3R0U6","unitName":"_12RC6","checkbox_wrapper":"_1RGf_","checkbox_clearOption":"_IMG1h","input_label_tooltip":"_1Ewcw","tooltip":"_271Bk","json_toolbar":"_34tIu","json_toolbar_btn":"_Sxnoe"};
1256
1256
 
1257
1257
  var styles$5 = {"radio":"_3ox_j","radio_flex":"_1-TJR","horizontal":"_2OJkg","disabled":"_3711f","radioImages":"_XxAUB","small":"_EFI2F","label":"_3CT1_","noOptions":"_1kxNM"};
1258
1258
 
@@ -5276,6 +5276,237 @@ function removeItem(groups, groupId, conditionId) {
5276
5276
  }).filter(Boolean);
5277
5277
  }
5278
5278
 
5279
+ function JsonInput(_ref) {
5280
+ let {
5281
+ defaultValue,
5282
+ onChange,
5283
+ disabled,
5284
+ rows,
5285
+ placeholder,
5286
+ autoFocus,
5287
+ isValid,
5288
+ copy,
5289
+ warning: externalWarning
5290
+ } = _ref;
5291
+ const [value, setValue] = useState(formatIfValid(defaultValue) || defaultValue || '');
5292
+ const [warningMsg, setWarningMsg] = useState({});
5293
+ const textareaRef = useRef(null);
5294
+ const isTyping = useRef(false);
5295
+ const isFocused = useRef(false);
5296
+ const prevDefaultValue = useRef(defaultValue);
5297
+ const adjustHeight = useCallback(() => {
5298
+ const el = textareaRef.current;
5299
+ if (!el || rows !== 'auto') return;
5300
+ el.style.minHeight = '0';
5301
+ el.style.minHeight = el.scrollHeight + 'px';
5302
+ }, [rows]);
5303
+ useEffect(() => {
5304
+ adjustHeight();
5305
+ }, [value, adjustHeight]);
5306
+ useEffect(() => {
5307
+ if (defaultValue === prevDefaultValue.current) return;
5308
+ prevDefaultValue.current = defaultValue;
5309
+ if (isFocused.current || isTyping.current) return;
5310
+ const formatted = formatIfValid(defaultValue) || defaultValue || '';
5311
+ setValue(formatted);
5312
+ if (formatted && formatted !== defaultValue) {
5313
+ setWarningMsg({
5314
+ type: 'ok',
5315
+ msg: 'Valid JSON'
5316
+ });
5317
+ isValid && isValid(true);
5318
+ } else if (defaultValue) {
5319
+ validateJson(defaultValue);
5320
+ } else {
5321
+ setWarningMsg({});
5322
+ }
5323
+ }, [defaultValue]);
5324
+ useEffect(() => {
5325
+ if (externalWarning && externalWarning.type) {
5326
+ setWarningMsg(externalWarning);
5327
+ }
5328
+ }, [externalWarning]);
5329
+ useEffect(() => {
5330
+ if (autoFocus && textareaRef.current) {
5331
+ textareaRef.current.focus();
5332
+ }
5333
+ }, [autoFocus]);
5334
+ function validateJson(str) {
5335
+ if (!str) {
5336
+ setWarningMsg({});
5337
+ isValid && isValid(true);
5338
+ return {
5339
+ valid: false,
5340
+ parsed: null
5341
+ };
5342
+ }
5343
+ try {
5344
+ const parsed = JSON.parse(str);
5345
+ setWarningMsg({
5346
+ type: 'ok',
5347
+ msg: 'Valid JSON'
5348
+ });
5349
+ isValid && isValid(true);
5350
+ return {
5351
+ valid: true,
5352
+ parsed
5353
+ };
5354
+ } catch (e) {
5355
+ const errorMsg = e.message || 'Invalid JSON';
5356
+ setWarningMsg({
5357
+ type: 'error',
5358
+ msg: errorMsg
5359
+ });
5360
+ isValid && isValid(false);
5361
+ return {
5362
+ valid: false,
5363
+ parsed: null
5364
+ };
5365
+ }
5366
+ }
5367
+ function handleChange(e) {
5368
+ const val = e.target.value;
5369
+ isTyping.current = true;
5370
+ setValue(val);
5371
+ onChange && onChange(val);
5372
+ }
5373
+ function handleBlur() {
5374
+ isFocused.current = false;
5375
+ isTyping.current = false;
5376
+ if (!value) {
5377
+ setWarningMsg({});
5378
+ isValid && isValid(true);
5379
+ prevDefaultValue.current = value;
5380
+ return;
5381
+ }
5382
+ const {
5383
+ valid,
5384
+ parsed
5385
+ } = validateJson(value);
5386
+ if (valid) {
5387
+ const formatted = JSON.stringify(parsed, null, 2);
5388
+ setValue(formatted);
5389
+ onChange && onChange(formatted);
5390
+ prevDefaultValue.current = formatted;
5391
+ } else {
5392
+ prevDefaultValue.current = value;
5393
+ }
5394
+ }
5395
+ function handleFocus() {
5396
+ isFocused.current = true;
5397
+ setWarningMsg({});
5398
+ }
5399
+ function handleKeyDown(e) {
5400
+ if (e.key === 'Tab') {
5401
+ e.preventDefault();
5402
+ const el = e.target;
5403
+ const start = el.selectionStart;
5404
+ const end = el.selectionEnd;
5405
+ if (e.shiftKey) {
5406
+ const before = value.substring(0, start);
5407
+ const lineStart = before.lastIndexOf('\n') + 1;
5408
+ const linePrefix = value.substring(lineStart, start);
5409
+ if (linePrefix.startsWith(' ')) {
5410
+ const newValue = value.substring(0, lineStart) + value.substring(lineStart + 2);
5411
+ setValue(newValue);
5412
+ onChange && onChange(newValue);
5413
+ requestAnimationFrame(() => {
5414
+ el.selectionStart = Math.max(lineStart, start - 2);
5415
+ el.selectionEnd = Math.max(lineStart, end - 2);
5416
+ });
5417
+ }
5418
+ } else {
5419
+ const newValue = value.substring(0, start) + ' ' + value.substring(end);
5420
+ setValue(newValue);
5421
+ onChange && onChange(newValue);
5422
+ requestAnimationFrame(() => {
5423
+ el.selectionStart = start + 2;
5424
+ el.selectionEnd = start + 2;
5425
+ });
5426
+ }
5427
+ }
5428
+ }
5429
+ function handleFormat() {
5430
+ if (!value) return;
5431
+ try {
5432
+ const parsed = JSON.parse(value);
5433
+ const formatted = JSON.stringify(parsed, null, 2);
5434
+ setValue(formatted);
5435
+ onChange && onChange(formatted);
5436
+ setWarningMsg({
5437
+ type: 'ok',
5438
+ msg: 'Valid JSON'
5439
+ });
5440
+ isValid && isValid(true);
5441
+ prevDefaultValue.current = formatted;
5442
+ } catch (e) {
5443
+ setWarningMsg({
5444
+ type: 'error',
5445
+ msg: e.message || 'Invalid JSON'
5446
+ });
5447
+ isValid && isValid(false);
5448
+ }
5449
+ }
5450
+ function handleClear() {
5451
+ setValue('');
5452
+ onChange && onChange('');
5453
+ setWarningMsg({});
5454
+ isValid && isValid(true);
5455
+ prevDefaultValue.current = '';
5456
+ }
5457
+ function handleCopy() {
5458
+ if (textareaRef.current) {
5459
+ textareaRef.current.select();
5460
+ try {
5461
+ document.execCommand('copy');
5462
+ } catch (err) {
5463
+ console.log('Unable to copy');
5464
+ }
5465
+ }
5466
+ }
5467
+ const autoRows = rows === 'auto';
5468
+ const rowCount = autoRows ? undefined : rows || 1;
5469
+ return /*#__PURE__*/React.createElement("div", {
5470
+ className: styles$4.field_wrapper
5471
+ }, /*#__PURE__*/React.createElement("textarea", {
5472
+ autoFocus: autoFocus,
5473
+ ref: textareaRef,
5474
+ disabled: disabled,
5475
+ className: "\n " + styles$4.field + "\n " + (disabled && styles$4.disabled) + "\n " + styles$4.code + "\n " + (warningMsg.type && styles$4[warningMsg.type]),
5476
+ rows: autoRows ? undefined : rowCount,
5477
+ onChange: handleChange,
5478
+ onBlur: handleBlur,
5479
+ onFocus: handleFocus,
5480
+ onKeyDown: handleKeyDown,
5481
+ value: value,
5482
+ placeholder: placeholder || ''
5483
+ }), value && !disabled && /*#__PURE__*/React.createElement("div", {
5484
+ className: styles$4.json_toolbar
5485
+ }, /*#__PURE__*/React.createElement("div", {
5486
+ className: styles$4.json_toolbar_btn + " icon icon-code",
5487
+ title: "Format JSON",
5488
+ onClick: handleFormat
5489
+ }), copy && /*#__PURE__*/React.createElement("div", {
5490
+ className: styles$4.json_toolbar_btn + " icon icon-copy",
5491
+ title: "Copy",
5492
+ onClick: handleCopy
5493
+ }), /*#__PURE__*/React.createElement("div", {
5494
+ className: styles$4.json_toolbar_btn + " icon icon-close",
5495
+ title: "Clear",
5496
+ onClick: handleClear
5497
+ })), warningMsg.msg && /*#__PURE__*/React.createElement("div", {
5498
+ className: styles$4.status + " " + styles$4[warningMsg.type]
5499
+ }, warningMsg.msg));
5500
+ }
5501
+ function formatIfValid(str) {
5502
+ if (!str) return null;
5503
+ try {
5504
+ return JSON.stringify(JSON.parse(str), null, 2);
5505
+ } catch (_unused) {
5506
+ return null;
5507
+ }
5508
+ }
5509
+
5279
5510
  function InputGroup(props) {
5280
5511
  return /*#__PURE__*/React.createElement("div", {
5281
5512
  className: styles$4.input_group,
@@ -5853,6 +6084,10 @@ function Input(props) {
5853
6084
  const [showColor, setShowColor] = useState(false);
5854
6085
  const lang = props.locale ? props.locale.length == 3 ? props.locale : 'ENG' : 'ENG';
5855
6086
  const pickerRef = useRef(null);
6087
+ const debouncedTypingReset = useRef(debounce$1(val => {
6088
+ isTyping.current = false;
6089
+ setDefVal(val);
6090
+ }, 800)).current;
5856
6091
  const tooltipId = "tooltip_" + Math.floor(Math.random() * 1000000000);
5857
6092
  useEffect(() => {
5858
6093
  if (props.forceReset) {
@@ -5877,31 +6112,6 @@ function Input(props) {
5877
6112
  }
5878
6113
  }, [props.type]);
5879
6114
  const checkValue = () => {};
5880
- const checkJsonValue = (e, v) => {
5881
- let parseJSON = {};
5882
- const val = v || value;
5883
- if (val) {
5884
- try {
5885
- parseJSON = JSON.parse(val);
5886
- setValue(JSON.stringify(parseJSON, null, 3));
5887
- e && setLines(countLines(e.target || e, JSON.stringify(parseJSON, null, 3)));
5888
- setWarningMesg({
5889
- type: 'ok',
5890
- msg: 'Valid JSON'
5891
- });
5892
- props.isValid && props.isValid(true);
5893
- } catch (_unused) {
5894
- console.log('Error in parsing JSON');
5895
- setWarningMesg({
5896
- type: 'error',
5897
- msg: 'Invalid JSON'
5898
- });
5899
- props.isValid && props.isValid(false);
5900
- e && setLines(val && typeof val == 'string' ? (val.match(/\n/g) || []).length + 1 : 1);
5901
- }
5902
- }
5903
- !val && setWarningMesg({});
5904
- };
5905
6115
  const copyValue = value => {
5906
6116
  inputEl.current.select();
5907
6117
  try {
@@ -5954,9 +6164,6 @@ function Input(props) {
5954
6164
  setDefVal(props.defaultValue);
5955
6165
  setLines(countLines(inputEl.current, props.defaultValue));
5956
6166
  }
5957
- if (props.type == 'json' && inputEl.current) {
5958
- checkJsonValue(inputEl.current, props.defaultValue);
5959
- }
5960
6167
  }, [props.defaultValue, isControlled]);
5961
6168
  useEffect(() => {
5962
6169
  props.type == 'textarea' && setLines(countLines(inputEl.current, value));
@@ -6013,11 +6220,7 @@ function Input(props) {
6013
6220
  setValue(val);
6014
6221
  props.onChange && props.onChange(val);
6015
6222
  isTyping.current = true;
6016
- const debouncedUpdate = debounce$1(() => {
6017
- isTyping.current = false;
6018
- setDefVal(val);
6019
- }, 800);
6020
- debouncedUpdate();
6223
+ debouncedTypingReset(val);
6021
6224
  }
6022
6225
  useEffect(() => {
6023
6226
  if (props.highlightEmpty && !value) {
@@ -6054,39 +6257,50 @@ function Input(props) {
6054
6257
  useEffect(() => {
6055
6258
  inputEl.current && (props.reFocus || props.reFocus === 0) && inputEl.current.focus();
6056
6259
  }, [props.reFocus]);
6057
- const textareaWidthCache = new WeakMap();
6260
+ const textareaWidthCacheRef = useRef(new WeakMap());
6261
+ const countLinesBufferRef = useRef(null);
6262
+ useEffect(() => {
6263
+ return () => {
6264
+ if (countLinesBufferRef.current && countLinesBufferRef.current.parentNode) {
6265
+ countLinesBufferRef.current.parentNode.removeChild(countLinesBufferRef.current);
6266
+ countLinesBufferRef.current = null;
6267
+ }
6268
+ };
6269
+ }, []);
6058
6270
  function countLines(textarea, text) {
6059
6271
  if (!textarea || !textarea.constructor || textarea.constructor.name != 'HTMLTextAreaElement') {
6060
6272
  return;
6061
6273
  }
6062
- let _buffer;
6063
- if (_buffer == null) {
6064
- _buffer = document.createElement('textarea');
6065
- _buffer.style.border = 'none';
6066
- _buffer.style.height = '0';
6067
- _buffer.style.overflow = 'hidden';
6068
- _buffer.style.padding = '0';
6069
- _buffer.style.position = 'absolute';
6070
- _buffer.style.left = '0';
6071
- _buffer.style.top = '0';
6072
- _buffer.style.zIndex = '-1';
6073
- document.body.appendChild(_buffer);
6074
- }
6274
+ if (!countLinesBufferRef.current) {
6275
+ const buf = document.createElement('textarea');
6276
+ buf.style.border = 'none';
6277
+ buf.style.height = '0';
6278
+ buf.style.overflow = 'hidden';
6279
+ buf.style.padding = '0';
6280
+ buf.style.position = 'absolute';
6281
+ buf.style.left = '0';
6282
+ buf.style.top = '0';
6283
+ buf.style.zIndex = '-1';
6284
+ document.body.appendChild(buf);
6285
+ countLinesBufferRef.current = buf;
6286
+ }
6287
+ const _buffer = countLinesBufferRef.current;
6075
6288
  var cs = window.getComputedStyle(textarea);
6076
6289
  var pl = parseInt(cs.paddingLeft);
6077
6290
  var pr = parseInt(cs.paddingRight);
6078
6291
  var lh = parseInt(cs.lineHeight);
6079
6292
  if (isNaN(lh)) lh = parseInt(cs.fontSize) + 3;
6080
6293
  const currentContentWidth = textarea.clientWidth - pl - pr;
6081
- let cachedWidth = textareaWidthCache.get(textarea);
6294
+ const widthCache = textareaWidthCacheRef.current;
6295
+ let cachedWidth = widthCache.get(textarea);
6082
6296
  if (cachedWidth === undefined) {
6083
6297
  cachedWidth = currentContentWidth;
6084
- textareaWidthCache.set(textarea, cachedWidth);
6298
+ widthCache.set(textarea, cachedWidth);
6085
6299
  } else {
6086
6300
  const widthDiff = Math.abs(currentContentWidth - cachedWidth);
6087
6301
  if (widthDiff >= 20) {
6088
6302
  cachedWidth = currentContentWidth;
6089
- textareaWidthCache.set(textarea, cachedWidth);
6303
+ widthCache.set(textarea, cachedWidth);
6090
6304
  }
6091
6305
  }
6092
6306
  _buffer.style.width = cachedWidth + 'px';
@@ -6441,29 +6655,16 @@ function Input(props) {
6441
6655
  }), value && props.copy && /*#__PURE__*/React.createElement("div", {
6442
6656
  className: styles$4.clear + " icon icon-copy",
6443
6657
  onClick: value => copyValue()
6444
- }))), props.type == 'json' && /*#__PURE__*/React.createElement("div", {
6445
- className: styles$4.field_wrapper
6446
- }, /*#__PURE__*/React.createElement("textarea", {
6447
- autoFocus: props.autoFocus,
6448
- ref: inputEl,
6658
+ }))), props.type == 'json' && /*#__PURE__*/React.createElement(JsonInput, {
6659
+ defaultValue: props.defaultValue || props.value,
6660
+ onChange: val => submit(val),
6449
6661
  disabled: props.disabled,
6450
- className: "\n " + styles$4.field + "\n " + (props.disabled && styles$4.disabled) + "\n " + styles$4.code + "\n " + (warningMsg.type && styles$4[warningMsg.type]),
6451
- type: "text",
6452
- rows: props.rows == 'auto' ? lines : props.rows || 1,
6453
- onChange: e => {
6454
- setLines(countLines(e.target));
6455
- handleChange(e.target.value);
6456
- },
6457
- value: value,
6458
- onBlur: e => checkJsonValue(e),
6459
- placeholder: "" + (props.placeholder ? props.placeholder : '')
6460
- }), value && !props.copy && !props.disabled && /*#__PURE__*/React.createElement("div", {
6461
- className: styles$4.clear + " icon icon-close",
6462
- onClick: clearValue
6463
- }), value && props.copy && /*#__PURE__*/React.createElement("div", {
6464
- className: styles$4.clear + " icon icon-copy",
6465
- onClick: value => copyValue()
6466
- })), props.type == 'textarea' && /*#__PURE__*/React.createElement("div", {
6662
+ rows: props.rows,
6663
+ placeholder: props.placeholder,
6664
+ autoFocus: props.autoFocus,
6665
+ isValid: props.isValid,
6666
+ copy: props.copy
6667
+ }), props.type == 'textarea' && /*#__PURE__*/React.createElement("div", {
6467
6668
  className: styles$4.field_wrapper
6468
6669
  }, /*#__PURE__*/React.createElement("textarea", {
6469
6670
  autoFocus: props.autoFocus,
@@ -17112,7 +17313,7 @@ function FpsHtml(props) {
17112
17313
  setRenderKey(prev => prev + 1);
17113
17314
  }, [socket]);
17114
17315
  useEffect(() => {
17115
- const componentId = _$1.get(data, 'params.comp_ID') || id;
17316
+ const componentId = data && data.comp_ID || id;
17116
17317
  if (!componentId) return;
17117
17318
  if (!window.FpsHtml_API) {
17118
17319
  window.FpsHtml_API = {};
@@ -17158,10 +17359,6 @@ FpsHtml.settings = {
17158
17359
  name: "HTML code",
17159
17360
  sysName: 'FpsHtml',
17160
17361
  form: [{
17161
- name: 'Comp ID',
17162
- sysName: 'comp_ID',
17163
- type: 'string'
17164
- }, {
17165
17362
  name: "Enter your HTML-code",
17166
17363
  sysName: "html",
17167
17364
  type: "html-SLenriched"
@@ -17203,10 +17400,6 @@ FpsMarkdown.settings = {
17203
17400
  name: "Markdown text",
17204
17401
  sysName: 'FpsMarkdown',
17205
17402
  form: [{
17206
- name: 'Comp ID',
17207
- sysName: 'comp_ID',
17208
- type: 'string'
17209
- }, {
17210
17403
  name: "Enter your text",
17211
17404
  sysName: "markdown",
17212
17405
  type: "markdown-SLenriched"