@devalok/shilp-sutra 0.57.0 → 0.59.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/MIGRATION.md +91 -0
- package/dist/_chunks/badge-group.js +75 -188
- package/dist/_chunks/badge-group.js.map +1 -1
- package/dist/_chunks/chat.js +244 -243
- package/dist/_chunks/chat.js.map +1 -1
- package/dist/_chunks/image-preview.js +71 -70
- package/dist/_chunks/image-preview.js.map +1 -1
- package/dist/_chunks/motion-preference.js +15 -0
- package/dist/_chunks/motion-preference.js.map +1 -0
- package/dist/_chunks/motion-provider.js +1 -1
- package/dist/_chunks/motion-provider.js.map +1 -1
- package/dist/_chunks/popover.js +50 -49
- package/dist/_chunks/popover.js.map +1 -1
- package/dist/_chunks/primitives-internal.js +29 -29
- package/dist/_chunks/primitives-internal.js.map +1 -1
- package/dist/_chunks/shared.js +48 -47
- package/dist/_chunks/shared.js.map +1 -1
- package/dist/_chunks/success.js +34 -34
- package/dist/_chunks/tree-view.js +1 -1
- package/dist/_chunks/tree-view.js.map +1 -1
- package/dist/ai/block-renderer.js +8 -8
- package/dist/ai/command-bar.js +65 -65
- package/dist/ai/command-bar.js.map +1 -1
- package/dist/ai/conversation.js +35 -35
- package/dist/ai/conversation.js.map +1 -1
- package/dist/ai/index.js +4 -4
- package/dist/composed/activity-feed.d.ts.map +1 -1
- package/dist/composed/activity-feed.js +108 -107
- package/dist/composed/activity-feed.js.map +1 -1
- package/dist/composed/command-palette.js +137 -137
- package/dist/composed/command-palette.js.map +1 -1
- package/dist/composed/content-card.js +1 -1
- package/dist/composed/content-card.js.map +1 -1
- package/dist/composed/date-picker/index.js +5 -5
- package/dist/composed/date-picker/index.js.map +1 -1
- package/dist/composed/empty-state.js +4 -4
- package/dist/composed/file-preview/image-preview.d.ts.map +1 -1
- package/dist/composed/file-preview/shared.d.ts.map +1 -1
- package/dist/composed/file-preview/video-preview.d.ts.map +1 -1
- package/dist/composed/file-preview.js +151 -150
- package/dist/composed/file-preview.js.map +1 -1
- package/dist/composed/filter-bar.d.ts.map +1 -1
- package/dist/composed/filter-bar.js +53 -52
- package/dist/composed/filter-bar.js.map +1 -1
- package/dist/composed/form-section.d.ts.map +1 -1
- package/dist/composed/form-section.js +38 -37
- package/dist/composed/form-section.js.map +1 -1
- package/dist/composed/master-detail.d.ts.map +1 -1
- package/dist/composed/master-detail.js +1 -1
- package/dist/composed/master-detail.js.map +1 -1
- package/dist/composed/multi-select-popover.d.ts.map +1 -1
- package/dist/composed/multi-select-popover.js +109 -108
- package/dist/composed/multi-select-popover.js.map +1 -1
- package/dist/composed/rich-chat-input/attachment-strip.d.ts.map +1 -1
- package/dist/composed/rich-chat-input/reply-banner.d.ts.map +1 -1
- package/dist/composed/rich-chat-input/schedule-send.d.ts.map +1 -1
- package/dist/composed/rich-chat-input.d.ts.map +1 -1
- package/dist/composed/rich-chat-input.js +467 -466
- package/dist/composed/rich-chat-input.js.map +1 -1
- package/dist/composed/rich-text-editor.js +3 -3
- package/dist/composed/rich-text-editor.js.map +1 -1
- package/dist/composed/schedule-view.js +2 -2
- package/dist/composed/schedule-view.js.map +1 -1
- package/dist/composed/status-badge.d.ts.map +1 -1
- package/dist/composed/status-badge.js +29 -28
- package/dist/composed/status-badge.js.map +1 -1
- package/dist/motion/index.d.ts +1 -0
- package/dist/motion/index.d.ts.map +1 -1
- package/dist/motion/index.js +2 -15
- package/dist/motion/motion-preference.d.ts +36 -0
- package/dist/motion/motion-preference.d.ts.map +1 -0
- package/dist/motion/motion-provider.d.ts +2 -1
- package/dist/motion/motion-provider.d.ts.map +1 -1
- package/dist/motion/primitives-index.js +103 -102
- package/dist/motion/primitives-index.js.map +1 -1
- package/dist/motion/primitives.d.ts.map +1 -1
- package/dist/shell/bottom-navbar.js +19 -19
- package/dist/shell/bottom-navbar.js.map +1 -1
- package/dist/shell/index.d.ts +1 -1
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/notification-center.d.ts +17 -0
- package/dist/shell/notification-center.d.ts.map +1 -1
- package/dist/shell/notification-center.js +109 -104
- package/dist/shell/notification-center.js.map +1 -1
- package/dist/shell/notification-preferences.js +1 -1
- package/dist/shell/notification-preferences.js.map +1 -1
- package/dist/shell/top-bar.js +1 -1
- package/dist/shell/top-bar.js.map +1 -1
- package/dist/tokens/index.css +1 -0
- package/dist/tokens/palettes.css +292 -0
- package/dist/tokens/semantic.css +72 -8
- package/dist/tokens/shilp-sutra.css +1 -0
- package/dist/tokens/utilities.css +10 -7
- package/dist/ui/accordion.d.ts.map +1 -1
- package/dist/ui/accordion.js +27 -26
- package/dist/ui/accordion.js.map +1 -1
- package/dist/ui/alert-dialog.d.ts.map +1 -1
- package/dist/ui/alert-dialog.js +60 -59
- package/dist/ui/alert-dialog.js.map +1 -1
- package/dist/ui/alert.d.ts.map +1 -1
- package/dist/ui/alert.js +55 -113
- package/dist/ui/alert.js.map +1 -1
- package/dist/ui/autocomplete.js +80 -80
- package/dist/ui/autocomplete.js.map +1 -1
- package/dist/ui/avatar.d.ts.map +1 -1
- package/dist/ui/avatar.js +69 -68
- package/dist/ui/avatar.js.map +1 -1
- package/dist/ui/badge-indicator.d.ts +4 -8
- package/dist/ui/badge-indicator.d.ts.map +1 -1
- package/dist/ui/badge-indicator.js +3 -8
- package/dist/ui/badge-indicator.js.map +1 -1
- package/dist/ui/badge.d.ts +8 -1
- package/dist/ui/badge.d.ts.map +1 -1
- package/dist/ui/banner.d.ts.map +1 -1
- package/dist/ui/banner.js +42 -40
- package/dist/ui/banner.js.map +1 -1
- package/dist/ui/button-group.d.ts.map +1 -1
- package/dist/ui/button-group.js +3 -23
- package/dist/ui/button-group.js.map +1 -1
- package/dist/ui/button.d.ts +10 -1
- package/dist/ui/button.d.ts.map +1 -1
- package/dist/ui/button.js +79 -212
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/card.d.ts.map +1 -1
- package/dist/ui/card.js +75 -72
- package/dist/ui/card.js.map +1 -1
- package/dist/ui/charts/radar-chart.d.ts.map +1 -1
- package/dist/ui/charts/radar-chart.js +1 -1
- package/dist/ui/charts/radar-chart.js.map +1 -1
- package/dist/ui/chat/message-list.d.ts.map +1 -1
- package/dist/ui/chat/message.d.ts.map +1 -1
- package/dist/ui/chat/typing-indicator.d.ts.map +1 -1
- package/dist/ui/code.js +1 -1
- package/dist/ui/code.js.map +1 -1
- package/dist/ui/color-input.d.ts.map +1 -1
- package/dist/ui/color-input.js +151 -150
- package/dist/ui/color-input.js.map +1 -1
- package/dist/ui/combobox.d.ts +14 -0
- package/dist/ui/combobox.d.ts.map +1 -1
- package/dist/ui/combobox.js +152 -148
- package/dist/ui/combobox.js.map +1 -1
- package/dist/ui/context-menu.d.ts.map +1 -1
- package/dist/ui/context-menu.js +70 -69
- package/dist/ui/context-menu.js.map +1 -1
- package/dist/ui/data-table-body.js +2 -2
- package/dist/ui/data-table-body.js.map +1 -1
- package/dist/ui/data-table-context.js +2 -2
- package/dist/ui/data-table-context.js.map +1 -1
- package/dist/ui/data-table-header.d.ts.map +1 -1
- package/dist/ui/data-table-header.js +41 -40
- package/dist/ui/data-table-header.js.map +1 -1
- package/dist/ui/data-table-pagination.js +2 -2
- package/dist/ui/data-table-pagination.js.map +1 -1
- package/dist/ui/dialog.d.ts.map +1 -1
- package/dist/ui/dialog.js +61 -60
- package/dist/ui/dialog.js.map +1 -1
- package/dist/ui/dot.d.ts.map +1 -1
- package/dist/ui/dot.js +10 -41
- package/dist/ui/dot.js.map +1 -1
- package/dist/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/ui/dropdown-menu.js +79 -78
- package/dist/ui/dropdown-menu.js.map +1 -1
- package/dist/ui/file-upload.d.ts.map +1 -1
- package/dist/ui/file-upload.js +116 -115
- package/dist/ui/file-upload.js.map +1 -1
- package/dist/ui/form.d.ts.map +1 -1
- package/dist/ui/form.js +27 -26
- package/dist/ui/form.js.map +1 -1
- package/dist/ui/hover-card.d.ts.map +1 -1
- package/dist/ui/hover-card.js +26 -25
- package/dist/ui/hover-card.js.map +1 -1
- package/dist/ui/icon.js +7 -7
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +3 -3
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/input.js +1 -1
- package/dist/ui/input.js.map +1 -1
- package/dist/ui/menubar.d.ts.map +1 -1
- package/dist/ui/menubar.js +73 -72
- package/dist/ui/menubar.js.map +1 -1
- package/dist/ui/navigation-menu.d.ts.map +1 -1
- package/dist/ui/navigation-menu.js +80 -79
- package/dist/ui/navigation-menu.js.map +1 -1
- package/dist/ui/popover.d.ts.map +1 -1
- package/dist/ui/progress.d.ts.map +1 -1
- package/dist/ui/progress.js +72 -68
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/radio.d.ts.map +1 -1
- package/dist/ui/radio.js +32 -31
- package/dist/ui/radio.js.map +1 -1
- package/dist/ui/search-input.d.ts.map +1 -1
- package/dist/ui/search-input.js +28 -27
- package/dist/ui/search-input.js.map +1 -1
- package/dist/ui/select.d.ts.map +1 -1
- package/dist/ui/select.js +64 -63
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/sidebar.d.ts.map +1 -1
- package/dist/ui/sidebar.js +4 -4
- package/dist/ui/sidebar.js.map +1 -1
- package/dist/ui/slider.d.ts +63 -9
- package/dist/ui/slider.d.ts.map +1 -1
- package/dist/ui/slider.js +74 -32
- package/dist/ui/slider.js.map +1 -1
- package/dist/ui/split-button.d.ts +8 -2
- package/dist/ui/split-button.d.ts.map +1 -1
- package/dist/ui/split-button.js +49 -95
- package/dist/ui/split-button.js.map +1 -1
- package/dist/ui/stat-card.d.ts.map +1 -1
- package/dist/ui/stat-card.js +89 -88
- package/dist/ui/stat-card.js.map +1 -1
- package/dist/ui/stat-flash.js +16 -16
- package/dist/ui/stepper.d.ts.map +1 -1
- package/dist/ui/stepper.js +63 -62
- package/dist/ui/stepper.js.map +1 -1
- package/dist/ui/table.js +3 -3
- package/dist/ui/table.js.map +1 -1
- package/dist/ui/tabs.d.ts.map +1 -1
- package/dist/ui/tabs.js +67 -66
- package/dist/ui/tabs.js.map +1 -1
- package/dist/ui/textarea.js +1 -1
- package/dist/ui/textarea.js.map +1 -1
- package/dist/ui/toast.d.ts.map +1 -1
- package/dist/ui/toast.js +195 -194
- package/dist/ui/toast.js.map +1 -1
- package/dist/ui/toggle.d.ts.map +1 -1
- package/dist/ui/toggle.js +24 -22
- package/dist/ui/toggle.js.map +1 -1
- package/dist/ui/tooltip.d.ts.map +1 -1
- package/dist/ui/tooltip.js +37 -36
- package/dist/ui/tooltip.js.map +1 -1
- package/dist/ui/tree-view/tree-item.d.ts.map +1 -1
- package/docs/recipes/customize-brand.md +58 -0
- package/docs/recipes/install-astro.md +1 -1
- package/docs/recipes/install-next-app-router.md +1 -1
- package/docs/recipes/install-next-pages.md +22 -1
- package/docs/recipes/install-remix.md +1 -1
- package/docs/recipes/install-tanstack-start.md +1 -1
- package/docs/recipes/install-vite.md +2 -1
- package/docs/recipes/server-components.md +7 -4
- package/docs/recipes/troubleshoot.md +1 -0
- package/llms.txt +1 -1
- package/mcp-manifest.json +9 -4
- package/package.json +3 -2
- package/skill/SKILL.md +1 -1
- package/skill/references/components.md +1 -1
- package/skill/references/customize-brand.md +58 -0
- package/skill/references/server-components.md +7 -4
- package/skill/references/setup-astro.md +1 -1
- package/skill/references/setup-next-app-router.md +1 -1
- package/skill/references/setup-next-pages.md +22 -1
- package/skill/references/setup-remix.md +1 -1
- package/skill/references/setup-tanstack-start.md +1 -1
- package/skill/references/setup-vite.md +2 -1
- package/skill/references/troubleshoot.md +1 -0
- package/dist/motion/check-motion-provider.d.ts +0 -2
- package/dist/motion/check-motion-provider.d.ts.map +0 -1
- package/dist/motion/index.js.map +0 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
type MotionPreferenceProps = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Makes the OS `prefers-reduced-motion` setting the DEFAULT for a component's
|
|
7
|
+
* animations, instead of something the consumer has to opt into.
|
|
8
|
+
*
|
|
9
|
+
* Framer Motion's `MotionConfigContext` defaults to `reducedMotion: "never"` —
|
|
10
|
+
* meaning every `motion.*` element ignores the OS setting until some ancestor
|
|
11
|
+
* says otherwise. Our only ancestor that says otherwise is `<MotionProvider>`,
|
|
12
|
+
* which consumers are not required to mount, so out of the box the whole
|
|
13
|
+
* library animated straight through a reduced-motion preference.
|
|
14
|
+
*
|
|
15
|
+
* Wrapping a component's root in this fixes that for the subtree. Under
|
|
16
|
+
* `"user"`, Framer suppresses exactly the positional keys — width, height,
|
|
17
|
+
* top/left/right/bottom and every transform — and leaves opacity, colour and
|
|
18
|
+
* filter animating normally. That is the behaviour WCAG 2.3.3 asks for: kill
|
|
19
|
+
* the movement, keep the fade.
|
|
20
|
+
*
|
|
21
|
+
* It renders no DOM, and defers to anything that has already made the call:
|
|
22
|
+
*
|
|
23
|
+
* - a mounted `<MotionProvider>` owns the decision, including the deliberate
|
|
24
|
+
* `reducedMotion={false}` "animate regardless" override;
|
|
25
|
+
* - a bare `<MotionConfig>` that has moved off the default was set on purpose;
|
|
26
|
+
* - nesting is self-cancelling — the outermost wrapper configures the context,
|
|
27
|
+
* and every one below it sees a non-default value and passes straight through.
|
|
28
|
+
*
|
|
29
|
+
* The one case it cannot read is a consumer who mounts `<MotionConfig
|
|
30
|
+
* reducedMotion="never">` by hand to force animation on. That is
|
|
31
|
+
* indistinguishable from the framework default, so this wrapper overrides it.
|
|
32
|
+
* `<MotionProvider reducedMotion={false}>` is the supported way to express it.
|
|
33
|
+
*/
|
|
34
|
+
declare function MotionPreference({ children }: MotionPreferenceProps): React.JSX.Element;
|
|
35
|
+
export { MotionPreference, type MotionPreferenceProps };
|
|
36
|
+
//# sourceMappingURL=motion-preference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion-preference.d.ts","sourceRoot":"","sources":["../../src/motion/motion-preference.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,KAAK,qBAAqB,GAAG;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,iBAAS,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE,qBAAqB,qBAQ5D;AAED,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,CAAA"}
|
|
@@ -6,6 +6,7 @@ type MotionContextValue = {
|
|
|
6
6
|
tweens: typeof tweens;
|
|
7
7
|
reducedMotion: boolean;
|
|
8
8
|
};
|
|
9
|
+
declare const MotionContext: React.Context<MotionContextValue | null>;
|
|
9
10
|
type MotionProviderProps = {
|
|
10
11
|
children: React.ReactNode;
|
|
11
12
|
/** 'user' = detect OS preference, true = force off, false = force on */
|
|
@@ -13,5 +14,5 @@ type MotionProviderProps = {
|
|
|
13
14
|
};
|
|
14
15
|
declare function MotionProvider({ children, reducedMotion }: MotionProviderProps): React.JSX.Element;
|
|
15
16
|
declare function useMotion(): MotionContextValue;
|
|
16
|
-
export { MotionProvider, type MotionProviderProps, useMotion };
|
|
17
|
+
export { MotionContext, MotionProvider, type MotionProviderProps, useMotion };
|
|
17
18
|
//# sourceMappingURL=motion-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion-provider.d.ts","sourceRoot":"","sources":["../../src/motion/motion-provider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAElD,KAAK,iBAAiB,GAAG,MAAM,GAAG,OAAO,CAAA;AAEzC,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,OAAO,OAAO,CAAA;IACvB,MAAM,EAAE,OAAO,MAAM,CAAA;IACrB,aAAa,EAAE,OAAO,CAAA;CACvB,CAAA;
|
|
1
|
+
{"version":3,"file":"motion-provider.d.ts","sourceRoot":"","sources":["../../src/motion/motion-provider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAElD,KAAK,iBAAiB,GAAG,MAAM,GAAG,OAAO,CAAA;AAEzC,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,OAAO,OAAO,CAAA;IACvB,MAAM,EAAE,OAAO,MAAM,CAAA;IACrB,aAAa,EAAE,OAAO,CAAA;CACvB,CAAA;AAKD,QAAA,MAAM,aAAa,0CAAuD,CAAA;AAE1E,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,wEAAwE;IACxE,aAAa,CAAC,EAAE,iBAAiB,CAAA;CAClC,CAAA;AAED,iBAAS,cAAc,CAAC,EAAE,QAAQ,EAAE,aAAsB,EAAE,EAAE,mBAAmB,qBAgBhF;AAED,iBAAS,SAAS,IAAI,kBAAkB,CAMvC;AAED,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAC,SAAS,EAAE,CAAA"}
|
|
@@ -1,45 +1,46 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { springs as e, tweens as t } from "../ui/lib/motion.js";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
3
|
+
import { MotionPreference as n } from "../_chunks/motion-preference.js";
|
|
4
|
+
import { cn as r } from "../ui/lib/utils.js";
|
|
5
|
+
import * as i from "react";
|
|
6
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
7
|
+
import { AnimatePresence as o, motion as s } from "framer-motion";
|
|
7
8
|
//#region src/motion/primitives.tsx
|
|
8
|
-
var
|
|
9
|
-
let
|
|
9
|
+
var c = i.forwardRef(({ show: e, children: i, className: c, layout: l, layoutId: u, whileInView: d, viewportOnce: f = !0, viewportMargin: p = "-50px", ...m }, h) => {
|
|
10
|
+
let g = d ? {
|
|
10
11
|
initial: "hidden",
|
|
11
12
|
whileInView: "visible",
|
|
12
13
|
viewport: {
|
|
13
|
-
once:
|
|
14
|
-
margin:
|
|
14
|
+
once: f,
|
|
15
|
+
margin: p
|
|
15
16
|
}
|
|
16
17
|
} : {};
|
|
17
|
-
return /* @__PURE__ */
|
|
18
|
-
ref:
|
|
18
|
+
return /* @__PURE__ */ a(n, { children: /* @__PURE__ */ a(o, { children: e && /* @__PURE__ */ a(s.div, {
|
|
19
|
+
ref: h,
|
|
19
20
|
initial: { opacity: 0 },
|
|
20
21
|
animate: { opacity: 1 },
|
|
21
22
|
exit: { opacity: 0 },
|
|
22
23
|
transition: t.fade,
|
|
23
|
-
className:
|
|
24
|
-
layout:
|
|
25
|
-
layoutId:
|
|
26
|
-
...
|
|
27
|
-
...
|
|
28
|
-
children:
|
|
29
|
-
}) });
|
|
24
|
+
className: r(c),
|
|
25
|
+
layout: l,
|
|
26
|
+
layoutId: u,
|
|
27
|
+
...g,
|
|
28
|
+
...m,
|
|
29
|
+
children: i
|
|
30
|
+
}) }) });
|
|
30
31
|
});
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
let
|
|
32
|
+
c.displayName = "MotionFade";
|
|
33
|
+
var l = i.forwardRef(({ show: i, children: c, className: l, preset: u = "snappy", layout: d, layoutId: f, whileInView: p, viewportOnce: m = !0, viewportMargin: h = "-50px", ...g }, _) => {
|
|
34
|
+
let v = e[u], y = p ? {
|
|
34
35
|
initial: "hidden",
|
|
35
36
|
whileInView: "visible",
|
|
36
37
|
viewport: {
|
|
37
|
-
once:
|
|
38
|
-
margin:
|
|
38
|
+
once: m,
|
|
39
|
+
margin: h
|
|
39
40
|
}
|
|
40
41
|
} : {};
|
|
41
|
-
return /* @__PURE__ */
|
|
42
|
-
ref:
|
|
42
|
+
return /* @__PURE__ */ a(n, { children: /* @__PURE__ */ a(o, { children: i && /* @__PURE__ */ a(s.div, {
|
|
43
|
+
ref: _,
|
|
43
44
|
initial: {
|
|
44
45
|
opacity: 0,
|
|
45
46
|
scale: .96
|
|
@@ -53,29 +54,29 @@ var c = r.forwardRef(({ show: r, children: s, className: c, preset: l = "snappy"
|
|
|
53
54
|
scale: .96
|
|
54
55
|
},
|
|
55
56
|
transition: {
|
|
56
|
-
...
|
|
57
|
+
...v,
|
|
57
58
|
opacity: t.fade
|
|
58
59
|
},
|
|
59
|
-
className:
|
|
60
|
-
layout:
|
|
61
|
-
layoutId:
|
|
62
|
-
...
|
|
63
|
-
...
|
|
64
|
-
children:
|
|
65
|
-
}) });
|
|
60
|
+
className: r(l),
|
|
61
|
+
layout: d,
|
|
62
|
+
layoutId: f,
|
|
63
|
+
...y,
|
|
64
|
+
...g,
|
|
65
|
+
children: c
|
|
66
|
+
}) }) });
|
|
66
67
|
});
|
|
67
|
-
|
|
68
|
-
var
|
|
69
|
-
let
|
|
68
|
+
l.displayName = "MotionScale";
|
|
69
|
+
var u = i.forwardRef(({ show: i, children: c, className: l, preset: u = "bouncy", layout: d, layoutId: f, whileInView: p, viewportOnce: m = !0, viewportMargin: h = "-50px", ...g }, _) => {
|
|
70
|
+
let v = e[u], y = p ? {
|
|
70
71
|
initial: "hidden",
|
|
71
72
|
whileInView: "visible",
|
|
72
73
|
viewport: {
|
|
73
|
-
once:
|
|
74
|
-
margin:
|
|
74
|
+
once: m,
|
|
75
|
+
margin: h
|
|
75
76
|
}
|
|
76
77
|
} : {};
|
|
77
|
-
return /* @__PURE__ */
|
|
78
|
-
ref:
|
|
78
|
+
return /* @__PURE__ */ a(n, { children: /* @__PURE__ */ a(o, { children: i && /* @__PURE__ */ a(s.div, {
|
|
79
|
+
ref: _,
|
|
79
80
|
initial: {
|
|
80
81
|
opacity: 0,
|
|
81
82
|
scale: .5
|
|
@@ -89,37 +90,37 @@ var l = r.forwardRef(({ show: r, children: s, className: c, preset: l = "bouncy"
|
|
|
89
90
|
scale: .5
|
|
90
91
|
},
|
|
91
92
|
transition: {
|
|
92
|
-
...
|
|
93
|
+
...v,
|
|
93
94
|
opacity: t.fade
|
|
94
95
|
},
|
|
95
|
-
className:
|
|
96
|
-
layout:
|
|
97
|
-
layoutId:
|
|
98
|
-
...
|
|
99
|
-
...
|
|
100
|
-
children:
|
|
101
|
-
}) });
|
|
96
|
+
className: r(l),
|
|
97
|
+
layout: d,
|
|
98
|
+
layoutId: f,
|
|
99
|
+
...y,
|
|
100
|
+
...g,
|
|
101
|
+
children: c
|
|
102
|
+
}) }) });
|
|
102
103
|
});
|
|
103
|
-
|
|
104
|
-
var
|
|
105
|
-
let
|
|
104
|
+
u.displayName = "MotionPop";
|
|
105
|
+
var d = i.forwardRef(({ show: i, children: c, className: l, preset: u = "smooth", direction: d = "up", layout: f, layoutId: p, whileInView: m, viewportOnce: h = !0, viewportMargin: g = "-50px", ..._ }, v) => {
|
|
106
|
+
let y = e[u], b = {
|
|
106
107
|
up: { y: 16 },
|
|
107
108
|
down: { y: -16 },
|
|
108
109
|
left: { x: 16 },
|
|
109
110
|
right: { x: -16 }
|
|
110
|
-
}[
|
|
111
|
+
}[d], x = m ? {
|
|
111
112
|
initial: "hidden",
|
|
112
113
|
whileInView: "visible",
|
|
113
114
|
viewport: {
|
|
114
|
-
once:
|
|
115
|
-
margin:
|
|
115
|
+
once: h,
|
|
116
|
+
margin: g
|
|
116
117
|
}
|
|
117
118
|
} : {};
|
|
118
|
-
return /* @__PURE__ */
|
|
119
|
-
ref:
|
|
119
|
+
return /* @__PURE__ */ a(n, { children: /* @__PURE__ */ a(o, { children: i && /* @__PURE__ */ a(s.div, {
|
|
120
|
+
ref: v,
|
|
120
121
|
initial: {
|
|
121
122
|
opacity: 0,
|
|
122
|
-
...
|
|
123
|
+
...b
|
|
123
124
|
},
|
|
124
125
|
animate: {
|
|
125
126
|
opacity: 1,
|
|
@@ -128,27 +129,27 @@ var u = r.forwardRef(({ show: r, children: s, className: c, preset: l = "smooth"
|
|
|
128
129
|
},
|
|
129
130
|
exit: {
|
|
130
131
|
opacity: 0,
|
|
131
|
-
...
|
|
132
|
+
...b
|
|
132
133
|
},
|
|
133
134
|
transition: {
|
|
134
|
-
...
|
|
135
|
+
...y,
|
|
135
136
|
opacity: t.fade
|
|
136
137
|
},
|
|
137
|
-
className:
|
|
138
|
-
layout:
|
|
139
|
-
layoutId:
|
|
140
|
-
...
|
|
141
|
-
...
|
|
142
|
-
children:
|
|
143
|
-
}) });
|
|
138
|
+
className: r(l),
|
|
139
|
+
layout: f,
|
|
140
|
+
layoutId: p,
|
|
141
|
+
...x,
|
|
142
|
+
..._,
|
|
143
|
+
children: c
|
|
144
|
+
}) }) });
|
|
144
145
|
});
|
|
145
|
-
|
|
146
|
-
var
|
|
147
|
-
let
|
|
148
|
-
return /* @__PURE__ */
|
|
146
|
+
d.displayName = "MotionSlide";
|
|
147
|
+
var f = i.forwardRef(({ show: i, children: c, className: l, preset: u = "gentle", layout: d, layoutId: f, ...p }, m) => {
|
|
148
|
+
let h = e[u];
|
|
149
|
+
return /* @__PURE__ */ a(n, { children: /* @__PURE__ */ a(o, {
|
|
149
150
|
initial: !1,
|
|
150
|
-
children:
|
|
151
|
-
ref:
|
|
151
|
+
children: i && /* @__PURE__ */ a(s.div, {
|
|
152
|
+
ref: m,
|
|
152
153
|
initial: {
|
|
153
154
|
height: 0,
|
|
154
155
|
opacity: 0,
|
|
@@ -165,44 +166,44 @@ var d = r.forwardRef(({ show: r, children: s, className: c, preset: l = "gentle"
|
|
|
165
166
|
overflow: "hidden"
|
|
166
167
|
},
|
|
167
168
|
transition: {
|
|
168
|
-
...
|
|
169
|
+
...h,
|
|
169
170
|
opacity: t.fade
|
|
170
171
|
},
|
|
171
|
-
className:
|
|
172
|
-
layout:
|
|
173
|
-
layoutId:
|
|
174
|
-
...
|
|
175
|
-
children:
|
|
172
|
+
className: r(l),
|
|
173
|
+
layout: d,
|
|
174
|
+
layoutId: f,
|
|
175
|
+
...p,
|
|
176
|
+
children: c
|
|
176
177
|
})
|
|
177
|
-
});
|
|
178
|
+
}) });
|
|
178
179
|
});
|
|
179
|
-
|
|
180
|
-
var
|
|
181
|
-
let
|
|
180
|
+
f.displayName = "MotionCollapse";
|
|
181
|
+
var p = i.forwardRef(({ children: e, className: t, delay: i = .04, whileInView: o, viewportOnce: c = !0, viewportMargin: l = "-50px", ...u }, d) => {
|
|
182
|
+
let f = {
|
|
182
183
|
hidden: {},
|
|
183
|
-
visible: { transition: { staggerChildren:
|
|
184
|
-
},
|
|
184
|
+
visible: { transition: { staggerChildren: i } }
|
|
185
|
+
}, p = o ? {
|
|
185
186
|
initial: "hidden",
|
|
186
187
|
whileInView: "visible",
|
|
187
188
|
viewport: {
|
|
188
|
-
once:
|
|
189
|
-
margin:
|
|
189
|
+
once: c,
|
|
190
|
+
margin: l
|
|
190
191
|
}
|
|
191
192
|
} : {
|
|
192
193
|
initial: "hidden",
|
|
193
194
|
animate: "visible"
|
|
194
195
|
};
|
|
195
|
-
return /* @__PURE__ */
|
|
196
|
-
ref:
|
|
197
|
-
variants:
|
|
198
|
-
className:
|
|
199
|
-
...
|
|
200
|
-
...
|
|
196
|
+
return /* @__PURE__ */ a(n, { children: /* @__PURE__ */ a(s.div, {
|
|
197
|
+
ref: d,
|
|
198
|
+
variants: f,
|
|
199
|
+
className: r(t),
|
|
200
|
+
...p,
|
|
201
|
+
...u,
|
|
201
202
|
children: e
|
|
202
|
-
});
|
|
203
|
+
}) });
|
|
203
204
|
});
|
|
204
|
-
|
|
205
|
-
var
|
|
205
|
+
p.displayName = "MotionStagger";
|
|
206
|
+
var m = {
|
|
206
207
|
hidden: {
|
|
207
208
|
opacity: 0,
|
|
208
209
|
y: 8
|
|
@@ -215,13 +216,13 @@ var p = {
|
|
|
215
216
|
opacity: t.fade
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
|
-
},
|
|
219
|
-
ref:
|
|
220
|
-
variants:
|
|
221
|
-
className:
|
|
222
|
-
...
|
|
219
|
+
}, h = i.forwardRef(({ children: e, className: t, ...i }, o) => /* @__PURE__ */ a(n, { children: /* @__PURE__ */ a(s.div, {
|
|
220
|
+
ref: o,
|
|
221
|
+
variants: m,
|
|
222
|
+
className: r(t),
|
|
223
|
+
...i,
|
|
223
224
|
children: e
|
|
224
|
-
}));
|
|
225
|
-
|
|
225
|
+
}) }));
|
|
226
|
+
h.displayName = "MotionStaggerItem";
|
|
226
227
|
//#endregion
|
|
227
|
-
export {
|
|
228
|
+
export { f as MotionCollapse, c as MotionFade, u as MotionPop, l as MotionScale, d as MotionSlide, p as MotionStagger, h as MotionStaggerItem };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives-index.js","names":[],"sources":["../../src/motion/primitives.tsx"],"sourcesContent":["'use client'\n\nimport { AnimatePresence, type HTMLMotionProps,motion, type Transition, type Variants } from 'framer-motion'\nimport * as React from 'react'\n\nimport type { SpringPreset } from '../ui/lib/motion'\nimport { springs, tweens } from '../ui/lib/motion'\nimport { cn } from '../ui/lib/utils'\n\n// ── Shared types ──\n\ntype MotionDivProps = Omit<HTMLMotionProps<'div'>, 'ref'>\n\ntype MotionPrimitiveProps = {\n show: boolean\n children: React.ReactNode\n className?: string\n preset?: SpringPreset\n layout?: boolean | 'position' | 'size' | 'preserve-aspect'\n layoutId?: string\n whileInView?: boolean\n viewportOnce?: boolean\n viewportMargin?: string\n}\n\n// ── MotionFade ──\n// Default: fade tween only (no spring needed for pure opacity)\n\nconst MotionFade = React.forwardRef<HTMLDivElement, MotionPrimitiveProps & MotionDivProps>(\n ({ show, children, className, layout, layoutId, whileInView, viewportOnce = true, viewportMargin = '-50px', ...rest }, ref) => {\n const inViewProps = whileInView ? {\n initial: 'hidden',\n whileInView: 'visible',\n viewport: { once: viewportOnce, margin: viewportMargin },\n } : {}\n\n return (\n <AnimatePresence>\n {show && (\n <motion.div\n ref={ref}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={tweens.fade}\n className={cn(className)}\n layout={layout}\n layoutId={layoutId}\n {...inViewProps}\n {...rest}\n >\n {children}\n </motion.div>\n )}\n </AnimatePresence>\n )\n },\n)\nMotionFade.displayName = 'MotionFade'\n\n// ── MotionScale ──\n// Default: snappy spring for scale + fade tween for opacity\n\nconst MotionScale = React.forwardRef<HTMLDivElement, MotionPrimitiveProps & MotionDivProps>(\n ({ show, children, className, preset = 'snappy', layout, layoutId, whileInView, viewportOnce = true, viewportMargin = '-50px', ...rest }, ref) => {\n const spring = springs[preset]\n const inViewProps = whileInView ? {\n initial: 'hidden',\n whileInView: 'visible',\n viewport: { once: viewportOnce, margin: viewportMargin },\n } : {}\n\n return (\n <AnimatePresence>\n {show && (\n <motion.div\n ref={ref}\n initial={{ opacity: 0, scale: 0.96 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.96 }}\n transition={{ ...spring, opacity: tweens.fade }}\n className={cn(className)}\n layout={layout}\n layoutId={layoutId}\n {...inViewProps}\n {...rest}\n >\n {children}\n </motion.div>\n )}\n </AnimatePresence>\n )\n },\n)\nMotionScale.displayName = 'MotionScale'\n\n// ── MotionPop ──\n// Default: bouncy spring with overshoot for scale + fade\n\nconst MotionPop = React.forwardRef<HTMLDivElement, MotionPrimitiveProps & MotionDivProps>(\n ({ show, children, className, preset = 'bouncy', layout, layoutId, whileInView, viewportOnce = true, viewportMargin = '-50px', ...rest }, ref) => {\n const spring = springs[preset]\n const inViewProps = whileInView ? {\n initial: 'hidden',\n whileInView: 'visible',\n viewport: { once: viewportOnce, margin: viewportMargin },\n } : {}\n\n return (\n <AnimatePresence>\n {show && (\n <motion.div\n ref={ref}\n initial={{ opacity: 0, scale: 0.5 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.5 }}\n transition={{ ...spring, opacity: tweens.fade }}\n className={cn(className)}\n layout={layout}\n layoutId={layoutId}\n {...inViewProps}\n {...rest}\n >\n {children}\n </motion.div>\n )}\n </AnimatePresence>\n )\n },\n)\nMotionPop.displayName = 'MotionPop'\n\n// ── MotionSlide ──\n// Default: smooth spring for translate + fade\n\nconst MotionSlide = React.forwardRef<\n HTMLDivElement,\n MotionPrimitiveProps & { direction?: 'up' | 'down' | 'left' | 'right' } & MotionDivProps\n>(\n ({ show, children, className, preset = 'smooth', direction = 'up', layout, layoutId, whileInView, viewportOnce = true, viewportMargin = '-50px', ...rest }, ref) => {\n const spring = springs[preset]\n const offsets = {\n up: { y: 16 },\n down: { y: -16 },\n left: { x: 16 },\n right: { x: -16 },\n }\n const offset = offsets[direction]\n const inViewProps = whileInView ? {\n initial: 'hidden',\n whileInView: 'visible',\n viewport: { once: viewportOnce, margin: viewportMargin },\n } : {}\n\n return (\n <AnimatePresence>\n {show && (\n <motion.div\n ref={ref}\n initial={{ opacity: 0, ...offset }}\n animate={{ opacity: 1, x: 0, y: 0 }}\n exit={{ opacity: 0, ...offset }}\n transition={{ ...spring, opacity: tweens.fade }}\n className={cn(className)}\n layout={layout}\n layoutId={layoutId}\n {...inViewProps}\n {...rest}\n >\n {children}\n </motion.div>\n )}\n </AnimatePresence>\n )\n },\n)\nMotionSlide.displayName = 'MotionSlide'\n\n// ── MotionCollapse ──\n// Default: gentle spring for height + fade\n// Uses height: \"auto\" — Framer Motion handles this natively\n\nconst MotionCollapse = React.forwardRef<HTMLDivElement, MotionPrimitiveProps & MotionDivProps>(\n ({ show, children, className, preset = 'gentle', layout, layoutId, ...rest }, ref) => {\n const spring = springs[preset]\n\n return (\n <AnimatePresence initial={false}>\n {show && (\n <motion.div\n ref={ref}\n initial={{ height: 0, opacity: 0, overflow: 'hidden' }}\n animate={{ height: 'auto', opacity: 1, overflow: 'hidden' }}\n exit={{ height: 0, opacity: 0, overflow: 'hidden' }}\n transition={{ ...spring, opacity: tweens.fade }}\n className={cn(className)}\n layout={layout}\n layoutId={layoutId}\n {...rest}\n >\n {children}\n </motion.div>\n )}\n </AnimatePresence>\n )\n },\n)\nMotionCollapse.displayName = 'MotionCollapse'\n\n// ── MotionStagger + MotionStaggerItem ──\n// Parent orchestrates children with staggerChildren\n\ntype MotionStaggerProps = {\n children: React.ReactNode\n className?: string\n delay?: number\n whileInView?: boolean\n viewportOnce?: boolean\n viewportMargin?: string\n}\n\nconst MotionStagger = React.forwardRef<HTMLDivElement, MotionStaggerProps & MotionDivProps>(\n ({ children, className, delay = 0.04, whileInView, viewportOnce = true, viewportMargin = '-50px', ...rest }, ref) => {\n const variants: Variants = {\n hidden: {},\n visible: {\n transition: { staggerChildren: delay },\n },\n }\n\n const viewProps = whileInView\n ? { initial: 'hidden' as const, whileInView: 'visible' as const, viewport: { once: viewportOnce, margin: viewportMargin } }\n : { initial: 'hidden' as const, animate: 'visible' as const }\n\n return (\n <motion.div\n ref={ref}\n variants={variants}\n className={cn(className)}\n {...viewProps}\n {...rest}\n >\n {children}\n </motion.div>\n )\n },\n)\nMotionStagger.displayName = 'MotionStagger'\n\nconst itemVariants: Variants = {\n hidden: { opacity: 0, y: 8 },\n visible: {\n opacity: 1,\n y: 0,\n transition: { ...springs.smooth, opacity: tweens.fade },\n },\n}\n\nconst MotionStaggerItem = React.forwardRef<HTMLDivElement, { children: React.ReactNode; className?: string } & MotionDivProps>(\n ({ children, className, ...rest }, ref) => {\n return (\n <motion.div\n ref={ref}\n variants={itemVariants}\n className={cn(className)}\n {...rest}\n >\n {children}\n </motion.div>\n )\n },\n)\nMotionStaggerItem.displayName = 'MotionStaggerItem'\n\nexport {\n MotionCollapse,\n MotionFade,\n MotionPop,\n type MotionPrimitiveProps,\n MotionScale,\n MotionSlide,\n MotionStagger,\n MotionStaggerItem,\n type MotionStaggerProps,\n}\n"],"mappings":";;;;;;AA4BA,IAAM,IAAa,EAAM,YACtB,EAAE,SAAM,aAAU,cAAW,WAAQ,aAAU,gBAAa,kBAAe,IAAM,oBAAiB,SAAS,GAAG,KAAQ,MAAQ;CAC7H,IAAM,IAAc,IAAc;EAChC,SAA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AACA,EAAkB,cAAc"}
|
|
1
|
+
{"version":3,"file":"primitives-index.js","names":[],"sources":["../../src/motion/primitives.tsx"],"sourcesContent":["'use client'\n\nimport { AnimatePresence, type HTMLMotionProps,motion, type Transition, type Variants } from 'framer-motion'\nimport * as React from 'react'\n\nimport type { SpringPreset } from '../ui/lib/motion'\nimport { springs, tweens } from '../ui/lib/motion'\nimport { cn } from '../ui/lib/utils'\nimport { MotionPreference } from './motion-preference'\n\n// ── Shared types ──\n\ntype MotionDivProps = Omit<HTMLMotionProps<'div'>, 'ref'>\n\ntype MotionPrimitiveProps = {\n show: boolean\n children: React.ReactNode\n className?: string\n preset?: SpringPreset\n layout?: boolean | 'position' | 'size' | 'preserve-aspect'\n layoutId?: string\n whileInView?: boolean\n viewportOnce?: boolean\n viewportMargin?: string\n}\n\n// ── MotionFade ──\n// Default: fade tween only (no spring needed for pure opacity)\n\nconst MotionFade = React.forwardRef<HTMLDivElement, MotionPrimitiveProps & MotionDivProps>(\n ({ show, children, className, layout, layoutId, whileInView, viewportOnce = true, viewportMargin = '-50px', ...rest }, ref) => {\n const inViewProps = whileInView ? {\n initial: 'hidden',\n whileInView: 'visible',\n viewport: { once: viewportOnce, margin: viewportMargin },\n } : {}\n\n return (\n <MotionPreference>\n <AnimatePresence>\n {show && (\n <motion.div\n ref={ref}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={tweens.fade}\n className={cn(className)}\n layout={layout}\n layoutId={layoutId}\n {...inViewProps}\n {...rest}\n >\n {children}\n </motion.div>\n )}\n </AnimatePresence>\n </MotionPreference>\n )\n },\n)\nMotionFade.displayName = 'MotionFade'\n\n// ── MotionScale ──\n// Default: snappy spring for scale + fade tween for opacity\n\nconst MotionScale = React.forwardRef<HTMLDivElement, MotionPrimitiveProps & MotionDivProps>(\n ({ show, children, className, preset = 'snappy', layout, layoutId, whileInView, viewportOnce = true, viewportMargin = '-50px', ...rest }, ref) => {\n const spring = springs[preset]\n const inViewProps = whileInView ? {\n initial: 'hidden',\n whileInView: 'visible',\n viewport: { once: viewportOnce, margin: viewportMargin },\n } : {}\n\n return (\n <MotionPreference>\n <AnimatePresence>\n {show && (\n <motion.div\n ref={ref}\n initial={{ opacity: 0, scale: 0.96 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.96 }}\n transition={{ ...spring, opacity: tweens.fade }}\n className={cn(className)}\n layout={layout}\n layoutId={layoutId}\n {...inViewProps}\n {...rest}\n >\n {children}\n </motion.div>\n )}\n </AnimatePresence>\n </MotionPreference>\n )\n },\n)\nMotionScale.displayName = 'MotionScale'\n\n// ── MotionPop ──\n// Default: bouncy spring with overshoot for scale + fade\n\nconst MotionPop = React.forwardRef<HTMLDivElement, MotionPrimitiveProps & MotionDivProps>(\n ({ show, children, className, preset = 'bouncy', layout, layoutId, whileInView, viewportOnce = true, viewportMargin = '-50px', ...rest }, ref) => {\n const spring = springs[preset]\n const inViewProps = whileInView ? {\n initial: 'hidden',\n whileInView: 'visible',\n viewport: { once: viewportOnce, margin: viewportMargin },\n } : {}\n\n return (\n <MotionPreference>\n <AnimatePresence>\n {show && (\n <motion.div\n ref={ref}\n initial={{ opacity: 0, scale: 0.5 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.5 }}\n transition={{ ...spring, opacity: tweens.fade }}\n className={cn(className)}\n layout={layout}\n layoutId={layoutId}\n {...inViewProps}\n {...rest}\n >\n {children}\n </motion.div>\n )}\n </AnimatePresence>\n </MotionPreference>\n )\n },\n)\nMotionPop.displayName = 'MotionPop'\n\n// ── MotionSlide ──\n// Default: smooth spring for translate + fade\n\nconst MotionSlide = React.forwardRef<\n HTMLDivElement,\n MotionPrimitiveProps & { direction?: 'up' | 'down' | 'left' | 'right' } & MotionDivProps\n>(\n ({ show, children, className, preset = 'smooth', direction = 'up', layout, layoutId, whileInView, viewportOnce = true, viewportMargin = '-50px', ...rest }, ref) => {\n const spring = springs[preset]\n const offsets = {\n up: { y: 16 },\n down: { y: -16 },\n left: { x: 16 },\n right: { x: -16 },\n }\n const offset = offsets[direction]\n const inViewProps = whileInView ? {\n initial: 'hidden',\n whileInView: 'visible',\n viewport: { once: viewportOnce, margin: viewportMargin },\n } : {}\n\n return (\n <MotionPreference>\n <AnimatePresence>\n {show && (\n <motion.div\n ref={ref}\n initial={{ opacity: 0, ...offset }}\n animate={{ opacity: 1, x: 0, y: 0 }}\n exit={{ opacity: 0, ...offset }}\n transition={{ ...spring, opacity: tweens.fade }}\n className={cn(className)}\n layout={layout}\n layoutId={layoutId}\n {...inViewProps}\n {...rest}\n >\n {children}\n </motion.div>\n )}\n </AnimatePresence>\n </MotionPreference>\n )\n },\n)\nMotionSlide.displayName = 'MotionSlide'\n\n// ── MotionCollapse ──\n// Default: gentle spring for height + fade\n// Uses height: \"auto\" — Framer Motion handles this natively\n\nconst MotionCollapse = React.forwardRef<HTMLDivElement, MotionPrimitiveProps & MotionDivProps>(\n ({ show, children, className, preset = 'gentle', layout, layoutId, ...rest }, ref) => {\n const spring = springs[preset]\n\n return (\n <MotionPreference>\n <AnimatePresence initial={false}>\n {show && (\n <motion.div\n ref={ref}\n initial={{ height: 0, opacity: 0, overflow: 'hidden' }}\n animate={{ height: 'auto', opacity: 1, overflow: 'hidden' }}\n exit={{ height: 0, opacity: 0, overflow: 'hidden' }}\n transition={{ ...spring, opacity: tweens.fade }}\n className={cn(className)}\n layout={layout}\n layoutId={layoutId}\n {...rest}\n >\n {children}\n </motion.div>\n )}\n </AnimatePresence>\n </MotionPreference>\n )\n },\n)\nMotionCollapse.displayName = 'MotionCollapse'\n\n// ── MotionStagger + MotionStaggerItem ──\n// Parent orchestrates children with staggerChildren\n\ntype MotionStaggerProps = {\n children: React.ReactNode\n className?: string\n delay?: number\n whileInView?: boolean\n viewportOnce?: boolean\n viewportMargin?: string\n}\n\nconst MotionStagger = React.forwardRef<HTMLDivElement, MotionStaggerProps & MotionDivProps>(\n ({ children, className, delay = 0.04, whileInView, viewportOnce = true, viewportMargin = '-50px', ...rest }, ref) => {\n const variants: Variants = {\n hidden: {},\n visible: {\n transition: { staggerChildren: delay },\n },\n }\n\n const viewProps = whileInView\n ? { initial: 'hidden' as const, whileInView: 'visible' as const, viewport: { once: viewportOnce, margin: viewportMargin } }\n : { initial: 'hidden' as const, animate: 'visible' as const }\n\n return (\n <MotionPreference>\n <motion.div\n ref={ref}\n variants={variants}\n className={cn(className)}\n {...viewProps}\n {...rest}\n >\n {children}\n </motion.div>\n </MotionPreference>\n )\n },\n)\nMotionStagger.displayName = 'MotionStagger'\n\nconst itemVariants: Variants = {\n hidden: { opacity: 0, y: 8 },\n visible: {\n opacity: 1,\n y: 0,\n transition: { ...springs.smooth, opacity: tweens.fade },\n },\n}\n\nconst MotionStaggerItem = React.forwardRef<HTMLDivElement, { children: React.ReactNode; className?: string } & MotionDivProps>(\n ({ children, className, ...rest }, ref) => {\n return (\n <MotionPreference>\n <motion.div\n ref={ref}\n variants={itemVariants}\n className={cn(className)}\n {...rest}\n >\n {children}\n </motion.div>\n </MotionPreference>\n )\n },\n)\nMotionStaggerItem.displayName = 'MotionStaggerItem'\n\nexport {\n MotionCollapse,\n MotionFade,\n MotionPop,\n type MotionPrimitiveProps,\n MotionScale,\n MotionSlide,\n MotionStagger,\n MotionStaggerItem,\n type MotionStaggerProps,\n}\n"],"mappings":";;;;;;;AA6BA,IAAM,IAAa,EAAM,YACtB,EAAE,SAAM,aAAU,cAAW,WAAQ,aAAU,gBAAa,kBAAe,IAAM,oBAAiB,SAAS,GAAG,KAAQ,MAAQ;CAC7H,IAAM,IAAc,IAAc;EAChC,SAAS;EACT,aAAa;EACb,UAAU;GAAE,MAAM;GAAc,QAAQ;EAAe;CACzD,IAAI,CAAC;CAEL,OACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UACG,KACC,kBAAC,EAAO,KAAR;EACO;EACL,SAAS,EAAE,SAAS,EAAE;EACtB,SAAS,EAAE,SAAS,E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CAEH;AACS,CAAA,EACI,CAAA,CAGxB;AACA,EAAkB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/motion/primitives.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAmB,KAAK,eAAe,EAAyC,MAAM,eAAe,CAAA;AAC5G,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/motion/primitives.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAmB,KAAK,eAAe,EAAyC,MAAM,eAAe,CAAA;AAC5G,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAOpD,KAAK,cAAc,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAA;AAEzD,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,iBAAiB,CAAA;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAKD,QAAA,MAAM,UAAU,8GA+Bf,CAAA;AAMD,QAAA,MAAM,WAAW,8GAgChB,CAAA;AAMD,QAAA,MAAM,SAAS,8GAgCd,CAAA;AAMD,QAAA,MAAM,WAAW;gBAEsB,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO;yDAwCtE,CAAA;AAOD,QAAA,MAAM,cAAc,8GA0BnB,CAAA;AAMD,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,QAAA,MAAM,aAAa,4GA2BlB,CAAA;AAYD,QAAA,MAAM,iBAAiB;cAAgD,KAAK,CAAC,SAAS;gBAAc,MAAM;yDAezG,CAAA;AAGD,OAAO,EACL,cAAc,EACd,UAAU,EACV,SAAS,EACT,KAAK,oBAAoB,EACzB,WAAW,EACX,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,KAAK,kBAAkB,GACxB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { springs as e } from "../ui/lib/motion.js";
|
|
3
|
+
import { IconProvider as t } from "../ui/icon-context.js";
|
|
4
4
|
import { cn as n } from "../ui/lib/utils.js";
|
|
5
5
|
import { Icon as r } from "../ui/icon.js";
|
|
6
6
|
import { normalizeIcon as i } from "../_chunks/normalize-icon.js";
|
|
@@ -29,24 +29,24 @@ function b({ count: e }) {
|
|
|
29
29
|
children: t
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
function x({ indicator:
|
|
33
|
-
if (
|
|
32
|
+
function x({ indicator: t, layoutId: n, reduced: r }) {
|
|
33
|
+
if (t === "none") return null;
|
|
34
34
|
let i = {
|
|
35
35
|
layoutId: n,
|
|
36
36
|
"aria-hidden": !0,
|
|
37
|
-
transition: r ? { duration: 0 } :
|
|
37
|
+
transition: r ? { duration: 0 } : e.snappy,
|
|
38
38
|
initial: !r && { opacity: 0 },
|
|
39
39
|
animate: { opacity: 1 }
|
|
40
40
|
};
|
|
41
|
-
return
|
|
41
|
+
return t === "underline" ? /* @__PURE__ */ m(_.span, {
|
|
42
42
|
...i,
|
|
43
43
|
className: "absolute top-0 h-[3px] w-full rounded-b-control-inner bg-accent-9"
|
|
44
|
-
}) :
|
|
44
|
+
}) : t === "tint" ? /* @__PURE__ */ m(_.span, {
|
|
45
45
|
...i,
|
|
46
|
-
className: "absolute inset-0 rounded-control bg-accent-
|
|
46
|
+
className: "absolute inset-0 rounded-control bg-accent-4"
|
|
47
47
|
}) : /* @__PURE__ */ m(_.span, {
|
|
48
48
|
...i,
|
|
49
|
-
className: "absolute inset-0 rounded-pill bg-accent-
|
|
49
|
+
className: "absolute inset-0 rounded-pill bg-accent-4"
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
var S = "relative flex h-16 w-full min-w-0 cursor-pointer flex-col items-center justify-center gap-ds-02 px-ds-01 pt-0 text-body-sm transition-colors duration-fast-02 ease-productive-standard";
|
|
@@ -54,7 +54,7 @@ function C({ item: r, isActive: a, indicator: o, indicatorId: s, showLabel: c, r
|
|
|
54
54
|
let u = d();
|
|
55
55
|
return /* @__PURE__ */ m(_.div, {
|
|
56
56
|
whileTap: l ? void 0 : { scale: .96 },
|
|
57
|
-
transition: l ? { duration: 0 } :
|
|
57
|
+
transition: l ? { duration: 0 } : e.snappy,
|
|
58
58
|
className: "flex min-w-0 flex-1 basis-0",
|
|
59
59
|
children: /* @__PURE__ */ h(u, {
|
|
60
60
|
href: r.href,
|
|
@@ -84,7 +84,7 @@ function C({ item: r, isActive: a, indicator: o, indicatorId: s, showLabel: c, r
|
|
|
84
84
|
/* @__PURE__ */ m("span", {
|
|
85
85
|
className: "relative [&>svg]:h-ico-md [&>svg]:w-ico-md",
|
|
86
86
|
"aria-hidden": "true",
|
|
87
|
-
children: /* @__PURE__ */ m(
|
|
87
|
+
children: /* @__PURE__ */ m(t, {
|
|
88
88
|
size: "md",
|
|
89
89
|
children: i(a && r.activeIcon ? r.activeIcon : r.icon)
|
|
90
90
|
})
|
|
@@ -124,7 +124,7 @@ var w = f.forwardRef(({ currentPath: a = "/", user: b = null, primaryItems: w =
|
|
|
124
124
|
type: "button",
|
|
125
125
|
"aria-label": "More navigation options",
|
|
126
126
|
whileTap: M ? void 0 : { scale: .96 },
|
|
127
|
-
transition: M ? { duration: 0 } :
|
|
127
|
+
transition: M ? { duration: 0 } : e.snappy,
|
|
128
128
|
className: n(S, "min-w-0 flex-1 basis-0", B ? "font-semibold text-accent-11" : "text-surface-fg-subtle"),
|
|
129
129
|
children: [B && E === "tint" && /* @__PURE__ */ m(x, {
|
|
130
130
|
indicator: "tint",
|
|
@@ -158,25 +158,25 @@ var w = f.forwardRef(({ currentPath: a = "/", user: b = null, primaryItems: w =
|
|
|
158
158
|
className: "rounded-t-bubble",
|
|
159
159
|
children: [/* @__PURE__ */ m(c, { children: /* @__PURE__ */ m(l, { children: "More" }) }), /* @__PURE__ */ m("div", {
|
|
160
160
|
className: "grid grid-cols-[repeat(auto-fit,minmax(72px,1fr))] gap-ds-03 pt-ds-04",
|
|
161
|
-
children: R.map((
|
|
162
|
-
let r = I(
|
|
161
|
+
children: R.map((e) => {
|
|
162
|
+
let r = I(e.href, e.exact);
|
|
163
163
|
return /* @__PURE__ */ h(j, {
|
|
164
|
-
href:
|
|
164
|
+
href: e.href,
|
|
165
165
|
onClick: () => P(!1),
|
|
166
166
|
"aria-current": r ? "page" : void 0,
|
|
167
167
|
className: n("flex min-w-0 flex-col items-center gap-ds-02b rounded-overlay-lg p-ds-04 text-body-sm transition-colors ease-productive-standard", r ? "bg-surface-panel-hover text-accent-11" : "text-surface-fg-subtle hover:bg-surface-panel-hover"),
|
|
168
168
|
children: [/* @__PURE__ */ m("span", {
|
|
169
169
|
className: "[&>svg]:h-ico-md [&>svg]:w-ico-md",
|
|
170
170
|
"aria-hidden": "true",
|
|
171
|
-
children: /* @__PURE__ */ m(
|
|
171
|
+
children: /* @__PURE__ */ m(t, {
|
|
172
172
|
size: "md",
|
|
173
|
-
children: i(
|
|
173
|
+
children: i(e.icon)
|
|
174
174
|
})
|
|
175
175
|
}), /* @__PURE__ */ m("span", {
|
|
176
176
|
className: "max-w-full truncate text-center",
|
|
177
|
-
children:
|
|
177
|
+
children: e.title
|
|
178
178
|
})]
|
|
179
|
-
},
|
|
179
|
+
}, e.href);
|
|
180
180
|
})
|
|
181
181
|
})]
|
|
182
182
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bottom-navbar.js","names":[],"sources":["../../src/shell/bottom-navbar.tsx"],"sourcesContent":["'use client'\n\n/**\n * BottomNavbar -- Mobile bottom navigation bar.\n *\n * Props-driven (currentPath / user / items) and router-agnostic via `useLink`.\n * The \"More\" overflow uses the DS `Sheet` primitive, so it inherits focus trap,\n * scroll lock, return-focus, `aria-modal`, and trigger↔panel ARIA wiring.\n */\nimport { IconDots } from '@tabler/icons-react'\nimport { motion, useReducedMotion } from 'framer-motion'\nimport * as React from 'react'\nimport { useState } from 'react'\n\nimport { Badge } from '../ui/badge'\nimport { Icon } from '../ui/icon'\nimport { IconProvider } from '../ui/icon-context'\nimport type { IconInput } from '../ui/lib/icon-input'\nimport { springs } from '../ui/lib/motion'\nimport { normalizeIcon } from '../ui/lib/normalize-icon'\nimport { cn } from '../ui/lib/utils'\nimport { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from '../ui/sheet'\nimport { useLink } from './link-context'\n\n// -----------------------------------------------------------------------\n// Types\n// -----------------------------------------------------------------------\n\nexport interface BottomNavbarUser {\n name: string\n role?: string\n}\n\nexport interface BottomNavItem {\n title: string\n href: string\n /** Icon for this nav item. Accepts any `IconInput`. */\n icon: IconInput\n /** Icon shown when the item is active — e.g. a filled variant. Falls back to `icon`. */\n activeIcon?: IconInput\n /** When true, the route matches only when the path is exactly equal */\n exact?: boolean\n /** Notification badge count. 0 or undefined = hidden, 1–99 = shown, >99 = \"99+\" */\n badge?: number\n /**\n * Roles allowed to see this item, matched against `user.role`. Omit to show\n * it to everyone. For arbitrary logic, use `canView` instead.\n */\n roles?: string[]\n /**\n * Visibility predicate — full control over whether this item renders.\n * Receives the current `user` (or `null`). Takes precedence over `roles`.\n */\n canView?: (user: BottomNavbarUser | null) => boolean\n}\n\n/**\n * Active-item indicator, animated between items on selection:\n * - `pill` (default) — Material-3 tonal pill behind the icon\n * - `underline` — top accent bar (Material-2 tab style)\n * - `tint` — subtle background tint on the whole active cell\n * - `none` — no shape; rely on the filled `activeIcon` + accent color (iOS)\n */\nexport type BottomNavIndicator = 'pill' | 'underline' | 'tint' | 'none'\n/** Show labels always (default) or only for the selected item (narrow viewports). */\nexport type BottomNavLabelVisibility = 'always' | 'selected'\n\nexport interface BottomNavbarProps extends React.HTMLAttributes<HTMLElement> {\n /** Currently active pathname */\n currentPath?: string\n /** Current user. Drives per-item role gating via `item.roles` / `item.canView`. */\n user?: BottomNavbarUser | null\n /** Primary nav items shown directly in the bottom bar (max 4 recommended) */\n primaryItems?: BottomNavItem[]\n /** Additional items shown in the \"More\" overflow sheet */\n moreItems?: BottomNavItem[]\n /** Active-indicator style. @default 'pill' */\n indicator?: BottomNavIndicator\n /** Label visibility. @default 'always' */\n labelVisibility?: BottomNavLabelVisibility\n /** Additional className for the nav element */\n className?: string\n}\n\n// -----------------------------------------------------------------------\n// Helpers\n// -----------------------------------------------------------------------\n\n/** Per-item role/visibility gate. `canView` wins; else `roles` matched against user.role; else visible. */\nfunction itemVisible(item: BottomNavItem, user: BottomNavbarUser | null): boolean {\n if (item.canView) return item.canView(user)\n if (item.roles && item.roles.length > 0) {\n return !!user?.role && item.roles.includes(user.role)\n }\n return true\n}\n\n// -----------------------------------------------------------------------\n// NavBadge (composes Badge)\n// -----------------------------------------------------------------------\n\nfunction NavBadge({ count }: { count: number }) {\n if (!count || count <= 0) return null\n const display = count > 99 ? '99+' : String(count)\n return (\n <Badge\n color=\"error\"\n variant=\"solid\"\n size=\"xs\"\n aria-label={`${count} notifications`}\n className=\"pointer-events-none absolute -end-1 -top-1 justify-center px-ds-01 tabular-nums motion-safe:animate-in motion-safe:zoom-in-75\"\n >\n {display}\n </Badge>\n )\n}\n\n// -----------------------------------------------------------------------\n// Active indicator (shared-element)\n// -----------------------------------------------------------------------\n\n/**\n * The active-item indicator. A single shared-element (`layoutId`) that SLIDES\n * to the selected item and fades in on first appearance. `none` renders\n * nothing (the filled `activeIcon` + accent color carry the state).\n */\nfunction ActiveIndicator({\n indicator,\n layoutId,\n reduced,\n}: {\n indicator: BottomNavIndicator\n layoutId: string\n reduced: boolean\n}) {\n if (indicator === 'none') return null\n const common = {\n layoutId,\n 'aria-hidden': true as const,\n transition: reduced ? { duration: 0 } : springs.snappy,\n initial: reduced ? false : { opacity: 0 },\n animate: { opacity: 1 },\n }\n if (indicator === 'underline') {\n return <motion.span {...common} className=\"absolute top-0 h-[3px] w-full rounded-b-control-inner bg-accent-9\" />\n }\n if (indicator === 'tint') {\n return <motion.span {...common} className=\"absolute inset-0 rounded-control bg-accent-3\" />\n }\n // pill (default) — Material-3 tonal pill behind the icon\n return <motion.span {...common} className=\"absolute inset-0 rounded-pill bg-accent-3\" />\n}\n\n// -----------------------------------------------------------------------\n// BottomNavLink (internal)\n// -----------------------------------------------------------------------\n\nconst itemClass =\n 'relative flex h-16 w-full min-w-0 cursor-pointer flex-col items-center justify-center gap-ds-02 px-ds-01 pt-0 text-body-sm transition-colors duration-fast-02 ease-productive-standard'\n\nfunction BottomNavLink({\n item,\n isActive,\n indicator,\n indicatorId,\n showLabel,\n reduced,\n}: {\n item: BottomNavItem\n isActive: boolean\n indicator: BottomNavIndicator\n indicatorId: string\n showLabel: boolean\n reduced: boolean\n}) {\n const Link = useLink()\n return (\n <motion.div\n whileTap={reduced ? undefined : { scale: 0.96 }}\n transition={reduced ? { duration: 0 } : springs.snappy}\n className=\"flex min-w-0 flex-1 basis-0\"\n >\n <Link\n href={item.href}\n aria-label={item.title}\n aria-current={isActive ? 'page' : undefined}\n className={cn(itemClass, isActive ? 'font-semibold text-accent-11' : 'text-surface-fg-subtle')}\n >\n {/* tint covers the whole cell — sits behind the content */}\n {isActive && indicator === 'tint' && (\n <ActiveIndicator indicator=\"tint\" layoutId={indicatorId} reduced={reduced} />\n )}\n <div className=\"relative flex w-full min-w-0 flex-col items-center gap-ds-02\">\n {isActive && indicator === 'underline' && (\n <ActiveIndicator indicator=\"underline\" layoutId={indicatorId} reduced={reduced} />\n )}\n <div className=\"relative px-ds-04 py-ds-01\">\n {isActive && indicator === 'pill' && (\n <ActiveIndicator indicator=\"pill\" layoutId={indicatorId} reduced={reduced} />\n )}\n <span className=\"relative [&>svg]:h-ico-md [&>svg]:w-ico-md\" aria-hidden=\"true\">\n <IconProvider size=\"md\">\n {normalizeIcon(isActive && item.activeIcon ? item.activeIcon : item.icon)}\n </IconProvider>\n </span>\n {item.badge != null && <NavBadge count={item.badge} />}\n </div>\n {showLabel && <span className=\"max-w-full truncate text-center\">{item.title}</span>}\n </div>\n </Link>\n </motion.div>\n )\n}\n\n// -----------------------------------------------------------------------\n// BottomNavbar\n// -----------------------------------------------------------------------\n\nconst BottomNavbar = React.forwardRef<HTMLElement, BottomNavbarProps>(\n (\n {\n currentPath = '/',\n user = null,\n primaryItems = [],\n moreItems = [],\n indicator = 'pill',\n labelVisibility = 'always',\n className,\n ...props\n },\n ref,\n ) => {\n const Link = useLink()\n const reduced = useReducedMotion() ?? false\n const [showMore, setShowMore] = useState(false)\n // Scope the shared-element layoutId per instance so two navbars don't animate into each other.\n const instanceId = React.useId()\n const indicatorId = `${instanceId}-nav-indicator`\n\n const isActive = (path: string, exact = false) => {\n if (exact || path === '/') return currentPath === path\n return currentPath.startsWith(path)\n }\n\n // Role/visibility gating\n const visiblePrimary = primaryItems.filter((item) => itemVisible(item, user))\n const visibleMore = moreItems.filter((item) => itemVisible(item, user))\n\n const isMoreActive = visibleMore.some((item) => isActive(item.href, item.exact))\n const moreSelected = showMore || isMoreActive\n const showMoreLabel = labelVisibility === 'always' || moreSelected\n\n return (\n <nav\n {...props}\n ref={ref}\n aria-label=\"Mobile navigation\"\n className={cn(\n 'fixed bottom-0 start-0 end-0 z-sticky flex w-full flex-row items-stretch justify-between border-t border-surface-border-strong bg-surface-base px-ds-05 pb-safe pt-0 md:hidden',\n className,\n )}\n >\n {visiblePrimary.map((item) => (\n <BottomNavLink\n key={item.href}\n item={item}\n isActive={isActive(item.href, item.exact)}\n indicator={indicator}\n indicatorId={indicatorId}\n showLabel={labelVisibility === 'always' || isActive(item.href, item.exact)}\n reduced={reduced}\n />\n ))}\n\n {visibleMore.length > 0 && (\n <Sheet open={showMore} onOpenChange={setShowMore}>\n <SheetTrigger asChild>\n <motion.button\n type=\"button\"\n aria-label=\"More navigation options\"\n whileTap={reduced ? undefined : { scale: 0.96 }}\n transition={reduced ? { duration: 0 } : springs.snappy}\n className={cn(\n itemClass,\n 'min-w-0 flex-1 basis-0',\n moreSelected ? 'font-semibold text-accent-11' : 'text-surface-fg-subtle',\n )}\n >\n {moreSelected && indicator === 'tint' && (\n <ActiveIndicator indicator=\"tint\" layoutId={indicatorId} reduced={reduced} />\n )}\n <div className=\"relative flex w-full min-w-0 flex-col items-center gap-ds-02\">\n {moreSelected && indicator === 'underline' && (\n <ActiveIndicator indicator=\"underline\" layoutId={indicatorId} reduced={reduced} />\n )}\n <div className=\"relative px-ds-04 py-ds-01\">\n {moreSelected && indicator === 'pill' && (\n <ActiveIndicator indicator=\"pill\" layoutId={indicatorId} reduced={reduced} />\n )}\n <Icon icon={IconDots} />\n </div>\n {showMoreLabel && <span className=\"max-w-full truncate text-center\">More</span>}\n </div>\n </motion.button>\n </SheetTrigger>\n\n <SheetContent side=\"bottom\" className=\"rounded-t-bubble\">\n <SheetHeader>\n <SheetTitle>More</SheetTitle>\n </SheetHeader>\n <div className=\"grid grid-cols-[repeat(auto-fit,minmax(72px,1fr))] gap-ds-03 pt-ds-04\">\n {visibleMore.map((item) => {\n const active = isActive(item.href, item.exact)\n return (\n <Link\n key={item.href}\n href={item.href}\n onClick={() => setShowMore(false)}\n aria-current={active ? 'page' : undefined}\n className={cn(\n 'flex min-w-0 flex-col items-center gap-ds-02b rounded-overlay-lg p-ds-04 text-body-sm transition-colors ease-productive-standard',\n active\n ? 'bg-surface-panel-hover text-accent-11'\n : 'text-surface-fg-subtle hover:bg-surface-panel-hover',\n )}\n >\n <span className=\"[&>svg]:h-ico-md [&>svg]:w-ico-md\" aria-hidden=\"true\">\n <IconProvider size=\"md\">{normalizeIcon(item.icon)}</IconProvider>\n </span>\n <span className=\"max-w-full truncate text-center\">{item.title}</span>\n </Link>\n )\n })}\n </div>\n </SheetContent>\n </Sheet>\n )}\n </nav>\n )\n },\n)\nBottomNavbar.displayName = 'BottomNavbar'\n\nexport { BottomNavbar }\n"],"mappings":";;;;;;;;;;;;;;;;AAyFA,SAAS,EAAY,GAAqB,GAAwC;CAKhF,OAJI,EAAK,UAAgB,EAAK,QAAQ,CAAI,IACtC,EAAK,SAAS,EAAK,MAAM,SAAS,IAC7B,CAAC,CAAC,GAAM,QAAQ,EAAK,MAAM,SAAS,EAAK,IAAI,IAE/C;AACT;AAMA,SAAS,EAAS,EAAE,YAA4B;CAC9C,IAAI,CAAC,KAAS,KAAS,GAAG,OAAO;CACjC,IAAM,IAAU,IAAQ,KAAK,QAAQ,OAAO,CAAK;CACjD,OACE,kBAAC,GAAD;EACE,OAAM;EACN,SAAQ;EACR,MAAK;EACL,cAAY,GAAG,EAAM;EACrB,WAAU;YAET;CACI,CAAA;AAEX;AAWA,SAAS,EAAgB,EACvB,cACA,aACA,cAKC;CACD,IAAI,MAAc,QAAQ,OAAO;CACjC,IAAM,IAAS;EACb;EACA,eAAe;EACf,YAAY,IAAU,EAAE,UAAU,EAAE,IAAI,EAAQ;EAChD,SAAS,MAAkB,EAAE,SAAS,EAAE;EACxC,SAAS,EAAE,SAAS,EAAE;CACxB;CAQA,OAPI,MAAc,cACT,kBAAC,EAAO,MAAR;EAAa,GAAI;EAAQ,W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MAAc,eAC7B,kBAAC,GAAD;QAAiB,WAAU;QAAY,UAAU;QAAsB;OAAU,CAAA;OAEnF,kBAAC,OAAD;QAAK,WAAU;kBAAf,CACG,KAAgB,MAAc,UAC7B,kBAAC,GAAD;SAAiB,WAAU;SAAO,UAAU;SAAsB;QAAU,CAAA,GAE9E,kBAAC,GAAD,EAAM,MAAM,EAAW,CAAA,CACpB;;OACJ,KAAiB,kBAAC,QAAD;QAAM,WAAU;kBAAkC;OAAU,CAAA;MAC3E;OACQ;;GACH,CAAA,GAEd,kBAAC,GAAD;IAAc,MAAK;IAAS,WAAU;cAAtC,CACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UAAY,OAAgB,CAAA,EACjB,CAAA,GACb,kBAAC,OAAD;KAAK,WAAU;eACZ,EAAY,KAAK,MAAS;MACzB,IAAM,IAAS,EAAS,EAAK,MAAM,EAAK,KAAK;MAC7C,OACE,kBAAC,GAAD;OAEE,MAAM,EAAK;OACX,eAAe,EAAY,EAAK;OAChC,gBAAc,IAAS,SAAS,KAAA;OAChC,WAAW,EACT,oIACA,IACI,0CACA,qDACN;iBAVF,CAYE,kBAAC,QAAD;QAAM,WAAU;QAAoC,eAAY;kBAC9D,kBAAC,GAAD;SAAc,MAAK;mBAAM,EAAc,EAAK,IAAI;QAAgB,CAAA;OAC5D,CAAA,GACN,kBAAC,QAAD;QAAM,WAAU;kBAAmC,EAAK;OAAY,CAAA,CAChE;SAfC,EAAK,IAeN;KAEV,CAAC;IACE,CAAA,CACO;KACT;IAEN;;AAET,CACF;AACA,EAAa,cAAc"}
|
|
1
|
+
{"version":3,"file":"bottom-navbar.js","names":[],"sources":["../../src/shell/bottom-navbar.tsx"],"sourcesContent":["'use client'\n\n/**\n * BottomNavbar -- Mobile bottom navigation bar.\n *\n * Props-driven (currentPath / user / items) and router-agnostic via `useLink`.\n * The \"More\" overflow uses the DS `Sheet` primitive, so it inherits focus trap,\n * scroll lock, return-focus, `aria-modal`, and trigger↔panel ARIA wiring.\n */\nimport { IconDots } from '@tabler/icons-react'\nimport { motion, useReducedMotion } from 'framer-motion'\nimport * as React from 'react'\nimport { useState } from 'react'\n\nimport { Badge } from '../ui/badge'\nimport { Icon } from '../ui/icon'\nimport { IconProvider } from '../ui/icon-context'\nimport type { IconInput } from '../ui/lib/icon-input'\nimport { springs } from '../ui/lib/motion'\nimport { normalizeIcon } from '../ui/lib/normalize-icon'\nimport { cn } from '../ui/lib/utils'\nimport { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from '../ui/sheet'\nimport { useLink } from './link-context'\n\n// -----------------------------------------------------------------------\n// Types\n// -----------------------------------------------------------------------\n\nexport interface BottomNavbarUser {\n name: string\n role?: string\n}\n\nexport interface BottomNavItem {\n title: string\n href: string\n /** Icon for this nav item. Accepts any `IconInput`. */\n icon: IconInput\n /** Icon shown when the item is active — e.g. a filled variant. Falls back to `icon`. */\n activeIcon?: IconInput\n /** When true, the route matches only when the path is exactly equal */\n exact?: boolean\n /** Notification badge count. 0 or undefined = hidden, 1–99 = shown, >99 = \"99+\" */\n badge?: number\n /**\n * Roles allowed to see this item, matched against `user.role`. Omit to show\n * it to everyone. For arbitrary logic, use `canView` instead.\n */\n roles?: string[]\n /**\n * Visibility predicate — full control over whether this item renders.\n * Receives the current `user` (or `null`). Takes precedence over `roles`.\n */\n canView?: (user: BottomNavbarUser | null) => boolean\n}\n\n/**\n * Active-item indicator, animated between items on selection:\n * - `pill` (default) — Material-3 tonal pill behind the icon\n * - `underline` — top accent bar (Material-2 tab style)\n * - `tint` — subtle background tint on the whole active cell\n * - `none` — no shape; rely on the filled `activeIcon` + accent color (iOS)\n */\nexport type BottomNavIndicator = 'pill' | 'underline' | 'tint' | 'none'\n/** Show labels always (default) or only for the selected item (narrow viewports). */\nexport type BottomNavLabelVisibility = 'always' | 'selected'\n\nexport interface BottomNavbarProps extends React.HTMLAttributes<HTMLElement> {\n /** Currently active pathname */\n currentPath?: string\n /** Current user. Drives per-item role gating via `item.roles` / `item.canView`. */\n user?: BottomNavbarUser | null\n /** Primary nav items shown directly in the bottom bar (max 4 recommended) */\n primaryItems?: BottomNavItem[]\n /** Additional items shown in the \"More\" overflow sheet */\n moreItems?: BottomNavItem[]\n /** Active-indicator style. @default 'pill' */\n indicator?: BottomNavIndicator\n /** Label visibility. @default 'always' */\n labelVisibility?: BottomNavLabelVisibility\n /** Additional className for the nav element */\n className?: string\n}\n\n// -----------------------------------------------------------------------\n// Helpers\n// -----------------------------------------------------------------------\n\n/** Per-item role/visibility gate. `canView` wins; else `roles` matched against user.role; else visible. */\nfunction itemVisible(item: BottomNavItem, user: BottomNavbarUser | null): boolean {\n if (item.canView) return item.canView(user)\n if (item.roles && item.roles.length > 0) {\n return !!user?.role && item.roles.includes(user.role)\n }\n return true\n}\n\n// -----------------------------------------------------------------------\n// NavBadge (composes Badge)\n// -----------------------------------------------------------------------\n\nfunction NavBadge({ count }: { count: number }) {\n if (!count || count <= 0) return null\n const display = count > 99 ? '99+' : String(count)\n return (\n <Badge\n color=\"error\"\n variant=\"solid\"\n size=\"xs\"\n aria-label={`${count} notifications`}\n className=\"pointer-events-none absolute -end-1 -top-1 justify-center px-ds-01 tabular-nums motion-safe:animate-in motion-safe:zoom-in-75\"\n >\n {display}\n </Badge>\n )\n}\n\n// -----------------------------------------------------------------------\n// Active indicator (shared-element)\n// -----------------------------------------------------------------------\n\n/**\n * The active-item indicator. A single shared-element (`layoutId`) that SLIDES\n * to the selected item and fades in on first appearance. `none` renders\n * nothing (the filled `activeIcon` + accent color carry the state).\n */\nfunction ActiveIndicator({\n indicator,\n layoutId,\n reduced,\n}: {\n indicator: BottomNavIndicator\n layoutId: string\n reduced: boolean\n}) {\n if (indicator === 'none') return null\n const common = {\n layoutId,\n 'aria-hidden': true as const,\n transition: reduced ? { duration: 0 } : springs.snappy,\n initial: reduced ? false : { opacity: 0 },\n animate: { opacity: 1 },\n }\n if (indicator === 'underline') {\n return <motion.span {...common} className=\"absolute top-0 h-[3px] w-full rounded-b-control-inner bg-accent-9\" />\n }\n if (indicator === 'tint') {\n return <motion.span {...common} className=\"absolute inset-0 rounded-control bg-accent-4\" />\n }\n // pill (default) — Material-3 tonal pill behind the icon\n return <motion.span {...common} className=\"absolute inset-0 rounded-pill bg-accent-4\" />\n}\n\n// -----------------------------------------------------------------------\n// BottomNavLink (internal)\n// -----------------------------------------------------------------------\n\nconst itemClass =\n 'relative flex h-16 w-full min-w-0 cursor-pointer flex-col items-center justify-center gap-ds-02 px-ds-01 pt-0 text-body-sm transition-colors duration-fast-02 ease-productive-standard'\n\nfunction BottomNavLink({\n item,\n isActive,\n indicator,\n indicatorId,\n showLabel,\n reduced,\n}: {\n item: BottomNavItem\n isActive: boolean\n indicator: BottomNavIndicator\n indicatorId: string\n showLabel: boolean\n reduced: boolean\n}) {\n const Link = useLink()\n return (\n <motion.div\n whileTap={reduced ? undefined : { scale: 0.96 }}\n transition={reduced ? { duration: 0 } : springs.snappy}\n className=\"flex min-w-0 flex-1 basis-0\"\n >\n <Link\n href={item.href}\n aria-label={item.title}\n aria-current={isActive ? 'page' : undefined}\n className={cn(itemClass, isActive ? 'font-semibold text-accent-11' : 'text-surface-fg-subtle')}\n >\n {/* tint covers the whole cell — sits behind the content */}\n {isActive && indicator === 'tint' && (\n <ActiveIndicator indicator=\"tint\" layoutId={indicatorId} reduced={reduced} />\n )}\n <div className=\"relative flex w-full min-w-0 flex-col items-center gap-ds-02\">\n {isActive && indicator === 'underline' && (\n <ActiveIndicator indicator=\"underline\" layoutId={indicatorId} reduced={reduced} />\n )}\n <div className=\"relative px-ds-04 py-ds-01\">\n {isActive && indicator === 'pill' && (\n <ActiveIndicator indicator=\"pill\" layoutId={indicatorId} reduced={reduced} />\n )}\n <span className=\"relative [&>svg]:h-ico-md [&>svg]:w-ico-md\" aria-hidden=\"true\">\n <IconProvider size=\"md\">\n {normalizeIcon(isActive && item.activeIcon ? item.activeIcon : item.icon)}\n </IconProvider>\n </span>\n {item.badge != null && <NavBadge count={item.badge} />}\n </div>\n {showLabel && <span className=\"max-w-full truncate text-center\">{item.title}</span>}\n </div>\n </Link>\n </motion.div>\n )\n}\n\n// -----------------------------------------------------------------------\n// BottomNavbar\n// -----------------------------------------------------------------------\n\nconst BottomNavbar = React.forwardRef<HTMLElement, BottomNavbarProps>(\n (\n {\n currentPath = '/',\n user = null,\n primaryItems = [],\n moreItems = [],\n indicator = 'pill',\n labelVisibility = 'always',\n className,\n ...props\n },\n ref,\n ) => {\n const Link = useLink()\n const reduced = useReducedMotion() ?? false\n const [showMore, setShowMore] = useState(false)\n // Scope the shared-element layoutId per instance so two navbars don't animate into each other.\n const instanceId = React.useId()\n const indicatorId = `${instanceId}-nav-indicator`\n\n const isActive = (path: string, exact = false) => {\n if (exact || path === '/') return currentPath === path\n return currentPath.startsWith(path)\n }\n\n // Role/visibility gating\n const visiblePrimary = primaryItems.filter((item) => itemVisible(item, user))\n const visibleMore = moreItems.filter((item) => itemVisible(item, user))\n\n const isMoreActive = visibleMore.some((item) => isActive(item.href, item.exact))\n const moreSelected = showMore || isMoreActive\n const showMoreLabel = labelVisibility === 'always' || moreSelected\n\n return (\n <nav\n {...props}\n ref={ref}\n aria-label=\"Mobile navigation\"\n className={cn(\n 'fixed bottom-0 start-0 end-0 z-sticky flex w-full flex-row items-stretch justify-between border-t border-surface-border-strong bg-surface-base px-ds-05 pb-safe pt-0 md:hidden',\n className,\n )}\n >\n {visiblePrimary.map((item) => (\n <BottomNavLink\n key={item.href}\n item={item}\n isActive={isActive(item.href, item.exact)}\n indicator={indicator}\n indicatorId={indicatorId}\n showLabel={labelVisibility === 'always' || isActive(item.href, item.exact)}\n reduced={reduced}\n />\n ))}\n\n {visibleMore.length > 0 && (\n <Sheet open={showMore} onOpenChange={setShowMore}>\n <SheetTrigger asChild>\n <motion.button\n type=\"button\"\n aria-label=\"More navigation options\"\n whileTap={reduced ? undefined : { scale: 0.96 }}\n transition={reduced ? { duration: 0 } : springs.snappy}\n className={cn(\n itemClass,\n 'min-w-0 flex-1 basis-0',\n moreSelected ? 'font-semibold text-accent-11' : 'text-surface-fg-subtle',\n )}\n >\n {moreSelected && indicator === 'tint' && (\n <ActiveIndicator indicator=\"tint\" layoutId={indicatorId} reduced={reduced} />\n )}\n <div className=\"relative flex w-full min-w-0 flex-col items-center gap-ds-02\">\n {moreSelected && indicator === 'underline' && (\n <ActiveIndicator indicator=\"underline\" layoutId={indicatorId} reduced={reduced} />\n )}\n <div className=\"relative px-ds-04 py-ds-01\">\n {moreSelected && indicator === 'pill' && (\n <ActiveIndicator indicator=\"pill\" layoutId={indicatorId} reduced={reduced} />\n )}\n <Icon icon={IconDots} />\n </div>\n {showMoreLabel && <span className=\"max-w-full truncate text-center\">More</span>}\n </div>\n </motion.button>\n </SheetTrigger>\n\n <SheetContent side=\"bottom\" className=\"rounded-t-bubble\">\n <SheetHeader>\n <SheetTitle>More</SheetTitle>\n </SheetHeader>\n <div className=\"grid grid-cols-[repeat(auto-fit,minmax(72px,1fr))] gap-ds-03 pt-ds-04\">\n {visibleMore.map((item) => {\n const active = isActive(item.href, item.exact)\n return (\n <Link\n key={item.href}\n href={item.href}\n onClick={() => setShowMore(false)}\n aria-current={active ? 'page' : undefined}\n className={cn(\n 'flex min-w-0 flex-col items-center gap-ds-02b rounded-overlay-lg p-ds-04 text-body-sm transition-colors ease-productive-standard',\n active\n ? 'bg-surface-panel-hover text-accent-11'\n : 'text-surface-fg-subtle hover:bg-surface-panel-hover',\n )}\n >\n <span className=\"[&>svg]:h-ico-md [&>svg]:w-ico-md\" aria-hidden=\"true\">\n <IconProvider size=\"md\">{normalizeIcon(item.icon)}</IconProvider>\n </span>\n <span className=\"max-w-full truncate text-center\">{item.title}</span>\n </Link>\n )\n })}\n </div>\n </SheetContent>\n </Sheet>\n )}\n </nav>\n )\n },\n)\nBottomNavbar.displayName = 'BottomNavbar'\n\nexport { BottomNavbar }\n"],"mappings":";;;;;;;;;;;;;;;;AAyFA,SAAS,EAAY,GAAqB,GAAwC;CA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