directual-web-components-v2 3.11.338 → 3.11.339

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.
package/dist/index.css CHANGED
@@ -1963,6 +1963,32 @@ a._IMG1h {
1963
1963
  ._1Ewcw ._271Bk:hover {
1964
1964
  opacity: 1;
1965
1965
  }
1966
+ ._3bMpu ._34tIu {
1967
+ position: absolute;
1968
+ top: 6px;
1969
+ right: 6px;
1970
+ display: flex;
1971
+ gap: 2px;
1972
+ opacity: 0;
1973
+ transition: opacity 0.2s;
1974
+ }
1975
+ ._3bMpu ._1Yv6j:hover ._34tIu {
1976
+ opacity: 1;
1977
+ }
1978
+ ._3bMpu ._Sxnoe {
1979
+ cursor: pointer;
1980
+ opacity: 0.4;
1981
+ padding: 4px;
1982
+ border-radius: var(--border-radius);
1983
+ font-size: var(--text-very-small-size);
1984
+ line-height: 1;
1985
+ -webkit-user-select: none;
1986
+ user-select: none;
1987
+ transition: opacity 0.15s;
1988
+ }
1989
+ ._3bMpu ._Sxnoe:hover {
1990
+ opacity: 0.9;
1991
+ }
1966
1992
  .react-tooltip {
1967
1993
  z-index: 1000;
1968
1994
  }
package/dist/index.js CHANGED
@@ -1257,7 +1257,7 @@ function _objectWithoutPropertiesLoose(r, e) {
1257
1257
 
1258
1258
  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"};
1259
1259
 
1260
- 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"};
1260
+ 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"};
1261
1261
 
1262
1262
  var styles$5 = {"radio":"_3ox_j","radio_flex":"_1-TJR","horizontal":"_2OJkg","disabled":"_3711f","radioImages":"_XxAUB","small":"_EFI2F","label":"_3CT1_","noOptions":"_1kxNM"};
1263
1263
 
@@ -5281,6 +5281,237 @@ function removeItem(groups, groupId, conditionId) {
5281
5281
  }).filter(Boolean);
5282
5282
  }
5283
5283
 
5284
+ function JsonInput(_ref) {
5285
+ let {
5286
+ defaultValue,
5287
+ onChange,
5288
+ disabled,
5289
+ rows,
5290
+ placeholder,
5291
+ autoFocus,
5292
+ isValid,
5293
+ copy,
5294
+ warning: externalWarning
5295
+ } = _ref;
5296
+ const [value, setValue] = React.useState(formatIfValid(defaultValue) || defaultValue || '');
5297
+ const [warningMsg, setWarningMsg] = React.useState({});
5298
+ const textareaRef = React.useRef(null);
5299
+ const isTyping = React.useRef(false);
5300
+ const isFocused = React.useRef(false);
5301
+ const prevDefaultValue = React.useRef(defaultValue);
5302
+ const adjustHeight = React.useCallback(() => {
5303
+ const el = textareaRef.current;
5304
+ if (!el || rows !== 'auto') return;
5305
+ el.style.height = 'auto';
5306
+ el.style.height = el.scrollHeight + 'px';
5307
+ }, [rows]);
5308
+ React.useEffect(() => {
5309
+ adjustHeight();
5310
+ }, [value, adjustHeight]);
5311
+ React.useEffect(() => {
5312
+ if (defaultValue === prevDefaultValue.current) return;
5313
+ prevDefaultValue.current = defaultValue;
5314
+ if (isFocused.current || isTyping.current) return;
5315
+ const formatted = formatIfValid(defaultValue) || defaultValue || '';
5316
+ setValue(formatted);
5317
+ if (formatted && formatted !== defaultValue) {
5318
+ setWarningMsg({
5319
+ type: 'ok',
5320
+ msg: 'Valid JSON'
5321
+ });
5322
+ isValid && isValid(true);
5323
+ } else if (defaultValue) {
5324
+ validateJson(defaultValue);
5325
+ } else {
5326
+ setWarningMsg({});
5327
+ }
5328
+ }, [defaultValue]);
5329
+ React.useEffect(() => {
5330
+ if (externalWarning && externalWarning.type) {
5331
+ setWarningMsg(externalWarning);
5332
+ }
5333
+ }, [externalWarning]);
5334
+ React.useEffect(() => {
5335
+ if (autoFocus && textareaRef.current) {
5336
+ textareaRef.current.focus();
5337
+ }
5338
+ }, [autoFocus]);
5339
+ function validateJson(str) {
5340
+ if (!str) {
5341
+ setWarningMsg({});
5342
+ isValid && isValid(true);
5343
+ return {
5344
+ valid: false,
5345
+ parsed: null
5346
+ };
5347
+ }
5348
+ try {
5349
+ const parsed = JSON.parse(str);
5350
+ setWarningMsg({
5351
+ type: 'ok',
5352
+ msg: 'Valid JSON'
5353
+ });
5354
+ isValid && isValid(true);
5355
+ return {
5356
+ valid: true,
5357
+ parsed
5358
+ };
5359
+ } catch (e) {
5360
+ const errorMsg = e.message || 'Invalid JSON';
5361
+ setWarningMsg({
5362
+ type: 'error',
5363
+ msg: errorMsg
5364
+ });
5365
+ isValid && isValid(false);
5366
+ return {
5367
+ valid: false,
5368
+ parsed: null
5369
+ };
5370
+ }
5371
+ }
5372
+ function handleChange(e) {
5373
+ const val = e.target.value;
5374
+ isTyping.current = true;
5375
+ setValue(val);
5376
+ onChange && onChange(val);
5377
+ }
5378
+ function handleBlur() {
5379
+ isFocused.current = false;
5380
+ isTyping.current = false;
5381
+ if (!value) {
5382
+ setWarningMsg({});
5383
+ isValid && isValid(true);
5384
+ prevDefaultValue.current = value;
5385
+ return;
5386
+ }
5387
+ const {
5388
+ valid,
5389
+ parsed
5390
+ } = validateJson(value);
5391
+ if (valid) {
5392
+ const formatted = JSON.stringify(parsed, null, 2);
5393
+ setValue(formatted);
5394
+ onChange && onChange(formatted);
5395
+ prevDefaultValue.current = formatted;
5396
+ } else {
5397
+ prevDefaultValue.current = value;
5398
+ }
5399
+ }
5400
+ function handleFocus() {
5401
+ isFocused.current = true;
5402
+ setWarningMsg({});
5403
+ }
5404
+ function handleKeyDown(e) {
5405
+ if (e.key === 'Tab') {
5406
+ e.preventDefault();
5407
+ const el = e.target;
5408
+ const start = el.selectionStart;
5409
+ const end = el.selectionEnd;
5410
+ if (e.shiftKey) {
5411
+ const before = value.substring(0, start);
5412
+ const lineStart = before.lastIndexOf('\n') + 1;
5413
+ const linePrefix = value.substring(lineStart, start);
5414
+ if (linePrefix.startsWith(' ')) {
5415
+ const newValue = value.substring(0, lineStart) + value.substring(lineStart + 2);
5416
+ setValue(newValue);
5417
+ onChange && onChange(newValue);
5418
+ requestAnimationFrame(() => {
5419
+ el.selectionStart = Math.max(lineStart, start - 2);
5420
+ el.selectionEnd = Math.max(lineStart, end - 2);
5421
+ });
5422
+ }
5423
+ } else {
5424
+ const newValue = value.substring(0, start) + ' ' + value.substring(end);
5425
+ setValue(newValue);
5426
+ onChange && onChange(newValue);
5427
+ requestAnimationFrame(() => {
5428
+ el.selectionStart = start + 2;
5429
+ el.selectionEnd = start + 2;
5430
+ });
5431
+ }
5432
+ }
5433
+ }
5434
+ function handleFormat() {
5435
+ if (!value) return;
5436
+ try {
5437
+ const parsed = JSON.parse(value);
5438
+ const formatted = JSON.stringify(parsed, null, 2);
5439
+ setValue(formatted);
5440
+ onChange && onChange(formatted);
5441
+ setWarningMsg({
5442
+ type: 'ok',
5443
+ msg: 'Valid JSON'
5444
+ });
5445
+ isValid && isValid(true);
5446
+ prevDefaultValue.current = formatted;
5447
+ } catch (e) {
5448
+ setWarningMsg({
5449
+ type: 'error',
5450
+ msg: e.message || 'Invalid JSON'
5451
+ });
5452
+ isValid && isValid(false);
5453
+ }
5454
+ }
5455
+ function handleClear() {
5456
+ setValue('');
5457
+ onChange && onChange('');
5458
+ setWarningMsg({});
5459
+ isValid && isValid(true);
5460
+ prevDefaultValue.current = '';
5461
+ }
5462
+ function handleCopy() {
5463
+ if (textareaRef.current) {
5464
+ textareaRef.current.select();
5465
+ try {
5466
+ document.execCommand('copy');
5467
+ } catch (err) {
5468
+ console.log('Unable to copy');
5469
+ }
5470
+ }
5471
+ }
5472
+ const autoRows = rows === 'auto';
5473
+ const rowCount = autoRows ? undefined : rows || 1;
5474
+ return /*#__PURE__*/React__default.createElement("div", {
5475
+ className: styles$4.field_wrapper
5476
+ }, /*#__PURE__*/React__default.createElement("textarea", {
5477
+ autoFocus: autoFocus,
5478
+ ref: textareaRef,
5479
+ disabled: disabled,
5480
+ className: "\n " + styles$4.field + "\n " + (disabled && styles$4.disabled) + "\n " + styles$4.code + "\n " + (warningMsg.type && styles$4[warningMsg.type]),
5481
+ rows: autoRows ? undefined : rowCount,
5482
+ onChange: handleChange,
5483
+ onBlur: handleBlur,
5484
+ onFocus: handleFocus,
5485
+ onKeyDown: handleKeyDown,
5486
+ value: value,
5487
+ placeholder: placeholder || ''
5488
+ }), /*#__PURE__*/React__default.createElement("div", {
5489
+ className: styles$4.json_toolbar
5490
+ }, value && !disabled && !copy && /*#__PURE__*/React__default.createElement("div", {
5491
+ className: styles$4.json_toolbar_btn + " icon icon-close",
5492
+ title: "Clear",
5493
+ onClick: handleClear
5494
+ }), value && copy && /*#__PURE__*/React__default.createElement("div", {
5495
+ className: styles$4.json_toolbar_btn + " icon icon-copy",
5496
+ title: "Copy",
5497
+ onClick: handleCopy
5498
+ }), value && !disabled && /*#__PURE__*/React__default.createElement("div", {
5499
+ className: styles$4.json_toolbar_btn + " icon icon-code",
5500
+ title: "Format JSON",
5501
+ onClick: handleFormat
5502
+ })), warningMsg.msg && /*#__PURE__*/React__default.createElement("div", {
5503
+ className: styles$4.status + " " + styles$4[warningMsg.type]
5504
+ }, warningMsg.msg));
5505
+ }
5506
+ function formatIfValid(str) {
5507
+ if (!str) return null;
5508
+ try {
5509
+ return JSON.stringify(JSON.parse(str), null, 2);
5510
+ } catch (_unused) {
5511
+ return null;
5512
+ }
5513
+ }
5514
+
5284
5515
  function InputGroup(props) {
5285
5516
  return /*#__PURE__*/React__default.createElement("div", {
5286
5517
  className: styles$4.input_group,
@@ -5858,6 +6089,10 @@ function Input(props) {
5858
6089
  const [showColor, setShowColor] = React.useState(false);
5859
6090
  const lang = props.locale ? props.locale.length == 3 ? props.locale : 'ENG' : 'ENG';
5860
6091
  const pickerRef = React.useRef(null);
6092
+ const debouncedTypingReset = React.useRef(_$1.debounce(val => {
6093
+ isTyping.current = false;
6094
+ setDefVal(val);
6095
+ }, 800)).current;
5861
6096
  const tooltipId = "tooltip_" + Math.floor(Math.random() * 1000000000);
5862
6097
  React.useEffect(() => {
5863
6098
  if (props.forceReset) {
@@ -5882,31 +6117,6 @@ function Input(props) {
5882
6117
  }
5883
6118
  }, [props.type]);
5884
6119
  const checkValue = () => {};
5885
- const checkJsonValue = (e, v) => {
5886
- let parseJSON = {};
5887
- const val = v || value;
5888
- if (val) {
5889
- try {
5890
- parseJSON = JSON.parse(val);
5891
- setValue(JSON.stringify(parseJSON, null, 3));
5892
- e && setLines(countLines(e.target || e, JSON.stringify(parseJSON, null, 3)));
5893
- setWarningMesg({
5894
- type: 'ok',
5895
- msg: 'Valid JSON'
5896
- });
5897
- props.isValid && props.isValid(true);
5898
- } catch (_unused) {
5899
- console.log('Error in parsing JSON');
5900
- setWarningMesg({
5901
- type: 'error',
5902
- msg: 'Invalid JSON'
5903
- });
5904
- props.isValid && props.isValid(false);
5905
- e && setLines(val && typeof val == 'string' ? (val.match(/\n/g) || []).length + 1 : 1);
5906
- }
5907
- }
5908
- !val && setWarningMesg({});
5909
- };
5910
6120
  const copyValue = value => {
5911
6121
  inputEl.current.select();
5912
6122
  try {
@@ -5959,9 +6169,6 @@ function Input(props) {
5959
6169
  setDefVal(props.defaultValue);
5960
6170
  setLines(countLines(inputEl.current, props.defaultValue));
5961
6171
  }
5962
- if (props.type == 'json' && inputEl.current) {
5963
- checkJsonValue(inputEl.current, props.defaultValue);
5964
- }
5965
6172
  }, [props.defaultValue, isControlled]);
5966
6173
  React.useEffect(() => {
5967
6174
  props.type == 'textarea' && setLines(countLines(inputEl.current, value));
@@ -6018,11 +6225,7 @@ function Input(props) {
6018
6225
  setValue(val);
6019
6226
  props.onChange && props.onChange(val);
6020
6227
  isTyping.current = true;
6021
- const debouncedUpdate = _$1.debounce(() => {
6022
- isTyping.current = false;
6023
- setDefVal(val);
6024
- }, 800);
6025
- debouncedUpdate();
6228
+ debouncedTypingReset(val);
6026
6229
  }
6027
6230
  React.useEffect(() => {
6028
6231
  if (props.highlightEmpty && !value) {
@@ -6059,39 +6262,50 @@ function Input(props) {
6059
6262
  React.useEffect(() => {
6060
6263
  inputEl.current && (props.reFocus || props.reFocus === 0) && inputEl.current.focus();
6061
6264
  }, [props.reFocus]);
6062
- const textareaWidthCache = new WeakMap();
6265
+ const textareaWidthCacheRef = React.useRef(new WeakMap());
6266
+ const countLinesBufferRef = React.useRef(null);
6267
+ React.useEffect(() => {
6268
+ return () => {
6269
+ if (countLinesBufferRef.current && countLinesBufferRef.current.parentNode) {
6270
+ countLinesBufferRef.current.parentNode.removeChild(countLinesBufferRef.current);
6271
+ countLinesBufferRef.current = null;
6272
+ }
6273
+ };
6274
+ }, []);
6063
6275
  function countLines(textarea, text) {
6064
6276
  if (!textarea || !textarea.constructor || textarea.constructor.name != 'HTMLTextAreaElement') {
6065
6277
  return;
6066
6278
  }
6067
- let _buffer;
6068
- if (_buffer == null) {
6069
- _buffer = document.createElement('textarea');
6070
- _buffer.style.border = 'none';
6071
- _buffer.style.height = '0';
6072
- _buffer.style.overflow = 'hidden';
6073
- _buffer.style.padding = '0';
6074
- _buffer.style.position = 'absolute';
6075
- _buffer.style.left = '0';
6076
- _buffer.style.top = '0';
6077
- _buffer.style.zIndex = '-1';
6078
- document.body.appendChild(_buffer);
6079
- }
6279
+ if (!countLinesBufferRef.current) {
6280
+ const buf = document.createElement('textarea');
6281
+ buf.style.border = 'none';
6282
+ buf.style.height = '0';
6283
+ buf.style.overflow = 'hidden';
6284
+ buf.style.padding = '0';
6285
+ buf.style.position = 'absolute';
6286
+ buf.style.left = '0';
6287
+ buf.style.top = '0';
6288
+ buf.style.zIndex = '-1';
6289
+ document.body.appendChild(buf);
6290
+ countLinesBufferRef.current = buf;
6291
+ }
6292
+ const _buffer = countLinesBufferRef.current;
6080
6293
  var cs = window.getComputedStyle(textarea);
6081
6294
  var pl = parseInt(cs.paddingLeft);
6082
6295
  var pr = parseInt(cs.paddingRight);
6083
6296
  var lh = parseInt(cs.lineHeight);
6084
6297
  if (isNaN(lh)) lh = parseInt(cs.fontSize) + 3;
6085
6298
  const currentContentWidth = textarea.clientWidth - pl - pr;
6086
- let cachedWidth = textareaWidthCache.get(textarea);
6299
+ const widthCache = textareaWidthCacheRef.current;
6300
+ let cachedWidth = widthCache.get(textarea);
6087
6301
  if (cachedWidth === undefined) {
6088
6302
  cachedWidth = currentContentWidth;
6089
- textareaWidthCache.set(textarea, cachedWidth);
6303
+ widthCache.set(textarea, cachedWidth);
6090
6304
  } else {
6091
6305
  const widthDiff = Math.abs(currentContentWidth - cachedWidth);
6092
6306
  if (widthDiff >= 20) {
6093
6307
  cachedWidth = currentContentWidth;
6094
- textareaWidthCache.set(textarea, cachedWidth);
6308
+ widthCache.set(textarea, cachedWidth);
6095
6309
  }
6096
6310
  }
6097
6311
  _buffer.style.width = cachedWidth + 'px';
@@ -6446,29 +6660,16 @@ function Input(props) {
6446
6660
  }), value && props.copy && /*#__PURE__*/React__default.createElement("div", {
6447
6661
  className: styles$4.clear + " icon icon-copy",
6448
6662
  onClick: value => copyValue()
6449
- }))), props.type == 'json' && /*#__PURE__*/React__default.createElement("div", {
6450
- className: styles$4.field_wrapper
6451
- }, /*#__PURE__*/React__default.createElement("textarea", {
6452
- autoFocus: props.autoFocus,
6453
- ref: inputEl,
6663
+ }))), props.type == 'json' && /*#__PURE__*/React__default.createElement(JsonInput, {
6664
+ defaultValue: props.defaultValue || props.value,
6665
+ onChange: val => submit(val),
6454
6666
  disabled: props.disabled,
6455
- className: "\n " + styles$4.field + "\n " + (props.disabled && styles$4.disabled) + "\n " + styles$4.code + "\n " + (warningMsg.type && styles$4[warningMsg.type]),
6456
- type: "text",
6457
- rows: props.rows == 'auto' ? lines : props.rows || 1,
6458
- onChange: e => {
6459
- setLines(countLines(e.target));
6460
- handleChange(e.target.value);
6461
- },
6462
- value: value,
6463
- onBlur: e => checkJsonValue(e),
6464
- placeholder: "" + (props.placeholder ? props.placeholder : '')
6465
- }), value && !props.copy && !props.disabled && /*#__PURE__*/React__default.createElement("div", {
6466
- className: styles$4.clear + " icon icon-close",
6467
- onClick: clearValue
6468
- }), value && props.copy && /*#__PURE__*/React__default.createElement("div", {
6469
- className: styles$4.clear + " icon icon-copy",
6470
- onClick: value => copyValue()
6471
- })), props.type == 'textarea' && /*#__PURE__*/React__default.createElement("div", {
6667
+ rows: props.rows,
6668
+ placeholder: props.placeholder,
6669
+ autoFocus: props.autoFocus,
6670
+ isValid: props.isValid,
6671
+ copy: props.copy
6672
+ }), props.type == 'textarea' && /*#__PURE__*/React__default.createElement("div", {
6472
6673
  className: styles$4.field_wrapper
6473
6674
  }, /*#__PURE__*/React__default.createElement("textarea", {
6474
6675
  autoFocus: props.autoFocus,
@@ -17117,7 +17318,7 @@ function FpsHtml(props) {
17117
17318
  setRenderKey(prev => prev + 1);
17118
17319
  }, [socket]);
17119
17320
  React.useEffect(() => {
17120
- const componentId = _$1__default.get(data, 'params.comp_ID') || id;
17321
+ const componentId = data && data.comp_ID || id;
17121
17322
  if (!componentId) return;
17122
17323
  if (!window.FpsHtml_API) {
17123
17324
  window.FpsHtml_API = {};
@@ -17163,10 +17364,6 @@ FpsHtml.settings = {
17163
17364
  name: "HTML code",
17164
17365
  sysName: 'FpsHtml',
17165
17366
  form: [{
17166
- name: 'Comp ID',
17167
- sysName: 'comp_ID',
17168
- type: 'string'
17169
- }, {
17170
17367
  name: "Enter your HTML-code",
17171
17368
  sysName: "html",
17172
17369
  type: "html-SLenriched"
@@ -17208,10 +17405,6 @@ FpsMarkdown.settings = {
17208
17405
  name: "Markdown text",
17209
17406
  sysName: 'FpsMarkdown',
17210
17407
  form: [{
17211
- name: 'Comp ID',
17212
- sysName: 'comp_ID',
17213
- type: 'string'
17214
- }, {
17215
17408
  name: "Enter your text",
17216
17409
  sysName: "markdown",
17217
17410
  type: "markdown-SLenriched"