@getcortexlabs/mavis-core 0.1.0-rc.11.1 → 0.1.0-rc.12
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 +23 -4
- package/dist/capabilities.js.map +1 -1
- package/dist/creative-controls.d.ts +47 -0
- package/dist/creative-controls.d.ts.map +1 -0
- package/dist/creative-controls.js +112 -0
- package/dist/creative-controls.js.map +1 -0
- package/dist/dashboard.d.ts +72 -0
- package/dist/dashboard.d.ts.map +1 -0
- package/dist/dashboard.js +115 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/screen-components.d.ts +45 -0
- package/dist/screen-components.d.ts.map +1 -0
- package/dist/screen-components.js +23 -0
- package/dist/screen-components.js.map +1 -0
- package/dist/vue/animated-text.d.ts +101 -0
- package/dist/vue/animated-text.d.ts.map +1 -0
- package/dist/vue/animated-text.js +56 -0
- package/dist/vue/animated-text.js.map +1 -0
- package/dist/vue/component-props.d.ts +692 -3
- package/dist/vue/component-props.d.ts.map +1 -1
- package/dist/vue/component-props.js +22 -0
- package/dist/vue/component-props.js.map +1 -1
- package/dist/vue/composer.d.ts +159 -0
- package/dist/vue/composer.d.ts.map +1 -0
- package/dist/vue/composer.js +142 -0
- package/dist/vue/composer.js.map +1 -0
- package/dist/vue/configurator.d.ts +1 -1
- package/dist/vue/creative-controls.d.ts +328 -0
- package/dist/vue/creative-controls.d.ts.map +1 -0
- package/dist/vue/creative-controls.js +396 -0
- package/dist/vue/creative-controls.js.map +1 -0
- package/dist/vue/creative-props.d.ts +260 -0
- package/dist/vue/creative-props.d.ts.map +1 -0
- package/dist/vue/creative-props.js +92 -0
- package/dist/vue/creative-props.js.map +1 -0
- package/dist/vue/dashboard-charts.d.ts +240 -0
- package/dist/vue/dashboard-charts.d.ts.map +1 -0
- package/dist/vue/dashboard-charts.js +263 -0
- package/dist/vue/dashboard-charts.js.map +1 -0
- package/dist/vue/dashboard-effects.d.ts +211 -0
- package/dist/vue/dashboard-effects.d.ts.map +1 -0
- package/dist/vue/dashboard-effects.js +235 -0
- package/dist/vue/dashboard-effects.js.map +1 -0
- package/dist/vue/dashboard-props.d.ts +244 -0
- package/dist/vue/dashboard-props.d.ts.map +1 -0
- package/dist/vue/dashboard-props.js +94 -0
- package/dist/vue/dashboard-props.js.map +1 -0
- package/dist/vue/discovery-controls.d.ts +1 -1
- package/dist/vue/global-components.d.ts +106 -0
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/index.d.ts +16 -0
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +16 -0
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/kanban.d.ts +150 -0
- package/dist/vue/kanban.d.ts.map +1 -0
- package/dist/vue/kanban.js +267 -0
- package/dist/vue/kanban.js.map +1 -0
- package/dist/vue/marquee.d.ts +96 -0
- package/dist/vue/marquee.d.ts.map +1 -0
- package/dist/vue/marquee.js +186 -0
- package/dist/vue/marquee.js.map +1 -0
- package/dist/vue/pin-cell.d.ts +14 -0
- package/dist/vue/pin-cell.d.ts.map +1 -0
- package/dist/vue/pin-cell.js +19 -0
- package/dist/vue/pin-cell.js.map +1 -0
- package/dist/vue/pin-input.d.ts +14 -0
- package/dist/vue/pin-input.d.ts.map +1 -0
- package/dist/vue/pin-input.js +23 -0
- package/dist/vue/pin-input.js.map +1 -0
- package/dist/vue/props.d.ts +6 -6
- package/dist/vue/screen-component-props.d.ts +236 -0
- package/dist/vue/screen-component-props.d.ts.map +1 -0
- package/dist/vue/screen-component-props.js +90 -0
- package/dist/vue/screen-component-props.js.map +1 -0
- package/dist/vue/scroll-frame.d.ts +223 -0
- package/dist/vue/scroll-frame.d.ts.map +1 -0
- package/dist/vue/scroll-frame.js +346 -0
- package/dist/vue/scroll-frame.js.map +1 -0
- package/dist/vue/speed-dial.d.ts +73 -0
- package/dist/vue/speed-dial.d.ts.map +1 -0
- package/dist/vue/speed-dial.js +78 -0
- package/dist/vue/speed-dial.js.map +1 -0
- package/dist/vue/swipe-deck.d.ts +120 -0
- package/dist/vue/swipe-deck.d.ts.map +1 -0
- package/dist/vue/swipe-deck.js +229 -0
- package/dist/vue/swipe-deck.js.map +1 -0
- package/dist/vue/time-picker.d.ts +2 -2
- package/dist/vue/tour.d.ts +120 -0
- package/dist/vue/tour.d.ts.map +1 -0
- package/dist/vue/tour.js +165 -0
- package/dist/vue/tour.js.map +1 -0
- package/dist/vue/tree-view.d.ts +1 -1
- package/package.json +1 -1
- package/src/capabilities.ts +24 -4
- package/src/creative-controls.ts +169 -0
- package/src/dashboard.ts +164 -0
- package/src/index.ts +5 -0
- package/src/screen-components.ts +59 -0
- package/src/vue/animated-text.ts +72 -0
- package/src/vue/component-props.ts +47 -0
- package/src/vue/composer.ts +192 -0
- package/src/vue/creative-controls.ts +524 -0
- package/src/vue/creative-props.ts +94 -0
- package/src/vue/dashboard-charts.ts +346 -0
- package/src/vue/dashboard-effects.ts +304 -0
- package/src/vue/dashboard-props.ts +95 -0
- package/src/vue/global-components.ts +116 -0
- package/src/vue/index.ts +20 -0
- package/src/vue/kanban.ts +360 -0
- package/src/vue/marquee.ts +248 -0
- package/src/vue/pin-cell.ts +26 -0
- package/src/vue/pin-input.ts +31 -0
- package/src/vue/screen-component-props.ts +92 -0
- package/src/vue/scroll-frame.ts +429 -0
- package/src/vue/speed-dial.ts +108 -0
- package/src/vue/swipe-deck.ts +277 -0
- package/src/vue/tour.ts +239 -0
package/dist/vue/tour.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { computed, defineComponent, h, inject, mergeProps, nextTick, onMounted, onScopeDispose, provide, reactive, ref, watch, } from '@vue/runtime-core';
|
|
2
|
+
import { validateTour } from '../creative-controls.js';
|
|
3
|
+
import { tourProps, tourTargetProps } from './creative-props.js';
|
|
4
|
+
import { useComponentState } from './component-motion.js';
|
|
5
|
+
import { useMavisTheme } from './theme.js';
|
|
6
|
+
const tourKey = Symbol('mavis-tour');
|
|
7
|
+
export const tourHostProps = { active: Boolean, restoreFocus: { type: Boolean, default: true } };
|
|
8
|
+
export function createTour(ui, platform) {
|
|
9
|
+
const MTour = defineComponent({
|
|
10
|
+
name: 'MTour',
|
|
11
|
+
inheritAttrs: false,
|
|
12
|
+
props: tourProps,
|
|
13
|
+
emits: {
|
|
14
|
+
'update:modelValue': (_id) => true,
|
|
15
|
+
finish: (_reason) => true,
|
|
16
|
+
missing: (_id) => true,
|
|
17
|
+
},
|
|
18
|
+
setup(props, { attrs, slots, emit }) {
|
|
19
|
+
const targets = reactive(new Set());
|
|
20
|
+
const index = computed(() => validateTour(props.steps).findIndex((step) => step.id === props.modelValue));
|
|
21
|
+
const step = computed(() => props.steps[index.value]);
|
|
22
|
+
let mounted = false, generation = 0;
|
|
23
|
+
const closeReason = ref('');
|
|
24
|
+
watch(() => props.modelValue, (value) => {
|
|
25
|
+
if (value !== null)
|
|
26
|
+
closeReason.value = '';
|
|
27
|
+
});
|
|
28
|
+
function close(reason) {
|
|
29
|
+
if (props.modelValue === null)
|
|
30
|
+
return;
|
|
31
|
+
closeReason.value = reason;
|
|
32
|
+
emit('update:modelValue', null);
|
|
33
|
+
emit('finish', reason);
|
|
34
|
+
}
|
|
35
|
+
function move(direction) {
|
|
36
|
+
for (let i = index.value + direction; i >= 0 && i < props.steps.length; i += direction) {
|
|
37
|
+
const next = props.steps[i];
|
|
38
|
+
if (targets.has(next.id)) {
|
|
39
|
+
emit('update:modelValue', next.id);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
emit('missing', next.id);
|
|
43
|
+
}
|
|
44
|
+
close(direction > 0 ? 'complete' : 'missing');
|
|
45
|
+
}
|
|
46
|
+
async function check() {
|
|
47
|
+
const token = ++generation;
|
|
48
|
+
await nextTick();
|
|
49
|
+
if (!mounted || token !== generation || props.modelValue === null)
|
|
50
|
+
return;
|
|
51
|
+
if (!step.value || !targets.has(step.value.id)) {
|
|
52
|
+
emit('missing', props.modelValue);
|
|
53
|
+
move(1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
provide(tourKey, {
|
|
57
|
+
current: () => step.value,
|
|
58
|
+
animated: () => props.animated,
|
|
59
|
+
register(id) {
|
|
60
|
+
if (!id.trim() || targets.has(id))
|
|
61
|
+
throw new TypeError('Tour target names must be nonempty and unique within a tour.');
|
|
62
|
+
targets.add(id);
|
|
63
|
+
return () => targets.delete(id);
|
|
64
|
+
},
|
|
65
|
+
close,
|
|
66
|
+
panel: () => h(ui.Column, { gap: 'md' }, {
|
|
67
|
+
default: () => [
|
|
68
|
+
h(ui.Text, {
|
|
69
|
+
text: `${props.label} · ${index.value + 1} / ${props.steps.length}`,
|
|
70
|
+
variant: 'caption',
|
|
71
|
+
tone: 'muted',
|
|
72
|
+
}),
|
|
73
|
+
h(ui.Text, { text: step.value?.title, variant: 'heading' }),
|
|
74
|
+
h(ui.Text, { text: step.value?.description }),
|
|
75
|
+
h(ui.Row, { gap: 'xs', wrap: true }, {
|
|
76
|
+
default: () => [
|
|
77
|
+
h(ui.Button, {
|
|
78
|
+
text: props.backLabel,
|
|
79
|
+
variant: 'secondary',
|
|
80
|
+
disabled: index.value <= 0,
|
|
81
|
+
onClick: () => move(-1),
|
|
82
|
+
}),
|
|
83
|
+
h(ui.Button, {
|
|
84
|
+
text: index.value === props.steps.length - 1
|
|
85
|
+
? props.finishLabel
|
|
86
|
+
: props.nextLabel,
|
|
87
|
+
onClick: () => move(1),
|
|
88
|
+
}),
|
|
89
|
+
h(ui.Button, {
|
|
90
|
+
text: props.skipLabel,
|
|
91
|
+
variant: 'ghost',
|
|
92
|
+
onClick: () => close('skip'),
|
|
93
|
+
}),
|
|
94
|
+
],
|
|
95
|
+
}),
|
|
96
|
+
],
|
|
97
|
+
}),
|
|
98
|
+
});
|
|
99
|
+
watch(() => [props.modelValue, props.steps, [...targets]], check, {
|
|
100
|
+
flush: 'post',
|
|
101
|
+
deep: true,
|
|
102
|
+
});
|
|
103
|
+
onMounted(() => {
|
|
104
|
+
mounted = true;
|
|
105
|
+
void check();
|
|
106
|
+
});
|
|
107
|
+
onScopeDispose(() => {
|
|
108
|
+
mounted = false;
|
|
109
|
+
generation++;
|
|
110
|
+
});
|
|
111
|
+
return () => h(ui.Host, mergeProps(attrs, {
|
|
112
|
+
id: props.id,
|
|
113
|
+
active: props.modelValue !== null,
|
|
114
|
+
restoreFocus: closeReason.value !== 'outside',
|
|
115
|
+
...(platform === 'web' ? { class: 'm-tour' } : {}),
|
|
116
|
+
}), slots);
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
const MTourTarget = defineComponent({
|
|
120
|
+
name: 'MTourTarget',
|
|
121
|
+
inheritAttrs: false,
|
|
122
|
+
props: tourTargetProps,
|
|
123
|
+
setup(props, { attrs, slots }) {
|
|
124
|
+
const context = inject(tourKey);
|
|
125
|
+
if (!context)
|
|
126
|
+
throw new Error('MTourTarget must be inside MTour.');
|
|
127
|
+
const { theme } = useMavisTheme();
|
|
128
|
+
const active = computed(() => context.current()?.id === props.name);
|
|
129
|
+
const surface = useComponentState(() => ({ opacity: active.value ? 1 : 0.55 }), 'selection');
|
|
130
|
+
let release = () => { };
|
|
131
|
+
watch(() => props.name, (name) => {
|
|
132
|
+
release();
|
|
133
|
+
release = context.register(name);
|
|
134
|
+
}, { immediate: true });
|
|
135
|
+
onScopeDispose(() => release());
|
|
136
|
+
return () => h(ui.TargetHost, mergeProps(attrs, {
|
|
137
|
+
active: active.value,
|
|
138
|
+
...(platform === 'web'
|
|
139
|
+
? { class: 'm-tour-target', 'data-tour-target': props.name }
|
|
140
|
+
: {}),
|
|
141
|
+
}), {
|
|
142
|
+
default: () => h(ui.Popover, {
|
|
143
|
+
open: active.value,
|
|
144
|
+
label: context.current()?.title ?? props.name,
|
|
145
|
+
triggerLabel: props.name,
|
|
146
|
+
width: 320,
|
|
147
|
+
onClose: (reason) => {
|
|
148
|
+
if (active.value)
|
|
149
|
+
context.close(reason);
|
|
150
|
+
},
|
|
151
|
+
}, {
|
|
152
|
+
anchor: () => h(ui.Box, {
|
|
153
|
+
padding: 'xs',
|
|
154
|
+
radius: 'md',
|
|
155
|
+
borderWidth: 2,
|
|
156
|
+
borderColor: active.value ? theme.value.colors.primary : 'transparent',
|
|
157
|
+
}, { default: () => slots.default?.({ active: active.value }) }),
|
|
158
|
+
default: () => h(ui.Column, { motionSurface: context.animated() ? surface : undefined, gap: 'sm' }, { default: () => context.panel() }),
|
|
159
|
+
}),
|
|
160
|
+
});
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
return { MTour, MTourTarget };
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=tour.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tour.js","sourceRoot":"","sources":["../../src/vue/tour.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,CAAC,EACD,MAAM,EACN,UAAU,EACV,QAAQ,EACR,SAAS,EACT,cAAc,EACd,OAAO,EACP,QAAQ,EACR,GAAG,EACH,KAAK,GAGN,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,YAAY,EAAiB,MAAM,yBAAyB,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAS1C,MAAM,OAAO,GAA8B,MAAM,CAAC,YAAY,CAAC,CAAA;AAC/D,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAA;AAChG,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AAC,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,EACtE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CACnC;iBACJ,CACF;aACJ,CACF,CAAA;QACL,CAAC;KACF,CAAC,CAAA;IACF,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,CAAA;AAC/B,CAAC"}
|
package/dist/vue/tree-view.d.ts
CHANGED
|
@@ -95,8 +95,8 @@ export declare function createTreeView(ui: {
|
|
|
95
95
|
default: string;
|
|
96
96
|
};
|
|
97
97
|
}>> & Readonly<{
|
|
98
|
-
"onUpdate:modelValue"?: ((_key: ChoiceValue) => any) | undefined;
|
|
99
98
|
onLoad?: ((_node: TreeNode) => any) | undefined;
|
|
99
|
+
"onUpdate:modelValue"?: ((_key: ChoiceValue) => any) | undefined;
|
|
100
100
|
"onUpdate:expanded"?: ((_keys: ChoiceValue[]) => any) | undefined;
|
|
101
101
|
}>, {
|
|
102
102
|
expandedLabel: string;
|
package/package.json
CHANGED
package/src/capabilities.ts
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
/** Source capabilities, not a promise that every feature is in the last npm release. */
|
|
2
2
|
export const componentNames = [
|
|
3
|
+
'MKanban',
|
|
4
|
+
'MDonutChart',
|
|
5
|
+
'MSparkline',
|
|
6
|
+
'MGradientBackground',
|
|
7
|
+
'MParticleField',
|
|
8
|
+
'MConfetti',
|
|
9
|
+
'MColorPicker',
|
|
10
|
+
'MSwipeDeck',
|
|
11
|
+
'MGauge',
|
|
12
|
+
'MTour',
|
|
13
|
+
'MTourTarget',
|
|
14
|
+
'MTransferList',
|
|
15
|
+
'MMarquee',
|
|
16
|
+
'MCollapsibleHeader',
|
|
17
|
+
'MRefreshControl',
|
|
18
|
+
'MComposer',
|
|
19
|
+
'MSpeedDial',
|
|
20
|
+
'MPinInput',
|
|
21
|
+
'MAnimatedText',
|
|
22
|
+
|
|
3
23
|
'MSortableList',
|
|
4
24
|
'MSwipeActions',
|
|
5
25
|
'MNumberFlow',
|
|
@@ -79,11 +99,11 @@ export type CapabilityStatus = 'experimental' | 'planned' | 'unsupported' | 'unv
|
|
|
79
99
|
export const targetCapabilities = {
|
|
80
100
|
version: 1,
|
|
81
101
|
source: 'repository',
|
|
82
|
-
publishedBaseline: '0.1.0-rc.
|
|
102
|
+
publishedBaseline: '0.1.0-rc.12',
|
|
83
103
|
developmentMotion: {
|
|
84
104
|
availability: 'published',
|
|
85
105
|
joltCommit: null,
|
|
86
|
-
publishedJoltRelease: '0.1.0-rc.11',
|
|
106
|
+
publishedJoltRelease: '0.1.0-rc.11.1',
|
|
87
107
|
features: {
|
|
88
108
|
gradient: ['web', 'ios', 'android'],
|
|
89
109
|
loadingEffects: ['web', 'ios'],
|
|
@@ -109,7 +129,7 @@ export const targetCapabilities = {
|
|
|
109
129
|
streaming: 'unverified',
|
|
110
130
|
rsc: 'unsupported',
|
|
111
131
|
},
|
|
112
|
-
motion: { engine: 'jolt', minimum: '0.1.0-rc.11', start: 'client-mount' },
|
|
132
|
+
motion: { engine: 'jolt', minimum: '0.1.0-rc.11.1', start: 'client-mount' },
|
|
113
133
|
ssr: {
|
|
114
134
|
availability: '0.1.0-alpha.5',
|
|
115
135
|
host: 'nuxt',
|
|
@@ -152,7 +172,7 @@ export const targetCapabilities = {
|
|
|
152
172
|
streaming: 'unsupported',
|
|
153
173
|
rsc: 'unsupported',
|
|
154
174
|
},
|
|
155
|
-
motion: { engine: 'jolt', minimum: '0.1.0-rc.11', start: 'native-loaded' },
|
|
175
|
+
motion: { engine: 'jolt', minimum: '0.1.0-rc.11.1', start: 'native-loaded' },
|
|
156
176
|
},
|
|
157
177
|
],
|
|
158
178
|
planned: [
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { validateChoices, type ChoiceOption, type ChoiceValue } from './choice.js'
|
|
2
|
+
|
|
3
|
+
export interface RgbaColor {
|
|
4
|
+
r: number
|
|
5
|
+
g: number
|
|
6
|
+
b: number
|
|
7
|
+
a: number
|
|
8
|
+
}
|
|
9
|
+
export interface HsvColor {
|
|
10
|
+
h: number
|
|
11
|
+
s: number
|
|
12
|
+
v: number
|
|
13
|
+
a: number
|
|
14
|
+
}
|
|
15
|
+
export function bounded(value: number, min: number, max: number) {
|
|
16
|
+
if (![value, min, max].every(Number.isFinite) || max <= min)
|
|
17
|
+
throw new RangeError('Values must be finite and max must exceed min.')
|
|
18
|
+
return Math.min(max, Math.max(min, value))
|
|
19
|
+
}
|
|
20
|
+
/** Deliberately accepts only HEX and numeric RGB(A), never arbitrary CSS. */
|
|
21
|
+
export function parseColor(input: string): RgbaColor | null {
|
|
22
|
+
const hex = /^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i.exec(input.trim())
|
|
23
|
+
if (hex) {
|
|
24
|
+
let value = hex[1]!
|
|
25
|
+
if (value.length <= 4) value = [...value].map((c) => c + c).join('')
|
|
26
|
+
return {
|
|
27
|
+
r: parseInt(value.slice(0, 2), 16),
|
|
28
|
+
g: parseInt(value.slice(2, 4), 16),
|
|
29
|
+
b: parseInt(value.slice(4, 6), 16),
|
|
30
|
+
a: value.length === 8 ? parseInt(value.slice(6), 16) / 255 : 1,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const rgb =
|
|
34
|
+
/^rgba?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)(?:\s*,\s*(\d*\.?\d+))?\s*\)$/i.exec(
|
|
35
|
+
input.trim(),
|
|
36
|
+
)
|
|
37
|
+
if (!rgb) return null
|
|
38
|
+
const [r, g, b, a] = [
|
|
39
|
+
Number(rgb[1]),
|
|
40
|
+
Number(rgb[2]),
|
|
41
|
+
Number(rgb[3]),
|
|
42
|
+
rgb[4] === undefined ? 1 : Number(rgb[4]),
|
|
43
|
+
]
|
|
44
|
+
if ([r!, g!, b!].some((v) => v > 255) || a! > 1) return null
|
|
45
|
+
return { r: Math.round(r!), g: Math.round(g!), b: Math.round(b!), a: a! }
|
|
46
|
+
}
|
|
47
|
+
export function colorHex(color: RgbaColor, alpha = false) {
|
|
48
|
+
return (
|
|
49
|
+
'#' +
|
|
50
|
+
[color.r, color.g, color.b, ...(alpha ? [color.a * 255] : [])]
|
|
51
|
+
.map((v) =>
|
|
52
|
+
Math.round(bounded(v, 0, 255))
|
|
53
|
+
.toString(16)
|
|
54
|
+
.padStart(2, '0'),
|
|
55
|
+
)
|
|
56
|
+
.join('')
|
|
57
|
+
.toUpperCase()
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
export function colorHsv(color: RgbaColor): HsvColor {
|
|
61
|
+
const [r, g, b] = [color.r / 255, color.g / 255, color.b / 255]
|
|
62
|
+
const max = Math.max(r!, g!, b!),
|
|
63
|
+
min = Math.min(r!, g!, b!),
|
|
64
|
+
delta = max - min
|
|
65
|
+
const h = !delta
|
|
66
|
+
? 0
|
|
67
|
+
: max === r
|
|
68
|
+
? ((g! - b!) / delta) % 6
|
|
69
|
+
: max === g
|
|
70
|
+
? (b! - r!) / delta + 2
|
|
71
|
+
: (r! - g!) / delta + 4
|
|
72
|
+
return { h: (h * 60 + 360) % 360, s: max ? (delta / max) * 100 : 0, v: max * 100, a: color.a }
|
|
73
|
+
}
|
|
74
|
+
export function hsvColor(color: HsvColor): RgbaColor {
|
|
75
|
+
const h = bounded(color.h, 0, 360) / 60,
|
|
76
|
+
s = bounded(color.s, 0, 100) / 100,
|
|
77
|
+
v = bounded(color.v, 0, 100) / 100
|
|
78
|
+
const c = v * s,
|
|
79
|
+
x = c * (1 - Math.abs((h % 2) - 1)),
|
|
80
|
+
m = v - c
|
|
81
|
+
const [r, g, b] =
|
|
82
|
+
h < 1
|
|
83
|
+
? [c, x, 0]
|
|
84
|
+
: h < 2
|
|
85
|
+
? [x, c, 0]
|
|
86
|
+
: h < 3
|
|
87
|
+
? [0, c, x]
|
|
88
|
+
: h < 4
|
|
89
|
+
? [0, x, c]
|
|
90
|
+
: h < 5
|
|
91
|
+
? [x, 0, c]
|
|
92
|
+
: [c, 0, x]
|
|
93
|
+
return {
|
|
94
|
+
r: Math.round((r! + m) * 255),
|
|
95
|
+
g: Math.round((g! + m) * 255),
|
|
96
|
+
b: Math.round((b! + m) * 255),
|
|
97
|
+
a: bounded(color.a, 0, 1),
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export interface SwipeCard {
|
|
101
|
+
id: ChoiceValue
|
|
102
|
+
title: string
|
|
103
|
+
description?: string
|
|
104
|
+
image?: string
|
|
105
|
+
}
|
|
106
|
+
export type SwipeDecision = 'accept' | 'reject'
|
|
107
|
+
export function deckDecision(
|
|
108
|
+
distance: number,
|
|
109
|
+
velocity: number,
|
|
110
|
+
threshold: number,
|
|
111
|
+
): SwipeDecision | null {
|
|
112
|
+
if (![distance, velocity, threshold].every(Number.isFinite) || threshold <= 0)
|
|
113
|
+
throw new RangeError('Invalid swipe geometry.')
|
|
114
|
+
return Math.abs(distance) >= threshold || (Math.abs(distance) > 12 && Math.abs(velocity) > 600)
|
|
115
|
+
? distance + velocity * 0.08 >= 0
|
|
116
|
+
? 'accept'
|
|
117
|
+
: 'reject'
|
|
118
|
+
: null
|
|
119
|
+
}
|
|
120
|
+
export function validateCards(items: readonly SwipeCard[]) {
|
|
121
|
+
validateChoices(
|
|
122
|
+
items.map((item) => ({ value: item.id, label: item.title })),
|
|
123
|
+
null,
|
|
124
|
+
)
|
|
125
|
+
return items
|
|
126
|
+
}
|
|
127
|
+
export interface TourStep {
|
|
128
|
+
id: string
|
|
129
|
+
title: string
|
|
130
|
+
description: string
|
|
131
|
+
}
|
|
132
|
+
export function validateTour(steps: readonly TourStep[]) {
|
|
133
|
+
validateChoices(
|
|
134
|
+
steps.map((step) => ({ value: step.id, label: step.title })),
|
|
135
|
+
null,
|
|
136
|
+
)
|
|
137
|
+
if (steps.some((step) => !step.id.trim()))
|
|
138
|
+
throw new TypeError('Tour targets require nonempty ids.')
|
|
139
|
+
return steps
|
|
140
|
+
}
|
|
141
|
+
export interface MarqueeItem {
|
|
142
|
+
id: ChoiceValue
|
|
143
|
+
label: string
|
|
144
|
+
image?: string
|
|
145
|
+
}
|
|
146
|
+
export function transferValues(
|
|
147
|
+
options: readonly ChoiceOption[],
|
|
148
|
+
selected: readonly ChoiceValue[],
|
|
149
|
+
checked: readonly ChoiceValue[],
|
|
150
|
+
direction: 'add' | 'remove',
|
|
151
|
+
) {
|
|
152
|
+
validateChoices(options, null)
|
|
153
|
+
const enabled = new Set(
|
|
154
|
+
options.filter((option) => !option.disabled).map((option) => option.value),
|
|
155
|
+
)
|
|
156
|
+
const changes = new Set(checked.filter((value) => enabled.has(value)))
|
|
157
|
+
return direction === 'add'
|
|
158
|
+
? [...new Set([...selected, ...changes])]
|
|
159
|
+
: selected.filter((value) => !changes.has(value))
|
|
160
|
+
}
|
|
161
|
+
export function gaugeGeometry(value: number, min: number, max: number, semi: boolean) {
|
|
162
|
+
const clamped = bounded(value, min, max)
|
|
163
|
+
return {
|
|
164
|
+
value: clamped,
|
|
165
|
+
ratio: (clamped - min) / (max - min),
|
|
166
|
+
path: semi ? 'M 10 50 A 40 40 0 0 1 90 50' : 'M 50 10 A 40 40 0 1 1 49.999 10',
|
|
167
|
+
viewBox: [0, 0, 100, semi ? 58 : 100] as const,
|
|
168
|
+
}
|
|
169
|
+
}
|
package/src/dashboard.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { chartGeometry } from './chart.js'
|
|
2
|
+
|
|
3
|
+
export interface KanbanColumn {
|
|
4
|
+
id: string
|
|
5
|
+
title: string
|
|
6
|
+
limit?: number
|
|
7
|
+
}
|
|
8
|
+
export interface KanbanCard {
|
|
9
|
+
id: string
|
|
10
|
+
column: string
|
|
11
|
+
title: string
|
|
12
|
+
description?: string
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
}
|
|
15
|
+
export interface KanbanMove {
|
|
16
|
+
id: string
|
|
17
|
+
from: string
|
|
18
|
+
to: string
|
|
19
|
+
before: string | null
|
|
20
|
+
}
|
|
21
|
+
export interface DonutSegment {
|
|
22
|
+
id: string
|
|
23
|
+
label: string
|
|
24
|
+
value: number
|
|
25
|
+
color?: string
|
|
26
|
+
}
|
|
27
|
+
export interface SparklinePoint {
|
|
28
|
+
id: string
|
|
29
|
+
label: string
|
|
30
|
+
value: number | null
|
|
31
|
+
}
|
|
32
|
+
export interface DashboardRect {
|
|
33
|
+
x: number
|
|
34
|
+
y: number
|
|
35
|
+
width: number
|
|
36
|
+
height: number
|
|
37
|
+
}
|
|
38
|
+
export function dashboardNumber(value: number, min: number, max: number, name: string) {
|
|
39
|
+
if (!Number.isFinite(value) || value < min || value > max)
|
|
40
|
+
throw new RangeError(`${name} must be between ${min} and ${max}.`)
|
|
41
|
+
return value
|
|
42
|
+
}
|
|
43
|
+
function unique(items: readonly { id: string }[], name: string) {
|
|
44
|
+
const keys = new Set<string>()
|
|
45
|
+
for (const item of items) {
|
|
46
|
+
if (!item.id || keys.has(item.id)) throw new TypeError(`${name} requires unique, nonempty IDs.`)
|
|
47
|
+
keys.add(item.id)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function validateKanban(columns: readonly KanbanColumn[], cards: readonly KanbanCard[]) {
|
|
51
|
+
unique(columns, 'Kanban columns')
|
|
52
|
+
unique(cards, 'Kanban cards')
|
|
53
|
+
if (!columns.length || columns.length > 12 || cards.length > 500)
|
|
54
|
+
throw new RangeError('Kanban supports 1–12 columns and at most 500 cards.')
|
|
55
|
+
for (const column of columns) {
|
|
56
|
+
if (!column.title.trim()) throw new TypeError('Kanban columns need a title.')
|
|
57
|
+
if (column.limit !== undefined && (!Number.isInteger(column.limit) || column.limit < 1))
|
|
58
|
+
throw new RangeError('Column limits must be positive integers.')
|
|
59
|
+
}
|
|
60
|
+
for (const card of cards)
|
|
61
|
+
if (!card.title.trim() || !columns.some((c) => c.id === card.column))
|
|
62
|
+
throw new TypeError('Cards require a title and an existing column.')
|
|
63
|
+
}
|
|
64
|
+
/** Keeps hidden cards and consumer metadata intact; limits apply to all cards, not the filtered view. */
|
|
65
|
+
export function moveKanban<T extends KanbanCard>(
|
|
66
|
+
columns: readonly KanbanColumn[],
|
|
67
|
+
cards: readonly T[],
|
|
68
|
+
id: string,
|
|
69
|
+
to: string,
|
|
70
|
+
before: string | null = null,
|
|
71
|
+
): { cards: T[]; move: KanbanMove } | null {
|
|
72
|
+
validateKanban(columns, cards)
|
|
73
|
+
const card = cards.find((c) => c.id === id),
|
|
74
|
+
column = columns.find((c) => c.id === to)
|
|
75
|
+
if (!card || card.disabled || !column || before === id) return null
|
|
76
|
+
if (before !== null && !cards.some((c) => c.id === before && c.column === to)) return null
|
|
77
|
+
if (
|
|
78
|
+
card.column !== to &&
|
|
79
|
+
column.limit !== undefined &&
|
|
80
|
+
cards.filter((c) => c.column === to).length >= column.limit
|
|
81
|
+
)
|
|
82
|
+
return null
|
|
83
|
+
const next = cards.filter((c) => c.id !== id)
|
|
84
|
+
const index = before === null ? next.length : next.findIndex((c) => c.id === before)
|
|
85
|
+
next.splice(index, 0, { ...card, column: to })
|
|
86
|
+
const oldOrder = cards
|
|
87
|
+
.filter((c) => c.column === to)
|
|
88
|
+
.map((c) => c.id)
|
|
89
|
+
.join('\0')
|
|
90
|
+
const newOrder = next
|
|
91
|
+
.filter((c) => c.column === to)
|
|
92
|
+
.map((c) => c.id)
|
|
93
|
+
.join('\0')
|
|
94
|
+
if (card.column === to && oldOrder === newOrder) return null
|
|
95
|
+
return { cards: next, move: { id, from: card.column, to, before } }
|
|
96
|
+
}
|
|
97
|
+
export function donutGeometry(segments: readonly DonutSegment[]) {
|
|
98
|
+
unique(segments, 'Donut segments')
|
|
99
|
+
if (segments.length > 24) throw new RangeError('Donut supports at most 24 segments.')
|
|
100
|
+
let total = 0
|
|
101
|
+
for (const segment of segments) {
|
|
102
|
+
if (!segment.label.trim() || !Number.isFinite(segment.value) || segment.value < 0)
|
|
103
|
+
throw new TypeError('Donut segments require a label and finite nonnegative value.')
|
|
104
|
+
if (segment.color && !/^#[\da-f]{6}$/i.test(segment.color))
|
|
105
|
+
throw new TypeError('Segment colors must be six-digit HEX.')
|
|
106
|
+
total += segment.value
|
|
107
|
+
}
|
|
108
|
+
if (!Number.isFinite(total)) throw new RangeError('Donut total must be finite.')
|
|
109
|
+
let offset = 0
|
|
110
|
+
return {
|
|
111
|
+
total,
|
|
112
|
+
segments: segments.map((segment) => {
|
|
113
|
+
const ratio = total ? segment.value / total : 0,
|
|
114
|
+
start = offset
|
|
115
|
+
offset = Math.min(1, offset + ratio)
|
|
116
|
+
return { ...segment, ratio, start, end: offset }
|
|
117
|
+
}),
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
export const donutPath = 'M 50 10 A 40 40 0 1 1 50 90 A 40 40 0 1 1 50 10'
|
|
121
|
+
/** Uses the chart domain/null conventions. A zero-length line is extended for a single point. */
|
|
122
|
+
export function sparklineGeometry(
|
|
123
|
+
points: readonly SparklinePoint[],
|
|
124
|
+
domain?: readonly [number, number],
|
|
125
|
+
width = 100,
|
|
126
|
+
height = 40,
|
|
127
|
+
) {
|
|
128
|
+
unique(points, 'Sparkline points')
|
|
129
|
+
const geometry = chartGeometry(
|
|
130
|
+
points.map((p) => ({ key: p.id, label: p.label })),
|
|
131
|
+
[{ key: 'sparkline', label: 'Values', values: points.map((p) => p.value) }],
|
|
132
|
+
domain,
|
|
133
|
+
)
|
|
134
|
+
const paths: { id: string; d: string }[] = []
|
|
135
|
+
let d = '',
|
|
136
|
+
id = '',
|
|
137
|
+
count = 0,
|
|
138
|
+
last = ''
|
|
139
|
+
const flush = () => {
|
|
140
|
+
if (d) paths.push({ id, d: count === 1 ? `${d} L${last}` : d })
|
|
141
|
+
d = ''
|
|
142
|
+
count = 0
|
|
143
|
+
}
|
|
144
|
+
for (const point of geometry.series[0]?.points ?? []) {
|
|
145
|
+
if (!point) {
|
|
146
|
+
flush()
|
|
147
|
+
continue
|
|
148
|
+
}
|
|
149
|
+
if (!d) id = points[point.index]!.id
|
|
150
|
+
const x =
|
|
151
|
+
(points.length === 1 ? 0.5 : 0.02 + (point.index / (points.length - 1)) * 0.96) * width
|
|
152
|
+
const y = (0.1 + point.y * 0.8) * height
|
|
153
|
+
last = `${Math.min(width * 0.98, x + 0.01)} ${y}`
|
|
154
|
+
d += `${d ? ' L' : 'M'}${x} ${y}`
|
|
155
|
+
count++
|
|
156
|
+
}
|
|
157
|
+
flush()
|
|
158
|
+
return { ...geometry, paths }
|
|
159
|
+
}
|
|
160
|
+
export function effectColors(colors: readonly string[]) {
|
|
161
|
+
if (colors.length < 2 || colors.length > 8 || colors.some((c) => !/^#[\da-f]{6}$/i.test(c)))
|
|
162
|
+
throw new TypeError('Effects require 2–8 six-digit HEX colors.')
|
|
163
|
+
return colors
|
|
164
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { IconName } from './icon.js'
|
|
2
|
+
import type { ChoiceValue } from './choice.js'
|
|
3
|
+
|
|
4
|
+
export interface SpeedDialAction {
|
|
5
|
+
value: ChoiceValue
|
|
6
|
+
label: string
|
|
7
|
+
icon?: IconName
|
|
8
|
+
disabled?: boolean
|
|
9
|
+
}
|
|
10
|
+
export interface ComposerAttachment {
|
|
11
|
+
id: string
|
|
12
|
+
name: string
|
|
13
|
+
}
|
|
14
|
+
export interface ComposerMessage {
|
|
15
|
+
text: string
|
|
16
|
+
attachments: readonly ComposerAttachment[]
|
|
17
|
+
}
|
|
18
|
+
/** Native/core-only consumers need no DOM typings; Web retains fetch's full signal type. */
|
|
19
|
+
export type RefreshSignal = typeof globalThis extends {
|
|
20
|
+
AbortController: { prototype: { signal: infer Signal } }
|
|
21
|
+
}
|
|
22
|
+
? Signal
|
|
23
|
+
: {
|
|
24
|
+
readonly aborted: boolean
|
|
25
|
+
readonly reason: unknown
|
|
26
|
+
throwIfAborted(): void
|
|
27
|
+
addEventListener(type: 'abort', listener: () => void, options?: { once?: boolean }): void
|
|
28
|
+
removeEventListener(type: 'abort', listener: () => void): void
|
|
29
|
+
}
|
|
30
|
+
export interface RefreshContext {
|
|
31
|
+
readonly signal: RefreshSignal
|
|
32
|
+
readonly cancelled: boolean
|
|
33
|
+
/** Apply results only while this refresh still owns the component. */
|
|
34
|
+
commit(change: () => void | Promise<void>): Promise<boolean>
|
|
35
|
+
}
|
|
36
|
+
export type RefreshAction = (context: RefreshContext) => void | Promise<void>
|
|
37
|
+
export type RefreshState = 'idle' | 'refreshing' | 'success' | 'error'
|
|
38
|
+
export function pinLength(length: number) {
|
|
39
|
+
if (!Number.isInteger(length) || length < 2 || length > 12)
|
|
40
|
+
throw new RangeError('MPinInput length must be an integer between 2 and 12.')
|
|
41
|
+
return length
|
|
42
|
+
}
|
|
43
|
+
/** Accept pasted separators and full-width digits without accepting arbitrary code. */
|
|
44
|
+
export function normalizePin(value: string, length: number) {
|
|
45
|
+
return value
|
|
46
|
+
.replace(/[0-9]/g, (digit) => String.fromCharCode(digit.charCodeAt(0) - 0xfee0))
|
|
47
|
+
.replace(/[^0-9]/g, '')
|
|
48
|
+
.slice(0, pinLength(length))
|
|
49
|
+
}
|
|
50
|
+
export function uniqueActions(actions: readonly SpeedDialAction[]) {
|
|
51
|
+
const keys = new Set<string>()
|
|
52
|
+
for (const action of actions) {
|
|
53
|
+
const key = `${typeof action.value}:${action.value}`
|
|
54
|
+
if (!action.label.trim() || keys.has(key))
|
|
55
|
+
throw new TypeError('Speed dial actions require unique values and nonempty labels.')
|
|
56
|
+
keys.add(key)
|
|
57
|
+
}
|
|
58
|
+
return actions
|
|
59
|
+
}
|