@vinicunca/taman-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -0
- package/dist/_virtual/_/plugin-vue/export-helper.mjs +8 -0
- package/dist/components/auth/index.d.ts +2 -0
- package/dist/components/auth/index.mjs +2 -0
- package/dist/components/auth/taman-auth-form.mjs +67 -0
- package/dist/components/auth/taman-auth-form.vue.d.ts +31 -0
- package/dist/components/back-to-top/index.mjs +2 -0
- package/dist/components/back-to-top/taman-back-to-top.mjs +70 -0
- package/dist/components/back-to-top/taman-back-to-top.vue.d.ts +18 -0
- package/dist/components/button/check-group-selection.mjs +17 -0
- package/dist/components/button/index.d.ts +4 -0
- package/dist/components/button/index.mjs +3 -0
- package/dist/components/button/taman-button-check-group.mjs +132 -0
- package/dist/components/button/taman-button-check-group.types.d.ts +22 -0
- package/dist/components/button/taman-button-check-group.vue.d.ts +41 -0
- package/dist/components/button/taman-button-icon.mjs +105 -0
- package/dist/components/button/taman-button-icon.vue.d.ts +17 -0
- package/dist/components/descriptions/index.d.ts +4 -0
- package/dist/components/descriptions/index.mjs +3 -0
- package/dist/components/descriptions/taman-description-cell.mjs +116 -0
- package/dist/components/descriptions/taman-description-item.mjs +10 -0
- package/dist/components/descriptions/taman-description-item.vue.d.ts +5 -0
- package/dist/components/descriptions/taman-description-row.mjs +131 -0
- package/dist/components/descriptions/taman-description.mjs +78 -0
- package/dist/components/descriptions/taman-description.types.d.ts +51 -0
- package/dist/components/descriptions/taman-description.vue.d.ts +23 -0
- package/dist/components/descriptions/use-taman-description.mjs +161 -0
- package/dist/components/file-upload/index.d.ts +3 -0
- package/dist/components/file-upload/index.mjs +2 -0
- package/dist/components/file-upload/taman-file-upload.mjs +88 -0
- package/dist/components/file-upload/taman-file-upload.types.d.ts +10 -0
- package/dist/components/file-upload/taman-file-upload.vue.d.ts +21 -0
- package/dist/components/full-screen/full-screen.mjs +27 -0
- package/dist/components/full-screen/full-screen.vue.d.ts +8 -0
- package/dist/components/full-screen/index.mjs +2 -0
- package/dist/components/icon/icon.mjs +27 -0
- package/dist/components/icon/icon.vue.d.ts +9 -0
- package/dist/components/icon/index.d.ts +2 -0
- package/dist/components/icon/index.mjs +2 -0
- package/dist/components/index.d.ts +34 -0
- package/dist/components/index.mjs +31 -0
- package/dist/components/input/index.d.ts +5 -0
- package/dist/components/input/index.mjs +4 -0
- package/dist/components/input/password-strength.d.ts +7 -0
- package/dist/components/input/password-strength.mjs +21 -0
- package/dist/components/input/taman-input-currency.mjs +76 -0
- package/dist/components/input/taman-input-currency.types.d.ts +8 -0
- package/dist/components/input/taman-input-currency.vue.d.ts +15 -0
- package/dist/components/input/taman-input-password.mjs +99 -0
- package/dist/components/input/taman-input-password.vue.d.ts +17 -0
- package/dist/components/input-date/format-calendar-input-value.mjs +26 -0
- package/dist/components/input-date/index.d.ts +3 -0
- package/dist/components/input-date/index.mjs +2 -0
- package/dist/components/input-date/taman-input-date.mjs +116 -0
- package/dist/components/input-date/taman-input-date.types.d.ts +14 -0
- package/dist/components/input-date/taman-input-date.vue.d.ts +21 -0
- package/dist/components/loading/index.d.ts +3 -0
- package/dist/components/loading/index.mjs +2 -0
- package/dist/components/loading/taman-loading.mjs +64 -0
- package/dist/components/loading/taman-loading.vue.d.ts +25 -0
- package/dist/components/loading/types.d.ts +13 -0
- package/dist/components/logo/index.mjs +2 -0
- package/dist/components/logo/taman-logo.mjs +60 -0
- package/dist/components/logo/taman-logo.vue.d.ts +32 -0
- package/dist/components/render-content/index.d.ts +2 -0
- package/dist/components/render-content/index.mjs +2 -0
- package/dist/components/render-content/render-content.mjs +42 -0
- package/dist/components/render-content/render-content.vue.d.ts +31 -0
- package/dist/components/scrollbar/index.d.ts +2 -0
- package/dist/components/scrollbar/index.mjs +2 -0
- package/dist/components/scrollbar/scrollbar.mjs +136 -0
- package/dist/components/scrollbar/scrollbar.vue.d.ts +50 -0
- package/dist/form/components/form-actions.mjs +151 -0
- package/dist/form/components/form-field-array.mjs +154 -0
- package/dist/form/components/form-field-array.types.d.ts +18 -0
- package/dist/form/form-render/form-render-field-collapsible.mjs +32 -0
- package/dist/form/form-render/form-render-field-control.mjs +44 -0
- package/dist/form/form-render/form-render-form-field.mjs +408 -0
- package/dist/form/form-render/form-render-form-label.mjs +46 -0
- package/dist/form/form-render/form-render-form.mjs +163 -0
- package/dist/form/form-render/form-render-group.mjs +89 -0
- package/dist/form/form-render/form-render.context.mjs +10 -0
- package/dist/form/form-render/form-render.dependencies.mjs +101 -0
- package/dist/form/form-render/form-render.helper.mjs +31 -0
- package/dist/form/form-render/form-render.schema.mjs +209 -0
- package/dist/form/form-render/index.mjs +4 -0
- package/dist/form/form.api.d.ts +54 -0
- package/dist/form/form.api.mjs +324 -0
- package/dist/form/form.built-ins.d.ts +36 -0
- package/dist/form/form.built-ins.mjs +48 -0
- package/dist/form/form.codec.d.ts +17 -0
- package/dist/form/form.codec.mjs +45 -0
- package/dist/form/form.config.d.ts +6 -0
- package/dist/form/form.config.mjs +43 -0
- package/dist/form/form.empty-value.d.ts +4 -0
- package/dist/form/form.empty-value.mjs +20 -0
- package/dist/form/form.field-name.mjs +25 -0
- package/dist/form/form.rule-registry.mjs +10 -0
- package/dist/form/form.runtime-field.mjs +56 -0
- package/dist/form/form.runtime.mjs +235 -0
- package/dist/form/form.schema-defaults.mjs +36 -0
- package/dist/form/form.types.d.ts +315 -0
- package/dist/form/form.use-delayed-flag.mjs +35 -0
- package/dist/form/form.use-form-context.mjs +44 -0
- package/dist/form/form.use-taman-form.d.ts +7 -0
- package/dist/form/form.use-taman-form.mjs +36 -0
- package/dist/form/index.d.ts +8 -0
- package/dist/form/index.mjs +6 -0
- package/dist/form/taman-use-form.mjs +146 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.mjs +56 -0
- package/dist/layout/components/index.mjs +6 -0
- package/dist/layout/components/taman-core-button-collapse.mjs +38 -0
- package/dist/layout/components/taman-core-button-fixed.mjs +29 -0
- package/dist/layout/components/taman-core-layout-content.mjs +50 -0
- package/dist/layout/components/taman-core-layout-footer.mjs +38 -0
- package/dist/layout/components/taman-core-layout-header.mjs +48 -0
- package/dist/layout/components/taman-core-layout-sidebar.mjs +319 -0
- package/dist/layout/components/taman-core-layout-tabbar.mjs +21 -0
- package/dist/layout/composables/use-layout.mjs +31 -0
- package/dist/layout/composables/use-sidebar-drag.mjs +103 -0
- package/dist/layout/header-scroll-state.mjs +9 -0
- package/dist/layout/index.d.ts +3 -0
- package/dist/layout/index.mjs +2 -0
- package/dist/layout/taman-core-layout.d.ts +41 -0
- package/dist/layout/taman-core-layout.mjs +603 -0
- package/dist/layout/taman-core-layout.vue.d.ts +99 -0
- package/dist/menu/components/collapse-transition.mjs +82 -0
- package/dist/menu/components/index.mjs +5 -0
- package/dist/menu/components/normal-menu/index.d.ts +3 -0
- package/dist/menu/components/normal-menu/index.mjs +2 -0
- package/dist/menu/components/normal-menu/normal-menu.d.ts +11 -0
- package/dist/menu/components/normal-menu/normal-menu.mjs +50 -0
- package/dist/menu/components/normal-menu/normal-menu.vue.d.ts +19 -0
- package/dist/menu/components/taman-menu-badge-dot.mjs +23 -0
- package/dist/menu/components/taman-menu-badge.mjs +49 -0
- package/dist/menu/components/taman-menu-badge.vue.d.ts +9 -0
- package/dist/menu/components/taman-menu-item.mjs +124 -0
- package/dist/menu/components/taman-menu-root.mjs +250 -0
- package/dist/menu/components/taman-menu-sub-menu-content.mjs +83 -0
- package/dist/menu/components/taman-menu-sub-menu.mjs +216 -0
- package/dist/menu/composables/index.mjs +3 -0
- package/dist/menu/composables/use-menu-context.mjs +36 -0
- package/dist/menu/composables/use-menu-scroll.mjs +23 -0
- package/dist/menu/composables/use-menu.mjs +33 -0
- package/dist/menu/index.d.ts +7 -0
- package/dist/menu/index.mjs +5 -0
- package/dist/menu/menu.constants.mjs +5 -0
- package/dist/menu/menu.types.d.ts +63 -0
- package/dist/menu/menu.utils.mjs +27 -0
- package/dist/menu/taman-menu.mjs +41 -0
- package/dist/menu/taman-menu.vue.d.ts +12 -0
- package/dist/menu/taman-sub-menu.mjs +75 -0
- package/dist/popup/alert/alert-builder.d.ts +8 -0
- package/dist/popup/alert/alert-builder.mjs +98 -0
- package/dist/popup/alert/alert-overlay.mjs +55 -0
- package/dist/popup/alert/alert.d.ts +43 -0
- package/dist/popup/alert/alert.mjs +10 -0
- package/dist/popup/alert/alert.vue.d.ts +26 -0
- package/dist/popup/alert/alert2.mjs +238 -0
- package/dist/popup/alert/index.d.ts +4 -0
- package/dist/popup/alert/index.mjs +4 -0
- package/dist/popup/dialog/dialog.api.d.ts +23 -0
- package/dist/popup/dialog/dialog.api.mjs +133 -0
- package/dist/popup/dialog/dialog.mjs +336 -0
- package/dist/popup/dialog/dialog.types.d.ts +60 -0
- package/dist/popup/dialog/dialog.vue.d.ts +46 -0
- package/dist/popup/dialog/index.d.ts +4 -0
- package/dist/popup/dialog/index.mjs +3 -0
- package/dist/popup/dialog/use-dialog-draggable.mjs +93 -0
- package/dist/popup/dialog/use-taman-dialog.d.ts +13 -0
- package/dist/popup/dialog/use-taman-dialog.mjs +106 -0
- package/dist/popup/drawer/drawer.api.d.ts +23 -0
- package/dist/popup/drawer/drawer.api.mjs +124 -0
- package/dist/popup/drawer/drawer.mjs +277 -0
- package/dist/popup/drawer/drawer.types.d.ts +56 -0
- package/dist/popup/drawer/drawer.vue.d.ts +47 -0
- package/dist/popup/drawer/index.d.ts +4 -0
- package/dist/popup/drawer/index.mjs +3 -0
- package/dist/popup/drawer/use-taman-drawer.d.ts +13 -0
- package/dist/popup/drawer/use-taman-drawer.mjs +109 -0
- package/dist/popup/index.d.ts +13 -0
- package/dist/popup/index.mjs +11 -0
- package/dist/tabs/components/index.mjs +2 -0
- package/dist/tabs/components/taman-tabs.mjs +158 -0
- package/dist/tabs/components/widgets/index.d.ts +4 -0
- package/dist/tabs/components/widgets/index.mjs +4 -0
- package/dist/tabs/components/widgets/tool-more.mjs +45 -0
- package/dist/tabs/components/widgets/tool-more.vue.d.ts +7 -0
- package/dist/tabs/components/widgets/tool-refresh.mjs +25 -0
- package/dist/tabs/components/widgets/tool-refresh.vue.d.ts +9 -0
- package/dist/tabs/components/widgets/tool-screen.mjs +29 -0
- package/dist/tabs/components/widgets/tool-screen.vue.d.ts +12 -0
- package/dist/tabs/index.d.ts +8 -0
- package/dist/tabs/index.mjs +6 -0
- package/dist/tabs/strict-context-menu.d.ts +10 -0
- package/dist/tabs/tabs.types.d.ts +30 -0
- package/dist/tabs/taman-tabs-view.mjs +101 -0
- package/dist/tabs/taman-tabs-view.vue.d.ts +18 -0
- package/dist/tabs/use-tabs-drag.mjs +69 -0
- package/dist/tabs/use-tabs-view-scroll.mjs +114 -0
- package/dist/ui/alert-dialog/alert-dialog-action.mjs +21 -0
- package/dist/ui/alert-dialog/alert-dialog-action.vue.d.ts +16 -0
- package/dist/ui/alert-dialog/alert-dialog-cancel.mjs +21 -0
- package/dist/ui/alert-dialog/alert-dialog-cancel.vue.d.ts +16 -0
- package/dist/ui/alert-dialog/alert-dialog-content.mjs +111 -0
- package/dist/ui/alert-dialog/alert-dialog-content.vue.d.ts +49 -0
- package/dist/ui/alert-dialog/alert-dialog-description.mjs +30 -0
- package/dist/ui/alert-dialog/alert-dialog-description.vue.d.ts +20 -0
- package/dist/ui/alert-dialog/alert-dialog-footer.mjs +14 -0
- package/dist/ui/alert-dialog/alert-dialog-footer.vue.d.ts +15 -0
- package/dist/ui/alert-dialog/alert-dialog-header.mjs +14 -0
- package/dist/ui/alert-dialog/alert-dialog-header.vue.d.ts +15 -0
- package/dist/ui/alert-dialog/alert-dialog-overlay.mjs +29 -0
- package/dist/ui/alert-dialog/alert-dialog-root.mjs +23 -0
- package/dist/ui/alert-dialog/alert-dialog-root.vue.d.ts +23 -0
- package/dist/ui/alert-dialog/alert-dialog-title.mjs +30 -0
- package/dist/ui/alert-dialog/alert-dialog-title.vue.d.ts +20 -0
- package/dist/ui/alert-dialog/alert-dialog-trigger.mjs +21 -0
- package/dist/ui/alert-dialog/alert-dialog-trigger.vue.d.ts +16 -0
- package/dist/ui/alert-dialog/index.d.ts +10 -0
- package/dist/ui/alert-dialog/index.mjs +10 -0
- package/dist/ui/dialog/dialog-close.mjs +21 -0
- package/dist/ui/dialog/dialog-close.vue.d.ts +16 -0
- package/dist/ui/dialog/dialog-content.mjs +111 -0
- package/dist/ui/dialog/dialog-content.vue.d.ts +51 -0
- package/dist/ui/dialog/dialog-description.mjs +31 -0
- package/dist/ui/dialog/dialog-description.vue.d.ts +20 -0
- package/dist/ui/dialog/dialog-footer.mjs +14 -0
- package/dist/ui/dialog/dialog-footer.vue.d.ts +15 -0
- package/dist/ui/dialog/dialog-header.mjs +14 -0
- package/dist/ui/dialog/dialog-header.vue.d.ts +15 -0
- package/dist/ui/dialog/dialog-overlay.mjs +34 -0
- package/dist/ui/dialog/dialog-overlay.vue.d.ts +14 -0
- package/dist/ui/dialog/dialog-root.mjs +24 -0
- package/dist/ui/dialog/dialog-root.vue.d.ts +23 -0
- package/dist/ui/dialog/dialog-title.mjs +31 -0
- package/dist/ui/dialog/dialog-title.vue.d.ts +20 -0
- package/dist/ui/dialog/dialog-trigger.mjs +21 -0
- package/dist/ui/dialog/dialog-trigger.vue.d.ts +16 -0
- package/dist/ui/dialog/index.d.ts +10 -0
- package/dist/ui/dialog/index.mjs +10 -0
- package/dist/ui/dialog/use-dialog-state-events.mjs +60 -0
- package/dist/ui/form/form-control.mjs +27 -0
- package/dist/ui/form/form-control.vue.d.ts +15 -0
- package/dist/ui/form/form-description.mjs +27 -0
- package/dist/ui/form/form-description.vue.d.ts +19 -0
- package/dist/ui/form/form-field.mjs +37 -0
- package/dist/ui/form/form-field.vue.d.ts +27 -0
- package/dist/ui/form/form-item.mjs +27 -0
- package/dist/ui/form/form-item.vue.d.ts +19 -0
- package/dist/ui/form/form-label.mjs +41 -0
- package/dist/ui/form/form-label.vue.d.ts +20 -0
- package/dist/ui/form/form-message.mjs +28 -0
- package/dist/ui/form/form-message.vue.d.ts +9 -0
- package/dist/ui/form/index.d.ts +8 -0
- package/dist/ui/form/index.mjs +8 -0
- package/dist/ui/form/injection-keys.d.ts +13 -0
- package/dist/ui/form/injection-keys.mjs +5 -0
- package/dist/ui/form/use-form-field.mjs +27 -0
- package/dist/ui/index.d.ts +42 -0
- package/dist/ui/index.mjs +42 -0
- package/dist/ui/label/index.d.ts +2 -0
- package/dist/ui/label/index.mjs +2 -0
- package/dist/ui/label/label.mjs +31 -0
- package/dist/ui/label/label.vue.d.ts +20 -0
- package/dist/ui/scroll-area/index.d.ts +3 -0
- package/dist/ui/scroll-area/index.mjs +3 -0
- package/dist/ui/scroll-area/scroll-area.mjs +47 -0
- package/dist/ui/scroll-area/scroll-area.vue.d.ts +21 -0
- package/dist/ui/scroll-area/scroll-bar.mjs +38 -0
- package/dist/ui/scroll-area/scroll-bar.vue.d.ts +12 -0
- package/dist/ui/sheet/index.d.ts +8 -0
- package/dist/ui/sheet/index.mjs +8 -0
- package/dist/ui/sheet/sheet-close.mjs +21 -0
- package/dist/ui/sheet/sheet-close.vue.d.ts +16 -0
- package/dist/ui/sheet/sheet-content.mjs +105 -0
- package/dist/ui/sheet/sheet-content.vue.d.ts +48 -0
- package/dist/ui/sheet/sheet-description.mjs +30 -0
- package/dist/ui/sheet/sheet-description.vue.d.ts +20 -0
- package/dist/ui/sheet/sheet-footer.mjs +14 -0
- package/dist/ui/sheet/sheet-footer.vue.d.ts +15 -0
- package/dist/ui/sheet/sheet-header.mjs +14 -0
- package/dist/ui/sheet/sheet-header.vue.d.ts +15 -0
- package/dist/ui/sheet/sheet-overlay.mjs +32 -0
- package/dist/ui/sheet/sheet-root.mjs +24 -0
- package/dist/ui/sheet/sheet-root.vue.d.ts +23 -0
- package/dist/ui/sheet/sheet-title.mjs +31 -0
- package/dist/ui/sheet/sheet-title.vue.d.ts +20 -0
- package/dist/ui/sheet/sheet.variants.d.ts +27 -0
- package/dist/ui/sheet/sheet.variants.mjs +12 -0
- package/dist/unocss/content.d.ts +4 -0
- package/dist/unocss/content.mjs +9 -0
- package/dist/unocss/index.d.ts +2 -0
- package/dist/unocss/index.mjs +2 -0
- package/package.json +78 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DrawerApiOptions, DrawerState } from "./drawer.types.js";
|
|
2
|
+
import { Store } from "@vinicunca/taman-core/store";
|
|
3
|
+
//#region src/popup/drawer/drawer.api.d.ts
|
|
4
|
+
declare class DrawerApi<TData = unknown> {
|
|
5
|
+
sharedData: Record<'payload', TData | undefined>;
|
|
6
|
+
store: Store<DrawerState>;
|
|
7
|
+
private api;
|
|
8
|
+
private state;
|
|
9
|
+
constructor(options?: DrawerApiOptions);
|
|
10
|
+
close(): Promise<void>;
|
|
11
|
+
getData(): TData | undefined;
|
|
12
|
+
lock(isLocked?: boolean): this;
|
|
13
|
+
onCancel(): void;
|
|
14
|
+
onClosed(): void;
|
|
15
|
+
onConfirm(): void;
|
|
16
|
+
onOpened(): void;
|
|
17
|
+
open(): void;
|
|
18
|
+
setData(payload: TData): this;
|
|
19
|
+
setState(stateOrFn: ((prev: DrawerState) => Partial<DrawerState>) | Partial<DrawerState>): this;
|
|
20
|
+
unlock(): this;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { DrawerApi };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { bindMethods, isFunction } from "@vinicunca/taman-core/utils";
|
|
2
|
+
import { Store } from "@vinicunca/taman-core/store";
|
|
3
|
+
//#region src/popup/drawer/drawer.api.ts
|
|
4
|
+
var DrawerApi = class {
|
|
5
|
+
sharedData = { payload: void 0 };
|
|
6
|
+
store;
|
|
7
|
+
api;
|
|
8
|
+
state;
|
|
9
|
+
constructor(options = {}) {
|
|
10
|
+
const { connectedComponent: _, onBeforeClose, onCancel, onClosed, onConfirm, onOpenChange, onOpened, ...storeState } = options;
|
|
11
|
+
const defaultState = {
|
|
12
|
+
class: "",
|
|
13
|
+
closable: true,
|
|
14
|
+
closeIconPlacement: "right",
|
|
15
|
+
closeOnClickModal: true,
|
|
16
|
+
closeOnPressEscape: true,
|
|
17
|
+
confirmLoading: false,
|
|
18
|
+
contentClass: "",
|
|
19
|
+
footer: true,
|
|
20
|
+
header: true,
|
|
21
|
+
isOpen: false,
|
|
22
|
+
loading: false,
|
|
23
|
+
modal: true,
|
|
24
|
+
openAutoFocus: false,
|
|
25
|
+
placement: "right",
|
|
26
|
+
showCancelButton: true,
|
|
27
|
+
showConfirmButton: true,
|
|
28
|
+
submitting: false,
|
|
29
|
+
title: ""
|
|
30
|
+
};
|
|
31
|
+
this.store = new Store({
|
|
32
|
+
...defaultState,
|
|
33
|
+
...storeState
|
|
34
|
+
});
|
|
35
|
+
this.store.subscribe((state) => {
|
|
36
|
+
const prevIsOpen = this.state?.isOpen;
|
|
37
|
+
this.state = state;
|
|
38
|
+
if (state?.isOpen !== prevIsOpen) this.api.onOpenChange?.(!!state?.isOpen);
|
|
39
|
+
});
|
|
40
|
+
this.state = this.store.state;
|
|
41
|
+
this.api = {
|
|
42
|
+
onBeforeClose,
|
|
43
|
+
onCancel,
|
|
44
|
+
onClosed,
|
|
45
|
+
onConfirm,
|
|
46
|
+
onOpenChange,
|
|
47
|
+
onOpened
|
|
48
|
+
};
|
|
49
|
+
bindMethods(this);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Close drawer
|
|
53
|
+
* @description When closing the drawer, the onBeforeClose hook function is called, and if onBeforeClose returns false, the drawer will not be closed
|
|
54
|
+
*/
|
|
55
|
+
async close() {
|
|
56
|
+
if (await this.api.onBeforeClose?.() ?? true) this.store.setState((prev) => ({
|
|
57
|
+
...prev,
|
|
58
|
+
isOpen: false,
|
|
59
|
+
submitting: false
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
getData() {
|
|
63
|
+
return this.sharedData.payload;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Lock drawer state (used for waiting state during submission)
|
|
67
|
+
* @description The locked state will disable the default cancel button, use spinner to cover the drawer content, hide the close button, prevent manual closing of the drawer, and mark the default submit button as loading state
|
|
68
|
+
*/
|
|
69
|
+
lock(isLocked = true) {
|
|
70
|
+
return this.setState({ submitting: isLocked });
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Cancel operation
|
|
74
|
+
*/
|
|
75
|
+
onCancel() {
|
|
76
|
+
if (this.api.onCancel) this.api.onCancel?.();
|
|
77
|
+
else this.close();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Callback after the drawer close animation is complete
|
|
81
|
+
*/
|
|
82
|
+
onClosed() {
|
|
83
|
+
if (!this.state.isOpen) this.api.onClosed?.();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Confirm operation
|
|
87
|
+
*/
|
|
88
|
+
onConfirm() {
|
|
89
|
+
this.api.onConfirm?.();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Callback after the drawer open animation is complete
|
|
93
|
+
*/
|
|
94
|
+
onOpened() {
|
|
95
|
+
if (this.state.isOpen) this.api.onOpened?.();
|
|
96
|
+
}
|
|
97
|
+
open() {
|
|
98
|
+
this.store.setState((prev) => ({
|
|
99
|
+
...prev,
|
|
100
|
+
isOpen: true
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
setData(payload) {
|
|
104
|
+
this.sharedData.payload = payload;
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
setState(stateOrFn) {
|
|
108
|
+
if (isFunction(stateOrFn)) this.store.setState(stateOrFn);
|
|
109
|
+
else this.store.setState((prev) => ({
|
|
110
|
+
...prev,
|
|
111
|
+
...stateOrFn
|
|
112
|
+
}));
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Unlock the drawer state
|
|
117
|
+
* @description Unlock the state set by the lock method, is an alias for lock(false)
|
|
118
|
+
*/
|
|
119
|
+
unlock() {
|
|
120
|
+
return this.lock(false);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
//#endregion
|
|
124
|
+
export { DrawerApi };
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import _sfc_main$1 from "../../components/button/taman-button-icon.mjs";
|
|
2
|
+
import _sfc_main$2 from "../../components/loading/taman-loading.mjs";
|
|
3
|
+
import _sfc_main$3 from "../../ui/sheet/sheet-close.mjs";
|
|
4
|
+
import _sfc_main$4 from "../../ui/sheet/sheet-content.mjs";
|
|
5
|
+
import _sfc_main$5 from "../../ui/sheet/sheet-description.mjs";
|
|
6
|
+
import sheet_footer_default from "../../ui/sheet/sheet-footer.mjs";
|
|
7
|
+
import sheet_header_default from "../../ui/sheet/sheet-header.mjs";
|
|
8
|
+
import _sfc_main$6 from "../../ui/sheet/sheet-root.mjs";
|
|
9
|
+
import _sfc_main$7 from "../../ui/sheet/sheet-title.mjs";
|
|
10
|
+
import { VisuallyHidden } from "../../index.mjs";
|
|
11
|
+
import { computed, createBlock, createCommentVNode, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, onDeactivated, openBlock, provide, ref, renderSlot, toDisplayString, unref, useId, watch, withCtx } from "vue";
|
|
12
|
+
import PButton from "pohon-ui/components/Button.vue";
|
|
13
|
+
import PSeparator from "pohon-ui/components/Separator.vue";
|
|
14
|
+
import PTooltip from "pohon-ui/components/Tooltip.vue";
|
|
15
|
+
import { useBreakpoints, useOverlayZIndex, usePriorityValues, useSimpleLocale } from "@vinicunca/taman-core/composables";
|
|
16
|
+
import PIcon from "pohon-ui/components/Icon.vue";
|
|
17
|
+
import { DISMISSABLE_DRAWER_ID, ELEMENT_ID_MAIN_CONTENT } from "@vinicunca/taman-core/constants";
|
|
18
|
+
//#region src/popup/drawer/drawer.vue
|
|
19
|
+
const _hoisted_1 = { class: "flex items-center" };
|
|
20
|
+
const _hoisted_2 = { class: "flex flex-col gap-1" };
|
|
21
|
+
const _hoisted_3 = { class: "flex-center" };
|
|
22
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
23
|
+
__name: "drawer",
|
|
24
|
+
props: {
|
|
25
|
+
drawerApi: { default: void 0 },
|
|
26
|
+
appendToMain: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false
|
|
29
|
+
},
|
|
30
|
+
cancelText: {},
|
|
31
|
+
class: { type: [
|
|
32
|
+
Boolean,
|
|
33
|
+
null,
|
|
34
|
+
String,
|
|
35
|
+
Object,
|
|
36
|
+
Array
|
|
37
|
+
] },
|
|
38
|
+
closable: { type: Boolean },
|
|
39
|
+
closeIconPlacement: { default: "right" },
|
|
40
|
+
closeOnClickModal: { type: Boolean },
|
|
41
|
+
closeOnPressEscape: { type: Boolean },
|
|
42
|
+
confirmLoading: { type: Boolean },
|
|
43
|
+
confirmText: {},
|
|
44
|
+
contentClass: {},
|
|
45
|
+
description: {},
|
|
46
|
+
destroyOnClose: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false
|
|
49
|
+
},
|
|
50
|
+
footer: { type: Boolean },
|
|
51
|
+
footerClass: { type: [
|
|
52
|
+
Boolean,
|
|
53
|
+
null,
|
|
54
|
+
String,
|
|
55
|
+
Object,
|
|
56
|
+
Array
|
|
57
|
+
] },
|
|
58
|
+
header: { type: Boolean },
|
|
59
|
+
headerClass: { type: [
|
|
60
|
+
Boolean,
|
|
61
|
+
null,
|
|
62
|
+
String,
|
|
63
|
+
Object,
|
|
64
|
+
Array
|
|
65
|
+
] },
|
|
66
|
+
loading: { type: Boolean },
|
|
67
|
+
modal: { type: Boolean },
|
|
68
|
+
openAutoFocus: { type: Boolean },
|
|
69
|
+
overlayBlur: {},
|
|
70
|
+
placement: {},
|
|
71
|
+
showCancelButton: { type: Boolean },
|
|
72
|
+
showConfirmButton: { type: Boolean },
|
|
73
|
+
submitting: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: false
|
|
76
|
+
},
|
|
77
|
+
title: {},
|
|
78
|
+
titleTooltip: {},
|
|
79
|
+
zIndex: {}
|
|
80
|
+
},
|
|
81
|
+
setup(__props) {
|
|
82
|
+
const props = __props;
|
|
83
|
+
const id = useId();
|
|
84
|
+
provide(DISMISSABLE_DRAWER_ID, id);
|
|
85
|
+
const { $t } = useSimpleLocale();
|
|
86
|
+
const { isMobile } = useBreakpoints();
|
|
87
|
+
const state = props.drawerApi?.useStore?.();
|
|
88
|
+
const { appendToMain, cancelText, class: drawerClass, closable, closeIconPlacement, closeOnClickModal, closeOnPressEscape, confirmLoading, confirmText, contentClass, description, destroyOnClose, footer: showFooter, footerClass, header: showHeader, headerClass, loading: showLoading, modal, openAutoFocus, overlayBlur, placement, showCancelButton, showConfirmButton, submitting, title, titleTooltip, zIndex } = usePriorityValues(props, state);
|
|
89
|
+
const openZIndex = useOverlayZIndex(() => state?.value?.isOpen);
|
|
90
|
+
const layerZIndex = computed(() => zIndex.value ?? openZIndex.value);
|
|
91
|
+
/**
|
|
92
|
+
* With keepAlive enabled, browser back/gesture navigation does not close the drawer
|
|
93
|
+
*/
|
|
94
|
+
onDeactivated(() => {
|
|
95
|
+
if (!appendToMain.value) props.drawerApi?.close();
|
|
96
|
+
});
|
|
97
|
+
function interactOutside(event) {
|
|
98
|
+
if (!closeOnClickModal.value || submitting.value) event.preventDefault();
|
|
99
|
+
}
|
|
100
|
+
function escapeKeyDown(event) {
|
|
101
|
+
if (!closeOnPressEscape.value || submitting.value) event.preventDefault();
|
|
102
|
+
}
|
|
103
|
+
function pointerDownOutside(event) {
|
|
104
|
+
const dismissableDrawer = event.target?.dataset.dismissableDrawer;
|
|
105
|
+
if (submitting.value || !closeOnClickModal.value || dismissableDrawer !== id) event.preventDefault();
|
|
106
|
+
}
|
|
107
|
+
function handerOpenAutoFocus(event) {
|
|
108
|
+
if (!openAutoFocus.value) event?.preventDefault();
|
|
109
|
+
}
|
|
110
|
+
function handleFocusOutside(event) {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
}
|
|
114
|
+
const getAppendTo = computed(() => {
|
|
115
|
+
return appendToMain.value ? `#${ELEMENT_ID_MAIN_CONTENT}` : void 0;
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* Improve the destroyOnClose feature
|
|
119
|
+
*/
|
|
120
|
+
const hasOpened = ref(false);
|
|
121
|
+
const isClosed = ref(true);
|
|
122
|
+
watch(() => state?.value?.isOpen, (value) => {
|
|
123
|
+
isClosed.value = false;
|
|
124
|
+
if (value && !unref(hasOpened)) hasOpened.value = true;
|
|
125
|
+
}, { immediate: true });
|
|
126
|
+
function handleClosed() {
|
|
127
|
+
isClosed.value = true;
|
|
128
|
+
props.drawerApi?.onClosed();
|
|
129
|
+
}
|
|
130
|
+
const getForceMount = computed(() => {
|
|
131
|
+
return !unref(destroyOnClose) && unref(hasOpened);
|
|
132
|
+
});
|
|
133
|
+
return (_ctx, _cache) => {
|
|
134
|
+
return openBlock(), createBlock(unref(_sfc_main$6), {
|
|
135
|
+
modal: false,
|
|
136
|
+
open: unref(state)?.isOpen,
|
|
137
|
+
"onUpdate:open": _cache[3] || (_cache[3] = () => __props.drawerApi?.close())
|
|
138
|
+
}, {
|
|
139
|
+
default: withCtx(() => [createVNode(unref(_sfc_main$4), {
|
|
140
|
+
"append-to": getAppendTo.value,
|
|
141
|
+
class: normalizeClass(["flex flex-col w-130", [{
|
|
142
|
+
"pohon:w-full": unref(isMobile) || unref(placement) === "bottom" || unref(placement) === "top",
|
|
143
|
+
"max-h-screen": unref(placement) === "bottom" || unref(placement) === "top",
|
|
144
|
+
"hidden": isClosed.value
|
|
145
|
+
}, unref(drawerClass)]]),
|
|
146
|
+
modal: unref(modal),
|
|
147
|
+
open: unref(state)?.isOpen,
|
|
148
|
+
side: unref(placement),
|
|
149
|
+
"z-index": layerZIndex.value,
|
|
150
|
+
"force-mount": getForceMount.value,
|
|
151
|
+
"overlay-blur": unref(overlayBlur),
|
|
152
|
+
onCloseAutoFocus: handleFocusOutside,
|
|
153
|
+
onClosed: handleClosed,
|
|
154
|
+
onEscapeKeyDown: escapeKeyDown,
|
|
155
|
+
onFocusOutside: handleFocusOutside,
|
|
156
|
+
onInteractOutside: interactOutside,
|
|
157
|
+
onOpenAutoFocus: handerOpenAutoFocus,
|
|
158
|
+
onOpened: _cache[2] || (_cache[2] = () => __props.drawerApi?.onOpened()),
|
|
159
|
+
onPointerDownOutside: pointerDownOutside
|
|
160
|
+
}, {
|
|
161
|
+
default: withCtx(() => [
|
|
162
|
+
unref(showHeader) ? (openBlock(), createBlock(unref(sheet_header_default), {
|
|
163
|
+
key: 0,
|
|
164
|
+
class: normalizeClass(["border-b items-start justify-between", [unref(headerClass), { "pl-2": unref(closable) && unref(closeIconPlacement) === "left" }]])
|
|
165
|
+
}, {
|
|
166
|
+
default: withCtx(() => [
|
|
167
|
+
createElementVNode("div", _hoisted_1, [
|
|
168
|
+
unref(closable) && unref(closeIconPlacement) === "left" ? (openBlock(), createBlock(unref(_sfc_main$3), {
|
|
169
|
+
key: 0,
|
|
170
|
+
"as-child": "",
|
|
171
|
+
disabled: unref(submitting)
|
|
172
|
+
}, {
|
|
173
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "close-icon", {}, () => [createVNode(unref(_sfc_main$1), { icon: "lucide:x" })])]),
|
|
174
|
+
_: 3
|
|
175
|
+
}, 8, ["disabled"])) : createCommentVNode("v-if", true),
|
|
176
|
+
unref(closable) && unref(closeIconPlacement) === "left" ? (openBlock(), createBlock(PSeparator, {
|
|
177
|
+
key: 1,
|
|
178
|
+
class: "ml-1 mr-2 h-8",
|
|
179
|
+
decorative: "",
|
|
180
|
+
orientation: "vertical"
|
|
181
|
+
})) : createCommentVNode("v-if", true),
|
|
182
|
+
createElementVNode("div", _hoisted_2, [unref(title) ? (openBlock(), createBlock(unref(_sfc_main$7), {
|
|
183
|
+
key: 0,
|
|
184
|
+
class: "text-left inline-flex gap-1"
|
|
185
|
+
}, {
|
|
186
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "title", {}, () => [createTextVNode(toDisplayString(unref(title)) + " ", 1), unref(titleTooltip) ? (openBlock(), createBlock(PTooltip, {
|
|
187
|
+
key: 0,
|
|
188
|
+
text: unref(titleTooltip)
|
|
189
|
+
}, {
|
|
190
|
+
default: withCtx(() => [createVNode(PIcon, {
|
|
191
|
+
name: "lucide:circle-help",
|
|
192
|
+
class: "color-text-muted"
|
|
193
|
+
})]),
|
|
194
|
+
_: 1
|
|
195
|
+
}, 8, ["text"])) : createCommentVNode("v-if", true)])]),
|
|
196
|
+
_: 3
|
|
197
|
+
})) : createCommentVNode("v-if", true), unref(description) ? (openBlock(), createBlock(unref(_sfc_main$5), {
|
|
198
|
+
key: 1,
|
|
199
|
+
class: "text-xs"
|
|
200
|
+
}, {
|
|
201
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "description", {}, () => [createTextVNode(toDisplayString(unref(description)), 1)])]),
|
|
202
|
+
_: 3
|
|
203
|
+
})) : createCommentVNode("v-if", true)])
|
|
204
|
+
]),
|
|
205
|
+
createElementVNode("div", _hoisted_3, [renderSlot(_ctx.$slots, "extra"), unref(closable) && unref(closeIconPlacement) === "right" ? (openBlock(), createBlock(unref(_sfc_main$3), {
|
|
206
|
+
key: 0,
|
|
207
|
+
"as-child": "",
|
|
208
|
+
disabled: unref(submitting)
|
|
209
|
+
}, {
|
|
210
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "close-icon", {}, () => [createVNode(unref(_sfc_main$1), { icon: "lucide:x" })])]),
|
|
211
|
+
_: 3
|
|
212
|
+
}, 8, ["disabled"])) : createCommentVNode("v-if", true)]),
|
|
213
|
+
!unref(title) || !unref(description) ? (openBlock(), createBlock(unref(VisuallyHidden), { key: 0 }, {
|
|
214
|
+
default: withCtx(() => [!unref(title) ? (openBlock(), createBlock(unref(_sfc_main$7), { key: 0 })) : createCommentVNode("v-if", true), !unref(description) ? (openBlock(), createBlock(unref(_sfc_main$5), { key: 1 })) : createCommentVNode("v-if", true)]),
|
|
215
|
+
_: 1
|
|
216
|
+
})) : createCommentVNode("v-if", true)
|
|
217
|
+
]),
|
|
218
|
+
_: 3
|
|
219
|
+
}, 8, ["class"])) : (openBlock(), createBlock(unref(VisuallyHidden), { key: 1 }, {
|
|
220
|
+
default: withCtx(() => [createVNode(unref(_sfc_main$7)), createVNode(unref(_sfc_main$5))]),
|
|
221
|
+
_: 1
|
|
222
|
+
})),
|
|
223
|
+
createElementVNode("div", { class: normalizeClass(["p-3 flex-1 relative overflow-y-auto", [unref(contentClass), { "pointer-events-none": unref(showLoading) || unref(submitting) }]]) }, [renderSlot(_ctx.$slots, "default")], 2),
|
|
224
|
+
unref(showLoading) || unref(submitting) ? (openBlock(), createBlock(unref(_sfc_main$2), {
|
|
225
|
+
key: 2,
|
|
226
|
+
spinning: ""
|
|
227
|
+
})) : createCommentVNode("v-if", true),
|
|
228
|
+
unref(showFooter) ? (openBlock(), createBlock(unref(sheet_footer_default), {
|
|
229
|
+
key: 3,
|
|
230
|
+
class: normalizeClass(["p-2 px-3 border-t flex-row w-full items-center justify-end", [unref(footerClass)]])
|
|
231
|
+
}, {
|
|
232
|
+
default: withCtx(() => [
|
|
233
|
+
renderSlot(_ctx.$slots, "prepend-footer"),
|
|
234
|
+
renderSlot(_ctx.$slots, "footer", {}, () => [
|
|
235
|
+
unref(showCancelButton) ? (openBlock(), createBlock(PButton, {
|
|
236
|
+
key: 0,
|
|
237
|
+
variant: "outline",
|
|
238
|
+
color: "neutral",
|
|
239
|
+
disabled: unref(submitting),
|
|
240
|
+
onClick: _cache[0] || (_cache[0] = () => __props.drawerApi?.onCancel())
|
|
241
|
+
}, {
|
|
242
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "cancelText", {}, () => [createTextVNode(toDisplayString(unref(cancelText) || unref($t)("cancel")), 1)])]),
|
|
243
|
+
_: 3
|
|
244
|
+
}, 8, ["disabled"])) : createCommentVNode("v-if", true),
|
|
245
|
+
renderSlot(_ctx.$slots, "center-footer"),
|
|
246
|
+
unref(showConfirmButton) ? (openBlock(), createBlock(PButton, {
|
|
247
|
+
key: 1,
|
|
248
|
+
loading: unref(confirmLoading) || unref(submitting),
|
|
249
|
+
onClick: _cache[1] || (_cache[1] = () => __props.drawerApi?.onConfirm())
|
|
250
|
+
}, {
|
|
251
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "confirmText", {}, () => [createTextVNode(toDisplayString(unref(confirmText) || unref($t)("confirm")), 1)])]),
|
|
252
|
+
_: 3
|
|
253
|
+
}, 8, ["loading"])) : createCommentVNode("v-if", true)
|
|
254
|
+
]),
|
|
255
|
+
renderSlot(_ctx.$slots, "append-footer")
|
|
256
|
+
]),
|
|
257
|
+
_: 3
|
|
258
|
+
}, 8, ["class"])) : createCommentVNode("v-if", true)
|
|
259
|
+
]),
|
|
260
|
+
_: 3
|
|
261
|
+
}, 8, [
|
|
262
|
+
"append-to",
|
|
263
|
+
"class",
|
|
264
|
+
"modal",
|
|
265
|
+
"open",
|
|
266
|
+
"side",
|
|
267
|
+
"z-index",
|
|
268
|
+
"force-mount",
|
|
269
|
+
"overlay-blur"
|
|
270
|
+
])]),
|
|
271
|
+
_: 3
|
|
272
|
+
}, 8, ["open"]);
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
//#endregion
|
|
277
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { DrawerApi } from "./drawer.api.js";
|
|
2
|
+
import { Component, HTMLAttributes, Ref } from "vue";
|
|
3
|
+
import { MaybePromise } from "@vinicunca/taman-core/typings";
|
|
4
|
+
//#region src/popup/drawer/drawer.types.d.ts
|
|
5
|
+
type DrawerPlacement = 'bottom' | 'left' | 'right' | 'top';
|
|
6
|
+
type CloseIconPlacement = 'left' | 'right';
|
|
7
|
+
interface TamanDrawerProps {
|
|
8
|
+
appendToMain?: boolean;
|
|
9
|
+
cancelText?: string;
|
|
10
|
+
class?: HTMLAttributes['class'];
|
|
11
|
+
closable?: boolean;
|
|
12
|
+
closeIconPlacement?: CloseIconPlacement;
|
|
13
|
+
closeOnClickModal?: boolean;
|
|
14
|
+
closeOnPressEscape?: boolean;
|
|
15
|
+
confirmLoading?: boolean;
|
|
16
|
+
confirmText?: string;
|
|
17
|
+
contentClass?: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
destroyOnClose?: boolean;
|
|
20
|
+
footer?: boolean;
|
|
21
|
+
footerClass?: HTMLAttributes['class'];
|
|
22
|
+
header?: boolean;
|
|
23
|
+
headerClass?: HTMLAttributes['class'];
|
|
24
|
+
loading?: boolean;
|
|
25
|
+
modal?: boolean;
|
|
26
|
+
openAutoFocus?: boolean;
|
|
27
|
+
overlayBlur?: number;
|
|
28
|
+
placement?: DrawerPlacement;
|
|
29
|
+
showCancelButton?: boolean;
|
|
30
|
+
showConfirmButton?: boolean;
|
|
31
|
+
submitting?: boolean;
|
|
32
|
+
title?: string;
|
|
33
|
+
titleTooltip?: string;
|
|
34
|
+
zIndex?: number;
|
|
35
|
+
}
|
|
36
|
+
interface DrawerState extends TamanDrawerProps {
|
|
37
|
+
isOpen?: boolean;
|
|
38
|
+
}
|
|
39
|
+
type ExtendedDrawerApi<TData = unknown> = DrawerApi<TData> & {
|
|
40
|
+
useStore: <T = NoInfer<DrawerState>>(selector?: (state: NoInfer<DrawerState>) => T) => Readonly<Ref<T>>;
|
|
41
|
+
};
|
|
42
|
+
type DrawerComponentInstance<TComponent extends Component> = TComponent extends (abstract new (...args: Array<any>) => infer TInstance) ? TInstance : never;
|
|
43
|
+
type InferDrawerData<TComponent extends Component> = [DrawerComponentInstance<TComponent>] extends [never] ? unknown : DrawerComponentInstance<TComponent> extends {
|
|
44
|
+
drawerApi: ExtendedDrawerApi<infer TData>;
|
|
45
|
+
} ? TData : unknown;
|
|
46
|
+
interface DrawerApiOptions<TConnectedComponent extends Component = Component> extends DrawerState {
|
|
47
|
+
connectedComponent?: TConnectedComponent;
|
|
48
|
+
onBeforeClose?: () => MaybePromise<boolean | undefined>;
|
|
49
|
+
onCancel?: () => void;
|
|
50
|
+
onClosed?: () => void;
|
|
51
|
+
onConfirm?: () => void;
|
|
52
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
53
|
+
onOpened?: () => void;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { CloseIconPlacement, DrawerApiOptions, DrawerPlacement, DrawerState, ExtendedDrawerApi, InferDrawerData, TamanDrawerProps };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CloseIconPlacement, ExtendedDrawerApi, TamanDrawerProps } from "./drawer.types.js";
|
|
2
|
+
//#region src/popup/drawer/drawer.vue.d.ts
|
|
3
|
+
interface Props extends TamanDrawerProps {
|
|
4
|
+
drawerApi?: ExtendedDrawerApi;
|
|
5
|
+
}
|
|
6
|
+
declare var __VLS_37: {}, __VLS_55: {}, __VLS_74: {}, __VLS_76: {}, __VLS_84: {}, __VLS_123: {}, __VLS_136: {}, __VLS_138: {}, __VLS_148: {}, __VLS_150: {}, __VLS_160: {}, __VLS_162: {};
|
|
7
|
+
type __VLS_Slots = {} & {
|
|
8
|
+
'close-icon'?: (props: typeof __VLS_37) => any;
|
|
9
|
+
} & {
|
|
10
|
+
title?: (props: typeof __VLS_55) => any;
|
|
11
|
+
} & {
|
|
12
|
+
description?: (props: typeof __VLS_74) => any;
|
|
13
|
+
} & {
|
|
14
|
+
extra?: (props: typeof __VLS_76) => any;
|
|
15
|
+
} & {
|
|
16
|
+
'close-icon'?: (props: typeof __VLS_84) => any;
|
|
17
|
+
} & {
|
|
18
|
+
default?: (props: typeof __VLS_123) => any;
|
|
19
|
+
} & {
|
|
20
|
+
'prepend-footer'?: (props: typeof __VLS_136) => any;
|
|
21
|
+
} & {
|
|
22
|
+
footer?: (props: typeof __VLS_138) => any;
|
|
23
|
+
} & {
|
|
24
|
+
cancelText?: (props: typeof __VLS_148) => any;
|
|
25
|
+
} & {
|
|
26
|
+
'center-footer'?: (props: typeof __VLS_150) => any;
|
|
27
|
+
} & {
|
|
28
|
+
confirmText?: (props: typeof __VLS_160) => any;
|
|
29
|
+
} & {
|
|
30
|
+
'append-footer'?: (props: typeof __VLS_162) => any;
|
|
31
|
+
};
|
|
32
|
+
declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
33
|
+
appendToMain: boolean;
|
|
34
|
+
closeIconPlacement: CloseIconPlacement;
|
|
35
|
+
destroyOnClose: boolean;
|
|
36
|
+
submitting: boolean;
|
|
37
|
+
drawerApi: ExtendedDrawerApi;
|
|
38
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
39
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
40
|
+
declare const _default: typeof __VLS_export;
|
|
41
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
42
|
+
new (): {
|
|
43
|
+
$slots: S;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { _default as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CloseIconPlacement, DrawerApiOptions, DrawerPlacement, DrawerState, ExtendedDrawerApi, InferDrawerData, TamanDrawerProps } from "./drawer.types.js";
|
|
2
|
+
import _default from "./drawer.vue.js";
|
|
3
|
+
import { createTamanDrawer, setDefaultDrawerProps, useTamanDrawer } from "./use-taman-drawer.js";
|
|
4
|
+
export { type CloseIconPlacement, type DrawerApiOptions, type DrawerPlacement, type DrawerState, type ExtendedDrawerApi, type InferDrawerData, _default as TamanDrawer, type TamanDrawerProps, createTamanDrawer, setDefaultDrawerProps, useTamanDrawer };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DrawerApiOptions, ExtendedDrawerApi, InferDrawerData, TamanDrawerProps } from "./drawer.types.js";
|
|
2
|
+
import { Component } from "vue";
|
|
3
|
+
//#region src/popup/drawer/use-taman-drawer.d.ts
|
|
4
|
+
declare const DRAWER_DATA_NOT_PROVIDED: unique symbol;
|
|
5
|
+
interface DrawerDataNotProvided {
|
|
6
|
+
readonly [DRAWER_DATA_NOT_PROVIDED]: true;
|
|
7
|
+
}
|
|
8
|
+
type ResolvedDrawerData<TData, TConnectedComponent extends Component> = TData extends DrawerDataNotProvided ? InferDrawerData<TConnectedComponent> : TData;
|
|
9
|
+
declare function setDefaultDrawerProps(props: Partial<TamanDrawerProps>): void;
|
|
10
|
+
declare function useTamanDrawer<TData = DrawerDataNotProvided, TConnectedComponent extends Component = Component>(options?: DrawerApiOptions<TConnectedComponent>): readonly [import("vue").DefineSetupFnComponent<TamanDrawerProps, {}, {}, TamanDrawerProps & {}, import("vue").PublicProps>, ExtendedDrawerApi<ResolvedDrawerData<TData, TConnectedComponent>>];
|
|
11
|
+
declare function createTamanDrawer<TData = unknown>(): <TConnectedComponent extends Component = Component>(options?: DrawerApiOptions<TConnectedComponent>) => readonly [import("vue").DefineSetupFnComponent<TamanDrawerProps, {}, {}, TamanDrawerProps & {}, import("vue").PublicProps>, ExtendedDrawerApi<ResolvedDrawerData<TData, TConnectedComponent>>];
|
|
12
|
+
//#endregion
|
|
13
|
+
export { createTamanDrawer, setDefaultDrawerProps, useTamanDrawer };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import _sfc_main from "./drawer.mjs";
|
|
2
|
+
import { DrawerApi } from "./drawer.api.mjs";
|
|
3
|
+
import { defineComponent, h, inject, markRaw, nextTick, onBeforeUnmount, provide, ref, shallowReactive } from "vue";
|
|
4
|
+
import { useSelector } from "@vinicunca/taman-core/store";
|
|
5
|
+
import { usePreferences } from "@vinicunca/taman-core/preferences";
|
|
6
|
+
//#region src/popup/drawer/use-taman-drawer.ts
|
|
7
|
+
const TAMAN_DRAWER_INJECT_KEY = Symbol("TAMAN_DRAWER_INJECT");
|
|
8
|
+
const { globalEscapeShortcutKey } = usePreferences();
|
|
9
|
+
/**
|
|
10
|
+
* Default configuration
|
|
11
|
+
*/
|
|
12
|
+
const DEFAULT_DRAWER_PROPS = {};
|
|
13
|
+
function setDefaultDrawerProps(props) {
|
|
14
|
+
Object.assign(DEFAULT_DRAWER_PROPS, props);
|
|
15
|
+
}
|
|
16
|
+
function useTamanDrawer(options = {}) {
|
|
17
|
+
const defaultOptions = {
|
|
18
|
+
closeOnPressEscape: globalEscapeShortcutKey.value,
|
|
19
|
+
...options
|
|
20
|
+
};
|
|
21
|
+
const { connectedComponent } = options;
|
|
22
|
+
if (connectedComponent) {
|
|
23
|
+
const extendedApi = shallowReactive({});
|
|
24
|
+
const isDrawerReady = ref(true);
|
|
25
|
+
return [defineComponent((props, { attrs, slots }) => {
|
|
26
|
+
function rebindApi(api) {
|
|
27
|
+
Object.setPrototypeOf(extendedApi, markRaw(api));
|
|
28
|
+
}
|
|
29
|
+
provide(TAMAN_DRAWER_INJECT_KEY, {
|
|
30
|
+
extendApi: rebindApi,
|
|
31
|
+
consumed: false,
|
|
32
|
+
options: defaultOptions,
|
|
33
|
+
async reCreateDrawer() {
|
|
34
|
+
isDrawerReady.value = false;
|
|
35
|
+
await nextTick();
|
|
36
|
+
isDrawerReady.value = true;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
checkProps(extendedApi, {
|
|
40
|
+
...props,
|
|
41
|
+
...attrs,
|
|
42
|
+
...slots
|
|
43
|
+
});
|
|
44
|
+
return () => h(isDrawerReady.value ? connectedComponent : "div", {
|
|
45
|
+
...props,
|
|
46
|
+
...attrs
|
|
47
|
+
}, slots);
|
|
48
|
+
}, {
|
|
49
|
+
name: "TamanParentDrawer",
|
|
50
|
+
inheritAttrs: false
|
|
51
|
+
}), extendedApi];
|
|
52
|
+
}
|
|
53
|
+
const injectData = inject(TAMAN_DRAWER_INJECT_KEY, {});
|
|
54
|
+
const isConsumed = injectData.consumed;
|
|
55
|
+
const effectiveOptions = isConsumed ? {} : injectData.options;
|
|
56
|
+
if (!isConsumed && injectData.consumed !== void 0) injectData.consumed = true;
|
|
57
|
+
onBeforeUnmount(() => {
|
|
58
|
+
if (!isConsumed && injectData.consumed !== void 0) injectData.consumed = false;
|
|
59
|
+
});
|
|
60
|
+
const mergedOptions = {
|
|
61
|
+
...DEFAULT_DRAWER_PROPS,
|
|
62
|
+
...effectiveOptions,
|
|
63
|
+
...defaultOptions
|
|
64
|
+
};
|
|
65
|
+
mergedOptions.onOpenChange = (isOpen) => {
|
|
66
|
+
options.onOpenChange?.(isOpen);
|
|
67
|
+
if (!isConsumed) injectData.options?.onOpenChange?.(isOpen);
|
|
68
|
+
};
|
|
69
|
+
const onClosed = mergedOptions.onClosed;
|
|
70
|
+
mergedOptions.onClosed = () => {
|
|
71
|
+
onClosed?.();
|
|
72
|
+
if (mergedOptions.destroyOnClose && !isConsumed) {
|
|
73
|
+
if (injectData.consumed !== void 0) injectData.consumed = false;
|
|
74
|
+
injectData.reCreateDrawer?.();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const api = new DrawerApi(mergedOptions);
|
|
78
|
+
const extendedApi = api;
|
|
79
|
+
extendedApi.useStore = (selector) => {
|
|
80
|
+
return useSelector(api.store, selector);
|
|
81
|
+
};
|
|
82
|
+
const Drawer = defineComponent((props, { attrs, slots }) => {
|
|
83
|
+
return () => h(_sfc_main, {
|
|
84
|
+
...props,
|
|
85
|
+
...attrs,
|
|
86
|
+
drawerApi: extendedApi
|
|
87
|
+
}, slots);
|
|
88
|
+
}, {
|
|
89
|
+
name: "TamanDrawer",
|
|
90
|
+
inheritAttrs: false
|
|
91
|
+
});
|
|
92
|
+
injectData.extendApi?.(extendedApi);
|
|
93
|
+
return [Drawer, extendedApi];
|
|
94
|
+
}
|
|
95
|
+
function createTamanDrawer() {
|
|
96
|
+
return function useTypedTamanDrawer(options = {}) {
|
|
97
|
+
return useTamanDrawer(options);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
async function checkProps(api, attrs) {
|
|
101
|
+
if (!attrs || Object.keys(attrs).length === 0) return;
|
|
102
|
+
await nextTick();
|
|
103
|
+
const state = api?.store?.state;
|
|
104
|
+
if (!state) return;
|
|
105
|
+
const stateKeys = new Set(Object.keys(state));
|
|
106
|
+
for (const attr of Object.keys(attrs)) if (stateKeys.has(attr) && !["class"].includes(attr)) console.warn(`[Taman Drawer]: When 'connectedComponent' exists, do not set props or slots '${attr}', which will increase complexity. If you need to modify the props of Drawer, please use useTamanDrawer or api.`);
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { createTamanDrawer, setDefaultDrawerProps, useTamanDrawer };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AlertBeforeCloseScope, AlertPromptProps, IconType, TamanAlertProps, useAlertContext } from "./alert/alert.js";
|
|
2
|
+
import { clearAllAlerts, tamanAlert, tamanConfirm, tamanPrompt } from "./alert/alert-builder.js";
|
|
3
|
+
import _default from "./alert/alert.vue.js";
|
|
4
|
+
import "./alert/index.js";
|
|
5
|
+
import { DialogApiOptions, DialogProps, DialogState, ExtendedDialogApi, InferDialogData } from "./dialog/dialog.types.js";
|
|
6
|
+
import _default$1 from "./dialog/dialog.vue.js";
|
|
7
|
+
import { createTamanDialog, setDefaultDialogProps, useTamanDialog } from "./dialog/use-taman-dialog.js";
|
|
8
|
+
import "./dialog/index.js";
|
|
9
|
+
import { CloseIconPlacement, DrawerApiOptions, DrawerPlacement, DrawerState, ExtendedDrawerApi, InferDrawerData, TamanDrawerProps } from "./drawer/drawer.types.js";
|
|
10
|
+
import _default$2 from "./drawer/drawer.vue.js";
|
|
11
|
+
import { createTamanDrawer, setDefaultDrawerProps, useTamanDrawer } from "./drawer/use-taman-drawer.js";
|
|
12
|
+
import "./drawer/index.js";
|
|
13
|
+
export { _default as Alert, type AlertBeforeCloseScope, type AlertPromptProps, type CloseIconPlacement, type DialogApiOptions, type DialogProps, type DialogState, type DrawerApiOptions, type DrawerPlacement, type DrawerState, type ExtendedDialogApi, type ExtendedDrawerApi, type IconType, type InferDialogData, type InferDrawerData, type TamanAlertProps, _default$1 as TamanDialog, _default$2 as TamanDrawer, type TamanDrawerProps, clearAllAlerts, createTamanDialog, createTamanDrawer, setDefaultDialogProps, setDefaultDrawerProps, tamanAlert, tamanConfirm, tamanPrompt, useAlertContext, useTamanDialog, useTamanDrawer };
|