@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
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
// iOS' WebKit (iPhone, iPad) zooms the page in as a text field with a font
|
|
3
|
+
// smaller than 16px is focused, and scrolls the layout viewport to keep a
|
|
4
|
+
// field it focuses clear of the keyboard (shifting a fixed layout, e.g. a
|
|
5
|
+
// `Viewport`'s bars). Two guards against them, each also a hook (made, and
|
|
6
|
+
// let go of, with the component); elsewhere, they do nothing. A third
|
|
7
|
+
// keeps a held press from selecting text (and showing the browser's text
|
|
8
|
+
// menu), e.g. on a menu's trigger.
|
|
9
|
+
/** Whether this is iOS' WebKit (the touch callout: iOS only). */
|
|
10
|
+
const isIos = () => typeof CSS !== 'undefined' && CSS.supports('-webkit-touch-callout', 'none');
|
|
11
|
+
/** Nothing to let go of (a guard that didn't apply). */
|
|
12
|
+
const noop = () => undefined;
|
|
13
|
+
/** Holds of the zoom guard, and the viewport's content before the first. */
|
|
14
|
+
let zoomHolds = 0;
|
|
15
|
+
let zoomRestore;
|
|
16
|
+
/** A viewport's content, its largest scale 1 (other entries kept). */
|
|
17
|
+
const withMaximumScale = (content) => [
|
|
18
|
+
...content
|
|
19
|
+
.split(',')
|
|
20
|
+
.map((entry) => entry.trim())
|
|
21
|
+
.filter((entry) => entry !== '' && !entry.startsWith('maximum-scale')),
|
|
22
|
+
'maximum-scale=1',
|
|
23
|
+
].join(', ');
|
|
24
|
+
/**
|
|
25
|
+
* iOS: no zoom as a text field is focused (the viewport's `maximum-scale`
|
|
26
|
+
* 1; iOS still lets the page be pinch-zoomed). Held until the returned
|
|
27
|
+
* function lets go of it (the viewport's content restored with the last).
|
|
28
|
+
*/
|
|
29
|
+
export const preventInputZoom = () => {
|
|
30
|
+
const meta = isIos()
|
|
31
|
+
? document.querySelector('meta[name=viewport]')
|
|
32
|
+
: null;
|
|
33
|
+
if (!meta)
|
|
34
|
+
return noop;
|
|
35
|
+
if (zoomHolds === 0) {
|
|
36
|
+
zoomRestore = meta.content;
|
|
37
|
+
meta.content = withMaximumScale(meta.content);
|
|
38
|
+
}
|
|
39
|
+
zoomHolds += 1;
|
|
40
|
+
let isHeld = true;
|
|
41
|
+
return () => {
|
|
42
|
+
if (!isHeld)
|
|
43
|
+
return;
|
|
44
|
+
isHeld = false;
|
|
45
|
+
zoomHolds -= 1;
|
|
46
|
+
if (zoomHolds === 0 && zoomRestore !== undefined) {
|
|
47
|
+
meta.content = zoomRestore;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
/** `preventInputZoom`, while the component is mounted (and `enabled`). */
|
|
52
|
+
export const useInputZoomPrevention = (isEnabled = true) => {
|
|
53
|
+
useEffect(() => (isEnabled ? preventInputZoom() : undefined), [isEnabled]);
|
|
54
|
+
};
|
|
55
|
+
/** What the keyboard edits text in (not buttons, boxes, pickers or files). */
|
|
56
|
+
const textField = [
|
|
57
|
+
'input:not([type=button], [type=checkbox], [type=color], [type=file], [type=hidden], [type=image], [type=radio], [type=range], [type=reset], [type=submit])',
|
|
58
|
+
'textarea',
|
|
59
|
+
'[contenteditable]:not([contenteditable=false])',
|
|
60
|
+
].join(', ');
|
|
61
|
+
/** What a touch activates itself (not a text field near it, see below). */
|
|
62
|
+
const control = [
|
|
63
|
+
'a[href]',
|
|
64
|
+
'button',
|
|
65
|
+
'input',
|
|
66
|
+
'select',
|
|
67
|
+
'textarea',
|
|
68
|
+
'[contenteditable]:not([contenteditable=false])',
|
|
69
|
+
'[role=button]',
|
|
70
|
+
'[role=link]',
|
|
71
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
72
|
+
].join(', ');
|
|
73
|
+
/**
|
|
74
|
+
* How far from a text field a touch still focuses it (px): iOS adjusts a
|
|
75
|
+
* touch to the control nearest it, within about a finger's width.
|
|
76
|
+
*/
|
|
77
|
+
const touchReach = 24;
|
|
78
|
+
/** How far a tap's touch may move (px; farther, it's a drag). */
|
|
79
|
+
const tapSlop = 10;
|
|
80
|
+
/** The distance from a point to a rect (0 within it). */
|
|
81
|
+
const distance = (x, y, rect) => Math.hypot(Math.max(rect.left - x, 0, x - rect.right), Math.max(rect.top - y, 0, y - rect.bottom));
|
|
82
|
+
/**
|
|
83
|
+
* The text field a touch focuses: the one touched (or within it), a
|
|
84
|
+
* label's, or, touching no control, the nearest within reach (iOS
|
|
85
|
+
* adjusting the touch to it).
|
|
86
|
+
*/
|
|
87
|
+
const touchedField = (event, root) => {
|
|
88
|
+
const { target } = event;
|
|
89
|
+
if (!(target instanceof Element))
|
|
90
|
+
return null;
|
|
91
|
+
const field = target.closest(textField);
|
|
92
|
+
if (field)
|
|
93
|
+
return field;
|
|
94
|
+
const labelled = target.closest('label')?.control;
|
|
95
|
+
if (labelled) {
|
|
96
|
+
return labelled.matches(textField) ? labelled : null;
|
|
97
|
+
}
|
|
98
|
+
const touch = event.changedTouches[0];
|
|
99
|
+
if (!touch || target.closest(control))
|
|
100
|
+
return null;
|
|
101
|
+
const { clientX: x, clientY: y } = touch;
|
|
102
|
+
let nearest = null;
|
|
103
|
+
let nearestDistance = touchReach;
|
|
104
|
+
for (const candidate of root.querySelectorAll(textField)) {
|
|
105
|
+
const candidateDistance = distance(x, y, candidate.getBoundingClientRect());
|
|
106
|
+
if (!(candidateDistance <= nearestDistance)) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
nearest = candidate;
|
|
110
|
+
nearestDistance = candidateDistance;
|
|
111
|
+
}
|
|
112
|
+
return nearest;
|
|
113
|
+
};
|
|
114
|
+
/** The layout viewport scrolled back to `scroll` (see `preventFocusShift`). */
|
|
115
|
+
const restoreScroll = (scroll) => {
|
|
116
|
+
if (Math.abs(window.scrollY - scroll) >= 1)
|
|
117
|
+
window.scrollTo(0, scroll);
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* iOS: a text field touched in `target` focused without scrolling (its
|
|
121
|
+
* touch's end: the field focused, `preventScroll`, instead of the
|
|
122
|
+
* browser's focusing, which scrolls the layout viewport); also touched
|
|
123
|
+
* just beside it (see `touchedField`). The touch's click doesn't follow,
|
|
124
|
+
* and the caret goes where the field puts it, not where it was touched.
|
|
125
|
+
* The page hidden with one focused and shown again (e.g. a Home Screen app
|
|
126
|
+
* left and reopened), it's focused again without scrolling, the layout
|
|
127
|
+
* viewport's scroll as it was. Until the returned function removes it.
|
|
128
|
+
*/
|
|
129
|
+
export const preventFocusShift = (target = document) => {
|
|
130
|
+
if (!isIos())
|
|
131
|
+
return noop;
|
|
132
|
+
// Where the touch started: a tap's (not a drag's, e.g. scrolling) end
|
|
133
|
+
// focuses.
|
|
134
|
+
let start;
|
|
135
|
+
const onTouchStart = (event) => {
|
|
136
|
+
start =
|
|
137
|
+
event.touches.length === 1
|
|
138
|
+
? event.touches[0]
|
|
139
|
+
: undefined;
|
|
140
|
+
};
|
|
141
|
+
const onTouchEnd = (event) => {
|
|
142
|
+
const end = event.changedTouches[0];
|
|
143
|
+
const isTap = start !== undefined &&
|
|
144
|
+
end !== undefined &&
|
|
145
|
+
Math.hypot(end.clientX - start.clientX, end.clientY - start.clientY) <=
|
|
146
|
+
tapSlop;
|
|
147
|
+
start = undefined;
|
|
148
|
+
const field = isTap ? touchedField(event, target) : null;
|
|
149
|
+
if (!field ||
|
|
150
|
+
field === document.activeElement ||
|
|
151
|
+
field.matches(':disabled') ||
|
|
152
|
+
!event.cancelable) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
field.focus({ preventScroll: true });
|
|
157
|
+
};
|
|
158
|
+
// The page hidden with a text field focused in `target` (e.g. a Home
|
|
159
|
+
// Screen app left with the keyboard shown): that field, its selection
|
|
160
|
+
// and the layout viewport's scroll. Shown again, iOS may focus it anew
|
|
161
|
+
// itself, scrolling (or drop the keyboard): it's focused again here
|
|
162
|
+
// without scrolling (its selection as it was), the scroll put back, also
|
|
163
|
+
// a frame and a moment later (iOS' scrolling may follow).
|
|
164
|
+
let hidden;
|
|
165
|
+
let restores = [];
|
|
166
|
+
const onVisibility = () => {
|
|
167
|
+
for (const restore of restores)
|
|
168
|
+
clearTimeout(restore);
|
|
169
|
+
restores = [];
|
|
170
|
+
if (document.visibilityState === 'hidden') {
|
|
171
|
+
const { activeElement } = document;
|
|
172
|
+
hidden =
|
|
173
|
+
activeElement instanceof HTMLElement &&
|
|
174
|
+
activeElement.matches(textField) &&
|
|
175
|
+
target.contains(activeElement)
|
|
176
|
+
? {
|
|
177
|
+
field: activeElement,
|
|
178
|
+
scroll: window.scrollY,
|
|
179
|
+
selection: activeElement instanceof HTMLInputElement ||
|
|
180
|
+
activeElement instanceof HTMLTextAreaElement
|
|
181
|
+
? [activeElement.selectionStart, activeElement.selectionEnd]
|
|
182
|
+
: undefined,
|
|
183
|
+
}
|
|
184
|
+
: undefined;
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (!hidden)
|
|
188
|
+
return;
|
|
189
|
+
const { field, scroll, selection } = hidden;
|
|
190
|
+
hidden = undefined;
|
|
191
|
+
if (!field.isConnected || field.matches(':disabled'))
|
|
192
|
+
return;
|
|
193
|
+
if (field === document.activeElement)
|
|
194
|
+
field.blur();
|
|
195
|
+
field.focus({ preventScroll: true });
|
|
196
|
+
if (selection &&
|
|
197
|
+
(field instanceof HTMLInputElement ||
|
|
198
|
+
field instanceof HTMLTextAreaElement)) {
|
|
199
|
+
try {
|
|
200
|
+
field.setSelectionRange(...selection);
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
// (Fields without a selection, e.g. `type="email"`.)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
restoreScroll(scroll);
|
|
207
|
+
requestAnimationFrame(() => restoreScroll(scroll));
|
|
208
|
+
restores = [100, 300].map((delay) => setTimeout(() => restoreScroll(scroll), delay));
|
|
209
|
+
};
|
|
210
|
+
const listeners = [
|
|
211
|
+
['touchstart', onTouchStart],
|
|
212
|
+
['touchend', onTouchEnd],
|
|
213
|
+
];
|
|
214
|
+
for (const [type, listener] of listeners) {
|
|
215
|
+
target.addEventListener(type, listener, { capture: true, passive: false });
|
|
216
|
+
}
|
|
217
|
+
document.addEventListener('visibilitychange', onVisibility);
|
|
218
|
+
return () => {
|
|
219
|
+
for (const [type, listener] of listeners) {
|
|
220
|
+
target.removeEventListener(type, listener, { capture: true });
|
|
221
|
+
}
|
|
222
|
+
document.removeEventListener('visibilitychange', onVisibility);
|
|
223
|
+
for (const restore of restores)
|
|
224
|
+
clearTimeout(restore);
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* `preventFocusShift`, in `target` (or the document), while the component
|
|
229
|
+
* is mounted (and `enabled`).
|
|
230
|
+
*/
|
|
231
|
+
export const useFocusShiftPrevention = (target, isEnabled = true) => {
|
|
232
|
+
useEffect(() => isEnabled ? preventFocusShift(target?.current ?? document) : undefined, [isEnabled, target]);
|
|
233
|
+
};
|
|
234
|
+
/** The properties `preventTextActions` sets (to `none`). */
|
|
235
|
+
const textActionProperties = [
|
|
236
|
+
'-webkit-touch-callout',
|
|
237
|
+
'-webkit-user-select',
|
|
238
|
+
'user-select',
|
|
239
|
+
];
|
|
240
|
+
/**
|
|
241
|
+
* A held press in `target` (e.g. a menu's trigger opened by it, its
|
|
242
|
+
* `openOn="secondaryClick"`) selects no text in it and shows no callout
|
|
243
|
+
* nor the browser's own text menu (iOS: its `user-select` and
|
|
244
|
+
* `-webkit-touch-callout`, `none`). Until the returned function restores
|
|
245
|
+
* them. (An app's choice: the text may well stay selectable.)
|
|
246
|
+
*/
|
|
247
|
+
export const preventTextActions = (target) => {
|
|
248
|
+
const { style } = target;
|
|
249
|
+
const previous = textActionProperties.map((property) => [
|
|
250
|
+
property,
|
|
251
|
+
style.getPropertyValue(property),
|
|
252
|
+
style.getPropertyPriority(property),
|
|
253
|
+
]);
|
|
254
|
+
for (const property of textActionProperties) {
|
|
255
|
+
style.setProperty(property, 'none');
|
|
256
|
+
}
|
|
257
|
+
let isHeld = true;
|
|
258
|
+
return () => {
|
|
259
|
+
if (!isHeld)
|
|
260
|
+
return;
|
|
261
|
+
isHeld = false;
|
|
262
|
+
for (const [property, value, priority] of previous) {
|
|
263
|
+
if (value)
|
|
264
|
+
style.setProperty(property, value, priority);
|
|
265
|
+
else
|
|
266
|
+
style.removeProperty(property);
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* `preventTextActions` on `target`, while the component is mounted (and
|
|
272
|
+
* `enabled`).
|
|
273
|
+
*/
|
|
274
|
+
export const useTextActionsPrevention = (target, isEnabled = true) => {
|
|
275
|
+
useEffect(() => {
|
|
276
|
+
const { current: element } = target;
|
|
277
|
+
return isEnabled && element ? preventTextActions(element) : undefined;
|
|
278
|
+
}, [isEnabled, target]);
|
|
279
|
+
};
|
|
280
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/components/viewport/input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7C,2EAA2E;AAC3E,0EAA0E;AAC1E,0EAA0E;AAC1E,2EAA2E;AAC3E,sEAAsE;AACtE,yEAAyE;AACzE,mCAAmC;AAEnC,iEAAiE;AACjE,MAAM,KAAK,GAAG,GAAG,EAAE,CACjB,OAAO,GAAG,KAAK,WAAW,IAAI,GAAG,CAAC,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;AAE9E,wDAAwD;AACxD,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC;AAE7B,4EAA4E;AAC5E,IAAI,SAAS,GAAG,CAAC,CAAC;AAClB,IAAI,WAA+B,CAAC;AAEpC,sEAAsE;AACtE,MAAM,gBAAgB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EAAE;IACR,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QACpC,OAAO,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAC1B,CAAC,CAAC"}
|
|
@@ -1,19 +1,47 @@
|
|
|
1
1
|
import './style.css';
|
|
2
|
-
import { FunctionComponent } from 'react';
|
|
3
|
-
import type { Listener, ViewportAnchorProps, ViewportContentProps, ViewportProviderProps, ViewportScrollEvent, VisualViewportState } from './props.js';
|
|
4
|
-
export
|
|
2
|
+
import { FunctionComponent, RefObject } from 'react';
|
|
3
|
+
import type { ElementGeometry, ElementGeometryOptions, ElementVisibilityOptions, Listener, SizeClass, ViewportAnchorProps, ViewportContentProps, ViewportKeyboardAccessoryProps, ViewportOverscrollProps, ViewportProviderProps, ViewportScrollEvent, ViewportScrollOptions, VisualViewportState } from './props.js';
|
|
4
|
+
export { preventFocusShift, preventInputZoom, preventTextActions, useFocusShiftPrevention, useInputZoomPrevention, useTextActionsPrevention, } from './input.js';
|
|
5
|
+
export { useScrollerRegistration, useViewportEdgeElement } from './edge.js';
|
|
6
|
+
export { EdgeEffects } from './edge-effect.js';
|
|
7
|
+
export { useAnchorSize, useCreateViewportAnchorHandle, ViewportAnchorHandle, ViewportScopeContext, } from './padding.js';
|
|
8
|
+
export type { ElementGeometry, ElementGeometryOptions, ElementVisibilityOptions, ViewportAnchorProps, ViewportContentProps, ViewportKeyboardAccessoryProps, ViewportContentSafeArea, ViewportEdge, ViewportEdgeEffect, ViewportOverscrollProps, ViewportPaddingProps, ViewportProviderProps, ViewportSafeArea, SizeClass, ViewportScrollEvent, ViewportScrollOptions, VisualViewportState, } from './props.js';
|
|
9
|
+
/**
|
|
10
|
+
* The window's horizontal size class (no `Provider` needed): e.g. a sheet
|
|
11
|
+
* on `compact` (a phone), a popover on `regular` (a tablet); `compact` before
|
|
12
|
+
* hydration (server rendering).
|
|
13
|
+
*/
|
|
14
|
+
export declare const useSizeClass: () => SizeClass;
|
|
5
15
|
/** The visual viewport and the keyboard's height (needs a `Provider`). */
|
|
6
16
|
export declare const useVisualViewport: () => VisualViewportState;
|
|
7
17
|
/**
|
|
8
|
-
* Calls `listener` on every scroll of the tracked scroll container
|
|
9
|
-
* `Provider`);
|
|
18
|
+
* Calls `listener` on every scroll of the tracked scroll container, and as
|
|
19
|
+
* it's overscrolled (needs a `Provider`); the direction past its own
|
|
20
|
+
* `threshold`. It can change without resubscribing.
|
|
21
|
+
*/
|
|
22
|
+
export declare const useViewportScroll: (listener: Listener, { threshold }?: ViewportScrollOptions) => void;
|
|
23
|
+
/**
|
|
24
|
+
* The direction the tracked scroll container is scrolled in (past
|
|
25
|
+
* `threshold`), and whether it's at its top or bottom (re-rendering when
|
|
26
|
+
* these change).
|
|
27
|
+
*/
|
|
28
|
+
export declare const useScrollDirection: (options?: ViewportScrollOptions) => Pick<ViewportScrollEvent, "atBottom" | "atTop" | "direction">;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the element (`ref`'s, as first mounted) is in the visible area:
|
|
31
|
+
* the viewport, or `scroller`'s box (an `IntersectionObserver`; `false`
|
|
32
|
+
* until it reports, and on the server).
|
|
10
33
|
*/
|
|
11
|
-
export declare const
|
|
34
|
+
export declare const useElementVisibility: (ref: RefObject<Element | null>, { rootMargin, scroller, threshold, }?: ElementVisibilityOptions) => boolean;
|
|
12
35
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
36
|
+
* Calls `listener` with where the element (`ref`'s, as first mounted) is in
|
|
37
|
+
* the visible area (the viewport, or `scroller`'s box): its edges'
|
|
38
|
+
* distances to the area's, how much of it shows. Measured once per frame
|
|
39
|
+
* while anything scrolls or resizes, and only while it's visible (once
|
|
40
|
+
* more as it leaves), and once as it mounts; the listener can change
|
|
41
|
+
* without resubscribing (as `useViewportScroll`'s), and nothing re-renders
|
|
42
|
+
* unless it does (e.g. setting state).
|
|
15
43
|
*/
|
|
16
|
-
export declare const
|
|
44
|
+
export declare const useElementGeometry: (ref: RefObject<Element | null>, listener: (geometry: ElementGeometry) => void, { scroller }?: ElementGeometryOptions) => void;
|
|
17
45
|
export declare const Viewport: {
|
|
18
46
|
Provider: FunctionComponent<ViewportProviderProps>;
|
|
19
47
|
Anchor: import("preact").FunctionalComponent<import("react").PropsWithoutRef<ViewportAnchorProps> & {
|
|
@@ -28,5 +56,15 @@ export declare const Viewport: {
|
|
|
28
56
|
BlockEnd: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<ViewportAnchorProps, "edge">> & {
|
|
29
57
|
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
30
58
|
}>;
|
|
59
|
+
Overscroll: import("preact").FunctionalComponent<import("react").PropsWithoutRef<ViewportOverscrollProps> & {
|
|
60
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
61
|
+
}>;
|
|
62
|
+
Padding: import("preact").FunctionalComponent<import("react").PropsWithoutRef<import("./props.js").ViewportPaddingProps> & {
|
|
63
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
64
|
+
}>;
|
|
65
|
+
KeyboardAccessory: import("preact").FunctionalComponent<import("react").PropsWithoutRef<ViewportKeyboardAccessoryProps> & {
|
|
66
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
67
|
+
}>;
|
|
68
|
+
createAnchorHandle: () => import("./padding.js").ViewportAnchorHandle;
|
|
31
69
|
};
|
|
32
70
|
//# sourceMappingURL=main.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/components/viewport/main.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAErB,OAAO,EAGL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":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