@rdlabo/ionic-theme-ios26 1.3.3 → 2.0.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 (42) hide show
  1. package/README.md +35 -55
  2. package/dist/css/components/ion-button.css +1 -1
  3. package/dist/css/components/ion-toolbar.css +1 -1
  4. package/dist/css/ionic-theme-ios26.css +1 -1
  5. package/dist/focus-controller /index.d.ts +6 -0
  6. package/dist/focus-controller /index.d.ts.map +1 -0
  7. package/dist/focus-controller /index.js +62 -0
  8. package/dist/popover/animations/ios.enter.js +1 -1
  9. package/dist/popover/utils.d.ts.map +1 -1
  10. package/dist/popover/utils.js +6 -0
  11. package/dist/transition/index.d.ts +19 -0
  12. package/dist/transition/index.d.ts.map +1 -0
  13. package/dist/transition/index.js +219 -0
  14. package/dist/transition/ios.transition.d.ts +5 -0
  15. package/dist/transition/ios.transition.d.ts.map +1 -0
  16. package/dist/transition/ios.transition.js +496 -0
  17. package/dist/utils.d.ts +10 -0
  18. package/dist/utils.d.ts.map +1 -1
  19. package/dist/utils.js +30 -0
  20. package/package.json +1 -1
  21. package/src/focus-controller /index.ts +123 -0
  22. package/src/popover/animations/ios.enter.ts +1 -1
  23. package/src/popover/utils.ts +6 -0
  24. package/src/styles/components/ion-button.scss +0 -4
  25. package/src/transition/index.ts +369 -0
  26. package/src/transition/ios.transition.ts +834 -0
  27. package/src/utils.ts +36 -0
  28. package/dist/gestures/animations.d.ts +0 -8
  29. package/dist/gestures/animations.d.ts.map +0 -1
  30. package/dist/gestures/animations.js +0 -97
  31. package/dist/gestures/gestures.d.ts +0 -3
  32. package/dist/gestures/gestures.d.ts.map +0 -1
  33. package/dist/gestures/gestures.js +0 -240
  34. package/dist/gestures/index.d.ts +0 -3
  35. package/dist/gestures/index.d.ts.map +0 -1
  36. package/dist/gestures/index.js +0 -160
  37. package/dist/gestures/interfaces.d.ts +0 -16
  38. package/dist/gestures/interfaces.d.ts.map +0 -1
  39. package/dist/gestures/interfaces.js +0 -1
  40. package/dist/gestures/utils.d.ts +0 -5
  41. package/dist/gestures/utils.d.ts.map +0 -1
  42. package/dist/gestures/utils.js +0 -27
@@ -0,0 +1,219 @@
1
+ import { config } from '../utils';
2
+ import { Build, writeTask } from '@stencil/core';
3
+ import { LIFECYCLE_DID_ENTER, LIFECYCLE_DID_LEAVE, LIFECYCLE_WILL_ENTER, LIFECYCLE_WILL_LEAVE } from '@ionic/core';
4
+ import { createFocusController } from '../focus-controller ';
5
+ import { raf } from '../utils';
6
+ const iosTransitionAnimation = () => import('./ios.transition');
7
+ const focusController = createFocusController();
8
+ export const transition = (opts) => {
9
+ return new Promise((resolve, reject) => {
10
+ writeTask(() => {
11
+ const transitioningInactiveHeader = getIosIonHeader(opts);
12
+ beforeTransition(opts, transitioningInactiveHeader);
13
+ runTransition(opts)
14
+ .then((result) => {
15
+ if (result.animation) {
16
+ result.animation.destroy();
17
+ }
18
+ afterTransition(opts);
19
+ resolve(result);
20
+ }, (error) => {
21
+ afterTransition(opts);
22
+ reject(error);
23
+ })
24
+ .finally(() => {
25
+ setHeaderTransitionClass(transitioningInactiveHeader, false);
26
+ });
27
+ });
28
+ });
29
+ };
30
+ const beforeTransition = (opts, transitioningInactiveHeader) => {
31
+ const enteringEl = opts.enteringEl;
32
+ const leavingEl = opts.leavingEl;
33
+ focusController.saveViewFocus(leavingEl);
34
+ setZIndex(enteringEl, leavingEl, opts.direction);
35
+ setHeaderTransitionClass(transitioningInactiveHeader, true);
36
+ if (opts.showGoBack) {
37
+ enteringEl.classList.add('can-go-back');
38
+ }
39
+ else {
40
+ enteringEl.classList.remove('can-go-back');
41
+ }
42
+ setPageHidden(enteringEl, false);
43
+ enteringEl.style.setProperty('pointer-events', 'none');
44
+ if (leavingEl) {
45
+ setPageHidden(leavingEl, false);
46
+ leavingEl.style.setProperty('pointer-events', 'none');
47
+ }
48
+ };
49
+ const runTransition = async (opts) => {
50
+ const animationBuilder = await getAnimationBuilder(opts);
51
+ const ani = animationBuilder && Build.isBrowser ? animation(animationBuilder, opts) : noAnimation(opts);
52
+ return ani;
53
+ };
54
+ const afterTransition = (opts) => {
55
+ const enteringEl = opts.enteringEl;
56
+ const leavingEl = opts.leavingEl;
57
+ enteringEl.classList.remove('ion-page-invisible');
58
+ enteringEl.style.removeProperty('pointer-events');
59
+ if (leavingEl !== undefined) {
60
+ leavingEl.classList.remove('ion-page-invisible');
61
+ leavingEl.style.removeProperty('pointer-events');
62
+ }
63
+ focusController.setViewFocus(enteringEl);
64
+ };
65
+ const getAnimationBuilder = async (opts) => {
66
+ if (!opts.leavingEl || !opts.animated || opts.duration === 0) {
67
+ return undefined;
68
+ }
69
+ if (opts.animationBuilder) {
70
+ return opts.animationBuilder;
71
+ }
72
+ const getAnimation = (await iosTransitionAnimation()).iosTransitionAnimation;
73
+ return getAnimation;
74
+ };
75
+ const animation = async (animationBuilder, opts) => {
76
+ await waitForReady(opts, true);
77
+ const trans = animationBuilder(opts.baseEl, opts);
78
+ fireWillEvents(opts.enteringEl, opts.leavingEl);
79
+ const didComplete = await playTransition(trans, opts);
80
+ if (opts.progressCallback) {
81
+ opts.progressCallback(undefined);
82
+ }
83
+ if (didComplete) {
84
+ fireDidEvents(opts.enteringEl, opts.leavingEl);
85
+ }
86
+ return {
87
+ hasCompleted: didComplete,
88
+ animation: trans,
89
+ };
90
+ };
91
+ const noAnimation = async (opts) => {
92
+ const enteringEl = opts.enteringEl;
93
+ const leavingEl = opts.leavingEl;
94
+ const focusManagerEnabled = config.get('focusManagerPriority', false);
95
+ await waitForReady(opts, focusManagerEnabled);
96
+ fireWillEvents(enteringEl, leavingEl);
97
+ fireDidEvents(enteringEl, leavingEl);
98
+ return {
99
+ hasCompleted: true,
100
+ };
101
+ };
102
+ const waitForReady = async (opts, defaultDeep) => {
103
+ const deep = opts.deepWait !== undefined ? opts.deepWait : defaultDeep;
104
+ if (deep) {
105
+ await Promise.all([deepReady(opts.enteringEl), deepReady(opts.leavingEl)]);
106
+ }
107
+ await notifyViewReady(opts.viewIsReady, opts.enteringEl);
108
+ };
109
+ const notifyViewReady = async (viewIsReady, enteringEl) => {
110
+ if (viewIsReady) {
111
+ await viewIsReady(enteringEl);
112
+ }
113
+ };
114
+ const playTransition = (trans, opts) => {
115
+ const progressCallback = opts.progressCallback;
116
+ const promise = new Promise((resolve) => {
117
+ trans.onFinish((currentStep) => resolve(currentStep === 1));
118
+ });
119
+ if (progressCallback) {
120
+ trans.progressStart(true);
121
+ progressCallback(trans);
122
+ }
123
+ else {
124
+ trans.play();
125
+ }
126
+ return promise;
127
+ };
128
+ const fireWillEvents = (enteringEl, leavingEl) => {
129
+ lifecycle(leavingEl, LIFECYCLE_WILL_LEAVE);
130
+ lifecycle(enteringEl, LIFECYCLE_WILL_ENTER);
131
+ };
132
+ const fireDidEvents = (enteringEl, leavingEl) => {
133
+ lifecycle(enteringEl, LIFECYCLE_DID_ENTER);
134
+ lifecycle(leavingEl, LIFECYCLE_DID_LEAVE);
135
+ };
136
+ export const lifecycle = (el, eventName) => {
137
+ if (el) {
138
+ const ev = new CustomEvent(eventName, {
139
+ bubbles: false,
140
+ cancelable: false,
141
+ });
142
+ el.dispatchEvent(ev);
143
+ }
144
+ };
145
+ export const waitForMount = () => {
146
+ return new Promise((resolve) => raf(() => raf(() => resolve())));
147
+ };
148
+ export const deepReady = async (el) => {
149
+ const element = el;
150
+ if (element) {
151
+ if (element.componentOnReady != null) {
152
+ const stencilEl = await element.componentOnReady();
153
+ if (stencilEl != null) {
154
+ return;
155
+ }
156
+ }
157
+ else if (element.__registerHost != null) {
158
+ const waitForCustomElement = new Promise((resolve) => raf(resolve));
159
+ await waitForCustomElement;
160
+ return;
161
+ }
162
+ await Promise.all(Array.from(element.children).map(deepReady));
163
+ }
164
+ };
165
+ export const setPageHidden = (el, hidden) => {
166
+ if (hidden) {
167
+ el.setAttribute('aria-hidden', 'true');
168
+ el.classList.add('ion-page-hidden');
169
+ }
170
+ else {
171
+ el.hidden = false;
172
+ el.removeAttribute('aria-hidden');
173
+ el.classList.remove('ion-page-hidden');
174
+ }
175
+ };
176
+ const setZIndex = (enteringEl, leavingEl, direction) => {
177
+ if (enteringEl !== undefined) {
178
+ enteringEl.style.zIndex = direction === 'back' ? '99' : '101';
179
+ }
180
+ if (leavingEl !== undefined) {
181
+ leavingEl.style.zIndex = '100';
182
+ }
183
+ };
184
+ const setHeaderTransitionClass = (header, isTransitioning) => {
185
+ if (!header) {
186
+ return;
187
+ }
188
+ const transitionClass = 'header-transitioning';
189
+ if (isTransitioning) {
190
+ header.classList.add(transitionClass);
191
+ }
192
+ else {
193
+ header.classList.remove(transitionClass);
194
+ }
195
+ };
196
+ export const getIonPageElement = (element) => {
197
+ if (element.classList.contains('ion-page')) {
198
+ return element;
199
+ }
200
+ const ionPage = element.querySelector(':scope > .ion-page, :scope > ion-nav, :scope > ion-tabs');
201
+ if (ionPage) {
202
+ return ionPage;
203
+ }
204
+ return element;
205
+ };
206
+ const getIosIonHeader = (opts) => {
207
+ const enteringEl = opts.enteringEl;
208
+ const leavingEl = opts.leavingEl;
209
+ const direction = opts.direction;
210
+ const mode = opts.mode;
211
+ if (mode !== 'ios') {
212
+ return null;
213
+ }
214
+ const element = direction === 'back' ? leavingEl : enteringEl;
215
+ if (!element) {
216
+ return null;
217
+ }
218
+ return element.querySelector('ion-header');
219
+ };
@@ -0,0 +1,5 @@
1
+ import type { Animation } from '@ionic/core/dist/types/utils/animation/animation-interface';
2
+ import type { TransitionOptions } from './index';
3
+ export declare const shadow: <T extends Element>(el: T) => ShadowRoot | T;
4
+ export declare const iosTransitionAnimation: (navEl: HTMLElement, opts: TransitionOptions) => Animation;
5
+ //# sourceMappingURL=ios.transition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ios.transition.d.ts","sourceRoot":"","sources":["../../src/transition/ios.transition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4DAA4D,CAAC;AAE5F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAWjD,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,OAAO,EAAE,IAAI,CAAC,KAAG,UAAU,GAAG,CAE9D,CAAC;AA4dF,eAAO,MAAM,sBAAsB,GAAI,OAAO,WAAW,EAAE,MAAM,iBAAiB,KAAG,SA2UpF,CAAC"}