@mrpelz/uikit-ish 7.8.0 → 7.10.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/dist/components/accordion/main.d.ts +12 -0
- package/dist/components/accordion/main.d.ts.map +1 -0
- package/dist/components/accordion/main.js +20 -0
- package/dist/components/accordion/main.js.map +1 -0
- package/dist/components/accordion/style.css +23 -0
- package/dist/components/action-sheet/main.d.ts +22 -16
- package/dist/components/action-sheet/main.d.ts.map +1 -1
- package/dist/components/action-sheet/main.js +89 -19
- package/dist/components/action-sheet/main.js.map +1 -1
- package/dist/components/action-sheet/props.d.ts +17 -5
- package/dist/components/action-sheet/props.d.ts.map +1 -1
- package/dist/components/action-sheet/style.css +24 -0
- package/dist/components/activity-view/main.d.ts +15 -4
- package/dist/components/activity-view/main.d.ts.map +1 -1
- package/dist/components/activity-view/main.js +27 -14
- package/dist/components/activity-view/main.js.map +1 -1
- package/dist/components/activity-view/props.d.ts +2 -10
- package/dist/components/activity-view/props.d.ts.map +1 -1
- package/dist/components/activity-view/style.css +29 -67
- package/dist/components/alert/main.d.ts +8 -7
- package/dist/components/alert/main.d.ts.map +1 -1
- package/dist/components/alert/main.js +32 -19
- package/dist/components/alert/main.js.map +1 -1
- package/dist/components/alert/props.d.ts +13 -2
- package/dist/components/alert/props.d.ts.map +1 -1
- package/dist/components/alert/style.css +36 -50
- package/dist/components/avatar/main.d.ts +5 -3
- package/dist/components/avatar/main.d.ts.map +1 -1
- package/dist/components/avatar/main.js +10 -8
- package/dist/components/avatar/main.js.map +1 -1
- package/dist/components/avatar/props.d.ts +4 -0
- package/dist/components/avatar/props.d.ts.map +1 -1
- package/dist/components/avatar/style.css +1 -7
- package/dist/components/badge/main.d.ts +3 -3
- package/dist/components/badge/main.d.ts.map +1 -1
- package/dist/components/badge/main.js +9 -9
- package/dist/components/badge/main.js.map +1 -1
- package/dist/components/badge/props.d.ts +4 -3
- package/dist/components/badge/props.d.ts.map +1 -1
- package/dist/components/badge/style.css +10 -4
- package/dist/components/button/main.d.ts.map +1 -1
- package/dist/components/button/main.js +15 -15
- package/dist/components/button/main.js.map +1 -1
- package/dist/components/button/props.d.ts +8 -8
- package/dist/components/button/props.d.ts.map +1 -1
- package/dist/components/button/style.css +37 -55
- package/dist/components/checkbox/main.d.ts.map +1 -1
- package/dist/components/checkbox/main.js +5 -7
- package/dist/components/checkbox/main.js.map +1 -1
- package/dist/components/checkbox/style.css +5 -8
- package/dist/components/collapsible/main.d.ts +9 -0
- package/dist/components/collapsible/main.d.ts.map +1 -0
- package/dist/components/collapsible/main.js +19 -0
- package/dist/components/collapsible/main.js.map +1 -0
- package/dist/components/collapsible/style.css +23 -0
- package/dist/components/color-picker/main.d.ts +27 -4
- package/dist/components/color-picker/main.d.ts.map +1 -1
- package/dist/components/color-picker/main.js +292 -110
- package/dist/components/color-picker/main.js.map +1 -1
- package/dist/components/color-picker/props.d.ts +64 -15
- package/dist/components/color-picker/props.d.ts.map +1 -1
- package/dist/components/color-picker/style.css +133 -65
- package/dist/components/contextual-menu/main.d.ts +11 -7
- package/dist/components/contextual-menu/main.d.ts.map +1 -1
- package/dist/components/contextual-menu/main.js +207 -202
- package/dist/components/contextual-menu/main.js.map +1 -1
- package/dist/components/contextual-menu/props.d.ts +21 -34
- package/dist/components/contextual-menu/props.d.ts.map +1 -1
- package/dist/components/contextual-menu/style.css +63 -34
- package/dist/components/date-picker/handle.d.ts +41 -0
- package/dist/components/date-picker/handle.d.ts.map +1 -0
- package/dist/components/date-picker/handle.js +47 -0
- package/dist/components/date-picker/handle.js.map +1 -0
- package/dist/components/date-picker/main.d.ts +31 -49
- package/dist/components/date-picker/main.d.ts.map +1 -1
- package/dist/components/date-picker/main.js +373 -178
- package/dist/components/date-picker/main.js.map +1 -1
- package/dist/components/date-picker/pager.d.ts +24 -0
- package/dist/components/date-picker/pager.d.ts.map +1 -0
- package/dist/components/date-picker/pager.js +307 -0
- package/dist/components/date-picker/pager.js.map +1 -0
- package/dist/components/date-picker/props.d.ts +98 -27
- package/dist/components/date-picker/props.d.ts.map +1 -1
- package/dist/components/date-picker/style.css +110 -118
- package/dist/components/drawer/main.d.ts +31 -0
- package/dist/components/drawer/main.d.ts.map +1 -0
- package/dist/components/drawer/main.js +119 -0
- package/dist/components/drawer/main.js.map +1 -0
- package/dist/components/drawer/props.d.ts +39 -0
- package/dist/components/drawer/props.d.ts.map +1 -0
- package/dist/components/drawer/props.js +2 -0
- package/dist/components/drawer/props.js.map +1 -0
- package/dist/components/drawer/style.css +135 -0
- package/dist/components/edit-menu/main.d.ts +7 -7
- package/dist/components/edit-menu/main.d.ts.map +1 -1
- package/dist/components/edit-menu/main.js +57 -40
- package/dist/components/edit-menu/main.js.map +1 -1
- package/dist/components/edit-menu/props.d.ts +14 -1
- package/dist/components/edit-menu/props.d.ts.map +1 -1
- package/dist/components/edit-menu/style.css +15 -8
- package/dist/components/form/main.d.ts +8 -0
- package/dist/components/form/main.d.ts.map +1 -1
- package/dist/components/form/main.js +18 -5
- package/dist/components/form/main.js.map +1 -1
- package/dist/components/form/props.d.ts +1 -2
- package/dist/components/form/props.d.ts.map +1 -1
- package/dist/components/glass/main.d.ts +1 -1
- package/dist/components/glass/main.js +4 -4
- package/dist/components/glass/main.js.map +1 -1
- package/dist/components/glass/props.d.ts +5 -5
- package/dist/components/glass/props.d.ts.map +1 -1
- package/dist/components/glass/style.css +176 -161
- package/dist/components/header/main.d.ts +5 -4
- package/dist/components/header/main.d.ts.map +1 -1
- package/dist/components/header/main.js +64 -34
- package/dist/components/header/main.js.map +1 -1
- package/dist/components/header/props.d.ts +2 -3
- package/dist/components/header/props.d.ts.map +1 -1
- package/dist/components/header/style.css +46 -65
- package/dist/components/index.d.ts +27 -23
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +17 -13
- package/dist/components/index.js.map +1 -1
- package/dist/components/layout/main.d.ts +2 -2
- package/dist/components/layout/main.d.ts.map +1 -1
- package/dist/components/layout/main.js +63 -167
- package/dist/components/layout/main.js.map +1 -1
- package/dist/components/layout/props.d.ts +2 -20
- package/dist/components/layout/props.d.ts.map +1 -1
- package/dist/components/layout/style.css +20 -91
- package/dist/components/list/main.d.ts +58 -10
- package/dist/components/list/main.d.ts.map +1 -1
- package/dist/components/list/main.js +1022 -465
- package/dist/components/list/main.js.map +1 -1
- package/dist/components/list/props.d.ts +211 -21
- package/dist/components/list/props.d.ts.map +1 -1
- package/dist/components/list/reorder.d.ts +146 -0
- package/dist/components/list/reorder.d.ts.map +1 -0
- package/dist/components/list/reorder.js +819 -0
- package/dist/components/list/reorder.js.map +1 -0
- package/dist/components/list/select.d.ts +6 -0
- package/dist/components/list/select.d.ts.map +1 -0
- package/dist/components/list/select.js +141 -0
- package/dist/components/list/select.js.map +1 -0
- package/dist/components/list/style.css +492 -507
- package/dist/components/list/swipe-actions-handle.d.ts +40 -0
- package/dist/components/list/swipe-actions-handle.d.ts.map +1 -0
- package/dist/components/list/swipe-actions-handle.js +51 -0
- package/dist/components/list/swipe-actions-handle.js.map +1 -0
- package/dist/components/menu/main.d.ts +102 -32
- package/dist/components/menu/main.d.ts.map +1 -1
- package/dist/components/menu/main.js +510 -99
- package/dist/components/menu/main.js.map +1 -1
- package/dist/components/menu/props.d.ts +5 -5
- package/dist/components/menu/props.d.ts.map +1 -1
- package/dist/components/menu/style.css +35 -43
- package/dist/components/navigation/main.d.ts +14 -2
- package/dist/components/navigation/main.d.ts.map +1 -1
- package/dist/components/navigation/main.js +437 -119
- package/dist/components/navigation/main.js.map +1 -1
- package/dist/components/navigation/props.d.ts +53 -3
- package/dist/components/navigation/props.d.ts.map +1 -1
- package/dist/components/navigation/style.css +56 -9
- package/dist/components/page/main.d.ts.map +1 -1
- package/dist/components/page/main.js +13 -8
- package/dist/components/page/main.js.map +1 -1
- package/dist/components/page/props.d.ts +8 -0
- package/dist/components/page/props.d.ts.map +1 -1
- package/dist/components/page/style.css +39 -4
- package/dist/components/page-control/main.d.ts +2 -2
- package/dist/components/page-control/main.d.ts.map +1 -1
- package/dist/components/page-control/main.js +66 -32
- package/dist/components/page-control/main.js.map +1 -1
- package/dist/components/page-control/props.d.ts +10 -2
- package/dist/components/page-control/props.d.ts.map +1 -1
- package/dist/components/page-control/style.css +7 -2
- package/dist/components/popover/main.d.ts +11 -6
- package/dist/components/popover/main.d.ts.map +1 -1
- package/dist/components/popover/main.js +63 -38
- package/dist/components/popover/main.js.map +1 -1
- package/dist/components/popover/props.d.ts +7 -6
- package/dist/components/popover/props.d.ts.map +1 -1
- package/dist/components/popover/style.css +54 -4
- package/dist/components/progress/main.d.ts +2 -3
- package/dist/components/progress/main.d.ts.map +1 -1
- package/dist/components/progress/main.js +148 -29
- package/dist/components/progress/main.js.map +1 -1
- package/dist/components/progress/props.d.ts +43 -9
- package/dist/components/progress/props.d.ts.map +1 -1
- package/dist/components/progress/style.css +82 -50
- package/dist/components/roll/main.d.ts +1 -1
- package/dist/components/roll/main.d.ts.map +1 -1
- package/dist/components/roll/main.js +90 -34
- package/dist/components/roll/main.js.map +1 -1
- package/dist/components/roll/props.d.ts +25 -8
- package/dist/components/roll/props.d.ts.map +1 -1
- package/dist/components/roll/style.css +12 -24
- package/dist/components/segmented/main.d.ts.map +1 -1
- package/dist/components/segmented/main.js +47 -30
- package/dist/components/segmented/main.js.map +1 -1
- package/dist/components/segmented/style.css +16 -23
- package/dist/components/sheet/main.d.ts +25 -15
- package/dist/components/sheet/main.d.ts.map +1 -1
- package/dist/components/sheet/main.js +66 -78
- package/dist/components/sheet/main.js.map +1 -1
- package/dist/components/sheet/props.d.ts +37 -3
- package/dist/components/sheet/props.d.ts.map +1 -1
- package/dist/components/sheet/style.css +183 -45
- package/dist/components/sidebar/main.d.ts.map +1 -1
- package/dist/components/sidebar/main.js +9 -13
- package/dist/components/sidebar/main.js.map +1 -1
- package/dist/components/sidebar/style.css +20 -14
- package/dist/components/slider/main.d.ts.map +1 -1
- package/dist/components/slider/main.js +23 -22
- package/dist/components/slider/main.js.map +1 -1
- package/dist/components/slider/props.d.ts +1 -2
- package/dist/components/slider/props.d.ts.map +1 -1
- package/dist/components/slider/style.css +27 -53
- package/dist/components/stepper/main.d.ts +4 -6
- package/dist/components/stepper/main.d.ts.map +1 -1
- package/dist/components/stepper/main.js +29 -25
- package/dist/components/stepper/main.js.map +1 -1
- package/dist/components/stepper/style.css +12 -16
- package/dist/components/switch/main.d.ts.map +1 -1
- package/dist/components/switch/main.js +40 -28
- package/dist/components/switch/main.js.map +1 -1
- package/dist/components/switch/props.d.ts +7 -5
- package/dist/components/switch/props.d.ts.map +1 -1
- package/dist/components/switch/style.css +40 -17
- package/dist/components/symbol/main.d.ts +2 -2
- package/dist/components/symbol/main.d.ts.map +1 -1
- package/dist/components/symbol/main.js +36 -28
- package/dist/components/symbol/main.js.map +1 -1
- package/dist/components/symbol/props.d.ts +39 -4
- package/dist/components/symbol/props.d.ts.map +1 -1
- package/dist/components/symbol/style.css +26 -5
- package/dist/components/tab-bar/main.d.ts +2 -2
- package/dist/components/tab-bar/main.d.ts.map +1 -1
- package/dist/components/tab-bar/main.js +133 -101
- package/dist/components/tab-bar/main.js.map +1 -1
- package/dist/components/tab-bar/props.d.ts +6 -6
- package/dist/components/tab-bar/props.d.ts.map +1 -1
- package/dist/components/tab-bar/style.css +113 -99
- package/dist/components/text-field/main.d.ts +3 -2
- package/dist/components/text-field/main.d.ts.map +1 -1
- package/dist/components/text-field/main.js +29 -30
- package/dist/components/text-field/main.js.map +1 -1
- package/dist/components/text-field/props.d.ts +23 -1
- package/dist/components/text-field/props.d.ts.map +1 -1
- package/dist/components/text-field/style.css +122 -82
- package/dist/components/toolbar/main.js +27 -27
- package/dist/components/toolbar/main.js.map +1 -1
- package/dist/components/toolbar/props.d.ts +10 -4
- package/dist/components/toolbar/props.d.ts.map +1 -1
- package/dist/components/toolbar/style.css +39 -33
- package/dist/components/tooltip/main.d.ts +10 -9
- package/dist/components/tooltip/main.d.ts.map +1 -1
- package/dist/components/tooltip/main.js +39 -10
- package/dist/components/tooltip/main.js.map +1 -1
- package/dist/components/tooltip/props.d.ts +2 -0
- package/dist/components/tooltip/props.d.ts.map +1 -1
- package/dist/components/tooltip/style.css +16 -16
- package/dist/components/typography/main.d.ts +2 -2
- package/dist/components/typography/main.d.ts.map +1 -1
- package/dist/components/typography/main.js +24 -16
- package/dist/components/typography/main.js.map +1 -1
- package/dist/components/typography/props.d.ts +11 -18
- package/dist/components/typography/props.d.ts.map +1 -1
- package/dist/components/typography/style.css +503 -623
- package/dist/components/utils/main.d.ts +78 -8
- package/dist/components/utils/main.d.ts.map +1 -1
- package/dist/components/utils/main.js +235 -16
- package/dist/components/utils/main.js.map +1 -1
- package/dist/components/utils/props.d.ts +27 -4
- package/dist/components/utils/props.d.ts.map +1 -1
- package/dist/components/utils/style.css +31 -18
- package/dist/components/viewport/edge-effect.d.ts +10 -0
- package/dist/components/viewport/edge-effect.d.ts.map +1 -0
- package/dist/components/viewport/edge-effect.js +100 -0
- package/dist/components/viewport/edge-effect.js.map +1 -0
- package/dist/components/viewport/edge.d.ts +39 -0
- package/dist/components/viewport/edge.d.ts.map +1 -0
- package/dist/components/viewport/edge.js +151 -0
- package/dist/components/viewport/edge.js.map +1 -0
- package/dist/components/viewport/input.d.ts +39 -0
- package/dist/components/viewport/input.d.ts.map +1 -0
- package/dist/components/viewport/input.js +280 -0
- package/dist/components/viewport/input.js.map +1 -0
- package/dist/components/viewport/main.d.ts +47 -9
- package/dist/components/viewport/main.d.ts.map +1 -1
- package/dist/components/viewport/main.js +745 -86
- package/dist/components/viewport/main.js.map +1 -1
- package/dist/components/viewport/padding.d.ts +78 -0
- package/dist/components/viewport/padding.d.ts.map +1 -0
- package/dist/components/viewport/padding.js +321 -0
- package/dist/components/viewport/padding.js.map +1 -0
- package/dist/components/viewport/props.d.ts +220 -11
- package/dist/components/viewport/props.d.ts.map +1 -1
- package/dist/components/viewport/style.css +377 -6
- package/dist/main.d.ts +0 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js.map +1 -1
- package/dist/styles.css +318 -302
- package/dist/styles.d.ts +2 -1
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +2 -1
- package/dist/styles.js.map +1 -1
- package/package.json +8 -16
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
/* eslint-disable unicorn/prefer-ternary */
|
|
3
3
|
import './style.css';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
4
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
5
|
+
import { Children, createContext, forwardRef, isValidElement, useContext, useLayoutEffect, useRef, useState, } from 'react';
|
|
6
|
+
import { cn, useForwardedRef, withStyle } from '../utils/main.js';
|
|
7
|
+
// Navigation (after Framework7's views and
|
|
7
8
|
// `router` transitions, without its routing): a stack of pages, the app's
|
|
8
|
-
// (no router of its own). The app renders its stack's pages as
|
|
9
|
-
// each with a key; the navigation transitions between
|
|
9
|
+
// (no router of its own). The app renders its stack's pages as its
|
|
10
|
+
// `Stack`'s children, each with a key; the navigation transitions between
|
|
11
|
+
// them:
|
|
10
12
|
//
|
|
11
13
|
// - a page added on top (keys extended): pushed, sliding in from the
|
|
12
14
|
// trailing edge over the page under it, which moves on a little and dims;
|
|
@@ -15,19 +17,30 @@ import { cn, useForwardedRef } from '../utils/main.js';
|
|
|
15
17
|
// - anything else (e.g. another stack, a sibling's): shown at once, no
|
|
16
18
|
// transition.
|
|
17
19
|
//
|
|
18
|
-
// Swiping from the top page's leading edge (touch, or a
|
|
19
|
-
// interactively: released past half the width (or flung),
|
|
20
|
-
// called for the app to pop its stack
|
|
21
|
-
// otherwise it settles back.
|
|
20
|
+
// Swiping from the top page's leading edge (its `SwipeArea`: touch, or a
|
|
21
|
+
// mouse) pops it interactively: released past half the width (or flung),
|
|
22
|
+
// `onBack` is called for the app to pop its stack, its pop on from where
|
|
23
|
+
// the swipe left it; otherwise it settles back. A `Back` (e.g. a bar's back
|
|
24
|
+
// button) calls `onBack` too, the app's pop transitioning as any.
|
|
25
|
+
//
|
|
26
|
+
// Popped again while popping (e.g. a back button pressed again, or swiped
|
|
27
|
+
// again), each pop runs its own transition: the page on top leaves on its
|
|
28
|
+
// own, on from where it is, and the page it revealed starts leaving too (a
|
|
29
|
+
// cascade; swiped, by the swipe); pushed back mid-transition, the push
|
|
30
|
+
// reverses from where it is. (Not swiped while pushing.)
|
|
22
31
|
//
|
|
23
32
|
// Pages under the top one stay mounted (their state and scroll positions
|
|
24
|
-
// kept), hidden. A page's `Header`
|
|
25
|
-
//
|
|
33
|
+
// kept), hidden. A page's `Header` moves with its page, its bar too; its
|
|
34
|
+
// persistent items (e.g. its back button, see `Persistent`) stay put while
|
|
35
|
+
// the other page moving has them too. What stays regardless (e.g. a bar of
|
|
36
|
+
// the app's) is in the `Root`, outside its `Stack`.
|
|
26
37
|
//
|
|
27
|
-
//
|
|
28
|
-
// -
|
|
29
|
-
//
|
|
30
|
-
|
|
38
|
+
// Also:
|
|
39
|
+
// - Each page's bar moves with it, its title too; the back button stays, in a bar of
|
|
40
|
+
// the app's outside the stack (see above), or in each page's bar, a
|
|
41
|
+
// persistent item (see `Persistent`): staying put between pages having
|
|
42
|
+
// one, moving with a page where only it has one.
|
|
43
|
+
/** Pushing and popping (350ms, an ease-out curve). */
|
|
31
44
|
const duration = 350;
|
|
32
45
|
const easing = 'cubic-bezier(0.2, 0.9, 0.3, 1)';
|
|
33
46
|
/**
|
|
@@ -39,83 +52,372 @@ const flingWindow = 100;
|
|
|
39
52
|
const isPrefix = (shorter, longer) => shorter.length < longer.length &&
|
|
40
53
|
shorter.every((key, index) => longer[index] === key);
|
|
41
54
|
const sameKeys = (a, b) => a.length === b.length && a.every((key, index) => b[index] === key);
|
|
42
|
-
/**
|
|
43
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Its root, for its `Back`s (going back: the app's `onBack`, if it can),
|
|
57
|
+
* its `SwipeArea`s (swiping back, if it can), and its `Stack`.
|
|
58
|
+
*/
|
|
59
|
+
const NavigationContext = createContext({});
|
|
60
|
+
/**
|
|
61
|
+
* A navigation: its stack's state (see above), its parts in it (its
|
|
62
|
+
* `Stack`, a `SwipeArea`, a bar that stays).
|
|
63
|
+
*/
|
|
64
|
+
const Root = forwardRef(({ className, onBack, ...props }, forwardedRef) => {
|
|
44
65
|
const ref = useForwardedRef(forwardedRef);
|
|
45
|
-
|
|
46
|
-
const keys =
|
|
47
|
-
const previousRef = useRef({ keys, pages });
|
|
66
|
+
// Its stack's keys (reported by its `Stack`).
|
|
67
|
+
const [keys, setKeys] = useState([]);
|
|
48
68
|
const [transition, setTransition] = useState(null);
|
|
49
|
-
// The
|
|
50
|
-
const
|
|
69
|
+
// (The latest, for a swipe's pop not taken up by the app.)
|
|
70
|
+
const keysRef = useRef(keys);
|
|
71
|
+
keysRef.current = keys;
|
|
51
72
|
const timerRef = useRef(undefined);
|
|
73
|
+
const frameRef = useRef(undefined);
|
|
52
74
|
const swipeRef = useRef(undefined);
|
|
53
75
|
// The progress (and its transition), on the root.
|
|
54
|
-
const setProgress = (progress,
|
|
76
|
+
const setProgress = (progress, isAnimated) => {
|
|
55
77
|
const { current: root } = ref;
|
|
56
78
|
if (!root)
|
|
57
79
|
return;
|
|
58
|
-
root.style.transition =
|
|
80
|
+
root.style.transition = isAnimated
|
|
59
81
|
? `--uikit-navigation-progress ${String(duration)}ms ${easing}`
|
|
60
82
|
: 'none';
|
|
61
83
|
root.style.setProperty('--uikit-navigation-progress', String(progress));
|
|
84
|
+
// (Its width as a length: moved by it, persistent items stay put, see
|
|
85
|
+
// `Persistent`.)
|
|
86
|
+
root.style.setProperty('--uikit-navigation-width', `${String(root.clientWidth)}px`);
|
|
87
|
+
};
|
|
88
|
+
// An animation's next steps (see `animate`) dropped: another taking
|
|
89
|
+
// over, or a swipe.
|
|
90
|
+
const stop = () => {
|
|
91
|
+
clearTimeout(timerRef.current);
|
|
92
|
+
if (frameRef.current !== undefined) {
|
|
93
|
+
cancelAnimationFrame(frameRef.current);
|
|
94
|
+
}
|
|
95
|
+
frameRef.current = undefined;
|
|
62
96
|
};
|
|
63
97
|
// Animates the progress, then calls `done` (once it's there).
|
|
64
98
|
const animate = (from, to, done) => {
|
|
65
|
-
|
|
99
|
+
stop();
|
|
66
100
|
setProgress(from, false);
|
|
67
101
|
ref.current?.getBoundingClientRect();
|
|
68
|
-
requestAnimationFrame(() => {
|
|
102
|
+
frameRef.current = requestAnimationFrame(() => {
|
|
103
|
+
frameRef.current = undefined;
|
|
69
104
|
setProgress(to, true);
|
|
70
105
|
timerRef.current = setTimeout(done, duration + 50);
|
|
71
106
|
});
|
|
72
107
|
};
|
|
108
|
+
const currentProgress = () => {
|
|
109
|
+
const { current: root } = ref;
|
|
110
|
+
if (!root)
|
|
111
|
+
return 0;
|
|
112
|
+
return (Number.parseFloat(getComputedStyle(root).getPropertyValue('--uikit-navigation-progress')) || 0);
|
|
113
|
+
};
|
|
73
114
|
const rest = () => {
|
|
74
115
|
const { current: root } = ref;
|
|
75
116
|
root?.style.removeProperty('transition');
|
|
76
117
|
root?.style.removeProperty('--uikit-navigation-progress');
|
|
118
|
+
root?.style.removeProperty('--uikit-navigation-width');
|
|
77
119
|
setTransition(null);
|
|
78
120
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
121
|
+
useLayoutEffect(() => stop, []);
|
|
122
|
+
// At rest, or popping (the page on top leaving: swiped back further, a
|
|
123
|
+
// cascade, see `startSwipe`); not while pushing, nor swiping.
|
|
124
|
+
const canSwipe = Boolean(onBack) &&
|
|
125
|
+
keys.length > 1 &&
|
|
126
|
+
(!transition || !keys.includes(transition.top));
|
|
127
|
+
// A swipe's transition (see `canSwipe`): the top page over the one under
|
|
128
|
+
// it; while popping, the page leaving on its own (on from where it is,
|
|
129
|
+
// as `Departing`), the top page from where it was revealed to (`from`).
|
|
130
|
+
const startSwipe = (top, under) => {
|
|
131
|
+
const { current: root } = ref;
|
|
132
|
+
if (!transition?.leaving || !root)
|
|
133
|
+
return { top, under };
|
|
134
|
+
const progress = currentProgress();
|
|
135
|
+
const direction = getComputedStyle(root).direction === 'rtl' ? -1 : 1;
|
|
136
|
+
return {
|
|
137
|
+
departing: [
|
|
138
|
+
...(transition.departing ?? []),
|
|
139
|
+
{ key: transition.top, page: transition.leaving, progress },
|
|
140
|
+
],
|
|
141
|
+
from: (1 - progress) * -0.3 * root.clientWidth * direction,
|
|
142
|
+
top,
|
|
143
|
+
under,
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
// Where it's back where it started (0; started elsewhere, `from`: where
|
|
147
|
+
// the top page is shown again).
|
|
148
|
+
const shownAt = (from) => {
|
|
149
|
+
const { current: root } = ref;
|
|
150
|
+
if (!from || !root)
|
|
151
|
+
return 0;
|
|
152
|
+
const direction = getComputedStyle(root).direction === 'rtl' ? -1 : 1;
|
|
153
|
+
return from / (from - root.clientWidth * direction);
|
|
154
|
+
};
|
|
155
|
+
const endSwipe = (event) => {
|
|
156
|
+
const { current: swipe } = swipeRef;
|
|
157
|
+
if (swipe?.pointerId !== event.pointerId)
|
|
84
158
|
return;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
159
|
+
swipeRef.current = undefined;
|
|
160
|
+
// Its speed as released: over the last moves (held still: none).
|
|
161
|
+
const now = performance.now();
|
|
162
|
+
const recent = swipe.moves.find(([time]) => now - time < flingWindow);
|
|
163
|
+
const first = recent;
|
|
164
|
+
const velocity = first
|
|
165
|
+
? ((swipe.progress - first[1]) * swipe.width) /
|
|
166
|
+
Math.max(now - first[0], 1)
|
|
167
|
+
: 0;
|
|
168
|
+
const top = keys.at(-1);
|
|
169
|
+
const from = transition?.from;
|
|
170
|
+
if (event.type !== 'pointercancel' &&
|
|
171
|
+
(swipe.progress > 0.5 || velocity > flingVelocity)) {
|
|
172
|
+
// Popped: on, the app's pop taking over (see `changeKeys`, from
|
|
173
|
+
// where it is); not popped by the app after all, back.
|
|
174
|
+
animate(swipe.progress, 1, () => {
|
|
175
|
+
if (top === undefined || !keysRef.current.includes(top))
|
|
176
|
+
return;
|
|
177
|
+
animate(1, shownAt(from), rest);
|
|
178
|
+
});
|
|
179
|
+
onBack?.({ event, reason: 'swipe' });
|
|
89
180
|
return;
|
|
90
181
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
182
|
+
animate(swipe.progress, shownAt(from), rest);
|
|
183
|
+
};
|
|
184
|
+
const back = onBack && keys.length > 1
|
|
185
|
+
? (eventDetails) => onBack(eventDetails)
|
|
186
|
+
: undefined;
|
|
187
|
+
// Where a swipe back starts (see `SwipeArea`): while one can, or goes on.
|
|
188
|
+
const swipeHandlers = canSwipe || swipeRef.current
|
|
189
|
+
? {
|
|
190
|
+
onLostPointerCapture: endSwipe,
|
|
191
|
+
onPointerCancel: endSwipe,
|
|
192
|
+
onPointerUp: endSwipe,
|
|
193
|
+
onPointerDown: (event) => {
|
|
194
|
+
const { current: root } = ref;
|
|
195
|
+
const top = keys.at(-1);
|
|
196
|
+
const under = keys.at(-2);
|
|
197
|
+
if (!root || !top || !under || event.button !== 0)
|
|
198
|
+
return;
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
201
|
+
const next = startSwipe(top, under);
|
|
202
|
+
// (The pop it interrupts: its pages on as `next` has them.)
|
|
203
|
+
stop();
|
|
204
|
+
swipeRef.current = {
|
|
205
|
+
pointerId: event.pointerId,
|
|
206
|
+
moves: [[performance.now(), 0]],
|
|
207
|
+
progress: 0,
|
|
208
|
+
width: root.clientWidth,
|
|
209
|
+
x: event.clientX,
|
|
210
|
+
};
|
|
211
|
+
setProgress(0, false);
|
|
212
|
+
setTransition(next);
|
|
213
|
+
},
|
|
214
|
+
onPointerMove: (event) => {
|
|
215
|
+
const { current: swipe } = swipeRef;
|
|
216
|
+
const { current: root } = ref;
|
|
217
|
+
if (swipe?.pointerId !== event.pointerId || !root)
|
|
218
|
+
return;
|
|
219
|
+
const direction = getComputedStyle(root).direction === 'rtl' ? -1 : 1;
|
|
220
|
+
const moved = (event.clientX - swipe.x) * direction;
|
|
221
|
+
swipe.progress = Math.min(Math.max(moved / swipe.width, 0), 1);
|
|
222
|
+
swipe.moves = [
|
|
223
|
+
...swipe.moves.slice(-8),
|
|
224
|
+
[performance.now(), swipe.progress],
|
|
225
|
+
];
|
|
226
|
+
setProgress(swipe.progress, false);
|
|
227
|
+
},
|
|
228
|
+
}
|
|
229
|
+
: undefined;
|
|
230
|
+
return (_jsx(NavigationContext.Provider, { value: {
|
|
231
|
+
back,
|
|
232
|
+
stack: {
|
|
233
|
+
animate,
|
|
234
|
+
progress: currentProgress,
|
|
235
|
+
rest,
|
|
236
|
+
setKeys,
|
|
237
|
+
setTransition,
|
|
238
|
+
transition,
|
|
239
|
+
},
|
|
240
|
+
swipe: swipeHandlers,
|
|
241
|
+
}, children: _jsx("div", { ref: ref, "data-navigation-moving": transition ? '' : undefined, "data-navigation-part": "root", ...props, className: cn('uikit-navigation-root', className) }) }));
|
|
242
|
+
});
|
|
243
|
+
/**
|
|
244
|
+
* A stack's keys changed (`previous` to `keys`, its tops differing): pushed,
|
|
245
|
+
* popped (also mid-transition, see `Stack`), or anything else (at rest).
|
|
246
|
+
*/
|
|
247
|
+
const changeKeys = (stack, previous, keys, element) => {
|
|
248
|
+
const oldTop = previous.keys.at(-1) ?? '';
|
|
249
|
+
const newTop = keys.at(-1) ?? '';
|
|
250
|
+
// Mid-transition (e.g. a back button pressed again): on from where it
|
|
251
|
+
// is, the page on top still leaving (popped further: the new top under
|
|
252
|
+
// it, those between gone) or coming back (pushed again).
|
|
253
|
+
const running = stack.transition;
|
|
254
|
+
if (isPrefix(keys, previous.keys)) {
|
|
255
|
+
if (running?.top === oldTop) {
|
|
256
|
+
// Its push reversed (or its swipe popped), from where it is.
|
|
257
|
+
stack.setTransition({
|
|
258
|
+
departing: running.departing,
|
|
259
|
+
from: running.from,
|
|
260
|
+
leaving: previous.pages.at(-1),
|
|
261
|
+
top: oldTop,
|
|
262
|
+
under: newTop,
|
|
263
|
+
});
|
|
264
|
+
stack.animate(stack.progress(), 1, stack.rest);
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (running && !keys.includes(running.top)) {
|
|
268
|
+
// Popped further while popping: the page on top leaving on its own
|
|
269
|
+
// (on from where it is, see `Departing`), the one it revealed
|
|
270
|
+
// leaving too, from where it was revealed to, the new top under
|
|
271
|
+
// it (a cascade, each press its own).
|
|
272
|
+
const progress = stack.progress();
|
|
273
|
+
const width = element?.clientWidth ?? 0;
|
|
274
|
+
const direction = element && getComputedStyle(element).direction === 'rtl' ? -1 : 1;
|
|
275
|
+
const leavingPage = running.leaving ??
|
|
276
|
+
previous.pages.find((page) => String(page.key) === running.top);
|
|
277
|
+
stack.setTransition({
|
|
278
|
+
departing: [
|
|
279
|
+
...(running.departing ?? []),
|
|
280
|
+
...(leavingPage
|
|
281
|
+
? [{ key: running.top, page: leavingPage, progress }]
|
|
282
|
+
: []),
|
|
283
|
+
],
|
|
284
|
+
from: (1 - progress) * -0.3 * width * direction,
|
|
99
285
|
leaving: previous.pages.at(-1),
|
|
100
286
|
top: oldTop,
|
|
101
287
|
under: newTop,
|
|
102
288
|
});
|
|
103
|
-
animate(0, 1, rest);
|
|
289
|
+
stack.animate(0, 1, stack.rest);
|
|
104
290
|
return;
|
|
105
291
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
292
|
+
stack.setTransition({
|
|
293
|
+
leaving: previous.pages.at(-1),
|
|
294
|
+
top: oldTop,
|
|
295
|
+
under: newTop,
|
|
296
|
+
});
|
|
297
|
+
stack.animate(0, 1, stack.rest);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (isPrefix(previous.keys, keys)) {
|
|
301
|
+
const isBack = running?.top === newTop;
|
|
302
|
+
stack.setTransition({ top: newTop, under: oldTop });
|
|
303
|
+
stack.animate(isBack ? stack.progress() : 1, 0, stack.rest);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
stack.rest();
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Its stack of pages (keyed children, see above), filling its root: pushed,
|
|
310
|
+
* popped, or replaced as the app's keys change.
|
|
311
|
+
*/
|
|
312
|
+
const Stack = forwardRef(({ className, children, ...props }, forwardedRef) => {
|
|
313
|
+
const ref = useForwardedRef(forwardedRef);
|
|
314
|
+
const { stack } = useContext(NavigationContext);
|
|
315
|
+
const pages = Children.toArray(children).filter((child) => isValidElement(child));
|
|
316
|
+
const keys = pages.map((page) => String(page.key));
|
|
317
|
+
const previousRef = useRef({ keys, pages });
|
|
318
|
+
const transition = stack?.transition ?? null;
|
|
319
|
+
// Pushed, popped, or replaced (see above).
|
|
320
|
+
useLayoutEffect(() => {
|
|
321
|
+
stack?.setKeys(keys);
|
|
322
|
+
const { current: previous } = previousRef;
|
|
323
|
+
previousRef.current = { keys, pages };
|
|
324
|
+
if (!stack || sameKeys(previous.keys, keys))
|
|
325
|
+
return;
|
|
326
|
+
const oldTop = previous.keys.at(-1);
|
|
327
|
+
const newTop = keys.at(-1);
|
|
328
|
+
if (oldTop === undefined || newTop === undefined || oldTop === newTop) {
|
|
329
|
+
stack.rest();
|
|
109
330
|
return;
|
|
110
331
|
}
|
|
111
|
-
|
|
332
|
+
changeKeys(stack, previous, keys, ref.current);
|
|
112
333
|
// (On a change of the stack's keys only, compared above.)
|
|
113
334
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
114
335
|
}, [keys.join('\n')]);
|
|
115
|
-
|
|
336
|
+
const departing = transition?.departing ?? [];
|
|
337
|
+
// Pages still leaving on their own (see above): each on from its
|
|
338
|
+
// progress as it was handed over, to gone (its own progress, over the
|
|
339
|
+
// root's).
|
|
340
|
+
const departedRef = useRef(new Set());
|
|
341
|
+
useLayoutEffect(() => {
|
|
342
|
+
const { current: element } = ref;
|
|
343
|
+
const { current: departed } = departedRef;
|
|
344
|
+
if (!transition)
|
|
345
|
+
departed.clear();
|
|
346
|
+
if (!element)
|
|
347
|
+
return;
|
|
348
|
+
for (const { key, progress } of departing) {
|
|
349
|
+
if (departed.has(key))
|
|
350
|
+
continue;
|
|
351
|
+
const frame = element.querySelector(`:scope > [data-navigation-key="${CSS.escape(key)}"]`);
|
|
352
|
+
if (!frame)
|
|
353
|
+
continue;
|
|
354
|
+
departed.add(key);
|
|
355
|
+
frame.animate([
|
|
356
|
+
{ '--uikit-navigation-progress': String(progress) },
|
|
357
|
+
{ '--uikit-navigation-progress': '1' },
|
|
358
|
+
], { duration, easing, fill: 'forwards' });
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
// In a transition, the persistent items several moving pages have (by
|
|
362
|
+
// their ids, see `Persistent`): shared, staying put (see style.css); the
|
|
363
|
+
// uppermost page's shown, still pressable (e.g. its back button pressed
|
|
364
|
+
// again: further back, see above), its page not inert.
|
|
365
|
+
const [pressable, setPressable] = useState(undefined);
|
|
366
|
+
useLayoutEffect(() => {
|
|
367
|
+
const { current: element } = ref;
|
|
368
|
+
if (!element || !transition) {
|
|
369
|
+
setPressable(undefined);
|
|
370
|
+
return undefined;
|
|
371
|
+
}
|
|
372
|
+
// The moving pages, uppermost first: those leaving on their own (the
|
|
373
|
+
// earliest above), the top, the one under it.
|
|
374
|
+
const frames = [
|
|
375
|
+
...(transition.departing ?? []).map(({ key }) => key),
|
|
376
|
+
transition.top,
|
|
377
|
+
transition.under,
|
|
378
|
+
]
|
|
379
|
+
.map((key) => element.querySelector(`:scope > [data-navigation-key="${CSS.escape(key)}"]`))
|
|
380
|
+
.filter((frame) => frame !== null);
|
|
381
|
+
const itemsOf = (frame) => [
|
|
382
|
+
...frame.querySelectorAll('[data-navigation-persistent]'),
|
|
383
|
+
];
|
|
384
|
+
const counts = new Map();
|
|
385
|
+
for (const frame of frames) {
|
|
386
|
+
for (const id of new Set(itemsOf(frame).map((item) => item.dataset.navigationPersistent))) {
|
|
387
|
+
counts.set(id, (counts.get(id) ?? 0) + 1);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const shown = new Set();
|
|
391
|
+
const marked = [];
|
|
392
|
+
let uppermost;
|
|
393
|
+
for (const frame of frames) {
|
|
394
|
+
for (const item of itemsOf(frame)) {
|
|
395
|
+
const id = item.dataset.navigationPersistent;
|
|
396
|
+
if ((counts.get(id) ?? 0) < 2)
|
|
397
|
+
continue;
|
|
398
|
+
item.dataset.navigationShared = '';
|
|
399
|
+
if (shown.has(id)) {
|
|
400
|
+
item.dataset.navigationSharedHidden = '';
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
shown.add(id);
|
|
404
|
+
uppermost ??= frame.dataset.navigationKey;
|
|
405
|
+
}
|
|
406
|
+
marked.push(item);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
setPressable(uppermost);
|
|
410
|
+
return () => {
|
|
411
|
+
for (const item of marked) {
|
|
412
|
+
delete item.dataset.navigationShared;
|
|
413
|
+
delete item.dataset.navigationSharedHidden;
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
}, [ref, transition]);
|
|
116
417
|
const roleOf = (key, index, count) => {
|
|
117
418
|
if (transition) {
|
|
118
|
-
|
|
419
|
+
const isLeaving = departing.some((entry) => entry.key === key);
|
|
420
|
+
if (isLeaving || key === transition.top)
|
|
119
421
|
return 'top';
|
|
120
422
|
if (key === transition.under)
|
|
121
423
|
return 'under';
|
|
@@ -126,76 +428,92 @@ const Root = forwardRef(({ className, children, onBack, ...props }, forwardedRef
|
|
|
126
428
|
const leaving = transition?.leaving && !keys.includes(transition.top)
|
|
127
429
|
? [transition.leaving]
|
|
128
430
|
: [];
|
|
129
|
-
const shown = [
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (swipedRef.current !== top)
|
|
153
|
-
return;
|
|
154
|
-
swipedRef.current = undefined;
|
|
155
|
-
animate(1, 0, rest);
|
|
156
|
-
}, 1000);
|
|
157
|
-
});
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
animate(swipe.progress, 0, rest);
|
|
161
|
-
};
|
|
162
|
-
return (_jsxs("div", { ref: ref, "data-navigation-moving": transition ? '' : undefined, "data-navigation-part": "root", ...props, className: cn('uikit-navigation-root', className), children: [shown.map((page, index) => {
|
|
163
|
-
const key = String(page.key);
|
|
164
|
-
const role = roleOf(key, index, shown.length);
|
|
165
|
-
return (_jsx("div", { "aria-hidden": role === 'current' ? undefined : true, className: "uikit-navigation-frame", "data-navigation-part": "page", "data-navigation-role": role, inert: role !== 'current', children: page }, key));
|
|
166
|
-
}), canSwipe || swipeRef.current ? (_jsx("div", { className: "uikit-navigation-edge", "data-navigation-part": "edge", onLostPointerCapture: endSwipe, onPointerCancel: endSwipe, onPointerUp: endSwipe, onPointerDown: (event) => {
|
|
167
|
-
const { current: root } = ref;
|
|
168
|
-
const top = keys.at(-1);
|
|
169
|
-
const under = keys.at(-2);
|
|
170
|
-
if (!root || !top || !under || event.button !== 0)
|
|
171
|
-
return;
|
|
172
|
-
event.preventDefault();
|
|
173
|
-
event.currentTarget.setPointerCapture(event.pointerId);
|
|
174
|
-
swipeRef.current = {
|
|
175
|
-
pointerId: event.pointerId,
|
|
176
|
-
moves: [[performance.now(), 0]],
|
|
177
|
-
progress: 0,
|
|
178
|
-
width: root.clientWidth,
|
|
179
|
-
x: event.clientX,
|
|
180
|
-
};
|
|
181
|
-
setProgress(0, false);
|
|
182
|
-
setTransition({ top, under });
|
|
183
|
-
}, onPointerMove: (event) => {
|
|
184
|
-
const { current: swipe } = swipeRef;
|
|
185
|
-
const { current: root } = ref;
|
|
186
|
-
if (swipe?.pointerId !== event.pointerId || !root)
|
|
187
|
-
return;
|
|
188
|
-
const direction = getComputedStyle(root).direction === 'rtl' ? -1 : 1;
|
|
189
|
-
const moved = (event.clientX - swipe.x) * direction;
|
|
190
|
-
swipe.progress = Math.min(Math.max(moved / swipe.width, 0), 1);
|
|
191
|
-
swipe.moves = [
|
|
192
|
-
...swipe.moves.slice(-8),
|
|
193
|
-
[performance.now(), swipe.progress],
|
|
194
|
-
];
|
|
195
|
-
setProgress(swipe.progress, false);
|
|
196
|
-
} })) : null] }));
|
|
431
|
+
const shown = [
|
|
432
|
+
...pages,
|
|
433
|
+
...leaving,
|
|
434
|
+
...departing
|
|
435
|
+
.filter(({ key }) => !keys.includes(key) && key !== transition?.top)
|
|
436
|
+
.map(({ page }) => page),
|
|
437
|
+
];
|
|
438
|
+
return (_jsx("div", { ref: ref, "data-navigation-part": "stack", ...props, className: cn('uikit-navigation-stack', className), children: shown.map((page, index) => {
|
|
439
|
+
const key = String(page.key);
|
|
440
|
+
const role = roleOf(key, index, shown.length);
|
|
441
|
+
const isInert = role !== 'current' && key !== pressable;
|
|
442
|
+
const departingIndex = departing.findIndex((entry) => entry.key === key);
|
|
443
|
+
return (_jsx("div", { "aria-hidden": isInert ? true : undefined, className: "uikit-navigation-frame", "data-navigation-departing": departingIndex === -1 ? undefined : '', "data-navigation-key": key, "data-navigation-part": "page", "data-navigation-role": role, inert: isInert, style: {
|
|
444
|
+
// Leaving on their own: above the top page, the earliest
|
|
445
|
+
// uppermost; the top page from where it was (see `from`).
|
|
446
|
+
zIndex: departingIndex === -1
|
|
447
|
+
? undefined
|
|
448
|
+
: 2 + departing.length - departingIndex,
|
|
449
|
+
'--uikit-navigation-from': key === transition?.top && transition.from !== undefined
|
|
450
|
+
? `${String(transition.from)}px`
|
|
451
|
+
: undefined,
|
|
452
|
+
}, children: page }, key));
|
|
453
|
+
}) }));
|
|
197
454
|
});
|
|
455
|
+
/**
|
|
456
|
+
* Where a swipe back starts (touch, or a mouse): a strip at the leading
|
|
457
|
+
* edge (`width`, 20px), over the pages, while there's a page to go back to
|
|
458
|
+
* (and an `onBack`); in its `Root`. Without one, pages aren't swiped back.
|
|
459
|
+
* Its swipes are its own: nothing scrolls meanwhile (`touch-action`), and
|
|
460
|
+
* a sheet around it isn't swiped along (Base UI's swipe ignore).
|
|
461
|
+
*/
|
|
462
|
+
const SwipeArea = forwardRef(({ className, style, width = 20, ...props }, ref) => {
|
|
463
|
+
const { swipe } = useContext(NavigationContext);
|
|
464
|
+
if (!swipe)
|
|
465
|
+
return null;
|
|
466
|
+
return (_jsx("div", { ref: ref, "data-base-ui-swipe-ignore": "", "data-navigation-part": "swipe-area", style: withStyle({ '--uikit-navigation-swipe-area-width': `${String(width)}px` }, style), ...props, ...swipe, className: cn('uikit-navigation-swipe-area', className) }));
|
|
467
|
+
});
|
|
468
|
+
/**
|
|
469
|
+
* A button taking its navigation back (its `onBack`, the app popping its
|
|
470
|
+
* stack), e.g. a bar's back button (`render`: a `Toolbar.Button`); on the
|
|
471
|
+
* root page (nothing to go back to), disabled.
|
|
472
|
+
*/
|
|
473
|
+
const Back = forwardRef(({ disabled, onClick, persistentId = 'back', render, ...props }, ref) => {
|
|
474
|
+
const { back } = useContext(NavigationContext);
|
|
475
|
+
return useRender({
|
|
476
|
+
defaultTagName: 'button',
|
|
477
|
+
props: {
|
|
478
|
+
'data-navigation-part': 'back',
|
|
479
|
+
'data-navigation-persistent': persistentId || undefined,
|
|
480
|
+
disabled: disabled ?? !back,
|
|
481
|
+
type: 'button',
|
|
482
|
+
...props,
|
|
483
|
+
onClick: (event) => {
|
|
484
|
+
onClick?.(event);
|
|
485
|
+
if (event.defaultPrevented)
|
|
486
|
+
return;
|
|
487
|
+
back?.({ event, reason: 'back-press' });
|
|
488
|
+
},
|
|
489
|
+
},
|
|
490
|
+
ref,
|
|
491
|
+
render,
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
/**
|
|
495
|
+
* An item of a page's bar (e.g. a toolbar button, `render`) that stays put
|
|
496
|
+
* through a transition while both pages moving have one of its id
|
|
497
|
+
* (`persistentId`), the upper page's shown; otherwise moving with its page.
|
|
498
|
+
* E.g. a back button (`Back` is one, by default): sliding in with the first
|
|
499
|
+
* page to have one, staying put on to deeper pages and back, sliding out
|
|
500
|
+
* with the first again.
|
|
501
|
+
*/
|
|
502
|
+
const Persistent = forwardRef(({ persistentId, render, ...props }, ref) => useRender({
|
|
503
|
+
defaultTagName: 'div',
|
|
504
|
+
props: {
|
|
505
|
+
'data-navigation-part': 'persistent',
|
|
506
|
+
'data-navigation-persistent': persistentId,
|
|
507
|
+
...props,
|
|
508
|
+
},
|
|
509
|
+
ref,
|
|
510
|
+
render,
|
|
511
|
+
}));
|
|
198
512
|
export const Navigation = {
|
|
199
513
|
Root,
|
|
514
|
+
Stack,
|
|
515
|
+
SwipeArea,
|
|
516
|
+
Back,
|
|
517
|
+
Persistent,
|
|
200
518
|
};
|
|
201
519
|
//# sourceMappingURL=main.js.map
|