@globalbrain/sefirot
Advanced tools
Comparing version 0.49.0 to 0.50.0
@@ -0,1 +1,7 @@ | ||
# [0.50.0](https://github.com/globalbrain/sefirot/compare/v0.49.0...v0.50.0) (2021-04-15) | ||
### Features | ||
* refactor bunch of stuff ([#58](https://github.com/globalbrain/sefirot/issues/58)) ([fc86f9a](https://github.com/globalbrain/sefirot/commit/fc86f9ab6a8c6d2e8a5c997aeaab3bb6000eea9f)) | ||
# [0.49.0](https://github.com/globalbrain/sefirot/compare/v0.48.0...v0.49.0) (2021-04-12) | ||
@@ -2,0 +8,0 @@ |
import { Values } from '../types/Utils' | ||
import { useStore } from './Store' | ||
import { ButtonAction } from './Action' | ||
@@ -9,3 +8,3 @@ export interface Alert { | ||
text: string | ||
actions: ButtonAction[] | ||
actions: Action[] | ||
} | ||
@@ -22,2 +21,10 @@ | ||
export interface Action { | ||
type: 'primary' | 'secondary' | 'tertiary' | 'text' | 'mute' | ||
mode: 'neutral' | 'info' | 'success' | 'warning' | 'danger' | ||
icon?: any | ||
label: string | ||
callback(): void | ||
} | ||
export function useAlert(alert: Alert) { | ||
@@ -24,0 +31,0 @@ const store = useStore() |
import { Values } from '../types/Utils' | ||
import { Refish } from './Utils' | ||
import { Header } from './Header' | ||
import { Action } from './Action' | ||
export * from './Header' | ||
export * from './Action' | ||
export interface Card { | ||
size?: Size | ||
border?: Mode | ||
header?: Header | ||
footer?: Footer | ||
mode?: Mode | ||
round?: number | ||
depth?: number | ||
collapsable?: boolean | ||
loading?: Refish<boolean> | ||
} | ||
export type Size = Values<typeof Sizes> | ||
export interface Header { | ||
title?: string | ||
actions?: Refish<Action[]> | ||
} | ||
export const Sizes = { | ||
Compact: 'compact', | ||
Wide: 'wide' | ||
} as const | ||
export interface Footer { | ||
actions: Action[] | ||
} | ||
export interface Action { | ||
type: 'primary' | 'secondary' | 'tertiary' | 'text' | 'mute' | ||
mode?: Mode | ||
icon?: any | ||
label?: string | ||
link?: string | ||
callback?(): void | ||
} | ||
export type Mode = Values<typeof Modes> | ||
export const Modes = { | ||
Neutral: 'neutral', | ||
Info: 'info', | ||
@@ -36,12 +41,4 @@ Success: 'success', | ||
export interface Footer { | ||
actions: Action[] | ||
} | ||
export function useCard(card: Card): Card { | ||
return card | ||
} | ||
export function useFooter(footer: Footer): Footer { | ||
return footer | ||
} |
@@ -5,2 +5,4 @@ import { Ref, ComputedRef, UnwrapRef, ref, computed, watch, isRef } from '@vue/composition-api' | ||
export type Source<S> = Ref<S> | ComputedRef<S> | ||
export function get<T>(refish: Refish<T> | (() => T)): T { | ||
@@ -18,2 +20,15 @@ if (isRef(refish)) { | ||
export function computedOnly<T, S>( | ||
source: Source<S>, | ||
callback: () => T | ||
): Ref<T> { | ||
const value = ref() as Ref<T> | ||
watch(source, () => { | ||
value.value = callback() | ||
}, { immediate: true }) | ||
return value | ||
} | ||
export function computedIf<T, R, E>( | ||
@@ -63,2 +78,15 @@ refish: Refish<T | null>, | ||
export function computedArrayOnly<T extends any[], S>( | ||
source: Source<S>, | ||
callback: (carry: T) => void | ||
): Ref<T> { | ||
return computedOnly(source, () => { | ||
const carry = [] as any | ||
callback(carry) | ||
return carry | ||
}) | ||
} | ||
export function computedArrayIf<T, D extends any[]>( | ||
@@ -65,0 +93,0 @@ refish: Refish<T | null>, |
{ | ||
"name": "@globalbrain/sefirot", | ||
"version": "0.49.0", | ||
"version": "0.50.0", | ||
"description": "Vue Components for Global Brain Design System.", | ||
@@ -5,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
290571
1963