@rdlabo/ionic-theme-ios26 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -1
- package/dist/css/components/ion-action-sheet.css +1 -1
- package/dist/css/components/ion-alert.css +1 -1
- package/dist/css/components/ion-button.css +1 -1
- package/dist/css/components/ion-datetime.css +1 -1
- package/dist/css/components/ion-fab.css +1 -1
- package/dist/css/components/ion-loading.css +1 -1
- package/dist/css/components/ion-modal.css +1 -1
- package/dist/css/components/ion-popover.css +1 -1
- package/dist/css/components/ion-range.css +1 -1
- package/dist/css/components/ion-searchbar.css +1 -1
- package/dist/css/components/ion-segment.css +1 -1
- package/dist/css/components/ion-tabs.css +1 -1
- package/dist/css/components/ion-toast.css +1 -1
- package/dist/css/components/ion-toggle.css +1 -1
- package/dist/css/components/ion-toolbar.css +1 -1
- package/dist/css/ionic-theme-ios26-dark-always.css +1 -1
- package/dist/css/ionic-theme-ios26-dark-class.css +1 -1
- package/dist/css/ionic-theme-ios26-dark-system.css +1 -1
- package/dist/css/ionic-theme-ios26.css +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/popover/animations/ios.enter.d.ts +4 -0
- package/dist/popover/animations/ios.enter.d.ts.map +1 -0
- package/dist/popover/animations/ios.enter.js +111 -0
- package/dist/popover/animations/ios.leave.d.ts +3 -0
- package/dist/popover/animations/ios.leave.d.ts.map +1 -0
- package/dist/popover/animations/ios.leave.js +60 -0
- package/dist/popover/popover-interface.d.ts +38 -0
- package/dist/popover/popover-interface.d.ts.map +1 -0
- package/dist/popover/popover-interface.js +1 -0
- package/dist/popover/utils.d.ts +48 -0
- package/dist/popover/utils.d.ts.map +1 -0
- package/dist/popover/utils.js +479 -0
- package/dist/sheets-of-glass/animations.d.ts +8 -0
- package/dist/sheets-of-glass/animations.d.ts.map +1 -0
- package/dist/sheets-of-glass/animations.js +97 -0
- package/dist/sheets-of-glass/index.d.ts +3 -0
- package/dist/sheets-of-glass/index.d.ts.map +1 -0
- package/dist/sheets-of-glass/index.js +160 -0
- package/dist/sheets-of-glass/interfaces.d.ts +16 -0
- package/dist/sheets-of-glass/interfaces.d.ts.map +1 -0
- package/dist/sheets-of-glass/interfaces.js +1 -0
- package/dist/utils.d.ts +5 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +26 -11
- package/package.json +1 -1
- package/src/index.ts +5 -3
- package/src/popover/animations/ios.enter.ts +176 -0
- package/src/popover/animations/ios.leave.ts +76 -0
- package/src/popover/popover-interface.ts +44 -0
- package/src/popover/utils.ts +912 -0
- package/src/{gestures → sheets-of-glass}/animations.ts +1 -1
- package/src/{gestures → sheets-of-glass}/index.ts +1 -1
- package/src/styles/components/ion-alert.scss +1 -0
- package/src/styles/components/ion-button.scss +29 -8
- package/src/styles/components/ion-popover.scss +6 -0
- package/src/styles/components/ion-range.scss +2 -1
- package/src/styles/components/ion-segment.scss +22 -7
- package/src/styles/components/ion-tabs.scss +9 -2
- package/src/styles/components/ion-toggle.scss +8 -4
- package/src/styles/utils/api.scss +12 -0
- package/src/{gestures/utils.ts → utils.ts} +18 -1
- /package/src/{gestures → sheets-of-glass}/interfaces.ts +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AnimationBuilder, ComponentProps, ComponentRef, FrameworkDelegate, Mode, OverlayInterface } from '@ionic/core';
|
|
2
|
+
export interface PopoverInterface extends OverlayInterface {
|
|
3
|
+
present: (event?: MouseEvent | TouchEvent | PointerEvent) => Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
export interface PopoverOptions<T extends ComponentRef = ComponentRef> {
|
|
6
|
+
component: T;
|
|
7
|
+
componentProps?: ComponentProps<T>;
|
|
8
|
+
showBackdrop?: boolean;
|
|
9
|
+
backdropDismiss?: boolean;
|
|
10
|
+
translucent?: boolean;
|
|
11
|
+
cssClass?: string | string[];
|
|
12
|
+
event?: Event;
|
|
13
|
+
delegate?: FrameworkDelegate;
|
|
14
|
+
animated?: boolean;
|
|
15
|
+
focusTrap?: boolean;
|
|
16
|
+
mode?: Mode;
|
|
17
|
+
keyboardClose?: boolean;
|
|
18
|
+
id?: string;
|
|
19
|
+
htmlAttributes?: {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
};
|
|
22
|
+
enterAnimation?: AnimationBuilder;
|
|
23
|
+
leaveAnimation?: AnimationBuilder;
|
|
24
|
+
size?: PopoverSize;
|
|
25
|
+
dismissOnSelect?: boolean;
|
|
26
|
+
reference?: PositionReference;
|
|
27
|
+
side?: PositionSide;
|
|
28
|
+
alignment?: PositionAlign;
|
|
29
|
+
arrow?: boolean;
|
|
30
|
+
trigger?: string;
|
|
31
|
+
triggerAction?: string;
|
|
32
|
+
}
|
|
33
|
+
export type PopoverSize = 'cover' | 'auto';
|
|
34
|
+
export type TriggerAction = 'click' | 'hover' | 'context-menu';
|
|
35
|
+
export type PositionReference = 'trigger' | 'event';
|
|
36
|
+
export type PositionSide = 'top' | 'right' | 'bottom' | 'left' | 'start' | 'end';
|
|
37
|
+
export type PositionAlign = 'start' | 'center' | 'end';
|
|
38
|
+
//# sourceMappingURL=popover-interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover-interface.d.ts","sourceRoot":"","sources":["../../src/popover/popover-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE7H,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5E;AAED,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY;IACnE,SAAS,EAAE,CAAC,C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,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { PopoverSize, PositionAlign, PositionReference, PositionSide, TriggerAction } from './popover-interface';
|
|
2
|
+
export interface ReferenceCoordinates {
|
|
3
|
+
top: number;
|
|
4
|
+
left: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
interface PopoverPosition {
|
|
9
|
+
top: number;
|
|
10
|
+
left: number;
|
|
11
|
+
referenceCoordinates?: ReferenceCoordinates;
|
|
12
|
+
arrowTop?: number;
|
|
13
|
+
arrowLeft?: number;
|
|
14
|
+
originX: string;
|
|
15
|
+
originY: string;
|
|
16
|
+
}
|
|
17
|
+
export interface PopoverStyles {
|
|
18
|
+
top: number;
|
|
19
|
+
left: number;
|
|
20
|
+
bottom?: number;
|
|
21
|
+
originX: string;
|
|
22
|
+
originY: string;
|
|
23
|
+
checkSafeAreaLeft: boolean;
|
|
24
|
+
checkSafeAreaRight: boolean;
|
|
25
|
+
arrowTop: number;
|
|
26
|
+
arrowLeft: number;
|
|
27
|
+
addPopoverBottomClass: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare const getArrowDimensions: (arrowEl: HTMLElement | null) => {
|
|
30
|
+
arrowWidth: number;
|
|
31
|
+
arrowHeight: number;
|
|
32
|
+
};
|
|
33
|
+
export declare const getPopoverDimensions: (size: PopoverSize, contentEl: HTMLElement, triggerEl?: HTMLElement) => {
|
|
34
|
+
contentWidth: number;
|
|
35
|
+
contentHeight: number;
|
|
36
|
+
};
|
|
37
|
+
export declare const configureDismissInteraction: (triggerEl: HTMLElement, triggerAction: TriggerAction, popoverEl: HTMLIonPopoverElement, parentPopoverEl: HTMLIonPopoverElement) => () => void;
|
|
38
|
+
export declare const configureTriggerInteraction: (triggerEl: HTMLElement, triggerAction: TriggerAction, popoverEl: HTMLIonPopoverElement) => () => void;
|
|
39
|
+
export declare const getIndexOfItem: (items: HTMLIonItemElement[], item: HTMLElement | null) => number;
|
|
40
|
+
export declare const getNextItem: (items: HTMLIonItemElement[], currentItem: HTMLElement | null) => HTMLIonItemElement;
|
|
41
|
+
export declare const getPrevItem: (items: HTMLIonItemElement[], currentItem: HTMLElement | null) => HTMLIonItemElement;
|
|
42
|
+
export declare const isTriggerElement: (el: HTMLElement) => boolean;
|
|
43
|
+
export declare const configureKeyboardInteraction: (popoverEl: HTMLIonPopoverElement) => () => void;
|
|
44
|
+
export declare const getPopoverPosition: (isRTL: boolean, contentWidth: number, contentHeight: number, arrowWidth: number, arrowHeight: number, reference: PositionReference, side: PositionSide, align: PositionAlign, defaultPosition: PopoverPosition, triggerEl?: HTMLElement, event?: MouseEvent | CustomEvent) => PopoverPosition;
|
|
45
|
+
export declare const calculateWindowAdjustment: (side: PositionSide, coordTop: number, coordLeft: number, bodyPadding: number, bodyWidth: number, bodyHeight: number, contentWidth: number, contentHeight: number, safeAreaMargin: number, contentOriginX: string, contentOriginY: string, triggerCoordinates?: ReferenceCoordinates, coordArrowTop?: number, coordArrowLeft?: number, arrowHeight?: number, eventElementRect?: DOMRect, isReplace?: boolean) => PopoverStyles;
|
|
46
|
+
export declare const shouldShowArrow: (side: PositionSide, didAdjustBounds?: boolean, ev?: Event, trigger?: HTMLElement) => boolean;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/popover/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAQtH,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE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eAAO,MAAM,WAAW,GAAI,OAAO,kBAAkB,EAAE,EAAE,aAAa,WAAW,GAAG,IAAI,uBAGvF,CAAC;AAgBF,eAAO,MAAM,gBAAgB,GAAI,IAAI,WAAW,YAAgD,CAAC;AAEjG,eAAO,MAAM,4BAA4B,GAAI,WAAW,qBAAqB,eAyG5E,CAAC;AAOF,eAAO,MAAM,kBAAkB,GAC7B,OAAO,OAAO,EACd,cAAc,MAAM,EACpB,eAAe,MAAM,EACrB,YAAY,MAAM,EAClB,aAAa,MAAM,EACnB,WAAW,iBAAiB,EAC5B,MAAM,YAAY,EAClB,OAAO,aAAa,EACpB,iBAAiB,eAAe,EAChC,YAAY,WAAW,EACvB,QAAQ,UAAU,GAAG,WAAW,KAC/B,eAuFF,CAAC;AAgPF,eAAO,MAAM,yBAAyB,GACpC,MAAM,YAAY,EAClB,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,aAAa,MAAM,EACnB,WAAW,MAAM,EACjB,YAAY,MAAM,EAClB,cAAc,MAAM,EACpB,eAAe,MAAM,EACrB,gBAAgB,MAAM,EACtB,gBAAgB,MAAM,EACtB,gBAAgB,MAAM,EACtB,qBAAqB,oBAAoB,EACzC,sBAAiB,EACjB,uBAAkB,EAClB,oBAAe,EACf,mBAAmB,OAAO,EAC1B,YAAW,OAAe,KACzB,aAkFF,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,MAAM,YAAY,EAAE,yBAAuB,EAAE,KAAK,KAAK,EAAE,UAAU,WAAW,YA0B7G,CAAC"}
|
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import { getElementRoot, raf } from '../utils';
|
|
2
|
+
import { POPOVER_IOS_BODY_MARGIN } from './animations/ios.enter';
|
|
3
|
+
export const getArrowDimensions = (arrowEl) => {
|
|
4
|
+
if (!arrowEl) {
|
|
5
|
+
return { arrowWidth: 0, arrowHeight: 0 };
|
|
6
|
+
}
|
|
7
|
+
const { width, height } = arrowEl.getBoundingClientRect();
|
|
8
|
+
return { arrowWidth: width, arrowHeight: height };
|
|
9
|
+
};
|
|
10
|
+
export const getPopoverDimensions = (size, contentEl, triggerEl) => {
|
|
11
|
+
const contentDimentions = contentEl.getBoundingClientRect();
|
|
12
|
+
const contentHeight = contentDimentions.height;
|
|
13
|
+
let contentWidth = contentDimentions.width;
|
|
14
|
+
if (size === 'cover' && triggerEl) {
|
|
15
|
+
const triggerDimensions = triggerEl.getBoundingClientRect();
|
|
16
|
+
contentWidth = triggerDimensions.width;
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
contentWidth,
|
|
20
|
+
contentHeight,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export const configureDismissInteraction = (triggerEl, triggerAction, popoverEl, parentPopoverEl) => {
|
|
24
|
+
let dismissCallbacks = [];
|
|
25
|
+
const root = getElementRoot(parentPopoverEl);
|
|
26
|
+
const parentContentEl = root.querySelector('.popover-content');
|
|
27
|
+
switch (triggerAction) {
|
|
28
|
+
case 'hover':
|
|
29
|
+
dismissCallbacks = [
|
|
30
|
+
{
|
|
31
|
+
eventName: 'mouseenter',
|
|
32
|
+
callback: (ev) => {
|
|
33
|
+
const element = document.elementFromPoint(ev.clientX, ev.clientY);
|
|
34
|
+
if (element === triggerEl) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
popoverEl.dismiss(undefined, undefined, false);
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
break;
|
|
42
|
+
case 'context-menu':
|
|
43
|
+
case 'click':
|
|
44
|
+
default:
|
|
45
|
+
dismissCallbacks = [
|
|
46
|
+
{
|
|
47
|
+
eventName: 'click',
|
|
48
|
+
callback: (ev) => {
|
|
49
|
+
const target = ev.target;
|
|
50
|
+
const closestTrigger = target.closest('[data-ion-popover-trigger]');
|
|
51
|
+
if (closestTrigger === triggerEl) {
|
|
52
|
+
ev.stopPropagation();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
popoverEl.dismiss(undefined, undefined, false);
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
dismissCallbacks.forEach(({ eventName, callback }) => parentContentEl.addEventListener(eventName, callback));
|
|
62
|
+
return () => {
|
|
63
|
+
dismissCallbacks.forEach(({ eventName, callback }) => parentContentEl.removeEventListener(eventName, callback));
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export const configureTriggerInteraction = (triggerEl, triggerAction, popoverEl) => {
|
|
67
|
+
let triggerCallbacks = [];
|
|
68
|
+
switch (triggerAction) {
|
|
69
|
+
case 'hover':
|
|
70
|
+
let hoverTimeout;
|
|
71
|
+
triggerCallbacks = [
|
|
72
|
+
{
|
|
73
|
+
eventName: 'mouseenter',
|
|
74
|
+
callback: async (ev) => {
|
|
75
|
+
ev.stopPropagation();
|
|
76
|
+
if (hoverTimeout) {
|
|
77
|
+
clearTimeout(hoverTimeout);
|
|
78
|
+
}
|
|
79
|
+
hoverTimeout = setTimeout(() => {
|
|
80
|
+
raf(() => {
|
|
81
|
+
popoverEl.presentFromTrigger(ev);
|
|
82
|
+
hoverTimeout = undefined;
|
|
83
|
+
});
|
|
84
|
+
}, 100);
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
eventName: 'mouseleave',
|
|
89
|
+
callback: (ev) => {
|
|
90
|
+
if (hoverTimeout) {
|
|
91
|
+
clearTimeout(hoverTimeout);
|
|
92
|
+
}
|
|
93
|
+
const target = ev.relatedTarget;
|
|
94
|
+
if (!target) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (target.closest('ion-popover') !== popoverEl) {
|
|
98
|
+
popoverEl.dismiss(undefined, undefined, false);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
eventName: 'click',
|
|
104
|
+
callback: (ev) => ev.stopPropagation(),
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
eventName: 'ionPopoverActivateTrigger',
|
|
108
|
+
callback: (ev) => popoverEl.presentFromTrigger(ev, true),
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
break;
|
|
112
|
+
case 'context-menu':
|
|
113
|
+
triggerCallbacks = [
|
|
114
|
+
{
|
|
115
|
+
eventName: 'contextmenu',
|
|
116
|
+
callback: (ev) => {
|
|
117
|
+
ev.preventDefault();
|
|
118
|
+
popoverEl.presentFromTrigger(ev);
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
eventName: 'click',
|
|
123
|
+
callback: (ev) => ev.stopPropagation(),
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
eventName: 'ionPopoverActivateTrigger',
|
|
127
|
+
callback: (ev) => popoverEl.presentFromTrigger(ev, true),
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
break;
|
|
131
|
+
case 'click':
|
|
132
|
+
default:
|
|
133
|
+
triggerCallbacks = [
|
|
134
|
+
{
|
|
135
|
+
eventName: 'click',
|
|
136
|
+
callback: (ev) => popoverEl.presentFromTrigger(ev),
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
eventName: 'ionPopoverActivateTrigger',
|
|
140
|
+
callback: (ev) => popoverEl.presentFromTrigger(ev, true),
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
triggerCallbacks.forEach(({ eventName, callback }) => triggerEl.addEventListener(eventName, callback));
|
|
146
|
+
triggerEl.setAttribute('data-ion-popover-trigger', 'true');
|
|
147
|
+
return () => {
|
|
148
|
+
triggerCallbacks.forEach(({ eventName, callback }) => triggerEl.removeEventListener(eventName, callback));
|
|
149
|
+
triggerEl.removeAttribute('data-ion-popover-trigger');
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
export const getIndexOfItem = (items, item) => {
|
|
153
|
+
if (!item || item.tagName !== 'ION-ITEM') {
|
|
154
|
+
return -1;
|
|
155
|
+
}
|
|
156
|
+
return items.findIndex((el) => el === item);
|
|
157
|
+
};
|
|
158
|
+
export const getNextItem = (items, currentItem) => {
|
|
159
|
+
const currentItemIndex = getIndexOfItem(items, currentItem);
|
|
160
|
+
return items[currentItemIndex + 1];
|
|
161
|
+
};
|
|
162
|
+
export const getPrevItem = (items, currentItem) => {
|
|
163
|
+
const currentItemIndex = getIndexOfItem(items, currentItem);
|
|
164
|
+
return items[currentItemIndex - 1];
|
|
165
|
+
};
|
|
166
|
+
const focusItem = (item) => {
|
|
167
|
+
const root = getElementRoot(item);
|
|
168
|
+
const button = root.querySelector('button');
|
|
169
|
+
if (button) {
|
|
170
|
+
raf(() => button.focus());
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
export const isTriggerElement = (el) => el.hasAttribute('data-ion-popover-trigger');
|
|
174
|
+
export const configureKeyboardInteraction = (popoverEl) => {
|
|
175
|
+
const callback = async (ev) => {
|
|
176
|
+
const activeElement = document.activeElement;
|
|
177
|
+
let items = [];
|
|
178
|
+
const targetTagName = ev.target?.tagName;
|
|
179
|
+
if (targetTagName !== 'ION-POPOVER' && targetTagName !== 'ION-ITEM') {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
items = Array.from(popoverEl.querySelectorAll('ion-item:not(ion-popover ion-popover *):not([disabled])'));
|
|
184
|
+
}
|
|
185
|
+
catch { }
|
|
186
|
+
switch (ev.key) {
|
|
187
|
+
case 'ArrowLeft':
|
|
188
|
+
const parentPopover = await popoverEl.getParentPopover();
|
|
189
|
+
if (parentPopover) {
|
|
190
|
+
popoverEl.dismiss(undefined, undefined, false);
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
case 'ArrowDown':
|
|
194
|
+
ev.preventDefault();
|
|
195
|
+
const nextItem = getNextItem(items, activeElement);
|
|
196
|
+
if (nextItem !== undefined) {
|
|
197
|
+
focusItem(nextItem);
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
200
|
+
case 'ArrowUp':
|
|
201
|
+
ev.preventDefault();
|
|
202
|
+
const prevItem = getPrevItem(items, activeElement);
|
|
203
|
+
if (prevItem !== undefined) {
|
|
204
|
+
focusItem(prevItem);
|
|
205
|
+
}
|
|
206
|
+
break;
|
|
207
|
+
case 'Home':
|
|
208
|
+
ev.preventDefault();
|
|
209
|
+
const firstItem = items[0];
|
|
210
|
+
if (firstItem !== undefined) {
|
|
211
|
+
focusItem(firstItem);
|
|
212
|
+
}
|
|
213
|
+
break;
|
|
214
|
+
case 'End':
|
|
215
|
+
ev.preventDefault();
|
|
216
|
+
const lastItem = items[items.length - 1];
|
|
217
|
+
if (lastItem !== undefined) {
|
|
218
|
+
focusItem(lastItem);
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
221
|
+
case 'ArrowRight':
|
|
222
|
+
case ' ':
|
|
223
|
+
case 'Enter':
|
|
224
|
+
if (activeElement && isTriggerElement(activeElement)) {
|
|
225
|
+
const rightEvent = new CustomEvent('ionPopoverActivateTrigger');
|
|
226
|
+
activeElement.dispatchEvent(rightEvent);
|
|
227
|
+
}
|
|
228
|
+
break;
|
|
229
|
+
default:
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
popoverEl.addEventListener('keydown', callback);
|
|
234
|
+
return () => popoverEl.removeEventListener('keydown', callback);
|
|
235
|
+
};
|
|
236
|
+
export const getPopoverPosition = (isRTL, contentWidth, contentHeight, arrowWidth, arrowHeight, reference, side, align, defaultPosition, triggerEl, event) => {
|
|
237
|
+
let referenceCoordinates = {
|
|
238
|
+
top: 0,
|
|
239
|
+
left: 0,
|
|
240
|
+
width: 0,
|
|
241
|
+
height: 0,
|
|
242
|
+
};
|
|
243
|
+
switch (reference) {
|
|
244
|
+
case 'event':
|
|
245
|
+
if (!event) {
|
|
246
|
+
return defaultPosition;
|
|
247
|
+
}
|
|
248
|
+
const mouseEv = event;
|
|
249
|
+
referenceCoordinates = {
|
|
250
|
+
top: mouseEv.clientY,
|
|
251
|
+
left: mouseEv.clientX,
|
|
252
|
+
width: 1,
|
|
253
|
+
height: 1,
|
|
254
|
+
};
|
|
255
|
+
break;
|
|
256
|
+
case 'trigger':
|
|
257
|
+
default:
|
|
258
|
+
const customEv = event;
|
|
259
|
+
const actualTriggerEl = (triggerEl || customEv?.detail?.ionShadowTarget || customEv?.target);
|
|
260
|
+
if (!actualTriggerEl) {
|
|
261
|
+
return defaultPosition;
|
|
262
|
+
}
|
|
263
|
+
const triggerBoundingBox = actualTriggerEl.getBoundingClientRect();
|
|
264
|
+
referenceCoordinates = {
|
|
265
|
+
top: triggerBoundingBox.top,
|
|
266
|
+
left: triggerBoundingBox.left,
|
|
267
|
+
width: triggerBoundingBox.width,
|
|
268
|
+
height: triggerBoundingBox.height,
|
|
269
|
+
};
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
const coordinates = calculatePopoverSide(side, referenceCoordinates, contentWidth, contentHeight, arrowWidth, arrowHeight, isRTL);
|
|
273
|
+
const alignedCoordinates = calculatePopoverAlign(align, side, referenceCoordinates, contentWidth, contentHeight);
|
|
274
|
+
const top = coordinates.top + alignedCoordinates.top;
|
|
275
|
+
const left = coordinates.left + alignedCoordinates.left;
|
|
276
|
+
const { arrowTop, arrowLeft } = calculateArrowPosition(side, arrowWidth, arrowHeight, top, left, contentWidth, contentHeight, isRTL);
|
|
277
|
+
const { originX, originY } = calculatePopoverOrigin(side, align, isRTL);
|
|
278
|
+
return { top, left, referenceCoordinates, arrowTop, arrowLeft, originX, originY };
|
|
279
|
+
};
|
|
280
|
+
const calculatePopoverOrigin = (side, align, isRTL) => {
|
|
281
|
+
switch (side) {
|
|
282
|
+
case 'top':
|
|
283
|
+
return { originX: getOriginXAlignment(align), originY: 'bottom' };
|
|
284
|
+
case 'bottom':
|
|
285
|
+
return { originX: getOriginXAlignment(align), originY: 'top' };
|
|
286
|
+
case 'left':
|
|
287
|
+
return { originX: 'right', originY: getOriginYAlignment(align) };
|
|
288
|
+
case 'right':
|
|
289
|
+
return { originX: 'left', originY: getOriginYAlignment(align) };
|
|
290
|
+
case 'start':
|
|
291
|
+
return { originX: isRTL ? 'left' : 'right', originY: getOriginYAlignment(align) };
|
|
292
|
+
case 'end':
|
|
293
|
+
return { originX: isRTL ? 'right' : 'left', originY: getOriginYAlignment(align) };
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
const getOriginXAlignment = (align) => {
|
|
297
|
+
switch (align) {
|
|
298
|
+
case 'start':
|
|
299
|
+
return 'left';
|
|
300
|
+
case 'center':
|
|
301
|
+
return 'center';
|
|
302
|
+
case 'end':
|
|
303
|
+
return 'right';
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
const getOriginYAlignment = (align) => {
|
|
307
|
+
switch (align) {
|
|
308
|
+
case 'start':
|
|
309
|
+
return 'top';
|
|
310
|
+
case 'center':
|
|
311
|
+
return 'center';
|
|
312
|
+
case 'end':
|
|
313
|
+
return 'bottom';
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
const calculateArrowPosition = (side, arrowWidth, arrowHeight, top, left, contentWidth, contentHeight, isRTL) => {
|
|
317
|
+
const leftPosition = {
|
|
318
|
+
arrowTop: top + contentHeight / 2 - arrowWidth / 2,
|
|
319
|
+
arrowLeft: left + contentWidth - arrowWidth / 2,
|
|
320
|
+
};
|
|
321
|
+
const rightPosition = { arrowTop: top + contentHeight / 2 - arrowWidth / 2, arrowLeft: left - arrowWidth * 1.5 };
|
|
322
|
+
switch (side) {
|
|
323
|
+
case 'top':
|
|
324
|
+
return { arrowTop: top + contentHeight, arrowLeft: left + contentWidth / 2 - arrowWidth / 2 };
|
|
325
|
+
case 'bottom':
|
|
326
|
+
return { arrowTop: top - arrowHeight, arrowLeft: left + contentWidth / 2 - arrowWidth / 2 };
|
|
327
|
+
case 'left':
|
|
328
|
+
return leftPosition;
|
|
329
|
+
case 'right':
|
|
330
|
+
return rightPosition;
|
|
331
|
+
case 'start':
|
|
332
|
+
return isRTL ? rightPosition : leftPosition;
|
|
333
|
+
case 'end':
|
|
334
|
+
return isRTL ? leftPosition : rightPosition;
|
|
335
|
+
default:
|
|
336
|
+
return { arrowTop: 0, arrowLeft: 0 };
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
const calculatePopoverSide = (side, triggerBoundingBox, contentWidth, contentHeight, arrowWidth, arrowHeight, isRTL) => {
|
|
340
|
+
const sideLeft = {
|
|
341
|
+
top: triggerBoundingBox.top,
|
|
342
|
+
left: triggerBoundingBox.left - contentWidth - arrowWidth,
|
|
343
|
+
};
|
|
344
|
+
const sideRight = {
|
|
345
|
+
top: triggerBoundingBox.top,
|
|
346
|
+
left: triggerBoundingBox.left + triggerBoundingBox.width + arrowWidth,
|
|
347
|
+
};
|
|
348
|
+
switch (side) {
|
|
349
|
+
case 'top':
|
|
350
|
+
return {
|
|
351
|
+
top: triggerBoundingBox.top - contentHeight - arrowHeight,
|
|
352
|
+
left: triggerBoundingBox.left,
|
|
353
|
+
};
|
|
354
|
+
case 'right':
|
|
355
|
+
return sideRight;
|
|
356
|
+
case 'bottom':
|
|
357
|
+
return {
|
|
358
|
+
top: triggerBoundingBox.top + triggerBoundingBox.height + arrowHeight,
|
|
359
|
+
left: triggerBoundingBox.left,
|
|
360
|
+
};
|
|
361
|
+
case 'left':
|
|
362
|
+
return sideLeft;
|
|
363
|
+
case 'start':
|
|
364
|
+
return isRTL ? sideRight : sideLeft;
|
|
365
|
+
case 'end':
|
|
366
|
+
return isRTL ? sideLeft : sideRight;
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
const calculatePopoverAlign = (align, side, triggerBoundingBox, contentWidth, contentHeight) => {
|
|
370
|
+
switch (align) {
|
|
371
|
+
case 'center':
|
|
372
|
+
return calculatePopoverCenterAlign(side, triggerBoundingBox, contentWidth, contentHeight);
|
|
373
|
+
case 'end':
|
|
374
|
+
return calculatePopoverEndAlign(side, triggerBoundingBox, contentWidth, contentHeight);
|
|
375
|
+
case 'start':
|
|
376
|
+
default:
|
|
377
|
+
return { top: 0, left: 0 };
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
const calculatePopoverEndAlign = (side, triggerBoundingBox, contentWidth, contentHeight) => {
|
|
381
|
+
switch (side) {
|
|
382
|
+
case 'start':
|
|
383
|
+
case 'end':
|
|
384
|
+
case 'left':
|
|
385
|
+
case 'right':
|
|
386
|
+
return {
|
|
387
|
+
top: -(contentHeight - triggerBoundingBox.height),
|
|
388
|
+
left: 0,
|
|
389
|
+
};
|
|
390
|
+
case 'top':
|
|
391
|
+
case 'bottom':
|
|
392
|
+
default:
|
|
393
|
+
return {
|
|
394
|
+
top: 0,
|
|
395
|
+
left: -(contentWidth - triggerBoundingBox.width),
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
const calculatePopoverCenterAlign = (side, triggerBoundingBox, contentWidth, contentHeight) => {
|
|
400
|
+
switch (side) {
|
|
401
|
+
case 'start':
|
|
402
|
+
case 'end':
|
|
403
|
+
case 'left':
|
|
404
|
+
case 'right':
|
|
405
|
+
return {
|
|
406
|
+
top: -(contentHeight / 2 - triggerBoundingBox.height / 2),
|
|
407
|
+
left: 0,
|
|
408
|
+
};
|
|
409
|
+
case 'top':
|
|
410
|
+
case 'bottom':
|
|
411
|
+
default:
|
|
412
|
+
return {
|
|
413
|
+
top: 0,
|
|
414
|
+
left: -(contentWidth / 2 - triggerBoundingBox.width / 2),
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
export const calculateWindowAdjustment = (side, coordTop, coordLeft, bodyPadding, bodyWidth, bodyHeight, contentWidth, contentHeight, safeAreaMargin, contentOriginX, contentOriginY, triggerCoordinates, coordArrowTop = 0, coordArrowLeft = 0, arrowHeight = 0, eventElementRect, isReplace = false) => {
|
|
419
|
+
let arrowTop = coordArrowTop;
|
|
420
|
+
const arrowLeft = coordArrowLeft;
|
|
421
|
+
const triggerTop = triggerCoordinates ? triggerCoordinates.top + triggerCoordinates.height : bodyHeight / 2 - contentHeight / 2;
|
|
422
|
+
const triggerHeight = triggerCoordinates ? triggerCoordinates.height : 0;
|
|
423
|
+
let left = coordLeft;
|
|
424
|
+
let top = !isReplace ? coordTop + POPOVER_IOS_BODY_MARGIN : coordTop - triggerHeight;
|
|
425
|
+
let bottom;
|
|
426
|
+
let originX = contentOriginX;
|
|
427
|
+
let originY = contentOriginY;
|
|
428
|
+
let checkSafeAreaLeft = false;
|
|
429
|
+
let checkSafeAreaRight = false;
|
|
430
|
+
let addPopoverBottomClass = false;
|
|
431
|
+
if (left < bodyPadding + safeAreaMargin) {
|
|
432
|
+
left = !eventElementRect ? bodyPadding : eventElementRect.left;
|
|
433
|
+
checkSafeAreaLeft = true;
|
|
434
|
+
originX = 'left';
|
|
435
|
+
}
|
|
436
|
+
else if (contentWidth + bodyPadding + left + safeAreaMargin > bodyWidth) {
|
|
437
|
+
checkSafeAreaRight = true;
|
|
438
|
+
left = !eventElementRect ? bodyWidth - contentWidth - bodyPadding : eventElementRect.right - contentWidth;
|
|
439
|
+
originX = 'right';
|
|
440
|
+
}
|
|
441
|
+
const compareTop = triggerCoordinates ? triggerCoordinates.top + triggerCoordinates.height / 2 : bodyHeight / 2 - contentHeight / 2;
|
|
442
|
+
if (compareTop > bodyHeight / 2 && (side === 'top' || side === 'bottom')) {
|
|
443
|
+
if (triggerTop - contentHeight > 0) {
|
|
444
|
+
if (!isReplace) {
|
|
445
|
+
top = Math.max(12, triggerTop - contentHeight - triggerHeight - (arrowHeight - 1)) - POPOVER_IOS_BODY_MARGIN;
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
top = Math.max(12, triggerTop - contentHeight - (arrowHeight - 1));
|
|
449
|
+
}
|
|
450
|
+
arrowTop = top + contentHeight;
|
|
451
|
+
originY = 'bottom';
|
|
452
|
+
addPopoverBottomClass = true;
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
bottom = bodyPadding;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return {
|
|
459
|
+
top,
|
|
460
|
+
left,
|
|
461
|
+
bottom,
|
|
462
|
+
originX,
|
|
463
|
+
originY,
|
|
464
|
+
checkSafeAreaLeft,
|
|
465
|
+
checkSafeAreaRight,
|
|
466
|
+
arrowTop,
|
|
467
|
+
arrowLeft,
|
|
468
|
+
addPopoverBottomClass,
|
|
469
|
+
};
|
|
470
|
+
};
|
|
471
|
+
export const shouldShowArrow = (side, didAdjustBounds = false, ev, trigger) => {
|
|
472
|
+
if (!ev && !trigger) {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
if (side !== 'top' && side !== 'bottom' && didAdjustBounds) {
|
|
476
|
+
return false;
|
|
477
|
+
}
|
|
478
|
+
return true;
|
|
479
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Animation, AnimationKeyFrames } from '@ionic/core/dist/types/utils/animation/animation-interface';
|
|
2
|
+
import { AnimationPosition, EffectScales } from './interfaces';
|
|
3
|
+
import { GestureDetail } from '@ionic/core';
|
|
4
|
+
export declare const getScaleAnimation: (effectElement: Element) => Animation;
|
|
5
|
+
export declare const createPreMoveAnimation: (effectElement: Element, tabSelectedElement: Element, currentTouchedElement: Element, animationPosition: AnimationPosition) => Animation;
|
|
6
|
+
export declare const createMoveAnimation: (effectElement: Element, detail: GestureDetail, tabSelectedElement: Element, animationPosition: AnimationPosition) => Animation;
|
|
7
|
+
export declare const getMoveAnimationKeyframe: (type: "moveRight" | "moveLeft" | "slowly", scales: EffectScales) => AnimationKeyFrames;
|
|
8
|
+
//# sourceMappingURL=animations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animations.d.ts","sourceRoot":"","sources":["../../src/sheets-of-glass/animations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,4DAA4D,CAAC;AAC3G,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AAG7D,eAAO,MAAM,iBAAiB,GAAI,eAAe,OAAO,KAAG,SAE1D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,eAAe,OAAO,EACtB,oBAAoB,OAAO,EAC3B,uBAAuB,OAAO,EAC9B,mBAAmB,iBAAiB,KACnC,SA0BF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,eAAe,OAAO,EACtB,QAAQ,aAAa,EACrB,oBAAoB,OAAO,EAC3B,mBAAmB,iBAAiB,KACnC,SAiBF,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,MAAM,WAAW,GAAG,UAAU,GAAG,QAAQ,EAAE,QAAQ,YAAY,KAAG,kBAqD1G,CAAC"}
|