glasslikeui 1.9.0 → 1.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.
Files changed (128) hide show
  1. package/README.md +892 -24
  2. package/dist/actions/adaptiveTone.d.ts +50 -0
  3. package/dist/actions/adaptiveTone.js +569 -0
  4. package/dist/actions/alertLogic.d.ts +67 -0
  5. package/dist/actions/alertLogic.js +123 -0
  6. package/dist/actions/anchorPlacement.d.ts +92 -0
  7. package/dist/actions/anchorPlacement.js +137 -0
  8. package/dist/actions/dragSnap.d.ts +1 -1
  9. package/dist/actions/dragSnapMath.d.ts +70 -0
  10. package/dist/actions/dragSnapMath.js +115 -0
  11. package/dist/actions/glassToneLogic.d.ts +182 -0
  12. package/dist/actions/glassToneLogic.js +513 -0
  13. package/dist/actions/heightTransition.d.ts +32 -0
  14. package/dist/actions/heightTransition.js +64 -0
  15. package/dist/actions/index.d.ts +1 -0
  16. package/dist/actions/index.js +1 -0
  17. package/dist/actions/inertSiblings.js +20 -4
  18. package/dist/actions/menuLogic.d.ts +40 -0
  19. package/dist/actions/menuLogic.js +68 -0
  20. package/dist/actions/modalDialog.d.ts +19 -0
  21. package/dist/actions/modalDialog.js +48 -0
  22. package/dist/actions/popoverLogic.d.ts +25 -0
  23. package/dist/actions/popoverLogic.js +48 -0
  24. package/dist/actions/rovingIndex.d.ts +30 -0
  25. package/dist/actions/rovingIndex.js +49 -0
  26. package/dist/actions/scrollRunTracker.d.ts +36 -0
  27. package/dist/actions/scrollRunTracker.js +77 -0
  28. package/dist/actions/scrollUnder.d.ts +21 -0
  29. package/dist/actions/scrollUnder.js +29 -0
  30. package/dist/actions/segmentedLogic.d.ts +38 -0
  31. package/dist/actions/segmentedLogic.js +59 -0
  32. package/dist/actions/sheetLogic.d.ts +43 -0
  33. package/dist/actions/sheetLogic.js +71 -0
  34. package/dist/actions/sliderLogic.d.ts +29 -0
  35. package/dist/actions/sliderLogic.js +53 -0
  36. package/dist/actions/swipeActions.d.ts +46 -2
  37. package/dist/actions/swipeActions.js +267 -46
  38. package/dist/actions/tabBarMinimize.d.ts +31 -0
  39. package/dist/actions/tabBarMinimize.js +38 -0
  40. package/dist/actions/tabViewLogic.d.ts +47 -0
  41. package/dist/actions/tabViewLogic.js +71 -0
  42. package/dist/actions/toggleKnobLogic.d.ts +57 -0
  43. package/dist/actions/toggleKnobLogic.js +66 -0
  44. package/dist/actions/toolbarFocus.d.ts +44 -0
  45. package/dist/actions/toolbarFocus.js +228 -0
  46. package/dist/actions/topLayer.d.ts +12 -0
  47. package/dist/actions/topLayer.js +18 -0
  48. package/dist/components/dialog/ActionSheet.svelte +457 -0
  49. package/dist/components/dialog/ActionSheet.svelte.d.ts +25 -0
  50. package/dist/components/dialog/Alert.svelte +337 -0
  51. package/dist/components/dialog/Alert.svelte.d.ts +28 -0
  52. package/dist/components/dialog/index.d.ts +6 -0
  53. package/dist/components/dialog/index.js +6 -0
  54. package/dist/components/glass/Glass.svelte +49 -17
  55. package/dist/components/glass/Glass.svelte.d.ts +8 -0
  56. package/dist/components/glass/GlassSection.svelte +9 -1
  57. package/dist/components/glass/LensFilters.svelte +4 -2
  58. package/dist/components/glass/Popover.svelte +379 -0
  59. package/dist/components/glass/Popover.svelte.d.ts +30 -0
  60. package/dist/components/glass/Sheet.svelte +470 -103
  61. package/dist/components/glass/Sheet.svelte.d.ts +55 -7
  62. package/dist/components/glass/index.d.ts +3 -0
  63. package/dist/components/glass/index.js +1 -0
  64. package/dist/components/index.d.ts +2 -0
  65. package/dist/components/index.js +4 -0
  66. package/dist/components/interactive/Badge.svelte +97 -6
  67. package/dist/components/interactive/Badge.svelte.d.ts +13 -2
  68. package/dist/components/interactive/Button.svelte +162 -20
  69. package/dist/components/interactive/Button.svelte.d.ts +14 -1
  70. package/dist/components/interactive/IconButton.svelte +214 -4
  71. package/dist/components/interactive/IconButton.svelte.d.ts +2 -1
  72. package/dist/components/interactive/ProgressView.svelte +306 -0
  73. package/dist/components/interactive/ProgressView.svelte.d.ts +25 -0
  74. package/dist/components/interactive/Segment.d.ts +14 -0
  75. package/dist/components/interactive/Segment.js +1 -0
  76. package/dist/components/interactive/SegmentedControl.svelte +399 -0
  77. package/dist/components/interactive/SegmentedControl.svelte.d.ts +17 -0
  78. package/dist/components/interactive/Slider.svelte +299 -0
  79. package/dist/components/interactive/Slider.svelte.d.ts +23 -0
  80. package/dist/components/interactive/TabView.svelte +573 -41
  81. package/dist/components/interactive/TabView.svelte.d.ts +25 -0
  82. package/dist/components/interactive/Toggle.svelte +287 -16
  83. package/dist/components/interactive/Toggle.svelte.d.ts +12 -0
  84. package/dist/components/interactive/index.d.ts +4 -0
  85. package/dist/components/interactive/index.js +3 -0
  86. package/dist/components/list/List.svelte +41 -17
  87. package/dist/components/list/List.svelte.d.ts +1 -0
  88. package/dist/components/list/ListRow.svelte +208 -47
  89. package/dist/components/list/ListRow.svelte.d.ts +16 -1
  90. package/dist/components/menu/Menu.svelte +51 -27
  91. package/dist/components/menu/Menu.svelte.d.ts +5 -0
  92. package/dist/components/menu/MenuItem.svelte +82 -25
  93. package/dist/components/menu/MenuItem.svelte.d.ts +8 -0
  94. package/dist/components/menu/MenuSection.svelte +95 -0
  95. package/dist/components/menu/MenuSection.svelte.d.ts +18 -0
  96. package/dist/components/menu/MenuSubmenu.svelte +196 -0
  97. package/dist/components/menu/MenuSubmenu.svelte.d.ts +11 -0
  98. package/dist/components/menu/index.d.ts +4 -1
  99. package/dist/components/menu/index.js +3 -1
  100. package/dist/components/navigation/NavigationBar.svelte +97 -15
  101. package/dist/components/navigation/NavigationBar.svelte.d.ts +6 -0
  102. package/dist/components/toolbar/Toolbar.svelte +43 -0
  103. package/dist/components/toolbar/Toolbar.svelte.d.ts +13 -0
  104. package/dist/components/toolbar/ToolbarItemGroup.svelte +45 -0
  105. package/dist/components/toolbar/ToolbarItemGroup.svelte.d.ts +14 -0
  106. package/dist/components/toolbar/ToolbarSpacer.svelte +36 -0
  107. package/dist/components/toolbar/ToolbarSpacer.svelte.d.ts +12 -0
  108. package/dist/components/toolbar/index.d.ts +7 -0
  109. package/dist/components/toolbar/index.js +7 -0
  110. package/dist/components/typography/Text.svelte +9 -1
  111. package/dist/constants/alertAction.d.ts +19 -0
  112. package/dist/constants/alertAction.js +1 -0
  113. package/dist/constants/badge.d.ts +32 -0
  114. package/dist/constants/badge.js +47 -0
  115. package/dist/constants/buttons.d.ts +45 -0
  116. package/dist/constants/buttons.js +52 -0
  117. package/dist/constants/colors.d.ts +9 -4
  118. package/dist/constants/colors.js +9 -4
  119. package/dist/constants/index.d.ts +3 -0
  120. package/dist/constants/index.js +3 -0
  121. package/dist/constants/progress.d.ts +56 -0
  122. package/dist/constants/progress.js +75 -0
  123. package/dist/constants/variants.d.ts +6 -2
  124. package/dist/constants/variants.js +2 -2
  125. package/dist/styles/glasslikeui.css +135 -1
  126. package/dist/styles/lens.css +21 -19
  127. package/dist/styles/squircle.css +17 -7
  128. package/package.json +1 -1
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The decisions SegmentedControl makes, as plain functions, so mutation testing
3
+ * reaches them (Stryker cannot instrument .svelte files). The control is a
4
+ * WAI-ARIA radio group: one tab stop, arrow keys move and select, disabled
5
+ * segments are skipped. Internal.
6
+ */
7
+ /** The parts of a segment these decisions read. */
8
+ export interface SegmentState {
9
+ value: string;
10
+ disabled?: boolean | undefined;
11
+ }
12
+ /** Whether a segment can be chosen: neither it nor the whole control is disabled. */
13
+ export declare function isSegmentSelectable(segment: SegmentState | undefined, controlDisabled: boolean): boolean;
14
+ /**
15
+ * The index of the segment that takes the tab stop: the selected one when it
16
+ * can be chosen, otherwise the first that can. -1 when none can, so the
17
+ * control drops out of the tab order.
18
+ */
19
+ export declare function segmentTabStop(segments: readonly SegmentState[], value: string | undefined, controlDisabled: boolean): number;
20
+ /**
21
+ * The index of the segment an arrow key moves to from the segment at
22
+ * `focused`, skipping the ones that cannot be chosen and wrapping at the ends.
23
+ * Both arrow axes move, as in a native radio group, and Left and Right swap in
24
+ * a right to left layout. Null when the key does nothing.
25
+ */
26
+ export declare function segmentKeyTarget(key: string, segments: readonly SegmentState[], focused: number, controlDisabled: boolean, isRightToLeft: boolean): number | null;
27
+ /** A segment's horizontal extent on screen. */
28
+ export interface SegmentSpan {
29
+ left: number;
30
+ right: number;
31
+ }
32
+ /**
33
+ * The index of the segment a dragged thumb is over at `x`: the one whose span
34
+ * holds it, else the nearest, so the thumb stays at the end once the pointer
35
+ * leaves the control. A shared edge counts for the earlier segment. Null when
36
+ * that segment cannot be chosen, or there is none.
37
+ */
38
+ export declare function segmentAtPoint(x: number, spans: readonly SegmentSpan[], segments: readonly SegmentState[], controlDisabled: boolean): number | null;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The decisions SegmentedControl makes, as plain functions, so mutation testing
3
+ * reaches them (Stryker cannot instrument .svelte files). The control is a
4
+ * WAI-ARIA radio group: one tab stop, arrow keys move and select, disabled
5
+ * segments are skipped. Internal.
6
+ */
7
+ import { rovingTarget } from './rovingIndex';
8
+ /** Whether a segment can be chosen: neither it nor the whole control is disabled. */
9
+ export function isSegmentSelectable(segment, controlDisabled) {
10
+ return segment !== undefined && !controlDisabled && segment.disabled !== true;
11
+ }
12
+ /**
13
+ * The index of the segment that takes the tab stop: the selected one when it
14
+ * can be chosen, otherwise the first that can. -1 when none can, so the
15
+ * control drops out of the tab order.
16
+ */
17
+ export function segmentTabStop(segments, value, controlDisabled) {
18
+ var selected = segments.findIndex(function (s) { return s.value === value; });
19
+ if (isSegmentSelectable(segments[selected], controlDisabled))
20
+ return selected;
21
+ return segments.findIndex(function (s) { return isSegmentSelectable(s, controlDisabled); });
22
+ }
23
+ /**
24
+ * The index of the segment an arrow key moves to from the segment at
25
+ * `focused`, skipping the ones that cannot be chosen and wrapping at the ends.
26
+ * Both arrow axes move, as in a native radio group, and Left and Right swap in
27
+ * a right to left layout. Null when the key does nothing.
28
+ */
29
+ export function segmentKeyTarget(key, segments, focused, controlDisabled, isRightToLeft) {
30
+ var selectable = segments
31
+ .map(function (s, index) { return (isSegmentSelectable(s, controlDisabled) ? index : -1); })
32
+ .filter(function (index) { return index !== -1; });
33
+ var target = rovingTarget(key, selectable.indexOf(focused), selectable.length, {
34
+ orientation: 'both',
35
+ isRightToLeft: isRightToLeft,
36
+ wraps: true,
37
+ jumpsToEnds: false
38
+ });
39
+ return target === null ? null : selectable[target];
40
+ }
41
+ /**
42
+ * The index of the segment a dragged thumb is over at `x`: the one whose span
43
+ * holds it, else the nearest, so the thumb stays at the end once the pointer
44
+ * leaves the control. A shared edge counts for the earlier segment. Null when
45
+ * that segment cannot be chosen, or there is none.
46
+ */
47
+ export function segmentAtPoint(x, spans, segments, controlDisabled) {
48
+ var nearest = -1;
49
+ var nearestGap = Infinity;
50
+ spans.forEach(function (span, index) {
51
+ // How far x lies outside the span, 0 inside it or on an edge.
52
+ var gap = Math.max(span.left - x, x - span.right, 0);
53
+ if (gap < nearestGap) {
54
+ nearest = index;
55
+ nearestGap = gap;
56
+ }
57
+ });
58
+ return isSegmentSelectable(segments[nearest], controlDisabled) ? nearest : null;
59
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The decisions Sheet makes, as plain functions, so mutation testing reaches
3
+ * them (Stryker cannot instrument .svelte files). The component wires them to
4
+ * its state and the DOM. Internal.
5
+ */
6
+ /** What a key press on the window does to the sheet. */
7
+ export type SheetKeyAction = 'close' | 'trap' | 'none';
8
+ /** How the sheet is shown, for sheetKeyAction. */
9
+ export interface SheetKeyContext {
10
+ /** A modal sheet (the default) traps Tab and closes on Escape from anywhere. */
11
+ modal?: boolean;
12
+ /** Whether focus is inside the sheet. A non-modal sheet only closes on Escape then. Default `false`. */
13
+ focusInside?: boolean;
14
+ }
15
+ /**
16
+ * Escape closes an open sheet and Tab is kept inside a modal one. A closed sheet
17
+ * ignores every key: the window listener stays attached, and would otherwise
18
+ * fire onClose on every Escape. A non-modal sheet leaves Tab alone, and takes
19
+ * Escape only while focus is inside it, so the page keeps its own Escape.
20
+ */
21
+ export declare function sheetKeyAction(key: string, isOpen: boolean, { modal, focusInside }?: SheetKeyContext): SheetKeyAction;
22
+ /**
23
+ * Whether closing gives focus back to the element that opened the sheet. A modal
24
+ * sheet always does. A non-modal one does only when focus is still in the sheet
25
+ * or nowhere, so a close does not pull focus from where the user moved it.
26
+ */
27
+ export declare function shouldReturnFocus(modal: boolean, focusInSheetOrNowhere: boolean): boolean;
28
+ /**
29
+ * The detent index a key press on the grabber moves to, or `null` for a key the
30
+ * grabber does not handle. It is a vertical slider: Up and Right grow the sheet
31
+ * one detent, Down and Left shrink it, Page Up and Page Down do the same, and
32
+ * Home and End go to the smallest and largest detent. Never past either end.
33
+ */
34
+ export declare function grabberKeyTarget(key: string, index: number, count: number): number | null;
35
+ /**
36
+ * Whether a close request is acted on. A closed or already closing sheet
37
+ * ignores repeat requests, so onClose fires exactly once per close.
38
+ */
39
+ export declare function canCloseSheet(isOpen: boolean, exiting: boolean): boolean;
40
+ /** Whether the close button leads the header. Anything but 'trailing' leads. */
41
+ export declare function closeButtonLeads(placement: 'leading' | 'trailing' | undefined): boolean;
42
+ /** Whether content is at its top. An overscroll bounce above it counts as the top. */
43
+ export declare function isAtScrollTop(scrollTop: number): boolean;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The decisions Sheet makes, as plain functions, so mutation testing reaches
3
+ * them (Stryker cannot instrument .svelte files). The component wires them to
4
+ * its state and the DOM. Internal.
5
+ */
6
+ /**
7
+ * Escape closes an open sheet and Tab is kept inside a modal one. A closed sheet
8
+ * ignores every key: the window listener stays attached, and would otherwise
9
+ * fire onClose on every Escape. A non-modal sheet leaves Tab alone, and takes
10
+ * Escape only while focus is inside it, so the page keeps its own Escape.
11
+ */
12
+ export function sheetKeyAction(key, isOpen, _a) {
13
+ var _b = _a === void 0 ? {} : _a, _c = _b.modal, modal = _c === void 0 ? true : _c, _d = _b.focusInside, focusInside = _d === void 0 ? false : _d;
14
+ if (!isOpen)
15
+ return 'none';
16
+ if (key === 'Escape')
17
+ return modal || focusInside ? 'close' : 'none';
18
+ if (key === 'Tab')
19
+ return modal ? 'trap' : 'none';
20
+ return 'none';
21
+ }
22
+ /**
23
+ * Whether closing gives focus back to the element that opened the sheet. A modal
24
+ * sheet always does. A non-modal one does only when focus is still in the sheet
25
+ * or nowhere, so a close does not pull focus from where the user moved it.
26
+ */
27
+ export function shouldReturnFocus(modal, focusInSheetOrNowhere) {
28
+ return modal || focusInSheetOrNowhere;
29
+ }
30
+ /**
31
+ * The detent index a key press on the grabber moves to, or `null` for a key the
32
+ * grabber does not handle. It is a vertical slider: Up and Right grow the sheet
33
+ * one detent, Down and Left shrink it, Page Up and Page Down do the same, and
34
+ * Home and End go to the smallest and largest detent. Never past either end.
35
+ */
36
+ export function grabberKeyTarget(key, index, count) {
37
+ if (count <= 0)
38
+ return null;
39
+ var last = count - 1;
40
+ switch (key) {
41
+ case 'ArrowUp':
42
+ case 'ArrowRight':
43
+ case 'PageUp':
44
+ return Math.min(index + 1, last);
45
+ case 'ArrowDown':
46
+ case 'ArrowLeft':
47
+ case 'PageDown':
48
+ return Math.max(index - 1, 0);
49
+ case 'Home':
50
+ return 0;
51
+ case 'End':
52
+ return last;
53
+ default:
54
+ return null;
55
+ }
56
+ }
57
+ /**
58
+ * Whether a close request is acted on. A closed or already closing sheet
59
+ * ignores repeat requests, so onClose fires exactly once per close.
60
+ */
61
+ export function canCloseSheet(isOpen, exiting) {
62
+ return isOpen && !exiting;
63
+ }
64
+ /** Whether the close button leads the header. Anything but 'trailing' leads. */
65
+ export function closeButtonLeads(placement) {
66
+ return placement !== 'trailing';
67
+ }
68
+ /** Whether content is at its top. An overscroll bounce above it counts as the top. */
69
+ export function isAtScrollTop(scrollTop) {
70
+ return scrollTop <= 0;
71
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The numbers Slider works with, as plain functions, so mutation testing
3
+ * reaches them (Stryker cannot instrument .svelte files). They follow the
4
+ * rules of a native `<input type="range">`, which sits under the slider, so
5
+ * the drawn knob and fill always agree with the value the browser reports.
6
+ * Internal.
7
+ */
8
+ /** A slider's bounds and step after bad values are replaced. */
9
+ export interface SliderRange {
10
+ min: number;
11
+ max: number;
12
+ step: number;
13
+ }
14
+ /**
15
+ * The bounds and step a native range input would use for these props: a
16
+ * missing or non-finite min is 0 and max is 100, a max below min is raised to
17
+ * min, and a step that is not a positive number is 1.
18
+ */
19
+ export declare function sliderRange(min: number, max: number, step: number): SliderRange;
20
+ /** The number of decimal places in `step`, so snapping does not leave float noise. */
21
+ export declare function stepDecimals(step: number): number;
22
+ /**
23
+ * The value a native range input settles on: clamped to the bounds, then the
24
+ * nearest step from min, and never a step past max. A non-finite value is the
25
+ * midpoint, the input's own default.
26
+ */
27
+ export declare function sliderValue(value: number, range: SliderRange): number;
28
+ /** How far along the track `value` sits, from 0 at min to 1 at max. 0 when the bounds meet. */
29
+ export declare function sliderFraction(value: number, range: SliderRange): number;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The numbers Slider works with, as plain functions, so mutation testing
3
+ * reaches them (Stryker cannot instrument .svelte files). They follow the
4
+ * rules of a native `<input type="range">`, which sits under the slider, so
5
+ * the drawn knob and fill always agree with the value the browser reports.
6
+ * Internal.
7
+ */
8
+ /**
9
+ * The bounds and step a native range input would use for these props: a
10
+ * missing or non-finite min is 0 and max is 100, a max below min is raised to
11
+ * min, and a step that is not a positive number is 1.
12
+ */
13
+ export function sliderRange(min, max, step) {
14
+ var low = Number.isFinite(min) ? min : 0;
15
+ var high = Number.isFinite(max) ? Math.max(low, max) : Math.max(low, 100);
16
+ var size = Number.isFinite(step) && step > 0 ? step : 1;
17
+ return { min: low, max: high, step: size };
18
+ }
19
+ /** The number of decimal places in `step`, so snapping does not leave float noise. */
20
+ export function stepDecimals(step) {
21
+ // Small numbers print in exponent form, such as 2.5e-8: the mantissa's
22
+ // decimals plus the exponent.
23
+ var _a = String(step).split('e-'), mantissa = _a[0], exponent = _a[1];
24
+ var dot = mantissa.indexOf('.');
25
+ var own = dot === -1 ? 0 : mantissa.length - dot - 1;
26
+ return own + (exponent === undefined ? 0 : Number(exponent));
27
+ }
28
+ /**
29
+ * The value a native range input settles on: clamped to the bounds, then the
30
+ * nearest step from min, and never a step past max. A non-finite value is the
31
+ * midpoint, the input's own default.
32
+ */
33
+ export function sliderValue(value, range) {
34
+ var min = range.min, max = range.max, step = range.step;
35
+ var start = Number.isFinite(value) ? value : min + (max - min) / 2;
36
+ var clamped = Math.min(max, Math.max(min, start));
37
+ var decimals = Math.min(20, Math.max(stepDecimals(step), stepDecimals(min)));
38
+ // Float noise is removed before comparing with max: 0.1 * 3 is 0.30000000000000004,
39
+ // which would otherwise count as past a max of 0.3.
40
+ var tidy = function (n) { return Number(n.toFixed(decimals)); };
41
+ var snapped = tidy(min + Math.round((clamped - min) / step) * step);
42
+ if (snapped > max)
43
+ snapped = tidy(snapped - step);
44
+ // Rounding to the decimals can cross a bound that has more of them than toFixed keeps.
45
+ return Math.min(max, Math.max(min, snapped));
46
+ }
47
+ /** How far along the track `value` sits, from 0 at min to 1 at max. 0 when the bounds meet. */
48
+ export function sliderFraction(value, range) {
49
+ var span = range.max - range.min;
50
+ if (span <= 0)
51
+ return 0;
52
+ return Math.min(1, Math.max(0, (value - range.min) / span));
53
+ }
@@ -10,6 +10,12 @@
10
10
  * `min-width: var(--swipe-reveal)` then grows to fill exactly the revealed
11
11
  * space, so no gap opens when the row is dragged past the action width.
12
12
  *
13
+ * A row can carry actions on both edges at once, as SwiftUI allows one
14
+ * `.swipeActions` per edge: pass `leading` and `trailing`. The drag direction
15
+ * picks the edge, so dragging back past the resting point closes one side and
16
+ * then opens the other. Under `dir="rtl"` leading is on the right. The older
17
+ * single edge form (`edge` with the top level strip options) still works.
18
+ *
13
19
  * Usage:
14
20
  * <div use:swipeActions={{
15
21
  * edge: 'trailing',
@@ -20,15 +26,39 @@
20
26
  */
21
27
  export type SwipeEdge = 'leading' | 'trailing';
22
28
  export type SwipeState = 'closed' | 'open' | 'fullSwipe';
29
+ /** Writing direction of the row. Leading is on the left in `ltr` and on the right in `rtl`. */
30
+ export type SwipeDirection = 'ltr' | 'rtl';
23
31
  export interface SwipeGeometry {
24
32
  edge: SwipeEdge;
33
+ /** Writing direction. Omitted means `ltr`. */
34
+ direction?: SwipeDirection | undefined;
25
35
  /** Total width of the revealed action strip, in px. */
26
36
  actionsWidth: number;
27
37
  /** Width of the row. 0 means "not measured yet". */
28
38
  rowWidth: number;
29
39
  allowsFullSwipe: boolean;
30
40
  }
41
+ /** The actions on one edge of a row. */
42
+ export interface SwipeEdgeActions {
43
+ /** Explicit strip width. Omit to measure `actionsElement` at gesture start. */
44
+ actionsWidth?: number | undefined;
45
+ /** The strip. Focus inside it opens this edge, so the keyboard needs no swipe. */
46
+ actionsElement?: HTMLElement | null | undefined;
47
+ allowsFullSwipe?: boolean | undefined;
48
+ /**
49
+ * Runs on a full swipe. The row then springs back closed, as in iOS, unless
50
+ * this returns `true`, for a row that is about to be removed.
51
+ */
52
+ onFullSwipe?: (() => boolean | void) | undefined;
53
+ }
31
54
  export interface SwipeActionsOptions {
55
+ /** Actions revealed from the leading edge. With `trailing`, replaces the single edge options. */
56
+ leading?: SwipeEdgeActions | undefined;
57
+ /** Actions revealed from the trailing edge. With `leading`, replaces the single edge options. */
58
+ trailing?: SwipeEdgeActions | undefined;
59
+ /** Writing direction. Omit to read it from the node. */
60
+ direction?: SwipeDirection | undefined;
61
+ /** Single edge form: the edge the top level strip options belong to. */
32
62
  edge?: SwipeEdge | undefined;
33
63
  /** Explicit strip width. Omit to measure `actionsElement` at gesture start. */
34
64
  actionsWidth?: number | undefined;
@@ -54,8 +84,22 @@ export declare const DEFAULT_SWIPE_RUBBER_BAND = 0.35;
54
84
  export declare const DEFAULT_SWIPE_VELOCITY = 500;
55
85
  /** px of travel before the gesture is claimed from the scroller. */
56
86
  export declare const SWIPE_SLOP = 4;
57
- /** Direction the content travels to reveal this edge's actions. */
58
- export declare function edgeSign(edge: SwipeEdge): number;
87
+ /** Direction the content travels to reveal this edge's actions: right is 1, left is -1. */
88
+ export declare function edgeSign(edge: SwipeEdge, direction?: SwipeDirection): number;
89
+ /** The edge an offset reveals, or null at rest. Right of rest is leading in `ltr`. */
90
+ export declare function edgeForOffset(offset: number, direction?: SwipeDirection): SwipeEdge | null;
91
+ /**
92
+ * The edge-most action of a strip, which SwiftUI lists first and a full swipe
93
+ * triggers: the first child for leading, the last for trailing.
94
+ */
95
+ export declare function edgeMostAction(strip: HTMLElement | null | undefined, edge: SwipeEdge): HTMLElement | null;
96
+ /**
97
+ * The writing direction an element is laid out in: its computed CSS
98
+ * `direction`, which covers both `dir` and a stylesheet that sets `direction`.
99
+ * Where styles are not computed (some test DOMs report LTR for everything),
100
+ * the nearest `dir` attribute still counts. Read once per gesture, not per move.
101
+ */
102
+ export declare function readDirection(el: Element): SwipeDirection;
59
103
  /** Constrain a raw pointer delta to the row's travel: one-to-one to the limit, damped beyond it, never past the row width, and zero against the configured edge. */
60
104
  export declare function clampSwipeOffset(rawDx: number, geo: SwipeGeometry): number;
61
105
  /** The unsigned distance a given offset has slid the content, in px. */