mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
fix(esm): reorganiza exports
This commit is contained in:
@ -1,52 +1,4 @@
|
|||||||
import { Mode } from '../interface';
|
import { IonicConfig } from '../interface';
|
||||||
|
|
||||||
export interface IonicConfig {
|
|
||||||
/**
|
|
||||||
* The mode determines which platform styles to use.
|
|
||||||
* Possible values are: `"ios"` or `"md"`.
|
|
||||||
*/
|
|
||||||
mode?: Mode;
|
|
||||||
persistConfig?: boolean;
|
|
||||||
|
|
||||||
inputShims?: boolean;
|
|
||||||
backButtonIcon?: string;
|
|
||||||
backButtonText?: string;
|
|
||||||
spinner?: string;
|
|
||||||
loadingSpinner?: string;
|
|
||||||
menuIcon?: string;
|
|
||||||
animated?: boolean;
|
|
||||||
pickerSpinner?: string;
|
|
||||||
refreshingIcon?: string;
|
|
||||||
refreshingSpinner?: string;
|
|
||||||
menuType?: string;
|
|
||||||
scrollPadding?: string;
|
|
||||||
inputBlurring?: string;
|
|
||||||
scrollAssist?: boolean;
|
|
||||||
hideCaretOnScroll?: string;
|
|
||||||
infiniteLoadingSpinner?: string;
|
|
||||||
keyboardHeight?: number;
|
|
||||||
swipeBackEnabled?: boolean;
|
|
||||||
|
|
||||||
tabbarPlacement?: string;
|
|
||||||
tabbarLayout?: string;
|
|
||||||
tabbarHighlight?: boolean;
|
|
||||||
|
|
||||||
actionSheetEnter?: string;
|
|
||||||
alertEnter?: string;
|
|
||||||
loadingEnter?: string;
|
|
||||||
modalEnter?: string;
|
|
||||||
popoverEnter?: string;
|
|
||||||
toastEnter?: string;
|
|
||||||
pickerEnter?: string;
|
|
||||||
|
|
||||||
actionSheetLeave?: string;
|
|
||||||
alertLeave?: string;
|
|
||||||
loadingLeave?: string;
|
|
||||||
modalLeave?: string;
|
|
||||||
popoverLeave?: string;
|
|
||||||
toastLeave?: string;
|
|
||||||
pickerLeave?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Config {
|
export class Config {
|
||||||
|
|
||||||
@ -81,3 +33,43 @@ export class Config {
|
|||||||
this.m.set(key, value);
|
this.m.set(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const IONIC_PREFIX = 'ionic:';
|
||||||
|
const IONIC_SESSION_KEY = 'ionic-persist-config';
|
||||||
|
|
||||||
|
export function configFromSession(): any {
|
||||||
|
try {
|
||||||
|
const configStr = window.sessionStorage.getItem(IONIC_SESSION_KEY);
|
||||||
|
return configStr !== null ? JSON.parse(configStr) : {};
|
||||||
|
} catch {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function saveConfig(config: any) {
|
||||||
|
try {
|
||||||
|
window.sessionStorage.setItem(IONIC_SESSION_KEY, JSON.stringify(config));
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function configFromURL() {
|
||||||
|
const config: any = {};
|
||||||
|
const win = window;
|
||||||
|
win.location.search.slice(1)
|
||||||
|
.split('&')
|
||||||
|
.map(entry => entry.split('='))
|
||||||
|
.map(([key, value]) => [decodeURIComponent(key), decodeURIComponent(value)])
|
||||||
|
.filter(([key]) => startsWith(key, IONIC_PREFIX))
|
||||||
|
.map(([key, value]) => [key.slice(IONIC_PREFIX.length), value])
|
||||||
|
.forEach(([key, value]) => {
|
||||||
|
config[key] = value;
|
||||||
|
});
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
function startsWith(input: string, search: string): boolean {
|
||||||
|
return input.substr(0, search.length) === search;
|
||||||
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import 'ionicons';
|
import 'ionicons';
|
||||||
|
|
||||||
import { configFromSession, configFromURL, saveConfig } from '../utils/config';
|
|
||||||
import { isPlatform, setupPlatforms } from '../utils/platform';
|
import { isPlatform, setupPlatforms } from '../utils/platform';
|
||||||
|
|
||||||
import { Config } from './config';
|
import { Config, configFromSession, configFromURL, saveConfig } from './config';
|
||||||
|
|
||||||
const win = window;
|
const win = window;
|
||||||
const Ionic = (win as any)['Ionic'] = (win as any)['Ionic'] || {};
|
const Ionic = (win as any)['Ionic'] = (win as any)['Ionic'] || {};
|
||||||
|
@ -9,8 +9,5 @@ export const enum ViewLifecycle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// util functions
|
// util functions
|
||||||
export * from './utils/helpers';
|
|
||||||
export * from './utils/haptic';
|
|
||||||
export * from './utils/framework-delegate';
|
|
||||||
export * from './utils/platform';
|
export * from './utils/platform';
|
||||||
export * from './utils/config';
|
export * from './utils/config';
|
||||||
|
5
core/src/interface.d.ts
vendored
5
core/src/interface.d.ts
vendored
@ -44,6 +44,11 @@ export type BackButtonEvent = CustomEvent<{
|
|||||||
register(priority: number, handler: () => Promise<any> | void): void;
|
register(priority: number, handler: () => Promise<any> | void): void;
|
||||||
}>
|
}>
|
||||||
|
|
||||||
|
export interface FrameworkDelegate {
|
||||||
|
attachViewToDom(container: any, component: any, propsOrDataObj?: any, cssClasses?: string[]): Promise<HTMLElement>;
|
||||||
|
removeViewFromDom(container: any, component: any): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface StencilGlobalHTMLAttributes {
|
interface StencilGlobalHTMLAttributes {
|
||||||
// for ion-menu and ion-split-pane
|
// for ion-menu and ion-split-pane
|
||||||
|
@ -1,4 +1,52 @@
|
|||||||
import { IonicConfig } from '../interface';
|
import { Mode } from '../interface';
|
||||||
|
|
||||||
|
export interface IonicConfig {
|
||||||
|
/**
|
||||||
|
* The mode determines which platform styles to use.
|
||||||
|
* Possible values are: `"ios"` or `"md"`.
|
||||||
|
*/
|
||||||
|
mode?: Mode;
|
||||||
|
persistConfig?: boolean;
|
||||||
|
|
||||||
|
inputShims?: boolean;
|
||||||
|
backButtonIcon?: string;
|
||||||
|
backButtonText?: string;
|
||||||
|
spinner?: string;
|
||||||
|
loadingSpinner?: string;
|
||||||
|
menuIcon?: string;
|
||||||
|
animated?: boolean;
|
||||||
|
pickerSpinner?: string;
|
||||||
|
refreshingIcon?: string;
|
||||||
|
refreshingSpinner?: string;
|
||||||
|
menuType?: string;
|
||||||
|
scrollPadding?: string;
|
||||||
|
inputBlurring?: string;
|
||||||
|
scrollAssist?: boolean;
|
||||||
|
hideCaretOnScroll?: string;
|
||||||
|
infiniteLoadingSpinner?: string;
|
||||||
|
keyboardHeight?: number;
|
||||||
|
swipeBackEnabled?: boolean;
|
||||||
|
|
||||||
|
tabbarPlacement?: string;
|
||||||
|
tabbarLayout?: string;
|
||||||
|
tabbarHighlight?: boolean;
|
||||||
|
|
||||||
|
actionSheetEnter?: string;
|
||||||
|
alertEnter?: string;
|
||||||
|
loadingEnter?: string;
|
||||||
|
modalEnter?: string;
|
||||||
|
popoverEnter?: string;
|
||||||
|
toastEnter?: string;
|
||||||
|
pickerEnter?: string;
|
||||||
|
|
||||||
|
actionSheetLeave?: string;
|
||||||
|
alertLeave?: string;
|
||||||
|
loadingLeave?: string;
|
||||||
|
modalLeave?: string;
|
||||||
|
popoverLeave?: string;
|
||||||
|
toastLeave?: string;
|
||||||
|
pickerLeave?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export function setupConfig(config: IonicConfig) {
|
export function setupConfig(config: IonicConfig) {
|
||||||
const win = window as any;
|
const win = window as any;
|
||||||
@ -14,43 +62,3 @@ export function setupConfig(config: IonicConfig) {
|
|||||||
};
|
};
|
||||||
return win.Ionic.config;
|
return win.Ionic.config;
|
||||||
}
|
}
|
||||||
|
|
||||||
const IONIC_PREFIX = 'ionic:';
|
|
||||||
const IONIC_SESSION_KEY = 'ionic-persist-config';
|
|
||||||
|
|
||||||
export function configFromSession(): any {
|
|
||||||
try {
|
|
||||||
const configStr = window.sessionStorage.getItem(IONIC_SESSION_KEY);
|
|
||||||
return configStr !== null ? JSON.parse(configStr) : {};
|
|
||||||
} catch {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function saveConfig(config: any) {
|
|
||||||
try {
|
|
||||||
window.sessionStorage.setItem(IONIC_SESSION_KEY, JSON.stringify(config));
|
|
||||||
} catch {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function configFromURL() {
|
|
||||||
const config: any = {};
|
|
||||||
const win = window;
|
|
||||||
win.location.search.slice(1)
|
|
||||||
.split('&')
|
|
||||||
.map(entry => entry.split('='))
|
|
||||||
.map(([key, value]) => [decodeURIComponent(key), decodeURIComponent(value)])
|
|
||||||
.filter(([key]) => startsWith(key, IONIC_PREFIX))
|
|
||||||
.map(([key, value]) => [key.slice(IONIC_PREFIX.length), value])
|
|
||||||
.forEach(([key, value]) => {
|
|
||||||
config[key] = value;
|
|
||||||
});
|
|
||||||
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
function startsWith(input: string, search: string): boolean {
|
|
||||||
return input.substr(0, search.length) === search;
|
|
||||||
}
|
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
import { ComponentRef } from '../interface';
|
import { ComponentRef, FrameworkDelegate } from '../interface';
|
||||||
|
|
||||||
export interface FrameworkDelegate {
|
|
||||||
attachViewToDom(container: any, component: any, propsOrDataObj?: any, cssClasses?: string[]): Promise<HTMLElement>;
|
|
||||||
removeViewFromDom(container: any, component: any): Promise<void>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function attachComponent(
|
export async function attachComponent(
|
||||||
delegate: FrameworkDelegate | undefined,
|
delegate: FrameworkDelegate | undefined,
|
||||||
|
Reference in New Issue
Block a user