@getcortexlabs/mavis-core 0.1.0-alpha.9 → 0.1.0-rc.11.1
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/README.md +2 -2
- package/dist/capabilities.d.ts +7 -7
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +29 -4
- package/dist/capabilities.js.map +1 -1
- package/dist/chart.d.ts +43 -0
- package/dist/chart.d.ts.map +1 -0
- package/dist/chart.js +105 -0
- package/dist/chart.js.map +1 -0
- package/dist/collections.d.ts +46 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +48 -0
- package/dist/collections.js.map +1 -0
- package/dist/contracts.d.ts +20 -0
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +2 -0
- package/dist/contracts.js.map +1 -1
- package/dist/discovery.d.ts +49 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +80 -0
- package/dist/discovery.js.map +1 -0
- package/dist/experimental-regions.d.ts +10 -0
- package/dist/experimental-regions.d.ts.map +1 -1
- package/dist/experimental-regions.js +23 -0
- package/dist/experimental-regions.js.map +1 -1
- package/dist/experimental.d.ts +5 -0
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +29 -0
- package/dist/experimental.js.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/interactive.d.ts +36 -0
- package/dist/interactive.d.ts.map +1 -0
- package/dist/interactive.js +61 -0
- package/dist/interactive.js.map +1 -0
- package/dist/link.d.ts +2 -0
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js.map +1 -1
- package/dist/motion.d.ts +8 -0
- package/dist/motion.d.ts.map +1 -1
- package/dist/motion.js +11 -0
- package/dist/motion.js.map +1 -1
- package/dist/navigation-transition.d.ts +10 -0
- package/dist/navigation-transition.d.ts.map +1 -0
- package/dist/navigation-transition.js +10 -0
- package/dist/navigation-transition.js.map +1 -0
- package/dist/number-flow-format.d.ts +16 -0
- package/dist/number-flow-format.d.ts.map +1 -0
- package/dist/number-flow-format.js +49 -0
- package/dist/number-flow-format.js.map +1 -0
- package/dist/popover.d.ts +17 -0
- package/dist/popover.d.ts.map +1 -0
- package/dist/popover.js +19 -0
- package/dist/popover.js.map +1 -0
- package/dist/section-scroll.d.ts +14 -0
- package/dist/section-scroll.d.ts.map +1 -0
- package/dist/section-scroll.js +28 -0
- package/dist/section-scroll.js.map +1 -0
- package/dist/time.d.ts +34 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +78 -0
- package/dist/time.js.map +1 -0
- package/dist/vue/carousel.d.ts +13 -0
- package/dist/vue/carousel.d.ts.map +1 -0
- package/dist/vue/carousel.js +136 -0
- package/dist/vue/carousel.js.map +1 -0
- package/dist/vue/chart.d.ts +194 -0
- package/dist/vue/chart.d.ts.map +1 -0
- package/dist/vue/chart.js +245 -0
- package/dist/vue/chart.js.map +1 -0
- package/dist/vue/command-palette.d.ts +129 -0
- package/dist/vue/command-palette.d.ts.map +1 -0
- package/dist/vue/command-palette.js +190 -0
- package/dist/vue/command-palette.js.map +1 -0
- package/dist/vue/component-motion.d.ts +17 -0
- package/dist/vue/component-motion.d.ts.map +1 -0
- package/dist/vue/component-motion.js +83 -0
- package/dist/vue/component-motion.js.map +1 -0
- package/dist/vue/component-props.d.ts +1016 -18
- package/dist/vue/component-props.d.ts.map +1 -1
- package/dist/vue/component-props.js +28 -0
- package/dist/vue/component-props.js.map +1 -1
- package/dist/vue/configurator.d.ts +2 -2
- package/dist/vue/configurator.d.ts.map +1 -1
- package/dist/vue/configurator.js +3 -1
- package/dist/vue/configurator.js.map +1 -1
- package/dist/vue/data-table.d.ts +17 -0
- package/dist/vue/data-table.d.ts.map +1 -0
- package/dist/vue/data-table.js +133 -0
- package/dist/vue/data-table.js.map +1 -0
- package/dist/vue/date-calendar.d.ts +2 -0
- package/dist/vue/date-calendar.d.ts.map +1 -1
- package/dist/vue/date-calendar.js +20 -1
- package/dist/vue/date-calendar.js.map +1 -1
- package/dist/vue/date-picker.d.ts +8 -8
- package/dist/vue/date-props.d.ts +6 -0
- package/dist/vue/date-props.d.ts.map +1 -1
- package/dist/vue/date-props.js +3 -0
- package/dist/vue/date-props.js.map +1 -1
- package/dist/vue/discovery-components.d.ts +50 -0
- package/dist/vue/discovery-components.d.ts.map +1 -0
- package/dist/vue/discovery-components.js +2 -0
- package/dist/vue/discovery-components.js.map +1 -0
- package/dist/vue/discovery-controls.d.ts +197 -0
- package/dist/vue/discovery-controls.d.ts.map +1 -0
- package/dist/vue/discovery-controls.js +185 -0
- package/dist/vue/discovery-controls.js.map +1 -0
- package/dist/vue/discovery-props.d.ts +249 -0
- package/dist/vue/discovery-props.d.ts.map +1 -0
- package/dist/vue/discovery-props.js +87 -0
- package/dist/vue/discovery-props.js.map +1 -0
- package/dist/vue/global-components.d.ts +131 -0
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/index.d.ts +25 -0
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +21 -0
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/interactive-components.d.ts +31 -0
- package/dist/vue/interactive-components.d.ts.map +1 -0
- package/dist/vue/interactive-components.js +2 -0
- package/dist/vue/interactive-components.js.map +1 -0
- package/dist/vue/interactive-props.d.ts +254 -0
- package/dist/vue/interactive-props.d.ts.map +1 -0
- package/dist/vue/interactive-props.js +85 -0
- package/dist/vue/interactive-props.js.map +1 -0
- package/dist/vue/list-motion.d.ts +7 -0
- package/dist/vue/list-motion.d.ts.map +1 -0
- package/dist/vue/list-motion.js +28 -0
- package/dist/vue/list-motion.js.map +1 -0
- package/dist/vue/menu.d.ts +122 -0
- package/dist/vue/menu.d.ts.map +1 -0
- package/dist/vue/menu.js +79 -0
- package/dist/vue/menu.js.map +1 -0
- package/dist/vue/navigation-controls.d.ts +125 -0
- package/dist/vue/navigation-controls.d.ts.map +1 -0
- package/dist/vue/navigation-controls.js +130 -0
- package/dist/vue/navigation-controls.js.map +1 -0
- package/dist/vue/navigation-props.d.ts +283 -0
- package/dist/vue/navigation-props.d.ts.map +1 -0
- package/dist/vue/navigation-props.js +82 -0
- package/dist/vue/navigation-props.js.map +1 -0
- package/dist/vue/number-flow.d.ts +75 -0
- package/dist/vue/number-flow.d.ts.map +1 -0
- package/dist/vue/number-flow.js +57 -0
- package/dist/vue/number-flow.js.map +1 -0
- package/dist/vue/partition.d.ts +15 -0
- package/dist/vue/partition.d.ts.map +1 -0
- package/dist/vue/partition.js +42 -0
- package/dist/vue/partition.js.map +1 -0
- package/dist/vue/platform.d.ts +37 -0
- package/dist/vue/platform.d.ts.map +1 -0
- package/dist/vue/platform.js +46 -0
- package/dist/vue/platform.js.map +1 -0
- package/dist/vue/props.d.ts +76 -36
- package/dist/vue/props.d.ts.map +1 -1
- package/dist/vue/props.js +3 -1
- package/dist/vue/props.js.map +1 -1
- package/dist/vue/sortable-list.d.ts +24 -0
- package/dist/vue/sortable-list.d.ts.map +1 -0
- package/dist/vue/sortable-list.js +251 -0
- package/dist/vue/sortable-list.js.map +1 -0
- package/dist/vue/swipe-actions.d.ts +96 -0
- package/dist/vue/swipe-actions.d.ts.map +1 -0
- package/dist/vue/swipe-actions.js +174 -0
- package/dist/vue/swipe-actions.js.map +1 -0
- package/dist/vue/time-picker.d.ts +488 -0
- package/dist/vue/time-picker.d.ts.map +1 -0
- package/dist/vue/time-picker.js +190 -0
- package/dist/vue/time-picker.js.map +1 -0
- package/dist/vue/tree-view.d.ts +111 -0
- package/dist/vue/tree-view.d.ts.map +1 -0
- package/dist/vue/tree-view.js +204 -0
- package/dist/vue/tree-view.js.map +1 -0
- package/dist/vue/virtual-list.d.ts +26 -0
- package/dist/vue/virtual-list.d.ts.map +1 -0
- package/dist/vue/virtual-list.js +2 -0
- package/dist/vue/virtual-list.js.map +1 -0
- package/dist/vue/wayfinding-controls.d.ts +199 -0
- package/dist/vue/wayfinding-controls.d.ts.map +1 -0
- package/dist/vue/wayfinding-controls.js +330 -0
- package/dist/vue/wayfinding-controls.js.map +1 -0
- package/dist/vue/wayfinding-props.d.ts +221 -0
- package/dist/vue/wayfinding-props.d.ts.map +1 -0
- package/dist/vue/wayfinding-props.js +86 -0
- package/dist/vue/wayfinding-props.js.map +1 -0
- package/dist/vue/workflows.d.ts +2 -2
- package/dist/vue/workflows.d.ts.map +1 -1
- package/dist/vue/workflows.js +17 -4
- package/dist/vue/workflows.js.map +1 -1
- package/dist/wayfinding.d.ts +50 -0
- package/dist/wayfinding.d.ts.map +1 -0
- package/dist/wayfinding.js +54 -0
- package/dist/wayfinding.js.map +1 -0
- package/package.json +2 -2
- package/src/capabilities.ts +30 -4
- package/src/chart.ts +151 -0
- package/src/collections.ts +87 -0
- package/src/contracts.ts +2 -0
- package/src/discovery.ts +139 -0
- package/src/experimental-regions.ts +29 -0
- package/src/experimental.ts +40 -0
- package/src/index.ts +18 -1
- package/src/interactive.ts +91 -0
- package/src/link.ts +2 -0
- package/src/motion.ts +14 -0
- package/src/navigation-transition.ts +14 -0
- package/src/number-flow-format.ts +68 -0
- package/src/popover.ts +38 -0
- package/src/section-scroll.ts +46 -0
- package/src/time.ts +83 -0
- package/src/vue/carousel.ts +198 -0
- package/src/vue/chart.ts +337 -0
- package/src/vue/command-palette.ts +235 -0
- package/src/vue/component-motion.ts +109 -0
- package/src/vue/component-props.ts +57 -0
- package/src/vue/configurator.ts +3 -1
- package/src/vue/data-table.ts +190 -0
- package/src/vue/date-calendar.ts +30 -1
- package/src/vue/date-props.ts +3 -0
- package/src/vue/discovery-components.ts +60 -0
- package/src/vue/discovery-controls.ts +241 -0
- package/src/vue/discovery-props.ts +92 -0
- package/src/vue/global-components.ts +121 -0
- package/src/vue/index.ts +44 -0
- package/src/vue/interactive-components.ts +29 -0
- package/src/vue/interactive-props.ts +90 -0
- package/src/vue/list-motion.ts +31 -0
- package/src/vue/menu.ts +100 -0
- package/src/vue/navigation-controls.ts +159 -0
- package/src/vue/navigation-props.ts +87 -0
- package/src/vue/number-flow.ts +83 -0
- package/src/vue/partition.ts +49 -0
- package/src/vue/platform.ts +73 -0
- package/src/vue/props.ts +3 -1
- package/src/vue/sortable-list.ts +308 -0
- package/src/vue/swipe-actions.ts +226 -0
- package/src/vue/time-picker.ts +227 -0
- package/src/vue/tree-view.ts +259 -0
- package/src/vue/virtual-list.ts +28 -0
- package/src/vue/wayfinding-controls.ts +430 -0
- package/src/vue/wayfinding-props.ts +97 -0
- package/src/vue/workflows.ts +17 -4
- package/src/wayfinding.ts +85 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { collectionKeys } from './discovery.js';
|
|
2
|
+
import { linkDestination } from './link.js';
|
|
3
|
+
import { validateNavigation } from './collections.js';
|
|
4
|
+
const searchable = (value) => value
|
|
5
|
+
.normalize('NFD')
|
|
6
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
7
|
+
.toLowerCase();
|
|
8
|
+
export function filterCommands(items, query) {
|
|
9
|
+
collectionKeys(items, 'value');
|
|
10
|
+
for (const item of items)
|
|
11
|
+
if (!item.label.trim())
|
|
12
|
+
throw new TypeError('Commands require labels.');
|
|
13
|
+
const terms = searchable(query.trim()).split(/\s+/).filter(Boolean);
|
|
14
|
+
return items.filter((item) => {
|
|
15
|
+
const haystack = searchable([item.label, item.description, item.group, ...(item.keywords ?? [])]
|
|
16
|
+
.filter(Boolean)
|
|
17
|
+
.join(' '));
|
|
18
|
+
return terms.every((term) => haystack.includes(term));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function validateRail(groups) {
|
|
22
|
+
collectionKeys(groups, 'key');
|
|
23
|
+
for (const group of groups)
|
|
24
|
+
if (!group.label.trim())
|
|
25
|
+
throw new TypeError('Navigation groups require labels.');
|
|
26
|
+
validateNavigation(groups.flatMap((group) => group.items));
|
|
27
|
+
}
|
|
28
|
+
export function breadcrumbParts(items, maxItems) {
|
|
29
|
+
collectionKeys(items, 'key');
|
|
30
|
+
if (!Number.isInteger(maxItems) || maxItems < 2)
|
|
31
|
+
throw new RangeError('Breadcrumb maxItems must be an integer of at least 2.');
|
|
32
|
+
items.forEach((item, index) => {
|
|
33
|
+
if (!item.label.trim())
|
|
34
|
+
throw new TypeError('Breadcrumb entries require labels.');
|
|
35
|
+
if (index < items.length - 1 && !item.href)
|
|
36
|
+
throw new TypeError('Breadcrumb ancestors require destinations.');
|
|
37
|
+
if (item.href !== undefined)
|
|
38
|
+
linkDestination(item.href);
|
|
39
|
+
});
|
|
40
|
+
if (items.length <= maxItems)
|
|
41
|
+
return { before: items, hidden: [], after: [] };
|
|
42
|
+
const split = items.length - maxItems + 1;
|
|
43
|
+
return { before: items.slice(0, 1), hidden: items.slice(1, split), after: items.slice(split) };
|
|
44
|
+
}
|
|
45
|
+
export function validateTimeline(items) {
|
|
46
|
+
collectionKeys(items, 'key');
|
|
47
|
+
for (const item of items) {
|
|
48
|
+
if (!item.title.trim())
|
|
49
|
+
throw new TypeError('Timeline entries require titles.');
|
|
50
|
+
if (item.status && !['complete', 'current', 'upcoming', 'error'].includes(item.status))
|
|
51
|
+
throw new TypeError('Unknown timeline status.');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=wayfinding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wayfinding.js","sourceRoot":"","sources":["../src/wayfinding.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getcortexlabs/mavis-core",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-rc.11.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Shared Mavis themes and component contracts.",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public",
|
|
51
|
-
"tag": "
|
|
51
|
+
"tag": "rc",
|
|
52
52
|
"registry": "https://registry.npmjs.org/"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|
package/src/capabilities.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
/** Source capabilities, not a promise that every feature is in the last npm release. */
|
|
2
2
|
export const componentNames = [
|
|
3
|
+
'MSortableList',
|
|
4
|
+
'MSwipeActions',
|
|
5
|
+
'MNumberFlow',
|
|
6
|
+
'MResizablePanels',
|
|
7
|
+
'MImageCompare',
|
|
8
|
+
'MImageViewer',
|
|
9
|
+
|
|
3
10
|
'MScreen',
|
|
4
11
|
'MRow',
|
|
5
12
|
'MColumn',
|
|
@@ -11,6 +18,7 @@ export const componentNames = [
|
|
|
11
18
|
'MText',
|
|
12
19
|
'MSpan',
|
|
13
20
|
'MThemeProvider',
|
|
21
|
+
'MPlatform',
|
|
14
22
|
'MIcon',
|
|
15
23
|
'MButton',
|
|
16
24
|
'MInput',
|
|
@@ -46,6 +54,24 @@ export const componentNames = [
|
|
|
46
54
|
'MFormErrors',
|
|
47
55
|
'MSteps',
|
|
48
56
|
'MPagination',
|
|
57
|
+
'MPopover',
|
|
58
|
+
'MMenu',
|
|
59
|
+
'MAppBar',
|
|
60
|
+
'MTabBar',
|
|
61
|
+
'MTimePicker',
|
|
62
|
+
'MVirtualList',
|
|
63
|
+
'MDataTable',
|
|
64
|
+
'MCarousel',
|
|
65
|
+
'MRangeSlider',
|
|
66
|
+
'MCalendar',
|
|
67
|
+
'MRating',
|
|
68
|
+
'MTreeView',
|
|
69
|
+
'MCommandPalette',
|
|
70
|
+
'MNavigationRail',
|
|
71
|
+
'MBreadcrumb',
|
|
72
|
+
'MTooltip',
|
|
73
|
+
'MTimeline',
|
|
74
|
+
'MChart',
|
|
49
75
|
] as const
|
|
50
76
|
export type ComponentName = (typeof componentNames)[number]
|
|
51
77
|
export type CapabilityStatus = 'experimental' | 'planned' | 'unsupported' | 'unverified'
|
|
@@ -53,11 +79,11 @@ export type CapabilityStatus = 'experimental' | 'planned' | 'unsupported' | 'unv
|
|
|
53
79
|
export const targetCapabilities = {
|
|
54
80
|
version: 1,
|
|
55
81
|
source: 'repository',
|
|
56
|
-
publishedBaseline: '0.1.0-
|
|
82
|
+
publishedBaseline: '0.1.0-rc.11.1',
|
|
57
83
|
developmentMotion: {
|
|
58
84
|
availability: 'published',
|
|
59
85
|
joltCommit: null,
|
|
60
|
-
publishedJoltRelease: '0.1.0-rc.
|
|
86
|
+
publishedJoltRelease: '0.1.0-rc.11',
|
|
61
87
|
features: {
|
|
62
88
|
gradient: ['web', 'ios', 'android'],
|
|
63
89
|
loadingEffects: ['web', 'ios'],
|
|
@@ -83,7 +109,7 @@ export const targetCapabilities = {
|
|
|
83
109
|
streaming: 'unverified',
|
|
84
110
|
rsc: 'unsupported',
|
|
85
111
|
},
|
|
86
|
-
motion: { engine: 'jolt', minimum: '0.1.0-rc.
|
|
112
|
+
motion: { engine: 'jolt', minimum: '0.1.0-rc.11', start: 'client-mount' },
|
|
87
113
|
ssr: {
|
|
88
114
|
availability: '0.1.0-alpha.5',
|
|
89
115
|
host: 'nuxt',
|
|
@@ -126,7 +152,7 @@ export const targetCapabilities = {
|
|
|
126
152
|
streaming: 'unsupported',
|
|
127
153
|
rsc: 'unsupported',
|
|
128
154
|
},
|
|
129
|
-
motion: { engine: 'jolt', minimum: '0.1.0-rc.
|
|
155
|
+
motion: { engine: 'jolt', minimum: '0.1.0-rc.11', start: 'native-loaded' },
|
|
130
156
|
},
|
|
131
157
|
],
|
|
132
158
|
planned: [
|
package/src/chart.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { collectionKeys } from './discovery.js'
|
|
2
|
+
import type { ChoiceValue } from './choice.js'
|
|
3
|
+
|
|
4
|
+
export interface ChartCategory {
|
|
5
|
+
key: ChoiceValue
|
|
6
|
+
label: string
|
|
7
|
+
}
|
|
8
|
+
export interface ChartSeries {
|
|
9
|
+
key: ChoiceValue
|
|
10
|
+
label: string
|
|
11
|
+
values: readonly (number | null)[]
|
|
12
|
+
/** A shared CSS/native hex color; the theme supplies defaults. */
|
|
13
|
+
color?: string
|
|
14
|
+
}
|
|
15
|
+
export interface ChartSelection {
|
|
16
|
+
category: ChoiceValue
|
|
17
|
+
series: ChoiceValue
|
|
18
|
+
}
|
|
19
|
+
export interface ChartPoint {
|
|
20
|
+
key?: ChoiceValue
|
|
21
|
+
x: number
|
|
22
|
+
y: number
|
|
23
|
+
value: number
|
|
24
|
+
index: number
|
|
25
|
+
}
|
|
26
|
+
export interface ChartGeometry {
|
|
27
|
+
min: number
|
|
28
|
+
max: number
|
|
29
|
+
zero: number
|
|
30
|
+
ticks: readonly number[]
|
|
31
|
+
series: readonly { key: ChoiceValue; points: readonly (ChartPoint | null)[] }[]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Hit testing uses normalized plot coordinates, independent of DOM/native geometry. */
|
|
35
|
+
export function chartHitTest(geometry: ChartGeometry, type: 'line' | 'bar', x: number, y: number) {
|
|
36
|
+
const count = geometry.series[0]?.points.length ?? 0
|
|
37
|
+
if (!count || !Number.isFinite(x) || !Number.isFinite(y)) return null
|
|
38
|
+
const category = Math.max(0, Math.min(count - 1, Math.floor(x * count)))
|
|
39
|
+
if (type === 'bar') {
|
|
40
|
+
const within = x * count - category
|
|
41
|
+
const series = Math.max(
|
|
42
|
+
0,
|
|
43
|
+
Math.min(
|
|
44
|
+
geometry.series.length - 1,
|
|
45
|
+
Math.floor(((within - 0.15) / 0.7) * geometry.series.length),
|
|
46
|
+
),
|
|
47
|
+
)
|
|
48
|
+
return geometry.series[series]?.points[category] ? { category, series } : null
|
|
49
|
+
}
|
|
50
|
+
let nearest = -1,
|
|
51
|
+
distance = Infinity
|
|
52
|
+
geometry.series.forEach((series, index) => {
|
|
53
|
+
const point = series.points[category]
|
|
54
|
+
if (point && Math.abs(point.y - y) < distance) {
|
|
55
|
+
nearest = index
|
|
56
|
+
distance = Math.abs(point.y - y)
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
return nearest < 0 ? null : { category, series: nearest }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Category positions and values normalized to [0,1], identical in both renderers. */
|
|
63
|
+
export function chartGeometry(
|
|
64
|
+
categories: readonly ChartCategory[],
|
|
65
|
+
series: readonly ChartSeries[],
|
|
66
|
+
domain?: readonly [number, number],
|
|
67
|
+
): ChartGeometry {
|
|
68
|
+
collectionKeys(categories, 'key')
|
|
69
|
+
collectionKeys(series, 'key')
|
|
70
|
+
// This first renderer targets small product charts, not unbounded telemetry streams.
|
|
71
|
+
if (categories.length > 100 || series.length > 8)
|
|
72
|
+
throw new RangeError('Chart supports up to 100 categories and 8 series.')
|
|
73
|
+
for (const category of categories)
|
|
74
|
+
if (!category.label.trim()) throw new TypeError('Chart categories require labels.')
|
|
75
|
+
const values: number[] = []
|
|
76
|
+
for (const item of series) {
|
|
77
|
+
if (!item.label.trim() || item.values.length !== categories.length)
|
|
78
|
+
throw new TypeError('Chart series require labels and one value per category.')
|
|
79
|
+
if (item.color && !/^#[\da-f]{6}$/i.test(item.color))
|
|
80
|
+
throw new TypeError('Chart colors must be six digit hex values.')
|
|
81
|
+
for (const value of item.values) {
|
|
82
|
+
if (value !== null && !Number.isFinite(value))
|
|
83
|
+
throw new RangeError('Chart values must be finite numbers or null.')
|
|
84
|
+
if (value !== null) values.push(value)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
let min = Math.min(0, ...values),
|
|
88
|
+
max = Math.max(0, ...values)
|
|
89
|
+
if (domain) {
|
|
90
|
+
if (domain.length !== 2 || !domain.every(Number.isFinite) || domain[0] >= domain[1])
|
|
91
|
+
throw new RangeError('Chart domain requires two increasing finite values.')
|
|
92
|
+
;[min, max] = domain
|
|
93
|
+
if (values.some((value) => value < min || value > max))
|
|
94
|
+
throw new RangeError('Chart domain must contain every value.')
|
|
95
|
+
} else if (min === max) max = min + 1
|
|
96
|
+
const span = max - min
|
|
97
|
+
if (!Number.isFinite(span)) throw new RangeError('Chart domain span must be finite.')
|
|
98
|
+
const y = (value: number) => 1 - (value - min) / span
|
|
99
|
+
return {
|
|
100
|
+
min,
|
|
101
|
+
max,
|
|
102
|
+
zero: y(Math.max(min, Math.min(max, 0))),
|
|
103
|
+
ticks: Array.from({ length: 5 }, (_, i) => min + span * (i / 4)),
|
|
104
|
+
series: series.map((item) => ({
|
|
105
|
+
key: item.key,
|
|
106
|
+
points: item.values.map((value, index) =>
|
|
107
|
+
value === null
|
|
108
|
+
? null
|
|
109
|
+
: {
|
|
110
|
+
key: categories[index]!.key,
|
|
111
|
+
value,
|
|
112
|
+
index,
|
|
113
|
+
x: (index + 0.5) / Math.max(1, categories.length),
|
|
114
|
+
y: y(value),
|
|
115
|
+
},
|
|
116
|
+
),
|
|
117
|
+
})),
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Presentation-only interpolation. Canonical values and hit testing always use the model. */
|
|
122
|
+
export function interpolateChart(
|
|
123
|
+
from: ChartGeometry | undefined,
|
|
124
|
+
to: ChartGeometry,
|
|
125
|
+
progress: number,
|
|
126
|
+
): ChartGeometry {
|
|
127
|
+
const mix = (a: number, b: number) => a + (b - a) * Math.max(0, Math.min(1, progress))
|
|
128
|
+
const previousSeries = new Map(from?.series.map((series) => [series.key, series]))
|
|
129
|
+
return {
|
|
130
|
+
...to,
|
|
131
|
+
zero: mix(from?.zero ?? to.zero, to.zero),
|
|
132
|
+
series: to.series.map((series) => {
|
|
133
|
+
const old = previousSeries.get(series.key)
|
|
134
|
+
const previousPoints = new Map(
|
|
135
|
+
old?.points.flatMap((point) => (point ? [[point.key ?? point.index, point] as const] : [])),
|
|
136
|
+
)
|
|
137
|
+
return {
|
|
138
|
+
...series,
|
|
139
|
+
points: series.points.map((point) => {
|
|
140
|
+
if (!point) return null
|
|
141
|
+
const previous = previousPoints.get(point.key ?? point.index)
|
|
142
|
+
return {
|
|
143
|
+
...point,
|
|
144
|
+
x: mix(previous?.x ?? point.x, point.x),
|
|
145
|
+
y: mix(previous?.y ?? from?.zero ?? to.zero, point.y),
|
|
146
|
+
}
|
|
147
|
+
}),
|
|
148
|
+
}
|
|
149
|
+
}),
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { choiceKey, type ChoiceValue } from './choice.js'
|
|
2
|
+
import type { IconName } from './icon.js'
|
|
3
|
+
import { linkDestination, type LinkNavigate } from './link.js'
|
|
4
|
+
|
|
5
|
+
export interface MenuAction {
|
|
6
|
+
value: ChoiceValue
|
|
7
|
+
label: string
|
|
8
|
+
icon?: IconName
|
|
9
|
+
disabled?: boolean
|
|
10
|
+
destructive?: boolean
|
|
11
|
+
}
|
|
12
|
+
export type MenuItem =
|
|
13
|
+
MenuAction | { type: 'separator'; key: string } | { type: 'group'; key: string; label: string }
|
|
14
|
+
export interface NavigationItem {
|
|
15
|
+
value: ChoiceValue
|
|
16
|
+
label: string
|
|
17
|
+
href: string
|
|
18
|
+
icon?: IconName
|
|
19
|
+
badge?: string | number
|
|
20
|
+
disabled?: boolean
|
|
21
|
+
navigate?: LinkNavigate
|
|
22
|
+
}
|
|
23
|
+
export function validateMenu(items: readonly MenuItem[]) {
|
|
24
|
+
const keys = new Set<string>()
|
|
25
|
+
for (const item of items) {
|
|
26
|
+
const key = 'type' in item ? `decoration:${item.key}` : choiceKey(item.value)
|
|
27
|
+
if (keys.has(key)) throw new RangeError('Menu items require unique keys.')
|
|
28
|
+
keys.add(key)
|
|
29
|
+
if ((!('type' in item) || item.type === 'group') && !item.label.trim())
|
|
30
|
+
throw new TypeError('Menu actions and groups require labels.')
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function validateNavigation(items: readonly NavigationItem[]) {
|
|
34
|
+
validateMenu(items)
|
|
35
|
+
items.forEach((item) => linkDestination(item.href))
|
|
36
|
+
}
|
|
37
|
+
export type VirtualItemKey<T = unknown> = string | ((item: T) => ChoiceValue)
|
|
38
|
+
export interface VirtualItemSlot<T = unknown> {
|
|
39
|
+
item: T
|
|
40
|
+
index: number
|
|
41
|
+
itemKey: ChoiceValue
|
|
42
|
+
}
|
|
43
|
+
export interface VirtualListHandle {
|
|
44
|
+
scrollToIndex(index: number): void
|
|
45
|
+
}
|
|
46
|
+
export function virtualKeys<T>(items: readonly T[], itemKey: VirtualItemKey<T>): ChoiceValue[] {
|
|
47
|
+
const seen = new Set<string>()
|
|
48
|
+
return items.map((item) => {
|
|
49
|
+
const key =
|
|
50
|
+
typeof itemKey === 'function' ? itemKey(item) : (item as Record<string, unknown>)?.[itemKey]
|
|
51
|
+
if (
|
|
52
|
+
(typeof key !== 'string' && typeof key !== 'number') ||
|
|
53
|
+
(typeof key === 'number' && !Number.isFinite(key))
|
|
54
|
+
)
|
|
55
|
+
throw new TypeError('Virtual list items require finite number or string keys.')
|
|
56
|
+
const id = choiceKey(key)
|
|
57
|
+
if (seen.has(id)) throw new RangeError('Virtual list keys must be unique.')
|
|
58
|
+
seen.add(id)
|
|
59
|
+
return key
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
export function virtualWindow(
|
|
63
|
+
count: number,
|
|
64
|
+
rowHeight: number,
|
|
65
|
+
height: number,
|
|
66
|
+
offset: number,
|
|
67
|
+
overscan = 3,
|
|
68
|
+
) {
|
|
69
|
+
if (
|
|
70
|
+
!Number.isInteger(count) ||
|
|
71
|
+
count < 0 ||
|
|
72
|
+
!Number.isFinite(rowHeight) ||
|
|
73
|
+
rowHeight <= 0 ||
|
|
74
|
+
!Number.isFinite(height) ||
|
|
75
|
+
height <= 0 ||
|
|
76
|
+
!Number.isInteger(overscan) ||
|
|
77
|
+
overscan < 0 ||
|
|
78
|
+
!Number.isFinite(offset)
|
|
79
|
+
)
|
|
80
|
+
throw new RangeError(
|
|
81
|
+
'Virtual list requires positive finite dimensions and nonnegative integer overscan.',
|
|
82
|
+
)
|
|
83
|
+
const scrollTop = Math.max(0, Math.min(offset, Math.max(0, count * rowHeight - height)))
|
|
84
|
+
const start = Math.max(0, Math.floor(scrollTop / rowHeight) - overscan)
|
|
85
|
+
const end = Math.min(count, Math.ceil((scrollTop + height) / rowHeight) + overscan)
|
|
86
|
+
return { start, end, scrollTop, totalHeight: count * rowHeight }
|
|
87
|
+
}
|
package/src/contracts.ts
CHANGED
|
@@ -104,6 +104,7 @@ const layout = {
|
|
|
104
104
|
}
|
|
105
105
|
export const rowContract = {
|
|
106
106
|
...layout,
|
|
107
|
+
motionRegion: motionBoxContract.motionRegion,
|
|
107
108
|
align: property<Align>()({
|
|
108
109
|
kind: 'string',
|
|
109
110
|
values: ['start', 'center', 'end', 'stretch'],
|
|
@@ -112,6 +113,7 @@ export const rowContract = {
|
|
|
112
113
|
}
|
|
113
114
|
export const columnContract = {
|
|
114
115
|
...layout,
|
|
116
|
+
motionRegion: motionBoxContract.motionRegion,
|
|
115
117
|
align: property<Align>()({
|
|
116
118
|
kind: 'string',
|
|
117
119
|
values: ['start', 'center', 'end', 'stretch'],
|
package/src/discovery.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { choiceKey, type ChoiceValue } from './choice.js'
|
|
2
|
+
import { virtualKeys, type VirtualItemKey } from './collections.js'
|
|
3
|
+
import { sliderScale } from './slider.js'
|
|
4
|
+
|
|
5
|
+
export type RangeValue = readonly [number, number]
|
|
6
|
+
export function rangeValue(
|
|
7
|
+
value: RangeValue,
|
|
8
|
+
min: number,
|
|
9
|
+
max: number,
|
|
10
|
+
step: number,
|
|
11
|
+
): [number, number] {
|
|
12
|
+
const scale = sliderScale(min, max, step)
|
|
13
|
+
if (!Array.isArray(value) || value.length !== 2 || value[0]! > value[1]!)
|
|
14
|
+
throw new RangeError('RangeSlider requires an ordered pair.')
|
|
15
|
+
return [scale.fromNative(scale.toNative(value[0]!)), scale.fromNative(scale.toNative(value[1]!))]
|
|
16
|
+
}
|
|
17
|
+
export function moveRange(
|
|
18
|
+
value: RangeValue,
|
|
19
|
+
thumb: 0 | 1,
|
|
20
|
+
next: number,
|
|
21
|
+
min: number,
|
|
22
|
+
max: number,
|
|
23
|
+
step: number,
|
|
24
|
+
): [number, number] {
|
|
25
|
+
const pair = rangeValue(value, min, max, step)
|
|
26
|
+
const scale = sliderScale(min, max, step)
|
|
27
|
+
const snapped = scale.fromNative(scale.toNative(next))
|
|
28
|
+
pair[thumb] = thumb === 0 ? Math.min(snapped, pair[1]) : Math.max(snapped, pair[0])
|
|
29
|
+
return pair
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface DataColumn<T = Record<string, unknown>> {
|
|
33
|
+
key: string
|
|
34
|
+
label: string
|
|
35
|
+
/** Display text; sorting remains an application-owned operation. */
|
|
36
|
+
value?: (item: T) => string | number | null | undefined
|
|
37
|
+
sortable?: boolean
|
|
38
|
+
width?: number
|
|
39
|
+
align?: 'start' | 'end'
|
|
40
|
+
}
|
|
41
|
+
export interface DataSort {
|
|
42
|
+
key: string
|
|
43
|
+
direction: 'ascending' | 'descending'
|
|
44
|
+
}
|
|
45
|
+
export interface DataCellSlot<T = Record<string, unknown>> {
|
|
46
|
+
item: T
|
|
47
|
+
itemKey: ChoiceValue
|
|
48
|
+
column: DataColumn<T>
|
|
49
|
+
value: string | number | null | undefined
|
|
50
|
+
index: number
|
|
51
|
+
}
|
|
52
|
+
export function validateColumns(columns: readonly DataColumn[]) {
|
|
53
|
+
const seen = new Set<string>()
|
|
54
|
+
if (!columns.length) throw new RangeError('DataTable requires at least one column.')
|
|
55
|
+
for (const column of columns) {
|
|
56
|
+
if (!column.key || !column.label.trim() || seen.has(column.key))
|
|
57
|
+
throw new TypeError('DataTable columns require unique keys and nonempty labels.')
|
|
58
|
+
if (column.width !== undefined && (!Number.isFinite(column.width) || column.width < 44))
|
|
59
|
+
throw new RangeError('Column width must be at least 44.')
|
|
60
|
+
seen.add(column.key)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function nextDataSort(current: DataSort | null, key: string): DataSort | null {
|
|
64
|
+
return current?.key !== key
|
|
65
|
+
? { key, direction: 'ascending' }
|
|
66
|
+
: current.direction === 'ascending'
|
|
67
|
+
? { key, direction: 'descending' }
|
|
68
|
+
: null
|
|
69
|
+
}
|
|
70
|
+
/** Page selection preserves keys from other pages and does not mutate the input. */
|
|
71
|
+
export function selectPage(
|
|
72
|
+
selected: readonly ChoiceValue[],
|
|
73
|
+
page: readonly ChoiceValue[],
|
|
74
|
+
checked: boolean,
|
|
75
|
+
) {
|
|
76
|
+
const pageIds = new Set(page.map(choiceKey))
|
|
77
|
+
const result = selected.filter((key) => !pageIds.has(choiceKey(key)))
|
|
78
|
+
return checked ? [...result, ...page] : result
|
|
79
|
+
}
|
|
80
|
+
export function collectionKeys<T>(items: readonly T[], itemKey: VirtualItemKey<T>) {
|
|
81
|
+
return virtualKeys(items, itemKey)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface TreeNode {
|
|
85
|
+
key: ChoiceValue
|
|
86
|
+
label: string
|
|
87
|
+
disabled?: boolean
|
|
88
|
+
children?: readonly TreeNode[]
|
|
89
|
+
/** True with undefined children requests loading on expansion. An empty array is loaded. */
|
|
90
|
+
hasChildren?: boolean
|
|
91
|
+
}
|
|
92
|
+
export interface TreeEntry {
|
|
93
|
+
node: TreeNode
|
|
94
|
+
parent: ChoiceValue | null
|
|
95
|
+
level: number
|
|
96
|
+
position: number
|
|
97
|
+
siblings: number
|
|
98
|
+
}
|
|
99
|
+
export function treeEntries(
|
|
100
|
+
nodes: readonly TreeNode[],
|
|
101
|
+
expanded: readonly ChoiceValue[],
|
|
102
|
+
): TreeEntry[] {
|
|
103
|
+
const seen = new Set<string>()
|
|
104
|
+
const open = new Set(expanded.map(choiceKey))
|
|
105
|
+
const visible: TreeEntry[] = []
|
|
106
|
+
function visit(
|
|
107
|
+
children: readonly TreeNode[],
|
|
108
|
+
parent: ChoiceValue | null,
|
|
109
|
+
level: number,
|
|
110
|
+
show: boolean,
|
|
111
|
+
) {
|
|
112
|
+
if (level > 100) throw new RangeError('TreeView depth exceeds 100 levels.')
|
|
113
|
+
for (const [index, node] of children.entries()) {
|
|
114
|
+
if (
|
|
115
|
+
(typeof node.key !== 'string' && typeof node.key !== 'number') ||
|
|
116
|
+
(typeof node.key === 'number' && !Number.isFinite(node.key)) ||
|
|
117
|
+
!node.label.trim()
|
|
118
|
+
)
|
|
119
|
+
throw new TypeError('Tree nodes require a finite key and label.')
|
|
120
|
+
const id = choiceKey(node.key)
|
|
121
|
+
if (seen.has(id)) throw new RangeError('Tree keys must be unique; cycles are not allowed.')
|
|
122
|
+
seen.add(id)
|
|
123
|
+
if (show)
|
|
124
|
+
visible.push({ node, parent, level, position: index + 1, siblings: children.length })
|
|
125
|
+
if (node.children) visit(node.children, node.key, level + 1, show && open.has(id))
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
visit(nodes, null, 1, true)
|
|
129
|
+
return visible
|
|
130
|
+
}
|
|
131
|
+
export function treeBranch(node: TreeNode) {
|
|
132
|
+
return node.children === undefined ? !!node.hasChildren : node.children.length > 0
|
|
133
|
+
}
|
|
134
|
+
export function ratingValue(value: number, max: number, step: number) {
|
|
135
|
+
if (!Number.isInteger(max) || max < 1 || max > 10 || (step !== 1 && step !== 0.5))
|
|
136
|
+
throw new RangeError('Rating requires max 1–10 and step 1 or 0.5.')
|
|
137
|
+
if (!Number.isFinite(value)) throw new RangeError('Rating must be finite.')
|
|
138
|
+
return Math.max(0, Math.min(max, Math.round(value / step) * step))
|
|
139
|
+
}
|
|
@@ -99,6 +99,11 @@ export interface MotionSharedOptions {
|
|
|
99
99
|
transition?: Exclude<MotionOptions, { type: 'gravity' }>
|
|
100
100
|
layoutTimeout?: number
|
|
101
101
|
}
|
|
102
|
+
export interface MotionLayoutOptions {
|
|
103
|
+
transition?: Exclude<MotionOptions, { type: 'gravity' }>
|
|
104
|
+
size?: 'scale' | false
|
|
105
|
+
enter?: boolean
|
|
106
|
+
}
|
|
102
107
|
export interface MotionSharedLayout extends MotionBinding {
|
|
103
108
|
readonly active: boolean
|
|
104
109
|
/** Explicit identity; follows replacement of this declared surface. */
|
|
@@ -151,6 +156,8 @@ type Available = {
|
|
|
151
156
|
onAvailable(setup: () => void | (() => void)): () => void
|
|
152
157
|
}
|
|
153
158
|
export interface MotionRegion extends Available {
|
|
159
|
+
/** Animate keyed direct children after a synchronous data mutation. Not a virtual-list API. */
|
|
160
|
+
animateLayout(change: () => void, options?: MotionLayoutOptions): MotionPlayback
|
|
154
161
|
onKeyboard(callback: (state: MotionKeyboardState) => void): MotionKeyboard
|
|
155
162
|
/** Waits for initial native layout; the engine owns simulation and later geometry. */
|
|
156
163
|
physicsWorld(
|
|
@@ -171,6 +178,7 @@ export interface MotionRegion extends Available {
|
|
|
171
178
|
diagnostics(options: MotionDiagnosticsOptions): MotionDiagnostics
|
|
172
179
|
}
|
|
173
180
|
export interface MotionRegionAdapter {
|
|
181
|
+
animateLayout?(change: () => void, options: MotionLayoutOptions): MotionPlayback
|
|
174
182
|
onKeyboard?(callback: (state: MotionKeyboardState) => void): Omit<MotionKeyboard, 'disposed'>
|
|
175
183
|
physicsWorld?(
|
|
176
184
|
bodies: readonly MotionCircleBody<MotionSurfaceAdapter>[],
|
|
@@ -396,6 +404,27 @@ function group(
|
|
|
396
404
|
export function createMotionRegion(): MotionRegion {
|
|
397
405
|
const entry: { state?: RegionState; setups: Set<() => () => void> } = { setups: new Set() }
|
|
398
406
|
const region: MotionRegion = {
|
|
407
|
+
animateLayout(change, options = {}) {
|
|
408
|
+
const state = regionState(region)
|
|
409
|
+
if (typeof change !== 'function')
|
|
410
|
+
throw new TypeError('Layout motion needs a synchronous change callback.')
|
|
411
|
+
if (options.size !== undefined && options.size !== false && options.size !== 'scale')
|
|
412
|
+
throw new TypeError('Layout size must be scale or false.')
|
|
413
|
+
if (options.enter !== undefined && typeof options.enter !== 'boolean')
|
|
414
|
+
throw new TypeError('Layout enter must be a boolean.')
|
|
415
|
+
if (!state.adapter.animateLayout) throw new Error('Layout motion is unavailable.')
|
|
416
|
+
const raw = state.adapter.animateLayout(change, options)
|
|
417
|
+
const resource = { dispose: () => raw.stop() }
|
|
418
|
+
state.resources.add(resource)
|
|
419
|
+
const forget = () => state.resources.delete(resource)
|
|
420
|
+
void raw.finished.then(forget, forget)
|
|
421
|
+
return {
|
|
422
|
+
finished: raw.finished,
|
|
423
|
+
stop() {
|
|
424
|
+
if (state.valid && state.resources.has(resource)) raw.stop()
|
|
425
|
+
},
|
|
426
|
+
}
|
|
427
|
+
},
|
|
399
428
|
get available() {
|
|
400
429
|
return Boolean(entry.state?.valid)
|
|
401
430
|
},
|
package/src/experimental.ts
CHANGED
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
type MotionValueOptions,
|
|
6
6
|
type MotionDecayOptions,
|
|
7
7
|
} from './experimental-playback.js'
|
|
8
|
+
import { validateSectionScroll, type SectionScrollOptions } from './section-scroll.js'
|
|
9
|
+
export { sectionScrollRange } from './section-scroll.js'
|
|
10
|
+
export type { SectionScrollOptions, ScrollEdge } from './section-scroll.js'
|
|
8
11
|
export * from './experimental-playback.js'
|
|
9
12
|
export * from './experimental-effects.js'
|
|
10
13
|
export * from './experimental-collections.js'
|
|
@@ -103,6 +106,12 @@ export interface MotionSurface extends MotionVisualSurface {
|
|
|
103
106
|
frames: MotionScrollFrames,
|
|
104
107
|
options: MotionScrollOptions,
|
|
105
108
|
): MotionScrollLink
|
|
109
|
+
scrollSection(
|
|
110
|
+
source: MotionScrollSource,
|
|
111
|
+
section: MotionRegion,
|
|
112
|
+
frames: MotionScrollFrames,
|
|
113
|
+
options?: SectionScrollOptions,
|
|
114
|
+
): MotionScrollLink
|
|
106
115
|
}
|
|
107
116
|
export interface MotionBinding {
|
|
108
117
|
readonly disposed: boolean
|
|
@@ -189,6 +198,12 @@ export interface MotionSurfaceAdapter extends Partial<MotionVisualAdapter> {
|
|
|
189
198
|
frames: MotionScrollFrames,
|
|
190
199
|
options: MotionScrollOptions,
|
|
191
200
|
): Omit<MotionScrollLink, 'disposed'>
|
|
201
|
+
scrollSection?(
|
|
202
|
+
source: MotionScrollAdapter,
|
|
203
|
+
section: MotionRegionAdapter,
|
|
204
|
+
frames: MotionScrollFrames,
|
|
205
|
+
options: SectionScrollOptions,
|
|
206
|
+
): Omit<MotionScrollLink, 'disposed'>
|
|
192
207
|
mapColor?(
|
|
193
208
|
source: Pick<MotionReadable, 'get' | 'dispose'>,
|
|
194
209
|
input: readonly number[],
|
|
@@ -963,6 +978,31 @@ export function createMotionSurface(): MotionSurface {
|
|
|
963
978
|
for (const [, state] of entries) depend(state, handle)
|
|
964
979
|
return handle
|
|
965
980
|
},
|
|
981
|
+
scrollSection(source, section, frames, options = {}) {
|
|
982
|
+
const binding = current()
|
|
983
|
+
const scroll = scrollSources.get(source)
|
|
984
|
+
if (!scroll) throw new Error('Scroll source is unavailable.')
|
|
985
|
+
const region = regionState(section)
|
|
986
|
+
validateScroll(frames, { range: [0, 1] })
|
|
987
|
+
validateSectionScroll(options)
|
|
988
|
+
if (!binding.adapter.scrollSection) throw new Error('Section scroll motion is unavailable.')
|
|
989
|
+
const raw = binding.adapter.scrollSection(scroll.adapter, region.adapter, frames, options)
|
|
990
|
+
const resource = { dispose: () => link.dispose() }
|
|
991
|
+
const link = own(binding, {
|
|
992
|
+
get execution() {
|
|
993
|
+
return raw.execution
|
|
994
|
+
},
|
|
995
|
+
refresh: () => raw.refresh(),
|
|
996
|
+
dispose() {
|
|
997
|
+
scroll.links.delete(link)
|
|
998
|
+
region.resources.delete(resource)
|
|
999
|
+
raw.dispose()
|
|
1000
|
+
},
|
|
1001
|
+
})
|
|
1002
|
+
scroll.links.add(link)
|
|
1003
|
+
region.resources.add(resource)
|
|
1004
|
+
return link
|
|
1005
|
+
},
|
|
966
1006
|
scrollLinked(source, frames, options) {
|
|
967
1007
|
const binding = current()
|
|
968
1008
|
const state = scrollSources.get(source)
|