@qoretechnologies/reqraft 0.10.61 → 0.10.62-pr.137.g86641aa

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.
Files changed (101) hide show
  1. package/dist/components/dpqlEditor/DpqlEditor.d.ts.map +1 -1
  2. package/dist/components/dpqlEditor/DpqlEditor.js +8 -3
  3. package/dist/components/dpqlEditor/DpqlEditor.js.map +1 -1
  4. package/dist/components/dpqlEditor/types.d.ts +5 -0
  5. package/dist/components/dpqlEditor/types.d.ts.map +1 -1
  6. package/dist/components/form/engine/CompactRow.d.ts.map +1 -1
  7. package/dist/components/form/engine/CompactRow.js +17 -8
  8. package/dist/components/form/engine/CompactRow.js.map +1 -1
  9. package/dist/components/form/engine/FormEngine.d.ts.map +1 -1
  10. package/dist/components/form/engine/FormEngine.js +65 -15
  11. package/dist/components/form/engine/FormEngine.js.map +1 -1
  12. package/dist/components/form/engine/OptionFieldMessages.d.ts.map +1 -1
  13. package/dist/components/form/engine/OptionFieldMessages.js +12 -1
  14. package/dist/components/form/engine/OptionFieldMessages.js.map +1 -1
  15. package/dist/components/form/engine/compactRowContext.d.ts +2 -0
  16. package/dist/components/form/engine/compactRowContext.d.ts.map +1 -1
  17. package/dist/components/form/engine/compactRowContext.js.map +1 -1
  18. package/dist/components/form/engine/readFirst.d.ts.map +1 -1
  19. package/dist/components/form/engine/readFirst.js +5 -1
  20. package/dist/components/form/engine/readFirst.js.map +1 -1
  21. package/dist/components/form/expressions/ExpressionField.d.ts +21 -1
  22. package/dist/components/form/expressions/ExpressionField.d.ts.map +1 -1
  23. package/dist/components/form/expressions/ExpressionField.js +72 -14
  24. package/dist/components/form/expressions/ExpressionField.js.map +1 -1
  25. package/dist/components/form/expressions/builder/index.d.ts.map +1 -1
  26. package/dist/components/form/expressions/builder/index.js +16 -3
  27. package/dist/components/form/expressions/builder/index.js.map +1 -1
  28. package/dist/components/form/expressions/expressionOperands.d.ts +16 -0
  29. package/dist/components/form/expressions/expressionOperands.d.ts.map +1 -0
  30. package/dist/components/form/expressions/expressionOperands.js +97 -0
  31. package/dist/components/form/expressions/expressionOperands.js.map +1 -0
  32. package/dist/components/form/expressions/mockExpressions.d.ts.map +1 -1
  33. package/dist/components/form/expressions/mockExpressions.js +15 -0
  34. package/dist/components/form/expressions/mockExpressions.js.map +1 -1
  35. package/dist/components/form/expressions/renderExpressionToText.d.ts +2 -0
  36. package/dist/components/form/expressions/renderExpressionToText.d.ts.map +1 -1
  37. package/dist/components/form/expressions/renderExpressionToText.js +24 -5
  38. package/dist/components/form/expressions/renderExpressionToText.js.map +1 -1
  39. package/dist/components/form/expressions/textOfExpression.d.ts +18 -0
  40. package/dist/components/form/expressions/textOfExpression.d.ts.map +1 -0
  41. package/dist/components/form/expressions/textOfExpression.js +37 -0
  42. package/dist/components/form/expressions/textOfExpression.js.map +1 -0
  43. package/dist/components/form/expressions/useRenderExpression.d.ts.map +1 -1
  44. package/dist/components/form/expressions/useRenderExpression.js +7 -7
  45. package/dist/components/form/expressions/useRenderExpression.js.map +1 -1
  46. package/dist/components/form/fields/rich-text/RichText.d.ts +8 -1
  47. package/dist/components/form/fields/rich-text/RichText.d.ts.map +1 -1
  48. package/dist/components/form/fields/rich-text/RichText.js +10 -10
  49. package/dist/components/form/fields/rich-text/RichText.js.map +1 -1
  50. package/dist/components/form/fields/template/TemplateField.d.ts +6 -0
  51. package/dist/components/form/fields/template/TemplateField.d.ts.map +1 -1
  52. package/dist/components/form/fields/template/TemplateField.js +280 -55
  53. package/dist/components/form/fields/template/TemplateField.js.map +1 -1
  54. package/dist/components/form/fields/template/writtenAsText.d.ts +57 -0
  55. package/dist/components/form/fields/template/writtenAsText.d.ts.map +1 -0
  56. package/dist/components/form/fields/template/writtenAsText.js +203 -0
  57. package/dist/components/form/fields/template/writtenAsText.js.map +1 -0
  58. package/dist/components/form/index.d.ts +2 -0
  59. package/dist/components/form/index.d.ts.map +1 -1
  60. package/dist/components/form/index.js +7 -1
  61. package/dist/components/form/index.js.map +1 -1
  62. package/dist/components/smartEditor/useLspSession.d.ts +6 -0
  63. package/dist/components/smartEditor/useLspSession.d.ts.map +1 -1
  64. package/dist/components/smartEditor/useLspSession.js +7 -6
  65. package/dist/components/smartEditor/useLspSession.js.map +1 -1
  66. package/dist/helpers/templates.d.ts +18 -0
  67. package/dist/helpers/templates.d.ts.map +1 -1
  68. package/dist/helpers/templates.js +30 -1
  69. package/dist/helpers/templates.js.map +1 -1
  70. package/dist/helpers/validations.d.ts.map +1 -1
  71. package/dist/helpers/validations.js +98 -18
  72. package/dist/helpers/validations.js.map +1 -1
  73. package/package.json +1 -1
  74. package/src/components/dpqlEditor/DpqlEditor.tsx +11 -18
  75. package/src/components/dpqlEditor/types.ts +5 -0
  76. package/src/components/form/engine/CompactRow.tsx +31 -10
  77. package/src/components/form/engine/FormEngine.stories.tsx +656 -18
  78. package/src/components/form/engine/FormEngine.tsx +64 -22
  79. package/src/components/form/engine/FormEngineRemote.stories.tsx +5 -0
  80. package/src/components/form/engine/OptionFieldMessages.tsx +12 -1
  81. package/src/components/form/engine/compactRowContext.ts +2 -0
  82. package/src/components/form/engine/readFirst.ts +7 -1
  83. package/src/components/form/expressions/ExpressionField.stories.tsx +57 -9
  84. package/src/components/form/expressions/ExpressionField.tsx +179 -60
  85. package/src/components/form/expressions/builder/ExpressionBuilder.stories.tsx +8 -1
  86. package/src/components/form/expressions/builder/index.tsx +16 -3
  87. package/src/components/form/expressions/dpqlMockLanguage.ts +7 -2
  88. package/src/components/form/expressions/expressionOperands.ts +74 -0
  89. package/src/components/form/expressions/mockExpressions.ts +16 -4
  90. package/src/components/form/expressions/renderExpressionToText.ts +26 -9
  91. package/src/components/form/expressions/textOfExpression.ts +39 -0
  92. package/src/components/form/expressions/useRenderExpression.ts +9 -1
  93. package/src/components/form/fields/number/Number.stories.tsx +8 -7
  94. package/src/components/form/fields/rich-text/RichText.tsx +18 -10
  95. package/src/components/form/fields/template/TemplateField.stories.tsx +486 -18
  96. package/src/components/form/fields/template/TemplateField.tsx +506 -62
  97. package/src/components/form/fields/template/writtenAsText.ts +217 -0
  98. package/src/components/form/index.tsx +6 -0
  99. package/src/components/smartEditor/useLspSession.ts +15 -10
  100. package/src/helpers/templates.ts +35 -0
  101. package/src/helpers/validations.ts +83 -12
@@ -97,6 +97,7 @@ var RichText_1 = require("../rich-text/RichText");
97
97
  var common_1 = require("../../../../helpers/common");
98
98
  var singleLineString_1 = require("../../../../helpers/singleLineString");
99
99
  var optionUiTypes_1 = require("../../../../helpers/optionUiTypes");
100
+ var writtenAsText_1 = require("./writtenAsText");
100
101
  var rowMenuContext_1 = require("../../engine/rowMenuContext");
101
102
  /**
102
103
  * How long the author must pause before typed text is sent to the DPQL
@@ -261,10 +262,10 @@ var isTemplateAwareUiType = function (uiType, extra) {
261
262
  };
262
263
  exports.isTemplateAwareUiType = isTemplateAwareUiType;
263
264
  var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
264
- var _b, _c, _d;
265
- var rowMenu = _a.rowMenu, value = _a.value, name = _a.name, onChange = _a.onChange, _e = _a.component, Comp = _e === void 0 ? AutoFormField_1.AutoFormField : _e, templates = _a.templates, interfaceContext = _a.interfaceContext, // eslint-disable-line @typescript-eslint/no-unused-vars
266
- _f = _a.allowTemplates, // eslint-disable-line @typescript-eslint/no-unused-vars
267
- allowTemplates = _f === void 0 ? true : _f, allowFunctions = _a.allowFunctions, allowTextExpressions = _a.allowTextExpressions, extraActions = _a.extraActions, componentOverrides = _a.componentOverrides, _g = _a.allowCustomValues, allowCustomValues = _g === void 0 ? true : _g, _h = _a.filterTemplatesByType, filterTemplatesByType = _h === void 0 ? true : _h, filterTemplatesFunc = _a.filterTemplatesFunc, componentFromType = _a.componentFromType, isFunction = _a.isFunction, isDefaultFunction = _a.isDefaultFunction, isDefaultTemplate = _a.isDefaultTemplate, returnType = _a.returnType, level = _a.level, className = _a.className, menuItems = _a.menuItems, menuActions = _a.menuActions, menuTrailingItems = _a.menuTrailingItems, reorder = _a.reorder, label = _a.label, rest = __rest(_a, ["rowMenu", "value", "name", "onChange", "component", "templates", "interfaceContext", "allowTemplates", "allowFunctions", "allowTextExpressions", "extraActions", "componentOverrides", "allowCustomValues", "filterTemplatesByType", "filterTemplatesFunc", "componentFromType", "isFunction", "isDefaultFunction", "isDefaultTemplate", "returnType", "level", "className", "menuItems", "menuActions", "menuTrailingItems", "reorder", "label"]);
265
+ var _b, _c, _d, _e, _f, _g;
266
+ var rowMenu = _a.rowMenu, value = _a.value, name = _a.name, onChange = _a.onChange, _h = _a.component, Comp = _h === void 0 ? AutoFormField_1.AutoFormField : _h, templates = _a.templates, interfaceContext = _a.interfaceContext, // eslint-disable-line @typescript-eslint/no-unused-vars
267
+ _j = _a.allowTemplates, // eslint-disable-line @typescript-eslint/no-unused-vars
268
+ allowTemplates = _j === void 0 ? true : _j, allowFunctions = _a.allowFunctions, allowTextExpressions = _a.allowTextExpressions, valueTabs = _a.valueTabs, extraActions = _a.extraActions, componentOverrides = _a.componentOverrides, _k = _a.allowCustomValues, allowCustomValues = _k === void 0 ? true : _k, _l = _a.filterTemplatesByType, filterTemplatesByType = _l === void 0 ? true : _l, filterTemplatesFunc = _a.filterTemplatesFunc, componentFromType = _a.componentFromType, isFunction = _a.isFunction, isDefaultFunction = _a.isDefaultFunction, isDefaultTemplate = _a.isDefaultTemplate, returnType = _a.returnType, level = _a.level, className = _a.className, menuItems = _a.menuItems, menuActions = _a.menuActions, menuTrailingItems = _a.menuTrailingItems, reorder = _a.reorder, label = _a.label, rest = __rest(_a, ["rowMenu", "value", "name", "onChange", "component", "templates", "interfaceContext", "allowTemplates", "allowFunctions", "allowTextExpressions", "valueTabs", "extraActions", "componentOverrides", "allowCustomValues", "filterTemplatesByType", "filterTemplatesFunc", "componentFromType", "isFunction", "isDefaultFunction", "isDefaultTemplate", "returnType", "level", "className", "menuItems", "menuActions", "menuTrailingItems", "reorder", "label"]);
268
269
  var qorusTypes = (0, useQorusTypes_1.useQorusTypes)();
269
270
  var functions = (0, useExpressions_1.useExpressions)({
270
271
  allow: !!allowFunctions,
@@ -369,17 +370,53 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
369
370
  /** Where this field lands when it is empty: an untyped one in template mode — see above. */
370
371
  var emptyLandsOnTemplates = typeIsAnyLike && (hasTemplatesOnOffer || (!!allowCustomValues && !hasOnlyAllowedValues));
371
372
  var opensOnTemplates = isEmptyValue && emptyLandsOnTemplates;
372
- var _j = (0, react_2.useState)((isDefaultTemplate || (0, templates_1.isValueTemplate)(value) || !allowCustomValues || opensOnTemplates) &&
373
- allowTemplates), isTemplateState = _j[0], setIsTemplate = _j[1];
373
+ /* An untyped field holding null is written in the same text field, as `null`: the editor an untyped
374
+ field otherwise falls to drew null as an empty box, the same as a field holding nothing, so the
375
+ author could not tell the two apart (qorus#646). */
376
+ var nullWrittenAsText = value === null && typeIsAnyLike && !!allowCustomValues && !hasOnlyAllowedValues;
377
+ /* The tabs a value is entered on (qorus#646, David): Value · Expression · Visual where the field takes
378
+ templates and expressions written as text, Value · Template where it takes templates only, none where
379
+ it takes no templates. One value, three views: see `selectTab`. */
380
+ var valueTabIsText = (0, writtenAsText_1.isWrittenAsTextOnTheValueTab)(type) && !hasOnlyAllowedValues;
381
+ var tabsKind = !valueTabs || !allowTemplates || editorHandlesTemplates || rest.arg_schema ? undefined
382
+ : allowFunctions && allowTextExpressions && !hasOnlyAllowedValues ? 'full'
383
+ : 'template';
384
+ /** The value is an expression (its AST), as the host says. */
385
+ var valueIsExpression = !!(isFunction || isDefaultFunction) && value !== null && typeof value === 'object';
386
+ /** Where a saved value opens: an expression on Expression; a template on Value where it is written as
387
+ * text, else on Expression (or Template, for a template-only field); anything else on Value. */
388
+ var _m = (0, react_2.useState)(function () {
389
+ if (!tabsKind)
390
+ return 'value';
391
+ if (valueIsExpression)
392
+ return tabsKind === 'full' ? 'expression' : 'value';
393
+ if (typeof value === 'string' && (0, templates_1.isValueTemplate)(value) && !valueTabIsText) {
394
+ return tabsKind === 'full' ? 'expression' : 'template';
395
+ }
396
+ return 'value';
397
+ }), tab = _m[0], setTab = _m[1];
398
+ var opensInExpressionText = tabsKind === 'full' && tab === 'expression' && !valueIsExpression;
399
+ var tabsKindRef = (0, react_2.useRef)(tabsKind);
400
+ tabsKindRef.current = tabsKind;
401
+ /** What the Text view is seeded with when the value is not an expression yet; null outside it. */
402
+ var _o = (0, react_2.useState)(opensInExpressionText ? (0, writtenAsText_1.expressionTextOfValue)(value) : null), expressionSeed = _o[0], setExpressionSeed = _o[1];
403
+ var _p = (0, react_2.useState)(tabsKind ?
404
+ tab === 'template' || (tab === 'value' && valueTabIsText)
405
+ : (isDefaultTemplate ||
406
+ (0, templates_1.isValueTemplate)(value) ||
407
+ !allowCustomValues ||
408
+ opensOnTemplates ||
409
+ nullWrittenAsText) &&
410
+ !!allowTemplates), isTemplateState = _p[0], setIsTemplate = _p[1];
374
411
  var isTemplate = editorHandlesTemplates ? false : isTemplateState;
375
- var _k = (0, react_2.useState)(!!isDefaultFunction && !!allowFunctions), internalIsFunction = _k[0], setInternalIsFunction = _k[1];
376
- var _l = (0, react_2.useState)(value), templateValue = _l[0], setTemplateValue = _l[1];
412
+ var _q = (0, react_2.useState)(tabsKind ? tab === 'expression' || tab === 'visual' : !!isDefaultFunction && !!allowFunctions), internalIsFunction = _q[0], setInternalIsFunction = _q[1];
413
+ var _r = (0, react_2.useState)(value), templateValue = _r[0], setTemplateValue = _r[1];
377
414
  // Typed text that turned out to be an expression the author may accept.
378
- var _m = (0, react_2.useState)(null), dpqlOffer = _m[0], setDpqlOffer = _m[1];
415
+ var _s = (0, react_2.useState)(null), dpqlOffer = _s[0], setDpqlOffer = _s[1];
379
416
  // The literal this field held before typed text switched it into
380
417
  // expression mode — kept so the switch is undoable, and so the editor
381
418
  // opens on the Text view the author was already writing in.
382
- var _o = (0, react_2.useState)(null), expressionFromText = _o[0], setExpressionFromText = _o[1];
419
+ var _t = (0, react_2.useState)(null), expressionFromText = _t[0], setExpressionFromText = _t[1];
383
420
  // Texts the author has said no to. Without this, dismissing an offer (or
384
421
  // undoing a switch) would re-detect the same text on the next render and
385
422
  // ask again forever.
@@ -392,6 +429,12 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
392
429
  if (isTemplate && (0, templates_1.isValueTemplate)(value)) {
393
430
  setTemplateValue(value);
394
431
  }
432
+ /* Emptied from outside the editor - the card's "Clear value", an undo, a host's reset - the text the
433
+ value is written in is emptied too. It kept its own copy, so a cleared value went on showing what it
434
+ had held (qorus#646: "Clear value" had no effect). The editor's own emptying sets this already. */
435
+ if (isEmptyValue && templateValue) {
436
+ setTemplateValue(null);
437
+ }
395
438
  }, [JSON.stringify(value)]);
396
439
  /* Clearing an untyped field returns it to the template selector, which is
397
440
  where mounting it empty already lands.
@@ -450,8 +493,19 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
450
493
  setIsTemplate(false);
451
494
  }
452
495
  }, [allowCustomValues]);
496
+ // null arriving later (written in the Text tab, say) is written in the text field too - see above
497
+ (0, react_2.useEffect)(function () {
498
+ if (!isTemplate && nullWrittenAsText && allowTemplates) {
499
+ setTemplateValue(null);
500
+ setIsTemplate(true);
501
+ }
502
+ }, [nullWrittenAsText, allowTemplates]);
453
503
  (0, react_2.useEffect)(function () {
454
- if (!isTemplate && (0, templates_1.isValueTemplate)(value) && allowTemplates) {
504
+ // a template on the Expression tab stays there: it is the expression editor's to show
505
+ if (!isTemplate &&
506
+ (0, templates_1.isValueTemplate)(value) &&
507
+ allowTemplates &&
508
+ !(tabsKind && internalIsFunction)) {
455
509
  // In auto mode, leave user-typed dollar-strings alone ('$foo: hello'
456
510
  // passes the loose check) — but a string that IS one well-formed token
457
511
  // ($data:{…}, $config:item) must still flip into template mode, or an
@@ -478,20 +532,19 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
478
532
  // When template key or template value change run the onChange function
479
533
  (0, react_use_1.useUpdateEffect)(function () {
480
534
  if (templateValue) {
535
+ /* Read from the text where the field is written as text: a lone template takes its own
536
+ type in an untyped field, a scalar's literal is that literal, other text is text. */
537
+ if (templateSupportsCustomValues) {
538
+ var read = (0, writtenAsText_1.templateTextValue)(templateValue, type, filteredTemplates);
539
+ onChange === null || onChange === void 0 ? void 0 : onChange(name, read.value, read.type, effectiveIsFunction);
540
+ return;
541
+ }
481
542
  onChange === null || onChange === void 0 ? void 0 : onChange(name, templateValue, type, effectiveIsFunction);
482
543
  }
483
544
  }, [JSON.stringify(templateValue)]);
484
545
  // an editor that takes templates into its own text has no template mode to switch to: "Use Template"
485
546
  // there emptied the field and showed nothing in its place
486
547
  var showTemplateToggle = allowCustomValues && allowTemplates && !rest.arg_schema && !editorHandlesTemplates;
487
- // Only a BRACED context ref (`$data:{…}` — machine-written, nobody types
488
- // one) renders as the picker chip (named via `resolveTemplateLabel`)
489
- // rather than as its raw text in a string editor. Plain word-path tokens
490
- // (`$local:id`) are typeable, so per the build #123 review they keep the
491
- // input that offers templates while typing. Mixed text-and-token strings
492
- // keep the string editor too; the chip-in-editor treatment arrives with
493
- // the rich-text string mode.
494
- var templateValueIsBracedToken = (0, templates_1.isBracedTemplateToken)(templateValue);
495
548
  /* An UNTYPED field can be typed into as well as picked from.
496
549
 
497
550
  Template mode has a typable editor whenever the field's type can hold
@@ -507,9 +560,16 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
507
560
  specific to that field: every empty untyped field with templates on
508
561
  offer got the same downgrade. The editor still offers the same templates
509
562
  on focus, so nothing is lost by being able to type as well. */
510
- var templateSupportsCustomValues = allowCustomValues && (type === 'string' || typeIsAnyLike) && !hasOnlyAllowedValues;
563
+ /* And so can a scalar: a whole number, a number or a yes/no is written as text too
564
+ (qorus#646). A template chosen into it is a chip in that text, not a pick-only
565
+ control that holds the template and nothing else, so text can be written around it;
566
+ what the field then holds is read from the text (writtenAsText). A date keeps its
567
+ date control. */
568
+ var templateSupportsCustomValues = allowCustomValues && (0, writtenAsText_1.isWrittenAsText)(type) && !hasOnlyAllowedValues;
511
569
  var showTemplatesDropdown = allowTemplates && (!allowCustomValues || (isTemplate && !templateSupportsCustomValues));
512
570
  var hasOnlyExpressions = !allowCustomValues && !allowTemplates && allowFunctions;
571
+ /** A date field with templates on offer: they are offered beside its date control. */
572
+ var dateTakesTemplates = type === 'date' && !!allowTemplates && hasTemplatesOnOffer && !hasOnlyAllowedValues;
513
573
  // True when some input control renders besides the ⋮ menu. When nothing
514
574
  // does (an empty `any` field: custom values are disallowed and the value's
515
575
  // type is picked FROM the menu), the menu trigger is the field's only
@@ -529,8 +589,11 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
529
589
  /* Emptying the text leaves the field where an empty field lands. For
530
590
  an untyped field that is THIS editor: switching to custom mode here
531
591
  mounted a different editor in its place, so deleting the last
532
- character lost the cursor. */
533
- if (!(emptyLandsOnTemplates && allowTemplates)) {
592
+ character lost the cursor. A field written as text (a whole number, a
593
+ number, a yes/no) is the same: deleting the template in it left a
594
+ different, empty editor in its place, and what was typed next went
595
+ nowhere. */
596
+ if (!((emptyLandsOnTemplates || templateSupportsCustomValues) && allowTemplates)) {
534
597
  setIsTemplate(false);
535
598
  }
536
599
  setTemplateValue(null);
@@ -539,7 +602,7 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
539
602
  else {
540
603
  setTemplateValue(val);
541
604
  }
542
- }, [name, onChange, emptyLandsOnTemplates, allowTemplates]);
605
+ }, [name, onChange, emptyLandsOnTemplates, templateSupportsCustomValues, allowTemplates]);
543
606
  var handleTemplateTextChange = (0, react_2.useCallback)(function (val) { return handleTemplateFieldChange(name, typeof val === 'string' ? val : ''); }, [handleTemplateFieldChange, name]);
544
607
  var handleSelectTemplateFromList = (0, react_2.useCallback)(
545
608
  // If the field has allowed values and supports templates, we do not want to overwrite the field type with the template type
@@ -576,6 +639,15 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
576
639
  // SEAM (reqraft): the IDE computes `canSaveValue` here and renders a
577
640
  // `SaveValueButton` in the controls menu — the saved-values storage is
578
641
  // IDE-only, so the menu item is dropped (`allowSaving` is inert).
642
+ /* A template chosen beside a date control is the value at once, IN the template control: handed to
643
+ the form while the field was still drawing its date control, the reference reached the date
644
+ picker first, which threw on it ("Invalid ISO 8601 date time string"). */
645
+ var handleSelectDateTemplate = (0, react_2.useCallback)(function (item) {
646
+ if (typeof (item === null || item === void 0 ? void 0 : item.value) !== 'string')
647
+ return;
648
+ setIsTemplate(true);
649
+ setTemplateValue(item.value);
650
+ }, []);
579
651
  var handleRemoveTemplateClick = (0, react_2.useCallback)(function () {
580
652
  /* This is the `×` ON the template control, and it means "I do not want a
581
653
  template here" — on a field whose menu offers no `Set Custom Value` it
@@ -631,6 +703,45 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
631
703
  onChange === null || onChange === void 0 ? void 0 : onChange(name, undefined);
632
704
  }
633
705
  }, [name, onChange, value, templateValue]);
706
+ /* One value, three views (qorus#646, David). Value → Expression writes the literal or template as
707
+ expression text, emitting nothing until it is edited. Expression ↔ Visual is the editor's own toggle.
708
+ Expression → Value converts only a literal or a lone template; any other expression stays, and the
709
+ Value tab says it cannot show it and offers to replace it. Nothing is lost silently. */
710
+ var selectTab = (0, react_2.useCallback)(function (next) {
711
+ if (next === tab)
712
+ return;
713
+ if (next === 'value' || next === 'template') {
714
+ if (valueIsExpression) {
715
+ var envelope = { is_expression: true, value: value };
716
+ var template = (0, writtenAsText_1.loneTemplateOf)(envelope);
717
+ var literal = template === undefined ? (0, writtenAsText_1.loneValueOf)(envelope) : undefined;
718
+ if (template !== undefined) {
719
+ setTemplateValue(template);
720
+ onChange === null || onChange === void 0 ? void 0 : onChange(name, template, type, false);
721
+ }
722
+ else if (literal !== undefined) {
723
+ setTemplateValue((0, writtenAsText_1.valueTextOf)(literal.value, type) || null);
724
+ onChange === null || onChange === void 0 ? void 0 : onChange(name, literal.value, type, false);
725
+ }
726
+ }
727
+ setInternalIsFunction(false);
728
+ setExpressionFromText(null);
729
+ setIsTemplate(next === 'template' || valueTabIsText);
730
+ }
731
+ else {
732
+ if (!valueIsExpression)
733
+ setExpressionSeed((0, writtenAsText_1.expressionTextOfValue)(value));
734
+ setInternalIsFunction(true);
735
+ }
736
+ setTab(next);
737
+ }, [tab, valueIsExpression, value, name, onChange, type, valueTabIsText]);
738
+ /** Replace what a tab cannot show with an empty value of its own kind. */
739
+ var replaceWithAValue = (0, react_2.useCallback)(function () {
740
+ setInternalIsFunction(false);
741
+ setTemplateValue(null);
742
+ setExpressionSeed(null);
743
+ onChange === null || onChange === void 0 ? void 0 : onChange(name, undefined, type, false);
744
+ }, [name, onChange, type]);
634
745
  var handleTemplateToggleClick = (0, react_2.useCallback)(function () {
635
746
  setInternalIsFunction(false);
636
747
  onChange(name, undefined, undefined, false);
@@ -640,11 +751,29 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
640
751
  var handleExpressionChange = (0, react_2.useCallback)(function (expressionValue, remove) {
641
752
  if (remove) {
642
753
  setInternalIsFunction(false);
754
+ setExpressionSeed(null);
643
755
  // The expression is gone, so there is no longer a switch to undo.
644
756
  setExpressionFromText(null);
645
757
  }
758
+ /* On the Expression tab, a lone template is the template: stored bare, as every consumer
759
+ evaluates it (see `loneTemplateOf`) - the server evaluates its expression form, template(...),
760
+ to the template's parts, not to its value. The Text view stays, seeded with it. */
761
+ var onTabs = !!tabsKindRef.current;
762
+ var lone = remove || !onTabs ? undefined : (0, writtenAsText_1.loneTemplateOf)(expressionValue);
763
+ if (lone !== undefined) {
764
+ setExpressionSeed(lone);
765
+ onChange(name, lone, type, false);
766
+ return;
767
+ }
768
+ // and a lone value (12, true) is that value, the field's own shape (see `loneValueOf`)
769
+ var literal = remove || !onTabs ? undefined : (0, writtenAsText_1.loneValueOf)(expressionValue);
770
+ if (literal !== undefined) {
771
+ setExpressionSeed((0, writtenAsText_1.expressionSeedOf)(literal.value));
772
+ onChange(name, literal.value, type, false);
773
+ return;
774
+ }
646
775
  onChange(name, expressionValue === null || expressionValue === void 0 ? void 0 : expressionValue.value, expressionDataType, !remove);
647
- }, [name, onChange, expressionDataType, value]);
776
+ }, [name, onChange, expressionDataType, value, type]);
648
777
  // ─── Text typed into a plain field that is really a DPQL expression ───
649
778
  //
650
779
  // A field that accepts expressions still gets DPQL TYPED into it, in the
@@ -678,6 +807,9 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
678
807
  setInternalIsFunction(true);
679
808
  setIsTemplate(false);
680
809
  setTemplateValue(null);
810
+ // the Value tab never holds an expression: detected, it moves to the Expression tab, with an undo
811
+ if (tabsKindRef.current === 'full')
812
+ setTab('expression');
681
813
  // `dpql/parse` answers with the field-ready envelope
682
814
  // (`{is_expression, value}`); this field stores the inner AST and
683
815
  // signals the flag through `onChange`'s fourth argument, exactly as
@@ -690,6 +822,10 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
690
822
  }
691
823
  declinedTexts.current.add(expressionFromText);
692
824
  setInternalIsFunction(false);
825
+ if (tabsKind) {
826
+ setTab('value');
827
+ setIsTemplate(valueTabIsText);
828
+ }
693
829
  setExpressionFromText(null);
694
830
  onChange === null || onChange === void 0 ? void 0 : onChange(name, expressionFromText, type, false);
695
831
  }, [expressionFromText, name, onChange, type]);
@@ -719,7 +855,8 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
719
855
  var canDetectDpql = !!allowFunctions &&
720
856
  !!allowTextExpressions &&
721
857
  !effectiveIsFunction &&
722
- !isTemplate &&
858
+ // the template editor is text too: an expression written around a template is detected there
859
+ (!isTemplate || templateSupportsCustomValues) &&
723
860
  !hasOnlyAllowedValues &&
724
861
  !rest.readonly &&
725
862
  !rest.readOnly &&
@@ -760,7 +897,8 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
760
897
  return;
761
898
  }
762
899
  var outcome = (0, dpqlDetection_1.classifyTypedText)({ text: text, type: type, field: validationField, parsed: parsed });
763
- if (outcome === 'switch') {
900
+ // on tabs, an expression detected switches (with an undo) rather than being offered
901
+ if (outcome === 'switch' || (outcome === 'offer' && tabsKindRef.current === 'full')) {
764
902
  enterExpressionRef.current(text, parsed.expression);
765
903
  }
766
904
  else if (outcome === 'offer') {
@@ -794,26 +932,28 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
794
932
  the row's — so leaving this out of the published list meant template mode
795
933
  was a one-way door on the surface most options are edited from. */
796
934
  var canOfferCustomValue = showTemplateToggle && isTemplate && templateSupportsCustomValues;
797
- var publishedItems = (0, react_2.useMemo)(function () { return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], (canOfferExpression && !functions.loading
798
- ? [
799
- {
800
- label: 'Use Expression',
801
- icon: 'Functions',
802
- tooltip: 'Run a function on this value',
803
- onClick: handleSelectFunctionChange,
804
- },
805
- ]
806
- : []), true), (canOfferTemplate
807
- ? [
808
- {
809
- label: 'Use Template',
810
- icon: 'MoneyDollarCircleLine',
811
- tooltip: 'Use a template',
812
- onClick: handleTemplateToggleClick,
813
- },
814
- ]
815
- : []), true), (canOfferCustomValue
816
- ? [
935
+ var publishedItems = (0, react_2.useMemo)(function () { return __spreadArray(__spreadArray(__spreadArray([], (tabsKind ?
936
+ []
937
+ : __spreadArray(__spreadArray([], (canOfferExpression && !functions.loading ?
938
+ [
939
+ {
940
+ label: 'Use Expression',
941
+ icon: 'Functions',
942
+ tooltip: 'Run a function on this value',
943
+ onClick: handleSelectFunctionChange,
944
+ },
945
+ ]
946
+ : []), true), (canOfferTemplate ?
947
+ [
948
+ {
949
+ label: 'Use Template',
950
+ icon: 'MoneyDollarCircleLine',
951
+ tooltip: 'Use a template',
952
+ onClick: handleTemplateToggleClick,
953
+ },
954
+ ]
955
+ : []), true)), true), (canOfferCustomValue && !tabsKind ?
956
+ [
817
957
  {
818
958
  label: 'Use Custom Value',
819
959
  icon: 'EditLine',
@@ -854,12 +994,20 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
854
994
  ].join(',');
855
995
  (0, rowMenuContext_1.useRowMenuPublisher)(rowMenu, publishedKey, publishedItems);
856
996
  var renderControls = (0, react_2.useCallback)(function () {
857
- var showFunctionsDropdown = allowFunctions && !hasOnlyAllowedValues && !rest.readonly && !internalIsFunction;
858
- var showTemplatesButton = showTemplateToggle && !isTemplate;
997
+ // on tabs, the tabs are the mode switch: the menu keeps value actions only
998
+ var showFunctionsDropdown = !tabsKind &&
999
+ allowFunctions &&
1000
+ !hasOnlyAllowedValues &&
1001
+ !rest.readonly &&
1002
+ !internalIsFunction;
1003
+ var showTemplatesButton = !tabsKind && showTemplateToggle && !isTemplate;
859
1004
  // The way back out of template mode, where the editor draws no `×`.
860
- var showCustomValueButton = showTemplateToggle && isTemplate && templateSupportsCustomValues;
1005
+ var showCustomValueButton = !tabsKind && showTemplateToggle && isTemplate && templateSupportsCustomValues;
861
1006
  // The "Set value" label promises a way to set one — reorder rows alone don't.
862
- var hasValueRows = showFunctionsDropdown || showTemplatesButton || showCustomValueButton || (0, lodash_1.size)(menuItems) > 0;
1007
+ var hasValueRows = showFunctionsDropdown ||
1008
+ showTemplatesButton ||
1009
+ showCustomValueButton ||
1010
+ (0, lodash_1.size)(menuItems) > 0;
863
1011
  /* A lone group opens itself. Two of the menu's groups are collapsed
864
1012
  sections, so a menu holding nothing but one of them asked for a click
865
1013
  to reach the only thing on offer — on an untyped field, "Set Custom
@@ -940,7 +1088,7 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
940
1088
  functions.loading ?
941
1089
  (0, jsx_runtime_1.jsx)(reqore_1.ReqoreSkeleton, { size: rest.size })
942
1090
  : (0, jsx_runtime_1.jsx)(reqore_1.ReqoreButton, { compact: true, transparent: true, label: 'Use Expression', className: 'function-selector', icon: 'Functions', tooltip: 'Run a function on this value', onClick: handleSelectFunctionChange })
943
- : null, showTemplatesButton ?
1091
+ : null, showTemplatesButton && !(showFunctionsDropdown && allowTextExpressions) ?
944
1092
  (0, jsx_runtime_1.jsxs)(reqore_1.ReqoreButton, { transparent: true, icon: 'MoneyDollarCircleLine', className: 'template-toggle', tooltip: 'Use a template', compact: true, size: rest.size, onClick: handleTemplateToggleClick, children: [' ', "Use Template", ' '] })
945
1093
  : null, showCustomValueButton ?
946
1094
  (0, jsx_runtime_1.jsxs)(reqore_1.ReqoreButton, { transparent: true, icon: 'EditLine', className: 'template-custom-value', tooltip: 'Write the value here instead of choosing a template', compact: true, size: rest.size, onClick: handleUseCustomValueClick, children: [' ', "Use Custom Value", ' '] })
@@ -959,6 +1107,7 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
959
1107
  handleSelectFunctionChange,
960
1108
  handleTemplateToggleClick,
961
1109
  handleUseCustomValueClick,
1110
+ allowTextExpressions,
962
1111
  hasOnlyAllowedValues,
963
1112
  isTemplate,
964
1113
  rest.readonly,
@@ -977,6 +1126,7 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
977
1126
  hasInputAffordance,
978
1127
  // the row decides whether this field draws a menu at all
979
1128
  rowMenu,
1129
+ tabsKind,
980
1130
  ]);
981
1131
  // When the type is a list, and it has an element type - that element type is different
982
1132
  // from the field type, so we need to send down the full templates object
@@ -998,6 +1148,67 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
998
1148
  rest.element_type,
999
1149
  type,
1000
1150
  ]);
1151
+ // ─── Value · Expression · Visual (or Value · Template) ───────────────────────────────────────────
1152
+ if (tabsKind && !rest.disabled) {
1153
+ var tabButton = function (key, label, icon, tooltip) { return ((0, jsx_runtime_1.jsx)(reqore_1.ReqoreButton, { compact: true, size: rest.size, icon: icon, active: tab === key, "aria-pressed": tab === key, "data-tab": label, className: "value-tab value-tab-".concat(key), tooltip: tooltip, disabled: rest.readOnly || rest.readonly, onClick: function () { return selectTab(key); }, children: label }, key)); };
1154
+ /* A lone template of another type than the field's is converted when the value is used: said as a
1155
+ warning, not a block - whether it converts depends on the data (qorus#646, David). */
1156
+ var loneTemplate_1 = typeof value === 'string' && (0, templates_1.isCompleteTemplateToken)(value) ? value : undefined;
1157
+ var templateBadge = loneTemplate_1 && !typeIsAnyLike ?
1158
+ (_e = (0, templates_1.findTemplate)(templates !== null && templates !== void 0 ? templates : {}, loneTemplate_1)) === null || _e === void 0 ? void 0 : _e.badge
1159
+ : undefined;
1160
+ var conversionNote_1 = (typeof templateBadge === 'string' &&
1161
+ templateBadge &&
1162
+ !(0, writtenAsText_1.sameValueType)(templateBadge, type)) ?
1163
+ "".concat((0, writtenAsText_1.templateTypeName)(templateBadge), " is converted to ").concat((0, writtenAsText_1.templateTypeName)(type).toLowerCase(), " when the value is used; a value that does not convert fails")
1164
+ : undefined;
1165
+ var cannotShow_1 = function (message) { return ((0, jsx_runtime_1.jsxs)(reqore_1.ReqoreMessage, { size: 'small', flat: true, opaque: false, intent: 'muted', className: 'value-tab-cannot-show', children: [message, ' ', (0, jsx_runtime_1.jsx)(reqore_1.ReqoreButton, { compact: true, size: rest.size, className: 'value-tab-replace', onClick: replaceWithAValue, disabled: rest.readOnly || rest.readonly, children: "Replace it with a value" })] })); };
1166
+ var valueBody = function () {
1167
+ var _a;
1168
+ if (valueIsExpression) {
1169
+ return cannotShow_1("This expression can't be shown as a value.");
1170
+ }
1171
+ if (valueTabIsText) {
1172
+ return ((0, jsx_runtime_1.jsxs)(reqore_1.ReqoreControlGroup, { vertical: true, fluid: true, gapSize: 'small', children: [(0, jsx_runtime_1.jsx)(RichText_1.RichTextFormField, __assign({ className: 'template-selector value-tab-text', valueFormat: 'text', singleLine: (0, singleLineString_1.isSingleLineStringType)('string'), value: typeof templateValue === 'string' ? templateValue : ((0, writtenAsText_1.valueTextOf)(value, type)), templates: filteredTemplates,
1173
+ // a chip of a field not of this type is named as the catalogue names it
1174
+ namingTemplates: templates, allowTemplates: true, onChange: handleTemplateTextChange }, rest, { fixed: false, fluid: true, panelProps: __assign(__assign({}, rest.panelProps), { style: __assign(__assign({}, (_a = rest.panelProps) === null || _a === void 0 ? void 0 : _a.style), { width: '150px', maxWidth: '100%', minWidth: 'fit-content' }) }), "aria-label": fieldAriaLabel })), conversionNote_1 ?
1175
+ (0, jsx_runtime_1.jsx)(reqore_1.ReqoreMessage, { size: 'small', flat: true, opaque: false, intent: 'warning', className: 'value-tab-conversion', children: conversionNote_1 })
1176
+ : null] }));
1177
+ }
1178
+ if (loneTemplate_1 !== undefined || (typeof value === 'string' && (0, templates_1.isValueTemplate)(value))) {
1179
+ return cannotShow_1("A template is shown on the ".concat(tabsKind === 'full' ? 'Expression' : 'Template', " tab, not here."));
1180
+ }
1181
+ return ((0, jsx_runtime_1.jsx)(Component, __assign({ value: value, allowTemplates: false, onChange: onChange, name: name, level: level }, rest, { componentOverrides: componentOverrides }, componentTypeProp, { "aria-label": fieldAriaLabel, className: "".concat(className, " template-selector") })));
1182
+ };
1183
+ var expressionBody = function () { return ((0, jsx_runtime_1.jsxs)(reqore_1.ReqoreControlGroup, { vertical: true, fluid: true, gapSize: 'small', children: [(0, jsx_runtime_1.jsx)(reqore_1.ReqoreErrorBoundary, { children: (0, jsx_runtime_1.jsx)(ExpressionField_1.ExpressionField
1184
+ /* A value that is not an expression yet is shown as the server reads it written alone:
1185
+ value(12) - so the Visual tab starts from the value, not from an operand with no operation. */
1186
+ , {
1187
+ /* A value that is not an expression yet is shown as the server reads it written alone:
1188
+ value(12) - so the Visual tab starts from the value, not from an operand with no operation. */
1189
+ value: {
1190
+ is_expression: true,
1191
+ value: value !== null && typeof value === 'object' ? value
1192
+ : !isEmptyValue && value !== null ?
1193
+ { exp: 'value', args: [{ type: type, value: value }] }
1194
+ : undefined,
1195
+ }, initialText: expressionSeed !== null && expressionSeed !== void 0 ? expressionSeed : undefined, heldAsValue: !isEmptyValue && value !== null && typeof value !== 'object', componentOverrides: componentOverrides, localTemplates: templates, type: type, returnType: (returnType || expressionDataType), onChange: handleExpressionChange, readOnly: rest.readOnly || rest.disabled, expressions: rest.expressions, expressionsUrl: rest.expressions_url, fields: rest.dpql_fields, serverHandled: rest.server_expression_handling, extraActions: extraActions, size: rest.size, defaultMode: tab === 'visual' ? 'visual' : 'text', requestedMode: tab === 'visual' ? 'visual' : 'text', hideModeToggle: true,
1196
+ // no language server: the Visual tab is where the expression is built
1197
+ onTextUnavailable: function () { return setTab('visual'); }, reorder: reorder }) }), expressionFromText !== null ?
1198
+ (0, jsx_runtime_1.jsx)(reqore_1.ReqoreButton, { fixed: true, compact: true, minimal: true, icon: 'ArrowGoBackLine', size: rest.size, className: 'dpql-detected-undo', tooltip: "Keep \"".concat(expressionFromText, "\" as a value instead"), onClick: undoExpressionFromText, children: "Undo" })
1199
+ : null] })); };
1200
+ var templateBody = function () { return ((0, jsx_runtime_1.jsx)(exports.TemplateDropdownSelector, { allowCustomValues: false, templates: templates, value: typeof value === 'string' && (0, templates_1.isValueTemplate)(value) ? value : null, items: filteredTemplates === null || filteredTemplates === void 0 ? void 0 : filteredTemplates.items, onItemSelect: handleSelectTemplateFromList, onRemoveClick: replaceWithAValue, size: rest.size, label: label, hasOnlyAllowedValues: hasOnlyAllowedValues })); };
1201
+ return ((0, jsx_runtime_1.jsxs)(reqore_1.ReqoreControlGroup, { vertical: true, fluid: true, gapSize: 'small', className: 'value-tabs-field', children: [(0, jsx_runtime_1.jsxs)(reqore_1.ReqoreControlGroup, { fluid: true, size: rest.size, verticalAlign: 'center', children: [(0, jsx_runtime_1.jsxs)(reqore_1.ReqoreControlGroup, { stack: true, size: rest.size, className: 'value-tabs', fixed: true, children: [tabButton('value', 'Value', 'EditLine'), tabsKind === 'full' ?
1202
+ [
1203
+ tabButton('expression', 'Expression', 'CodeLine', 'Write an expression - it also takes templates'),
1204
+ tabButton('visual', 'Visual', 'NodeTree', 'Build the expression visually'),
1205
+ ]
1206
+ : tabButton('template', 'Template', 'MoneyDollarCircleLine', 'Choose a template')] }), renderControls()] }), tab === 'value' ?
1207
+ valueBody()
1208
+ : tab === 'template' ?
1209
+ templateBody()
1210
+ : expressionBody()] }));
1211
+ }
1001
1212
  if (effectiveIsFunction && !hasOnlyAllowedValues) {
1002
1213
  // SEAM (reqraft): `allowTextExpressions` swaps the IDE's bare builder
1003
1214
  // for the ExpressionField shell (Visual = the same builder, Text = the
@@ -1042,12 +1253,26 @@ var TemplateFieldImpl = (0, react_2.memo)(function (_a) {
1042
1253
  }
1043
1254
  return ((0, jsx_runtime_1.jsxs)(reqore_1.ReqoreControlGroup, __assign({ fluid: rest.fluid, fixed: rest.fixed, size: rest.size }, rest, { stack: false, verticalAlign: 'flex-start', children: [!isTemplate && allowCustomValues ?
1044
1255
  (0, jsx_runtime_1.jsx)(Component, __assign({ value: value, allowTemplates: allowTemplates, onChange: onChange, name: name, level: level }, rest, { componentOverrides: componentOverrides }, componentTypeProp, { "aria-label": fieldAriaLabel, className: "".concat(className, " template-selector"), templates: componentTemplates }))
1045
- : null, isTemplate && templateSupportsCustomValues && !templateValueIsBracedToken ?
1046
- (0, jsx_runtime_1.jsx)(RichText_1.RichTextFormField, __assign({ className: 'template-selector', valueFormat: 'text', singleLine: (0, singleLineString_1.isSingleLineStringType)('string'), value: typeof templateValue === 'string' ? templateValue : '', templates: filteredTemplates, allowTemplates: true, onChange: handleTemplateTextChange }, rest, { "aria-label": fieldAriaLabel }))
1256
+ : null, !isTemplate && allowCustomValues && dateTakesTemplates ?
1257
+ (0, jsx_runtime_1.jsx)(reqore_1.ReqoreDropdown, { className: 'date-template-picker', icon: 'MoneyDollarCircleLine', fixed: true, compact: true, size: rest.size, tooltip: 'Use a template', "aria-label": 'Use a template', filterable: true, items: filteredTemplates === null || filteredTemplates === void 0 ? void 0 : filteredTemplates.items, onItemSelect: handleSelectDateTemplate })
1258
+ : null, isTemplate && templateSupportsCustomValues ?
1259
+ (0, jsx_runtime_1.jsx)(RichText_1.RichTextFormField, __assign({ className: 'template-selector', valueFormat: 'text', singleLine: (0, singleLineString_1.isSingleLineStringType)('string'),
1260
+ /* null shows as null, not as an empty field: the two are different values, and an
1261
+ untyped field holding null looked exactly like one holding nothing (qorus#646) */
1262
+ value: typeof templateValue === 'string' ? templateValue : (((_f = (0, writtenAsText_1.untypedTextOf)(value, type)) !== null && _f !== void 0 ? _f : '')), templates: filteredTemplates,
1263
+ // a chip of a field not of this type (text around it, say) is named as the catalogue names it
1264
+ namingTemplates: templates, allowTemplates: true, onChange: handleTemplateTextChange }, rest, {
1265
+ /* The text the value is written in takes the room its row gives it and gives it back: a
1266
+ caller's \`fixed\` sized a picker chip, and on a text field it kept the field at its full
1267
+ width, pushing the ⋮ past an operand's row in a narrow column. */
1268
+ fixed: false, fluid: true,
1269
+ /* 150px wide, as a free text field is, wider for what it holds, and narrower only where its
1270
+ row has less room - an operand in a narrow column - as a number's input is: a fixed
1271
+ 150px minimum held it at full width there. */
1272
+ panelProps: __assign(__assign({}, rest.panelProps), { style: __assign(__assign({}, (_g = rest.panelProps) === null || _g === void 0 ? void 0 : _g.style), { width: '150px', maxWidth: '100%', minWidth: 'fit-content' }) }), "aria-label": fieldAriaLabel }))
1047
1273
  : null, dpqlOffer ?
1048
1274
  (0, jsx_runtime_1.jsxs)(reqore_1.ReqoreControlGroup, { fixed: true, stack: true, size: rest.size, children: [(0, jsx_runtime_1.jsx)(reqore_1.ReqoreButton, { compact: true, icon: 'Functions', intent: 'info', className: 'dpql-detected-offer', tooltip: "\"".concat(dpqlOffer.text, "\" reads as an expression. It is also valid text here, so nothing has been changed \u2014 use it as an expression?"), onClick: acceptDpqlOffer, children: "Use as expression" }), (0, jsx_runtime_1.jsx)(reqore_1.ReqoreButton, { compact: true, icon: 'CloseLine', intent: 'info', className: 'dpql-detected-dismiss', tooltip: 'Keep it as plain text', onClick: declineDpqlOffer })] })
1049
- : null, (showTemplatesDropdown ||
1050
- (isTemplate && templateSupportsCustomValues && templateValueIsBracedToken)) ?
1275
+ : null, showTemplatesDropdown ?
1051
1276
  (0, jsx_runtime_1.jsx)(exports.TemplateDropdownSelector, { allowCustomValues: allowCustomValues, templates: templates, value: templateValue, items: filteredTemplates === null || filteredTemplates === void 0 ? void 0 : filteredTemplates.items, onItemSelect: handleSelectTemplateFromList, onRemoveClick: handleRemoveTemplateClick, size: rest.size, label: label, hasOnlyAllowedValues: hasOnlyAllowedValues })
1052
1277
  : null, renderControls()] })));
1053
1278
  });