@cervio/create-plugin 0.0.0-stage → 1.1.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/LICENSE +21 -0
- package/README.md +101 -2
- package/dist/chunk-AGG3S6VV.js +209 -0
- package/dist/cli.js +10 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +6 -0
- package/package.json +55 -3
- package/template/.cursor/rules/cervio-plugin.mdc +39 -0
- package/template/AGENTS.md +213 -0
- package/template/README.md +43 -0
- package/template/cervio.json +5 -0
- package/template/gitignore +4 -0
- package/template/index.html +12 -0
- package/template/manifest.json +13 -0
- package/template/package.json +28 -0
- package/template/src/App.tsx +92 -0
- package/template/src/SurfaceApp.tsx +40 -0
- package/template/src/i18n/en.ts +17 -0
- package/template/src/i18n/index.ts +15 -0
- package/template/src/i18n/it.ts +17 -0
- package/template/src/index.css +99 -0
- package/template/src/main.tsx +10 -0
- package/template/src/surface-main.tsx +10 -0
- package/template/src/vite-env.d.ts +5 -0
- package/template/surface.html +12 -0
- package/template/tsconfig.json +18 -0
- package/template/vite.config.ts +37 -0
- package/template/vite.surface.config.ts +25 -0
- package/template-policy/README.md +46 -0
- package/template-policy/cervio.json +4 -0
- package/template-policy/gitignore +4 -0
- package/template-policy/manifest.json +28 -0
- package/template-policy/package.json +19 -0
- package/template-policy/server/index.js +35 -0
- package/template-policy/src/index.js +50 -0
- package/template-task/.cursor/rules/cervio-plugin.mdc +17 -0
- package/template-task/AGENTS.md +34 -0
- package/template-task/README.md +46 -0
- package/template-task/cervio.json +4 -0
- package/template-task/gitignore +4 -0
- package/template-task/index.html +12 -0
- package/template-task/manifest.json +11 -0
- package/template-task/package.json +28 -0
- package/template-task/src/App.tsx +117 -0
- package/template-task/src/i18n/en.ts +14 -0
- package/template-task/src/i18n/index.ts +14 -0
- package/template-task/src/i18n/it.ts +14 -0
- package/template-task/src/index.css +117 -0
- package/template-task/src/main.tsx +10 -0
- package/template-task/src/vite-env.d.ts +5 -0
- package/template-task/tsconfig.json +18 -0
- package/template-task/vite.config.ts +31 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write-gate plugin source: edit this file, then `npm run build`
|
|
3
|
+
* (bundles into `server/index.js`). The host isolate cannot resolve node_modules.
|
|
4
|
+
*
|
|
5
|
+
* Host-mediated reads: declare entities with access:["read"] in manifest.json,
|
|
6
|
+
* then use the second `host` argument (getRecord / listRecords / sumField).
|
|
7
|
+
* Reads run as the save caller; they share the hook deadlineMs.
|
|
8
|
+
*/
|
|
9
|
+
import { definePolicy, allow, deny } from '@cervio/plugin-sdk/policy'
|
|
10
|
+
|
|
11
|
+
export default definePolicy(async (input, host) => {
|
|
12
|
+
const message =
|
|
13
|
+
(input.settings && typeof input.settings.block_message === 'string'
|
|
14
|
+
? input.settings.block_message
|
|
15
|
+
: null) || 'Save blocked by example write-gate plugin'
|
|
16
|
+
|
|
17
|
+
// Demo: deny when the record payload sets `blocked: true`.
|
|
18
|
+
if (input.record?.data?.blocked === true) {
|
|
19
|
+
return deny(message, 'EXAMPLE_BLOCKED')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Example host reads (requires manifest.entities with access:["read"]):
|
|
23
|
+
//
|
|
24
|
+
// if (host) {
|
|
25
|
+
// const parentId = String(input.record?.data?.parent_id ?? '')
|
|
26
|
+
// if (parentId) {
|
|
27
|
+
// const parent = await host.getRecord('parent_entity', parentId)
|
|
28
|
+
// const related = await host.listRecords('child_entity', {
|
|
29
|
+
// filters: { parent_id: parentId },
|
|
30
|
+
// limit: 50,
|
|
31
|
+
// })
|
|
32
|
+
// const total = await host.sumField('child_entity', 'amount', {
|
|
33
|
+
// filters: { parent_id: parentId },
|
|
34
|
+
// })
|
|
35
|
+
// // Soft budget sketch (hours overrun consumer):
|
|
36
|
+
// // const budget = Number(parent?.data?.budget_ore ?? 0)
|
|
37
|
+
// // const used = await host.sumField('dettaglio_attivita', 'ore', {
|
|
38
|
+
// // filters: { attivita_id: parentId },
|
|
39
|
+
// // })
|
|
40
|
+
// // const next = Number(input.record?.data?.ore ?? 0)
|
|
41
|
+
// // const remaining = budget - used - next
|
|
42
|
+
// // if (remaining < 0) return deny(`Ore rimanenti insufficienti [${remaining}]`, 'OVER_BUDGET')
|
|
43
|
+
// void parent
|
|
44
|
+
// void related
|
|
45
|
+
// void total
|
|
46
|
+
// }
|
|
47
|
+
// }
|
|
48
|
+
|
|
49
|
+
return allow()
|
|
50
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Cervio task plugin rules - task context, drafts, submit, build/validate/push loop
|
|
3
|
+
globs:
|
|
4
|
+
- "**/*"
|
|
5
|
+
alwaysApply: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Cervio task plugin - agent rules
|
|
9
|
+
|
|
10
|
+
Read `AGENTS.md` in full before editing anything: this rule only points to it.
|
|
11
|
+
|
|
12
|
+
1. Host access only through `@cervio/plugin-sdk` (`getTaskPluginContext`,
|
|
13
|
+
`setTaskDraft`, `submitTaskOutcome`, `markReady`).
|
|
14
|
+
2. Seed state from the saved draft on mount; debounce draft saves.
|
|
15
|
+
3. Fill the box (`height: 100%`, internal scroll).
|
|
16
|
+
4. No `version` in `manifest.json`; declare every `/api/v1` call in `cervio_apis`.
|
|
17
|
+
5. Loop: `npm run build`, `npm run validate`, `npm run push:dev`.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Agent rules: Cervio task plugin
|
|
2
|
+
|
|
3
|
+
This project is a Cervio **task plugin** (`plugin_type: task_form`), scaffolded with
|
|
4
|
+
`@cervio/create-plugin`. It runs in a sandboxed iframe inside a workflow task.
|
|
5
|
+
|
|
6
|
+
## Must
|
|
7
|
+
|
|
8
|
+
- Use `@cervio/plugin-sdk` for everything host-related: `getTaskPluginContext`,
|
|
9
|
+
`setTaskDraft`, `submitTaskOutcome`, `markReady`, `createCervioSessionClient`.
|
|
10
|
+
Never post raw `postMessage` payloads to the host.
|
|
11
|
+
- Read the saved draft (`pluginContext.draft`) on mount before deriving initial values:
|
|
12
|
+
the widget remounts when the user switches between compact and expanded view.
|
|
13
|
+
- Save drafts after a pause (debounce), not on every keystroke.
|
|
14
|
+
- Call `markReady()` once, when the first useful content is on screen (also on error).
|
|
15
|
+
- Treat `canSubmit` as a hint: the server re-checks the assignee and the task status.
|
|
16
|
+
- Fill the box: `height: 100%`, internal scroll, usable from about 352px high.
|
|
17
|
+
- Every `/api/v1` call needs its method and path prefix in `manifest.json`
|
|
18
|
+
`cervio_apis`. Read records through views (`listViewRecords`, `countViewRecords`):
|
|
19
|
+
the entity records endpoint is for organization administrators only.
|
|
20
|
+
- All user-visible strings in `src/i18n` (`it` and `en`, same keys).
|
|
21
|
+
- Use host CSS variables (`var(--background)`, `var(--foreground)`...); never define
|
|
22
|
+
`:root`.
|
|
23
|
+
|
|
24
|
+
## Must not
|
|
25
|
+
|
|
26
|
+
- No `window.alert` / `window.confirm`, no `window.location.origin` (it is `"null"`
|
|
27
|
+
in the sandbox): use the SDK, which resolves the host origin.
|
|
28
|
+
- No secrets, tokens or API keys in the code or the ZIP.
|
|
29
|
+
- No `version` in `manifest.json`: Cervio assigns release versions on upload.
|
|
30
|
+
- No polling loops or a request per render.
|
|
31
|
+
|
|
32
|
+
## Commands
|
|
33
|
+
|
|
34
|
+
`npm run build`, `npm run validate`, `npm run push:dev`, `npm run push`.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# {{PLUGIN_NAME}}
|
|
2
|
+
|
|
3
|
+
A Cervio task plugin, scaffolded with `@cervio/create-plugin`. It renders inside a
|
|
4
|
+
workflow task (Admin → Workflow → task layouts → plugin widget), not as a page.
|
|
5
|
+
|
|
6
|
+
## Develop
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install
|
|
10
|
+
npm run build # dist/index.html + dist/assets
|
|
11
|
+
npm run validate # same checks as the Cervio upload
|
|
12
|
+
npm run push:dev # dev channel; npm run push for a release
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`npm run dev` previews the UI locally, but the task context and submit only exist
|
|
16
|
+
inside Cervio.
|
|
17
|
+
|
|
18
|
+
## task or task_form
|
|
19
|
+
|
|
20
|
+
The manifest declares `"plugin_type": "task_form"`: the widget can complete the task
|
|
21
|
+
with `submitTaskOutcome()`. For a read-only helper (checklist, calculator) use `"task"`
|
|
22
|
+
and let an `actions` widget of the layout complete the task.
|
|
23
|
+
|
|
24
|
+
## How it works
|
|
25
|
+
|
|
26
|
+
- `getTaskPluginContext()`: the task, its outcomes, the workflow variables the layout
|
|
27
|
+
exposes, and the last saved draft. The binding is frozen when the task is created.
|
|
28
|
+
- `setTaskDraft()`: saves work in progress (the template saves after a short pause).
|
|
29
|
+
Read the draft on mount: the widget remounts when the user expands it.
|
|
30
|
+
- `submitTaskOutcome(outcome, data)`: completes the task. The server checks the
|
|
31
|
+
assignee and the task status again.
|
|
32
|
+
- `markReady()`: tells Cervio the widget is ready, to time how long it takes to open.
|
|
33
|
+
|
|
34
|
+
## Size
|
|
35
|
+
|
|
36
|
+
The layout chooses the box height; `task_widget.preferred_size` in the manifest is only
|
|
37
|
+
the default (`compact`, `standard`, `tall`, `fill`). The UI fills its box, scrolls
|
|
38
|
+
inside, and works from about 352px high.
|
|
39
|
+
|
|
40
|
+
## API calls
|
|
41
|
+
|
|
42
|
+
`cervio_apis` is empty: the widget calls no `/api/v1` endpoint. Declare every method and
|
|
43
|
+
path prefix you add (for example `{ "method": "GET", "path_prefix": "/api/v1/me" }`),
|
|
44
|
+
otherwise the call fails with `Path not declared for this plugin`.
|
|
45
|
+
|
|
46
|
+
Documentation: [docs.cervio.app](https://docs.cervio.app), Authoring → Task plugins.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="it">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>{{PLUGIN_NAME}}</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@cervio/plugin-core/manifest.schema.json",
|
|
3
|
+
"plugin_key": "{{PLUGIN_KEY}}",
|
|
4
|
+
"name": "{{PLUGIN_NAME}}",
|
|
5
|
+
"plugin_type": "task_form",
|
|
6
|
+
"description": "Describe what the assignee does in this task.",
|
|
7
|
+
"requiredApiVersion": "1.0.0",
|
|
8
|
+
"entry": "src/main.tsx",
|
|
9
|
+
"task_widget": { "preferred_size": "standard" },
|
|
10
|
+
"cervio_apis": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{PLUGIN_KEY}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"validate": "cervio validate",
|
|
11
|
+
"push": "cervio push",
|
|
12
|
+
"push:dev": "cervio push --dev"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@cervio/plugin-sdk": "^2.0.0",
|
|
16
|
+
"react": "^19.0.0",
|
|
17
|
+
"react-dom": "^19.0.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@cervio/cli": "^1.0.0",
|
|
21
|
+
"@cervio/plugin-core": "^1.0.0",
|
|
22
|
+
"@types/react": "^19.0.0",
|
|
23
|
+
"@types/react-dom": "^19.0.0",
|
|
24
|
+
"@vitejs/plugin-react": "^6.2.0",
|
|
25
|
+
"typescript": "~5.9.0",
|
|
26
|
+
"vite": "^8.3.5"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
getTaskPluginContext,
|
|
4
|
+
markReady,
|
|
5
|
+
setTaskDraft,
|
|
6
|
+
submitTaskOutcome,
|
|
7
|
+
type CervioTaskOutcome,
|
|
8
|
+
} from '@cervio/plugin-sdk'
|
|
9
|
+
import { createAppI18n } from './i18n'
|
|
10
|
+
|
|
11
|
+
type Draft = { notes: string }
|
|
12
|
+
|
|
13
|
+
const DRAFT_DELAY_MS = 600
|
|
14
|
+
|
|
15
|
+
export function App() {
|
|
16
|
+
const i18n = createAppI18n()
|
|
17
|
+
const task = getTaskPluginContext()
|
|
18
|
+
const ctx = task?.pluginContext
|
|
19
|
+
|
|
20
|
+
// Start from the saved draft: the widget remounts (compact/expanded view), and
|
|
21
|
+
// re-deriving values from scratch would drop the assignee's last edits.
|
|
22
|
+
const [notes, setNotes] = useState(() => String((ctx?.draft as Draft | null)?.notes ?? ''))
|
|
23
|
+
const [saving, setSaving] = useState<'idle' | 'saving' | 'saved' | 'error'>('idle')
|
|
24
|
+
const [submitting, setSubmitting] = useState<string | null>(null)
|
|
25
|
+
const [error, setError] = useState<string | null>(null)
|
|
26
|
+
const [done, setDone] = useState(false)
|
|
27
|
+
const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
// Everything the first screen shows comes from the boot payload: it is ready now.
|
|
31
|
+
markReady()
|
|
32
|
+
}, [])
|
|
33
|
+
|
|
34
|
+
function onNotesChange(value: string) {
|
|
35
|
+
setNotes(value)
|
|
36
|
+
if (!task) return
|
|
37
|
+
// Coalesce keystrokes into one draft save.
|
|
38
|
+
clearTimeout(timer.current)
|
|
39
|
+
timer.current = setTimeout(async () => {
|
|
40
|
+
setSaving('saving')
|
|
41
|
+
const res = await setTaskDraft({ notes: value })
|
|
42
|
+
setSaving(res.ok ? 'saved' : 'error')
|
|
43
|
+
}, DRAFT_DELAY_MS)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function complete(outcome: CervioTaskOutcome) {
|
|
47
|
+
clearTimeout(timer.current)
|
|
48
|
+
setSubmitting(outcome.value)
|
|
49
|
+
setError(null)
|
|
50
|
+
// The server checks the assignee and the task status again: canSubmit is a hint.
|
|
51
|
+
const res = await submitTaskOutcome(outcome.value, { notes })
|
|
52
|
+
setSubmitting(null)
|
|
53
|
+
if (res.ok) setDone(true)
|
|
54
|
+
else setError(i18n.t('task.submitError', { message: res.error ?? 'unknown' }))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!task || !ctx) {
|
|
58
|
+
return (
|
|
59
|
+
<main className="task">
|
|
60
|
+
<p className="task-muted">{i18n.t('task.outsideCervio')}</p>
|
|
61
|
+
</main>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const variables = Object.entries(ctx.instanceVariables)
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<main className="task">
|
|
69
|
+
<section className="task-body">
|
|
70
|
+
<h2 className="task-title">{i18n.t('task.title')}</h2>
|
|
71
|
+
|
|
72
|
+
<dl className="task-vars">
|
|
73
|
+
{variables.length === 0 && <p className="task-muted">{i18n.t('task.noVariables')}</p>}
|
|
74
|
+
{variables.map(([name, value]) => (
|
|
75
|
+
<div key={name} className="task-var">
|
|
76
|
+
<dt>{name}</dt>
|
|
77
|
+
<dd>{typeof value === 'object' ? JSON.stringify(value) : String(value)}</dd>
|
|
78
|
+
</div>
|
|
79
|
+
))}
|
|
80
|
+
</dl>
|
|
81
|
+
|
|
82
|
+
<label className="task-label" htmlFor="notes">
|
|
83
|
+
{i18n.t('task.notes')}
|
|
84
|
+
</label>
|
|
85
|
+
<textarea
|
|
86
|
+
id="notes"
|
|
87
|
+
className="task-notes"
|
|
88
|
+
value={notes}
|
|
89
|
+
disabled={done}
|
|
90
|
+
onChange={(e) => onNotesChange(e.target.value)}
|
|
91
|
+
/>
|
|
92
|
+
<p className="task-muted" aria-live="polite">
|
|
93
|
+
{saving === 'saving' && i18n.t('task.saving')}
|
|
94
|
+
{saving === 'saved' && i18n.t('task.saved')}
|
|
95
|
+
{saving === 'error' && i18n.t('task.saveError')}
|
|
96
|
+
</p>
|
|
97
|
+
</section>
|
|
98
|
+
|
|
99
|
+
<footer className="task-actions">
|
|
100
|
+
{error && <p className="task-error">{error}</p>}
|
|
101
|
+
{done && <p className="task-muted">{i18n.t('task.completed')}</p>}
|
|
102
|
+
{task.canSubmit && !done
|
|
103
|
+
? ctx.outcomes.map((outcome) => (
|
|
104
|
+
<button
|
|
105
|
+
key={outcome.value}
|
|
106
|
+
type="button"
|
|
107
|
+
disabled={submitting !== null}
|
|
108
|
+
onClick={() => complete(outcome)}
|
|
109
|
+
>
|
|
110
|
+
{submitting === outcome.value ? i18n.t('task.submitting') : outcome.label}
|
|
111
|
+
</button>
|
|
112
|
+
))
|
|
113
|
+
: null}
|
|
114
|
+
</footer>
|
|
115
|
+
</main>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const en = {
|
|
2
|
+
task: {
|
|
3
|
+
title: '{{PLUGIN_NAME}}',
|
|
4
|
+
noVariables: 'No workflow variables are exposed to this widget.',
|
|
5
|
+
notes: 'Notes',
|
|
6
|
+
saving: 'Saving draft…',
|
|
7
|
+
saved: 'Draft saved',
|
|
8
|
+
saveError: 'The draft could not be saved.',
|
|
9
|
+
submitting: 'Completing…',
|
|
10
|
+
submitError: 'The task could not be completed: {message}',
|
|
11
|
+
completed: 'Task completed.',
|
|
12
|
+
outsideCervio: 'This widget runs inside a Cervio task. Open it from My tasks.',
|
|
13
|
+
},
|
|
14
|
+
} as const
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin runs in a sandboxed iframe: catalogs ship inside the ZIP. Keep the
|
|
3
|
+
* same keys in every locale. Resolve order: host locale (when enabled for this
|
|
4
|
+
* plugin), then the fallback locale, then the default below.
|
|
5
|
+
*/
|
|
6
|
+
import { createI18n, type CervioI18nCatalog } from '@cervio/plugin-sdk'
|
|
7
|
+
import { en } from './en'
|
|
8
|
+
import { it } from './it'
|
|
9
|
+
|
|
10
|
+
export const messages: CervioI18nCatalog = { it, en }
|
|
11
|
+
|
|
12
|
+
export function createAppI18n() {
|
|
13
|
+
return createI18n({ defaultLocale: 'it', messages })
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const it = {
|
|
2
|
+
task: {
|
|
3
|
+
title: '{{PLUGIN_NAME}}',
|
|
4
|
+
noVariables: 'Nessuna variabile del processo è esposta a questo riquadro.',
|
|
5
|
+
notes: 'Note',
|
|
6
|
+
saving: 'Salvataggio della bozza…',
|
|
7
|
+
saved: 'Bozza salvata',
|
|
8
|
+
saveError: 'Non è stato possibile salvare la bozza.',
|
|
9
|
+
submitting: 'Completamento…',
|
|
10
|
+
submitError: 'Non è stato possibile completare l’attività: {message}',
|
|
11
|
+
completed: 'Attività completata.',
|
|
12
|
+
outsideCervio: 'Questo riquadro funziona dentro un’attività di Cervio. Aprilo da Le mie attività.',
|
|
13
|
+
},
|
|
14
|
+
} as const
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/* Design tokens come only from the host theme bridge: do not define :root here.
|
|
2
|
+
Use var(--background), var(--foreground), var(--border), var(--primary)... */
|
|
3
|
+
|
|
4
|
+
* {
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
html,
|
|
9
|
+
body,
|
|
10
|
+
#root {
|
|
11
|
+
height: 100%;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
body {
|
|
16
|
+
font-family: var(--font-sans, system-ui, sans-serif);
|
|
17
|
+
color: var(--foreground);
|
|
18
|
+
background: var(--background);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* The widget fills the box the layout gives it (from about 352px high) and
|
|
22
|
+
scrolls inside: the actions stay visible at the bottom. */
|
|
23
|
+
.task {
|
|
24
|
+
height: 100%;
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.task-body {
|
|
30
|
+
flex: 1;
|
|
31
|
+
min-height: 0;
|
|
32
|
+
overflow: auto;
|
|
33
|
+
padding: 1rem 1.25rem;
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
gap: 0.75rem;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.task-title {
|
|
40
|
+
margin: 0;
|
|
41
|
+
font-size: 1rem;
|
|
42
|
+
font-weight: 600;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.task-vars {
|
|
46
|
+
margin: 0;
|
|
47
|
+
display: grid;
|
|
48
|
+
gap: 0.25rem;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.task-var {
|
|
52
|
+
display: flex;
|
|
53
|
+
gap: 0.5rem;
|
|
54
|
+
font-size: 0.875rem;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.task-var dt {
|
|
58
|
+
color: var(--muted-foreground);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.task-var dd {
|
|
62
|
+
margin: 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.task-label {
|
|
66
|
+
font-size: 0.875rem;
|
|
67
|
+
font-weight: 500;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.task-notes {
|
|
71
|
+
min-height: 6rem;
|
|
72
|
+
resize: vertical;
|
|
73
|
+
padding: 0.5rem;
|
|
74
|
+
font: inherit;
|
|
75
|
+
color: var(--foreground);
|
|
76
|
+
background: var(--background);
|
|
77
|
+
border: 1px solid var(--border);
|
|
78
|
+
border-radius: var(--radius, 0.375rem);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.task-muted {
|
|
82
|
+
margin: 0;
|
|
83
|
+
font-size: 0.8125rem;
|
|
84
|
+
color: var(--muted-foreground);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.task-error {
|
|
88
|
+
margin: 0 auto 0 0;
|
|
89
|
+
font-size: 0.8125rem;
|
|
90
|
+
color: var(--destructive);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.task-actions {
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-wrap: wrap;
|
|
96
|
+
justify-content: flex-end;
|
|
97
|
+
align-items: center;
|
|
98
|
+
gap: 0.5rem;
|
|
99
|
+
padding: 0.75rem 1.25rem;
|
|
100
|
+
border-top: 1px solid var(--border);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.task-actions button {
|
|
104
|
+
padding: 0.5rem 0.875rem;
|
|
105
|
+
font: inherit;
|
|
106
|
+
font-size: 0.875rem;
|
|
107
|
+
color: var(--primary-foreground);
|
|
108
|
+
background: var(--primary);
|
|
109
|
+
border: 0;
|
|
110
|
+
border-radius: var(--radius, 0.375rem);
|
|
111
|
+
cursor: pointer;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.task-actions button:disabled {
|
|
115
|
+
opacity: 0.6;
|
|
116
|
+
cursor: default;
|
|
117
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"isolatedModules": true,
|
|
10
|
+
"moduleDetection": "force",
|
|
11
|
+
"strict": true,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"jsx": "react-jsx",
|
|
14
|
+
"noUnusedLocals": true,
|
|
15
|
+
"noUnusedParameters": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["src"]
|
|
18
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
import { defineConfig } from 'vite'
|
|
3
|
+
import react from '@vitejs/plugin-react'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Task widget build: one entry JS + one CSS. Cervio serves `dist/` as a cached
|
|
7
|
+
* document per uploaded version and inlines the entry JS (up to ~384 KB) and
|
|
8
|
+
* CSS into it, so the widget opens without extra requests. Keep everything the
|
|
9
|
+
* first screen needs in the entry; use dynamic `import()` only for rare, heavy
|
|
10
|
+
* features (a sandboxed iframe does not cache its own requests).
|
|
11
|
+
*/
|
|
12
|
+
export default defineConfig({
|
|
13
|
+
plugins: [react()],
|
|
14
|
+
base: './',
|
|
15
|
+
build: {
|
|
16
|
+
target: 'es2022',
|
|
17
|
+
outDir: 'dist',
|
|
18
|
+
assetsDir: 'assets',
|
|
19
|
+
emptyOutDir: true,
|
|
20
|
+
cssCodeSplit: false,
|
|
21
|
+
modulePreload: false,
|
|
22
|
+
rolldownOptions: {
|
|
23
|
+
input: fileURLToPath(new URL('./index.html', import.meta.url)),
|
|
24
|
+
output: {
|
|
25
|
+
chunkFileNames: 'assets/[name]-[hash].js',
|
|
26
|
+
entryFileNames: 'assets/[name]-[hash].js',
|
|
27
|
+
assetFileNames: 'assets/[name]-[hash][extname]',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})
|