本文整理匯總了TypeScript中@dojo/widget-core/mixins/Themed.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: ThemedMixin
import WidgetBase from '@dojo/widget-core/WidgetBase';
import ThemedMixin, { theme } from '@dojo/widget-core/mixins/Themed';
import { v } from '@dojo/widget-core/d';
import { Todo } from './../todoProcesses';
import * as css from './styles/todoItem.m.css';
export interface TodoItemProperties {
todo: Todo;
toggleTodo: (payload: { id: string }) => void;
removeTodo: (payload: { id: string }) => void;
editTodo: (payload: { id: string }) => void;
}
export const TodoItemBase = ThemedMixin(WidgetBase);
@theme(css)
export default class TodoItem extends TodoItemBase<TodoItemProperties> {
private toggleTodo() {
this.properties.toggleTodo({ id: this.properties.todo.id });
}
private editTodo() {
this.properties.editTodo({ id: this.properties.todo.id });
}
private removeTodo() {
this.properties.removeTodo({ id: this.properties.todo.id });
}
示例2: ThemedMixin
import TodoCard from './TodoCard';
import TodoDetailsOutlet from './../outlets/TodoDetailsOutlet';
import * as css from './styles/todoList.m.css';
export interface TodoListProperties {
view: string;
filter: string;
todos: Todo[];
searchValue: string;
toggleTodo: (payload: { id: string }) => void;
removeTodo: (payload: { id: string }) => void;
editTodo: (payload: { id: string }) => void;
}
export const TodoListBase = ThemedMixin(WidgetBase);
function filterTodos(todos: Todo[], quickFilter: string, filter: string): Todo[] {
return todos.filter((todo) => {
return (quickFilter === '' || todo.label.toLowerCase().indexOf(quickFilter.toLowerCase()) >= 0) &&
(filter === 'completed' && todo.completed || filter === 'active' && !todo.completed || filter === 'all');
});
}
@theme(css)
export default class TodoList extends TodoListBase<TodoListProperties> {
protected render() {
const { todos, searchValue, view, filter, toggleTodo, removeTodo, editTodo } = this.properties;
return [
v('ul', { classes: this.theme([ css.todoList, view === 'card' && todos.length > 0 ? css.cardList : null ]) }, filterTodos(todos, searchValue, filter).map((todo) => {
示例3: parseUnits
* @return An object containing `hour`, `second`, and `number` properties.
*/
export function parseUnits (value: string | TimeUnits): TimeUnits {
if (typeof value === 'string') {
if (!TIME_PATTERN.test(value)) {
throw new Error('Time strings must be in the format HH:mm or HH:mm:ss');
}
const [ hour, minute, second = 0 ] = value.split(':').map(unit => parseInt(unit, 10));
return { hour, minute, second } as TimeUnits;
}
return value;
}
export const TimePickerBase = ThemedMixin(WidgetBase);
@theme(css)
export class TimePicker extends TimePickerBase<TimePickerProperties> {
protected options: TimeUnits[] | null;
private _formatUnits(units: TimeUnits): string {
const { step = 60 } = this.properties;
const { hour, minute, second } = units;
return (step >= 60 ? [ hour, minute ] : [ hour, minute, second ])
.map(unit => padStart(String(unit), 2, '0'))
.join(':');
}
private _getOptionLabel(value: TimeUnits) {
示例4: parseUnits
* @return An object containing `hour`, `second`, and `number` properties.
*/
export function parseUnits (value: string | TimeUnits): TimeUnits {
if (typeof value === 'string') {
if (!TIME_PATTERN.test(value)) {
throw new Error('Time strings must be in the format HH:mm or HH:mm:ss');
}
const [ hour, minute, second = 0 ] = value.split(':').map(unit => parseInt(unit, 10));
return { hour, minute, second } as TimeUnits;
}
return value;
}
export const ThemedBase = ThemedMixin(WidgetBase);
@theme(css)
export class TimePickerBase<P extends TimePickerProperties = TimePickerProperties> extends ThemedBase<P, null> {
protected options: TimeUnits[] | null;
private _uuid: string;
constructor() {
super();
this._uuid = uuid();
}
private _formatUnits(units: TimeUnits): string {
const { step = 60 } = this.properties;
const { hour, minute, second } = units;