@flowdrop/flowdrop 2.15.1 → 2.16.0
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/CHANGELOG.md +69 -0
- package/README.md +4 -0
- package/dist/components/App.svelte +7 -0
- package/dist/components/App.svelte.d.ts +6 -0
- package/dist/components/Input.svelte +2 -2
- package/dist/components/Navbar.svelte +6 -0
- package/dist/components/SchemaForm.svelte +2 -1
- package/dist/components/SchemaForm.svelte.d.ts +2 -1
- package/dist/components/form/FormAutocomplete.svelte +76 -12
- package/dist/components/form/FormFieldset.svelte +5 -3
- package/dist/components/form/FormFieldset.svelte.d.ts +1 -1
- package/dist/components/primitives/Button.svelte +1 -1
- package/dist/components/primitives/Button.svelte.d.ts +1 -1
- package/dist/components/primitives/Card.svelte +1 -1
- package/dist/components/primitives/Card.svelte.d.ts +1 -1
- package/dist/components/primitives/Checkbox.svelte +1 -1
- package/dist/components/primitives/Checkbox.svelte.d.ts +1 -1
- package/dist/components/primitives/Chip.svelte +1 -1
- package/dist/components/primitives/Chip.svelte.d.ts +1 -1
- package/dist/components/primitives/Combobox.svelte +1 -1
- package/dist/components/primitives/Combobox.svelte.d.ts +1 -1
- package/dist/components/primitives/Composer.svelte +1 -1
- package/dist/components/primitives/Composer.svelte.d.ts +1 -1
- package/dist/components/primitives/EmptyState.svelte +1 -1
- package/dist/components/primitives/EmptyState.svelte.d.ts +1 -1
- package/dist/components/primitives/Field.svelte +1 -1
- package/dist/components/primitives/Field.svelte.d.ts +1 -1
- package/dist/components/primitives/IconButton.svelte +1 -1
- package/dist/components/primitives/IconButton.svelte.d.ts +1 -1
- package/dist/components/primitives/Menu.svelte +1 -1
- package/dist/components/primitives/Menu.svelte.d.ts +1 -1
- package/dist/components/primitives/Notice.svelte +1 -1
- package/dist/components/primitives/Notice.svelte.d.ts +1 -1
- package/dist/components/primitives/PanelHeader.svelte +1 -1
- package/dist/components/primitives/PanelHeader.svelte.d.ts +1 -1
- package/dist/components/primitives/Segmented.svelte +2 -2
- package/dist/components/primitives/Segmented.svelte.d.ts +2 -2
- package/dist/components/primitives/Select.svelte +1 -1
- package/dist/components/primitives/Select.svelte.d.ts +1 -1
- package/dist/components/primitives/StatusPill.svelte +1 -1
- package/dist/components/primitives/StatusPill.svelte.d.ts +1 -1
- package/dist/components/primitives/Switch.svelte +1 -1
- package/dist/components/primitives/Switch.svelte.d.ts +1 -1
- package/dist/components/primitives/Tabs.svelte +2 -2
- package/dist/components/primitives/Tabs.svelte.d.ts +2 -2
- package/dist/components/primitives/Toolbar.svelte +1 -1
- package/dist/components/primitives/Toolbar.svelte.d.ts +1 -1
- package/dist/components/primitives/ToolbarSeparator.svelte +1 -1
- package/dist/components/primitives/ToolbarSeparator.svelte.d.ts +1 -1
- package/dist/messages/defaults.d.ts +1 -0
- package/dist/messages/defaults.js +1 -0
- package/dist/openapi/v1/openapi.yaml +10 -2
- package/dist/schemas/v1/workflow.schema.json +1 -1
- package/dist/svelte-app.d.ts +21 -0
- package/dist/svelte-app.js +41 -2
- package/dist/themes/scopedSkinCss.d.ts +22 -0
- package/dist/themes/scopedSkinCss.js +27 -1
- package/dist/types/index.d.ts +11 -1
- package/dist/ui/index.d.ts +76 -0
- package/dist/ui/index.js +81 -0
- package/dist/utils/apiUrl.d.ts +55 -0
- package/dist/utils/apiUrl.js +117 -0
- package/dist/utils/portal.js +45 -3
- package/dist/webmcp/index.d.ts +5 -0
- package/dist/webmcp/index.js +5 -0
- package/package.json +6 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface SegmentedOption {
|
|
1
|
+
export interface SegmentedOption {
|
|
2
2
|
/** Value written to `value` when chosen */
|
|
3
3
|
value: string;
|
|
4
4
|
/** Visible label */
|
|
@@ -39,7 +39,7 @@ interface Props {
|
|
|
39
39
|
*
|
|
40
40
|
* `float` draws the switch as its own floating control, as in the canvas toolbar.
|
|
41
41
|
*
|
|
42
|
-
*
|
|
42
|
+
* Exported from `@flowdrop/flowdrop/ui`.
|
|
43
43
|
*/
|
|
44
44
|
declare const Segmented: import("svelte").Component<Props, {}, "value">;
|
|
45
45
|
type Segmented = ReturnType<typeof Segmented>;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
**Use it for** choosing one value in a config form.
|
|
16
16
|
**Not for** a list of actions; use `Menu`. Not for a two or three way mode; use `Segmented`.
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Exported from `@flowdrop/flowdrop/ui`.
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
21
|
<script lang="ts">
|
|
@@ -37,7 +37,7 @@ interface Props extends Omit<HTMLSelectAttributes, 'size' | 'children' | 'value'
|
|
|
37
37
|
* **Use it for** choosing one value in a config form.
|
|
38
38
|
* **Not for** a list of actions; use `Menu`. Not for a two or three way mode; use `Segmented`.
|
|
39
39
|
*
|
|
40
|
-
*
|
|
40
|
+
* Exported from `@flowdrop/flowdrop/ui`.
|
|
41
41
|
*/
|
|
42
42
|
declare const Select: import("svelte").Component<Props, {}, "">;
|
|
43
43
|
type Select = ReturnType<typeof Select>;
|
|
@@ -32,7 +32,7 @@ interface Props {
|
|
|
32
32
|
* **Use it for** the run status of a node or a run on the canvas.
|
|
33
33
|
* **Not for** a free-form tag; use `Chip`.
|
|
34
34
|
*
|
|
35
|
-
*
|
|
35
|
+
* Exported from `@flowdrop/flowdrop/ui`.
|
|
36
36
|
*/
|
|
37
37
|
declare const StatusPill: import("svelte").Component<Props, {}, "">;
|
|
38
38
|
type StatusPill = ReturnType<typeof StatusPill>;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
**Use it for** a setting that takes effect right away.
|
|
10
10
|
**Not for** an option that is saved later with a form; use `Checkbox`.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Exported from `@flowdrop/flowdrop/ui`.
|
|
13
13
|
-->
|
|
14
14
|
|
|
15
15
|
<script lang="ts">
|
|
@@ -19,7 +19,7 @@ interface Props extends Omit<HTMLInputAttributes, 'type' | 'checked' | 'onchange
|
|
|
19
19
|
* **Use it for** a setting that takes effect right away.
|
|
20
20
|
* **Not for** an option that is saved later with a form; use `Checkbox`.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* Exported from `@flowdrop/flowdrop/ui`.
|
|
23
23
|
*/
|
|
24
24
|
declare const Switch: import("svelte").Component<Props, {}, "">;
|
|
25
25
|
type Switch = ReturnType<typeof Switch>;
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
Each tab has `id={tabId(idBase, value)}` and `aria-controls={tabPanelId(idBase, value)}`.
|
|
19
19
|
Without `idBase` an id is generated that you cannot know, so pass `idBase` whenever panels exist.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Exported from `@flowdrop/flowdrop/ui`.
|
|
22
22
|
-->
|
|
23
23
|
|
|
24
24
|
<script lang="ts" module>
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
<script lang="ts">
|
|
36
36
|
import Icon from '@iconify/svelte';
|
|
37
37
|
|
|
38
|
-
interface TabItem {
|
|
38
|
+
export interface TabItem {
|
|
39
39
|
/** Value written to `value` when chosen */
|
|
40
40
|
value: string;
|
|
41
41
|
/** Visible label */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare function tabId(idBase: string, value: string): string;
|
|
3
3
|
/** DOM id of the panel the tab for `value` controls. */
|
|
4
4
|
export declare function tabPanelId(idBase: string, value: string): string;
|
|
5
|
-
interface TabItem {
|
|
5
|
+
export interface TabItem {
|
|
6
6
|
/** Value written to `value` when chosen */
|
|
7
7
|
value: string;
|
|
8
8
|
/** Visible label */
|
|
@@ -47,7 +47,7 @@ interface Props {
|
|
|
47
47
|
* Each tab has `id={tabId(idBase, value)}` and `aria-controls={tabPanelId(idBase, value)}`.
|
|
48
48
|
* Without `idBase` an id is generated that you cannot know, so pass `idBase` whenever panels exist.
|
|
49
49
|
*
|
|
50
|
-
*
|
|
50
|
+
* Exported from `@flowdrop/flowdrop/ui`.
|
|
51
51
|
*/
|
|
52
52
|
declare const Tabs: import("svelte").Component<Props, {}, "value">;
|
|
53
53
|
type Tabs = ReturnType<typeof Tabs>;
|
|
@@ -25,7 +25,7 @@ interface Props {
|
|
|
25
25
|
* (Editor/Canvas).
|
|
26
26
|
* **Not for** drawing a bar; it has no surface of its own.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
28
|
+
* Exported from `@flowdrop/flowdrop/ui`.
|
|
29
29
|
*/
|
|
30
30
|
declare const Toolbar: import("svelte").Component<Props, {}, "">;
|
|
31
31
|
type Toolbar = ReturnType<typeof Toolbar>;
|
|
@@ -7,7 +7,7 @@ interface Props {
|
|
|
7
7
|
*
|
|
8
8
|
* Pass the same `orientation` as the toolbar. The line is drawn across that axis.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* Exported from `@flowdrop/flowdrop/ui`.
|
|
11
11
|
*/
|
|
12
12
|
declare const ToolbarSeparator: import("svelte").Component<Props, {}, "">;
|
|
13
13
|
type ToolbarSeparator = ReturnType<typeof ToolbarSeparator>;
|
|
@@ -132,6 +132,7 @@ export declare const defaultMessages: {
|
|
|
132
132
|
readonly suggestions: "Suggestions";
|
|
133
133
|
readonly retry: "Retry";
|
|
134
134
|
readonly timedOut: "The request timed out";
|
|
135
|
+
readonly invalidUrl: "Suggestions are not available: the field has an invalid URL";
|
|
135
136
|
readonly noResults: "No results found";
|
|
136
137
|
};
|
|
137
138
|
readonly field: {
|
|
@@ -106,6 +106,7 @@ export const defaultMessages = {
|
|
|
106
106
|
suggestions: 'Suggestions',
|
|
107
107
|
retry: 'Retry',
|
|
108
108
|
timedOut: 'The request timed out',
|
|
109
|
+
invalidUrl: 'Suggestions are not available: the field has an invalid URL',
|
|
109
110
|
noResults: 'No results found'
|
|
110
111
|
},
|
|
111
112
|
field: {
|
|
@@ -3251,8 +3251,16 @@ components:
|
|
|
3251
3251
|
type: string
|
|
3252
3252
|
description: |
|
|
3253
3253
|
The callback URL to fetch autocomplete suggestions from.
|
|
3254
|
-
|
|
3255
|
-
|
|
3254
|
+
|
|
3255
|
+
- `https://host/…` or `//host/…`: used as given.
|
|
3256
|
+
- `/path`: relative to the site, used as given.
|
|
3257
|
+
- `path` or `./path` without a leading slash: relative to the API base
|
|
3258
|
+
(`endpointConfig.baseUrl`), so `secrets/options` reaches
|
|
3259
|
+
`{baseUrl}/secrets/options`. A `SchemaForm` given a `baseUrl` prop
|
|
3260
|
+
uses the prop instead; with neither, the URL is used as given.
|
|
3261
|
+
- Malformed URLs are refused and nothing is fetched; the full rule is
|
|
3262
|
+
in the library's config schema guide ("How `url` is resolved").
|
|
3263
|
+
example: secrets/options
|
|
3256
3264
|
queryParam:
|
|
3257
3265
|
type: string
|
|
3258
3266
|
default: q
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"properties": {
|
|
118
118
|
"url": {
|
|
119
119
|
"type": "string",
|
|
120
|
-
"description": "The callback URL to fetch autocomplete suggestions from.\
|
|
120
|
+
"description": "The callback URL to fetch autocomplete suggestions from.\n\n- `https://host/…` or `//host/…`: used as given.\n- `/path`: relative to the site, used as given.\n- `path` or `./path` without a leading slash: relative to the API base\n (`endpointConfig.baseUrl`), so `secrets/options` reaches\n `{baseUrl}/secrets/options`. A `SchemaForm` given a `baseUrl` prop\n uses the prop instead; with neither, the URL is used as given.\n- Malformed URLs are refused and nothing is fetched; the full rule is\n in the library's config schema guide (\"How `url` is resolved\").\n"
|
|
121
121
|
},
|
|
122
122
|
"queryParam": {
|
|
123
123
|
"type": "string",
|
package/dist/svelte-app.d.ts
CHANGED
|
@@ -103,6 +103,27 @@ export interface FlowDropMountOptions {
|
|
|
103
103
|
* logo's accessible name, `logoAlt` overrides the logo's accessible name, `href` an optional link around it.
|
|
104
104
|
*/
|
|
105
105
|
branding?: NavbarBranding;
|
|
106
|
+
/**
|
|
107
|
+
* Host content at the navbar's trailing end, before the settings gear, e.g. a
|
|
108
|
+
* user menu. Only shown with the navbar.
|
|
109
|
+
*
|
|
110
|
+
* The library renders an empty host element there and calls this with it, once
|
|
111
|
+
* the element is in the page. The callback runs whenever the navbar renders that slot (so it may run again if the
|
|
112
|
+
* navbar is re-mounted); the function it returns, if any, is called when the slot
|
|
113
|
+
* goes away.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* // Svelte host
|
|
117
|
+
* navbarEnd: (target) => {
|
|
118
|
+
* const c = mount(UserMenu, { target });
|
|
119
|
+
* return () => unmount(c);
|
|
120
|
+
* }
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* // Plain JS host
|
|
124
|
+
* navbarEnd: (target) => target.append(button)
|
|
125
|
+
*/
|
|
126
|
+
navbarEnd?: (target: HTMLElement) => void | (() => void);
|
|
106
127
|
/** Show settings gear icon in navbar */
|
|
107
128
|
showSettings?: boolean;
|
|
108
129
|
/** Show the "Connected" status indicator in the navbar (default: true) */
|
package/dist/svelte-app.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module svelte-app
|
|
8
8
|
*/
|
|
9
|
-
import { mount, unmount } from 'svelte';
|
|
9
|
+
import { mount, unmount, createRawSnippet, untrack } from 'svelte';
|
|
10
10
|
import WorkflowEditor from './components/WorkflowEditor.svelte';
|
|
11
11
|
import App from './components/App.svelte';
|
|
12
12
|
import { DEFAULT_PORT_CONFIG } from './config/defaultPortConfig.js';
|
|
@@ -279,7 +279,45 @@ function createRunCommand(fd, isDestroyed, registerCancel, onBaseline) {
|
|
|
279
279
|
* ```
|
|
280
280
|
*/
|
|
281
281
|
export async function mountFlowDropApp(container, options = {}) {
|
|
282
|
-
const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, editorMode, onEditorModeChange, playground, pipelineId, navbarTitle, navbarActions, branding, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, colorScheme, draftStorageKey: customDraftKey, draftStorage, formatAdapters, workflowFormats, workflowSettingsSchema, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId, webmcp, host, contextMenu } = options;
|
|
282
|
+
const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, editorMode, onEditorModeChange, playground, pipelineId, navbarTitle, navbarActions, branding, navbarEnd, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, colorScheme, draftStorageKey: customDraftKey, draftStorage, formatAdapters, workflowFormats, workflowSettingsSchema, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId, webmcp, host, contextMenu } = options;
|
|
283
|
+
// The host's element callback becomes a snippet: one empty host element, handed
|
|
284
|
+
// to the callback in `setup`, whose return value is the cleanup.
|
|
285
|
+
if (navbarEnd && showNavbar !== true) {
|
|
286
|
+
logger.warn('[FlowDrop] navbarEnd was given but showNavbar is not true: the navbar is hidden, so navbarEnd will not render.');
|
|
287
|
+
}
|
|
288
|
+
const navbarEndSnippet = navbarEnd
|
|
289
|
+
? createRawSnippet(() => ({
|
|
290
|
+
render: () => '<div class="flowdrop-navbar__host-end"></div>',
|
|
291
|
+
setup: (el) => {
|
|
292
|
+
let cleanup;
|
|
293
|
+
let gone = false;
|
|
294
|
+
const run = () => {
|
|
295
|
+
if (gone)
|
|
296
|
+
return;
|
|
297
|
+
// untrack: state the host reads must not re-run the navbar. A throwing
|
|
298
|
+
// callback is logged and skipped, so it cannot break the editor.
|
|
299
|
+
try {
|
|
300
|
+
const result = untrack(() => navbarEnd(el));
|
|
301
|
+
if (typeof result === 'function')
|
|
302
|
+
cleanup = result;
|
|
303
|
+
}
|
|
304
|
+
catch (error) {
|
|
305
|
+
logger.error('[FlowDrop] navbarEnd callback failed:', error);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
// On the editor's first render the navbar is built before it is
|
|
309
|
+
// attached to the page; the host gets the element once it is in it.
|
|
310
|
+
if (el.isConnected)
|
|
311
|
+
run();
|
|
312
|
+
else
|
|
313
|
+
queueMicrotask(run);
|
|
314
|
+
return () => {
|
|
315
|
+
gone = true;
|
|
316
|
+
cleanup?.();
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
}))
|
|
320
|
+
: undefined;
|
|
283
321
|
// Per-instance state container — this is what allows multiple FlowDrop
|
|
284
322
|
// editors to coexist on one page without sharing workflow/history state.
|
|
285
323
|
const { fd, isDefault } = acquireInstance(instanceId);
|
|
@@ -346,6 +384,7 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
346
384
|
navbarTitle,
|
|
347
385
|
navbarActions,
|
|
348
386
|
branding,
|
|
387
|
+
navbarEnd: navbarEndSnippet,
|
|
349
388
|
showSettings,
|
|
350
389
|
showStatus,
|
|
351
390
|
endpointConfig: config,
|
|
@@ -45,3 +45,25 @@ export declare function scopeSelector(scopeId: string): string;
|
|
|
45
45
|
* Returns '' when the skin and display set nothing.
|
|
46
46
|
*/
|
|
47
47
|
export declare function buildScopedSkinCss(scopeId: string, skin: Pick<FlowDropSkin, 'tokens' | 'darkTokens' | 'font'> | undefined, display?: FlowDropDisplayConfig): string;
|
|
48
|
+
/**
|
|
49
|
+
* CSS for a skin on any element a host chooses, e.g. a whole app on `:root`:
|
|
50
|
+
*
|
|
51
|
+
* tokens → {selector}{selector} (light / base)
|
|
52
|
+
* darkTokens → {selector}[data-theme='dark'] (dark)
|
|
53
|
+
*
|
|
54
|
+
* The doubled selector outranks tokens.css's own `:root` block, as the scoped
|
|
55
|
+
* rule does. Dark mode follows `data-theme="dark"` on that element, the same
|
|
56
|
+
* attribute tokens.css keys its dark palette on, so a host sets it there; for
|
|
57
|
+
* `:root` that is `<html data-theme>`, set by the host and still supported.
|
|
58
|
+
* (Only the editor *writing* its theme to `<html>`, the mirror, is deprecated
|
|
59
|
+
* and goes in 3.0.) For the
|
|
60
|
+
* components' base styles use an element that is also `.flowdrop-scope`, e.g.
|
|
61
|
+
* `skinCss(graphiteSkin, '.flowdrop-scope')`.
|
|
62
|
+
* Load tokens.css first; this only overrides it.
|
|
63
|
+
*
|
|
64
|
+
* @param skin - The skin, e.g. `graphiteSkin`
|
|
65
|
+
* @param selector - Where the tokens apply (default `:root`): one trusted, static
|
|
66
|
+
* compound selector such as `:root` or `.app`. It is doubled for specificity, so a
|
|
67
|
+
* selector list (`a, b`) or a descendant selector (`.a .b`) does not work.
|
|
68
|
+
*/
|
|
69
|
+
export declare function skinCss(skin: Pick<FlowDropSkin, 'tokens' | 'darkTokens' | 'font'>, selector?: string): string;
|
|
@@ -187,13 +187,39 @@ export function scopeSelector(scopeId) {
|
|
|
187
187
|
* Returns '' when the skin and display set nothing.
|
|
188
188
|
*/
|
|
189
189
|
export function buildScopedSkinCss(scopeId, skin, display) {
|
|
190
|
+
return buildSkinCss(scopeSelector(scopeId), skin, display);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* CSS for a skin on any element a host chooses, e.g. a whole app on `:root`:
|
|
194
|
+
*
|
|
195
|
+
* tokens → {selector}{selector} (light / base)
|
|
196
|
+
* darkTokens → {selector}[data-theme='dark'] (dark)
|
|
197
|
+
*
|
|
198
|
+
* The doubled selector outranks tokens.css's own `:root` block, as the scoped
|
|
199
|
+
* rule does. Dark mode follows `data-theme="dark"` on that element, the same
|
|
200
|
+
* attribute tokens.css keys its dark palette on, so a host sets it there; for
|
|
201
|
+
* `:root` that is `<html data-theme>`, set by the host and still supported.
|
|
202
|
+
* (Only the editor *writing* its theme to `<html>`, the mirror, is deprecated
|
|
203
|
+
* and goes in 3.0.) For the
|
|
204
|
+
* components' base styles use an element that is also `.flowdrop-scope`, e.g.
|
|
205
|
+
* `skinCss(graphiteSkin, '.flowdrop-scope')`.
|
|
206
|
+
* Load tokens.css first; this only overrides it.
|
|
207
|
+
*
|
|
208
|
+
* @param skin - The skin, e.g. `graphiteSkin`
|
|
209
|
+
* @param selector - Where the tokens apply (default `:root`): one trusted, static
|
|
210
|
+
* compound selector such as `:root` or `.app`. It is doubled for specificity, so a
|
|
211
|
+
* selector list (`a, b`) or a descendant selector (`.a .b`) does not work.
|
|
212
|
+
*/
|
|
213
|
+
export function skinCss(skin, selector = ':root') {
|
|
214
|
+
return buildSkinCss(selector, skin);
|
|
215
|
+
}
|
|
216
|
+
function buildSkinCss(scope, skin, display) {
|
|
190
217
|
const tokens = effectiveSkinTokens(skin, display);
|
|
191
218
|
const darkTokens = skin?.darkTokens ?? {};
|
|
192
219
|
const lightKeys = Object.keys(tokens);
|
|
193
220
|
const darkKeys = Object.keys(darkTokens);
|
|
194
221
|
if (lightKeys.length === 0 && darkKeys.length === 0)
|
|
195
222
|
return '';
|
|
196
|
-
const scope = scopeSelector(scopeId);
|
|
197
223
|
// A skin's light tokens also apply in dark mode (as with the old :root rule),
|
|
198
224
|
// so an alias a skin sets in either palette is never overridden here.
|
|
199
225
|
const skinSet = new Set([...lightKeys, ...darkKeys]);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -336,7 +336,17 @@ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH';
|
|
|
336
336
|
export interface AutocompleteConfig {
|
|
337
337
|
/**
|
|
338
338
|
* The callback URL to fetch autocomplete suggestions from.
|
|
339
|
-
*
|
|
339
|
+
*
|
|
340
|
+
* - `https://host/…` or `//host/…`: used as given.
|
|
341
|
+
* - `/path`: relative to the site, used as given (SchemaForm puts its
|
|
342
|
+
* `baseUrl` prop in front of it).
|
|
343
|
+
* - `path` or `./path` without a leading slash: relative to the API base
|
|
344
|
+
* (`endpointConfig.baseUrl`), so `secrets/options` reaches
|
|
345
|
+
* `{baseUrl}/secrets/options` wherever the editor mounts the API. A
|
|
346
|
+
* SchemaForm given a `baseUrl` prop uses the prop instead; with neither,
|
|
347
|
+
* the URL is used as given.
|
|
348
|
+
* - Malformed URLs are refused and nothing is fetched; the full rule is in
|
|
349
|
+
* docs/config-schema-guide.md ("How `url` is resolved").
|
|
340
350
|
*/
|
|
341
351
|
url: string;
|
|
342
352
|
/**
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlowDrop UI Module
|
|
3
|
+
*
|
|
4
|
+
* The design-system components the editor is built from: the primitives, the
|
|
5
|
+
* surfaces, and the text controls. They use the `--fd-*` tokens only, so a host
|
|
6
|
+
* that loads the package's styles gets the editor's look in its own pages.
|
|
7
|
+
*
|
|
8
|
+
* @module ui
|
|
9
|
+
*
|
|
10
|
+
* Experimental in 2.x: names and props may still change in a minor release
|
|
11
|
+
* while the design system settles. It becomes semver-stable no later than 3.0;
|
|
12
|
+
* pin a minor version (`~2.16.0`) if you depend on it.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```svelte
|
|
16
|
+
* <script>
|
|
17
|
+
* import { Button, Card } from '@flowdrop/flowdrop/ui';
|
|
18
|
+
* import '@flowdrop/flowdrop/styles/base.css';
|
|
19
|
+
* </script>
|
|
20
|
+
*
|
|
21
|
+
* <div class="flowdrop-scope" data-theme="light">
|
|
22
|
+
* <Card><Button variant="primary">Save</Button></Card>
|
|
23
|
+
* </div>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* The base styles (box-sizing, type, `color-scheme`) apply only inside
|
|
27
|
+
* `.flowdrop-root`, `.flowdrop-scope` or `.flowdrop-portal`, so wrap the host
|
|
28
|
+
* content that uses these components in one of them. Set `data-theme`
|
|
29
|
+
* (`light` or `dark`) on that wrapper: an overlay such as `SurfaceOverlay` is
|
|
30
|
+
* moved to `<body>` and takes the scheme from it. Without one, the overlay
|
|
31
|
+
* follows the editor's stored theme setting, which may not match the page.
|
|
32
|
+
*
|
|
33
|
+
* To give that content the editor's Graphite look, load tokens.css and add
|
|
34
|
+
* `skinCss(graphiteSkin, '.flowdrop-scope')` as a stylesheet. Dark mode is
|
|
35
|
+
* `data-theme="dark"` on the element the selector matches (here the
|
|
36
|
+
* `.flowdrop-scope` div); for the default `:root` the host sets it on `<html>`
|
|
37
|
+
* itself, which stays supported. Only the editor writing its theme to `<html>`
|
|
38
|
+
* (the mirror) is deprecated, removed in 3.0. The selector is scoped so the skin
|
|
39
|
+
* stays inside the wrapper; the default `:root` restyles the whole page.
|
|
40
|
+
*
|
|
41
|
+
* Built-in strings (labels, placeholders) are English by default and follow
|
|
42
|
+
* `setMessages` from `@flowdrop/flowdrop/core` when the host calls it in an
|
|
43
|
+
* ancestor component.
|
|
44
|
+
*/
|
|
45
|
+
export { default as Button } from '../components/primitives/Button.svelte';
|
|
46
|
+
export { default as Card } from '../components/primitives/Card.svelte';
|
|
47
|
+
export { default as Checkbox } from '../components/primitives/Checkbox.svelte';
|
|
48
|
+
export { default as Chip } from '../components/primitives/Chip.svelte';
|
|
49
|
+
export { default as Combobox } from '../components/primitives/Combobox.svelte';
|
|
50
|
+
export { default as Composer } from '../components/primitives/Composer.svelte';
|
|
51
|
+
export { default as EmptyState } from '../components/primitives/EmptyState.svelte';
|
|
52
|
+
export { default as Field } from '../components/primitives/Field.svelte';
|
|
53
|
+
export { default as IconButton } from '../components/primitives/IconButton.svelte';
|
|
54
|
+
export { default as Menu } from '../components/primitives/Menu.svelte';
|
|
55
|
+
export type { MenuItem, MenuEntry, MenuGroup, MenuSeparator } from '../components/primitives/Menu.svelte';
|
|
56
|
+
export { default as Notice } from '../components/primitives/Notice.svelte';
|
|
57
|
+
export { default as PanelHeader } from '../components/primitives/PanelHeader.svelte';
|
|
58
|
+
export { default as Segmented } from '../components/primitives/Segmented.svelte';
|
|
59
|
+
export type { SegmentedOption } from '../components/primitives/Segmented.svelte';
|
|
60
|
+
export { default as Select } from '../components/primitives/Select.svelte';
|
|
61
|
+
export type { SelectOption } from '../utils/selectOptions.js';
|
|
62
|
+
export { default as StatusPill } from '../components/primitives/StatusPill.svelte';
|
|
63
|
+
export type { StatusPillStatus } from '../components/primitives/StatusPill.svelte';
|
|
64
|
+
export { default as Switch } from '../components/primitives/Switch.svelte';
|
|
65
|
+
export { default as Tabs, tabId, tabPanelId } from '../components/primitives/Tabs.svelte';
|
|
66
|
+
export type { TabItem } from '../components/primitives/Tabs.svelte';
|
|
67
|
+
export { default as Toolbar } from '../components/primitives/Toolbar.svelte';
|
|
68
|
+
export { default as ToolbarSeparator } from '../components/primitives/ToolbarSeparator.svelte';
|
|
69
|
+
export { default as SurfaceOverlay } from '../components/surfaces/SurfaceOverlay.svelte';
|
|
70
|
+
export { default as TabbedSurface } from '../components/surfaces/TabbedSurface.svelte';
|
|
71
|
+
export type { SurfaceTab } from '../components/surfaces/TabbedSurface.svelte';
|
|
72
|
+
export { default as Input } from '../components/Input.svelte';
|
|
73
|
+
export { default as Textarea } from '../components/Textarea.svelte';
|
|
74
|
+
export { graphiteSkin } from '../skins/graphite.js';
|
|
75
|
+
export { skinCss } from '../themes/scopedSkinCss.js';
|
|
76
|
+
export type { FlowDropSkin } from '../types/skin.js';
|
package/dist/ui/index.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlowDrop UI Module
|
|
3
|
+
*
|
|
4
|
+
* The design-system components the editor is built from: the primitives, the
|
|
5
|
+
* surfaces, and the text controls. They use the `--fd-*` tokens only, so a host
|
|
6
|
+
* that loads the package's styles gets the editor's look in its own pages.
|
|
7
|
+
*
|
|
8
|
+
* @module ui
|
|
9
|
+
*
|
|
10
|
+
* Experimental in 2.x: names and props may still change in a minor release
|
|
11
|
+
* while the design system settles. It becomes semver-stable no later than 3.0;
|
|
12
|
+
* pin a minor version (`~2.16.0`) if you depend on it.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```svelte
|
|
16
|
+
* <script>
|
|
17
|
+
* import { Button, Card } from '@flowdrop/flowdrop/ui';
|
|
18
|
+
* import '@flowdrop/flowdrop/styles/base.css';
|
|
19
|
+
* </script>
|
|
20
|
+
*
|
|
21
|
+
* <div class="flowdrop-scope" data-theme="light">
|
|
22
|
+
* <Card><Button variant="primary">Save</Button></Card>
|
|
23
|
+
* </div>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* The base styles (box-sizing, type, `color-scheme`) apply only inside
|
|
27
|
+
* `.flowdrop-root`, `.flowdrop-scope` or `.flowdrop-portal`, so wrap the host
|
|
28
|
+
* content that uses these components in one of them. Set `data-theme`
|
|
29
|
+
* (`light` or `dark`) on that wrapper: an overlay such as `SurfaceOverlay` is
|
|
30
|
+
* moved to `<body>` and takes the scheme from it. Without one, the overlay
|
|
31
|
+
* follows the editor's stored theme setting, which may not match the page.
|
|
32
|
+
*
|
|
33
|
+
* To give that content the editor's Graphite look, load tokens.css and add
|
|
34
|
+
* `skinCss(graphiteSkin, '.flowdrop-scope')` as a stylesheet. Dark mode is
|
|
35
|
+
* `data-theme="dark"` on the element the selector matches (here the
|
|
36
|
+
* `.flowdrop-scope` div); for the default `:root` the host sets it on `<html>`
|
|
37
|
+
* itself, which stays supported. Only the editor writing its theme to `<html>`
|
|
38
|
+
* (the mirror) is deprecated, removed in 3.0. The selector is scoped so the skin
|
|
39
|
+
* stays inside the wrapper; the default `:root` restyles the whole page.
|
|
40
|
+
*
|
|
41
|
+
* Built-in strings (labels, placeholders) are English by default and follow
|
|
42
|
+
* `setMessages` from `@flowdrop/flowdrop/core` when the host calls it in an
|
|
43
|
+
* ancestor component.
|
|
44
|
+
*/
|
|
45
|
+
// ============================================================================
|
|
46
|
+
// Primitives
|
|
47
|
+
// ============================================================================
|
|
48
|
+
export { default as Button } from '../components/primitives/Button.svelte';
|
|
49
|
+
export { default as Card } from '../components/primitives/Card.svelte';
|
|
50
|
+
export { default as Checkbox } from '../components/primitives/Checkbox.svelte';
|
|
51
|
+
export { default as Chip } from '../components/primitives/Chip.svelte';
|
|
52
|
+
export { default as Combobox } from '../components/primitives/Combobox.svelte';
|
|
53
|
+
export { default as Composer } from '../components/primitives/Composer.svelte';
|
|
54
|
+
export { default as EmptyState } from '../components/primitives/EmptyState.svelte';
|
|
55
|
+
export { default as Field } from '../components/primitives/Field.svelte';
|
|
56
|
+
export { default as IconButton } from '../components/primitives/IconButton.svelte';
|
|
57
|
+
export { default as Menu } from '../components/primitives/Menu.svelte';
|
|
58
|
+
export { default as Notice } from '../components/primitives/Notice.svelte';
|
|
59
|
+
export { default as PanelHeader } from '../components/primitives/PanelHeader.svelte';
|
|
60
|
+
export { default as Segmented } from '../components/primitives/Segmented.svelte';
|
|
61
|
+
export { default as Select } from '../components/primitives/Select.svelte';
|
|
62
|
+
export { default as StatusPill } from '../components/primitives/StatusPill.svelte';
|
|
63
|
+
export { default as Switch } from '../components/primitives/Switch.svelte';
|
|
64
|
+
export { default as Tabs, tabId, tabPanelId } from '../components/primitives/Tabs.svelte';
|
|
65
|
+
export { default as Toolbar } from '../components/primitives/Toolbar.svelte';
|
|
66
|
+
export { default as ToolbarSeparator } from '../components/primitives/ToolbarSeparator.svelte';
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// Surfaces
|
|
69
|
+
// ============================================================================
|
|
70
|
+
export { default as SurfaceOverlay } from '../components/surfaces/SurfaceOverlay.svelte';
|
|
71
|
+
export { default as TabbedSurface } from '../components/surfaces/TabbedSurface.svelte';
|
|
72
|
+
// ============================================================================
|
|
73
|
+
// Text controls
|
|
74
|
+
// ============================================================================
|
|
75
|
+
export { default as Input } from '../components/Input.svelte';
|
|
76
|
+
export { default as Textarea } from '../components/Textarea.svelte';
|
|
77
|
+
// ============================================================================
|
|
78
|
+
// Skin: the editor's look for a host's own pages
|
|
79
|
+
// ============================================================================
|
|
80
|
+
export { graphiteSkin } from '../skins/graphite.js';
|
|
81
|
+
export { skinCss } from '../themes/scopedSkinCss.js';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve an autocomplete callback URL from node metadata.
|
|
3
|
+
*
|
|
4
|
+
* The URL's own form says what it is relative to:
|
|
5
|
+
*
|
|
6
|
+
* - `https://host/…` or `//host/…` names its own origin and is used as given.
|
|
7
|
+
* - `/path` is relative to the site and is used as given. A `prefix` (the
|
|
8
|
+
* `baseUrl` prop of `SchemaForm`) is put in front of it, as it always was.
|
|
9
|
+
* - `path` (no leading slash, optionally `./path`) is relative to the API
|
|
10
|
+
* base, so a backend can name its own endpoints without knowing where the
|
|
11
|
+
* editor reaches it, e.g. behind a hub's proxy mount
|
|
12
|
+
* (`secrets/options` under `/api/flowdrop/remotes/r1` →
|
|
13
|
+
* `/api/flowdrop/remotes/r1/secrets/options`). A `prefix` (a `SchemaForm`
|
|
14
|
+
* given a `baseUrl` prop) takes precedence: what the form was given beats
|
|
15
|
+
* the editor's base. With neither it is used as given.
|
|
16
|
+
*
|
|
17
|
+
* The base is treated as a folder: its last segment is kept, so
|
|
18
|
+
* `secrets/options` under `https://site/api/flowdrop` is
|
|
19
|
+
* `https://site/api/flowdrop/secrets/options`. This differs on purpose from
|
|
20
|
+
* `new URL()` and HTML resolution, which would drop `flowdrop`.
|
|
21
|
+
*
|
|
22
|
+
* Refused, the result is `null`: any URL with a tab or newline, a control
|
|
23
|
+
* character or space at either end, or a backslash in its path (the browser
|
|
24
|
+
* would fetch something other than its text says), and a no-slash URL that is
|
|
25
|
+
* empty, starts with `?` or `#`, or contains a `..` path segment (`%2e%2e`
|
|
26
|
+
* included).
|
|
27
|
+
*
|
|
28
|
+
* @param url - The URL from the schema's `autocomplete.url`
|
|
29
|
+
* @param base - The API base (`endpointConfig.baseUrl`), relative or absolute
|
|
30
|
+
* @param prefix - SchemaForm's `baseUrl` prop: goes in front of `/path` URLs,
|
|
31
|
+
* and, when set, is the base for no-slash URLs instead of `base`
|
|
32
|
+
* @returns The URL to fetch, or `null` when the URL is refused
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveAutocompleteUrl(url: string, base?: string, prefix?: string): string | null;
|
|
35
|
+
/**
|
|
36
|
+
* Whether `url` is written relative to the API base: no scheme, no `//host`,
|
|
37
|
+
* no leading slash (`secrets/options`, `./secrets/options`).
|
|
38
|
+
*/
|
|
39
|
+
export declare function isBaseRelative(url: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether `url` names its own origin: it has a scheme (`https://…`) or is
|
|
42
|
+
* `//host/…`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isAbsoluteUrl(url: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether a request may carry the instance's auth: it goes to the page's own
|
|
47
|
+
* origin, or to the API base's origin under the base path. Decided on the URL
|
|
48
|
+
* the browser actually fetches, not on its text.
|
|
49
|
+
*
|
|
50
|
+
* @param requestUrl - The URL that is fetched
|
|
51
|
+
* @param apiBase - The API base (`endpointConfig.baseUrl`), relative or absolute
|
|
52
|
+
* @param pageUrl - The page's URL (`location.href`); without one (SSR) only an
|
|
53
|
+
* absolute URL under an absolute API base qualifies
|
|
54
|
+
*/
|
|
55
|
+
export declare function mayCarryInstanceAuth(requestUrl: string, apiBase: string, pageUrl: string | undefined): boolean;
|