@stacksjs/defaults 0.75.98 → 0.75.99

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.
@@ -2,7 +2,7 @@
2
2
  "publisher": "Stacks",
3
3
  "name": "vscode-stacks",
4
4
  "displayName": "Stacks",
5
- "version": "0.75.98",
5
+ "version": "0.75.99",
6
6
  "description": "Stacks, built into VS Code: stx templates, pickier linting and formatting, encrypted env files, the dev server preview and every buddy command. No other extensions required.",
7
7
  "license": "MIT",
8
8
  "funding": "https://github.com/sponsors/chrisbbreuer",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/defaults",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.98",
5
+ "version": "0.75.99",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/stacksjs/stacks.git",
@@ -55,7 +55,7 @@
55
55
  "dependencies": {
56
56
  "@iconify-json/f7": "^1.2.2",
57
57
  "@iconify-json/hugeicons": "^1.2.35",
58
- "@stacksjs/mobile": "^0.75.98",
58
+ "@stacksjs/mobile": "^0.75.99",
59
59
  "@stacksjs/sanitizer": "^0.2.406",
60
60
  "@xterm/addon-fit": "^0.11.0",
61
61
  "@xterm/xterm": "^6.0.0",
@@ -102,6 +102,14 @@ describe('Native components', () => {
102
102
  expect(sheet).toContain("useModel('open'")
103
103
  })
104
104
 
105
+ it('covers the tab bar while up, and closes when its screen is left', () => {
106
+ const sheet = read('NativeSheet')
107
+ expect(sheet).toContain('coverTabBar(element, true)')
108
+ expect(sheet).toContain('coverTabBar(element, false)')
109
+ expect(sheet).toContain("useEventListener('stx:navigate'")
110
+ expect(sheet).toContain('if (to !== openedOn) close()')
111
+ })
112
+
105
113
  it('refreshes through the shared gesture and hands the page done()', () => {
106
114
  const refresh = read('NativePullToRefresh')
107
115
  expect(refresh).toContain('observePullToRefresh(')
@@ -18,7 +18,7 @@ const { title = '', back = '', backLabel = 'Back', large = true } = defineProps<
18
18
  </script>
19
19
 
20
20
  <script client>
21
- import { backLabelFor, canGoBack, enterNavTrail, goBack, haptics, navTrail, observeLargeTitle } from '@stacksjs/mobile'
21
+ import { backLabelFor, canGoBack, enterNavTrail, goBack, haptics, navTrail, observeLargeTitle, previousScreenPath, trailEntryFor } from '@stacksjs/mobile'
22
22
 
23
23
  const isLarge = useReactiveProp<boolean>('large', true)
24
24
  const onScroll = useReactiveProp<boolean>('titleOnScroll', false)
@@ -59,7 +59,11 @@ onMount(() => {
59
59
  const { current, previous } = enterNavTrail(navTrail(), window.location.pathname + window.location.search)
60
60
  here = current
61
61
  current.title = navTitle()
62
- if (previous && canGoBack()) previousTitle.set(previous.title)
62
+ // With a stack per tab the router knows where back goes; the trail only
63
+ // knows what was entered last, which may be another tab's screen.
64
+ const backPath = previousScreenPath()
65
+ const returnsTo = backPath === undefined ? previous : backPath ? trailEntryFor(navTrail(), backPath) : null
66
+ if (returnsTo && canGoBack()) previousTitle.set(returnsTo.title)
63
67
  })
64
68
  onDestroy(() => stopScroll?.())
65
69
 
@@ -1,6 +1,6 @@
1
1
  <script client>
2
2
  import type { SheetDetent } from '@stacksjs/mobile'
3
- import { liftToBody, lockBackground, observeSheetDrag, presentPageAsCard, trapFocus } from '@stacksjs/mobile'
3
+ import { coverTabBar, liftToBody, lockBackground, observeSheetDrag, presentPageAsCard, trapFocus } from '@stacksjs/mobile'
4
4
 
5
5
  /**
6
6
  * A bottom sheet: a task that belongs to this screen, raised over it.
@@ -14,6 +14,11 @@ import { liftToBody, lockBackground, observeSheetDrag, presentPageAsCard, trapFo
14
14
  * the screen or all of it and is dragged between them, the first named being
15
15
  * where it opens. At large the page behind shrinks back into a card, as iOS
16
16
  * presents a page sheet. Without `detents` it is as tall as its content.
17
+ *
18
+ * As on iOS it covers the tab bar: in the app the native bar steps aside while
19
+ * it is up. It belongs to the screen it was opened on, so leaving that screen
20
+ * (a link from outside, a tab switch) closes it rather than carrying it over
21
+ * the next one.
17
22
  */
18
23
  const emit = defineEmits()
19
24
  const open = useModel('open', { default: false })
@@ -41,6 +46,11 @@ let putBackTimer: ReturnType<typeof setTimeout> | null = null
41
46
  let previousFocus: HTMLElement | null = null
42
47
  let carded = false
43
48
  let stopDrag: (() => void) | null = null
49
+ let openedOn = ''
50
+
51
+ function currentPath(): string {
52
+ return root()?.ownerDocument.defaultView?.location.pathname ?? ''
53
+ }
44
54
 
45
55
  function root(): HTMLElement | null {
46
56
  return sheetRoot.current as HTMLElement | null
@@ -57,10 +67,14 @@ function present(): void {
57
67
  // scales the page), and everything else made inert behind it.
58
68
  putBack ??= liftToBody(element)
59
69
  releaseBackground = lockBackground(element)
70
+ openedOn = currentPath()
71
+ coverTabBar(element, true)
60
72
  void nextTick(() => (panel.current as HTMLElement | null)?.focus())
61
73
  }
62
74
 
63
75
  function dismissed(): void {
76
+ const element = root()
77
+ if (element) coverTabBar(element, false)
64
78
  releaseBackground?.()
65
79
  releaseBackground = null
66
80
  previousFocus?.focus?.()
@@ -118,11 +132,20 @@ onDestroy(() => {
118
132
  stopDrag?.()
119
133
  releaseBackground?.()
120
134
  const element = root()
135
+ if (element && open()) coverTabBar(element, false)
121
136
  if (carded && element) presentPageAsCard(element.ownerDocument, false)
122
137
  if (putBackTimer) clearTimeout(putBackTimer)
123
138
  putBack?.()
124
139
  })
125
140
 
141
+ // The router moved to another screen while this one's sheet was up.
142
+ useEventListener('stx:navigate', (event: CustomEvent<{ url?: string }>) => {
143
+ if (!open()) return
144
+ const location = root()?.ownerDocument.defaultView?.location
145
+ const to = event.detail?.url ? new URL(event.detail.url, location?.href).pathname : currentPath()
146
+ if (to !== openedOn) close()
147
+ })
148
+
126
149
  useEventListener('keydown', (event: KeyboardEvent) => {
127
150
  if (!open()) return
128
151
  if (event.key === 'Escape') close()