init component
This commit is contained in:
1
node_modules/buetify/lib/composables/snackbar/index.d.ts
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/snackbar/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
export * from './useSnackbar';
|
||||
2
node_modules/buetify/lib/composables/snackbar/index.js
generated
vendored
Executable file
2
node_modules/buetify/lib/composables/snackbar/index.js
generated
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
export * from './useSnackbar';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/buetify/lib/composables/snackbar/index.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/snackbar/index.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/composables/snackbar/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAd","sourcesContent":["export * from './useSnackbar';\n"],"sourceRoot":"","file":"index.js"}
|
||||
54
node_modules/buetify/lib/composables/snackbar/useSnackbar.d.ts
generated
vendored
Executable file
54
node_modules/buetify/lib/composables/snackbar/useSnackbar.d.ts
generated
vendored
Executable file
@@ -0,0 +1,54 @@
|
||||
import { FunctionN } from 'fp-ts/lib/function';
|
||||
import { IO } from 'fp-ts/lib/IO';
|
||||
import { ExtractPropTypes, PropType, Slots } from 'vue';
|
||||
import { ColorVariant, PositionVariant } from '../../types';
|
||||
import { NoticeController, OpenNoticeOptions, RenderNoticeOptions } from '../noticeController';
|
||||
export declare const SnackbarPropsDefinition: {
|
||||
position: {
|
||||
type: PropType<PositionVariant>;
|
||||
default: "is-bottom-right";
|
||||
};
|
||||
actionText: {
|
||||
type: PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
onAction: {
|
||||
type: PropType<IO<void>>;
|
||||
default: import("fp-ts/lib/function").Lazy<() => void>;
|
||||
};
|
||||
variant: {
|
||||
type: PropType<ColorVariant>;
|
||||
default: "is-success";
|
||||
};
|
||||
transition: {
|
||||
type: PropType<import("../../types").Transition>;
|
||||
required: boolean;
|
||||
};
|
||||
duration: {
|
||||
type: PropType<number>;
|
||||
default: number;
|
||||
};
|
||||
message: {
|
||||
type: PropType<string>;
|
||||
};
|
||||
shouldQueue: {
|
||||
type: PropType<boolean>;
|
||||
default: boolean;
|
||||
};
|
||||
isIndefinite: {
|
||||
type: PropType<boolean>;
|
||||
default: boolean;
|
||||
};
|
||||
};
|
||||
export interface SnackbarProps extends ExtractPropTypes<typeof SnackbarPropsDefinition> {
|
||||
}
|
||||
export interface RenderSnackbarOptions extends RenderNoticeOptions, OpenNoticeOptions {
|
||||
onAction?: IO<void>;
|
||||
actionText?: string;
|
||||
}
|
||||
export interface OpenSnackbarOptions extends RenderSnackbarOptions {
|
||||
}
|
||||
export interface SnackbarController extends NoticeController {
|
||||
open: FunctionN<[OpenSnackbarOptions], void>;
|
||||
}
|
||||
export declare function useSnackbar(props?: SnackbarProps, slots?: Slots): SnackbarController;
|
||||
71
node_modules/buetify/lib/composables/snackbar/useSnackbar.js
generated
vendored
Executable file
71
node_modules/buetify/lib/composables/snackbar/useSnackbar.js
generated
vendored
Executable file
@@ -0,0 +1,71 @@
|
||||
import { constant, constVoid } from 'fp-ts/lib/function';
|
||||
import { h, shallowRef } from 'vue';
|
||||
import { constEmptyArray } from '../../utils/helpers';
|
||||
import { DEFAULT_USE_NOTICE_PROPS, useNoticeController, UseNoticePropsDefinition } from '../noticeController';
|
||||
export const SnackbarPropsDefinition = { ...UseNoticePropsDefinition,
|
||||
position: {
|
||||
type: String,
|
||||
default: 'is-bottom-right'
|
||||
},
|
||||
actionText: {
|
||||
type: String,
|
||||
default: 'OK'
|
||||
},
|
||||
onAction: {
|
||||
type: Function,
|
||||
default: constant(constVoid)
|
||||
},
|
||||
variant: {
|
||||
type: String,
|
||||
default: 'is-success'
|
||||
}
|
||||
};
|
||||
const DEFAULT_SNACKBAR_PROPS = { ...DEFAULT_USE_NOTICE_PROPS,
|
||||
variant: SnackbarPropsDefinition.variant.default,
|
||||
position: SnackbarPropsDefinition.position.default,
|
||||
actionText: SnackbarPropsDefinition.actionText.default,
|
||||
onAction: SnackbarPropsDefinition.onAction.default()
|
||||
};
|
||||
|
||||
function generateMessage(slots, message) {
|
||||
return message ? h('p', {
|
||||
class: 'text',
|
||||
innerHTML: message
|
||||
}) : h('p', {
|
||||
class: 'text'
|
||||
}, slots.message && slots.message());
|
||||
}
|
||||
|
||||
function generateAction(props, slots, noticeController, options) {
|
||||
return h('div', {
|
||||
class: ['action', options.variant ?? props.variant, options.position ?? props.position]
|
||||
}, [h('button', {
|
||||
class: 'button',
|
||||
onClick: () => {
|
||||
if (options.onAction) {
|
||||
options.onAction();
|
||||
} else {
|
||||
props.onAction();
|
||||
}
|
||||
|
||||
noticeController.close();
|
||||
}
|
||||
}, slots.action ? slots.action(noticeController) : options.actionText ?? props.actionText)]);
|
||||
}
|
||||
|
||||
function getGenerateSnackbar(props, slots, noticeController) {
|
||||
return options => () => {
|
||||
return [h('article', {
|
||||
class: ['snackbar', options.position || props.position],
|
||||
role: 'alert'
|
||||
}, [generateMessage(slots, options.message ?? props.message), generateAction(props, slots, noticeController, options)])];
|
||||
};
|
||||
}
|
||||
|
||||
export function useSnackbar(props = DEFAULT_SNACKBAR_PROPS, slots = {}) {
|
||||
const renderNotification = shallowRef(constant(constEmptyArray));
|
||||
const controller = useNoticeController(props, renderNotification);
|
||||
renderNotification.value = getGenerateSnackbar(props, slots, controller);
|
||||
return controller;
|
||||
}
|
||||
//# sourceMappingURL=useSnackbar.js.map
|
||||
1
node_modules/buetify/lib/composables/snackbar/useSnackbar.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/snackbar/useSnackbar.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user