@yewdiel21/motion-kit 0.14.0 → 0.16.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/README.md +178 -155
- package/bin/motion-kit.mjs +3 -3
- package/dist/auto/index.d.ts +6 -3
- package/dist/auto/index.js +8 -2
- package/dist/auto/index.js.map +1 -1
- package/dist/{chunk-EY4BJKC4.js → chunk-NFZIX3IA.js} +2 -2
- package/dist/chunk-RBEKR5UZ.js +3660 -0
- package/dist/chunk-RBEKR5UZ.js.map +1 -0
- package/dist/{chunk-CU6SXW3E.js → chunk-SDQ776LG.js} +1596 -485
- package/dist/chunk-SDQ776LG.js.map +1 -0
- package/dist/css/components/add-to-cart.css +72 -0
- package/dist/css/components/bidirectional-slider.css +168 -0
- package/dist/css/components/chart.css +7 -0
- package/dist/css/components/data-table.css +121 -26
- package/dist/css/components/filter-builder.css +10 -15
- package/dist/css/components/heatmap-chart.css +398 -0
- package/dist/css/components/hover-card.css +8 -2
- package/dist/css/components/image-preview.css +90 -2
- package/dist/css/components/json-viewer.css +33 -1
- package/dist/css/components/nav.css +102 -102
- package/dist/css/components/orbit-menu.css +130 -0
- package/dist/css/components/pagination.css +10 -5
- package/dist/css/components/pie-chart.css +397 -0
- package/dist/css/components/pill-button.css +135 -0
- package/dist/css/components/radar-chart.css +377 -0
- package/dist/css/components/radial-chart.css +412 -0
- package/dist/css/components/sankey-chart.css +365 -0
- package/dist/css/components/scroll-island.css +114 -0
- package/dist/css/components/select.css +136 -0
- package/dist/css/components/toolbar.css +122 -0
- package/dist/css/components/tree-view.css +79 -0
- package/dist/css/components/voice-dots.css +70 -0
- package/dist/elements/index.d.ts +180 -7
- package/dist/elements/index.js +293 -7
- package/dist/elements/index.js.map +1 -1
- package/dist/{engine-Cn6IhE3z.d.ts → engine-5zRIssTO.d.ts} +11 -1
- package/dist/index.css +1849 -168
- package/dist/index.d.ts +4 -4
- package/dist/index.js +33 -3
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +117 -11
- package/dist/react/index.js +320 -13
- package/dist/react/index.js.map +1 -1
- package/dist/{reduced-BBUusld6.d.ts → reduced-DQwVXQYb.d.ts} +1 -1
- package/dist/{reveal-DEvp6U6T.d.ts → reveal-DRpNO4KP.d.ts} +109 -4
- package/dist/store-Da3zSh8Z.d.ts +457 -0
- package/package.json +9 -16
- package/registry.json +1096 -948
- package/src/auto/auto-init.ts +6 -0
- package/src/components/add-to-cart/README.md +49 -0
- package/src/components/add-to-cart/add-to-cart.css +71 -0
- package/src/components/add-to-cart/element.ts +20 -0
- package/src/components/add-to-cart/engine.ts +206 -0
- package/src/components/add-to-cart/react.tsx +33 -0
- package/src/components/bidirectional-slider/README.md +46 -0
- package/src/components/bidirectional-slider/bidirectional-slider.css +167 -0
- package/src/components/bidirectional-slider/element.ts +42 -0
- package/src/components/bidirectional-slider/engine.ts +289 -0
- package/src/components/bidirectional-slider/react.tsx +45 -0
- package/src/components/chart/README.md +49 -24
- package/src/components/chart/chart.css +7 -0
- package/src/components/chart/element.ts +4 -1
- package/src/components/chart/engine.ts +153 -34
- package/src/components/chart/parts.ts +237 -0
- package/src/components/chart/react.tsx +2 -2
- package/src/components/chart/use-chart.ts +55 -0
- package/src/components/data-table/README.md +3 -3
- package/src/components/data-table/data-table.css +121 -26
- package/src/components/data-table/engine.ts +81 -29
- package/src/components/editable-table/engine.ts +67 -11
- package/src/components/filter-builder/engine.ts +33 -2
- package/src/components/filter-builder/filter-builder.css +10 -15
- package/src/components/heatmap-chart/README.md +48 -0
- package/src/components/heatmap-chart/element.ts +21 -0
- package/src/components/heatmap-chart/engine.ts +281 -0
- package/src/components/heatmap-chart/heatmap-chart.css +93 -0
- package/src/components/heatmap-chart/react.tsx +14 -0
- package/src/components/hover-card/engine.ts +30 -1
- package/src/components/hover-card/hover-card.css +8 -2
- package/src/components/image-preview/element.ts +1 -1
- package/src/components/image-preview/engine.ts +95 -15
- package/src/components/image-preview/image-preview.css +90 -2
- package/src/components/image-preview/react.tsx +3 -3
- package/src/components/json-viewer/engine.ts +11 -2
- package/src/components/json-viewer/json-viewer.css +33 -1
- package/src/components/nav/README.md +12 -10
- package/src/components/nav/element.ts +5 -5
- package/src/components/nav/engine.ts +21 -14
- package/src/components/nav/nav.css +102 -102
- package/src/components/nav/react.tsx +4 -4
- package/src/components/orbit-menu/README.md +46 -0
- package/src/components/orbit-menu/element.ts +27 -0
- package/src/components/orbit-menu/engine.ts +179 -0
- package/src/components/orbit-menu/orbit-menu.css +129 -0
- package/src/components/orbit-menu/react.tsx +44 -0
- package/src/components/pagination/README.md +1 -1
- package/src/components/pagination/engine.ts +50 -4
- package/src/components/pagination/pagination.css +10 -5
- package/src/components/pie-chart/README.md +48 -0
- package/src/components/pie-chart/element.ts +30 -0
- package/src/components/pie-chart/engine.ts +283 -0
- package/src/components/pie-chart/pie-chart.css +92 -0
- package/src/components/pie-chart/react.tsx +14 -0
- package/src/components/pill-button/README.md +46 -0
- package/src/components/pill-button/element.ts +16 -0
- package/src/components/pill-button/engine.ts +77 -0
- package/src/components/pill-button/pill-button.css +134 -0
- package/src/components/pill-button/react.tsx +32 -0
- package/src/components/radar-chart/README.md +48 -0
- package/src/components/radar-chart/element.ts +30 -0
- package/src/components/radar-chart/engine.ts +327 -0
- package/src/components/radar-chart/radar-chart.css +72 -0
- package/src/components/radar-chart/react.tsx +14 -0
- package/src/components/radial-chart/README.md +58 -0
- package/src/components/radial-chart/element.ts +30 -0
- package/src/components/radial-chart/engine.ts +317 -0
- package/src/components/radial-chart/radial-chart.css +107 -0
- package/src/components/radial-chart/react.tsx +14 -0
- package/src/components/sankey-chart/README.md +48 -0
- package/src/components/sankey-chart/element.ts +31 -0
- package/src/components/sankey-chart/engine.ts +401 -0
- package/src/components/sankey-chart/react.tsx +14 -0
- package/src/components/sankey-chart/sankey-chart.css +60 -0
- package/src/components/scroll-island/README.md +44 -0
- package/src/components/scroll-island/element.ts +16 -0
- package/src/components/scroll-island/engine.ts +274 -0
- package/src/components/scroll-island/react.tsx +26 -0
- package/src/components/scroll-island/scroll-island.css +113 -0
- package/src/components/select/README.md +34 -0
- package/src/components/select/element.ts +26 -0
- package/src/components/select/engine.ts +267 -0
- package/src/components/select/react.tsx +33 -0
- package/src/components/select/select.css +135 -0
- package/src/components/toolbar/README.md +46 -0
- package/src/components/toolbar/element.ts +30 -0
- package/src/components/toolbar/engine.ts +230 -0
- package/src/components/toolbar/react.tsx +34 -0
- package/src/components/toolbar/toolbar.css +121 -0
- package/src/components/tree-view/element.ts +1 -1
- package/src/components/tree-view/engine.ts +174 -0
- package/src/components/tree-view/react.tsx +7 -3
- package/src/components/tree-view/tree-view.css +79 -0
- package/src/components/voice-dots/README.md +48 -0
- package/src/components/voice-dots/element.ts +45 -0
- package/src/components/voice-dots/engine.ts +243 -0
- package/src/components/voice-dots/react.tsx +52 -0
- package/src/components/voice-dots/voice-dots.css +69 -0
- package/src/elements/index.ts +39 -0
- package/src/index.ts +16 -0
- package/src/motion/liquid.ts +14 -4
- package/src/react/index.ts +14 -1
- package/dist/chunk-6P4P7NU6.js +0 -1401
- package/dist/chunk-6P4P7NU6.js.map +0 -1
- package/dist/chunk-CU6SXW3E.js.map +0 -1
- package/dist/store-DjkTBX7f.d.ts +0 -195
- /package/dist/{chunk-EY4BJKC4.js.map → chunk-NFZIX3IA.js.map} +0 -0
|
@@ -4,20 +4,26 @@ import { inert, warnOnce, type Instance } from '../../core/types';
|
|
|
4
4
|
import { revealFrom, type RevealHandle } from '../../motion/reveal';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
|
-
* navigation: seven desktop styles
|
|
8
|
-
*
|
|
7
|
+
* navigation: seven desktop styles named after how they look (sidebar, pills,
|
|
8
|
+
* dock, card, rail, wash, magnify) and one glass bar on phones, all in CSS (nav.css). The
|
|
9
9
|
* engine marks the current page (aria-current="page"), switches styles (and can
|
|
10
10
|
* remember the choice), and on start can reveal the
|
|
11
11
|
* app shell from the first button.
|
|
12
12
|
* Parts: .mk-nav__buttons .mk-nav__button (data-mk-value or href), .mk-nav__button--first.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
export const NAV_STYLES = ['
|
|
15
|
+
export const NAV_STYLES = ['sidebar', 'pills', 'dock', 'card', 'rail', 'wash', 'magnify'] as const;
|
|
16
16
|
export type NavStyle = (typeof NAV_STYLES)[number];
|
|
17
|
+
/** The names before 0.15, still accepted: each turns into the style it always was. */
|
|
18
|
+
export const NAV_STYLE_ALIASES = { clasica: 'sidebar', bonita: 'pills', guapa: 'card', tasks: 'rail', melon: 'wash', tunnel: 'magnify' } as const satisfies Record<string, NavStyle>;
|
|
19
|
+
export type NavStyleAlias = keyof typeof NAV_STYLE_ALIASES;
|
|
20
|
+
/** A style name (new or old) as one of NAV_STYLES, or undefined. */
|
|
21
|
+
export const toNavStyle = (value: unknown): NavStyle | undefined =>
|
|
22
|
+
NAV_STYLES.includes(value as NavStyle) ? (value as NavStyle) : (NAV_STYLE_ALIASES as Record<string, NavStyle>)[value as string];
|
|
17
23
|
|
|
18
24
|
export interface NavOptions {
|
|
19
|
-
/** Default: the saved one (storageKey), else the mk-nav--<style> class in the markup, else '
|
|
20
|
-
style?: NavStyle;
|
|
25
|
+
/** Default: the saved one (storageKey), else the mk-nav--<style> class in the markup, else 'pills'. Old names (clasica…) work too. */
|
|
26
|
+
style?: NavStyle | NavStyleAlias;
|
|
21
27
|
/** The accent variant: the current page in primary-container. */
|
|
22
28
|
accent?: boolean;
|
|
23
29
|
/** Reveal the shell from the first button when the nav starts (off by default). */
|
|
@@ -31,7 +37,7 @@ export interface NavOptions {
|
|
|
31
37
|
export interface NavInstance extends Instance {
|
|
32
38
|
/** Mark a page as current, by index or value (silent: no event). */
|
|
33
39
|
select(target: number | string): void;
|
|
34
|
-
setStyle(style: NavStyle): void;
|
|
40
|
+
setStyle(style: NavStyle | NavStyleAlias): void;
|
|
35
41
|
setAccent(on: boolean): void;
|
|
36
42
|
readonly index: number;
|
|
37
43
|
readonly style: NavStyle;
|
|
@@ -47,7 +53,6 @@ export interface NavigateDetail {
|
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
const ITEM = '.mk-nav__buttons .mk-nav__button';
|
|
50
|
-
const isStyle = (value: unknown): value is NavStyle => NAV_STYLES.includes(value as NavStyle);
|
|
51
56
|
const valueOf = (item: HTMLElement) => item.dataset.mkValue ?? item.getAttribute('href') ?? undefined;
|
|
52
57
|
|
|
53
58
|
const read = (key: string) => {
|
|
@@ -77,17 +82,18 @@ export function revealShell(nav: HTMLElement): RevealHandle | null {
|
|
|
77
82
|
export function createNav(root: HTMLElement | null, options: NavOptions = {}): NavInstance {
|
|
78
83
|
if (!root) {
|
|
79
84
|
warnOnce('nav: missing root');
|
|
80
|
-
return inert({ select() {}, setStyle() {}, setAccent() {}, index: -1, style: '
|
|
85
|
+
return inert({ select() {}, setStyle() {}, setAccent() {}, index: -1, style: 'pills', items: [] });
|
|
81
86
|
}
|
|
82
87
|
const scope = createScope();
|
|
83
88
|
const items = () => [...root.querySelectorAll<HTMLElement>(ITEM)];
|
|
84
|
-
const
|
|
89
|
+
const known = [...NAV_STYLES, ...Object.keys(NAV_STYLE_ALIASES)];
|
|
90
|
+
const fromClass = toNavStyle(known.find((name) => root.classList.contains(`mk-nav--${name}`)));
|
|
85
91
|
const saved = options.storageKey ? read(options.storageKey) : null;
|
|
86
|
-
let style: NavStyle = options.style ?? (
|
|
92
|
+
let style: NavStyle = toNavStyle(options.style) ?? toNavStyle(saved) ?? fromClass ?? 'pills';
|
|
87
93
|
|
|
88
94
|
const paint = (accent: boolean) => {
|
|
89
95
|
const classes = new Set(root.classList);
|
|
90
|
-
for (const name of
|
|
96
|
+
for (const name of known) classes.delete(`mk-nav--${name}`);
|
|
91
97
|
classes.add('mk-nav');
|
|
92
98
|
classes.add(`mk-nav--${style}`);
|
|
93
99
|
if (accent) classes.add('mk-nav--accent');
|
|
@@ -133,13 +139,14 @@ export function createNav(root: HTMLElement | null, options: NavOptions = {}): N
|
|
|
133
139
|
else mark(item);
|
|
134
140
|
},
|
|
135
141
|
setStyle(next) {
|
|
136
|
-
|
|
142
|
+
const resolved = toNavStyle(next);
|
|
143
|
+
if (!resolved) {
|
|
137
144
|
warnOnce(`nav: unknown style "${String(next)}" (use ${NAV_STYLES.join(', ')})`);
|
|
138
145
|
return;
|
|
139
146
|
}
|
|
140
|
-
style =
|
|
147
|
+
style = resolved;
|
|
141
148
|
paint(accent);
|
|
142
|
-
if (options.storageKey) write(options.storageKey,
|
|
149
|
+
if (options.storageKey) write(options.storageKey, resolved);
|
|
143
150
|
},
|
|
144
151
|
setAccent(on) {
|
|
145
152
|
accent = on;
|