@stacksjs/components 0.2.784 → 0.2.787
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/AddressField-gcydmvkf.stx +33 -0
- package/dist/CommandBar-k35nsefs.stx +34 -0
- package/dist/ContentCard-gjsm9qrr.stx +19 -0
- package/dist/FloatingPanel-qp8cq8hz.stx +21 -0
- package/dist/{Image-czxrr68w.stx → Image-ndt0d1dq.stx} +1 -0
- package/dist/{List-dpvcp0z1.stx → List-q8ff8gdr.stx} +12 -2
- package/dist/SidebarDivider-6whech7a.stx +19 -0
- package/dist/SidebarRow-301dd797.stx +51 -0
- package/dist/SpaceSwitcher-297p5gnb.stx +22 -0
- package/dist/{Switch-zfjdd6dw.stx → Switch-s8yf2rvm.stx} +2 -1
- package/dist/TileGrid-nne4x506.stx +47 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -7
- package/dist/ui/app-frame/AddressField.d.ts +4 -0
- package/dist/ui/app-frame/CommandBar.d.ts +4 -0
- package/dist/ui/app-frame/ContentCard.d.ts +4 -0
- package/dist/ui/app-frame/FloatingPanel.d.ts +4 -0
- package/dist/ui/app-frame/SidebarDivider.d.ts +4 -0
- package/dist/ui/app-frame/SidebarRow.d.ts +4 -0
- package/dist/ui/app-frame/SpaceSwitcher.d.ts +4 -0
- package/dist/ui/app-frame/TileGrid.d.ts +4 -0
- package/dist/ui/app-frame/index.d.ts +69 -0
- package/dist/ui/list/index.d.ts +1 -0
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/ui/app-frame/AddressField.stx +33 -0
- package/src/ui/app-frame/CommandBar.stx +34 -0
- package/src/ui/app-frame/ContentCard.stx +19 -0
- package/src/ui/app-frame/FloatingPanel.stx +21 -0
- package/src/ui/app-frame/README.md +42 -0
- package/src/ui/app-frame/SidebarDivider.stx +19 -0
- package/src/ui/app-frame/SidebarRow.stx +51 -0
- package/src/ui/app-frame/SpaceSwitcher.stx +22 -0
- package/src/ui/app-frame/TileGrid.stx +47 -0
- package/src/ui/app-frame/index.ts +87 -0
- package/src/ui/image/Image.stx +1 -0
- package/src/ui/list/List.stx +12 -2
- package/src/ui/list/index.ts +3 -0
- package/src/ui/switch/Switch.stx +2 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script client>
|
|
2
|
+
/**
|
|
3
|
+
* The page's address as a pill you press to edit: the address bar of a
|
|
4
|
+
* sidebar browser, or a search field that opens a search screen.
|
|
5
|
+
*
|
|
6
|
+
* Arc's: 36pt tall, 10pt corners, a fill a shade darker than the sidebar, the
|
|
7
|
+
* host in the sidebar's colour at three-quarters strength, and two buttons at
|
|
8
|
+
* the right end (copy the link, the site's controls) that come in under the
|
|
9
|
+
* pointer. A touch screen has no pointer, so there they stay.
|
|
10
|
+
*/
|
|
11
|
+
const text = useReactiveProp('text', '')
|
|
12
|
+
const placeholder = useReactiveProp('placeholder', 'Search or enter address')
|
|
13
|
+
/** A lock before the text, for a secure page. */
|
|
14
|
+
const secure = useReactiveProp('secure', false)
|
|
15
|
+
const tint = useReactiveProp('tint', '#1b1d3a')
|
|
16
|
+
const fill = useReactiveProp('fill', '#0000000d')
|
|
17
|
+
/** Shows the copy-link button. */
|
|
18
|
+
const copyable = useReactiveProp('copyable', true)
|
|
19
|
+
/** Shows the site-controls button. */
|
|
20
|
+
const controls = useReactiveProp('controls', false)
|
|
21
|
+
const testId = useReactiveProp('testId', 'address')
|
|
22
|
+
const emit = defineEmits(['open', 'copylink', 'controls'])
|
|
23
|
+
const touch = useMediaQuery('(hover: none)')
|
|
24
|
+
const hovered = state(false)
|
|
25
|
+
const actionsShown = derived(() => touch() || hovered())
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<Pressable class="flex-row gap-[6px] items-center pl-[12px] pr-[3px] h-[36px] rounded-[10px] duration-150 transition" :style="{ backgroundColor: fill() }" :testID="testId()" @press="emit('open')" @hover-change="hovered.set($event.hovered)">
|
|
29
|
+
<Icon :if="secure()" symbol="lock.fill" class="h-[11px] w-[11px]" :style="{ color: tint(), opacity: 0.55 }" />
|
|
30
|
+
<Text class="flex-1 font-medium text-[14px]" :style="{ color: tint(), opacity: text() ? 0.75 : 0.45 }" :numberOfLines="1">{{ text() || placeholder() }}</Text>
|
|
31
|
+
<Button :if="actionsShown() && text() && copyable()" symbol="link" variant="ghost" iconOnly class="text-[12px]" :style="{ color: tint() }" :testID="testId() + '-copy'" @click.stop="emit('copylink')" />
|
|
32
|
+
<Button :if="actionsShown() && controls()" symbol="slider.horizontal.3" variant="ghost" iconOnly class="text-[12px]" :style="{ color: tint() }" testID="site-controls" @click.stop="emit('controls')" />
|
|
33
|
+
</Pressable>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script client>
|
|
2
|
+
/**
|
|
3
|
+
* A search field with its results under it, for jumping anywhere by typing:
|
|
4
|
+
* Arc's command bar, a launcher, a palette of actions.
|
|
5
|
+
*
|
|
6
|
+
* It owns no state: the parent keeps the text and which result is
|
|
7
|
+
* highlighted, and hears `input`, `keydown` (arrows, Escape), `submit` and
|
|
8
|
+
* `pick` (a result's index). On a narrow screen it takes the full width.
|
|
9
|
+
*
|
|
10
|
+
* `results`: `{ key, title, detail?, image?, symbol? }`.
|
|
11
|
+
*/
|
|
12
|
+
const value = useReactiveProp('value', '')
|
|
13
|
+
const placeholder = useReactiveProp('placeholder', 'Search or enter address')
|
|
14
|
+
const results = useReactiveProp('results', [])
|
|
15
|
+
const highlighted = useReactiveProp('highlighted', 0)
|
|
16
|
+
const accent = useReactiveProp('accent', '#3b5bfd')
|
|
17
|
+
const testId = useReactiveProp('testId', 'command')
|
|
18
|
+
const emit = defineEmits(['input', 'keydown', 'submit', 'pick'])
|
|
19
|
+
const narrow = useMediaQuery('(max-width: 720px)')
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<View class="overflow-hidden gap-[4px] p-[8px] bg-white/90 rounded-[16px] shadow-2xl" material="hud" :style="{ width: narrow() ? '94%' : 680 }">
|
|
23
|
+
<View class="flex-row gap-[10px] items-center px-[10px] h-[48px]">
|
|
24
|
+
<Icon symbol="magnifyingglass" class="h-[17px] w-[17px]" :style="{ color: '#6b6e8f' }" />
|
|
25
|
+
<TextInput class="flex-1 text-[19px]" :bordered="false" :value="value()" autofocus select-text-on-focus :placeholder="placeholder()" :testID="testId()" @input="emit('input', $event)" @keydown="emit('keydown', $event)" @submit="emit('submit')" />
|
|
26
|
+
</View>
|
|
27
|
+
<View :if="results().length" class="mx-[6px] h-[1px] bg-black/10"></View>
|
|
28
|
+
<Pressable :for="(result, index) in results()" :key="result.key" class="flex-row gap-[10px] items-center px-[12px] h-[40px] rounded-[10px]" :style="index === highlighted() ? { backgroundColor: accent() } : {}" :testID="'result-' + index" @press="emit('pick', index)">
|
|
29
|
+
<Image :if="result.image" :src="result.image" class="h-[16px] w-[16px] rounded-[3px]" />
|
|
30
|
+
<Icon :if="!result.image" :symbol="result.symbol || 'globe'" class="h-[16px] w-[16px]" :style="{ color: index === highlighted() ? '#ffffff' : '#3a3d5c' }" />
|
|
31
|
+
<Text class="flex-1 text-[14px]" :style="{ color: index === highlighted() ? '#ffffff' : '#1b1d3a' }" :numberOfLines="1">{{ result.title }}</Text>
|
|
32
|
+
<Text :if="result.detail" class="text-[12px]" :style="{ color: index === highlighted() ? '#ffffffcc' : '#6b6e8f' }">{{ result.detail }}</Text>
|
|
33
|
+
</Pressable>
|
|
34
|
+
</View>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script client>
|
|
2
|
+
/**
|
|
3
|
+
* The card a document sits on beside a sidebar: Arc's web page, rounded and
|
|
4
|
+
* lifted off the window's colour by a soft shadow, with a hairline across the
|
|
5
|
+
* top while it loads. The page goes in the default slot.
|
|
6
|
+
*/
|
|
7
|
+
/** 0 to 1 while loading; 0 hides the line. */
|
|
8
|
+
const progress = useReactiveProp('progress', 0)
|
|
9
|
+
const dark = useReactiveProp('dark', false)
|
|
10
|
+
const accent = useReactiveProp('accent', '#3b5bfd')
|
|
11
|
+
/** A ring round the card: the chosen pane of a split view. */
|
|
12
|
+
const ring = useReactiveProp('ring', false)
|
|
13
|
+
const testId = useReactiveProp('testId', '')
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<View class="overflow-hidden flex-1 rounded-[10px]" :style="{ backgroundColor: dark() ? '#1d1e24' : '#ffffff', shadowColor: '#000000', shadowOpacity: 0.14, shadowRadius: 4, shadowOffset: { width: 0, height: 1 }, borderWidth: ring() ? 2 : 0, borderColor: ring() ? accent() : '#00000000' }" :testID="testId()">
|
|
17
|
+
<slot />
|
|
18
|
+
<View :if="progress() > 0" class="absolute left-0 top-0 h-[2px] duration-200 transition" :style="{ width: (progress() * 100) + '%', backgroundColor: accent() }"></View>
|
|
19
|
+
</View>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script client>
|
|
2
|
+
/**
|
|
3
|
+
* A panel that floats over the window on the system's HUD material: a
|
|
4
|
+
* popover's body, a find bar, a permission prompt. What it holds goes in the
|
|
5
|
+
* default slot; `place` positions it (`{ left: 14, top: 86 }`, or `right`,
|
|
6
|
+
* `bottom`), and without one it sits where its parent lays it out.
|
|
7
|
+
*/
|
|
8
|
+
const width = useReactiveProp('width', 300)
|
|
9
|
+
const place = useReactiveProp('place', null)
|
|
10
|
+
const padding = useReactiveProp('padding', 14)
|
|
11
|
+
const testId = useReactiveProp('testId', '')
|
|
12
|
+
const panelStyle = derived(() => ({
|
|
13
|
+
width: width(),
|
|
14
|
+
padding: padding(),
|
|
15
|
+
...(place() ? { position: 'absolute', zIndex: 30, ...place() } : {}),
|
|
16
|
+
}))
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<View class="gap-[10px] bg-white/95 rounded-[14px] shadow-2xl" material="hud" :style="panelStyle()" :testID="testId()">
|
|
20
|
+
<slot />
|
|
21
|
+
</View>
|
|
@@ -255,6 +255,7 @@ const imagePlaceholderStyles = derived(() => {
|
|
|
255
255
|
</script>
|
|
256
256
|
|
|
257
257
|
<picture class="{{ className }}" style="{{ frameStyle }}" :style="{ aspectRatio: imageRatio(), borderRadius: imageRadius(), ...imagePlaceholderStyles() }"
|
|
258
|
+
@if($native)data-stx-fill-root@endif
|
|
258
259
|
@if(!$native)
|
|
259
260
|
@if(zoomOnHover)data-stx-image-zoom@endif
|
|
260
261
|
:data-stx-image-zoom="imageZoomEnabled() ? '' : null"
|
|
@@ -46,7 +46,7 @@ const webPadding = derived(() => {
|
|
|
46
46
|
const vertical = style.paddingVertical ?? all
|
|
47
47
|
const across = style.paddingHorizontal ?? all
|
|
48
48
|
const px = value => `${Math.max(0, Number(value) || 0)}px`
|
|
49
|
-
return {
|
|
49
|
+
return { maxWidth: '100%', boxSizing: 'border-box', ...(horizontal() ? { display: 'flex', flexDirection: 'row', overflowX: 'auto', overflowY: 'hidden' } : {}), paddingTop: px(style.paddingTop ?? vertical), paddingBottom: px(style.paddingBottom ?? vertical), paddingLeft: px(style.paddingLeft ?? across), paddingRight: px(style.paddingRight ?? across) }
|
|
50
50
|
})
|
|
51
51
|
onMount(() => {
|
|
52
52
|
if (nativeHost || typeof IntersectionObserver !== 'function') return
|
|
@@ -76,9 +76,19 @@ onMount(() => {
|
|
|
76
76
|
return () => { stop(); changes.disconnect(); observer.disconnect() }
|
|
77
77
|
})
|
|
78
78
|
</script>
|
|
79
|
-
<div data-native="FlatList" ref="listRef" role="list" class="{{ viewportClasses }} {{ className }}" :horizontal="horizontal()" :contentContainerStyle="contentStyle()" :style="nativeHost ? {} : webPadding()" data-stx-list data-stx-layout-root @end-reached="reachedEnd()" @refresh="emit('refresh')">
|
|
79
|
+
<div data-native="FlatList" ref="listRef" role="list" class="{{ viewportClasses }} {{ className }}" :horizontal="horizontal()" :contentContainerStyle="contentStyle()" :style="nativeHost ? {} : webPadding()" :data-stx-list-direction="horizontal ? 'horizontal' : 'vertical'" data-stx-list data-stx-layout-root @end-reached="reachedEnd()" @refresh="emit('refresh')">
|
|
80
80
|
<slot />
|
|
81
81
|
@if(!nativeHost)
|
|
82
82
|
<div ref="endRef" aria-hidden="true" style="height:1px;width:1px;flex-shrink:0"></div>
|
|
83
83
|
@endif
|
|
84
84
|
</div>
|
|
85
|
+
|
|
86
|
+
@if(!nativeHost)
|
|
87
|
+
<style>
|
|
88
|
+
/* A page list needs a fallback bound, but authored viewport classes win.
|
|
89
|
+
Keeping the fallback at zero specificity also works when it follows the
|
|
90
|
+
application's stylesheet, including during SPA navigation. */
|
|
91
|
+
:where([data-stx-list]) { max-height: 100dvh; }
|
|
92
|
+
:where([data-stx-list][data-stx-list-direction="horizontal"]) { max-height: none; }
|
|
93
|
+
</style>
|
|
94
|
+
@endif
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script client>
|
|
2
|
+
/**
|
|
3
|
+
* A hairline between two parts of a sidebar, with an optional quiet action at
|
|
4
|
+
* its end: Arc's line between pinned tabs and Today, and its "↓ Clear".
|
|
5
|
+
*/
|
|
6
|
+
const action = useReactiveProp('action', '')
|
|
7
|
+
const actionSymbol = useReactiveProp('actionSymbol', 'arrow.down')
|
|
8
|
+
const tint = useReactiveProp('tint', '#1b1d3a')
|
|
9
|
+
const testId = useReactiveProp('testId', '')
|
|
10
|
+
const emit = defineEmits(['action'])
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<View class="flex-row gap-[8px] items-center pl-[10px] pr-[4px] h-[17px]">
|
|
14
|
+
<View class="flex-1 h-[1px]" :style="{ backgroundColor: tint(), opacity: 0.12 }"></View>
|
|
15
|
+
<Pressable :if="action()" class="flex-row gap-[3px] items-center px-[5px] h-[17px] hover:bg-black/5 rounded-[5px]" :testID="testId()" @press="emit('action')">
|
|
16
|
+
<Icon :symbol="actionSymbol()" class="h-[9px] w-[9px]" :style="{ color: tint(), opacity: 0.45 }" />
|
|
17
|
+
<Text class="font-semibold text-[11px]" :style="{ color: tint(), opacity: 0.45 }">{{ action() }}</Text>
|
|
18
|
+
</Pressable>
|
|
19
|
+
</View>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script client>
|
|
2
|
+
/**
|
|
3
|
+
* One row of an app's sidebar: a tab, a folder, a pinned page, an action.
|
|
4
|
+
*
|
|
5
|
+
* Measured off Arc: 40pt tall, the icon's 18pt box at 9pt in, the label at
|
|
6
|
+
* 35pt, a 10pt radius, and the chosen row lifted out as a white card. A close
|
|
7
|
+
* button shows where a pointer hovers. On a touch screen (no hover) the row is
|
|
8
|
+
* 44pt, the touch target the platform asks for, and the button always shows.
|
|
9
|
+
*
|
|
10
|
+
* `item` is the row, read live so the component can stand in a `:for`:
|
|
11
|
+
* `{ label, image?, symbol?, emoji?, active?, strong?, muted?, depth?,
|
|
12
|
+
* closable?, closeSymbol?, editing?, highlighted?, dragData?, dragUrl?,
|
|
13
|
+
* dropInside?, testId? }`. One object rather than a prop each: every prop is a
|
|
14
|
+
* binding and a signal of its own, and a sidebar has dozens of rows.
|
|
15
|
+
* `theme`: `{ tint, activeBackground?, hoverBackground?, touch? }`, shared by every row; `touch`
|
|
16
|
+
* (no hovering pointer) makes the row 44pt and always shows its button.
|
|
17
|
+
*/
|
|
18
|
+
const item = useReactiveProp('item', {})
|
|
19
|
+
const theme = useReactiveProp('theme', {})
|
|
20
|
+
const emit = defineEmits(['select', 'close', 'menu', 'drop', 'rename', 'imageerror'])
|
|
21
|
+
// Kept lean on purpose: a sidebar holds dozens of these, and every signal,
|
|
22
|
+
// derived value and effect is a few objects more per row for the collector.
|
|
23
|
+
// The theme carries `touch` (computed once by the parent) for the same reason.
|
|
24
|
+
const hovered = state(false)
|
|
25
|
+
let draft = null
|
|
26
|
+
|
|
27
|
+
function rowStyle(row, look, over) {
|
|
28
|
+
return {
|
|
29
|
+
height: look.touch ? 44 : 40,
|
|
30
|
+
paddingLeft: 9 + (row.depth || 0) * 16,
|
|
31
|
+
backgroundColor: row.active ? look.activeBackground || '#ffffffd9' : over ? look.hoverBackground || '#0000000d' : '#00000000',
|
|
32
|
+
shadowColor: '#000000',
|
|
33
|
+
shadowOpacity: row.active ? 0.08 : 0,
|
|
34
|
+
shadowRadius: row.active ? 2 : 0,
|
|
35
|
+
shadowOffset: { width: 0, height: row.active ? 1 : 0 },
|
|
36
|
+
borderWidth: row.highlighted ? 2 : 0,
|
|
37
|
+
borderColor: row.highlighted ? '#3b5bfd' : '#00000000',
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function finish() { emit('rename', (draft ?? item().label ?? '').trim()); draft = null }
|
|
41
|
+
function typed(event) { draft = String(event?.text ?? event?.value ?? event?.target?.value ?? '') }
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<Pressable class="flex-row gap-[8px] items-center pr-[5px] rounded-[10px] duration-100 transition" :style="rowStyle(item(), theme(), hovered())" :draggable="Boolean(item().dragData)" :drag-data="item().dragData || ''" :drag-url="item().dragUrl || ''" :drop-inside="Boolean(item().dropInside)" :testID="item().testId || ''" @press="emit('select')" @contextmenu="emit('menu')" @drop="emit('drop', $event)" @hover-change="hovered.set($event.hovered)">
|
|
45
|
+
<Image :if="item().image" :src="item().image" class="h-[18px] w-[18px] rounded-[4px]" @error="emit('imageerror', item().image)" />
|
|
46
|
+
<Icon :if="!item().image && item().symbol" :symbol="item().symbol" class="h-[17px] w-[18px]" :style="{ color: theme().tint || '#1b1d3a', opacity: item().muted ? 0.5 : 1 }" />
|
|
47
|
+
<Text :if="!item().image && !item().symbol && item().emoji" class="w-[18px] text-[14px] text-center">{{ item().emoji }}</Text>
|
|
48
|
+
<Text :if="!item().editing" class="flex-1 text-[14px]" :class="item().strong ? 'font-semibold' : 'font-medium'" :style="{ color: theme().tint || '#1b1d3a', opacity: item().muted ? 0.5 : 1 }" :numberOfLines="1">{{ item().label }}</Text>
|
|
49
|
+
<TextInput :if="item().editing" class="flex-1 font-medium text-[14px]" :bordered="false" :value="item().label" autofocus select-text-on-focus :testID="(item().testId || '') + '-rename'" @input="typed($event)" @submit="finish()" @blur="finish()" />
|
|
50
|
+
<Button :if="item().closable && !item().editing && (theme().touch || hovered())" :symbol="item().closeSymbol || 'xmark'" variant="ghost" iconOnly class="text-[11px]" :style="{ color: theme().tint || '#1b1d3a', opacity: item().muted ? 0.5 : 1 }" :testID="(item().testId || '') + '-close'" @click.stop="emit('close')" />
|
|
51
|
+
</Pressable>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script client>
|
|
2
|
+
/**
|
|
3
|
+
* A row of icons that each switch the view to one of several spaces,
|
|
4
|
+
* workspaces or accounts: the foot of Arc's sidebar.
|
|
5
|
+
*
|
|
6
|
+
* Each icon is a 36 by 34pt target; the current one is drawn at full strength
|
|
7
|
+
* and the rest faded, as Arc does.
|
|
8
|
+
*
|
|
9
|
+
* `items`: `{ id, label?, symbol?, emoji?, testId? }`; `active` is the current id.
|
|
10
|
+
*/
|
|
11
|
+
const items = useReactiveProp('items', [])
|
|
12
|
+
const active = useReactiveProp('active', '')
|
|
13
|
+
const tint = useReactiveProp('tint', '#1b1d3a')
|
|
14
|
+
const emit = defineEmits(['select', 'menu'])
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<View class="flex-row items-center justify-center">
|
|
18
|
+
<Pressable :for="item in items()" :key="item.id" class="items-center justify-center h-[34px] w-[36px] hover:bg-black/5 rounded-[8px]" :testID="item.testId || ''" :accessibilityLabel="item.label || ''" @press="emit('select', item.id)" @contextmenu="emit('menu', item.id)">
|
|
19
|
+
<Icon :if="item.symbol" :symbol="item.symbol" class="h-[14px] w-[16px]" :style="{ color: tint(), opacity: item.id === active() ? 0.85 : 0.35 }" />
|
|
20
|
+
<Text :if="!item.symbol" class="text-[13px]" :style="{ color: tint(), opacity: item.id === active() ? 1 : 0.5 }">{{ item.emoji || '●' }}</Text>
|
|
21
|
+
</Pressable>
|
|
22
|
+
</View>
|
|
@@ -99,12 +99,13 @@ defineExpose({ isChecked, toggle })
|
|
|
99
99
|
:value="isChecked() ? '{{ checkedValue }}' : '{{ uncheckedValue }}'"
|
|
100
100
|
/>
|
|
101
101
|
@endif
|
|
102
|
+
{{-- Keep the controlled value boolean when a nullable model resets. --}}
|
|
102
103
|
<div
|
|
103
104
|
data-native="Switch"
|
|
104
105
|
data-stx-native-host-root
|
|
105
106
|
role="switch"
|
|
106
107
|
value="{{ checked ? 'true' : 'false' }}"
|
|
107
|
-
:value="isChecked()"
|
|
108
|
+
:value="!!isChecked()"
|
|
108
109
|
aria-label="{{ label || 'Toggle switch' }}"
|
|
109
110
|
:aria-label="currentLabel() || 'Toggle switch'"
|
|
110
111
|
:aria-checked="isChecked() ? 'true' : 'false'"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script client>
|
|
2
|
+
/**
|
|
3
|
+
* A grid of square-ish tiles: an app's favourites, pinned apps, shortcuts.
|
|
4
|
+
*
|
|
5
|
+
* Arc's favourites: four columns across the sidebar, 8pt apart, 12pt corners,
|
|
6
|
+
* an 18pt icon in the middle, a faint fill that darkens under the pointer (the
|
|
7
|
+
* host applies `hover:` itself, so hovering costs no script) and
|
|
8
|
+
* turns white for the open one. A short last row keeps its tiles the width of
|
|
9
|
+
* the others rather than stretching them. `columns` sets how many fit across,
|
|
10
|
+
* which a phone or a wide sidebar can raise.
|
|
11
|
+
*
|
|
12
|
+
* `items`: `{ id, label?, image?, symbol?, emoji?, active?, dragData?, dragUrl?, testId? }`.
|
|
13
|
+
*/
|
|
14
|
+
const items = useReactiveProp('items', [])
|
|
15
|
+
const columns = useReactiveProp('columns', 4)
|
|
16
|
+
const tint = useReactiveProp('tint', '#1b1d3a')
|
|
17
|
+
const fill = useReactiveProp('fill', '#0000000d')
|
|
18
|
+
const activeFill = useReactiveProp('activeFill', '#ffffffd9')
|
|
19
|
+
/** The tile height; the width is the column's. */
|
|
20
|
+
const height = useReactiveProp('height', 47)
|
|
21
|
+
const emit = defineEmits(['select', 'menu', 'drop', 'imageerror'])
|
|
22
|
+
|
|
23
|
+
/** The items in rows of `columns`, the last one padded with empty cells. */
|
|
24
|
+
const grid = derived(() => {
|
|
25
|
+
const across = Math.max(1, Number(columns()) || 4)
|
|
26
|
+
const list = items() || []
|
|
27
|
+
const out = []
|
|
28
|
+
for (let start = 0; start < list.length; start += across) {
|
|
29
|
+
const row = list.slice(start, start + across).map(item => ({ key: item.id, item }))
|
|
30
|
+
while (row.length < across) row.push({ key: `pad-${start}-${row.length}`, item: null })
|
|
31
|
+
out.push({ key: `row-${start}`, cells: row })
|
|
32
|
+
}
|
|
33
|
+
return out
|
|
34
|
+
})
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<View class="gap-[8px]" @drop="emit('drop', $event)">
|
|
38
|
+
<View :for="row in grid()" :key="row.key" class="flex-row gap-[8px]">
|
|
39
|
+
<View :for="cell in row.cells" :key="cell.key" class="flex-1">
|
|
40
|
+
<Pressable :if="cell.item" class="items-center justify-center hover:bg-black/10 rounded-[12px] duration-150 transition" :style="{ height: height(), backgroundColor: cell.item.active ? activeFill() : fill(), shadowColor: '#000000', shadowOpacity: cell.item.active ? 0.08 : 0, shadowRadius: cell.item.active ? 2 : 0, shadowOffset: { width: 0, height: cell.item.active ? 1 : 0 } }" :draggable="Boolean(cell.item.dragData)" :drag-data="cell.item.dragData || ''" :drag-url="cell.item.dragUrl || ''" :testID="cell.item.testId || ''" :accessibilityLabel="cell.item.label || ''" @press="emit('select', cell.item.id)" @contextmenu="emit('menu', cell.item.id)">
|
|
41
|
+
<Image :if="cell.item.image" :src="cell.item.image" class="h-[18px] w-[18px] rounded-[4px]" @error="emit('imageerror', cell.item.image)" />
|
|
42
|
+
<Icon :if="!cell.item.image && cell.item.symbol" :symbol="cell.item.symbol" class="h-[18px] w-[18px]" :style="{ color: tint() }" />
|
|
43
|
+
<Text :if="!cell.item.image && !cell.item.symbol" class="text-[16px]">{{ cell.item.emoji || (cell.item.label || '?').slice(0, 1).toUpperCase() }}</Text>
|
|
44
|
+
</Pressable>
|
|
45
|
+
</View>
|
|
46
|
+
</View>
|
|
47
|
+
</View>
|
package/dist/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export * from './utils/overlays';
|
|
|
40
40
|
export * from './theme/index';
|
|
41
41
|
// Export UI components
|
|
42
42
|
export * from './ui/accordion/index';
|
|
43
|
+
export * from './ui/app-frame/index';
|
|
43
44
|
export * from './ui/audio/index';
|
|
44
45
|
export * from './ui/auth/index';
|
|
45
46
|
export * from './ui/avatar/index';
|