@rdlabo/ionic-theme-ios27 1.0.4 → 1.1.0-beta.pr224.shac63de393e27b

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 (96) hide show
  1. package/dist/css/components/ion-toggle.css +1 -1
  2. package/dist/css/ionic-theme-ios27.css +1 -1
  3. package/dist/native/components/searchable-tabs.d.ts.map +1 -1
  4. package/dist/native/components/searchable-tabs.js +2 -0
  5. package/dist/native/runtime.d.ts.map +1 -1
  6. package/dist/native/runtime.js +73 -7
  7. package/dist/native/shared/crossfade.d.ts +2 -2
  8. package/dist/native/shared/crossfade.d.ts.map +1 -1
  9. package/dist/native/shared/crossfade.js +3 -3
  10. package/dist/segment/index.d.ts.map +1 -1
  11. package/dist/segment/index.js +7 -0
  12. package/docs/animation.md +2 -2
  13. package/docs/native-ui-shell.md +2 -0
  14. package/package.json +2 -5
  15. package/src/native/components/searchable-tabs.ts +3 -0
  16. package/src/native/runtime.ts +81 -6
  17. package/src/native/shared/crossfade.ts +4 -3
  18. package/src/segment/index.ts +11 -0
  19. package/src/styles/components/ion-toggle.scss +8 -2
  20. package/src/tab-bar-searchable/index.ts +1 -1
  21. package/node_modules/@rdlabo/ionic-theme-utils/LICENSE +0 -21
  22. package/node_modules/@rdlabo/ionic-theme-utils/README.md +0 -28
  23. package/node_modules/@rdlabo/ionic-theme-utils/dist/dom.d.ts +0 -3
  24. package/node_modules/@rdlabo/ionic-theme-utils/dist/dom.d.ts.map +0 -1
  25. package/node_modules/@rdlabo/ionic-theme-utils/dist/dom.js +0 -13
  26. package/node_modules/@rdlabo/ionic-theme-utils/dist/dom.js.map +0 -1
  27. package/node_modules/@rdlabo/ionic-theme-utils/dist/focus-controller.d.ts +0 -6
  28. package/node_modules/@rdlabo/ionic-theme-utils/dist/focus-controller.d.ts.map +0 -1
  29. package/node_modules/@rdlabo/ionic-theme-utils/dist/focus-controller.js +0 -37
  30. package/node_modules/@rdlabo/ionic-theme-utils/dist/focus-controller.js.map +0 -1
  31. package/node_modules/@rdlabo/ionic-theme-utils/dist/index.d.ts +0 -13
  32. package/node_modules/@rdlabo/ionic-theme-utils/dist/index.d.ts.map +0 -1
  33. package/node_modules/@rdlabo/ionic-theme-utils/dist/index.js +0 -11
  34. package/node_modules/@rdlabo/ionic-theme-utils/dist/index.js.map +0 -1
  35. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/animations/ios.enter.d.ts +0 -3
  36. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/animations/ios.enter.d.ts.map +0 -1
  37. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/animations/ios.enter.js +0 -196
  38. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/animations/ios.enter.js.map +0 -1
  39. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/animations/ios.leave.d.ts +0 -3
  40. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/animations/ios.leave.d.ts.map +0 -1
  41. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/animations/ios.leave.js +0 -80
  42. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/animations/ios.leave.js.map +0 -1
  43. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/callout-surface.d.ts +0 -2
  44. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/callout-surface.d.ts.map +0 -1
  45. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/callout-surface.js +0 -45
  46. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/callout-surface.js.map +0 -1
  47. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/popover-interface.d.ts +0 -38
  48. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/popover-interface.d.ts.map +0 -1
  49. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/popover-interface.js +0 -2
  50. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/popover-interface.js.map +0 -1
  51. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/utils.d.ts +0 -38
  52. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/utils.d.ts.map +0 -1
  53. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/utils.js +0 -378
  54. package/node_modules/@rdlabo/ionic-theme-utils/dist/popover/utils.js.map +0 -1
  55. package/node_modules/@rdlabo/ionic-theme-utils/dist/sheets-of-glass.d.ts +0 -16
  56. package/node_modules/@rdlabo/ionic-theme-utils/dist/sheets-of-glass.d.ts.map +0 -1
  57. package/node_modules/@rdlabo/ionic-theme-utils/dist/sheets-of-glass.js +0 -2
  58. package/node_modules/@rdlabo/ionic-theme-utils/dist/sheets-of-glass.js.map +0 -1
  59. package/node_modules/@rdlabo/ionic-theme-utils/dist/tab-bar-searchable/interfaces.d.ts +0 -41
  60. package/node_modules/@rdlabo/ionic-theme-utils/dist/tab-bar-searchable/interfaces.d.ts.map +0 -1
  61. package/node_modules/@rdlabo/ionic-theme-utils/dist/tab-bar-searchable/interfaces.js +0 -6
  62. package/node_modules/@rdlabo/ionic-theme-utils/dist/tab-bar-searchable/interfaces.js.map +0 -1
  63. package/node_modules/@rdlabo/ionic-theme-utils/dist/tab-bar-searchable/utils.d.ts +0 -12
  64. package/node_modules/@rdlabo/ionic-theme-utils/dist/tab-bar-searchable/utils.d.ts.map +0 -1
  65. package/node_modules/@rdlabo/ionic-theme-utils/dist/tab-bar-searchable/utils.js +0 -61
  66. package/node_modules/@rdlabo/ionic-theme-utils/dist/tab-bar-searchable/utils.js.map +0 -1
  67. package/node_modules/@rdlabo/ionic-theme-utils/dist/theme.d.ts +0 -15
  68. package/node_modules/@rdlabo/ionic-theme-utils/dist/theme.d.ts.map +0 -1
  69. package/node_modules/@rdlabo/ionic-theme-utils/dist/theme.js +0 -49
  70. package/node_modules/@rdlabo/ionic-theme-utils/dist/theme.js.map +0 -1
  71. package/node_modules/@rdlabo/ionic-theme-utils/dist/transition/ios.transition.d.ts +0 -18
  72. package/node_modules/@rdlabo/ionic-theme-utils/dist/transition/ios.transition.d.ts.map +0 -1
  73. package/node_modules/@rdlabo/ionic-theme-utils/dist/transition/ios.transition.js +0 -412
  74. package/node_modules/@rdlabo/ionic-theme-utils/dist/transition/ios.transition.js.map +0 -1
  75. package/node_modules/@rdlabo/ionic-theme-utils/package.json +0 -68
  76. package/node_modules/@rdlabo/ionic-theme-utils/scripts/copy-structured-list.mjs +0 -17
  77. package/node_modules/@rdlabo/ionic-theme-utils/src/dom.spec.ts +0 -19
  78. package/node_modules/@rdlabo/ionic-theme-utils/src/dom.ts +0 -16
  79. package/node_modules/@rdlabo/ionic-theme-utils/src/focus-controller.ts +0 -38
  80. package/node_modules/@rdlabo/ionic-theme-utils/src/index.ts +0 -59
  81. package/node_modules/@rdlabo/ionic-theme-utils/src/popover/animations/ios.enter.ts +0 -259
  82. package/node_modules/@rdlabo/ionic-theme-utils/src/popover/animations/ios.leave.ts +0 -99
  83. package/node_modules/@rdlabo/ionic-theme-utils/src/popover/callout-surface.ts +0 -54
  84. package/node_modules/@rdlabo/ionic-theme-utils/src/popover/popover-interface.ts +0 -44
  85. package/node_modules/@rdlabo/ionic-theme-utils/src/popover/utils.spec.ts +0 -58
  86. package/node_modules/@rdlabo/ionic-theme-utils/src/popover/utils.ts +0 -698
  87. package/node_modules/@rdlabo/ionic-theme-utils/src/sheets-of-glass.ts +0 -17
  88. package/node_modules/@rdlabo/ionic-theme-utils/src/styles/index.scss +0 -1
  89. package/node_modules/@rdlabo/ionic-theme-utils/src/styles/md-ion-list-inset.scss +0 -20
  90. package/node_modules/@rdlabo/ionic-theme-utils/src/styles/structured-list.scss +0 -310
  91. package/node_modules/@rdlabo/ionic-theme-utils/src/tab-bar-searchable/interfaces.ts +0 -28
  92. package/node_modules/@rdlabo/ionic-theme-utils/src/tab-bar-searchable/utils.spec.ts +0 -56
  93. package/node_modules/@rdlabo/ionic-theme-utils/src/tab-bar-searchable/utils.ts +0 -75
  94. package/node_modules/@rdlabo/ionic-theme-utils/src/theme.ts +0 -51
  95. package/node_modules/@rdlabo/ionic-theme-utils/src/transition/ios.transition.spec.ts +0 -52
  96. package/node_modules/@rdlabo/ionic-theme-utils/src/transition/ios.transition.ts +0 -542
@@ -1,698 +0,0 @@
1
- import { getElementRoot, raf } from '../dom';
2
-
3
- import type { PopoverSize, PositionAlign, PositionReference, PositionSide, TriggerAction } from './popover-interface';
4
-
5
- /** Shared with theme popover enter animations (iOS body margin). */
6
- export const POPOVER_IOS_BODY_MARGIN = 8;
7
-
8
- interface InteractionCallback {
9
- eventName: string;
10
- callback: (ev: any) => void; // TODO(FW-2832): type
11
- }
12
-
13
- export interface ReferenceCoordinates {
14
- top: number;
15
- left: number;
16
- width: number;
17
- height: number;
18
- }
19
-
20
- interface PopoverPosition {
21
- top: number;
22
- left: number;
23
- referenceCoordinates?: ReferenceCoordinates;
24
- originX: string;
25
- originY: string;
26
- }
27
-
28
- export interface PopoverStyles {
29
- top: number;
30
- left: number;
31
- bottom?: number;
32
- originX: string;
33
- originY: string;
34
- checkSafeAreaLeft: boolean;
35
- checkSafeAreaRight: boolean;
36
- addPopoverBottomClass: boolean;
37
- }
38
-
39
- /**
40
- * Returns the recommended dimensions of the popover
41
- * that takes into account whether or not the width
42
- * should match the trigger width.
43
- */
44
- export const getPopoverDimensions = (size: PopoverSize, contentEl: HTMLElement, triggerEl?: HTMLElement) => {
45
- const contentDimentions = contentEl.getBoundingClientRect();
46
- const contentHeight = contentDimentions.height;
47
- let contentWidth = contentDimentions.width;
48
-
49
- if (size === 'cover' && triggerEl) {
50
- const triggerDimensions = triggerEl.getBoundingClientRect();
51
- contentWidth = triggerDimensions.width;
52
- }
53
-
54
- return {
55
- contentWidth,
56
- contentHeight,
57
- };
58
- };
59
-
60
- export const configureDismissInteraction = (
61
- triggerEl: HTMLElement,
62
- triggerAction: TriggerAction,
63
- popoverEl: HTMLIonPopoverElement,
64
- parentPopoverEl: HTMLIonPopoverElement,
65
- ) => {
66
- let dismissCallbacks: InteractionCallback[] = [];
67
- const root = getElementRoot(parentPopoverEl);
68
- const parentContentEl = root.querySelector('.popover-content') as HTMLElement;
69
-
70
- switch (triggerAction) {
71
- case 'hover':
72
- dismissCallbacks = [
73
- {
74
- /**
75
- * Do not use mouseover here
76
- * as this will causes the event to
77
- * be dispatched on each underlying
78
- * element rather than on the popover
79
- * content as a whole.
80
- */
81
- eventName: 'mouseenter',
82
- callback: (ev: MouseEvent) => {
83
- /**
84
- * Do not dismiss the popover is we
85
- * are hovering over its trigger.
86
- * This would be easier if we used mouseover
87
- * but this would cause the event to be dispatched
88
- * more often than we would like, potentially
89
- * causing performance issues.
90
- */
91
- const element = document.elementFromPoint(ev.clientX, ev.clientY) as HTMLElement | null;
92
- if (element === triggerEl) {
93
- return;
94
- }
95
-
96
- popoverEl.dismiss(undefined, undefined, false);
97
- },
98
- },
99
- ];
100
- break;
101
- case 'context-menu':
102
- case 'click':
103
- default:
104
- dismissCallbacks = [
105
- {
106
- eventName: 'click',
107
- callback: (ev: MouseEvent) => {
108
- /**
109
- * Do not dismiss the popover is we
110
- * are hovering over its trigger.
111
- */
112
- const target = ev.target as HTMLElement;
113
- const closestTrigger = target.closest('[data-ion-popover-trigger]');
114
- if (closestTrigger === triggerEl) {
115
- /**
116
- * stopPropagation here so if the
117
- * popover has dismissOnSelect="true"
118
- * the popover does not dismiss since
119
- * we just clicked a trigger element.
120
- */
121
- ev.stopPropagation();
122
- return;
123
- }
124
-
125
- popoverEl.dismiss(undefined, undefined, false);
126
- },
127
- },
128
- ];
129
- break;
130
- }
131
-
132
- dismissCallbacks.forEach(({ eventName, callback }) => parentContentEl.addEventListener(eventName, callback));
133
-
134
- return () => {
135
- dismissCallbacks.forEach(({ eventName, callback }) => parentContentEl.removeEventListener(eventName, callback));
136
- };
137
- };
138
-
139
- /**
140
- * Configures the triggerEl to respond
141
- * to user interaction based upon the triggerAction
142
- * prop that devs have defined.
143
- */
144
- export const configureTriggerInteraction = (triggerEl: HTMLElement, triggerAction: TriggerAction, popoverEl: HTMLIonPopoverElement) => {
145
- let triggerCallbacks: InteractionCallback[] = [];
146
-
147
- /**
148
- * Based upon the kind of trigger interaction
149
- * the user wants, we setup the correct event
150
- * listeners.
151
- */
152
- switch (triggerAction) {
153
- case 'hover':
154
- let hoverTimeout: ReturnType<typeof setTimeout> | undefined;
155
-
156
- triggerCallbacks = [
157
- {
158
- eventName: 'mouseenter',
159
- callback: async (ev: Event) => {
160
- ev.stopPropagation();
161
-
162
- if (hoverTimeout) {
163
- clearTimeout(hoverTimeout);
164
- }
165
-
166
- /**
167
- * Hovering over a trigger should not
168
- * immediately open the next popover.
169
- */
170
- hoverTimeout = setTimeout(() => {
171
- raf(() => {
172
- popoverEl.presentFromTrigger(ev);
173
- hoverTimeout = undefined;
174
- });
175
- }, 100);
176
- },
177
- },
178
- {
179
- eventName: 'mouseleave',
180
- callback: (ev: MouseEvent) => {
181
- if (hoverTimeout) {
182
- clearTimeout(hoverTimeout);
183
- }
184
-
185
- /**
186
- * If mouse is over another popover
187
- * that is not this popover then we should
188
- * close this popover.
189
- */
190
- const target = ev.relatedTarget as HTMLElement | null;
191
- if (!target) {
192
- return;
193
- }
194
-
195
- if (target.closest('ion-popover') !== popoverEl) {
196
- popoverEl.dismiss(undefined, undefined, false);
197
- }
198
- },
199
- },
200
- {
201
- /**
202
- * stopPropagation here prevents the popover
203
- * from dismissing when dismiss-on-select="true".
204
- */
205
- eventName: 'click',
206
- callback: (ev: Event) => ev.stopPropagation(),
207
- },
208
- {
209
- eventName: 'ionPopoverActivateTrigger',
210
- callback: (ev: Event) => popoverEl.presentFromTrigger(ev, true),
211
- },
212
- ];
213
-
214
- break;
215
- case 'context-menu':
216
- triggerCallbacks = [
217
- {
218
- eventName: 'contextmenu',
219
- callback: (ev: Event) => {
220
- /**
221
- * Prevents the platform context
222
- * menu from appearing.
223
- */
224
- ev.preventDefault();
225
- popoverEl.presentFromTrigger(ev);
226
- },
227
- },
228
- {
229
- eventName: 'click',
230
- callback: (ev: Event) => ev.stopPropagation(),
231
- },
232
- {
233
- eventName: 'ionPopoverActivateTrigger',
234
- callback: (ev: Event) => popoverEl.presentFromTrigger(ev, true),
235
- },
236
- ];
237
-
238
- break;
239
- case 'click':
240
- default:
241
- triggerCallbacks = [
242
- {
243
- /**
244
- * Do not do a stopPropagation() here
245
- * because if you had two click triggers
246
- * then clicking the first trigger and then
247
- * clicking the second trigger would not cause
248
- * the first popover to dismiss.
249
- */
250
- eventName: 'click',
251
- callback: (ev: Event) => popoverEl.presentFromTrigger(ev),
252
- },
253
- {
254
- eventName: 'ionPopoverActivateTrigger',
255
- callback: (ev: Event) => popoverEl.presentFromTrigger(ev, true),
256
- },
257
- ];
258
- break;
259
- }
260
-
261
- triggerCallbacks.forEach(({ eventName, callback }) => triggerEl.addEventListener(eventName, callback));
262
- triggerEl.setAttribute('data-ion-popover-trigger', 'true');
263
-
264
- return () => {
265
- triggerCallbacks.forEach(({ eventName, callback }) => triggerEl.removeEventListener(eventName, callback));
266
- triggerEl.removeAttribute('data-ion-popover-trigger');
267
- };
268
- };
269
-
270
- /**
271
- * Returns the index of an ion-item in an array of ion-items.
272
- */
273
- export const getIndexOfItem = (items: HTMLIonItemElement[], item: HTMLElement | null) => {
274
- if (!item || item.tagName !== 'ION-ITEM') {
275
- return -1;
276
- }
277
-
278
- return items.findIndex((el) => el === item);
279
- };
280
-
281
- /**
282
- * Given an array of elements and a currently focused ion-item
283
- * returns the next ion-item relative to the focused one or
284
- * undefined.
285
- */
286
- export const getNextItem = (items: HTMLIonItemElement[], currentItem: HTMLElement | null) => {
287
- const currentItemIndex = getIndexOfItem(items, currentItem);
288
- return items[currentItemIndex + 1];
289
- };
290
-
291
- /**
292
- * Given an array of elements and a currently focused ion-item
293
- * returns the previous ion-item relative to the focused one or
294
- * undefined.
295
- */
296
- export const getPrevItem = (items: HTMLIonItemElement[], currentItem: HTMLElement | null) => {
297
- const currentItemIndex = getIndexOfItem(items, currentItem);
298
- return items[currentItemIndex - 1];
299
- };
300
-
301
- /** Focus the internal button of the ion-item */
302
- const focusItem = (item: HTMLIonItemElement) => {
303
- const root = getElementRoot(item);
304
- const button = root.querySelector('button');
305
-
306
- if (button) {
307
- raf(() => button.focus());
308
- }
309
- };
310
-
311
- /**
312
- * Positions a popover by taking into account
313
- * the reference point, preferred side, alignment
314
- * and viewport dimensions.
315
- */
316
- export const getPopoverPosition = (
317
- isRTL: boolean,
318
- contentWidth: number,
319
- contentHeight: number,
320
- reference: PositionReference,
321
- side: PositionSide,
322
- align: PositionAlign,
323
- defaultPosition: PopoverPosition,
324
- triggerEl?: HTMLElement,
325
- event?: MouseEvent | CustomEvent,
326
- ): PopoverPosition => {
327
- let referenceCoordinates = {
328
- top: 0,
329
- left: 0,
330
- width: 0,
331
- height: 0,
332
- };
333
-
334
- /**
335
- * Calculate position relative to the
336
- * x-y coordinates in the event that
337
- * was passed in
338
- */
339
- switch (reference) {
340
- case 'event':
341
- if (!event) {
342
- return defaultPosition;
343
- }
344
-
345
- const mouseEv = event as MouseEvent;
346
-
347
- referenceCoordinates = {
348
- top: mouseEv.clientY,
349
- left: mouseEv.clientX,
350
- width: 1,
351
- height: 1,
352
- };
353
-
354
- break;
355
-
356
- /**
357
- * Calculate position relative to the bounding
358
- * box on either the trigger element
359
- * specified via the `trigger` prop or
360
- * the target specified on the event
361
- * that was passed in.
362
- */
363
- case 'trigger':
364
- default:
365
- const customEv = event as CustomEvent;
366
-
367
- /**
368
- * ionShadowTarget is used when we need to align the
369
- * popover with an element inside of the shadow root
370
- * of an Ionic component. Ex: Presenting a popover
371
- * by clicking on the collapsed indicator inside
372
- * of `ion-breadcrumb` and centering it relative
373
- * to the indicator rather than `ion-breadcrumb`
374
- * as a whole.
375
- */
376
- const actualTriggerEl = (triggerEl || customEv?.detail?.ionShadowTarget || customEv?.target) as HTMLElement | null;
377
- if (!actualTriggerEl) {
378
- return defaultPosition;
379
- }
380
- const triggerBoundingBox = actualTriggerEl.getBoundingClientRect();
381
- referenceCoordinates = {
382
- top: triggerBoundingBox.top,
383
- left: triggerBoundingBox.left,
384
- width: triggerBoundingBox.width,
385
- height: triggerBoundingBox.height,
386
- };
387
-
388
- break;
389
- }
390
-
391
- /**
392
- * Get top/left offset that would allow
393
- * popover to be positioned on the
394
- * preferred side of the reference.
395
- */
396
- const coordinates = calculatePopoverSide(side, referenceCoordinates, contentWidth, contentHeight, isRTL);
397
-
398
- /**
399
- * Get the top/left adjustments that
400
- * would allow the popover content
401
- * to have the correct alignment.
402
- */
403
- const alignedCoordinates = calculatePopoverAlign(align, side, referenceCoordinates, contentWidth, contentHeight);
404
-
405
- const top = coordinates.top + alignedCoordinates.top;
406
- const left = coordinates.left + alignedCoordinates.left;
407
-
408
- const { originX, originY } = calculatePopoverOrigin(side, align, isRTL);
409
-
410
- return { top, left, referenceCoordinates, originX, originY };
411
- };
412
-
413
- /**
414
- * Determines the transform-origin
415
- * of the popover animation so that it
416
- * is in line with what the side and alignment
417
- * prop values are. Currently only used
418
- * with the MD animation.
419
- */
420
- const calculatePopoverOrigin = (side: PositionSide, align: PositionAlign, isRTL: boolean) => {
421
- switch (side) {
422
- case 'top':
423
- return { originX: getOriginXAlignment(align), originY: 'bottom' };
424
- case 'bottom':
425
- return { originX: getOriginXAlignment(align), originY: 'top' };
426
- case 'left':
427
- return { originX: 'right', originY: getOriginYAlignment(align) };
428
- case 'right':
429
- return { originX: 'left', originY: getOriginYAlignment(align) };
430
- case 'start':
431
- return { originX: isRTL ? 'left' : 'right', originY: getOriginYAlignment(align) };
432
- case 'end':
433
- return { originX: isRTL ? 'right' : 'left', originY: getOriginYAlignment(align) };
434
- }
435
- };
436
-
437
- const getOriginXAlignment = (align: PositionAlign) => {
438
- switch (align) {
439
- case 'start':
440
- return 'left';
441
- case 'center':
442
- return 'center';
443
- case 'end':
444
- return 'right';
445
- }
446
- };
447
-
448
- const getOriginYAlignment = (align: PositionAlign) => {
449
- switch (align) {
450
- case 'start':
451
- return 'top';
452
- case 'center':
453
- return 'center';
454
- case 'end':
455
- return 'bottom';
456
- }
457
- };
458
-
459
- /**
460
- * Calculates the required top/left
461
- * values needed to position the popover
462
- * content on the side specified in the
463
- * `side` prop.
464
- */
465
- const calculatePopoverSide = (
466
- side: PositionSide,
467
- triggerBoundingBox: ReferenceCoordinates,
468
- contentWidth: number,
469
- contentHeight: number,
470
- isRTL: boolean,
471
- ) => {
472
- const sideLeft = {
473
- top: triggerBoundingBox.top,
474
- left: triggerBoundingBox.left - contentWidth,
475
- };
476
- const sideRight = {
477
- top: triggerBoundingBox.top,
478
- left: triggerBoundingBox.left + triggerBoundingBox.width,
479
- };
480
-
481
- switch (side) {
482
- case 'top':
483
- return {
484
- top: triggerBoundingBox.top - contentHeight,
485
- left: triggerBoundingBox.left,
486
- };
487
- case 'right':
488
- return sideRight;
489
- case 'bottom':
490
- return {
491
- top: triggerBoundingBox.top + triggerBoundingBox.height,
492
- left: triggerBoundingBox.left,
493
- };
494
- case 'left':
495
- return sideLeft;
496
- case 'start':
497
- return isRTL ? sideRight : sideLeft;
498
- case 'end':
499
- return isRTL ? sideLeft : sideRight;
500
- }
501
- };
502
-
503
- /**
504
- * Calculates the required top/left
505
- * offset values needed to provide the
506
- * correct alignment regardless while taking
507
- * into account the side the popover is on.
508
- */
509
- const calculatePopoverAlign = (
510
- align: PositionAlign,
511
- side: PositionSide,
512
- triggerBoundingBox: ReferenceCoordinates,
513
- contentWidth: number,
514
- contentHeight: number,
515
- ) => {
516
- switch (align) {
517
- case 'center':
518
- return calculatePopoverCenterAlign(side, triggerBoundingBox, contentWidth, contentHeight);
519
- case 'end':
520
- return calculatePopoverEndAlign(side, triggerBoundingBox, contentWidth, contentHeight);
521
- case 'start':
522
- default:
523
- return { top: 0, left: 0 };
524
- }
525
- };
526
-
527
- /**
528
- * Calculate the end alignment for
529
- * the popover. If side is on the x-axis
530
- * then the align values refer to the top
531
- * and bottom margins of the content.
532
- * If side is on the y-axis then the
533
- * align values refer to the left and right
534
- * margins of the content.
535
- */
536
- const calculatePopoverEndAlign = (
537
- side: PositionSide,
538
- triggerBoundingBox: ReferenceCoordinates,
539
- contentWidth: number,
540
- contentHeight: number,
541
- ) => {
542
- switch (side) {
543
- case 'start':
544
- case 'end':
545
- case 'left':
546
- case 'right':
547
- return {
548
- top: -(contentHeight - triggerBoundingBox.height),
549
- left: 0,
550
- };
551
- case 'top':
552
- case 'bottom':
553
- default:
554
- return {
555
- top: 0,
556
- left: -(contentWidth - triggerBoundingBox.width),
557
- };
558
- }
559
- };
560
-
561
- /**
562
- * Calculate the center alignment for
563
- * the popover. If side is on the x-axis
564
- * then the align values refer to the top
565
- * and bottom margins of the content.
566
- * If side is on the y-axis then the
567
- * align values refer to the left and right
568
- * margins of the content.
569
- */
570
- const calculatePopoverCenterAlign = (
571
- side: PositionSide,
572
- triggerBoundingBox: ReferenceCoordinates,
573
- contentWidth: number,
574
- contentHeight: number,
575
- ) => {
576
- switch (side) {
577
- case 'start':
578
- case 'end':
579
- case 'left':
580
- case 'right':
581
- return {
582
- top: -(contentHeight / 2 - triggerBoundingBox.height / 2),
583
- left: 0,
584
- };
585
- case 'top':
586
- case 'bottom':
587
- default:
588
- return {
589
- top: 0,
590
- left: -(contentWidth / 2 - triggerBoundingBox.width / 2),
591
- };
592
- }
593
- };
594
-
595
- /**
596
- * Adjusts popover positioning coordinates
597
- * such that popover does not appear offscreen
598
- * or overlapping safe area bounds.
599
- */
600
- export const calculateWindowAdjustment = (
601
- side: PositionSide,
602
- coordTop: number,
603
- coordLeft: number,
604
- bodyPadding: number,
605
- bodyWidth: number,
606
- bodyHeight: number,
607
- contentWidth: number,
608
- contentHeight: number,
609
- safeAreaMargin: number,
610
- contentOriginX: string,
611
- contentOriginY: string,
612
- triggerCoordinates?: ReferenceCoordinates,
613
- eventElementRect?: DOMRect,
614
- isReplace: boolean = false,
615
- ): PopoverStyles => {
616
- const triggerTop = triggerCoordinates ? triggerCoordinates.top + triggerCoordinates.height : bodyHeight / 2 - contentHeight / 2;
617
- const triggerHeight = triggerCoordinates ? triggerCoordinates.height : 0;
618
- let left = coordLeft;
619
- let top = !isReplace ? coordTop + POPOVER_IOS_BODY_MARGIN : coordTop - triggerHeight;
620
- let bottom;
621
- let originX = contentOriginX;
622
- let originY = contentOriginY;
623
- let checkSafeAreaLeft = false;
624
- let checkSafeAreaRight = false;
625
- let addPopoverBottomClass = false;
626
-
627
- /**
628
- * Adjust popover so it does not
629
- * go off the left of the screen.
630
- */
631
- if (left < bodyPadding + safeAreaMargin) {
632
- left = !eventElementRect ? bodyPadding : eventElementRect.left;
633
- if (left === 0) {
634
- left = safeAreaMargin;
635
- }
636
- checkSafeAreaLeft = true;
637
- originX = 'left';
638
- /**
639
- * Adjust popover so it does not
640
- * go off the right of the screen.
641
- */
642
- } else if (contentWidth + bodyPadding + left + safeAreaMargin > bodyWidth) {
643
- checkSafeAreaRight = true;
644
- left = !eventElementRect ? bodyWidth - contentWidth - bodyPadding : eventElementRect.right - contentWidth;
645
- if (left + contentWidth === bodyWidth) {
646
- left = left - safeAreaMargin;
647
- }
648
- originX = 'right';
649
- }
650
-
651
- /**
652
- * Adjust popover so it does not
653
- * go off the top of the screen.
654
- * If popover is on the left or the right of
655
- * the trigger, then we should not adjust top
656
- * margins.
657
- */
658
- const compareTop = triggerCoordinates ? triggerCoordinates.top + triggerCoordinates.height / 2 : bodyHeight / 2 - contentHeight / 2;
659
- if (compareTop > bodyHeight / 2 && (side === 'top' || side === 'bottom')) {
660
- if (triggerTop - contentHeight > 0) {
661
- /**
662
- * While we strive to align the popover with the trigger
663
- * on smaller screens this is not always possible. As a result,
664
- * we adjust the popover up so that it does not hang
665
- * off the bottom of the screen. However, we do not want to move
666
- * the popover up so much that it goes off the top of the screen.
667
- *
668
- * We chose 12 here so that the popover position looks a bit nicer as
669
- * it is not right up against the edge of the screen.
670
- */
671
- if (!isReplace) {
672
- top = Math.max(12, triggerTop - contentHeight - triggerHeight) - POPOVER_IOS_BODY_MARGIN;
673
- } else {
674
- top = Math.max(12, triggerTop - contentHeight);
675
- }
676
- originY = 'bottom';
677
- addPopoverBottomClass = true;
678
-
679
- /**
680
- * If not enough room for popover to appear
681
- * above trigger, then cut it off.
682
- */
683
- } else {
684
- bottom = bodyPadding;
685
- }
686
- }
687
-
688
- return {
689
- top,
690
- left,
691
- bottom,
692
- originX,
693
- originY,
694
- checkSafeAreaLeft,
695
- checkSafeAreaRight,
696
- addPopoverBottomClass,
697
- };
698
- };
@@ -1,17 +0,0 @@
1
- export interface EffectScales {
2
- small: string;
3
- medium: string;
4
- large: string;
5
- xlarge: string;
6
- }
7
-
8
- export interface registeredEffect {
9
- destroy: () => void;
10
- }
11
-
12
- export interface AnimationPosition {
13
- minPositionX: number;
14
- maxPositionX: number;
15
- width: number;
16
- positionY: number;
17
- }
@@ -1 +0,0 @@
1
- @forward 'structured-list';