cosmic-components
Advanced tools
Comparing version 0.0.1-alpha.10 to 0.0.1-alpha.11
@@ -20,13 +20,2 @@ /** | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
(function (factory) { | ||
@@ -54,3 +43,4 @@ if (typeof module === "object" && typeof module.exports === "object") { | ||
styles: {}, | ||
defaultStyles: {} | ||
defaultStyles: {}, | ||
styleMode: Base.styleMode | ||
}; | ||
@@ -95,7 +85,19 @@ }; | ||
Base.dispatchMode = 'message'; | ||
// 外观定制模式 | ||
Base.styleMode = 'merge'; | ||
Base.computed = { | ||
newStyles: function () { | ||
var styleMode = this.data.get('styleMode'); | ||
if (styleMode === 'overwrite') { | ||
return this.data.get('styles'); | ||
} | ||
var defaultStyles = this.data.get('defaultStyles'); | ||
var styles = this.data.get('styles'); | ||
return __assign(__assign({}, defaultStyles), styles); | ||
return Object.keys(defaultStyles).reduce(function (acc, cur) { | ||
acc[cur] = defaultStyles[cur]; | ||
if (styles[cur]) { | ||
acc[cur] += ' ' + styles[cur]; | ||
} | ||
return acc; | ||
}, {}); | ||
} | ||
@@ -102,0 +104,0 @@ }; |
{ | ||
"name": "cosmic-components", | ||
"version": "0.0.1-alpha.10", | ||
"version": "0.0.1-alpha.11", | ||
"main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "./src/index.ts", |
@@ -7,12 +7,10 @@ /** | ||
import {Component} from 'san'; | ||
import {Styles, BaseData} from './interface'; | ||
import { | ||
Styles, | ||
BaseData, | ||
DispatchMode, | ||
StyleMode, | ||
Store | ||
} from './interface'; | ||
// 定义事件派发的模式,默认 message | ||
type DispatchMode = 'message' | 'store'; | ||
// store 需要实现 dispatch 接口 | ||
interface Store { | ||
dispatch: (action: string, payload?: unknown) => void; | ||
} | ||
export default class Base extends Component { | ||
@@ -25,10 +23,20 @@ | ||
// 外观定制模式 | ||
static styleMode: StyleMode = 'merge'; | ||
static computed = { | ||
newStyles(this: Base): Styles { | ||
newStyles(this: Base) { | ||
const styleMode = this.data.get('styleMode'); | ||
if (styleMode === 'overwrite') { | ||
return this.data.get('styles'); | ||
} | ||
const defaultStyles = this.data.get('defaultStyles'); | ||
const styles = this.data.get('styles'); | ||
return { | ||
...defaultStyles, | ||
...styles | ||
}; | ||
return Object.keys(defaultStyles).reduce((acc, cur) => { | ||
acc[cur] = defaultStyles[cur]; | ||
if (styles[cur]) { | ||
acc[cur] += ' ' + styles[cur]; | ||
} | ||
return acc; | ||
}, {} as Styles); | ||
} | ||
@@ -45,3 +53,4 @@ }; | ||
styles: {}, | ||
defaultStyles: {} | ||
defaultStyles: {}, | ||
styleMode: Base.styleMode | ||
}; | ||
@@ -48,0 +57,0 @@ } |
export type Styles = Record<string, string>; | ||
// 定义事件派发的模式,默认 message | ||
export type DispatchMode = 'message' | 'store'; | ||
// 外观定制模式 | ||
export type StyleMode = 'merge' | 'overwrite'; | ||
// store 需要实现 dispatch 接口 | ||
export interface Store { | ||
dispatch: (action: string, payload?: unknown) => void; | ||
} | ||
export interface BaseProps { | ||
@@ -19,2 +30,7 @@ | ||
defaultStyles?: Styles; | ||
/** | ||
* 外观定制模式 | ||
*/ | ||
styleMode?: StyleMode; | ||
} | ||
@@ -21,0 +37,0 @@ |
@@ -10,3 +10,3 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -13,0 +13,0 @@ initData(): AvatarData; |
@@ -6,12 +6,9 @@ /** | ||
import { Component } from 'san'; | ||
import { Styles, BaseData } from './interface'; | ||
declare type DispatchMode = 'message' | 'store'; | ||
interface Store { | ||
dispatch: (action: string, payload?: unknown) => void; | ||
} | ||
import { BaseData, DispatchMode, StyleMode, Store } from './interface'; | ||
export default class Base extends Component { | ||
static trimWhitespace: string; | ||
static dispatchMode: DispatchMode; | ||
static styleMode: StyleMode; | ||
static computed: { | ||
newStyles(this: Base): Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -47,2 +44,1 @@ store?: Store; | ||
export declare const setupStore: (store: Store) => void; | ||
export {}; |
export declare type Styles = Record<string, string>; | ||
export declare type DispatchMode = 'message' | 'store'; | ||
export declare type StyleMode = 'merge' | 'overwrite'; | ||
export interface Store { | ||
dispatch: (action: string, payload?: unknown) => void; | ||
} | ||
export interface BaseProps { | ||
@@ -15,2 +20,6 @@ /** | ||
defaultStyles?: Styles; | ||
/** | ||
* 外观定制模式 | ||
*/ | ||
styleMode?: StyleMode; | ||
} | ||
@@ -17,0 +26,0 @@ export interface BaseState { |
@@ -11,3 +11,3 @@ /** | ||
type(this: Button): string; | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -27,4 +27,5 @@ initData(): { | ||
styles?: import("../Base/interface").Styles | undefined; | ||
styleMode?: import("../Base/interface").StyleMode | undefined; | ||
}; | ||
click(event: Event): void; | ||
} |
@@ -33,3 +33,3 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -36,0 +36,0 @@ static messages: { |
@@ -21,3 +21,3 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -24,0 +24,0 @@ initData(): Data; |
@@ -12,5 +12,5 @@ /** | ||
colStyle(this: Col): {}; | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
initData(): ColData; | ||
} |
@@ -13,5 +13,5 @@ /** | ||
rowStyle(this: Row): {}; | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
initData(): RowData; | ||
} |
@@ -13,3 +13,3 @@ /** | ||
objectFitValue(this: Image): string; | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -16,0 +16,0 @@ initData(): Data; |
@@ -12,3 +12,3 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -15,0 +15,0 @@ initData(): Data; |
@@ -5,3 +5,3 @@ import Base from '../Base'; | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -8,0 +8,0 @@ initData(): Data; |
@@ -5,5 +5,5 @@ import Base from '../base'; | ||
static computed: { | ||
newStyles(this: import("../..").Base): import("../../Base/interface").Styles; | ||
newStyles(this: import("../..").Base): any; | ||
}; | ||
click(e: Event): void; | ||
} |
@@ -5,5 +5,5 @@ import Base from '../base'; | ||
static computed: { | ||
newStyles(this: import("../..").Base): import("../../Base/interface").Styles; | ||
newStyles(this: import("../..").Base): any; | ||
}; | ||
click(e: Event): void; | ||
} |
@@ -5,5 +5,5 @@ import Base from '../base'; | ||
static computed: { | ||
newStyles(this: import("../..").Base): import("../../Base/interface").Styles; | ||
newStyles(this: import("../..").Base): any; | ||
}; | ||
click(e: Event): void; | ||
} |
@@ -19,3 +19,3 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -22,0 +22,0 @@ initData(): Data; |
@@ -14,5 +14,5 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
initData(): LoadingData; | ||
} |
@@ -21,3 +21,3 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -24,0 +24,0 @@ initData(): Data; |
@@ -16,3 +16,3 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -19,0 +19,0 @@ initData(): Data; |
@@ -9,5 +9,5 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
initData(): ResultData; | ||
} |
@@ -22,3 +22,3 @@ import Base from '../Base'; | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -25,0 +25,0 @@ initData(): import("../Base/interface").BaseData & { |
@@ -18,3 +18,3 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -21,0 +21,0 @@ static messages: { |
@@ -15,3 +15,3 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -18,0 +18,0 @@ static messages: { |
@@ -15,3 +15,3 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -18,0 +18,0 @@ initData(): Data; |
@@ -15,3 +15,3 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -18,0 +18,0 @@ initData(): Data; |
@@ -16,3 +16,3 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -19,0 +19,0 @@ static messages: { |
@@ -19,3 +19,3 @@ import Base from '../Base'; | ||
checked(this: TR): string[] | "" | "ON" | undefined; | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -22,0 +22,0 @@ static dataTypes: { |
@@ -13,3 +13,3 @@ /** | ||
cursorStyle(this: Tabs): string; | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -28,3 +28,3 @@ sourceSlots?: SourceSlot; | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -31,0 +31,0 @@ initData(): PaneData; |
@@ -16,3 +16,3 @@ /** | ||
static computed: { | ||
newStyles(this: Base): import("../Base/interface").Styles; | ||
newStyles(this: Base): any; | ||
}; | ||
@@ -19,0 +19,0 @@ initData(): Data; |
Sorry, the diff of this file is not supported yet
434395
7693