@widgetic/creator 0.3.60 → 0.3.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CreatorApp.svelte +597 -112
- package/dist/components/HoverTooltip.svelte +8 -2
- package/dist/components/HoverTooltip.svelte.d.ts +5 -0
- package/dist/components/VersionDropdownRow.svelte +101 -0
- package/dist/components/VersionDropdownRow.svelte.d.ts +29 -0
- package/dist/components/WidgetShapeLivePreviews.svelte +397 -124
- package/dist/components/WidgetShapeLivePreviews.svelte.d.ts +43 -11
- package/dist/utils/versionPreviewError.d.ts +9 -0
- package/dist/utils/versionPreviewError.js +19 -0
- package/package.json +1 -1
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
let className = '';
|
|
6
6
|
export { className as class };
|
|
7
7
|
export let style = '';
|
|
8
|
+
/**
|
|
9
|
+
* Optional max width (px) for the bubble. When set, the tooltip wraps onto
|
|
10
|
+
* multiple lines instead of one long single line — used for tooltips that
|
|
11
|
+
* need a short explanation rather than a label.
|
|
12
|
+
*/
|
|
13
|
+
export let maxWidth: number | null = null;
|
|
8
14
|
|
|
9
15
|
let triggerEl: HTMLElement | null = null;
|
|
10
16
|
let open = false;
|
|
@@ -46,8 +52,8 @@
|
|
|
46
52
|
{#if open && text}
|
|
47
53
|
<Portal target={portalTarget}>
|
|
48
54
|
<div
|
|
49
|
-
class="wc-hover-tooltip-bubble pointer-events-none fixed z-[99999] -translate-x-1/2 -translate-y-full rounded-md bg-[#1f2937] px-2.5 py-1 text-xs leading-snug text-[#f9fafb] whitespace-
|
|
50
|
-
style="top: {tipTop}px; left: {tipLeft}px;"
|
|
55
|
+
class="wc-hover-tooltip-bubble pointer-events-none fixed z-[99999] -translate-x-1/2 -translate-y-full rounded-md bg-[#1f2937] px-2.5 py-1 text-xs leading-snug text-[#f9fafb] shadow-md {maxWidth ? 'whitespace-normal text-center' : 'whitespace-nowrap'}"
|
|
56
|
+
style="top: {tipTop}px; left: {tipLeft}px;{maxWidth ? ` max-width: ${maxWidth}px;` : ''}"
|
|
51
57
|
role="tooltip"
|
|
52
58
|
>
|
|
53
59
|
{text}
|
|
@@ -20,6 +20,11 @@ declare const HoverTooltip: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_Pr
|
|
|
20
20
|
text?: string;
|
|
21
21
|
class?: string;
|
|
22
22
|
style?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional max width (px) for the bubble. When set, the tooltip wraps onto
|
|
25
|
+
* multiple lines instead of one long single line — used for tooltips that
|
|
26
|
+
* need a short explanation rather than a label.
|
|
27
|
+
*/ maxWidth?: number | null;
|
|
23
28
|
}, {
|
|
24
29
|
default: {};
|
|
25
30
|
}>, {
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* VersionDropdownRow — the ONE row used by BOTH version dropdowns (chat
|
|
4
|
+
* history panel and widget-shape preview menu), so the columns can never
|
|
5
|
+
* drift apart again:
|
|
6
|
+
* vN (fixed) | commit (debug only) | date OR DRAFT badge (same slot) | action (fixed)
|
|
7
|
+
* A Draft replaces the date with its DRAFT badge (no date, no line under
|
|
8
|
+
* it); LIVE sits in the action slot with the exact width of PUBLISH, so
|
|
9
|
+
* the right edge lines up across every row.
|
|
10
|
+
*/
|
|
11
|
+
import HoverTooltip from './HoverTooltip.svelte';
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
/** Version label shown in the first cell (e.g. "v2"). */
|
|
15
|
+
versionLabel: string;
|
|
16
|
+
/** Short commit sha (debug builds only; placeholder dash when missing). */
|
|
17
|
+
commitSha?: string | null;
|
|
18
|
+
/** Show the commit cell (debug mode). */
|
|
19
|
+
showCommit?: boolean;
|
|
20
|
+
/** Date label; the cell shows an em dash when missing. */
|
|
21
|
+
dateLabel?: string | null;
|
|
22
|
+
/** Row is the currently live version — LIVE badge in the action slot. */
|
|
23
|
+
isLive?: boolean;
|
|
24
|
+
/** Row is a draft — DRAFT badge replaces the date + Publish action. */
|
|
25
|
+
isDraft?: boolean;
|
|
26
|
+
/** Selected/highlighted row. */
|
|
27
|
+
selected?: boolean;
|
|
28
|
+
/** Publish/Set-live in flight. */
|
|
29
|
+
busy?: boolean;
|
|
30
|
+
/** Draft publish disabled (with tooltip reason when provided). */
|
|
31
|
+
publishDisabled?: boolean;
|
|
32
|
+
publishDisabledReason?: string | null;
|
|
33
|
+
/** Set-live disabled for this row. */
|
|
34
|
+
setLiveDisabled?: boolean;
|
|
35
|
+
onselect?: () => void;
|
|
36
|
+
onpublish?: () => void;
|
|
37
|
+
onsetlive?: () => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const { versionLabel, commitSha = null, showCommit = false, dateLabel = null, isLive = false, isDraft = false, selected = false, busy = false, publishDisabled = false, publishDisabledReason = null, setLiveDisabled = false, onselect, onpublish, onsetlive }: Props = $props();
|
|
41
|
+
|
|
42
|
+
// One fixed width per column — identical on every row and in both dropdowns.
|
|
43
|
+
// Explicit PIXEL widths that hug the content (vN, 7-char SHA, dd/mm/yyyy
|
|
44
|
+
// hh:mm) — no rem sizing, no floating side padding.
|
|
45
|
+
const COL_VERSION = 'w-[16px] justify-end';
|
|
46
|
+
const COL_COMMIT = 'w-[44px] justify-end';
|
|
47
|
+
const COL_DATE = 'w-[88px]';
|
|
48
|
+
const COL_ACTION = 'w-[60px]';
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<div
|
|
52
|
+
class="version-dropdown-row flex items-center gap-2 rounded px-2 py-1.5 w-max text-[10px] cursor-pointer {selected ? 'bg-emerald-50 text-emerald-800' : 'text-gray-700 hover:bg-gray-50'}"
|
|
53
|
+
role="option"
|
|
54
|
+
aria-selected={selected}
|
|
55
|
+
tabindex="0"
|
|
56
|
+
onclick={() => onselect?.()}
|
|
57
|
+
onkeydown={(e) => {
|
|
58
|
+
if (e.target !== e.currentTarget) return;
|
|
59
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
onselect?.();
|
|
62
|
+
}
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
<span class="{COL_VERSION} flex shrink-0 justify-end font-semibold tabular-nums {isDraft ? 'text-amber-600' : 'text-emerald-700'}">{versionLabel}</span>
|
|
66
|
+
{#if showCommit}
|
|
67
|
+
<span class="{COL_COMMIT} flex shrink-0 font-mono text-slate-400" title={commitSha ?? ''}>{commitSha ? commitSha.slice(0, 7) : '—'}</span>
|
|
68
|
+
{/if}
|
|
69
|
+
{#if isDraft}
|
|
70
|
+
<!-- DRAFT lives in the date slot — same column, same width, no date line. -->
|
|
71
|
+
<span
|
|
72
|
+
class="{COL_DATE} flex shrink-0 items-center justify-center rounded bg-amber-50 py-0.5 font-semibold uppercase tracking-wide text-amber-600"
|
|
73
|
+
title="Not published — preview only"
|
|
74
|
+
>Draft</span>
|
|
75
|
+
{:else}
|
|
76
|
+
<span class="{COL_DATE} flex shrink-0 items-center justify-start whitespace-nowrap tabular-nums text-slate-400">{dateLabel || '—'}</span>
|
|
77
|
+
{/if}
|
|
78
|
+
{#if isLive}
|
|
79
|
+
<span class="{COL_ACTION} flex shrink-0 items-center justify-center rounded bg-emerald-100 py-0.5 font-semibold uppercase tracking-wide text-emerald-600">live</span>
|
|
80
|
+
{:else if isDraft}
|
|
81
|
+
<HoverTooltip
|
|
82
|
+
text={publishDisabledReason || 'Build this draft version and make it the Live version'}
|
|
83
|
+
maxWidth={160}
|
|
84
|
+
class="inline-flex shrink-0"
|
|
85
|
+
>
|
|
86
|
+
<button
|
|
87
|
+
type="button"
|
|
88
|
+
class="{COL_ACTION} flex shrink-0 items-center justify-center rounded border border-emerald-600 bg-emerald-600 py-0.5 font-semibold uppercase tracking-wide text-white hover:bg-emerald-700 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer transition-colors"
|
|
89
|
+
disabled={busy || publishDisabled}
|
|
90
|
+
onclick={(e) => { e.stopPropagation(); onpublish?.(); }}
|
|
91
|
+
>{busy ? '...' : 'Publish'}</button>
|
|
92
|
+
</HoverTooltip>
|
|
93
|
+
{:else}
|
|
94
|
+
<button
|
|
95
|
+
type="button"
|
|
96
|
+
class="{COL_ACTION} flex shrink-0 items-center justify-center rounded border border-emerald-300 py-0.5 font-semibold uppercase tracking-wide text-emerald-700 hover:bg-emerald-100 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer transition-colors"
|
|
97
|
+
disabled={busy || setLiveDisabled}
|
|
98
|
+
onclick={(e) => { e.stopPropagation(); onsetlive?.(); }}
|
|
99
|
+
>{busy ? '...' : 'Set live'}</button>
|
|
100
|
+
{/if}
|
|
101
|
+
</div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
/** Version label shown in the first cell (e.g. "v2"). */
|
|
3
|
+
versionLabel: string;
|
|
4
|
+
/** Short commit sha (debug builds only; placeholder dash when missing). */
|
|
5
|
+
commitSha?: string | null;
|
|
6
|
+
/** Show the commit cell (debug mode). */
|
|
7
|
+
showCommit?: boolean;
|
|
8
|
+
/** Date label; the cell shows an em dash when missing. */
|
|
9
|
+
dateLabel?: string | null;
|
|
10
|
+
/** Row is the currently live version — LIVE badge in the action slot. */
|
|
11
|
+
isLive?: boolean;
|
|
12
|
+
/** Row is a draft — DRAFT badge replaces the date + Publish action. */
|
|
13
|
+
isDraft?: boolean;
|
|
14
|
+
/** Selected/highlighted row. */
|
|
15
|
+
selected?: boolean;
|
|
16
|
+
/** Publish/Set-live in flight. */
|
|
17
|
+
busy?: boolean;
|
|
18
|
+
/** Draft publish disabled (with tooltip reason when provided). */
|
|
19
|
+
publishDisabled?: boolean;
|
|
20
|
+
publishDisabledReason?: string | null;
|
|
21
|
+
/** Set-live disabled for this row. */
|
|
22
|
+
setLiveDisabled?: boolean;
|
|
23
|
+
onselect?: () => void;
|
|
24
|
+
onpublish?: () => void;
|
|
25
|
+
onsetlive?: () => void;
|
|
26
|
+
}
|
|
27
|
+
declare const VersionDropdownRow: import("svelte").Component<Props, {}, "">;
|
|
28
|
+
type VersionDropdownRow = ReturnType<typeof VersionDropdownRow>;
|
|
29
|
+
export default VersionDropdownRow;
|