@artkit-ai/react 0.1.0 → 0.2.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.
Files changed (89) hide show
  1. package/dist/cache.d.ts +7 -11
  2. package/dist/cache.d.ts.map +1 -1
  3. package/dist/cache.js +32 -53
  4. package/dist/cache.js.map +1 -1
  5. package/dist/client.d.ts +4 -15
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +2 -29
  8. package/dist/client.js.map +1 -1
  9. package/dist/components/card.d.ts +2 -2
  10. package/dist/components/card.d.ts.map +1 -1
  11. package/dist/components/card.js +3 -3
  12. package/dist/components/card.js.map +1 -1
  13. package/dist/components/editor.d.ts +31 -18
  14. package/dist/components/editor.d.ts.map +1 -1
  15. package/dist/components/editor.js +81 -131
  16. package/dist/components/editor.js.map +1 -1
  17. package/dist/components/icons.d.ts +2 -2
  18. package/dist/components/icons.d.ts.map +1 -1
  19. package/dist/components/icons.js +2 -2
  20. package/dist/components/icons.js.map +1 -1
  21. package/dist/components/panel.d.ts +13 -16
  22. package/dist/components/panel.d.ts.map +1 -1
  23. package/dist/components/panel.js +13 -97
  24. package/dist/components/panel.js.map +1 -1
  25. package/dist/components/shared.d.ts +2 -6
  26. package/dist/components/shared.d.ts.map +1 -1
  27. package/dist/components/shared.js +2 -6
  28. package/dist/components/shared.js.map +1 -1
  29. package/dist/components/view.d.ts +7 -8
  30. package/dist/components/view.d.ts.map +1 -1
  31. package/dist/components/view.js +16 -15
  32. package/dist/components/view.js.map +1 -1
  33. package/dist/context.d.ts +14 -9
  34. package/dist/context.d.ts.map +1 -1
  35. package/dist/context.js.map +1 -1
  36. package/dist/editor-session.d.ts +77 -165
  37. package/dist/editor-session.d.ts.map +1 -1
  38. package/dist/editor-session.js +164 -586
  39. package/dist/editor-session.js.map +1 -1
  40. package/dist/hooks.d.ts +2 -23
  41. package/dist/hooks.d.ts.map +1 -1
  42. package/dist/hooks.js +24 -116
  43. package/dist/hooks.js.map +1 -1
  44. package/dist/i18n.d.ts +4 -66
  45. package/dist/i18n.d.ts.map +1 -1
  46. package/dist/i18n.js +6 -68
  47. package/dist/i18n.js.map +1 -1
  48. package/dist/index.d.ts +6 -9
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +4 -8
  51. package/dist/index.js.map +1 -1
  52. package/dist/provider.d.ts +1 -1
  53. package/dist/provider.d.ts.map +1 -1
  54. package/dist/provider.js +12 -12
  55. package/dist/provider.js.map +1 -1
  56. package/dist/styles.d.ts +1 -1
  57. package/dist/styles.d.ts.map +1 -1
  58. package/dist/styles.js +4 -4
  59. package/package.json +2 -2
  60. package/src/cache.ts +32 -55
  61. package/src/client.ts +7 -55
  62. package/src/components/card.tsx +6 -7
  63. package/src/components/editor.tsx +208 -308
  64. package/src/components/icons.tsx +2 -2
  65. package/src/components/panel.tsx +43 -300
  66. package/src/components/shared.tsx +3 -12
  67. package/src/components/view.tsx +26 -29
  68. package/src/context.ts +16 -11
  69. package/src/editor-session.ts +197 -675
  70. package/src/hooks.ts +25 -140
  71. package/src/i18n.ts +6 -68
  72. package/src/index.ts +7 -39
  73. package/src/provider.tsx +13 -13
  74. package/src/styles.ts +4 -4
  75. package/dist/components/approval.d.ts +0 -34
  76. package/dist/components/approval.d.ts.map +0 -1
  77. package/dist/components/approval.js +0 -80
  78. package/dist/components/approval.js.map +0 -1
  79. package/dist/components/version-diff.d.ts +0 -35
  80. package/dist/components/version-diff.d.ts.map +0 -1
  81. package/dist/components/version-diff.js +0 -85
  82. package/dist/components/version-diff.js.map +0 -1
  83. package/dist/line-diff.d.ts +0 -25
  84. package/dist/line-diff.d.ts.map +0 -1
  85. package/dist/line-diff.js +0 -96
  86. package/dist/line-diff.js.map +0 -1
  87. package/src/components/approval.tsx +0 -219
  88. package/src/components/version-diff.tsx +0 -266
  89. package/src/line-diff.ts +0 -111
@@ -1,161 +1,111 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Redo2, RotateCcw, Undo2 } from 'lucide-react';
3
- import { Suspense, use, useCallback, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
2
+ import { Redo2, Save, Undo2 } from 'lucide-react';
3
+ import { Suspense, use, useEffect, useMemo, useState, useSyncExternalStore } from 'react';
4
4
  import { useArtkit } from '../context.js';
5
- import { EditorSession } from '../editor-session.js';
5
+ import { DraftSession } from '../editor-session.js';
6
6
  import { useArtifact } from '../hooks.js';
7
7
  import { hashString } from '../styles.js';
8
- import { ChangeList, cx, ErrorBoundary, ErrorMessage, errorMessage, formatDate, Loading, rootAttributes, slot, useAnnouncer, } from './shared.js';
9
- import { ArtifactView, KindRenderer, renderContext } from './view.js';
8
+ import { cx, ErrorBoundary, ErrorMessage, Loading, rootAttributes, slot } from './shared.js';
9
+ import { ArtifactView, renderContext } from './view.js';
10
10
  /**
11
- * Kind editor host (spec §13.1, §13.6). Falls back to `ArtifactView` when the kind has no editor loader,
12
- * when the permission is `read` or while another actor holds the lock. The editor module is only loaded
13
- * here, when editing starts.
11
+ * Editor of one artifact (spec §11.6). Edits are applied to a local draft; nothing reaches the server. The Save button
12
+ * emits the draft through `onSave`, and Ctrl/Cmd+S does the same. Undo and redo are local.
14
13
  */
15
14
  export function ArtifactEditor(props) {
16
15
  const ctx = useArtkit();
17
- const { t } = ctx;
18
- const id = props.id ?? props.artifact?.id;
19
- const query = useArtifact(id, props.artifact ? { initial: props.artifact } : {});
20
- const artifact = query.artifact;
16
+ const fetched = useArtifact(props.artifact ? undefined : props.id);
17
+ const artifact = props.artifact ?? fetched.artifact;
21
18
  if (!artifact) {
22
- return (_jsx("div", { className: cx('ak-root ak-editor', props.className), ...rootAttributes(ctx), children: query.error ? (_jsx(ErrorMessage, { error: query.error, onRetry: () => void query.refresh().catch(() => undefined) })) : (_jsx(Loading, {})) }));
19
+ return (_jsx("div", { className: cx('ak-root ak-editor', props.className), ...rootAttributes(ctx), children: fetched.error ? (_jsx(ErrorMessage, { error: fetched.error, onRetry: () => void fetched.refresh().catch(() => undefined) })) : (_jsx(Loading, {})) }));
23
20
  }
24
- const editable = (props.permission ?? 'edit') === 'edit' &&
25
- ctx.hasEditor(artifact.kind) &&
26
- ctx.registry.has(artifact.kind);
27
- if (!editable || props.lockedBy) {
28
- return (_jsxs("div", { className: cx('ak-root ak-editor', props.className), ...rootAttributes(ctx, artifact.themeId), "data-readonly": "true", children: [props.lockedBy ? (_jsx("p", { ...slot(props.slots, 'notice', 'ak-notice'), role: "status", children: t('lockedBy', { actor: t(`actor_${props.lockedBy.type}`) }) })) : null, _jsx(ArtifactView, { artifact: artifact, ...(props.lockedBy && props.partial !== undefined ? { partial: props.partial } : {}) })] }));
21
+ const editable = !props.readOnly && ctx.hasEditor(artifact.format) && ctx.registry.has(artifact.format);
22
+ if (!editable) {
23
+ return (_jsx("div", { className: cx('ak-root ak-editor', props.className), ...rootAttributes(ctx, artifact.themeId), "data-readonly": "true", children: _jsx(ArtifactView, { artifact: artifact }) }));
29
24
  }
30
25
  return _jsx(EditingHost, { ...props, artifact: artifact }, artifact.id);
31
26
  }
32
- function EditingHost(props) {
27
+ function EditingHost({ artifact, readOnly, onSave, onChange, className, slots, }) {
33
28
  const ctx = useArtkit();
34
- const { t, client, cache, registry } = ctx;
35
- const callbacks = useRef(props);
36
- callbacks.current = props;
37
- const artifactId = props.artifact.id;
38
- const [session] = useState(() => new EditorSession({
39
- registry,
40
- artifact: props.artifact,
41
- locale: ctx.locale,
42
- ...(props.groupingWindowMs === undefined ? {} : { groupingWindowMs: props.groupingWindowMs }),
43
- send: (request) => client.apply(artifactId, request),
44
- load: (version) => cache.load(artifactId, version, version === undefined),
45
- onCommitted: (result) => {
46
- cache.put(result.artifact);
47
- callbacks.current.onCommitted?.(result);
48
- },
49
- }));
50
- const state = useSyncExternalStore(session.subscribe, session.getSnapshot, session.getSnapshot);
51
- // Newer versions from the cache or props (agent commits, refetches) are rebased into the session.
29
+ const [session] = useState(() => new DraftSession({ registry: ctx.registry, artifact, locale: ctx.locale }));
30
+ const snapshot = useSyncExternalStore(session.subscribe, session.getSnapshot, session.getSnapshot);
31
+ const [saving, setSaving] = useState(false);
32
+ const [saveError, setSaveError] = useState();
33
+ // A newer artifact from the application (after a save, or a reload) moves the draft forward.
52
34
  useEffect(() => {
53
- session.receive(props.artifact);
54
- }, [session, props.artifact]);
55
- useEffect(() => {
56
- cache.put(state.confirmed);
57
- }, [cache, state.confirmed]);
58
- // Unmounting must not lose the last keystrokes still waiting in the grouping window.
59
- useEffect(() => () => session.flush(), [session]);
60
- const [live, announce] = useAnnouncer();
61
- const lastSeq = useRef(0);
62
- useEffect(() => {
63
- const event = state.event;
64
- if (!event || event.seq === lastSeq.current)
65
- return;
66
- lastSeq.current = event.seq;
67
- switch (event.type) {
68
- case 'saved':
69
- announce(t('savedVersion', { version: event.version }));
70
- break;
71
- case 'undone':
72
- announce(t('undone'));
73
- break;
74
- case 'redone':
75
- announce(t('redone'));
76
- break;
77
- case 'rebased':
78
- announce(t('agentUpdated', { version: event.version }));
79
- break;
80
- case 'rejected':
81
- case 'rolled_back':
82
- announce(t('rolledBack', { message: errorMessage(event.error, event.error.message) }));
83
- callbacks.current.onError?.(event.error);
84
- break;
85
- case 'conflict':
86
- announce(t('conflictTitle'));
87
- break;
88
- case 'conflict_resolved':
89
- break;
35
+ if (artifact.version !== session.getSnapshot().baseVersion ||
36
+ artifact.id !== session.getSnapshot().artifact.id) {
37
+ session.load(artifact);
90
38
  }
91
- }, [state.event, announce, t]);
92
- const [, forceRender] = useState(0);
39
+ }, [artifact, session]);
93
40
  useEffect(() => {
94
- if (!state.lockedUntil)
41
+ onChange?.(snapshot);
42
+ }, [snapshot, onChange]);
43
+ const draft = snapshot.artifact;
44
+ const canSave = Boolean(onSave) && snapshot.dirty && !saving && !readOnly;
45
+ async function save() {
46
+ if (!canSave || !onSave)
95
47
  return;
96
- const delay = Date.parse(state.lockedUntil) - Date.now();
97
- if (delay <= 0)
98
- return;
99
- const timer = setTimeout(() => forceRender((n) => n + 1), delay + 10);
100
- return () => clearTimeout(timer);
101
- }, [state.lockedUntil]);
102
- const locked = state.lockedUntil !== undefined && Date.parse(state.lockedUntil) > Date.now();
103
- const readOnly = state.status === 'conflict' || locked;
104
- const onKeyDown = useCallback((event) => {
105
- if (event.defaultPrevented || !(event.ctrlKey || event.metaKey) || event.altKey)
48
+ setSaving(true);
49
+ setSaveError(undefined);
50
+ try {
51
+ await onSave({
52
+ artifactId: draft.id,
53
+ format: draft.format,
54
+ baseVersion: snapshot.baseVersion,
55
+ title: draft.title,
56
+ locale: draft.locale,
57
+ themeId: draft.themeId,
58
+ content: draft.content,
59
+ operations: snapshot.operations,
60
+ });
61
+ }
62
+ catch (error) {
63
+ setSaveError(error);
64
+ }
65
+ finally {
66
+ setSaving(false);
67
+ }
68
+ }
69
+ function onKeyDown(event) {
70
+ if (event.defaultPrevented || !(event.metaKey || event.ctrlKey))
106
71
  return;
107
72
  const key = event.key.toLowerCase();
108
- if (key === 'z' && !event.shiftKey) {
73
+ if (key === 's') {
74
+ event.preventDefault();
75
+ void save();
76
+ }
77
+ else if (key === 'z' && !event.shiftKey) {
109
78
  event.preventDefault();
110
79
  session.undo();
111
80
  }
112
- else if ((key === 'z' && event.shiftKey) || key === 'y') {
81
+ else if (key === 'y' || (key === 'z' && event.shiftKey)) {
113
82
  event.preventDefault();
114
83
  session.redo();
115
84
  }
116
- }, [session]);
117
- const onBlur = useCallback((event) => {
118
- if (!event.currentTarget.contains(event.relatedTarget))
119
- session.flush();
120
- }, [session]);
121
- const view = state.view;
122
- const renderCtx = useMemo(() => renderContext(ctx, view.themeId, view.locale, 'screen', false), [ctx, view.themeId, view.locale]);
123
- const lint = useMemo(() => {
124
- try {
125
- return registry
126
- .get(props.artifact.kind)
127
- .lint(view.content, { locale: view.locale, theme: ctx.themeFor(view.themeId) });
128
- }
129
- catch {
130
- return [];
131
- }
132
- }, [ctx, registry, props.artifact.kind, view]);
133
- const emit = useCallback((operations, options) => {
134
- session.emit(operations, options);
135
- }, [session]);
136
- const statusText = state.status === 'saving'
137
- ? t('saving')
138
- : state.status === 'editing'
139
- ? t('unsaved')
140
- : state.status === 'conflict'
141
- ? t('conflictTitle')
142
- : t('saved');
143
- return (_jsxs("section", { className: cx('ak-root ak-editor', props.className), ...rootAttributes(ctx, view.themeId), "aria-label": t('editorLabel', { title: view.title }), lang: view.locale, onKeyDown: onKeyDown, onBlur: onBlur, "data-status": state.status, children: [live, _jsxs("div", { ...slot(props.slots, 'toolbar', 'ak-editor-toolbar'), role: "toolbar", "aria-label": t('editorLabel', { title: view.title }), children: [_jsxs("button", { type: "button", className: "ak-button", onClick: session.undo, disabled: !state.canUndo, "aria-keyshortcuts": "Control+Z Meta+Z", children: [_jsx(Undo2, { "aria-hidden": "true" }), t('undo')] }), _jsxs("button", { type: "button", className: "ak-button", onClick: session.redo, disabled: !state.canRedo, "aria-keyshortcuts": "Control+Shift+Z Meta+Shift+Z Control+Y", children: [_jsx(Redo2, { "aria-hidden": "true" }), t('redo')] }), lint.length > 0 ? (_jsx("span", { className: "ak-badge", children: t('lintWarnings', { count: lint.length }) })) : null, _jsx("span", { ...slot(props.slots, 'status', 'ak-editor-status'), "aria-hidden": "true", children: statusText })] }), locked && state.lockedUntil ? (_jsx("p", { ...slot(props.slots, 'notice', 'ak-notice'), role: "status", children: t('lockedUntil', { time: formatDate(state.lockedUntil, ctx.locale) }) })) : null, state.error && state.status !== 'conflict' ? (_jsx(ErrorMessage, { error: state.error, onDismiss: session.dismissError, ...slot(props.slots, 'error', '') })) : null, state.conflict ? _jsx(ConflictBox, { state: state, session: session, slots: props.slots }) : null, _jsx("div", { ...slot(props.slots, 'body', 'ak-view-body'), children: _jsx(ErrorBoundary, { onReset: () => ctx.resetLoad('editor', props.artifact.kind), fallback: (error, reset) => (_jsxs(_Fragment, { children: [_jsx(ErrorMessage, { error: error, onRetry: reset }), _jsx(KindRenderer, { kind: props.artifact.kind, content: view.content, ctx: renderCtx })] })), children: _jsx(Suspense, { fallback: _jsx(KindRenderer, { kind: props.artifact.kind, content: view.content, ctx: renderCtx }), children: _jsx(LoadedEditor, { kind: props.artifact.kind, content: view.content, ctx: renderCtx, emit: emit, readOnly: readOnly, lint: lint }) }) }) })] }));
85
+ }
86
+ const emit = (operations, options) => {
87
+ void session.apply(operations, { ...(options?.kind ? { kind: options.kind } : {}) });
88
+ };
89
+ const actions = {
90
+ canUndo: snapshot.canUndo,
91
+ canRedo: snapshot.canRedo,
92
+ undo: () => session.undo(),
93
+ redo: () => session.redo(),
94
+ dirty: snapshot.dirty,
95
+ saving,
96
+ canSave,
97
+ save: () => void save(),
98
+ };
99
+ return (_jsxs("section", { className: cx('ak-root ak-editor', className), ...rootAttributes(ctx, draft.themeId), "data-dirty": snapshot.dirty || undefined, onKeyDown: onKeyDown, children: [snapshot.error ? _jsx(ErrorMessage, { error: snapshot.error, onDismiss: () => session.undo() }) : null, saveError ? _jsx(ErrorMessage, { error: saveError }) : null, _jsx("div", { ...slot(slots, 'body', 'ak-editor-body'), children: _jsx(ErrorBoundary, { fallback: (error) => _jsx(ErrorMessage, { error: error }), children: _jsx(Suspense, { fallback: _jsx(Loading, {}), children: _jsx(LoadedEditor, { slots: slots, actions: actions, format: draft.format, content: draft.content, ctx: ctx, themeId: draft.themeId, locale: draft.locale, emit: emit, readOnly: Boolean(readOnly), lint: snapshot.lint }) }) }) })] }));
144
100
  }
145
- function ConflictBox({ state, session, slots, }) {
146
- const { t } = useArtkit();
147
- const conflict = state.conflict;
148
- const first = useRef(null);
149
- const titleId = useId();
150
- useEffect(() => {
151
- first.current?.focus();
152
- }, []);
153
- const undoing = conflict.reason === 'undo' || conflict.reason === 'redo';
154
- return (_jsxs("section", { ...slot(slots, 'conflict', 'ak-conflict'), role: "alert", "aria-labelledby": titleId, children: [_jsx("h3", { className: "ak-conflict-title", id: titleId, children: t('conflictTitle') }), _jsx("p", { children: undoing ? t('conflictUndoBody') : t('conflictBody', { version: conflict.latest.version }) }), _jsx(ChangeList, { changes: conflict.changes }), _jsxs("div", { className: "ak-approval-actions", children: [_jsx("button", { ref: first, type: "button", className: "ak-button", "data-variant": "primary", onClick: () => session.resolveConflict('keep-theirs'), children: t('keepTheirs') }), _jsxs("button", { type: "button", className: "ak-button", onClick: () => session.resolveConflict('reapply'), children: [_jsx(RotateCcw, { "aria-hidden": "true" }), t('reapplyMine')] })] })] }));
101
+ function LoadedEditor({ format, content, ctx, themeId, locale, emit, readOnly, lint, actions, slots, }) {
102
+ const { Editor, css, toolbar } = use(ctx.loadEditor(format));
103
+ const renderCtx = useMemo(() => renderContext(ctx, themeId, locale, 'screen', false), [ctx, themeId, locale]);
104
+ return (_jsxs(_Fragment, { children: [css ? (_jsx("style", { href: `artkit-editor-${format}-${hashString(css)}`, precedence: "artkit", nonce: ctx.nonce, children: css })) : null, toolbar === 'format' ? null : _jsx(HostToolbar, { actions: actions, slots: slots }), _jsx(Editor, { content: content, ctx: renderCtx, emit: emit, readOnly: readOnly, lint: lint, actions: actions })] }));
155
105
  }
156
- function LoadedEditor({ kind, content, ctx: renderCtx, emit, readOnly, lint, }) {
157
- const ctx = useArtkit();
158
- const { Editor, css } = use(ctx.loadEditor(kind));
159
- return (_jsxs(_Fragment, { children: [css ? (_jsx("style", { href: `artkit-editor-${kind}-${hashString(css)}`, precedence: "artkit", nonce: ctx.nonce, children: css })) : null, _jsx(Editor, { content: content, ctx: renderCtx, emit: emit, readOnly: readOnly, lint: lint })] }));
106
+ /** Undo, redo, save status and save, drawn by the host above editors that do not draw their own toolbar. */
107
+ function HostToolbar({ actions, slots }) {
108
+ const { t } = useArtkit();
109
+ return (_jsxs("header", { ...slot(slots, 'toolbar', 'ak-editor-toolbar'), children: [_jsxs("div", { className: "ak-editor-history", children: [_jsx("button", { type: "button", className: "ak-button", "data-variant": "quiet", disabled: !actions.canUndo, onClick: actions.undo, "aria-label": t('undo'), title: t('undo'), children: _jsx(Undo2, { "aria-hidden": "true" }) }), _jsx("button", { type: "button", className: "ak-button", "data-variant": "quiet", disabled: !actions.canRedo, onClick: actions.redo, "aria-label": t('redo'), title: t('redo'), children: _jsx(Redo2, { "aria-hidden": "true" }) })] }), _jsx("span", { ...slot(slots, 'status', 'ak-editor-status'), role: "status", "aria-live": "polite", children: actions.dirty ? t('unsaved') : t('saved') }), _jsxs("button", { type: "button", className: "ak-button", "data-variant": "primary", disabled: !actions.canSave, onClick: actions.save, children: [_jsx(Save, { "aria-hidden": "true" }), actions.saving ? t('saving') : t('save')] })] }));
160
110
  }
161
111
  //# sourceMappingURL=editor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor.js","sourceRoot":"","sources":["../../src/components/editor.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAGL,QAAQ,EACR,GAAG,EACH,WAAW,EACX,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,EACR,oBAAoB,GACrB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAA2B,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,UAAU,EACV,EAAE,EACF,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,OAAO,EACP,cAAc,EAEd,IAAI,EACJ,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAuBtE;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC;IACxB,MAAM,EAAE,CAAC,EAAE,GAAG,GAAG,CAAC;IAClB,MAAM,EAAE,GAAG,K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ACP,kBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,WAAW,kBACR,SAAS,EACtB,QAAQ,EAAE,CAAC,OAAO,CAAC,OAAO,EAC1B,OAAO,EAAE,OAAO,CAAC,IAAI,aAErB,KAAC,IAAI,mBAAa,MAAM,GAAG,EAC1B,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAClC,IACF,CACV,CAAC;AACJ,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { type LucideIcon } from 'lucide-react';
2
2
  /** Lucide icon per native kind; unknown kinds get a generic file. */
3
3
  export declare const KIND_ICONS: Record<string, LucideIcon>;
4
- export declare function KindIcon({ kind, className }: {
5
- kind: string;
4
+ export declare function KindIcon({ format, className }: {
5
+ format: string;
6
6
  className?: string;
7
7
  }): import("react").JSX.Element;
8
8
  //# sourceMappingURL=icons.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/components/icons.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,UAAU,EAAiC,MAAM,cAAc,CAAC;AAE9F,qEAAqE;AACrE,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAKjD,CAAC;AAEF,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,+BAGjF"}
1
+ {"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/components/icons.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,UAAU,EAAiC,MAAM,cAAc,CAAC;AAE9F,qEAAqE;AACrE,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAKjD,CAAC;AAEF,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,+BAGrF"}
@@ -7,8 +7,8 @@ export const KIND_ICONS = {
7
7
  slides: Presentation,
8
8
  diagram: Workflow,
9
9
  };
10
- export function KindIcon({ kind, className }) {
11
- const Icon = KIND_ICONS[kind] ?? File;
10
+ export function KindIcon({ format, className }) {
11
+ const Icon = KIND_ICONS[format] ?? File;
12
12
  return _jsx(Icon, { "aria-hidden": "true", focusable: "false", className: className });
13
13
  }
14
14
  //# sourceMappingURL=icons.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"icons.js","sourceRoot":"","sources":["../../src/components/icons.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAmB,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE9F,qEAAqE;AACrE,MAAM,CAAC,MAAM,UAAU,GAA+B;IACpD,QAAQ,EAAE,QAAQ;IAClB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,QAAQ;CAClB,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAwC;IAChF,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;IACtC,OAAO,KAAC,IAAI,mBAAa,MAAM,EAAC,SAAS,EAAC,OAAO,EAAC,SAAS,EAAE,SAAS,GAAI,CAAC;AAC7E,CAAC"}
1
+ {"version":3,"file":"icons.js","sourceRoot":"","sources":["../../src/components/icons.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAmB,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE9F,qEAAqE;AACrE,MAAM,CAAC,MAAM,UAAU,GAA+B;IACpD,QAAQ,EAAE,QAAQ;IAClB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,QAAQ;CAClB,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,EAA0C;IACpF,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;IACxC,OAAO,KAAC,IAAI,mBAAa,MAAM,EAAC,SAAS,EAAC,OAAO,EAAC,SAAS,EAAE,SAAS,GAAI,CAAC;AAC7E,CAAC"}
@@ -1,26 +1,20 @@
1
- import type { Actor, Artifact } from '@artkit-ai/core';
1
+ import type { Artifact } from '@artkit-ai/core';
2
2
  import { type ReactNode } from 'react';
3
- import type { StatusAction } from '../client.js';
4
- import { type EditorPermission } from './editor.js';
3
+ import type { DraftSnapshot } from '../editor-session.js';
4
+ import { type ArtifactEditorProps } from './editor.js';
5
5
  import { type Slots } from './shared.js';
6
- export type PanelTab = 'view' | 'code' | 'history';
7
- export type ArtifactPanelPart = 'header' | 'title' | 'toolbar' | 'tabs' | 'body' | 'code' | 'history';
6
+ export type PanelTab = 'view' | 'edit' | 'code';
7
+ export type ArtifactPanelPart = 'header' | 'title' | 'toolbar' | 'tabs' | 'body' | 'code';
8
8
  export interface ArtifactPanelProps {
9
9
  id?: string;
10
10
  artifact?: Artifact;
11
11
  tab?: PanelTab;
12
12
  defaultTab?: PanelTab;
13
13
  onTabChange?(tab: PanelTab): void;
14
- /** Selected version (undefined = latest). Controlled when `onVersionChange` is given with it. */
15
- version?: number;
16
- onVersionChange?(version: number | undefined): void;
17
- /** `edit` shows the kind editor in the View tab for the latest version (default `read`). */
18
- permission?: EditorPermission;
19
- /** Streaming preview and lock state, forwarded to the view/editor. */
20
- partial?: unknown;
21
- lockedBy?: Actor | null;
22
- /** Lifecycle actions offered; defaults depend on the status. `false` hides them. */
23
- actions?: StatusAction[] | false;
14
+ /** Save action of the editor tab: the application decides what saving means. */
15
+ onSave?: ArtifactEditorProps['onSave'];
16
+ /** Draft changes, forwarded from the editor tab. */
17
+ onChange?(snapshot: DraftSnapshot): void;
24
18
  /** Export formats; defaults to the provider's server formats plus browser exporters. */
25
19
  exportFormats?: string[];
26
20
  onClose?(): void;
@@ -29,6 +23,9 @@ export interface ArtifactPanelProps {
29
23
  className?: string;
30
24
  slots?: Slots<ArtifactPanelPart>;
31
25
  }
32
- /** Assistant-style side panel: View, Code and History tabs, version selector, export and lifecycle (spec §13.1). */
26
+ /**
27
+ * Side panel of one artifact: View, Edit and Code tabs and the export menu (spec §13.1). There is no history, approval
28
+ * or archive here: the application owns versions and publication.
29
+ */
33
30
  export declare function ArtifactPanel(props: ArtifactPanelProps): import("react").JSX.Element;
34
31
  //# sourceMappingURL=panel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../src/components/panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAgC,MAAM,iBAAiB,CAAC;AAErF,OAAO,EAEL,KAAK,SAAS,EAOf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAKjD,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAQL,KAAK,KAAK,EAIX,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AACnD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtG,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,UAAU,CAAC,EAAE,QAAQ,CAAC;IACtB,WAAW,CAAC,CAAC,GAAG,EAAE,QAAQ,GAAG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B;IACjC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,UAAU,CAAC,EAAE,QAAQ,CAAC;IACtB,WAAW,CAAC,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAAC;IAClC,gFAAgF;IAChF,MAAM,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACvC,oDAAoD;IACpD,QAAQ,CAAC,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IACzC,wFAAwF;IACxF,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB,6CAA6C;IAC7C,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;CAClC;AAKD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,+BAkItD"}
@@ -1,31 +1,20 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Archive, Check, ChevronDown, Copy, Download, Eye, History, Rocket, Send, X } from 'lucide-react';
2
+ import { ChevronDown, Copy, Download, X } from 'lucide-react';
3
3
  import { useCallback, useEffect, useId, useMemo, useRef, useState, } from 'react';
4
4
  import { useArtkit } from '../context.js';
5
- import { useArtifact, useArtifactExport, useArtifactHistory } from '../hooks.js';
6
- import { RejectForm } from './approval.js';
5
+ import { useArtifact, useArtifactExport } from '../hooks.js';
7
6
  import { ArtifactEditor } from './editor.js';
8
- import { ChangeList, cx, ErrorMessage, formatDate, kindLabel, Loading, rootAttributes, StatusBadge, slot, useAnnouncer, } from './shared.js';
7
+ import { cx, ErrorMessage, formatLabel, Loading, rootAttributes, slot, useAnnouncer, } from './shared.js';
9
8
  import { ArtifactView } from './view.js';
10
- const DEFAULT_ACTIONS = {
11
- draft: ['submit', 'archive'],
12
- pending_approval: ['approve', 'reject', 'archive'],
13
- published: ['archive'],
14
- archived: [],
15
- };
16
- const ACTION_FROM = {
17
- submit: ['draft'],
18
- approve: ['pending_approval'],
19
- reject: ['pending_approval'],
20
- publish: ['draft', 'pending_approval'],
21
- archive: ['draft', 'pending_approval', 'published'],
22
- };
23
- const TABS = ['view', 'code', 'history'];
24
- const TAB_LABEL = { view: 'tabView', code: 'tabCode', history: 'tabHistory' };
25
- /** Assistant-style side panel: View, Code and History tabs, version selector, export and lifecycle (spec §13.1). */
9
+ const TABS = ['view', 'edit', 'code'];
10
+ const TAB_LABEL = { view: 'tabView', edit: 'tabEdit', code: 'tabCode' };
11
+ /**
12
+ * Side panel of one artifact: View, Edit and Code tabs and the export menu (spec §13.1). There is no history, approval
13
+ * or archive here: the application owns versions and publication.
14
+ */
26
15
  export function ArtifactPanel(props) {
27
16
  const ctx = useArtkit();
28
- const { t, client, cache } = ctx;
17
+ const { t } = ctx;
29
18
  const id = props.id ?? props.artifact?.id;
30
19
  const latestQuery = useArtifact(id, props.artifact ? { initial: props.artifact } : {});
31
20
  const latest = latestQuery.artifact;
@@ -35,59 +24,15 @@ export function ArtifactPanel(props) {
35
24
  setOwnTab(next);
36
25
  props.onTabChange?.(next);
37
26
  };
38
- const [ownVersion, setOwnVersion] = useState(undefined);
39
- const selectedVersion = props.onVersionChange ? props.version : (props.version ?? ownVersion);
40
- const selectVersion = (next) => {
41
- setOwnVersion(next);
42
- props.onVersionChange?.(next);
43
- };
44
- const viewingLatest = selectedVersion === undefined || selectedVersion === latest?.version;
45
- const selectedQuery = useArtifact(viewingLatest ? undefined : id, selectedVersion === undefined ? {} : { version: selectedVersion });
46
- const shown = viewingLatest ? latest : selectedQuery.artifact;
47
- const history = useArtifactHistory(id);
48
- const exporter = useArtifactExport(id ?? '', latest?.kind);
27
+ const exporter = useArtifactExport(id ?? '', latest?.format);
49
28
  const [live, announce] = useAnnouncer();
50
- const [statusBusy, setStatusBusy] = useState(undefined);
51
- const [actionError, setActionError] = useState(undefined);
52
- const [rejecting, setRejecting] = useState(false);
53
- const [reason, setReason] = useState('');
54
29
  const baseId = useId();
55
30
  if (!latest || !id) {
56
31
  return (_jsx("aside", { className: cx('ak-root ak-panel', props.className), ...rootAttributes(ctx), children: latestQuery.error ? (_jsx(ErrorMessage, { error: latestQuery.error, onRetry: () => void latestQuery.refresh().catch(() => undefined) })) : (_jsx(Loading, {})) }));
57
32
  }
58
- const actions = (props.actions === false ? [] : (props.actions ?? DEFAULT_ACTIONS[latest.status])).filter((action) => ACTION_FROM[action].includes(latest.status));
59
- async function runAction(action, message) {
60
- if (!latest)
61
- return;
62
- setStatusBusy(action);
63
- setActionError(undefined);
64
- try {
65
- const updated = await client.setStatus(latest.id, action, message);
66
- cache.put(updated);
67
- announce(t('statusChanged', { status: t(`status_${updated.status}`) }));
68
- setRejecting(false);
69
- setReason('');
70
- }
71
- catch (error) {
72
- setActionError(error);
73
- }
74
- finally {
75
- setStatusBusy(undefined);
76
- }
77
- }
78
- async function restore(version) {
79
- try {
80
- const result = await history.restore(version);
81
- announce(t('restored', { version, newVersion: result.version }));
82
- selectVersion(undefined);
83
- }
84
- catch (error) {
85
- setActionError(error);
86
- }
87
- }
88
33
  async function exportAs(format) {
89
34
  try {
90
- const result = await exporter.exportArtifact(format, viewingLatest ? {} : { version: selectedVersion });
35
+ const result = await exporter.exportArtifact(format, {});
91
36
  announce(t('exported', { filename: result.filename }));
92
37
  }
93
38
  catch {
@@ -113,18 +58,8 @@ export function ArtifactPanel(props) {
113
58
  selectTab(next);
114
59
  document.getElementById(tabId(next))?.focus();
115
60
  };
116
- const versionOptions = mergeVersions(history.entries, latest.version);
117
61
  const exportFormats = props.exportFormats ?? exporter.formats;
118
- return (_jsxs("aside", { className: cx('ak-root ak-panel', props.className), ...rootAttributes(ctx, latest.themeId), "aria-labelledby": `${baseId}-title`, "data-kind": latest.kind, children: [live, _jsxs("header", { ...slot(props.slots, 'header', 'ak-panel-header'), children: [_jsx("h2", { id: `${baseId}-title`, ...slot(props.slots, 'title', 'ak-panel-title'), children: latest.title }), _jsx("span", { className: "ak-history-meta", children: kindLabel(ctx, latest.kind) }), _jsx(StatusBadge, { status: latest.status }), props.headerActions, props.onClose ? (_jsx("button", { type: "button", className: "ak-button", "data-variant": "quiet", onClick: props.onClose, "aria-label": t('close'), children: _jsx(X, { "aria-hidden": "true" }) })) : null] }), _jsxs("div", { ...slot(props.slots, 'toolbar', 'ak-panel-toolbar'), children: [_jsx("label", { htmlFor: `${baseId}-version`, children: t('version') }), _jsxs("select", { id: `${baseId}-version`, className: "ak-select", value: viewingLatest ? '' : String(selectedVersion), onChange: (event) => selectVersion(event.target.value === '' ? undefined : Number(event.target.value)), children: [_jsx("option", { value: "", children: `${t('versionShort', { version: latest.version })} (${t('latest')})` }), versionOptions
119
- .filter((version) => version !== latest.version)
120
- .map((version) => (_jsx("option", { value: String(version), children: t('versionShort', { version }) }, version)))] }), _jsx(ExportMenu, { formats: exportFormats, pending: exporter.pending, onOpen: () => void exporter.loadFormats(), onSelect: (format) => void exportAs(format) }), actions.map((action) => action === 'reject' ? (_jsxs("button", { type: "button", className: "ak-button", "data-variant": "danger", disabled: statusBusy !== undefined, onClick: () => setRejecting(true), children: [_jsx(X, { "aria-hidden": "true" }), t('action_reject')] }, action)) : (_jsxs("button", { type: "button", className: "ak-button", "data-variant": action === 'approve' || action === 'submit' || action === 'publish' ? 'primary' : undefined, disabled: statusBusy !== undefined, onClick: () => void runAction(action), children: [_jsx(ActionIcon, { action: action }), t(`action_${action}`)] }, action)))] }), rejecting ? (_jsx("div", { className: "ak-panel-toolbar", children: _jsx(RejectForm, { busy: statusBusy !== undefined, requireReason: true, reason: reason, onReasonChange: setReason, onSubmit: () => void runAction('reject', reason.trim()), onCancel: () => setRejecting(false) }) })) : null, actionError ? _jsx(ErrorMessage, { error: actionError, onDismiss: () => setActionError(undefined) }) : null, exporter.error ? _jsx(ErrorMessage, { error: exporter.error }) : null, exporter.warnings.length > 0 ? (_jsxs("div", { className: "ak-notice", role: "status", children: [t('exportWarnings'), _jsx("ul", { children: exporter.warnings.map((warning) => (_jsx("li", { children: warning }, warning))) })] })) : null, _jsx("div", { ...slot(props.slots, 'tabs', 'ak-tabs'), role: "tablist", "aria-label": t('tabsLabel'), children: TABS.map((name) => (_jsx("button", { id: tabId(name), type: "button", role: "tab", className: "ak-tab", "aria-selected": tab === name, "aria-controls": panelId(name), tabIndex: tab === name ? 0 : -1, onClick: () => selectTab(name), onKeyDown: onTabKeyDown, children: t(TAB_LABEL[name]) }, name))) }), _jsxs("div", { ...slot(props.slots, 'body', 'ak-panel-body'), role: "tabpanel", id: panelId(tab), "aria-labelledby": tabId(tab), children: [tab === 'view' ? (viewingLatest && (props.permission === 'edit' || props.lockedBy) ? (_jsx(ArtifactEditor, { artifact: latest, permission: props.permission ?? 'read', ...(props.lockedBy ? { lockedBy: props.lockedBy } : {}), ...(props.partial === undefined ? {} : { partial: props.partial }) })) : shown ? (_jsx(ArtifactView, { artifact: shown, ...(viewingLatest && props.partial !== undefined ? { partial: props.partial } : {}) })) : selectedQuery.error ? (_jsx(ErrorMessage, { error: selectedQuery.error })) : (_jsx(Loading, {}))) : null, tab === 'code' ? _jsx(CodeTab, { artifact: shown, slots: props.slots }) : null, tab === 'history' ? (_jsx(HistoryTab, { history: history, latestVersion: latest.version, selectedVersion: viewingLatest ? latest.version : selectedVersion, slots: props.slots, onView: (version) => {
121
- selectVersion(version === latest.version ? undefined : version);
122
- selectTab('view');
123
- }, onRestore: (version) => void restore(version) })) : null] })] }));
124
- }
125
- function mergeVersions(entries, latest) {
126
- const versions = new Set([latest, ...entries.map((entry) => entry.version)]);
127
- return [...versions].sort((a, b) => b - a);
62
+ return (_jsxs("aside", { className: cx('ak-root ak-panel', props.className), ...rootAttributes(ctx, latest.themeId), "aria-labelledby": `${baseId}-title`, "data-format": latest.format, children: [live, _jsxs("header", { ...slot(props.slots, 'header', 'ak-panel-header'), children: [_jsx("h2", { id: `${baseId}-title`, ...slot(props.slots, 'title', 'ak-panel-title'), children: latest.title }), _jsx("span", { className: "ak-history-meta", children: formatLabel(ctx, latest.format) }), _jsx("span", { className: "ak-badge", children: t('versionShort', { version: latest.version }) }), props.headerActions, _jsx(ExportMenu, { formats: exportFormats, pending: exporter.pending, onOpen: () => void exporter.loadFormats(), onSelect: (format) => void exportAs(format) }), props.onClose ? (_jsx("button", { type: "button", className: "ak-button", "data-variant": "quiet", onClick: props.onClose, "aria-label": t('close'), children: _jsx(X, { "aria-hidden": "true" }) })) : null] }), exporter.error ? _jsx(ErrorMessage, { error: exporter.error, className: "ak-panel-notice" }) : null, _jsx("div", { role: "tablist", "aria-label": latest.title, ...slot(props.slots, 'tabs', 'ak-tabs'), children: TABS.map((name) => (_jsx("button", { id: tabId(name), type: "button", role: "tab", className: "ak-tab", "aria-selected": tab === name, "aria-controls": panelId(name), tabIndex: tab === name ? 0 : -1, onClick: () => selectTab(name), onKeyDown: onTabKeyDown, children: t(TAB_LABEL[name]) }, name))) }), _jsxs("div", { id: panelId(tab), role: "tabpanel", "aria-labelledby": tabId(tab), ...slot(props.slots, 'body', 'ak-panel-body'), children: [tab === 'view' ? _jsx(ArtifactView, { artifact: latest }) : null, tab === 'edit' ? (_jsx(ArtifactEditor, { artifact: latest, ...(props.onSave ? { onSave: props.onSave } : {}), ...(props.onChange ? { onChange: props.onChange } : {}) })) : null, tab === 'code' ? _jsx(CodeTab, { artifact: latest, slots: props.slots }) : null] })] }));
128
63
  }
129
64
  function CodeTab({ artifact, slots, }) {
130
65
  const { t } = useArtkit();
@@ -137,20 +72,6 @@ function CodeTab({ artifact, slots, }) {
137
72
  clipboard.writeText(text).then(() => setCopied(true), () => setCopied(false));
138
73
  }, children: [_jsx(Copy, { "aria-hidden": "true" }), copied ? t('copied') : t('copy')] })) : null, _jsx("pre", { ...slot(slots, 'code', 'ak-code'), children: _jsx("code", { children: text }) })] }));
139
74
  }
140
- function HistoryTab(props) {
141
- const ctx = useArtkit();
142
- const { t } = ctx;
143
- const { history } = props;
144
- if (history.error && history.entries.length === 0)
145
- return _jsx(ErrorMessage, { error: history.error, onRetry: () => void history.refresh() });
146
- if (history.loading && history.entries.length === 0)
147
- return _jsx(Loading, {});
148
- if (history.entries.length === 0)
149
- return _jsx("p", { className: "ak-notice", children: t('historyEmpty') });
150
- return (_jsxs("div", { children: [_jsx("ol", { ...slot(props.slots, 'history', 'ak-history'), reversed: true, children: history.entries.map((entry) => (_jsxs("li", { className: "ak-history-entry", "aria-current": entry.version === props.selectedVersion ? 'true' : undefined, children: [_jsxs("div", { className: "ak-history-head", children: [_jsx("strong", { children: t('versionShort', { version: entry.version }) }), _jsxs("span", { className: "ak-history-meta", children: [formatDate(entry.createdAt, ctx.locale), " \u00B7", ' ', t('by', { actor: t(`actor_${entry.actor.type}`) }), entry.restoredFrom !== undefined
151
- ? ` · ${t('restoredFrom', { version: entry.restoredFrom })}`
152
- : ''] }), _jsxs("span", { className: "ak-history-actions", children: [_jsxs("button", { type: "button", className: "ak-button", "aria-label": t('viewVersion', { version: entry.version }), onClick: () => props.onView(entry.version), children: [_jsx(Eye, { "aria-hidden": "true" }), t('tabView')] }), entry.version !== props.latestVersion ? (_jsxs("button", { type: "button", className: "ak-button", "aria-label": t('restoreVersion', { version: entry.version }), disabled: history.restoring !== undefined, onClick: () => props.onRestore(entry.version), children: [_jsx(History, { "aria-hidden": "true" }), t('restore')] })) : null] })] }), entry.message ? _jsx("p", { className: "ak-history-meta", children: entry.message }) : null, entry.diff.length > 0 ? _jsx(ChangeList, { changes: entry.diff }) : null] }, entry.version))) }), history.hasMore ? (_jsx("button", { type: "button", className: "ak-button", disabled: history.loading, onClick: () => void history.loadMore(), children: t('loadMore') })) : null] }));
153
- }
154
75
  function ExportMenu(props) {
155
76
  const { t } = useArtkit();
156
77
  const [open, setOpen] = useState(false);
@@ -208,9 +129,4 @@ function ExportMenu(props) {
208
129
  props.onSelect(format);
209
130
  }, children: format.toUpperCase() }, format)))) })) : null] }));
210
131
  }
211
- const ACTION_ICONS = { submit: Send, approve: Check, publish: Rocket, archive: Archive };
212
- function ActionIcon({ action }) {
213
- const Icon = ACTION_ICONS[action];
214
- return Icon ? _jsx(Icon, { "aria-hidden": "true" }) : null;
215
- }
216
132
  //# sourceMappingURL=panel.js.map