@harborclient/sdk 1.0.40 → 1.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CodeEditor/editorChrome.d.ts.map +1 -1
- package/dist/components/CodeEditor/editorChrome.js +53 -7
- package/dist/components/CodeEditor/index.d.ts +4 -2
- package/dist/components/CodeEditor/index.d.ts.map +1 -1
- package/dist/components/CodeEditor/index.js +6 -32
- package/dist/components/FormDataEditor/index.d.ts +4 -2
- package/dist/components/FormDataEditor/index.d.ts.map +1 -1
- package/dist/components/KeyValueEditor/index.d.ts +4 -2
- package/dist/components/KeyValueEditor/index.d.ts.map +1 -1
- package/dist/components/VariableInput/index.d.ts +4 -2
- package/dist/components/VariableInput/index.d.ts.map +1 -1
- package/dist/components/VariableInput/index.js +4 -4
- package/dist/components/VariableTable/index.d.ts +6 -2
- package/dist/components/VariableTable/index.d.ts.map +1 -1
- package/dist/components/VariableTable/index.js +41 -2
- package/dist/components/VariableTooltip/VariableTooltipValue.d.ts +21 -0
- package/dist/components/VariableTooltip/VariableTooltipValue.d.ts.map +1 -0
- package/dist/components/VariableTooltip/VariableTooltipValue.js +25 -0
- package/dist/components/VariableTooltip/dom.d.ts +19 -0
- package/dist/components/VariableTooltip/dom.d.ts.map +1 -0
- package/dist/components/VariableTooltip/dom.js +93 -0
- package/dist/components/VariableTooltip/index.d.ts +3 -0
- package/dist/components/VariableTooltip/index.d.ts.map +1 -0
- package/dist/components/VariableTooltip/index.js +2 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/snippets.d.ts +194 -7
- package/dist/types.d.ts +3 -3
- package/package.json +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorChrome.d.ts","sourceRoot":"","sources":["../../../src/components/CodeEditor/editorChrome.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;GAEG;AACH,eAAO,MAAM,cAAc,gBAUzB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa,gBAUxB,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"editorChrome.d.ts","sourceRoot":"","sources":["../../../src/components/CodeEditor/editorChrome.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;GAEG;AACH,eAAO,MAAM,cAAc,gBAUzB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa,gBAUxB,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,KAAK,CAAC,CAyIvF;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,OAAO,GACd,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAEvC"}
|
|
@@ -94,20 +94,66 @@ export function createEditorTheme(fontSize) {
|
|
|
94
94
|
flexDirection: 'column',
|
|
95
95
|
gap: '6px',
|
|
96
96
|
padding: '8px 12px',
|
|
97
|
-
fontSize,
|
|
97
|
+
fontSize: '16px',
|
|
98
98
|
color: 'var(--mac-text)'
|
|
99
99
|
},
|
|
100
|
-
'.cm-variable-tooltip-
|
|
100
|
+
'.cm-variable-tooltip-value-row': {
|
|
101
|
+
display: 'flex',
|
|
102
|
+
alignItems: 'center',
|
|
103
|
+
gap: '6px'
|
|
104
|
+
},
|
|
105
|
+
'.cm-variable-tooltip-value': {
|
|
106
|
+
boxSizing: 'border-box',
|
|
107
|
+
flex: '1 1 0%',
|
|
108
|
+
minWidth: '0',
|
|
109
|
+
borderRadius: '8px',
|
|
110
|
+
border: '1px solid var(--mac-separator)',
|
|
111
|
+
backgroundColor: 'var(--mac-field)',
|
|
112
|
+
padding: '6px 10px',
|
|
113
|
+
fontSize: '16px',
|
|
114
|
+
color: 'var(--mac-text)',
|
|
115
|
+
cursor: 'default'
|
|
116
|
+
},
|
|
117
|
+
'.cm-variable-tooltip-value-muted': {
|
|
101
118
|
color: 'var(--mac-muted)'
|
|
102
119
|
},
|
|
120
|
+
'.cm-variable-tooltip-copy': {
|
|
121
|
+
display: 'inline-flex',
|
|
122
|
+
flexShrink: '0',
|
|
123
|
+
alignItems: 'center',
|
|
124
|
+
justifyContent: 'center',
|
|
125
|
+
width: '30px',
|
|
126
|
+
height: '30px',
|
|
127
|
+
borderRadius: '9999px',
|
|
128
|
+
border: 'none',
|
|
129
|
+
backgroundColor: 'transparent',
|
|
130
|
+
color: 'var(--mac-muted)',
|
|
131
|
+
cursor: 'pointer'
|
|
132
|
+
},
|
|
133
|
+
'.cm-variable-tooltip-copy:hover': {
|
|
134
|
+
backgroundColor: 'var(--mac-selection)',
|
|
135
|
+
color: 'var(--mac-text)'
|
|
136
|
+
},
|
|
137
|
+
'.cm-variable-tooltip-copy-icon': {
|
|
138
|
+
display: 'block'
|
|
139
|
+
},
|
|
103
140
|
'.cm-variable-tooltip-edit': {
|
|
104
141
|
alignSelf: 'flex-start',
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
142
|
+
display: 'inline-flex',
|
|
143
|
+
alignItems: 'center',
|
|
144
|
+
justifyContent: 'center',
|
|
145
|
+
minHeight: '32px',
|
|
146
|
+
borderRadius: '9999px',
|
|
147
|
+
border: '1px solid var(--mac-separator)',
|
|
148
|
+
backgroundColor: 'var(--mac-control)',
|
|
149
|
+
padding: '4px 12px',
|
|
150
|
+
fontSize: '15px',
|
|
151
|
+
color: 'var(--mac-text)',
|
|
108
152
|
cursor: 'pointer',
|
|
109
|
-
|
|
110
|
-
|
|
153
|
+
boxShadow: '0 1px 2px rgba(0, 0, 0, 0.05)'
|
|
154
|
+
},
|
|
155
|
+
'.cm-variable-tooltip-edit:hover': {
|
|
156
|
+
backgroundColor: 'var(--mac-selection)'
|
|
111
157
|
},
|
|
112
158
|
'.cm-tooltip.cm-tooltip-autocomplete': {
|
|
113
159
|
border: '1px solid var(--mac-separator)',
|
|
@@ -155,9 +155,11 @@ export interface Props extends Omit<ComponentPropsWithoutRef<'div'>, 'children'
|
|
|
155
155
|
*/
|
|
156
156
|
variables?: Variable[];
|
|
157
157
|
/**
|
|
158
|
-
* Opens
|
|
158
|
+
* Opens settings to edit a hovered variable.
|
|
159
|
+
*
|
|
160
|
+
* @param key - Variable name from the hovered {{key}} token.
|
|
159
161
|
*/
|
|
160
|
-
onEditVariable?: () => void;
|
|
162
|
+
onEditVariable?: (key: string) => void;
|
|
161
163
|
/**
|
|
162
164
|
* When set on a JavaScript editor, enables custom autocomplete (e.g. hc API completions).
|
|
163
165
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/CodeEditor/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAmC,MAAM,0BAA0B,CAAC;AA0BlG,OAAO,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/CodeEditor/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAmC,MAAM,0BAA0B,CAAC;AA0BlG,OAAO,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,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,aAAa,CAAC,EAAE,eAAe,CAAC;IAEhC;;OAEG;IACH,aAAa,CAAC,EAAE,eAAe,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;IAE5C;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AA4SD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,QAAiB,EACjB,QAAgB,EAChB,QAAQ,EACR,WAAW,EACX,oBAA4B,EAC5B,SAAmB,EACnB,MAAM,EACN,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,SAAc,EACd,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,IAAW,EACX,aAAa,EACb,aAAa,EACb,QAAQ,EACR,EAAE,EACF,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,cAAc,EAAE,WAAW,EAC3B,kBAAkB,EAAE,eAAe,EACnC,GAAG,KAAK,EACT,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAidrB"}
|
|
@@ -10,6 +10,9 @@ import { createElement, useCallback, useEffect, useId, useMemo, useRef, useState
|
|
|
10
10
|
import CodeMirrorImport from '@uiw/react-codemirror';
|
|
11
11
|
import { normalizeCodeEditorFontSize } from '../../ui/codeEditorSettings.js';
|
|
12
12
|
import { VARIABLE_NAME_CHARS, getVariableTooltipContent } from '../../variables/index.js';
|
|
13
|
+
import { Button } from '../Button/index.js';
|
|
14
|
+
import { buildVariableTooltipDom } from '../VariableTooltip/dom.js';
|
|
15
|
+
import { VariableTooltipValue } from '../VariableTooltip/index.js';
|
|
13
16
|
import { useCodeEditorConfig } from './config.js';
|
|
14
17
|
import { createBuiltInSyntaxHighlighting, createEditorTheme } from './editorChrome.js';
|
|
15
18
|
import { createSlashCommandHighlighter } from './slashCommandHighlighter.js';
|
|
@@ -157,33 +160,6 @@ function findVariableAtPos(doc, pos) {
|
|
|
157
160
|
}
|
|
158
161
|
return null;
|
|
159
162
|
}
|
|
160
|
-
/**
|
|
161
|
-
* Builds DOM content for a variable tooltip.
|
|
162
|
-
*/
|
|
163
|
-
function buildVariableTooltipDom(key, variables, onEditVariable) {
|
|
164
|
-
const content = getVariableTooltipContent(key, variables);
|
|
165
|
-
const dom = document.createElement('div');
|
|
166
|
-
dom.className = 'cm-variable-tooltip';
|
|
167
|
-
const valueEl = document.createElement('div');
|
|
168
|
-
valueEl.textContent = content.text;
|
|
169
|
-
if (content.muted) {
|
|
170
|
-
valueEl.className = 'cm-variable-tooltip-muted';
|
|
171
|
-
}
|
|
172
|
-
dom.appendChild(valueEl);
|
|
173
|
-
if (onEditVariable) {
|
|
174
|
-
const btn = document.createElement('button');
|
|
175
|
-
btn.type = 'button';
|
|
176
|
-
btn.textContent = 'Edit value';
|
|
177
|
-
btn.className = 'cm-variable-tooltip-edit';
|
|
178
|
-
btn.setAttribute('aria-label', `Edit value for ${key}`);
|
|
179
|
-
btn.addEventListener('mousedown', (e) => {
|
|
180
|
-
e.preventDefault();
|
|
181
|
-
onEditVariable();
|
|
182
|
-
});
|
|
183
|
-
dom.appendChild(btn);
|
|
184
|
-
}
|
|
185
|
-
return dom;
|
|
186
|
-
}
|
|
187
163
|
/**
|
|
188
164
|
* Joins non-empty element ids into a space-separated `aria-describedby` value.
|
|
189
165
|
*
|
|
@@ -244,7 +220,7 @@ function variableTooltipEscapeHandler(isOpen, onDismiss, getValidationDescribedB
|
|
|
244
220
|
keydown(event, view) {
|
|
245
221
|
if (event.key === 'Escape' && isOpen()) {
|
|
246
222
|
event.preventDefault();
|
|
247
|
-
onDismiss(
|
|
223
|
+
onDismiss();
|
|
248
224
|
setContentDescribedBy(view.dom.querySelector('.cm-content'), getValidationDescribedBy);
|
|
249
225
|
return true;
|
|
250
226
|
}
|
|
@@ -653,11 +629,9 @@ export function CodeEditor({ value, onChange, language = 'text', readOnly = fals
|
|
|
653
629
|
...(height ? { height: '100%' } : {}),
|
|
654
630
|
basicSetup,
|
|
655
631
|
...(shouldTrackViewState ? { onCreateEditor: stableOnCreateEditor } : {})
|
|
656
|
-
}), selectionTooltip && selectionTooltipContent && variables ? (_jsxs("div", { id: tooltipId, role: "tooltip", className: "hc-code-editor-tooltip app-no-drag pointer-events-auto fixed z-50 flex max-w-sm -translate-x-1/2 -translate-y-full flex-col gap-1.5 rounded-lg border border-separator bg-surface px-3 py-2 text-[
|
|
657
|
-
? 'hc-code-editor-tooltip-text text-muted'
|
|
658
|
-
: 'hc-code-editor-tooltip-text', children: selectionTooltipContent.text }), onEditVariable ? (_jsx("button", { type: "button", className: "hc-code-editor-tooltip-edit self-start text-[14px] text-accent hover:underline", "aria-label": `Edit value for ${selectionTooltip.key}`, onMouseDown: (event) => {
|
|
632
|
+
}), selectionTooltip && selectionTooltipContent && variables ? (_jsxs("div", { id: tooltipId, role: "tooltip", className: "hc-code-editor-tooltip app-no-drag pointer-events-auto fixed z-50 flex max-w-sm -translate-x-1/2 -translate-y-full flex-col gap-1.5 rounded-lg border border-separator bg-surface px-3 py-2 text-[16px] text-text shadow-md", style: { top: selectionTooltip.top - 4, left: selectionTooltip.left }, children: [_jsx(VariableTooltipValue, { value: selectionTooltipContent.text, variableKey: selectionTooltip.key, muted: selectionTooltipContent.muted }), onEditVariable ? (_jsx(Button, { variant: "secondary", className: "hc-code-editor-tooltip-edit self-start", "aria-label": `Edit value for ${selectionTooltip.key}`, onMouseDown: (event) => {
|
|
659
633
|
event.preventDefault();
|
|
660
|
-
onEditVariable();
|
|
634
|
+
onEditVariable(selectionTooltip.key);
|
|
661
635
|
setSelectionTooltip(null);
|
|
662
636
|
}, children: "Edit value" })) : null] })) : null] }));
|
|
663
637
|
}
|
|
@@ -18,9 +18,11 @@ export interface Props {
|
|
|
18
18
|
*/
|
|
19
19
|
onSelectFiles: () => Promise<string[]>;
|
|
20
20
|
/**
|
|
21
|
-
* Opens
|
|
21
|
+
* Opens settings to edit a hovered variable.
|
|
22
|
+
*
|
|
23
|
+
* @param key - Variable name from the hovered {{key}} token.
|
|
22
24
|
*/
|
|
23
|
-
onEditVariable?: () => void;
|
|
25
|
+
onEditVariable?: (key: string) => void;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* Editable table of multipart form parts with text and file field types.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FormDataEditor/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAoB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAQ/E,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,KAAK,EAAE,YAAY,EAAE,CAAC;IAEtB;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;IAE1C;;OAEG;IACH,SAAS,EAAE,QAAQ,EAAE,CAAC;IAEtB;;OAEG;IACH,aAAa,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAEvC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FormDataEditor/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAoB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAQ/E,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,KAAK,EAAE,YAAY,EAAE,CAAC;IAEtB;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;IAE1C;;OAEG;IACH,SAAS,EAAE,QAAQ,EAAE,CAAC;IAEtB;;OAEG;IACH,aAAa,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAEvC;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,QAAQ,EACR,SAAS,EACT,aAAa,EACb,cAAc,EACf,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CA6KrB"}
|
|
@@ -23,9 +23,11 @@ export interface Props {
|
|
|
23
23
|
*/
|
|
24
24
|
variables: Variable[];
|
|
25
25
|
/**
|
|
26
|
-
* Opens
|
|
26
|
+
* Opens settings to edit a hovered variable.
|
|
27
|
+
*
|
|
28
|
+
* @param key - Variable name from the hovered {{key}} token.
|
|
27
29
|
*/
|
|
28
|
-
onEditVariable?: () => void;
|
|
30
|
+
onEditVariable?: (key: string) => void;
|
|
29
31
|
/**
|
|
30
32
|
* Optional async source for key column autocomplete suggestions.
|
|
31
33
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/KeyValueEditor/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAOnE,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,IAAI,EAAE,QAAQ,EAAE,CAAC;IAEjB;;OAEG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;IAErC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,SAAS,EAAE,QAAQ,EAAE,CAAC;IAEtB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/KeyValueEditor/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAOnE,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,IAAI,EAAE,QAAQ,EAAE,CAAC;IAEjB;;OAEG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;IAErC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,SAAS,EAAE,QAAQ,EAAE,CAAC;IAEtB;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAEvC;;OAEG;IACH,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAE/B;;OAEG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,QAAQ,EACR,cAAsB,EACtB,gBAA0B,EAC1B,SAAS,EACT,cAAc,EACd,SAAS,EACT,WAAW,EACZ,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAoGrB"}
|
|
@@ -31,9 +31,11 @@ export interface Props extends Omit<ComponentPropsWithoutRef<'div'>, 'children'
|
|
|
31
31
|
*/
|
|
32
32
|
wrapperClassName?: string;
|
|
33
33
|
/**
|
|
34
|
-
* Opens
|
|
34
|
+
* Opens settings to edit the hovered variable.
|
|
35
|
+
*
|
|
36
|
+
* @param key - Variable name from the hovered {{key}} token.
|
|
35
37
|
*/
|
|
36
|
-
onEditVariable?: () => void;
|
|
38
|
+
onEditVariable?: (key: string) => void;
|
|
37
39
|
/**
|
|
38
40
|
* DOM id forwarded to the underlying input for label association.
|
|
39
41
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/VariableInput/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,aAAa,EAAc,MAAM,OAAO,CAAC;AACtF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAS/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/VariableInput/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,GAAG,EAAE,aAAa,EAAc,MAAM,OAAO,CAAC;AACtF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAS/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAenE,MAAM,WAAW,KAAM,SAAQ,IAAI,CACjC,wBAAwB,CAAC,KAAK,CAAC,EAC/B,UAAU,GAAG,WAAW,GAAG,IAAI,GAAG,YAAY,GAAG,iBAAiB,GAAG,WAAW,GAAG,UAAU,CAC9F;IACC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAElC;;OAEG;IACH,SAAS,EAAE,QAAQ,EAAE,CAAC;IAEtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAEzD;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAEvC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAc,EACd,gBAAgB,EAChB,cAAc,EACd,EAAE,EACF,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,MAAM,EACN,GAAG,KAAK,EACT,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAuSrB"}
|
|
@@ -3,6 +3,8 @@ import { useEffect, useId, useMemo, useRef, useState } from '@harborclient/sdk/r
|
|
|
3
3
|
import { getDynamicVariableDescription, getVariableTokenAtOffset, getVariableTooltipContent, resolveVariable, tokenizeVariables } from '../../variables/index.js';
|
|
4
4
|
import { SuggestionList } from '../Autocomplete/SuggestionList.js';
|
|
5
5
|
import { useAutocomplete } from '../Autocomplete/useAutocomplete.js';
|
|
6
|
+
import { Button } from '../Button/index.js';
|
|
7
|
+
import { VariableTooltipValue } from '../VariableTooltip/index.js';
|
|
6
8
|
import { Input } from '../forms/index.js';
|
|
7
9
|
import { cn } from '../utils.js';
|
|
8
10
|
/**
|
|
@@ -165,10 +167,8 @@ export function VariableInput({ value, onChange, variables, placeholder, onKeyDo
|
|
|
165
167
|
}, onFocus: () => {
|
|
166
168
|
openAutocomplete();
|
|
167
169
|
updateTooltipFromCaret();
|
|
168
|
-
}, onBlur: closeAutocomplete, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onSelect: updateTooltipFromCaret, onClick: updateTooltipFromCaret, onScroll: syncScroll, onMouseMove: handleMouseMove, onMouseLeave: scheduleHide }), source && (_jsx(SuggestionList, { open: autocompleteOpen, items: autocompleteItems, activeIndex: autocompleteActiveIndex, anchorRef: inputRef, listboxId: listboxId, onSelect: selectItem, onActiveIndexChange: setActiveIndex, onClose: closeSuggestions })), tooltip && tooltipContent && (_jsxs("div", { id: tooltipId, role: "tooltip", className: "hc-variable-input-tooltip pointer-events-auto fixed z-50 flex max-w-sm -translate-x-1/2 -translate-y-full flex-col gap-2 rounded-lg border border-separator bg-surface px-4 py-3 text-[
|
|
169
|
-
|
|
170
|
-
: 'hc-variable-input-tooltip-text', children: tooltipContent.text }), onEditVariable && (_jsx("button", { type: "button", className: "hc-variable-input-tooltip-edit app-no-drag -mx-1 self-start rounded px-1 py-0.5 text-[14px] text-accent hover:underline", "aria-label": `Edit value for ${tooltip.key}`, onClick: () => {
|
|
171
|
-
onEditVariable();
|
|
170
|
+
}, onBlur: closeAutocomplete, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onSelect: updateTooltipFromCaret, onClick: updateTooltipFromCaret, onScroll: syncScroll, onMouseMove: handleMouseMove, onMouseLeave: scheduleHide }), source && (_jsx(SuggestionList, { open: autocompleteOpen, items: autocompleteItems, activeIndex: autocompleteActiveIndex, anchorRef: inputRef, listboxId: listboxId, onSelect: selectItem, onActiveIndexChange: setActiveIndex, onClose: closeSuggestions })), tooltip && tooltipContent && (_jsxs("div", { id: tooltipId, role: "tooltip", className: "hc-variable-input-tooltip pointer-events-auto fixed z-50 flex max-w-sm -translate-x-1/2 -translate-y-full flex-col gap-2 rounded-lg border border-separator bg-surface px-4 py-3 text-[16px] text-text shadow-md after:pointer-events-auto after:absolute after:right-0 after:-bottom-2 after:left-0 after:h-2 after:content-['']", style: { top: tooltip.top - 4, left: tooltip.left }, onMouseEnter: cancelHide, onMouseLeave: scheduleHide, children: [_jsx(VariableTooltipValue, { value: tooltipContent.text, variableKey: tooltip.key, muted: tooltipContent.muted }), onEditVariable && (_jsx(Button, { variant: "secondary", className: "hc-variable-input-tooltip-edit self-start", "aria-label": `Edit value for ${tooltip.key}`, onClick: () => {
|
|
171
|
+
onEditVariable(tooltip.key);
|
|
172
172
|
setTooltip(null);
|
|
173
173
|
}, children: "Edit value" }))] }))] }));
|
|
174
174
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ComponentPropsWithoutRef, type JSX } from 'react';
|
|
2
2
|
import type { Variable } from '../../types.js';
|
|
3
3
|
interface Props extends Omit<ComponentPropsWithoutRef<'div'>, 'children' | 'onChange'> {
|
|
4
4
|
/**
|
|
@@ -13,10 +13,14 @@ interface Props extends Omit<ComponentPropsWithoutRef<'div'>, 'children' | 'onCh
|
|
|
13
13
|
* Optional helper text above the table.
|
|
14
14
|
*/
|
|
15
15
|
description?: string;
|
|
16
|
+
/**
|
|
17
|
+
* When set, scrolls to and focuses the Value input for the matching variable key.
|
|
18
|
+
*/
|
|
19
|
+
focusKey?: string;
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
22
|
* Editable table for key/value/default/share variable rows.
|
|
19
23
|
*/
|
|
20
|
-
export declare function VariableTable({ variables, onChange, description, className, ...props }: Props): JSX.Element;
|
|
24
|
+
export declare function VariableTable({ variables, onChange, description, focusKey, className, ...props }: Props): JSX.Element;
|
|
21
25
|
export {};
|
|
22
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/VariableTable/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/VariableTable/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,GAAG,EAAqB,MAAM,OAAO,CAAC;AACnF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAY/C,UAAU,KAAM,SAAQ,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACpF;;OAEG;IACH,SAAS,EAAE,QAAQ,EAAE,CAAC;IAEtB;;OAEG;IACH,QAAQ,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;IAE1C;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAC5B,SAAS,EACT,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CA4JrB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@harborclient/sdk/jsx-runtime";
|
|
2
2
|
import { faPlus, faXmark } from '@fortawesome/free-solid-svg-icons';
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
3
4
|
import { Button } from '../Button/index.js';
|
|
4
5
|
import { FaIcon } from '../FaIcon/index.js';
|
|
5
6
|
import { Table, TableBody, TableCell, TableHead, TableHeader } from '../Table/index.js';
|
|
@@ -12,7 +13,9 @@ const emptyVariable = () => ({ key: '', value: '', defaultValue: '', share: fals
|
|
|
12
13
|
/**
|
|
13
14
|
* Editable table for key/value/default/share variable rows.
|
|
14
15
|
*/
|
|
15
|
-
export function VariableTable({ variables, onChange, description, className, ...props }) {
|
|
16
|
+
export function VariableTable({ variables, onChange, description, focusKey, className, ...props }) {
|
|
17
|
+
const valueInputRefs = useRef(new Map());
|
|
18
|
+
const lastFocusedKeyRef = useRef(undefined);
|
|
16
19
|
/**
|
|
17
20
|
* Updates a single variable row by index.
|
|
18
21
|
*/
|
|
@@ -35,5 +38,41 @@ export function VariableTable({ variables, onChange, description, className, ...
|
|
|
35
38
|
}
|
|
36
39
|
onChange(variables.filter((_, i) => i !== index));
|
|
37
40
|
};
|
|
38
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Scrolls to and focuses the Value input for the row matching `focusKey`.
|
|
43
|
+
* Runs once per distinct `focusKey` so subsequent edits do not steal focus.
|
|
44
|
+
*/
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const trimmedFocusKey = focusKey?.trim();
|
|
47
|
+
if (!trimmedFocusKey || trimmedFocusKey === lastFocusedKeyRef.current) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const rowIndex = variables.findIndex((variable) => variable.key.trim() === trimmedFocusKey);
|
|
51
|
+
if (rowIndex < 0) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
lastFocusedKeyRef.current = trimmedFocusKey;
|
|
55
|
+
/**
|
|
56
|
+
* Waits two animation frames so the table row can mount after tab navigation.
|
|
57
|
+
*/
|
|
58
|
+
requestAnimationFrame(() => {
|
|
59
|
+
requestAnimationFrame(() => {
|
|
60
|
+
const input = valueInputRefs.current.get(rowIndex);
|
|
61
|
+
if (input == null ||
|
|
62
|
+
typeof input.focus !== 'function' ||
|
|
63
|
+
typeof input.select !== 'function') {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
input.scrollIntoView({ block: 'nearest' });
|
|
67
|
+
input.focus();
|
|
68
|
+
input.select();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}, [focusKey, variables]);
|
|
72
|
+
return (_jsxs("div", { ...props, className: cn('hc-variable-table', className), children: [description && (_jsx("p", { className: "hc-variable-table-description mb-3 text-[14px] text-muted", children: description })), _jsxs("div", { className: "hc-variable-table-content flex flex-col gap-1.5", children: [_jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs("tr", { children: [_jsx(TableHead, { children: "Key" }), _jsx(TableHead, { children: "Value" }), _jsx(TableHead, { children: "Default" }), _jsx(TableHead, { className: "w-14 text-center", children: "Share" }), _jsx(TableHead, { className: "w-7 p-0 text-center" })] }) }), _jsx(TableBody, { children: variables.map((variable, index) => (_jsxs("tr", { children: [_jsx(TableCell, { children: _jsx(Input, { type: "text", className: "w-full", value: variable.key, placeholder: "variable", "aria-label": `Key, row ${index + 1}`, onChange: (e) => updateVariable(index, { key: e.target.value }) }) }), _jsx(TableCell, { children: _jsx(Input, { ref: (element) => {
|
|
73
|
+
if (element)
|
|
74
|
+
valueInputRefs.current.set(index, element);
|
|
75
|
+
else
|
|
76
|
+
valueInputRefs.current.delete(index);
|
|
77
|
+
}, type: "text", className: "w-full", value: variable.value, placeholder: "value", "aria-label": `Value, row ${index + 1}`, onChange: (e) => updateVariable(index, { value: e.target.value }) }) }), _jsx(TableCell, { children: _jsx(Input, { type: "text", className: "w-full", value: variable.defaultValue, placeholder: "default", "aria-label": `Default, row ${index + 1}`, onChange: (e) => updateVariable(index, { defaultValue: e.target.value }) }) }), _jsx(TableCell, { className: "w-14 text-center", children: _jsx(Checkbox, { checked: variable.share, onChange: (e) => updateVariable(index, { share: e.target.checked }), "aria-label": `Include value in export, row ${index + 1}`, title: "Include value in export" }) }), _jsx(TableCell, { className: "w-7 p-0 text-center", children: _jsx(Button, { type: "button", variant: "iconDanger", onClick: () => removeVariable(index), title: "Remove", "aria-label": `Remove row ${index + 1}`, children: _jsx(FaIcon, { icon: faXmark, className: "h-3.5 w-3.5" }) }) })] }, index))) })] }), _jsxs(Button, { type: "button", variant: "toolbar", className: "hc-variable-table-add inline-flex items-center gap-1 self-start", onClick: addVariable, children: [_jsx(FaIcon, { icon: faPlus, className: "h-3 w-3" }), "Add variable"] })] })] }));
|
|
39
78
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
/**
|
|
4
|
+
* Resolved variable value shown in the readonly field.
|
|
5
|
+
*/
|
|
6
|
+
value: string;
|
|
7
|
+
/**
|
|
8
|
+
* Variable name from the hovered {{key}} token.
|
|
9
|
+
*/
|
|
10
|
+
variableKey: string;
|
|
11
|
+
/**
|
|
12
|
+
* When true, styles the value as muted placeholder text.
|
|
13
|
+
*/
|
|
14
|
+
muted?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Readonly resolved-value field with a copy control for variable tooltips.
|
|
18
|
+
*/
|
|
19
|
+
export declare function VariableTooltipValue({ value, variableKey, muted }: Props): JSX.Element;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=VariableTooltipValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VariableTooltipValue.d.ts","sourceRoot":"","sources":["../../../src/components/VariableTooltip/VariableTooltipValue.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAMjC,UAAU,KAAK;IACb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAkCtF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@harborclient/sdk/jsx-runtime";
|
|
2
|
+
import { faCircleCheck, faCopy } from '@fortawesome/free-solid-svg-icons';
|
|
3
|
+
import { useState } from '@harborclient/sdk/react';
|
|
4
|
+
import { Button } from '../Button/index.js';
|
|
5
|
+
import { FaIcon } from '../FaIcon/index.js';
|
|
6
|
+
import { Input } from '../forms/index.js';
|
|
7
|
+
import { cn } from '../utils.js';
|
|
8
|
+
/**
|
|
9
|
+
* Readonly resolved-value field with a copy control for variable tooltips.
|
|
10
|
+
*/
|
|
11
|
+
export function VariableTooltipValue({ value, variableKey, muted }) {
|
|
12
|
+
const [copied, setCopied] = useState(false);
|
|
13
|
+
/**
|
|
14
|
+
* Copies the resolved value to the clipboard and briefly confirms success in the icon.
|
|
15
|
+
*/
|
|
16
|
+
const handleCopy = () => {
|
|
17
|
+
void navigator.clipboard.writeText(value).then(() => {
|
|
18
|
+
setCopied(true);
|
|
19
|
+
window.setTimeout(() => setCopied(false), 2000);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
return (_jsxs("div", { className: "hc-variable-tooltip-value-row flex items-center gap-1.5", children: [_jsx(Input, { readOnly: true, value: value, "aria-label": `Resolved value for ${variableKey}`, className: cn('min-w-0 flex-1', muted && 'text-muted') }), _jsx(Button, { type: "button", variant: "icon", "aria-label": copied ? `Copied value for ${variableKey}` : `Copy value for ${variableKey}`, onMouseDown: (event) => {
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
}, onClick: handleCopy, children: _jsx(FaIcon, { icon: copied ? faCircleCheck : faCopy, className: "h-4 w-4" }) })] }));
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Variable } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Appends a readonly value field and copy button row to a variable tooltip container.
|
|
4
|
+
*
|
|
5
|
+
* @param parent - Tooltip root element receiving the value row.
|
|
6
|
+
* @param value - Resolved value text to display and copy.
|
|
7
|
+
* @param key - Variable name from the hovered token.
|
|
8
|
+
* @param muted - Whether the value should use muted styling.
|
|
9
|
+
*/
|
|
10
|
+
export declare function appendVariableTooltipValueRow(parent: HTMLElement, value: string, key: string, muted: boolean): void;
|
|
11
|
+
/**
|
|
12
|
+
* Builds DOM content for a CodeMirror variable hover tooltip.
|
|
13
|
+
*
|
|
14
|
+
* @param key - Variable name from the hovered {{key}} token.
|
|
15
|
+
* @param variables - Variables used to resolve tooltip text.
|
|
16
|
+
* @param onEditVariable - Optional callback to open variable settings.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildVariableTooltipDom(key: string, variables: Variable[], onEditVariable?: (key: string) => void): HTMLDivElement;
|
|
19
|
+
//# sourceMappingURL=dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../src/components/VariableTooltip/dom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AA8B/C;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,GACb,IAAI,CA0CN;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,QAAQ,EAAE,EACrB,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GACrC,cAAc,CAqBhB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { getVariableTooltipContent } from '../../variables/index.js';
|
|
2
|
+
const COPY_ICON_PATH = 'M208 0H332.1c12.7 0 24.9 5.1 33.9 14.1l67.9 67.9c9 9 14.1 21.2 14.1 33.9V336c0 26.5-21.5 48-48 48H208c-26.5 0-48-21.5-48-48V48c0-26.5 21.5-48 48-48zM48 128h80v64H64v256h192v-32h64v48c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V176c0-26.5 21.5-48 48-48z';
|
|
3
|
+
const CHECK_ICON_PATH = 'M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z';
|
|
4
|
+
/**
|
|
5
|
+
* Creates an inline SVG icon for imperative tooltip controls.
|
|
6
|
+
*
|
|
7
|
+
* @param path - SVG path data for the icon glyph.
|
|
8
|
+
*/
|
|
9
|
+
function createTooltipIcon(path) {
|
|
10
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
11
|
+
svg.setAttribute('viewBox', '0 0 448 512');
|
|
12
|
+
svg.setAttribute('width', '16');
|
|
13
|
+
svg.setAttribute('height', '16');
|
|
14
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
15
|
+
svg.classList.add('hc-variable-tooltip-copy-icon');
|
|
16
|
+
const pathEl = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
17
|
+
pathEl.setAttribute('fill', 'currentColor');
|
|
18
|
+
pathEl.setAttribute('d', path);
|
|
19
|
+
svg.appendChild(pathEl);
|
|
20
|
+
return svg;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Appends a readonly value field and copy button row to a variable tooltip container.
|
|
24
|
+
*
|
|
25
|
+
* @param parent - Tooltip root element receiving the value row.
|
|
26
|
+
* @param value - Resolved value text to display and copy.
|
|
27
|
+
* @param key - Variable name from the hovered token.
|
|
28
|
+
* @param muted - Whether the value should use muted styling.
|
|
29
|
+
*/
|
|
30
|
+
export function appendVariableTooltipValueRow(parent, value, key, muted) {
|
|
31
|
+
const row = document.createElement('div');
|
|
32
|
+
row.className = 'cm-variable-tooltip-value-row';
|
|
33
|
+
const input = document.createElement('input');
|
|
34
|
+
input.type = 'text';
|
|
35
|
+
input.readOnly = true;
|
|
36
|
+
input.value = value;
|
|
37
|
+
input.className = 'cm-variable-tooltip-value';
|
|
38
|
+
input.setAttribute('aria-label', `Resolved value for ${key}`);
|
|
39
|
+
if (muted) {
|
|
40
|
+
input.classList.add('cm-variable-tooltip-value-muted');
|
|
41
|
+
}
|
|
42
|
+
const copyBtn = document.createElement('button');
|
|
43
|
+
copyBtn.type = 'button';
|
|
44
|
+
copyBtn.className = 'cm-variable-tooltip-copy app-no-drag';
|
|
45
|
+
copyBtn.setAttribute('aria-label', `Copy value for ${key}`);
|
|
46
|
+
copyBtn.appendChild(createTooltipIcon(COPY_ICON_PATH));
|
|
47
|
+
/**
|
|
48
|
+
* Copies the resolved value and briefly swaps the icon to a check mark.
|
|
49
|
+
*/
|
|
50
|
+
const handleCopy = () => {
|
|
51
|
+
void navigator.clipboard.writeText(value).then(() => {
|
|
52
|
+
copyBtn.replaceChildren(createTooltipIcon(CHECK_ICON_PATH));
|
|
53
|
+
copyBtn.setAttribute('aria-label', `Copied value for ${key}`);
|
|
54
|
+
window.setTimeout(() => {
|
|
55
|
+
copyBtn.replaceChildren(createTooltipIcon(COPY_ICON_PATH));
|
|
56
|
+
copyBtn.setAttribute('aria-label', `Copy value for ${key}`);
|
|
57
|
+
}, 2000);
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
copyBtn.addEventListener('mousedown', (event) => {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
});
|
|
63
|
+
copyBtn.addEventListener('click', handleCopy);
|
|
64
|
+
row.appendChild(input);
|
|
65
|
+
row.appendChild(copyBtn);
|
|
66
|
+
parent.appendChild(row);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Builds DOM content for a CodeMirror variable hover tooltip.
|
|
70
|
+
*
|
|
71
|
+
* @param key - Variable name from the hovered {{key}} token.
|
|
72
|
+
* @param variables - Variables used to resolve tooltip text.
|
|
73
|
+
* @param onEditVariable - Optional callback to open variable settings.
|
|
74
|
+
*/
|
|
75
|
+
export function buildVariableTooltipDom(key, variables, onEditVariable) {
|
|
76
|
+
const content = getVariableTooltipContent(key, variables);
|
|
77
|
+
const dom = document.createElement('div');
|
|
78
|
+
dom.className = 'cm-variable-tooltip';
|
|
79
|
+
appendVariableTooltipValueRow(dom, content.text, key, content.muted);
|
|
80
|
+
if (onEditVariable) {
|
|
81
|
+
const btn = document.createElement('button');
|
|
82
|
+
btn.type = 'button';
|
|
83
|
+
btn.textContent = 'Edit value';
|
|
84
|
+
btn.className = 'cm-variable-tooltip-edit app-no-drag';
|
|
85
|
+
btn.setAttribute('aria-label', `Edit value for ${key}`);
|
|
86
|
+
btn.addEventListener('mousedown', (event) => {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
onEditVariable(key);
|
|
89
|
+
});
|
|
90
|
+
dom.appendChild(btn);
|
|
91
|
+
}
|
|
92
|
+
return dom;
|
|
93
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/VariableTooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -53,6 +53,7 @@ export type { TableVariant } from './Table/index.js';
|
|
|
53
53
|
export { VariableInput } from './VariableInput/index.js';
|
|
54
54
|
export type { Props as VariableInputProps } from './VariableInput/index.js';
|
|
55
55
|
export { VariableTable } from './VariableTable/index.js';
|
|
56
|
+
export { VariableTooltipValue, appendVariableTooltipValueRow, buildVariableTooltipDom } from './VariableTooltip/index.js';
|
|
56
57
|
export { cleanVariables, resolveTabListKeyAction } from './utils.js';
|
|
57
58
|
export type { TabListKeyOptions } from './utils.js';
|
|
58
59
|
export { useDialogFocus, getFocusableElements } from './useDialogFocus.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,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E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -39,6 +39,7 @@ export { Toolbar } from './Toolbar/index.js';
|
|
|
39
39
|
export { Table, TableBody, TableCell, TableHead, TableHeader, tableCellClass, tableCellClassLoose, tableHeadClass, tableHeadClassLoose } from './Table/index.js';
|
|
40
40
|
export { VariableInput } from './VariableInput/index.js';
|
|
41
41
|
export { VariableTable } from './VariableTable/index.js';
|
|
42
|
+
export { VariableTooltipValue, appendVariableTooltipValueRow, buildVariableTooltipDom } from './VariableTooltip/index.js';
|
|
42
43
|
export { cleanVariables, resolveTabListKeyAction } from './utils.js';
|
|
43
44
|
export { useDialogFocus, getFocusableElements } from './useDialogFocus.js';
|
|
44
45
|
export { segment, segmentGroup } from './classes.js';
|
package/dist/snippets.d.ts
CHANGED
|
@@ -27,9 +27,9 @@ interface HcHeaderApi {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* Variable helpers
|
|
30
|
+
* Variable bag helpers shared by hc.collection.variables, hc.environment.variables, and hc.globals.
|
|
31
31
|
*/
|
|
32
|
-
interface
|
|
32
|
+
interface HcVariableBagApi {
|
|
33
33
|
/**
|
|
34
34
|
* Returns a variable value, preferring values set in the current script run.
|
|
35
35
|
*/
|
|
@@ -40,12 +40,183 @@ interface HcVariablesApi {
|
|
|
40
40
|
*/
|
|
41
41
|
set(key: string, value: unknown): void;
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Removes a single key from this scope for the remainder of the script run.
|
|
45
|
+
*/
|
|
46
|
+
clear(key: string): void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Request-scoped variable helpers on hc.request.variables.
|
|
51
|
+
*/
|
|
52
|
+
interface HcRequestVariablesApi extends HcVariableBagApi {
|
|
43
53
|
/**
|
|
44
54
|
* Replaces {{variable}} tokens and dynamic $ tokens in a template string.
|
|
45
55
|
*/
|
|
46
56
|
replaceIn(template: unknown): string;
|
|
47
57
|
}
|
|
48
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Auth type selector for hc.request.auth and hc.collection.auth.
|
|
61
|
+
*/
|
|
62
|
+
type HcAuthType = 'none' | 'basic' | 'bearer' | 'oauth2';
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* OAuth client credential transport for hc.*.auth when type is oauth2.
|
|
66
|
+
*/
|
|
67
|
+
type HcOAuth2ClientAuth = 'header' | 'body';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Flat auth field names accepted by hc.*.auth.update().
|
|
71
|
+
*/
|
|
72
|
+
type HcAuthField =
|
|
73
|
+
| 'type'
|
|
74
|
+
| 'token'
|
|
75
|
+
| 'username'
|
|
76
|
+
| 'password'
|
|
77
|
+
| 'tokenUrl'
|
|
78
|
+
| 'clientId'
|
|
79
|
+
| 'clientSecret'
|
|
80
|
+
| 'scope'
|
|
81
|
+
| 'audience'
|
|
82
|
+
| 'clientAuth';
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Partial flat auth object accepted by hc.request.auth.set() and hc.collection.auth.set().
|
|
86
|
+
*
|
|
87
|
+
* Merges onto the current auth configuration; switching type preserves stored
|
|
88
|
+
* credentials for other types.
|
|
89
|
+
*/
|
|
90
|
+
interface HcAuthInput {
|
|
91
|
+
type?: HcAuthType;
|
|
92
|
+
token?: string;
|
|
93
|
+
username?: string;
|
|
94
|
+
password?: string;
|
|
95
|
+
tokenUrl?: string;
|
|
96
|
+
clientId?: string;
|
|
97
|
+
clientSecret?: string;
|
|
98
|
+
scope?: string;
|
|
99
|
+
audience?: string;
|
|
100
|
+
clientAuth?: HcOAuth2ClientAuth;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Flat auth shape returned by hc.request.auth.get() and hc.collection.auth.get().
|
|
105
|
+
*
|
|
106
|
+
* Includes only fields relevant to the active auth type.
|
|
107
|
+
*/
|
|
108
|
+
type HcAuthSnapshot =
|
|
109
|
+
| { type: 'none' }
|
|
110
|
+
| { type: 'basic'; username: string; password: string }
|
|
111
|
+
| { type: 'bearer'; token: string }
|
|
112
|
+
| {
|
|
113
|
+
type: 'oauth2';
|
|
114
|
+
tokenUrl: string;
|
|
115
|
+
clientId: string;
|
|
116
|
+
clientSecret: string;
|
|
117
|
+
scope: string;
|
|
118
|
+
audience: string;
|
|
119
|
+
clientAuth: HcOAuth2ClientAuth;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Auth helpers on hc.request.auth and hc.collection.auth.
|
|
124
|
+
*
|
|
125
|
+
* Request auth changes apply to the current send only. Collection auth changes
|
|
126
|
+
* persist to the collection when the send completes.
|
|
127
|
+
*/
|
|
128
|
+
interface HcAuthApi {
|
|
129
|
+
/**
|
|
130
|
+
* Returns the active auth fields as a flat object for the current auth type.
|
|
131
|
+
*/
|
|
132
|
+
get(): HcAuthSnapshot;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Merges auth configuration from a partial flat auth object.
|
|
136
|
+
*/
|
|
137
|
+
set(input: HcAuthInput): void;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Updates a single flat auth field, such as type or token.
|
|
141
|
+
*/
|
|
142
|
+
update(field: HcAuthField, value: unknown): void;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Cookie bag for the request host resolved at send start.
|
|
147
|
+
* URL changes mid-script do not retarget this bag.
|
|
148
|
+
*/
|
|
149
|
+
interface HcCookieApi {
|
|
150
|
+
/**
|
|
151
|
+
* Returns a cookie value by name, preferring values set in the current script run.
|
|
152
|
+
*/
|
|
153
|
+
get(name: string): string | undefined;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Sets a cookie for the request host for the remainder of the script run.
|
|
157
|
+
*/
|
|
158
|
+
set(name: string, value: unknown): void;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Removes a single cookie by name for the remainder of the script run.
|
|
162
|
+
*/
|
|
163
|
+
clear(name: string): void;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Collection runner flow control available in pre/post scripts during a run.
|
|
168
|
+
*/
|
|
169
|
+
interface HcExecutionApi {
|
|
170
|
+
/**
|
|
171
|
+
* Jumps to the named request in the active collection run, or stops the run when null.
|
|
172
|
+
*/
|
|
173
|
+
setNextRequest(name: string | null): void;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Skips the HTTP send and post-request scripts for the current request.
|
|
177
|
+
*/
|
|
178
|
+
skipRequest(): void;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Postman-compatible script execution metadata (pm.info equivalent).
|
|
183
|
+
*/
|
|
184
|
+
interface HcInfoApi {
|
|
185
|
+
/** `"prerequest"` for pre-request scripts, `"test"` for post-request scripts. */
|
|
186
|
+
readonly eventName: 'prerequest' | 'test';
|
|
187
|
+
/** Display name of the saved request. */
|
|
188
|
+
readonly requestName: string;
|
|
189
|
+
/** Saved request database id as a string, or empty when unsaved. */
|
|
190
|
+
readonly requestId: string;
|
|
191
|
+
/** Collection run iteration index; 0 for manual sends and non-data-driven runs. */
|
|
192
|
+
readonly iteration: number;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Outbound request payload accepted by hc.sendRequest.
|
|
197
|
+
*/
|
|
198
|
+
interface HcSendRequestInput {
|
|
199
|
+
method?: string;
|
|
200
|
+
url: string;
|
|
201
|
+
headers?: Array<{ key: string; value: string; enabled?: boolean }> | Record<string, string>;
|
|
202
|
+
params?: Array<{ key: string; value: string; enabled?: boolean }>;
|
|
203
|
+
body?: string;
|
|
204
|
+
bodyType?: 'none' | 'json' | 'text' | 'multipart' | 'urlencoded';
|
|
205
|
+
body_type?: 'none' | 'json' | 'text' | 'multipart' | 'urlencoded';
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Response snapshot returned by hc.sendRequest.
|
|
210
|
+
*/
|
|
211
|
+
interface HcSendRequestResponse {
|
|
212
|
+
readonly code: number;
|
|
213
|
+
readonly status: string;
|
|
214
|
+
readonly headers: Record<string, string>;
|
|
215
|
+
readonly responseTime: number;
|
|
216
|
+
text(): string;
|
|
217
|
+
json(): unknown;
|
|
218
|
+
}
|
|
219
|
+
|
|
49
220
|
/**
|
|
50
221
|
* Chai-lite matcher returned by hc.expect(actual).
|
|
51
222
|
*/
|
|
@@ -99,22 +270,38 @@ interface HcScriptApi {
|
|
|
99
270
|
url: string;
|
|
100
271
|
body: string;
|
|
101
272
|
headers: HcHeaderApi;
|
|
273
|
+
auth: HcAuthApi;
|
|
274
|
+
variables: HcRequestVariablesApi;
|
|
102
275
|
};
|
|
103
|
-
variables: HcVariablesApi;
|
|
104
276
|
collection: {
|
|
105
277
|
readonly id: number | null;
|
|
106
278
|
readonly name: string;
|
|
107
|
-
variables:
|
|
279
|
+
variables: HcVariableBagApi;
|
|
108
280
|
headers: HcHeaderApi;
|
|
281
|
+
auth: HcAuthApi;
|
|
109
282
|
};
|
|
110
283
|
environment: {
|
|
111
284
|
readonly name: string;
|
|
112
|
-
variables:
|
|
285
|
+
variables: HcVariableBagApi;
|
|
113
286
|
};
|
|
114
|
-
globals:
|
|
287
|
+
globals: HcVariableBagApi;
|
|
288
|
+
cookies: HcCookieApi;
|
|
289
|
+
execution: HcExecutionApi;
|
|
290
|
+
/** Read-only metadata about the current script run (Postman pm.info equivalent). */
|
|
291
|
+
info: HcInfoApi;
|
|
292
|
+
/**
|
|
293
|
+
* Sends an outbound HTTP request from the script sandbox.
|
|
294
|
+
* Requires Settings → General → Allow script network requests.
|
|
295
|
+
*
|
|
296
|
+
* @throws When the setting is disabled or sendRequest is unavailable in this context.
|
|
297
|
+
*/
|
|
298
|
+
sendRequest(req: HcSendRequestInput): Promise<HcSendRequestResponse>;
|
|
115
299
|
test(name: string, fn: () => void): void;
|
|
116
300
|
expect(actual: unknown): HcExpectMatcher;
|
|
117
|
-
|
|
301
|
+
/**
|
|
302
|
+
* Available in post-request scripts after the primary request completes.
|
|
303
|
+
*/
|
|
304
|
+
response?: HcResponseApi;
|
|
118
305
|
}
|
|
119
306
|
|
|
120
307
|
/**
|
package/dist/types.d.ts
CHANGED
|
@@ -1726,7 +1726,7 @@ export interface PluginScriptContextInit {
|
|
|
1726
1726
|
*/
|
|
1727
1727
|
response?: PluginScriptResponseInit;
|
|
1728
1728
|
/**
|
|
1729
|
-
* Merged runtime variables for hc.variables, hc.collection.variables,
|
|
1729
|
+
* Merged runtime variables for hc.request.variables, hc.collection.variables,
|
|
1730
1730
|
* hc.environment.variables, and hc.globals lookups.
|
|
1731
1731
|
*/
|
|
1732
1732
|
variables?: Record<string, string>;
|
|
@@ -1772,7 +1772,7 @@ export interface PluginScriptRunResult {
|
|
|
1772
1772
|
*/
|
|
1773
1773
|
request: PluginScriptRequestInit;
|
|
1774
1774
|
/**
|
|
1775
|
-
* Ephemeral variable sets from hc.variables.set.
|
|
1775
|
+
* Ephemeral variable sets from hc.request.variables.set.
|
|
1776
1776
|
*/
|
|
1777
1777
|
variableSets: Record<string, string>;
|
|
1778
1778
|
/**
|
|
@@ -1836,7 +1836,7 @@ export interface PluginScriptContext {
|
|
|
1836
1836
|
* Script sandbox factory available on {@link MainPluginContext.scripts}.
|
|
1837
1837
|
*
|
|
1838
1838
|
* Runs user scripts with the same hc object as collection and request pre/post scripts
|
|
1839
|
-
* (`hc.request`, `hc.
|
|
1839
|
+
* (`hc.request`, `hc.collection`, `hc.environment`, `hc.globals`,
|
|
1840
1840
|
* `hc.test`, `hc.expect`, and `hc.response` when a response is provided).
|
|
1841
1841
|
*/
|
|
1842
1842
|
export interface PluginScripts {
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harborclient/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"description": "TypeScript SDK for HarborClient development.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"harborclient",
|
|
7
7
|
"plugins",
|
|
8
8
|
"themes",
|
|
9
9
|
"snippets",
|
|
10
|
-
"typescript"
|
|
11
|
-
"types"
|
|
10
|
+
"typescript"
|
|
12
11
|
],
|
|
13
12
|
"homepage": "https://github.com/harborclient/sdk",
|
|
14
13
|
"bugs": {
|