@qoretechnologies/reqraft 0.10.45 → 0.10.46-pr.107.g08386aa

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.
@@ -61,6 +61,7 @@ import { SchemaDataView, canRenderWithSchema } from './_structuredData/SchemaDat
61
61
  import { query } from '../../../utils/fetch';
62
62
  import {
63
63
  colorToCss,
64
+ findAllowedValueOption,
64
65
  formatBytes,
65
66
  formatOptionValue,
66
67
  getAllowedValueImage,
@@ -154,9 +155,7 @@ const MAX_INLINE_OPTION_ACTIONS = 2;
154
155
  */
155
156
  export const richtextItemText = (item: unknown): string | undefined =>
156
157
  item && typeof item === 'object' && (item as { type?: unknown }).type === 'richtext' ?
157
- richtextToString(
158
- (item as { value?: Parameters<typeof richtextToString>[0] }).value
159
- )
158
+ richtextToString((item as { value?: Parameters<typeof richtextToString>[0] }).value)
160
159
  : undefined;
161
160
 
162
161
  export const CompactRow = memo(
@@ -280,7 +279,10 @@ export const CompactRow = memo(
280
279
  const renderReadFirstValue = (
281
280
  field: IQorusFormField,
282
281
  schema: TQorusFormFieldSchema | undefined,
283
- formatted: string
282
+ formatted: string,
283
+ // The collapsed row gets one line and an ellipsis; the OPEN read-only
284
+ // row (see `isExpanded && readOnly` below) gets the whole value, wrapped.
285
+ full = false
284
286
  ): React.ReactNode => {
285
287
  const valueType = getValueType(field, schema);
286
288
  const wrapStyle: React.CSSProperties = {
@@ -289,12 +291,12 @@ export const CompactRow = memo(
289
291
  gap: 6,
290
292
  minWidth: 0,
291
293
  maxWidth: '100%',
294
+ ...(full ? { flexWrap: 'wrap' } : {}),
292
295
  };
293
- const textStyle: React.CSSProperties = {
294
- overflow: 'hidden',
295
- textOverflow: 'ellipsis',
296
- whiteSpace: 'nowrap',
297
- };
296
+ const textStyle: React.CSSProperties =
297
+ full ?
298
+ { whiteSpace: 'pre-wrap', overflowWrap: 'anywhere' }
299
+ : { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' };
298
300
 
299
301
  if (valueType === 'rgbcolor') {
300
302
  const swatch = colorToCss(field?.value);
@@ -430,7 +432,10 @@ export const CompactRow = memo(
430
432
  // reads as those strings. Without this the row fell through to the generic
431
433
  // list summary and printed a bare count ("1 item") above the structured
432
434
  // tree, never the address itself.
433
- if (Array.isArray(field?.value) && field.value.some((item) => richtextItemText(item) !== undefined)) {
435
+ if (
436
+ Array.isArray(field?.value) &&
437
+ field.value.some((item) => richtextItemText(item) !== undefined)
438
+ ) {
434
439
  const texts = field.value.map((item) => richtextItemText(item) ?? String(item ?? ''));
435
440
  return <span style={textStyle}>{texts.filter((text) => text !== '').join(', ')}</span>;
436
441
  }
@@ -465,8 +470,8 @@ export const CompactRow = memo(
465
470
  ?.metadata as TTemplateMeta | undefined
466
471
  )}
467
472
  />
468
- : <span key={index} style={{ whiteSpace: 'pre' }}>
469
- {collapseSummaryBreaks(segment.text)}
473
+ : <span key={index} style={{ whiteSpace: full ? 'pre-wrap' : 'pre' }}>
474
+ {full ? segment.text : collapseSummaryBreaks(segment.text)}
470
475
  </span>
471
476
  )}
472
477
  </span>
@@ -508,7 +513,7 @@ export const CompactRow = memo(
508
513
  tooltip={segment.text}
509
514
  {...getTemplateTagStyle(segment.item?.metadata as TTemplateMeta | undefined)}
510
515
  />
511
- : <span key={index} style={{ whiteSpace: 'pre' }}>
516
+ : <span key={index} style={{ whiteSpace: full ? 'pre-wrap' : 'pre' }}>
512
517
  {segment.text}
513
518
  </span>
514
519
  )}
@@ -517,7 +522,7 @@ export const CompactRow = memo(
517
522
  }
518
523
  }
519
524
 
520
- return formatted;
525
+ return full ? <span style={textStyle}>{formatted}</span> : formatted;
521
526
  };
522
527
 
523
528
  const schema = options?.[optionName];
@@ -614,6 +619,8 @@ export const CompactRow = memo(
614
619
  );
615
620
  };
616
621
  const required = !!(schema?.required || schema?.required_groups);
622
+ // The asterisk says "you have to fill this in". Read-only, nobody does.
623
+ const requiredMark = required && !readOnly;
617
624
  const removable =
618
625
  !readOnly && !schema?.preselected && !schema?.required && !schema?.required_groups;
619
626
  const changed = !hidden && !readOnly && hasOptionChanged(optionField?.value, optionName);
@@ -785,8 +792,7 @@ export const CompactRow = memo(
785
792
  // value is unset or scalar renders no inset, so fetching its schema would buy
786
793
  // a round trip per row and show nothing. `query` caches GETs, so rows sharing
787
794
  // an id (every row of one list) cost one request between them.
788
- const valueLooksStructured =
789
- !!optionField?.value && typeof optionField.value === 'object';
795
+ const valueLooksStructured = !!optionField?.value && typeof optionField.value === 'object';
790
796
 
791
797
  React.useEffect(() => {
792
798
  if (!argSchemaId || !valueLooksStructured) {
@@ -975,8 +981,13 @@ export const CompactRow = memo(
975
981
  })
976
982
  ) as TInfoMsg[])
977
983
  : [];
984
+ // Validation verdicts and dependency hints are the editor's: "text value
985
+ // is empty", "disabled until X is set" tell someone what to do next, and
986
+ // a reader has no next. A read-only row states the value and leaves it.
987
+ // The default-value note below is different — it says what applies when
988
+ // nothing is set, which is a fact about the record — and stays.
978
989
  const fieldMessages: TInfoMsg[] =
979
- infoActive ?
990
+ infoActive && !readOnly ?
980
991
  getOptionFieldMessages({
981
992
  schema: options || {},
982
993
  option: optionField || ({} as IQorusFormField),
@@ -1180,9 +1191,11 @@ export const CompactRow = memo(
1180
1191
  // in the same corner of the same column, so stating one as a chip and the
1181
1192
  // other as text made two spellings of one idea.
1182
1193
  const codeSizeNode =
1183
- valueType === 'code-editor' &&
1184
- typeof optionField?.value === 'string' &&
1185
- optionField.value !== '' ?
1194
+ (
1195
+ valueType === 'code-editor' &&
1196
+ typeof optionField?.value === 'string' &&
1197
+ optionField.value !== ''
1198
+ ) ?
1186
1199
  (() => {
1187
1200
  const { lines, chars } = describeCodeSize(optionField.value as string);
1188
1201
  return (
@@ -1198,7 +1211,7 @@ export const CompactRow = memo(
1198
1211
  })()
1199
1212
  : null;
1200
1213
 
1201
- if (isExpanded) {
1214
+ if (isExpanded && !readOnly) {
1202
1215
  if (inlineEditable) {
1203
1216
  const collapse = () => toggleExpandedOption(optionName);
1204
1217
  const editingRow = (
@@ -1612,10 +1625,12 @@ export const CompactRow = memo(
1612
1625
  // renderer is present — the count is the one thing the row cannot show you by
1613
1626
  // showing you the text, and it is what tells you there is more below.
1614
1627
  const lineCountNote =
1615
- !hidden &&
1616
- (schema as { ui_type?: string } | undefined)?.ui_type === 'markdown' &&
1617
- typeof optionField?.value === 'string' &&
1618
- isMultilineMarkdown(optionField.value) ?
1628
+ (
1629
+ !hidden &&
1630
+ (schema as { ui_type?: string } | undefined)?.ui_type === 'markdown' &&
1631
+ typeof optionField?.value === 'string' &&
1632
+ isMultilineMarkdown(optionField.value)
1633
+ ) ?
1619
1634
  `${optionField.value.trim().split('\n').length} lines`
1620
1635
  : undefined;
1621
1636
  const typeLabel =
@@ -1769,12 +1784,246 @@ export const CompactRow = memo(
1769
1784
  invalid: worstIntent === 'danger',
1770
1785
  warned: worstIntent === 'warning',
1771
1786
  });
1772
- const dotStatus = hidden || fieldDisabled ? undefined : rowStatus;
1787
+ // No dot at all in a read-only form: the dot reports progress on the
1788
+ // form, and a read view has no progress to report.
1789
+ const dotStatus = hidden || fieldDisabled || readOnly ? undefined : rowStatus;
1773
1790
  const dotColor =
1774
1791
  dotStatus === 'invalid' ? cDanger
1775
1792
  : dotStatus === 'todo' ? cWarning
1776
1793
  : dotStatus === 'set' ? cSuccess || cInfo
1777
1794
  : undefined;
1795
+ // ---------------------------------------------------------------------
1796
+ // Read-only, OPEN: a view of the value, never an editor.
1797
+ //
1798
+ // A read-only form used to open a row into the same editor the editable
1799
+ // form uses, with `readOnly` handed down and each editor left to honour
1800
+ // it. Some did, by disabling themselves — an id in a greyed-out input;
1801
+ // some did not — a choice that could still be changed. Either way the
1802
+ // reader was given a control, and the one thing a read view must never
1803
+ // hand over is a control.
1804
+ //
1805
+ // Opening a row here means "show me all of it": the value in full — the
1806
+ // text wrapped instead of cut at one line, the whole code block, every
1807
+ // field of a hash, the chosen option with what it means — and the
1808
+ // field's explanation under it. Nothing on the row is interactive except
1809
+ // the actions the host injected and Close.
1810
+ // ---------------------------------------------------------------------
1811
+ if (isExpanded && readOnly) {
1812
+ const collapse = () => toggleExpandedOption(optionName);
1813
+ const chosen = findAllowedValueOption(optionField?.value, schema) as
1814
+ { desc?: string; short_desc?: string } | undefined;
1815
+ const chosenDesc = empty ? undefined : chosen?.desc || chosen?.short_desc;
1816
+ const renderFullValue = (): React.ReactNode => {
1817
+ if (hidden || empty) {
1818
+ return <span className='options-readfirst-read-unset'>Not set</span>;
1819
+ }
1820
+ if (showStructuredPreview) {
1821
+ // Uncapped. The collapsed row shows the first rows of a hash under
1822
+ // a "Show more"; the open one is where the rest was promised.
1823
+ return (
1824
+ <div className='options-readfirst-structured'>
1825
+ {previewWithSchema ?
1826
+ <SchemaDataView
1827
+ value={optionField?.value}
1828
+ schema={previewArgSchema!}
1829
+ showTypes={showFieldTypes}
1830
+ colors={{
1831
+ key: cKey,
1832
+ muted: cMuted,
1833
+ border: `${cMuted}66`,
1834
+ accent:
1835
+ (theme?.intents as Record<string, string> | undefined)?.custom1 || cInfo,
1836
+ }}
1837
+ />
1838
+ : <StructuredDataView
1839
+ value={optionField?.value}
1840
+ collapsibleRoot={false}
1841
+ showTypes={showFieldTypes}
1842
+ defaultExpandDepth={6}
1843
+ />
1844
+ }
1845
+ </div>
1846
+ );
1847
+ }
1848
+ if (showCodePreview) {
1849
+ return codePreviewRenderer ?
1850
+ codePreviewRenderer({
1851
+ value: optionField.value as string,
1852
+ name: optionName,
1853
+ schema,
1854
+ options,
1855
+ values: availableOptions,
1856
+ })
1857
+ : <StyledCodePreview
1858
+ className='options-readfirst-code'
1859
+ $bg={cHover}
1860
+ $border={`${cDivider}88`}
1861
+ $fg={cKey}
1862
+ >
1863
+ {optionField.value as string}
1864
+ </StyledCodePreview>;
1865
+ }
1866
+ if (
1867
+ markdownRenderer &&
1868
+ (schema as { ui_type?: string } | undefined)?.ui_type === 'markdown' &&
1869
+ typeof optionField?.value === 'string'
1870
+ ) {
1871
+ return (
1872
+ <div className='options-readfirst-markdown'>
1873
+ {markdownRenderer({ value: optionField.value, compact: true })}
1874
+ </div>
1875
+ );
1876
+ }
1877
+ return (
1878
+ <span className='options-readfirst-read-full'>
1879
+ {renderReadFirstValue(optionField, schema, formatted, true)}
1880
+ </span>
1881
+ );
1882
+ };
1883
+ return (
1884
+ <StyledColumn
1885
+ key={optionName}
1886
+ data-field={optionName}
1887
+ className={clusterBlockClass || undefined}
1888
+ >
1889
+ <div
1890
+ data-field={optionName}
1891
+ className='readfirst-row readfirst-row-editing readfirst-row-reading options-readfirst-reading options-readfirst-value'
1892
+ style={
1893
+ readRowHeights.current[optionName] ?
1894
+ { minHeight: readRowHeights.current[optionName] }
1895
+ : undefined
1896
+ }
1897
+ {...clusterHoverProps}
1898
+ >
1899
+ <StyledLabelBlock className='options-readfirst-label-block'>
1900
+ <StyledRowLabel
1901
+ role='button'
1902
+ tabIndex={0}
1903
+ aria-label={`Collapse ${label}`}
1904
+ title={schema?.short_desc || undefined}
1905
+ $color={cKey}
1906
+ $pointer
1907
+ onClick={collapse}
1908
+ onKeyDown={(event) => {
1909
+ if (event.key === 'Enter' || event.key === ' ') {
1910
+ event.preventDefault();
1911
+ collapse();
1912
+ }
1913
+ }}
1914
+ >
1915
+ {rowChromeIcon}
1916
+ <span className='options-readfirst-label-text' style={{ minWidth: 0 }}>
1917
+ {label}
1918
+ {helpIcon}
1919
+ </span>
1920
+ {typeLabel ?
1921
+ <ReqoreTag
1922
+ size='tiny'
1923
+ minimal
1924
+ label={typeLabel}
1925
+ labelEffect={{ opacity: 0.55 }}
1926
+ />
1927
+ : null}
1928
+ </StyledRowLabel>
1929
+ {labelShortDesc ?
1930
+ <StyledLabelDesc
1931
+ className='options-readfirst-label-desc'
1932
+ size='small'
1933
+ effect={{ opacity: 0.55 }}
1934
+ >
1935
+ {labelShortDesc}
1936
+ </StyledLabelDesc>
1937
+ : null}
1938
+ {codeSizeNode}
1939
+ {lineCountNote ?
1940
+ <ReqoreP
1941
+ className='options-readfirst-label-lines'
1942
+ size='tiny'
1943
+ effect={{ opacity: 0.45, textAlign: 'left' }}
1944
+ style={{ fontFamily: 'monospace' }}
1945
+ >
1946
+ {lineCountNote}
1947
+ </ReqoreP>
1948
+ : null}
1949
+ </StyledLabelBlock>
1950
+ <StyledRowValue
1951
+ className='options-readfirst-read-value'
1952
+ $color={empty || hidden ? `${cMuted}66` : cKey}
1953
+ $empty={empty || hidden}
1954
+ >
1955
+ <div className='options-readfirst-read-body'>{renderFullValue()}</div>
1956
+ {/* A choice reads as the option AND what the option means:
1957
+ "Authenticated users — callers must present a token". The
1958
+ picker showed that description while choosing; the reader
1959
+ gets it without a picker. */}
1960
+ {chosenDesc ?
1961
+ <ReqoreP
1962
+ className='options-readfirst-read-choice-desc'
1963
+ size='small'
1964
+ effect={{ opacity: 0.6 }}
1965
+ >
1966
+ {chosenDesc}
1967
+ </ReqoreP>
1968
+ : null}
1969
+ {valueReasons.map((m, i) => (
1970
+ <span
1971
+ key={`${m.content}-${i}`}
1972
+ className='options-readfirst-reason'
1973
+ style={{ color: reasonColor(m.intent) }}
1974
+ >
1975
+ {m.content}
1976
+ </span>
1977
+ ))}
1978
+ {panelMessages.length ?
1979
+ <ReqoreControlGroup
1980
+ className='options-readfirst-info-panel'
1981
+ vertical
1982
+ fluid
1983
+ gapSize='normal'
1984
+ >
1985
+ {panelMessages.map(renderInfoStrip)}
1986
+ </ReqoreControlGroup>
1987
+ : null}
1988
+ {/* The long description, inline. The `?` still opens it in a
1989
+ dialog, but the reader opened THIS row to learn about this
1990
+ field, and the explanation belongs where they are looking. */}
1991
+ {schema?.desc && schema.desc !== schema.short_desc ?
1992
+ <div className='options-readfirst-read-desc'>
1993
+ <Description
1994
+ longDescription={schema.desc}
1995
+ longDescriptionOnly
1996
+ longDescriptionShownByDefault
1997
+ compact
1998
+ margin='none'
1999
+ />
2000
+ </div>
2001
+ : null}
2002
+ </StyledRowValue>
2003
+ <StyledRowActions>
2004
+ {inlineOptionActions.map((action, index) =>
2005
+ renderInjectedOptionAction(action, index)
2006
+ )}
2007
+ {injectedOptionActionMenuItems.length ?
2008
+ <ReqoreDropdown
2009
+ className='options-injected-actions-menu'
2010
+ icon='MoreFill'
2011
+ flat
2012
+ minimal
2013
+ fixed
2014
+ size='small'
2015
+ tooltip='Field actions'
2016
+ items={injectedOptionActionMenuItems}
2017
+ />
2018
+ : null}
2019
+ {closeExpandedFieldButton}
2020
+ </StyledRowActions>
2021
+ {clusterNode}
2022
+ </div>
2023
+ </StyledColumn>
2024
+ );
2025
+ }
2026
+
1778
2027
  const row = (
1779
2028
  <div
1780
2029
  key={optionName}
@@ -1802,7 +2051,7 @@ export const CompactRow = memo(
1802
2051
  stays right after the last word even when the name wraps. */}
1803
2052
  <span className='options-readfirst-label-text' style={{ minWidth: 0 }}>
1804
2053
  {label}
1805
- {required ?
2054
+ {requiredMark ?
1806
2055
  <ReqoreIcon
1807
2056
  icon='Asterisk'
1808
2057
  color='danger'
@@ -145,24 +145,26 @@ export const CompactToolbar = memo((reqoreProps: Partial<IReqoreControlGroupProp
145
145
 
146
146
  return (
147
147
  <ReqoreControlGroup {...reqoreProps} vertical fluid fixed={false} gapSize='big'>
148
- {parts.completion && completion.total ?
148
+ {/* No completion in a read-only form. The meter answers "how much is
149
+ left to do", and a reader can do none of it: "4/6 set · 67%" over a
150
+ form nobody can fill in is a progress report on somebody else's
151
+ work. The read view lists what is set, and that is the whole
152
+ answer. */}
153
+ {parts.completion && completion.total && !readOnly ?
149
154
  <StyledCompletion className='options-readfirst-completion'>
150
155
  <StyledCompletionLine>
151
- {!readOnly ?
152
- <StyledSummary
153
- className='options-readfirst-status'
154
- $color={invalidCount ? cWarning : cSuccess}
155
- style={{ fontWeight: 600 }}
156
- >
157
- {invalidCount ? 'Draft' : 'Ready'}
158
- </StyledSummary>
159
- : null}
156
+ <StyledSummary
157
+ className='options-readfirst-status'
158
+ $color={invalidCount ? cWarning : cSuccess}
159
+ style={{ fontWeight: 600 }}
160
+ >
161
+ {invalidCount ? 'Draft' : 'Ready'}
162
+ </StyledSummary>
160
163
  <StyledSummary style={{ opacity: 0.5 }}>
161
- {!readOnly ? '· ' : ''}
162
- {completion.set}/{completion.total} set
163
- {!readOnly && attentionCount ? ' ·' : ''}
164
+ · {completion.set}/{completion.total} set
165
+ {attentionCount ? ' ·' : ''}
164
166
  </StyledSummary>
165
- {!readOnly && attentionCount ?
167
+ {attentionCount ?
166
168
  <StyledAttentionLink
167
169
  $color={cWarning}
168
170
  className='options-readfirst-attention-link'