@stacksjs/components 0.2.975 → 0.2.979
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/SettingsUpdateRow-1gsqj04f.stx +138 -0
- package/dist/{SettingsWindow-q0x86xqb.stx → SettingsWindow-z76981eg.stx} +42 -1
- package/dist/index.js +8 -8
- package/dist/ui/settings/SettingsUpdateRow.d.ts +3 -18
- package/package.json +3 -3
- package/src/ui/settings/SettingsUpdateRow.stx +81 -18
- package/src/ui/settings/SettingsWindow.stx +42 -1
- package/dist/SettingsUpdateRow-92mmxvpd.stx +0 -75
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<script server>
|
|
2
|
+
import { SETTINGS_NATIVE } from './native-theme'
|
|
3
|
+
import { settingsUpdateView } from './update'
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* <SettingsUpdateRow>: the row every app that updates itself needs. The app
|
|
7
|
+
* and its version, a sentence about where the update stands, download progress,
|
|
8
|
+
* optional release notes, and the one button that moves it on: Check Now,
|
|
9
|
+
* Download and Install, or Restart to Update.
|
|
10
|
+
*/
|
|
11
|
+
export const appName = $props.appName || ''
|
|
12
|
+
export const status = $props.status && typeof $props.status === 'object' ? $props.status : null
|
|
13
|
+
export const setting = $props.setting || 'software-update'
|
|
14
|
+
export const keywords = Array.isArray($props.keywords) ? $props.keywords.join(' ') : ($props.keywords || 'update version upgrade release')
|
|
15
|
+
export const className = $props.className || ''
|
|
16
|
+
export const served = settingsUpdateView(status, appName)
|
|
17
|
+
export const progressClasses = $native ? SETTINGS_NATIVE.updateProgress : 'stx-settings-update-progress'
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script client>
|
|
21
|
+
import { settingsUpdateView } from './update'
|
|
22
|
+
|
|
23
|
+
const emit = defineEmits(['check', 'install', 'relaunch'])
|
|
24
|
+
const current = useReactiveProp('status', {{ status }})
|
|
25
|
+
const name = useReactiveProp('appName', {{ appName }})
|
|
26
|
+
const notesOpen = state(false)
|
|
27
|
+
const view = derived(() => settingsUpdateView(current(), name()))
|
|
28
|
+
const downloading = derived(() => current()?.state === 'downloading')
|
|
29
|
+
const progressWidth = derived(() => {
|
|
30
|
+
const p = Number(current()?.progress)
|
|
31
|
+
if (!Number.isFinite(p)) return '0%'
|
|
32
|
+
return `${Math.round(Math.min(1, Math.max(0, p)) * 100)}%`
|
|
33
|
+
})
|
|
34
|
+
const releaseNotes = derived(() => String(current()?.notes || '').trim())
|
|
35
|
+
const checkedLabel = derived(() => {
|
|
36
|
+
const raw = current()?.lastCheckedAt
|
|
37
|
+
if (!raw || current()?.state !== 'current') return ''
|
|
38
|
+
const when = new Date(raw)
|
|
39
|
+
return Number.isNaN(when.getTime()) ? '' : `Last checked ${when.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
function act(action) {
|
|
43
|
+
// The status may have moved on since the button was drawn.
|
|
44
|
+
if (view().action === action && !view().busy) emit(action)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function toggleNotes() {
|
|
48
|
+
notesOpen.update(v => !v)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
defineExpose({ view })
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<SettingsRow
|
|
55
|
+
label="{{ served.title }}"
|
|
56
|
+
:label="view().title"
|
|
57
|
+
description="{{ served.sentence }}"
|
|
58
|
+
:description="view().sentence"
|
|
59
|
+
setting="{{ setting }}"
|
|
60
|
+
keywords="{{ keywords }}"
|
|
61
|
+
multiline
|
|
62
|
+
className="{{ className }}"
|
|
63
|
+
>
|
|
64
|
+
<span :show="view().progress" :text="view().progress" class="{{ progressClasses }}" data-settings-update-progress>{{ served.progress }}</span>
|
|
65
|
+
<Button :if="view().action === 'check'" appearance="mac" :label="view().actionLabel" :loading="view().busy" @click="act('check')" />
|
|
66
|
+
<Button :if="view().action === 'install'" appearance="mac" variant="primary" :label="view().actionLabel" :loading="view().busy" @click="act('install')" />
|
|
67
|
+
<Button :if="view().action === 'relaunch'" appearance="mac" variant="primary" :label="view().actionLabel" @click="act('relaunch')" />
|
|
68
|
+
</SettingsRow>
|
|
69
|
+
|
|
70
|
+
@if(!$native)
|
|
71
|
+
<div class="stx-settings-update-meta" :show="downloading() || Boolean(releaseNotes()) || Boolean(checkedLabel())">
|
|
72
|
+
<div class="stx-settings-update-bar" :show="downloading()" role="progressbar" aria-label="Update download progress">
|
|
73
|
+
<div class="stx-settings-update-fill" :style="'width: ' + progressWidth()"></div>
|
|
74
|
+
</div>
|
|
75
|
+
<p class="stx-settings-update-checked" :show="Boolean(checkedLabel())" :text="checkedLabel()"></p>
|
|
76
|
+
<div class="stx-settings-update-notes" :show="Boolean(releaseNotes())">
|
|
77
|
+
<button type="button" class="stx-settings-update-notes-toggle" :aria-expanded="notesOpen() ? 'true' : 'false'" @click="toggleNotes()">
|
|
78
|
+
<span :text="notesOpen() ? 'Hide release notes' : 'Release notes'"></span>
|
|
79
|
+
</button>
|
|
80
|
+
<p class="stx-settings-update-notes-body" :show="notesOpen()" :text="releaseNotes()"></p>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
@endif
|
|
84
|
+
|
|
85
|
+
<style data-native-exclude data-stx-public-style src="../../theme/macos.css"></style>
|
|
86
|
+
<style data-native-exclude>
|
|
87
|
+
.stx-settings-update-progress {
|
|
88
|
+
color: var(--stx-mac-ink-secondary);
|
|
89
|
+
font-size: var(--stx-mac-font-size-small);
|
|
90
|
+
font-variant-numeric: tabular-nums;
|
|
91
|
+
letter-spacing: 0;
|
|
92
|
+
}
|
|
93
|
+
.stx-settings-update-meta {
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
gap: 8px;
|
|
97
|
+
padding: 0 var(--stx-mac-row-pad-x, 14px) 12px;
|
|
98
|
+
}
|
|
99
|
+
.stx-settings-update-bar {
|
|
100
|
+
width: 100%;
|
|
101
|
+
height: 6px;
|
|
102
|
+
border-radius: 999px;
|
|
103
|
+
overflow: hidden;
|
|
104
|
+
background: color-mix(in srgb, var(--stx-mac-ink, #000) 10%, transparent);
|
|
105
|
+
}
|
|
106
|
+
.stx-settings-update-fill {
|
|
107
|
+
height: 100%;
|
|
108
|
+
border-radius: 999px;
|
|
109
|
+
background: var(--stx-mac-accent, #0a84ff);
|
|
110
|
+
transition: width 0.2s ease;
|
|
111
|
+
}
|
|
112
|
+
.stx-settings-update-checked {
|
|
113
|
+
margin: 0;
|
|
114
|
+
font-size: 11px;
|
|
115
|
+
color: var(--stx-mac-ink-secondary);
|
|
116
|
+
}
|
|
117
|
+
.stx-settings-update-notes {
|
|
118
|
+
border-radius: 8px;
|
|
119
|
+
padding: 8px 10px;
|
|
120
|
+
background: color-mix(in srgb, var(--stx-mac-ink, #000) 4%, transparent);
|
|
121
|
+
font-size: 12px;
|
|
122
|
+
line-height: 1.45;
|
|
123
|
+
color: var(--stx-mac-ink-secondary);
|
|
124
|
+
}
|
|
125
|
+
.stx-settings-update-notes-toggle {
|
|
126
|
+
border: 0;
|
|
127
|
+
padding: 0;
|
|
128
|
+
background: none;
|
|
129
|
+
font: inherit;
|
|
130
|
+
font-weight: 500;
|
|
131
|
+
color: var(--stx-mac-ink);
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
}
|
|
134
|
+
.stx-settings-update-notes-body {
|
|
135
|
+
margin: 6px 0 0;
|
|
136
|
+
white-space: pre-wrap;
|
|
137
|
+
}
|
|
138
|
+
</style>
|
|
@@ -79,6 +79,8 @@ const noResults = state(false)
|
|
|
79
79
|
const searchFocus = state(false)
|
|
80
80
|
let stopCommands = null
|
|
81
81
|
let unregister = null
|
|
82
|
+
let paneChannel = null
|
|
83
|
+
let stopDrag = null
|
|
82
84
|
|
|
83
85
|
/*
|
|
84
86
|
* The last open pane, kept under `stx:settings:<key>`: local storage in a
|
|
@@ -167,8 +169,17 @@ onMount(() => {
|
|
|
167
169
|
unregister = registerComponentApi(settingsId, api)
|
|
168
170
|
}
|
|
169
171
|
else {
|
|
172
|
+
let initialPane = asText(openPane())
|
|
173
|
+
if (!initialPane && typeof location !== 'undefined') {
|
|
174
|
+
try {
|
|
175
|
+
const fromQuery = new URLSearchParams(location.search).get('pane')
|
|
176
|
+
if (fromQuery) initialPane = fromQuery
|
|
177
|
+
}
|
|
178
|
+
catch {}
|
|
179
|
+
}
|
|
180
|
+
|
|
170
181
|
settings = new SettingsWindowView(root, {
|
|
171
|
-
pane:
|
|
182
|
+
pane: initialPane,
|
|
172
183
|
storageKey,
|
|
173
184
|
storage: paneStorage,
|
|
174
185
|
globalKeys: {{ globalKeys }},
|
|
@@ -176,6 +187,32 @@ onMount(() => {
|
|
|
176
187
|
failedPane: {{ failedPane }},
|
|
177
188
|
retryPane: {{ retryPane }},
|
|
178
189
|
}, callbacks)
|
|
190
|
+
|
|
191
|
+
if (typeof BroadcastChannel === 'function') {
|
|
192
|
+
try {
|
|
193
|
+
paneChannel = new BroadcastChannel(`stx:settings-window:${storageKey || 'settings'}`)
|
|
194
|
+
paneChannel.onmessage = (event) => {
|
|
195
|
+
const target = typeof event.data === 'string' ? event.data : event.data?.pane
|
|
196
|
+
if (target && settings) settings.showPane(asText(target))
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
catch {}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if ({{ globalKeys }}) {
|
|
203
|
+
const onMouseDown = (event) => {
|
|
204
|
+
if (event.button !== 0) return
|
|
205
|
+
const drag = globalThis.craft?.window?.startDrag
|
|
206
|
+
if (typeof drag !== 'function') return
|
|
207
|
+
const target = event.target
|
|
208
|
+
if (!(target instanceof Element)) return
|
|
209
|
+
if (!target.closest('[data-settings-toolbar], [data-settings-sidebar]')) return
|
|
210
|
+
if (target.closest('a, button, input, select, textarea, label, [role="tab"], [data-settings-item]')) return
|
|
211
|
+
drag.call(globalThis.craft.window)
|
|
212
|
+
}
|
|
213
|
+
root.addEventListener('mousedown', onMouseDown)
|
|
214
|
+
stopDrag = () => root.removeEventListener('mousedown', onMouseDown)
|
|
215
|
+
}
|
|
179
216
|
}
|
|
180
217
|
|
|
181
218
|
// The first run finds the pane the view just opened, which may be a stored
|
|
@@ -189,8 +226,12 @@ onMount(() => {
|
|
|
189
226
|
onDestroy(() => {
|
|
190
227
|
if (stopCommands) stopCommands()
|
|
191
228
|
if (unregister) unregister()
|
|
229
|
+
if (stopDrag) stopDrag()
|
|
230
|
+
if (paneChannel) { try { paneChannel.close() } catch {} }
|
|
192
231
|
stopCommands = null
|
|
193
232
|
unregister = null
|
|
233
|
+
stopDrag = null
|
|
234
|
+
paneChannel = null
|
|
194
235
|
if (settings) settings.destroy()
|
|
195
236
|
settings = null
|
|
196
237
|
})
|