@qoretechnologies/reqraft 0.10.10 → 0.10.13-pr.74.gccefa54

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 (155) hide show
  1. package/.claude/CLAUDE.md +11 -8
  2. package/dist/components/composer/Composer.d.ts +108 -0
  3. package/dist/components/composer/Composer.d.ts.map +1 -0
  4. package/dist/components/composer/Composer.js +238 -0
  5. package/dist/components/composer/Composer.js.map +1 -0
  6. package/dist/components/composer/helpers.d.ts +21 -0
  7. package/dist/components/composer/helpers.d.ts.map +1 -0
  8. package/dist/components/composer/helpers.js +75 -0
  9. package/dist/components/composer/helpers.js.map +1 -0
  10. package/dist/components/composer/index.d.ts +3 -0
  11. package/dist/components/composer/index.d.ts.map +1 -0
  12. package/dist/components/composer/index.js +19 -0
  13. package/dist/components/composer/index.js.map +1 -0
  14. package/dist/components/form/engine/FormEngine.d.ts +1 -1
  15. package/dist/components/imageLightbox/ImageLightbox.d.ts +17 -0
  16. package/dist/components/imageLightbox/ImageLightbox.d.ts.map +1 -0
  17. package/dist/components/imageLightbox/ImageLightbox.js +129 -0
  18. package/dist/components/imageLightbox/ImageLightbox.js.map +1 -0
  19. package/dist/components/imageLightbox/index.d.ts +2 -0
  20. package/dist/components/imageLightbox/index.d.ts.map +1 -0
  21. package/dist/components/imageLightbox/index.js +18 -0
  22. package/dist/components/imageLightbox/index.js.map +1 -0
  23. package/dist/components/supportTicket/AttachmentChips.d.ts +10 -0
  24. package/dist/components/supportTicket/AttachmentChips.d.ts.map +1 -0
  25. package/dist/components/supportTicket/AttachmentChips.js +119 -0
  26. package/dist/components/supportTicket/AttachmentChips.js.map +1 -0
  27. package/dist/components/supportTicket/InterfaceReferenceTags.d.ts +35 -0
  28. package/dist/components/supportTicket/InterfaceReferenceTags.d.ts.map +1 -0
  29. package/dist/components/supportTicket/InterfaceReferenceTags.js +31 -0
  30. package/dist/components/supportTicket/InterfaceReferenceTags.js.map +1 -0
  31. package/dist/components/supportTicket/ReferencePicker.d.ts +41 -0
  32. package/dist/components/supportTicket/ReferencePicker.d.ts.map +1 -0
  33. package/dist/components/supportTicket/ReferencePicker.js +86 -0
  34. package/dist/components/supportTicket/ReferencePicker.js.map +1 -0
  35. package/dist/components/supportTicket/TicketHeader.d.ts +86 -0
  36. package/dist/components/supportTicket/TicketHeader.d.ts.map +1 -0
  37. package/dist/components/supportTicket/TicketHeader.js +149 -0
  38. package/dist/components/supportTicket/TicketHeader.js.map +1 -0
  39. package/dist/components/supportTicket/TicketMetaTags.d.ts +32 -0
  40. package/dist/components/supportTicket/TicketMetaTags.d.ts.map +1 -0
  41. package/dist/components/supportTicket/TicketMetaTags.js +21 -0
  42. package/dist/components/supportTicket/TicketMetaTags.js.map +1 -0
  43. package/dist/components/supportTicket/TicketReplyBox.d.ts +63 -0
  44. package/dist/components/supportTicket/TicketReplyBox.d.ts.map +1 -0
  45. package/dist/components/supportTicket/TicketReplyBox.js +115 -0
  46. package/dist/components/supportTicket/TicketReplyBox.js.map +1 -0
  47. package/dist/components/supportTicket/fileToAttachment.d.ts +9 -0
  48. package/dist/components/supportTicket/fileToAttachment.d.ts.map +1 -0
  49. package/dist/components/supportTicket/fileToAttachment.js +28 -0
  50. package/dist/components/supportTicket/fileToAttachment.js.map +1 -0
  51. package/dist/components/supportTicket/index.d.ts +9 -0
  52. package/dist/components/supportTicket/index.d.ts.map +1 -0
  53. package/dist/components/supportTicket/index.js +25 -0
  54. package/dist/components/supportTicket/index.js.map +1 -0
  55. package/dist/components/supportTicket/meta.d.ts +63 -0
  56. package/dist/components/supportTicket/meta.d.ts.map +1 -0
  57. package/dist/components/supportTicket/meta.js +79 -0
  58. package/dist/components/supportTicket/meta.js.map +1 -0
  59. package/dist/components/ticketReferences/TicketReferences.d.ts +52 -0
  60. package/dist/components/ticketReferences/TicketReferences.d.ts.map +1 -0
  61. package/dist/components/ticketReferences/TicketReferences.js +453 -0
  62. package/dist/components/ticketReferences/TicketReferences.js.map +1 -0
  63. package/dist/components/ticketReferences/index.d.ts +3 -0
  64. package/dist/components/ticketReferences/index.d.ts.map +1 -0
  65. package/dist/components/ticketReferences/index.js +6 -0
  66. package/dist/components/ticketReferences/index.js.map +1 -0
  67. package/dist/components/ticketThread/TicketThread.d.ts +52 -0
  68. package/dist/components/ticketThread/TicketThread.d.ts.map +1 -0
  69. package/dist/components/ticketThread/TicketThread.js +248 -0
  70. package/dist/components/ticketThread/TicketThread.js.map +1 -0
  71. package/dist/components/ticketThread/index.d.ts +3 -0
  72. package/dist/components/ticketThread/index.d.ts.map +1 -0
  73. package/dist/components/ticketThread/index.js +7 -0
  74. package/dist/components/ticketThread/index.js.map +1 -0
  75. package/dist/helpers/common.d.ts +5 -0
  76. package/dist/helpers/common.d.ts.map +1 -1
  77. package/dist/helpers/common.js +20 -1
  78. package/dist/helpers/common.js.map +1 -1
  79. package/dist/helpers/scrollbar.d.ts +2 -0
  80. package/dist/helpers/scrollbar.d.ts.map +1 -0
  81. package/dist/helpers/scrollbar.js +25 -0
  82. package/dist/helpers/scrollbar.js.map +1 -0
  83. package/dist/index.d.ts +5 -0
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +7 -1
  86. package/dist/index.js.map +1 -1
  87. package/package.json +3 -3
  88. package/src/components/composer/Composer.stories.tsx +238 -0
  89. package/src/components/composer/Composer.tsx +545 -0
  90. package/src/components/composer/helpers.ts +74 -0
  91. package/src/components/composer/index.ts +2 -0
  92. package/src/components/dpqlEditor/DpqlEditor.stories.tsx +74 -2
  93. package/src/components/form/engine/FormEngine.stories.tsx +654 -32
  94. package/src/components/form/engine/FormEngineRemote.stories.tsx +48 -0
  95. package/src/components/form/engine/_structuredData/StructuredDataView.stories.tsx +8 -0
  96. package/src/components/form/engine/variants/FormEngineVariants.stories.tsx +40 -0
  97. package/src/components/form/expressions/ExpressionField.stories.tsx +74 -2
  98. package/src/components/form/expressions/builder/ExpressionBuilder.stories.tsx +187 -0
  99. package/src/components/form/fields/Field.stories.tsx +40 -0
  100. package/src/components/form/fields/array/ArrayAutoField.stories.tsx +64 -0
  101. package/src/components/form/fields/auto/AutoFormField.stories.tsx +136 -0
  102. package/src/components/form/fields/binary/Binary.stories.tsx +32 -0
  103. package/src/components/form/fields/boolean/Boolean.stories.tsx +24 -0
  104. package/src/components/form/fields/byte-size/ByteSize.stories.tsx +24 -0
  105. package/src/components/form/fields/color/Color.stories.tsx +30 -0
  106. package/src/components/form/fields/cron/Cron.stories.tsx +8 -0
  107. package/src/components/form/fields/date/Date.stories.tsx +22 -0
  108. package/src/components/form/fields/file/File.stories.tsx +48 -0
  109. package/src/components/form/fields/long-string/LongString.stories.tsx +24 -0
  110. package/src/components/form/fields/markdown/Markdown.stories.tsx +8 -0
  111. package/src/components/form/fields/number/Number.stories.tsx +31 -0
  112. package/src/components/form/fields/object/Object.stories.tsx +88 -0
  113. package/src/components/form/fields/radio-group/RadioGroup.stories.tsx +24 -0
  114. package/src/components/form/fields/rich-text/RichText.stories.tsx +23 -0
  115. package/src/components/form/fields/schema-definition/SchemaDefinitionField.stories.tsx +72 -0
  116. package/src/components/form/fields/select/Select.stories.tsx +104 -0
  117. package/src/components/form/fields/string/String.stories.tsx +16 -0
  118. package/src/components/form/fields/template/TemplateField.stories.tsx +160 -0
  119. package/src/components/form/fields/url/Url.stories.tsx +24 -0
  120. package/src/components/imageLightbox/ImageLightbox.stories.tsx +156 -0
  121. package/src/components/imageLightbox/ImageLightbox.tsx +169 -0
  122. package/src/components/imageLightbox/index.ts +1 -0
  123. package/src/components/log/Log.stories.tsx +96 -0
  124. package/src/components/menu/Menu.stories.tsx +54 -0
  125. package/src/components/qonsoleSmartInput/QonsoleSmartInput.stories.tsx +14 -0
  126. package/src/components/smartEditor/SmartEditor.stories.tsx +32 -0
  127. package/src/components/supportTicket/AttachmentChips.stories.tsx +122 -0
  128. package/src/components/supportTicket/AttachmentChips.tsx +142 -0
  129. package/src/components/supportTicket/InterfaceReferenceTags.stories.tsx +134 -0
  130. package/src/components/supportTicket/InterfaceReferenceTags.tsx +85 -0
  131. package/src/components/supportTicket/ReferencePicker.stories.tsx +296 -0
  132. package/src/components/supportTicket/ReferencePicker.tsx +237 -0
  133. package/src/components/supportTicket/TicketConversation.stories.tsx +122 -0
  134. package/src/components/supportTicket/TicketHeader.stories.tsx +183 -0
  135. package/src/components/supportTicket/TicketHeader.tsx +247 -0
  136. package/src/components/supportTicket/TicketMetaTags.stories.tsx +103 -0
  137. package/src/components/supportTicket/TicketMetaTags.tsx +85 -0
  138. package/src/components/supportTicket/TicketReplyBox.stories.tsx +355 -0
  139. package/src/components/supportTicket/TicketReplyBox.tsx +146 -0
  140. package/src/components/supportTicket/fileToAttachment.ts +24 -0
  141. package/src/components/supportTicket/index.ts +8 -0
  142. package/src/components/supportTicket/meta.ts +145 -0
  143. package/src/components/ticketReferences/TicketReferences.stories.tsx +301 -0
  144. package/src/components/ticketReferences/TicketReferences.tsx +899 -0
  145. package/src/components/ticketReferences/index.ts +2 -0
  146. package/src/components/ticketThread/TicketThread.stories.tsx +751 -0
  147. package/src/components/ticketThread/TicketThread.tsx +650 -0
  148. package/src/components/ticketThread/index.ts +6 -0
  149. package/src/helpers/common.ts +19 -0
  150. package/src/helpers/scrollbar.ts +32 -0
  151. package/src/hooks/useFetch/useFetch.stories.tsx +30 -0
  152. package/src/hooks/useStorage/useStorage.stories.tsx +30 -0
  153. package/src/hooks/useWebSocket/useWebsocket.stories.tsx +127 -1
  154. package/src/index.tsx +5 -0
  155. package/src/stores/currentUser/currentUser.stories.tsx +17 -0
@@ -0,0 +1,122 @@
1
+ import { StoryObj } from '@storybook/react-vite';
2
+ import { useState } from 'react';
3
+ import { expect, userEvent, waitFor, within } from 'storybook/test';
4
+ import { StoryMeta } from '../../types';
5
+ import { AttachmentChips } from './AttachmentChips';
6
+
7
+ /**
8
+ * Staged-file chips for a ticket composer. Image files show a thumbnail and open the shared
9
+ * `ImageLightbox` on click; other files show a paperclip. The pencil renames a file inline
10
+ * (a File name is read-only, so the host swaps in a renamed copy); the ✕ removes it.
11
+ */
12
+ const meta = {
13
+ component: AttachmentChips,
14
+ title: 'Components/AttachmentChips',
15
+ } as StoryMeta<typeof AttachmentChips>;
16
+ export default meta;
17
+ type Story = StoryObj<typeof meta>;
18
+
19
+ const imageFile = (label: string, hue: number, name: string): File => {
20
+ const svg =
21
+ `<svg xmlns='http://www.w3.org/2000/svg' width='640' height='400'>` +
22
+ `<rect width='640' height='400' fill='hsl(${hue},40%,16%)'/>` +
23
+ `<text x='24' y='210' fill='white' font-family='sans-serif' font-size='30'>${label}</text></svg>`;
24
+ return new File([svg], name, { type: 'image/svg+xml' });
25
+ };
26
+ const textFile = (name: string): File => new File(['log contents'], name, { type: 'text/plain' });
27
+
28
+ const FILES = [
29
+ imageFile('before', 265, 'screenshot-2026-07-26-17-41-44.png'),
30
+ imageFile('after', 205, 'canvas-after.png'),
31
+ textFile('server.log'),
32
+ ];
33
+
34
+ // Plays the composer's role: owns the file set, swaps in a renamed copy on rename.
35
+ const Harness = () => {
36
+ const [files, setFiles] = useState<File[]>(FILES);
37
+ return (
38
+ <AttachmentChips
39
+ files={files}
40
+ onRemove={(index) => setFiles((current) => current.filter((_, j) => j !== index))}
41
+ onRename={(index, name) =>
42
+ setFiles((current) =>
43
+ current.map((file, i) => (i === index ? new File([file], name, { type: file.type }) : file))
44
+ )
45
+ }
46
+ />
47
+ );
48
+ };
49
+
50
+ /**
51
+ * Two screenshots + a log. Clicking a screenshot chip opens the lightbox (paging across the two
52
+ * images); the log stays a plain chip. Proves the preview opens and paints the image.
53
+ */
54
+ export const WithImages: Story = {
55
+ parameters: {
56
+ docs: {
57
+ description: {
58
+ story:
59
+ 'Renders staged chips for two screenshots and a log, where clicking a screenshot chip opens the shared lightbox while the log stays a plain chip.',
60
+ },
61
+ },
62
+ },
63
+ render: () => <Harness />,
64
+ play: async ({ canvasElement }) => {
65
+ const canvas = within(canvasElement);
66
+ await expect(canvas.getByText('screenshot-2026-07-26-17-41-44.png')).toBeInTheDocument();
67
+ await expect(canvas.getByText('server.log')).toBeInTheDocument();
68
+
69
+ // clicking an image chip opens the shared lightbox (portals to the body)
70
+ await userEvent.click(canvas.getByText('canvas-after.png'));
71
+ await waitFor(() => expect(document.querySelector('[role="dialog"]')).not.toBeNull());
72
+ await waitFor(() =>
73
+ expect(document.body.querySelector('img[alt="canvas-after.png"]')).not.toBeNull()
74
+ );
75
+ },
76
+ };
77
+
78
+ /**
79
+ * Renaming an auto-named screenshot: the pencil turns the chip into an inline input; Enter
80
+ * commits and the chip shows the new name. Discriminating — remove the rename wiring and the
81
+ * chip keeps its `screenshot-<timestamp>.png` name.
82
+ */
83
+ export const Rename: Story = {
84
+ parameters: {
85
+ docs: {
86
+ description: {
87
+ story:
88
+ 'Renders the staged chips and renames an auto-named screenshot inline — the pencil opens an input, Enter commits, and the chip shows the new name.',
89
+ },
90
+ },
91
+ },
92
+ render: () => <Harness />,
93
+ play: async ({ canvasElement }) => {
94
+ const canvas = within(canvasElement);
95
+ const chip = canvas.getByText('screenshot-2026-07-26-17-41-44.png').closest('.reqore-tag');
96
+ if (!chip) {
97
+ throw new Error('chip not found');
98
+ }
99
+ // click the rename pencil (its own action; the ✕ is a separate reqore-tag-remove)
100
+ const renameAction = chip.querySelector<HTMLElement>('.reqore-tag-action:not(.reqore-tag-remove)');
101
+ if (!renameAction) {
102
+ throw new Error('rename action not rendered');
103
+ }
104
+ await userEvent.click(renameAction);
105
+
106
+ // the inline input appears, pre-filled with the current name
107
+ const input = await waitFor(() => {
108
+ const el = canvasElement.querySelector<HTMLInputElement>('input');
109
+ if (!el) {
110
+ throw new Error('rename input not shown');
111
+ }
112
+ return el;
113
+ });
114
+ await userEvent.clear(input);
115
+ await userEvent.type(input, 'mapper-error.png');
116
+ await userEvent.keyboard('{Enter}');
117
+
118
+ // the chip now carries the new name; the auto-name is gone
119
+ await waitFor(() => expect(canvas.getByText('mapper-error.png')).toBeInTheDocument());
120
+ await expect(canvas.queryByText('screenshot-2026-07-26-17-41-44.png')).not.toBeInTheDocument();
121
+ },
122
+ };
@@ -0,0 +1,142 @@
1
+ import { ReqoreControlGroup, ReqoreInput, ReqoreTag } from '@qoretechnologies/reqore';
2
+ import { useEffect, useState } from 'react';
3
+ import { ImageLightbox } from '../imageLightbox';
4
+
5
+ /*
6
+ * Renders the files staged on a ticket composer as removable chips. Image files — whether
7
+ * uploaded, pasted, or captured as a screenshot — show a thumbnail and open the shared
8
+ * `ImageLightbox` on click (paging across the staged images, click-to-zoom); everything else
9
+ * shows a paperclip + filename. When `onRename` is given, a pencil turns the chip into an
10
+ * inline input so a captured `screenshot-<timestamp>.png` can be given a meaningful name (a
11
+ * File's name is read-only, so the host swaps in a renamed copy).
12
+ *
13
+ * The thumbnail object URLs ARE the full-image URLs the lightbox shows, so they're created
14
+ * once here and revoked when the file set changes or on unmount. Renders nothing when empty.
15
+ */
16
+
17
+ export interface IAttachmentChipsProps {
18
+ files: File[];
19
+ onRemove: (index: number) => void;
20
+ /** Rename a staged file. Omit to make chips non-renamable. The host replaces the File with a
21
+ * renamed copy (`new File([file], newName, { type: file.type })`). */
22
+ onRename?: (index: number, newName: string) => void;
23
+ disabled?: boolean;
24
+ }
25
+
26
+ export const AttachmentChips = ({ files, onRemove, onRename, disabled }: IAttachmentChipsProps) => {
27
+ const [thumbnails, setThumbnails] = useState<string[]>([]);
28
+ // index into the image subset that's open in the lightbox, or null when closed.
29
+ const [previewIndex, setPreviewIndex] = useState<number | null>(null);
30
+ // the file index currently being renamed inline, plus its working name.
31
+ const [editingIndex, setEditingIndex] = useState<number | null>(null);
32
+ const [draftName, setDraftName] = useState<string>('');
33
+
34
+ useEffect(() => {
35
+ const urls = files.map((file) =>
36
+ file.type.startsWith('image/') ? URL.createObjectURL(file) : ''
37
+ );
38
+ setThumbnails(urls);
39
+ return () => urls.forEach((url) => url && URL.revokeObjectURL(url));
40
+ }, [files]);
41
+
42
+ if (!files.length) {
43
+ return null;
44
+ }
45
+
46
+ // The staged images in order, each with its original file index + object URL — the set the
47
+ // lightbox pages across. Non-image files are skipped.
48
+ const imageEntries = files
49
+ .map((file, index) => ({ file, index, url: thumbnails[index] }))
50
+ .filter((entry) => entry.url);
51
+
52
+ const startRename = (index: number) => {
53
+ setDraftName(files[index].name);
54
+ setEditingIndex(index);
55
+ };
56
+ const commitRename = () => {
57
+ if (editingIndex === null) {
58
+ return;
59
+ }
60
+ const name = draftName.trim();
61
+ if (onRename && name && name !== files[editingIndex].name) {
62
+ onRename(editingIndex, name);
63
+ }
64
+ setEditingIndex(null);
65
+ };
66
+
67
+ return (
68
+ <>
69
+ <ReqoreControlGroup wrap gapSize='small' verticalAlign='center'>
70
+ {files.map((file, index) => {
71
+ if (editingIndex === index) {
72
+ return (
73
+ <ReqoreInput
74
+ key={`edit-${index}`}
75
+ value={draftName}
76
+ onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
77
+ setDraftName(event.target.value)
78
+ }
79
+ onBlur={commitRename}
80
+ onKeyDown={(event: React.KeyboardEvent) => {
81
+ if (event.key === 'Enter') {
82
+ commitRename();
83
+ } else if (event.key === 'Escape') {
84
+ setEditingIndex(null);
85
+ }
86
+ }}
87
+ size='small'
88
+ fixed
89
+ autoFocus
90
+ />
91
+ );
92
+ }
93
+
94
+ const thumbnail = thumbnails[index];
95
+ const imageIndex = thumbnail
96
+ ? imageEntries.findIndex((entry) => entry.index === index)
97
+ : -1;
98
+ const actions =
99
+ onRename && !disabled
100
+ ? [
101
+ {
102
+ icon: 'Edit2Line' as const,
103
+ tooltip: 'Rename',
104
+ onClick: (event: React.MouseEvent<HTMLDivElement>) => {
105
+ event.stopPropagation();
106
+ startRename(index);
107
+ },
108
+ },
109
+ ]
110
+ : undefined;
111
+ return (
112
+ <ReqoreTag
113
+ key={`${file.name}-${index}`}
114
+ icon={thumbnail ? undefined : 'AttachmentLine'}
115
+ leftIconProps={thumbnail ? { image: thumbnail } : undefined}
116
+ label={file.name}
117
+ size='small'
118
+ tooltip={thumbnail ? 'Click to preview' : undefined}
119
+ actions={actions}
120
+ onClick={thumbnail ? () => setPreviewIndex(imageIndex) : undefined}
121
+ onRemoveClick={disabled ? undefined : () => onRemove(index)}
122
+ />
123
+ );
124
+ })}
125
+ </ReqoreControlGroup>
126
+ {previewIndex !== null && imageEntries[previewIndex] ? (
127
+ <ImageLightbox
128
+ images={imageEntries.map((entry) => ({
129
+ attachment_id: String(entry.index),
130
+ filename: entry.file.name,
131
+ }))}
132
+ index={previewIndex}
133
+ onIndex={setPreviewIndex}
134
+ onClose={() => setPreviewIndex(null)}
135
+ fetchAttachmentUrl={async (id) =>
136
+ imageEntries.find((entry) => String(entry.index) === id)?.url ?? ''
137
+ }
138
+ />
139
+ ) : null}
140
+ </>
141
+ );
142
+ };
@@ -0,0 +1,134 @@
1
+ import { StoryObj } from '@storybook/react-vite';
2
+ import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
3
+ import { StoryMeta } from '../../types';
4
+ import { InterfaceReferenceTags } from './InterfaceReferenceTags';
5
+ import { IInterfaceReference } from './meta';
6
+
7
+ // Several references, including two of the same kind (workflow), as `{kind, name}`
8
+ // snapshots — no `resolveInterfaceIcon` is passed, so the built-in per-kind default
9
+ // icons are exercised.
10
+ const REFERENCES: IInterfaceReference[] = [
11
+ { interface_kind: 'workflow', interface_name: 'order-sync:1.2', reference_id: 'r1' },
12
+ { interface_kind: 'workflow', interface_name: 'invoice-sync:2.3', reference_id: 'r2' },
13
+ { interface_kind: 'service', interface_name: 'notification-svc', reference_id: 'r3' },
14
+ { interface_kind: 'job', interface_name: 'nightly-cleanup', reference_id: 'r4' },
15
+ ];
16
+
17
+ const meta = {
18
+ component: InterfaceReferenceTags,
19
+ title: 'Components/InterfaceReferenceTags',
20
+ args: {
21
+ references: REFERENCES,
22
+ label: 'References',
23
+ },
24
+ } as StoryMeta<typeof InterfaceReferenceTags>;
25
+
26
+ export default meta;
27
+ type Story = StoryObj<typeof meta>;
28
+
29
+ /** The ticket-header use: a "References" label followed by one chip per reference. */
30
+ export const Default: Story = {
31
+ parameters: {
32
+ docs: {
33
+ description: {
34
+ story:
35
+ "Renders the ticket-header use — a 'References' label followed by one chip per reference.",
36
+ },
37
+ },
38
+ },
39
+ async play({ canvasElement }) {
40
+ const canvas = within(canvasElement);
41
+ await expect(canvas.getByText('References')).toBeInTheDocument();
42
+ await expect(canvas.getByText('order-sync:1.2')).toBeInTheDocument();
43
+ await expect(canvas.getByText('invoice-sync:2.3')).toBeInTheDocument();
44
+ await expect(canvas.getByText('notification-svc')).toBeInTheDocument();
45
+ await expect(canvas.getByText('nightly-cleanup')).toBeInTheDocument();
46
+ },
47
+ };
48
+
49
+ /**
50
+ * When `onInterfaceClick` is passed the chips become interactive; clicking one
51
+ * calls it with that reference (the customer view, which can open the interface on
52
+ * its own instance, wires this).
53
+ */
54
+ export const Clickable: Story = {
55
+ parameters: {
56
+ docs: {
57
+ description: {
58
+ story:
59
+ 'Renders interactive chips by passing onInterfaceClick — clicking a chip calls it with that reference, as the customer view (which can open the interface on its own instance) wires.',
60
+ },
61
+ },
62
+ },
63
+ args: { onInterfaceClick: fn() },
64
+ async play({ canvasElement, args }) {
65
+ const canvas = within(canvasElement);
66
+ await userEvent.click(canvas.getByText('invoice-sync:2.3'));
67
+ await waitFor(() =>
68
+ expect(args.onInterfaceClick).toHaveBeenCalledWith(
69
+ expect.objectContaining({
70
+ interface_kind: 'workflow',
71
+ interface_name: 'invoice-sync:2.3',
72
+ })
73
+ )
74
+ );
75
+ },
76
+ };
77
+
78
+ /** The in-thread use: no label — the chips sit under a message. */
79
+ export const NoLabel: Story = {
80
+ parameters: {
81
+ docs: {
82
+ description: {
83
+ story:
84
+ 'Renders the in-thread use with label undefined — no label, just the chips as they sit under a message.',
85
+ },
86
+ },
87
+ },
88
+ args: { label: undefined },
89
+ async play({ canvasElement }) {
90
+ const canvas = within(canvasElement);
91
+ await expect(canvas.queryByText('References')).not.toBeInTheDocument();
92
+ await expect(canvas.getByText('order-sync:1.2')).toBeInTheDocument();
93
+ },
94
+ };
95
+
96
+ /**
97
+ * With no references the component renders nothing — no empty header, no chips —
98
+ * so a ticket without references shows a clean gap rather than a stray "References:"
99
+ * label. The dashed frame below is a story-only caption; the empty space inside it
100
+ * is the component.
101
+ */
102
+ export const Empty: Story = {
103
+ parameters: {
104
+ docs: {
105
+ description: {
106
+ story:
107
+ 'Renders the empty case — with no references the component renders nothing (no header, no chips), shown inside a dashed story-only caption frame.',
108
+ },
109
+ },
110
+ },
111
+ args: { references: [] },
112
+ decorators: [
113
+ (Story) => (
114
+ <div
115
+ style={{
116
+ border: '1px dashed rgba(150, 150, 150, 0.4)',
117
+ borderRadius: 6,
118
+ padding: 12,
119
+ fontSize: 12,
120
+ opacity: 0.6,
121
+ }}
122
+ >
123
+ No references → the row renders nothing (no empty header, no chips):
124
+ <Story />
125
+ </div>
126
+ ),
127
+ ],
128
+ async play({ canvasElement }) {
129
+ // The dashed frame + caption are the decorator; the component itself renders
130
+ // nothing — no header text, no chips.
131
+ await expect(within(canvasElement).queryByText('References')).not.toBeInTheDocument();
132
+ await expect(within(canvasElement).queryByText('order-sync:1.2')).not.toBeInTheDocument();
133
+ },
134
+ };
@@ -0,0 +1,85 @@
1
+ import { ReqoreControlGroup, ReqoreP, ReqoreTag } from '@qoretechnologies/reqore';
2
+ import { TSizes } from '@qoretechnologies/reqore/dist/constants/sizes';
3
+ import { IReqoreIconName } from '@qoretechnologies/reqore/dist/types/icons';
4
+ import { ComponentProps } from 'react';
5
+ import { defaultInterfaceIcon, IInterfaceReference } from './meta';
6
+
7
+ export interface IInterfaceReferenceTagsProps {
8
+ references?: IInterfaceReference[];
9
+ /** Optional leading label, e.g. "References" in a ticket header. Omitted (the
10
+ * default) inside the thread, where the chips sit under a message. */
11
+ label?: string;
12
+ /** Resolve a per-kind icon. Consumers with their own icon vocabulary (the IDE)
13
+ * pass one; when omitted the built-in per-kind default is used. */
14
+ resolveInterfaceIcon?: (kind: string) => IReqoreIconName;
15
+ /** Open a referenced interface; chips are static (informational) when omitted —
16
+ * e.g. the staff view, which can't reach the customer's instance. */
17
+ onInterfaceClick?: (reference: IInterfaceReference) => void;
18
+ size?: TSizes;
19
+ /** Chip styling — pass `intent`/`customTheme` (e.g. `{ main: 'custom1' }`) to tint
20
+ * the reference chips to a surface's accent (the Qonsole/helpdesk composer does). */
21
+ intent?: ComponentProps<typeof ReqoreTag>['intent'];
22
+ customTheme?: ComponentProps<typeof ReqoreTag>['customTheme'];
23
+ /** Resolve a per-reference image — e.g. a qog's trigger-app logo, the way the
24
+ * qogs list does. When this (or the reference's own `logo`) returns a value, the
25
+ * chip shows the image in place of the kind icon. */
26
+ resolveInterfaceImage?: (reference: IInterfaceReference) => string | undefined;
27
+ }
28
+
29
+ /**
30
+ * The chips for the Qorus interfaces a ticket or message references, as
31
+ * `{kind, name}` snapshots. The single renderer for interface references across
32
+ * every support surface — the ticket header (with a "References" label), the
33
+ * thread (per message, no label), and the Qonsole card — so a reference looks
34
+ * identical everywhere. Renders nothing when there are no references.
35
+ */
36
+ export const InterfaceReferenceTags = ({
37
+ references,
38
+ label,
39
+ resolveInterfaceIcon,
40
+ onInterfaceClick,
41
+ size = 'small',
42
+ intent,
43
+ customTheme,
44
+ resolveInterfaceImage,
45
+ }: IInterfaceReferenceTagsProps) => {
46
+ if (!references?.length) {
47
+ return null;
48
+ }
49
+ const resolveIcon = resolveInterfaceIcon ?? defaultInterfaceIcon;
50
+ return (
51
+ <ReqoreControlGroup verticalAlign='center' wrap gapSize='small'>
52
+ {label ? (
53
+ <ReqoreP size='small' effect={{ opacity: 0.6 }}>
54
+ {label}
55
+ </ReqoreP>
56
+ ) : null}
57
+ {references.map((reference) => {
58
+ // an app-triggered qog shows the trigger app's logo (stored, or resolved by
59
+ // a viewer with the app catalogue); everything else shows its kind glyph.
60
+ const image = reference.logo ?? resolveInterfaceImage?.(reference);
61
+ return (
62
+ <ReqoreTag
63
+ key={
64
+ reference.reference_id ??
65
+ `${reference.interface_kind}:${reference.interface_name}`
66
+ }
67
+ icon={image ? undefined : resolveIcon(reference.interface_kind)}
68
+ leftIconProps={image ? { image } : undefined}
69
+ labelKey={reference.interface_kind}
70
+ label={reference.interface_name}
71
+ size={size}
72
+ intent={intent}
73
+ customTheme={customTheme}
74
+ tooltip={
75
+ onInterfaceClick
76
+ ? `Open ${reference.interface_kind} ${reference.interface_name}`
77
+ : `${reference.interface_kind}: ${reference.interface_name}`
78
+ }
79
+ onClick={onInterfaceClick ? () => onInterfaceClick(reference) : undefined}
80
+ />
81
+ );
82
+ })}
83
+ </ReqoreControlGroup>
84
+ );
85
+ };