@mystravil/hardpoint 0.0.0-stage → 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.
- package/CHANGELOG.md +38 -0
- package/LICENSE +25 -0
- package/README.md +64 -3
- package/dist/base.css +625 -0
- package/dist/components/AppShell.svelte +698 -0
- package/dist/components/AppShell.svelte.d.ts +77 -0
- package/dist/components/Button.svelte +174 -0
- package/dist/components/Button.svelte.d.ts +20 -0
- package/dist/components/Checkbox.svelte +235 -0
- package/dist/components/Checkbox.svelte.d.ts +23 -0
- package/dist/components/CheckboxGroup.svelte +207 -0
- package/dist/components/CheckboxGroup.svelte.d.ts +44 -0
- package/dist/components/Combobox.svelte +901 -0
- package/dist/components/Combobox.svelte.d.ts +72 -0
- package/dist/components/Dialog.svelte +359 -0
- package/dist/components/Dialog.svelte.d.ts +43 -0
- package/dist/components/Disclosure.svelte +201 -0
- package/dist/components/Disclosure.svelte.d.ts +27 -0
- package/dist/components/EmptyState.svelte +88 -0
- package/dist/components/EmptyState.svelte.d.ts +22 -0
- package/dist/components/ErrorState.svelte +135 -0
- package/dist/components/ErrorState.svelte.d.ts +26 -0
- package/dist/components/ImageViewer.svelte +764 -0
- package/dist/components/ImageViewer.svelte.d.ts +55 -0
- package/dist/components/KeyValueList.svelte +114 -0
- package/dist/components/KeyValueList.svelte.d.ts +43 -0
- package/dist/components/ListDetail.svelte +218 -0
- package/dist/components/ListDetail.svelte.d.ts +37 -0
- package/dist/components/LoadRegion.svelte +219 -0
- package/dist/components/LoadRegion.svelte.d.ts +27 -0
- package/dist/components/MediaFrame.svelte +110 -0
- package/dist/components/MediaFrame.svelte.d.ts +20 -0
- package/dist/components/MediaImage.svelte +256 -0
- package/dist/components/MediaImage.svelte.d.ts +16 -0
- package/dist/components/Menu.svelte +258 -0
- package/dist/components/Menu.svelte.d.ts +36 -0
- package/dist/components/MenuCheckboxItem.svelte +119 -0
- package/dist/components/MenuCheckboxItem.svelte.d.ts +15 -0
- package/dist/components/MenuGroup.svelte +50 -0
- package/dist/components/MenuGroup.svelte.d.ts +15 -0
- package/dist/components/MenuItem.svelte +94 -0
- package/dist/components/MenuItem.svelte.d.ts +19 -0
- package/dist/components/MenuRadioGroup.svelte +62 -0
- package/dist/components/MenuRadioGroup.svelte.d.ts +20 -0
- package/dist/components/MenuRadioItem.svelte +110 -0
- package/dist/components/MenuRadioItem.svelte.d.ts +17 -0
- package/dist/components/MenuSeparator.svelte +28 -0
- package/dist/components/MenuSeparator.svelte.d.ts +6 -0
- package/dist/components/Meter.svelte +283 -0
- package/dist/components/Meter.svelte.d.ts +66 -0
- package/dist/components/NativeSelect.svelte +135 -0
- package/dist/components/NativeSelect.svelte.d.ts +52 -0
- package/dist/components/Notice.svelte +262 -0
- package/dist/components/Notice.svelte.d.ts +30 -0
- package/dist/components/Pagination.svelte +132 -0
- package/dist/components/Pagination.svelte.d.ts +18 -0
- package/dist/components/Popover.svelte +222 -0
- package/dist/components/Popover.svelte.d.ts +35 -0
- package/dist/components/Progress.svelte +157 -0
- package/dist/components/Progress.svelte.d.ts +34 -0
- package/dist/components/RadioGroup.svelte +440 -0
- package/dist/components/RadioGroup.svelte.d.ts +50 -0
- package/dist/components/Select.svelte +471 -0
- package/dist/components/Select.svelte.d.ts +48 -0
- package/dist/components/Skeleton.svelte +149 -0
- package/dist/components/Skeleton.svelte.d.ts +24 -0
- package/dist/components/Spinner.svelte +118 -0
- package/dist/components/Spinner.svelte.d.ts +13 -0
- package/dist/components/Stat.svelte +253 -0
- package/dist/components/Stat.svelte.d.ts +46 -0
- package/dist/components/Steps.svelte +189 -0
- package/dist/components/Steps.svelte.d.ts +31 -0
- package/dist/components/Switch.svelte +222 -0
- package/dist/components/Switch.svelte.d.ts +18 -0
- package/dist/components/Table.svelte +504 -0
- package/dist/components/Table.svelte.d.ts +92 -0
- package/dist/components/Tabs.svelte +246 -0
- package/dist/components/Tabs.svelte.d.ts +44 -0
- package/dist/components/Tag.svelte +40 -0
- package/dist/components/Tag.svelte.d.ts +15 -0
- package/dist/components/TextArea.svelte +272 -0
- package/dist/components/TextArea.svelte.d.ts +28 -0
- package/dist/components/TextField.svelte +256 -0
- package/dist/components/TextField.svelte.d.ts +32 -0
- package/dist/components/Timeline.svelte +156 -0
- package/dist/components/Timeline.svelte.d.ts +30 -0
- package/dist/components/Toaster.svelte +411 -0
- package/dist/components/Toaster.svelte.d.ts +11 -0
- package/dist/components/Tooltip.svelte +200 -0
- package/dist/components/Tooltip.svelte.d.ts +38 -0
- package/dist/components/TooltipGroup.svelte +46 -0
- package/dist/components/TooltipGroup.svelte.d.ts +29 -0
- package/dist/components/internal/Scrim.svelte +52 -0
- package/dist/components/internal/Scrim.svelte.d.ts +15 -0
- package/dist/components/internal/Sheet.svelte +263 -0
- package/dist/components/internal/Sheet.svelte.d.ts +36 -0
- package/dist/components/internal/fade-in.d.ts +10 -0
- package/dist/components/internal/fade-in.js +20 -0
- package/dist/components/internal/groups.d.ts +14 -0
- package/dist/components/internal/groups.js +23 -0
- package/dist/components/internal/resolve.d.ts +8 -0
- package/dist/components/internal/resolve.js +247 -0
- package/dist/components/internal/swipe-dismiss.d.ts +47 -0
- package/dist/components/internal/swipe-dismiss.js +220 -0
- package/dist/components/internal/visual-viewport.svelte.d.ts +35 -0
- package/dist/components/internal/visual-viewport.svelte.js +79 -0
- package/dist/components/toast.svelte.d.ts +57 -0
- package/dist/components/toast.svelte.js +84 -0
- package/dist/fonts/OFL-geist-pixel.txt +92 -0
- package/dist/fonts/OFL.txt +93 -0
- package/dist/fonts/geist-latin-variable.woff2 +0 -0
- package/dist/fonts/geist-mono-latin-variable.woff2 +0 -0
- package/dist/fonts/geist-pixel-square.woff2 +0 -0
- package/dist/fonts.css +71 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +45 -0
- package/dist/motion/Motion.svelte +15 -0
- package/dist/motion/Motion.svelte.d.ts +9 -0
- package/dist/motion/context.d.ts +18 -0
- package/dist/motion/context.js +26 -0
- package/dist/motion/index.d.ts +3 -0
- package/dist/motion/index.js +3 -0
- package/dist/motion/transitions.d.ts +31 -0
- package/dist/motion/transitions.js +112 -0
- package/dist/tokens.css +283 -0
- package/package.json +76 -6
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { createContext, type Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Wraps a row of controls whose tooltips belong together, such as a
|
|
6
|
+
* toolbar. The group renders no element of its own: it sets up one Bits UI
|
|
7
|
+
* `Tooltip.Provider` that every `Tooltip` inside it shares, so once one
|
|
8
|
+
* tooltip in the row has opened, the next opens at once while the pointer
|
|
9
|
+
* moves along the row. Lay out the controls with your own markup inside it.
|
|
10
|
+
*/
|
|
11
|
+
export type TooltipGroupProps = {
|
|
12
|
+
/** The controls and their tooltips. */
|
|
13
|
+
children: Snippet;
|
|
14
|
+
/**
|
|
15
|
+
* Milliseconds a pointer rests on a control before the first tooltip
|
|
16
|
+
* opens (default 700, Bits UI's, as for a Tooltip outside a group). A
|
|
17
|
+
* Tooltip's own `delayDuration` wins over it.
|
|
18
|
+
*/
|
|
19
|
+
delayDuration?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Milliseconds after a tooltip in the group closes during which the next
|
|
22
|
+
* one opens without the delay (default 300, Bits UI's). 0 makes every
|
|
23
|
+
* tooltip wait the full delay.
|
|
24
|
+
*/
|
|
25
|
+
skipDelayDuration?: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const [, setGroup, hasGroup] = createContext<true>();
|
|
29
|
+
|
|
30
|
+
/** A Tooltip inside a group uses the group's provider instead of its own. */
|
|
31
|
+
export function inTooltipGroup(): boolean {
|
|
32
|
+
return hasGroup();
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<script lang="ts">
|
|
37
|
+
import { Tooltip } from 'bits-ui';
|
|
38
|
+
|
|
39
|
+
let { children, delayDuration, skipDelayDuration }: TooltipGroupProps = $props();
|
|
40
|
+
|
|
41
|
+
setGroup(true);
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<Tooltip.Provider {delayDuration} {skipDelayDuration}>
|
|
45
|
+
{@render children()}
|
|
46
|
+
</Tooltip.Provider>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a row of controls whose tooltips belong together, such as a
|
|
4
|
+
* toolbar. The group renders no element of its own: it sets up one Bits UI
|
|
5
|
+
* `Tooltip.Provider` that every `Tooltip` inside it shares, so once one
|
|
6
|
+
* tooltip in the row has opened, the next opens at once while the pointer
|
|
7
|
+
* moves along the row. Lay out the controls with your own markup inside it.
|
|
8
|
+
*/
|
|
9
|
+
export type TooltipGroupProps = {
|
|
10
|
+
/** The controls and their tooltips. */
|
|
11
|
+
children: Snippet;
|
|
12
|
+
/**
|
|
13
|
+
* Milliseconds a pointer rests on a control before the first tooltip
|
|
14
|
+
* opens (default 700, Bits UI's, as for a Tooltip outside a group). A
|
|
15
|
+
* Tooltip's own `delayDuration` wins over it.
|
|
16
|
+
*/
|
|
17
|
+
delayDuration?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Milliseconds after a tooltip in the group closes during which the next
|
|
20
|
+
* one opens without the delay (default 300, Bits UI's). 0 makes every
|
|
21
|
+
* tooltip wait the full delay.
|
|
22
|
+
*/
|
|
23
|
+
skipDelayDuration?: number;
|
|
24
|
+
};
|
|
25
|
+
/** A Tooltip inside a group uses the group's provider instead of its own. */
|
|
26
|
+
export declare function inTooltipGroup(): boolean;
|
|
27
|
+
declare const TooltipGroup: import("svelte").Component<TooltipGroupProps, {}, "">;
|
|
28
|
+
type TooltipGroup = ReturnType<typeof TooltipGroup>;
|
|
29
|
+
export default TooltipGroup;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
/**
|
|
3
|
+
* The z-index token an overlay sits on (tokens.css, layer scale).
|
|
4
|
+
* `dialog`: dialogs, their sheets and the shell drawer. `popover`:
|
|
5
|
+
* popovers, menus, select lists and comboboxes, and their sheets on
|
|
6
|
+
* compact widths, so they open over a dialog.
|
|
7
|
+
*/
|
|
8
|
+
export type OverlayLayer = 'dialog' | 'popover';
|
|
9
|
+
|
|
10
|
+
export type ScrimProps = {
|
|
11
|
+
/** Shown while true. Pass the Bits UI content's `open`. */
|
|
12
|
+
open: boolean;
|
|
13
|
+
layer: OverlayLayer;
|
|
14
|
+
};
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script lang="ts">
|
|
18
|
+
import { fade } from '../../motion/index.js';
|
|
19
|
+
|
|
20
|
+
let { open, layer }: ScrimProps = $props();
|
|
21
|
+
|
|
22
|
+
// A press on the scrim keeps focus where it is (on the trigger, or
|
|
23
|
+
// inside a dialog). The press still reaches Bits UI as an outside
|
|
24
|
+
// interaction, which closes the overlay.
|
|
25
|
+
function keepFocus(e: PointerEvent) {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<!--
|
|
31
|
+
Dims the page behind a dialog or sheet. Render it just before the panel,
|
|
32
|
+
on the same layer, so the panel paints over it. It fades with the panel's
|
|
33
|
+
timing (--dur-sheet in, --dur-sheet-exit out).
|
|
34
|
+
-->
|
|
35
|
+
{#if open}
|
|
36
|
+
<div class="hp-scrim" data-layer={layer} aria-hidden="true" onpointerdown={keepFocus} transition:fade></div>
|
|
37
|
+
{/if}
|
|
38
|
+
|
|
39
|
+
<style>
|
|
40
|
+
/* While a floating list is open Bits UI sets pointer-events: none on
|
|
41
|
+
<body>; the scrim takes presses again, so a tap on it closes. */
|
|
42
|
+
.hp-scrim {
|
|
43
|
+
position: fixed;
|
|
44
|
+
inset: 0;
|
|
45
|
+
z-index: var(--layer-dialog);
|
|
46
|
+
background: var(--scrim);
|
|
47
|
+
pointer-events: auto;
|
|
48
|
+
}
|
|
49
|
+
.hp-scrim[data-layer='popover'] {
|
|
50
|
+
z-index: var(--layer-popover);
|
|
51
|
+
}
|
|
52
|
+
</style>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The z-index token an overlay sits on (tokens.css, layer scale).
|
|
3
|
+
* `dialog`: dialogs, their sheets and the shell drawer. `popover`:
|
|
4
|
+
* popovers, menus, select lists and comboboxes, and their sheets on
|
|
5
|
+
* compact widths, so they open over a dialog.
|
|
6
|
+
*/
|
|
7
|
+
export type OverlayLayer = 'dialog' | 'popover';
|
|
8
|
+
export type ScrimProps = {
|
|
9
|
+
/** Shown while true. Pass the Bits UI content's `open`. */
|
|
10
|
+
open: boolean;
|
|
11
|
+
layer: OverlayLayer;
|
|
12
|
+
};
|
|
13
|
+
declare const Scrim: import("svelte").Component<ScrimProps, {}, "">;
|
|
14
|
+
type Scrim = ReturnType<typeof Scrim>;
|
|
15
|
+
export default Scrim;
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
import type { OverlayLayer } from './Scrim.svelte';
|
|
5
|
+
|
|
6
|
+
/** Attributes and handlers not listed here go to the panel. */
|
|
7
|
+
export type SheetProps = Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'children'> & {
|
|
8
|
+
/**
|
|
9
|
+
* Shown while true. Pass the `open` that the Bits UI content's
|
|
10
|
+
* `child` snippet receives (render the content with `forceMount`), so
|
|
11
|
+
* the sheet and its scrim slide and fade out before they unmount.
|
|
12
|
+
*/
|
|
13
|
+
open: boolean;
|
|
14
|
+
/** The title row's text, in tracked caps. */
|
|
15
|
+
title: string;
|
|
16
|
+
/** The title element's `id`, so the content can be labelled by it. */
|
|
17
|
+
titleId?: string;
|
|
18
|
+
/** The title element: `p`, or `h2` when the sheet is a dialog. */
|
|
19
|
+
titleTag?: 'p' | 'h2';
|
|
20
|
+
/** The z-index token: `dialog` for dialogs, `popover` for everything else. */
|
|
21
|
+
layer: OverlayLayer;
|
|
22
|
+
/**
|
|
23
|
+
* Called by the close button and by a swipe down. A tap on the scrim
|
|
24
|
+
* and Escape close through Bits UI.
|
|
25
|
+
*/
|
|
26
|
+
onclose: () => void;
|
|
27
|
+
/** The close button's accessible name. */
|
|
28
|
+
closeLabel?: string;
|
|
29
|
+
/** The panel element. */
|
|
30
|
+
ref?: HTMLElement | null;
|
|
31
|
+
/** The body, under the title row. It scrolls if it does not fit. */
|
|
32
|
+
children: Snippet;
|
|
33
|
+
/** A row pinned under the body, such as a dialog's actions. */
|
|
34
|
+
footer?: Snippet;
|
|
35
|
+
};
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<script lang="ts">
|
|
39
|
+
import { sheet } from '../../motion/index.js';
|
|
40
|
+
import Scrim from './Scrim.svelte';
|
|
41
|
+
import { swipeDismiss } from './swipe-dismiss.js';
|
|
42
|
+
import { followVisualViewport } from './visual-viewport.svelte.js';
|
|
43
|
+
|
|
44
|
+
let {
|
|
45
|
+
open,
|
|
46
|
+
title,
|
|
47
|
+
titleId,
|
|
48
|
+
titleTag = 'p',
|
|
49
|
+
layer,
|
|
50
|
+
onclose,
|
|
51
|
+
closeLabel = 'Close',
|
|
52
|
+
ref = $bindable(null),
|
|
53
|
+
children,
|
|
54
|
+
footer,
|
|
55
|
+
class: className,
|
|
56
|
+
...rest
|
|
57
|
+
}: SheetProps = $props();
|
|
58
|
+
|
|
59
|
+
let body = $state<HTMLElement | null>(null);
|
|
60
|
+
|
|
61
|
+
// The sheet follows the visual viewport while it is open (decided
|
|
62
|
+
// 2026-11-10; internal/visual-viewport.svelte.ts): while the on-screen
|
|
63
|
+
// keyboard shortens it, the sheet's bottom edge sits on its bottom edge
|
|
64
|
+
// and the sheet may grow to its height less the header row's
|
|
65
|
+
// (--header-height and the top safe area), where it was half the screen.
|
|
66
|
+
// The focused field in the body stays in sight.
|
|
67
|
+
const viewport = followVisualViewport(() => open, () => body);
|
|
68
|
+
|
|
69
|
+
// The press that opened the sheet never acts on what the sheet now shows
|
|
70
|
+
// under the finger (decided 2026-11-10). On touch, Bits UI's Menu and
|
|
71
|
+
// Select triggers open on pointerup, and the click that follows lands on
|
|
72
|
+
// the sheet, which under reduced motion fades in where it ends up; a
|
|
73
|
+
// mouse opens them on pointerdown, and its pointerup on an item counts
|
|
74
|
+
// as a choice. So until a press starts inside the sheet, a pointerup or a
|
|
75
|
+
// pointer's click inside it stops here. A click from Enter, Space or
|
|
76
|
+
// element.click() has detail 0 and always passes.
|
|
77
|
+
function ignoreOpeningPress(node: HTMLElement) {
|
|
78
|
+
let pressed = false;
|
|
79
|
+
const press = () => (pressed = true);
|
|
80
|
+
const guard = (e: MouseEvent) => {
|
|
81
|
+
if (pressed || (e.type === 'click' && e.detail === 0)) return;
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
e.stopImmediatePropagation();
|
|
84
|
+
};
|
|
85
|
+
const capture = { capture: true };
|
|
86
|
+
node.addEventListener('pointerdown', press, capture);
|
|
87
|
+
node.addEventListener('pointerup', guard, capture);
|
|
88
|
+
node.addEventListener('click', guard, capture);
|
|
89
|
+
return () => {
|
|
90
|
+
node.removeEventListener('pointerdown', press, capture);
|
|
91
|
+
node.removeEventListener('pointerup', guard, capture);
|
|
92
|
+
node.removeEventListener('click', guard, capture);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<!--
|
|
98
|
+
The bottom sheet every overlay uses on compact widths (BRIEF, Apps and
|
|
99
|
+
phones: Overlays): a scrim, then a panel at the bottom edge with a handle,
|
|
100
|
+
a caps title, a close button, the body and an optional footer. It opens at
|
|
101
|
+
half the screen at most, with no drag to expand; the body scrolls inside.
|
|
102
|
+
A swipe down dismisses it (internal/swipe-dismiss.ts). While the visual
|
|
103
|
+
viewport is shorter than the layout viewport (the on-screen keyboard), it
|
|
104
|
+
sits on top of it and may fill the space above it. The press that opened
|
|
105
|
+
it does not act inside it.
|
|
106
|
+
|
|
107
|
+
Render it inside the Bits UI content's `child` snippet and spread the
|
|
108
|
+
snippet's `props` onto it when the panel is the content element (a
|
|
109
|
+
dialog), or onto an element in the body when the content is a list (a
|
|
110
|
+
menu, a select): then pass `onInteractOutside` to the content and call
|
|
111
|
+
`preventDefault()` for presses inside `ref`, so the title row does not
|
|
112
|
+
count as outside.
|
|
113
|
+
-->
|
|
114
|
+
<Scrim {open} {layer} />
|
|
115
|
+
{#if open}
|
|
116
|
+
{@const lifted = viewport.current}
|
|
117
|
+
<div
|
|
118
|
+
bind:this={ref}
|
|
119
|
+
{...rest}
|
|
120
|
+
class={['hp-sheet', className]}
|
|
121
|
+
data-layer={layer}
|
|
122
|
+
style:bottom={lifted ? `calc(100% - ${lifted.bottom}px)` : undefined}
|
|
123
|
+
style:padding-bottom={lifted ? '0px' : undefined}
|
|
124
|
+
style:--sheet-max-height={lifted
|
|
125
|
+
? `calc(${lifted.height}px - var(--header-height) - env(safe-area-inset-top))`
|
|
126
|
+
: undefined}
|
|
127
|
+
transition:sheet
|
|
128
|
+
{@attach ignoreOpeningPress}
|
|
129
|
+
{@attach swipeDismiss(() => onclose())}
|
|
130
|
+
>
|
|
131
|
+
<div class="hp-sheet-head">
|
|
132
|
+
<span class="hp-sheet-handle" aria-hidden="true"></span>
|
|
133
|
+
<svelte:element this={titleTag} id={titleId} class="hp-sheet-title">{title}</svelte:element>
|
|
134
|
+
<button type="button" class="hp-sheet-close" aria-label={closeLabel} onclick={() => onclose()}>
|
|
135
|
+
<svg
|
|
136
|
+
viewBox="0 0 16 16"
|
|
137
|
+
fill="none"
|
|
138
|
+
stroke="currentColor"
|
|
139
|
+
stroke-width="1.5"
|
|
140
|
+
stroke-linecap="square"
|
|
141
|
+
aria-hidden="true"
|
|
142
|
+
>
|
|
143
|
+
<path d="M3 3l10 10M13 3L3 13" />
|
|
144
|
+
</svg>
|
|
145
|
+
</button>
|
|
146
|
+
</div>
|
|
147
|
+
<div class="hp-sheet-body" bind:this={body}>
|
|
148
|
+
{@render children()}
|
|
149
|
+
</div>
|
|
150
|
+
{#if footer}
|
|
151
|
+
<div class="hp-sheet-footer">
|
|
152
|
+
{@render footer()}
|
|
153
|
+
</div>
|
|
154
|
+
{/if}
|
|
155
|
+
</div>
|
|
156
|
+
{/if}
|
|
157
|
+
|
|
158
|
+
<style>
|
|
159
|
+
/* While a floating list is open Bits UI sets pointer-events: none on
|
|
160
|
+
<body>; the panel takes presses again. */
|
|
161
|
+
.hp-sheet {
|
|
162
|
+
/* The height cap: half the screen, or the room above the on-screen
|
|
163
|
+
keyboard while it is up (set inline). A list that must keep its
|
|
164
|
+
height while it filters asks for this. */
|
|
165
|
+
--sheet-max-height: 50dvh;
|
|
166
|
+
|
|
167
|
+
position: fixed;
|
|
168
|
+
inset: auto 0 0;
|
|
169
|
+
z-index: var(--layer-dialog);
|
|
170
|
+
display: flex;
|
|
171
|
+
flex-direction: column;
|
|
172
|
+
box-sizing: border-box;
|
|
173
|
+
/* Opens at half the screen at most; the body scrolls inside. */
|
|
174
|
+
max-height: var(--sheet-max-height);
|
|
175
|
+
padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
|
|
176
|
+
border-top: 1px solid var(--border-control);
|
|
177
|
+
background: var(--canvas);
|
|
178
|
+
color: var(--text);
|
|
179
|
+
overscroll-behavior: contain;
|
|
180
|
+
pointer-events: auto;
|
|
181
|
+
}
|
|
182
|
+
.hp-sheet[data-layer='popover'] {
|
|
183
|
+
z-index: var(--layer-popover);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* The grab area: handle, title and close button. The swipe owns touches
|
|
187
|
+
here; the body below keeps its scroll until it reaches the top. */
|
|
188
|
+
.hp-sheet-head {
|
|
189
|
+
flex: none;
|
|
190
|
+
display: grid;
|
|
191
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
192
|
+
align-items: start;
|
|
193
|
+
padding: 0 var(--space-1) 0 var(--gutter);
|
|
194
|
+
touch-action: none;
|
|
195
|
+
}
|
|
196
|
+
.hp-sheet-handle {
|
|
197
|
+
grid-column: 1 / -1;
|
|
198
|
+
justify-self: center;
|
|
199
|
+
width: var(--space-8);
|
|
200
|
+
height: var(--space-1);
|
|
201
|
+
margin-top: var(--space-2);
|
|
202
|
+
background: var(--border-control);
|
|
203
|
+
}
|
|
204
|
+
/* Tracked caps at the compact view-title size. A long title wraps (200
|
|
205
|
+
percent zoom); the padding centres its first line on the 44px close
|
|
206
|
+
button, so a single line sits where it always did. The clip stays: it
|
|
207
|
+
keeps the first glyph's antialiasing inside the text edge, as before. */
|
|
208
|
+
.hp-sheet-title {
|
|
209
|
+
overflow: hidden;
|
|
210
|
+
padding-block: calc((44px - 1lh) / 2);
|
|
211
|
+
font-size: var(--type-body);
|
|
212
|
+
font-weight: 500;
|
|
213
|
+
line-height: 24px;
|
|
214
|
+
letter-spacing: var(--label-tracking);
|
|
215
|
+
text-transform: var(--label-transform);
|
|
216
|
+
overflow-wrap: anywhere;
|
|
217
|
+
}
|
|
218
|
+
.hp-sheet-close {
|
|
219
|
+
display: grid;
|
|
220
|
+
place-items: center;
|
|
221
|
+
width: 44px;
|
|
222
|
+
height: 44px;
|
|
223
|
+
padding: 0;
|
|
224
|
+
border: 0;
|
|
225
|
+
background: transparent;
|
|
226
|
+
color: var(--text);
|
|
227
|
+
cursor: pointer;
|
|
228
|
+
-webkit-tap-highlight-color: transparent;
|
|
229
|
+
}
|
|
230
|
+
.hp-sheet-close svg {
|
|
231
|
+
width: var(--space-4);
|
|
232
|
+
height: var(--space-4);
|
|
233
|
+
}
|
|
234
|
+
.hp-sheet-close:active {
|
|
235
|
+
background: var(--surface-raised);
|
|
236
|
+
}
|
|
237
|
+
@media (hover: hover) and (pointer: fine) {
|
|
238
|
+
.hp-sheet-close {
|
|
239
|
+
transition: background-color var(--dur-hover) var(--settle);
|
|
240
|
+
}
|
|
241
|
+
.hp-sheet-close:hover {
|
|
242
|
+
background: var(--surface-hover);
|
|
243
|
+
}
|
|
244
|
+
.hp-sheet-close:active {
|
|
245
|
+
background: var(--surface-raised);
|
|
246
|
+
transition-duration: var(--dur-press);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/* A flex column, so a list inside can take the rest of the height
|
|
251
|
+
(flex: 1 1 auto; min-height: 0) and scroll on its own. */
|
|
252
|
+
.hp-sheet-body {
|
|
253
|
+
display: flex;
|
|
254
|
+
flex-direction: column;
|
|
255
|
+
flex: 1 1 auto;
|
|
256
|
+
min-height: 0;
|
|
257
|
+
overflow-y: auto;
|
|
258
|
+
overscroll-behavior: contain;
|
|
259
|
+
}
|
|
260
|
+
.hp-sheet-footer {
|
|
261
|
+
flex: none;
|
|
262
|
+
}
|
|
263
|
+
</style>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { OverlayLayer } from './Scrim.svelte';
|
|
4
|
+
/** Attributes and handlers not listed here go to the panel. */
|
|
5
|
+
export type SheetProps = Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'children'> & {
|
|
6
|
+
/**
|
|
7
|
+
* Shown while true. Pass the `open` that the Bits UI content's
|
|
8
|
+
* `child` snippet receives (render the content with `forceMount`), so
|
|
9
|
+
* the sheet and its scrim slide and fade out before they unmount.
|
|
10
|
+
*/
|
|
11
|
+
open: boolean;
|
|
12
|
+
/** The title row's text, in tracked caps. */
|
|
13
|
+
title: string;
|
|
14
|
+
/** The title element's `id`, so the content can be labelled by it. */
|
|
15
|
+
titleId?: string;
|
|
16
|
+
/** The title element: `p`, or `h2` when the sheet is a dialog. */
|
|
17
|
+
titleTag?: 'p' | 'h2';
|
|
18
|
+
/** The z-index token: `dialog` for dialogs, `popover` for everything else. */
|
|
19
|
+
layer: OverlayLayer;
|
|
20
|
+
/**
|
|
21
|
+
* Called by the close button and by a swipe down. A tap on the scrim
|
|
22
|
+
* and Escape close through Bits UI.
|
|
23
|
+
*/
|
|
24
|
+
onclose: () => void;
|
|
25
|
+
/** The close button's accessible name. */
|
|
26
|
+
closeLabel?: string;
|
|
27
|
+
/** The panel element. */
|
|
28
|
+
ref?: HTMLElement | null;
|
|
29
|
+
/** The body, under the title row. It scrolls if it does not fit. */
|
|
30
|
+
children: Snippet;
|
|
31
|
+
/** A row pinned under the body, such as a dialog's actions. */
|
|
32
|
+
footer?: Snippet;
|
|
33
|
+
};
|
|
34
|
+
declare const Sheet: import("svelte").Component<SheetProps, {}, "ref">;
|
|
35
|
+
type Sheet = ReturnType<typeof Sheet>;
|
|
36
|
+
export default Sheet;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Short motion (BRIEF): fades `node` in from opacity 0 over the duration
|
|
3
|
+
* token `token`, such as `--dur-panel`, on `--settle`. Both are read from the
|
|
4
|
+
* node now, so a retuned token applies. At 0ms it does nothing and the node
|
|
5
|
+
* shows at once, as it did before the token existed. Opacity only, so it
|
|
6
|
+
* runs under reduced motion too. Call it after the change is in the DOM and
|
|
7
|
+
* before the next frame, so the first frame already shows opacity 0. Returns
|
|
8
|
+
* the fade, or null when there is none.
|
|
9
|
+
*/
|
|
10
|
+
export declare function fadeIn(node: Element, token: string): Animation | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { duration } from '../../motion/transitions.js';
|
|
2
|
+
/**
|
|
3
|
+
* Short motion (BRIEF): fades `node` in from opacity 0 over the duration
|
|
4
|
+
* token `token`, such as `--dur-panel`, on `--settle`. Both are read from the
|
|
5
|
+
* node now, so a retuned token applies. At 0ms it does nothing and the node
|
|
6
|
+
* shows at once, as it did before the token existed. Opacity only, so it
|
|
7
|
+
* runs under reduced motion too. Call it after the change is in the DOM and
|
|
8
|
+
* before the next frame, so the first frame already shows opacity 0. Returns
|
|
9
|
+
* the fade, or null when there is none.
|
|
10
|
+
*/
|
|
11
|
+
export function fadeIn(node, token) {
|
|
12
|
+
const ms = duration(node, token);
|
|
13
|
+
if (ms <= 0)
|
|
14
|
+
return null;
|
|
15
|
+
const settle = getComputedStyle(node).getPropertyValue('--settle').trim();
|
|
16
|
+
return node.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
17
|
+
duration: ms,
|
|
18
|
+
easing: CSS.supports('transition-timing-function', settle) ? settle : 'ease-out'
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type OptionGroup<T> = {
|
|
2
|
+
name: string;
|
|
3
|
+
items: T[];
|
|
4
|
+
};
|
|
5
|
+
export type GroupedOptions<T> = {
|
|
6
|
+
/** The items without a group, in their order. */
|
|
7
|
+
loose: T[];
|
|
8
|
+
groups: OptionGroup<T>[];
|
|
9
|
+
/** Every item in the order the list shows them. */
|
|
10
|
+
ordered: T[];
|
|
11
|
+
};
|
|
12
|
+
export declare function groupOptions<T extends {
|
|
13
|
+
group?: string;
|
|
14
|
+
}>(items: readonly T[]): GroupedOptions<T>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Options in named groups, in one list (Select, Combobox, NativeSelect).
|
|
2
|
+
// Items without a group come first, before any heading; then each group,
|
|
3
|
+
// in the order its first item appears. Items keep their order inside a
|
|
4
|
+
// group. An empty `group` counts as none, because a heading needs text.
|
|
5
|
+
export function groupOptions(items) {
|
|
6
|
+
const loose = [];
|
|
7
|
+
const byName = new Map();
|
|
8
|
+
for (const item of items) {
|
|
9
|
+
if (!item.group) {
|
|
10
|
+
loose.push(item);
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const members = byName.get(item.group);
|
|
14
|
+
if (members)
|
|
15
|
+
members.push(item);
|
|
16
|
+
else
|
|
17
|
+
byName.set(item.group, [item]);
|
|
18
|
+
}
|
|
19
|
+
if (!byName.size)
|
|
20
|
+
return { loose, groups: [], ordered: loose };
|
|
21
|
+
const groups = Array.from(byName, ([name, members]) => ({ name, items: members }));
|
|
22
|
+
return { loose, groups, ordered: loose.concat(...groups.map((g) => g.items)) };
|
|
23
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shows `image` on `canvas` as a mosaic that sharpens one step per `step`
|
|
3
|
+
* ms, then calls `done`. The canvas carries `data-step` (1 to 5) and
|
|
4
|
+
* `data-block` (the block size in device pixels) for the step on screen.
|
|
5
|
+
* When the box is empty or the image has no size, `done` runs at once.
|
|
6
|
+
* Returns a stop function.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveImage(canvas: HTMLCanvasElement, image: HTMLImageElement, step: number, done: () => void): () => void;
|