@privyid/persona 0.3.0 → 0.4.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/dist/components/camera/Camera.vue +366 -0
- package/dist/components/camera/Camera.vue.d.ts +92 -0
- package/dist/components/camera/adapter/adapter.d.ts +41 -0
- package/dist/components/camera/adapter/adapter.mjs +3 -0
- package/dist/components/camera/adapter/capture.d.ts +5 -0
- package/dist/components/camera/adapter/capture.mjs +12 -0
- package/dist/components/camera/adapter/liveness.d.ts +5 -0
- package/dist/components/camera/adapter/liveness.mjs +46 -0
- package/dist/components/camera/adapter/qr-code.d.ts +2 -0
- package/dist/components/camera/adapter/qr-code.mjs +19 -0
- package/dist/components/camera/assets/shutter.wav +0 -0
- package/dist/components/camera/utils/motion.d.ts +29 -0
- package/dist/components/camera/utils/motion.mjs +88 -0
- package/dist/components/camera/utils/take-picture.d.ts +1 -0
- package/dist/components/camera/utils/take-picture.mjs +12 -0
- package/dist/components/collapse/Collapse.vue +88 -0
- package/dist/components/collapse/Collapse.vue.d.ts +29 -0
- package/dist/components/contextual-bar/ContextualBar.vue +292 -0
- package/dist/components/contextual-bar/ContextualBar.vue.d.ts +77 -0
- package/dist/components/contextual-bar/assets/images/img-background-contextualbar.svg +14 -0
- package/dist/components/contextual-bar/assets/images/img-bg-contextualbar.svg +19 -0
- package/dist/components/cropper/Cropper.vue +418 -0
- package/dist/components/cropper/Cropper.vue.d.ts +148 -0
- package/dist/components/cropper/assets/ps-neutral.png +0 -0
- package/dist/components/cropper/assets/sample-1.jpg +0 -0
- package/dist/components/cropper/utils/crop-image.d.ts +44 -0
- package/dist/components/cropper/utils/crop-image.mjs +43 -0
- package/dist/components/cropper/utils/use-pinch.d.ts +8 -0
- package/dist/components/cropper/utils/use-pinch.mjs +42 -0
- package/dist/components/cropper/utils/use-ratio.d.ts +9 -0
- package/dist/components/cropper/utils/use-ratio.mjs +24 -0
- package/dist/components/dialog/Dialog.vue +2 -0
- package/dist/components/dialog/DialogFooter.vue +4 -2
- package/dist/components/dialog/use-dialog.d.ts +3 -0
- package/dist/components/dropdown/Dropdown.vue.d.ts +2 -2
- package/dist/components/dropzone/Dropzone.vue +166 -0
- package/dist/components/dropzone/Dropzone.vue.d.ts +68 -0
- package/dist/components/dropzone/utils/accept.d.ts +1 -0
- package/dist/components/dropzone/utils/accept.mjs +17 -0
- package/dist/components/input/Input.vue +1 -1
- package/dist/components/modal/Modal.vue +62 -2
- package/dist/components/modal/Modal.vue.d.ts +21 -0
- package/dist/components/nav/Nav.vue +7 -1
- package/dist/components/nav/Nav.vue.d.ts +2 -2
- package/dist/components/nav/NavForm.vue +19 -0
- package/dist/components/nav/NavItem.vue +10 -0
- package/dist/components/nav/NavItemDropdown.vue +5 -1
- package/dist/components/nav/NavItemDropdown.vue.d.ts +9 -0
- package/dist/components/navbar/Navbar.vue +143 -0
- package/dist/components/navbar/Navbar.vue.d.ts +56 -0
- package/dist/components/navbar/NavbarBrand.vue +33 -0
- package/dist/components/navbar/NavbarBrand.vue.d.ts +14 -0
- package/dist/components/navbar/NavbarNav.vue +113 -0
- package/dist/components/navbar/NavbarNav.vue.d.ts +18 -0
- package/dist/components/navbar/NavbarToggle.vue +75 -0
- package/dist/components/navbar/NavbarToggle.vue.d.ts +6 -0
- package/dist/components/navbar/use-navbar.d.ts +10 -0
- package/dist/components/navbar/use-navbar.mjs +1 -0
- package/dist/components/navbar-menu/NavbarNavMenu.vue +62 -0
- package/dist/components/navbar-menu/NavbarNavMenu.vue.d.ts +15 -0
- package/dist/components/progress/Progress.vue +200 -0
- package/dist/components/progress/Progress.vue.d.ts +42 -0
- package/dist/components/progress/ProgressItem.vue +50 -0
- package/dist/components/progress/ProgressItem.vue.d.ts +25 -0
- package/dist/components/select/Select.vue.d.ts +1 -1
- package/dist/components/sidebar/SidebarNav.vue +4 -0
- package/dist/components/signature-draw/SignatureDrawDesktop.vue +2 -2
- package/dist/components/signature-draw/utils/canvas.d.ts +7 -1
- package/dist/components/signature-draw/utils/canvas.mjs +8 -2
- package/dist/components/signature-draw/utils/use-draw.mjs +6 -5
- package/dist/components/signature-text/SignatureText.vue.d.ts +1 -1
- package/dist/components/signature-text/utils/formatter.mjs +1 -1
- package/dist/components/spread/Spread.vue +55 -0
- package/dist/components/spread/Spread.vue.d.ts +14 -0
- package/dist/components/steps/Step.vue +55 -0
- package/dist/components/steps/Step.vue.d.ts +32 -0
- package/dist/components/steps/StepSlider.vue +39 -0
- package/dist/components/steps/StepSlider.vue.d.ts +25 -0
- package/dist/components/steps/Steps.vue +110 -0
- package/dist/components/steps/Steps.vue.d.ts +56 -0
- package/dist/components/steps/use-steps.d.ts +25 -0
- package/dist/components/steps/use-steps.mjs +52 -0
- package/dist/components/steps/utils/hook.d.ts +4 -0
- package/dist/components/steps/utils/hook.mjs +16 -0
- package/dist/components/subheading/Subheading.vue +2 -2
- package/dist/components/tabs/TabContent.vue +2 -2
- package/dist/components/tabs/Tabs.vue +4 -5
- package/dist/components/tabs/Tabs.vue.d.ts +1 -1
- package/dist/components/textarea/Textarea.vue.d.ts +1 -1
- package/dist/components/utils/base64.d.ts +8 -0
- package/dist/components/utils/base64.mjs +29 -0
- package/dist/components/utils/color.d.ts +6 -1
- package/dist/components/utils/color.mjs +4 -0
- package/dist/components/utils/vnode.d.ts +14 -1
- package/dist/components/utils/vnode.mjs +5 -2
- package/dist/components/wizard/Wizard.vue +85 -0
- package/dist/components/wizard/Wizard.vue.d.ts +72 -0
- package/dist/components/wizard/WizardBody.vue +50 -0
- package/dist/components/wizard/WizardBody.vue.d.ts +23 -0
- package/dist/components/wizard/WizardHeader.vue +38 -0
- package/dist/components/wizard/WizardHeader.vue.d.ts +16 -0
- package/dist/components/wizard/WizardStep.vue +20 -0
- package/dist/components/wizard/WizardStep.vue.d.ts +34 -0
- package/dist/core/index.cjs +1 -75
- package/dist/core/index.d.ts +6 -1
- package/dist/core/index.mjs +15 -1
- package/dist/module.d.ts +8 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +14 -2
- package/dist/types.d.ts +5 -1
- package/package.json +11 -7
- package/dist/components/dialog/index.d.ts +0 -6
- package/dist/components/dialog/index.mjs +0 -5
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export const MOTION_THRESHOLD = 40;
|
|
2
|
+
export const MOTION_FPS = 15;
|
|
3
|
+
export const MOTION_AREA_SIZE = 160;
|
|
4
|
+
export function takeSample(canvas, video) {
|
|
5
|
+
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
6
|
+
context.drawImage(
|
|
7
|
+
video,
|
|
8
|
+
video.videoWidth / 2 - MOTION_AREA_SIZE,
|
|
9
|
+
video.videoHeight / 2 - MOTION_AREA_SIZE,
|
|
10
|
+
MOTION_AREA_SIZE,
|
|
11
|
+
MOTION_AREA_SIZE,
|
|
12
|
+
0,
|
|
13
|
+
0,
|
|
14
|
+
MOTION_AREA_SIZE,
|
|
15
|
+
MOTION_AREA_SIZE
|
|
16
|
+
);
|
|
17
|
+
return context.getImageData(0, 0, canvas.width, canvas.height);
|
|
18
|
+
}
|
|
19
|
+
export function createTemplate(imageData) {
|
|
20
|
+
const centerX = imageData.width / 2;
|
|
21
|
+
const centerY = imageData.height / 2;
|
|
22
|
+
const width = imageData.width / 4;
|
|
23
|
+
const height = imageData.height / 4;
|
|
24
|
+
const xPos = centerX - width / 2;
|
|
25
|
+
const yPos = centerY - height / 2;
|
|
26
|
+
const buffer = new Uint8ClampedArray(width * height);
|
|
27
|
+
const template = {
|
|
28
|
+
centerX,
|
|
29
|
+
centerY,
|
|
30
|
+
width,
|
|
31
|
+
height,
|
|
32
|
+
xPos,
|
|
33
|
+
yPos,
|
|
34
|
+
buffer
|
|
35
|
+
};
|
|
36
|
+
const p = imageData.data;
|
|
37
|
+
let counter = 0;
|
|
38
|
+
for (let y = template.yPos; y < template.yPos + template.height; y++) {
|
|
39
|
+
let bufferIndex = y * imageData.width * 4 + template.xPos * 4 + 1;
|
|
40
|
+
for (let x = template.xPos; x < template.xPos + template.width; x++) {
|
|
41
|
+
template.buffer[counter++] = p[bufferIndex];
|
|
42
|
+
bufferIndex += 4;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return template;
|
|
46
|
+
}
|
|
47
|
+
export function motionDetection(imageData, template) {
|
|
48
|
+
let bestHitX = 0;
|
|
49
|
+
let bestHitY = 0;
|
|
50
|
+
let maxCorr = 0;
|
|
51
|
+
const searchWidth = imageData.width / 4;
|
|
52
|
+
const searchHeight = imageData.height / 4;
|
|
53
|
+
const p = imageData.data;
|
|
54
|
+
for (let y = template.centerY - searchHeight; y <= template.centerY + searchHeight - template.height; y++) {
|
|
55
|
+
for (let x = template.centerX - searchWidth; x <= template.centerX + searchWidth - template.width; x++) {
|
|
56
|
+
let nominator = 0;
|
|
57
|
+
let denominator = 0;
|
|
58
|
+
let templateIndex = 0;
|
|
59
|
+
for (let ty = 0; ty < template.height; ty++) {
|
|
60
|
+
let bufferIndex = x * 4 + 1 + (y + ty) * imageData.width * 4;
|
|
61
|
+
for (let tx = 0; tx < template.width; tx++) {
|
|
62
|
+
const imagepixel = p[bufferIndex];
|
|
63
|
+
nominator += template.buffer[templateIndex++] * imagepixel;
|
|
64
|
+
denominator += imagepixel * imagepixel;
|
|
65
|
+
bufferIndex += 4;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let ncc = 0;
|
|
69
|
+
if (denominator > 0)
|
|
70
|
+
ncc = nominator * nominator / denominator;
|
|
71
|
+
if (ncc > maxCorr) {
|
|
72
|
+
maxCorr = ncc;
|
|
73
|
+
bestHitX = x;
|
|
74
|
+
bestHitY = y;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const distX = bestHitX - template.xPos;
|
|
79
|
+
const distY = bestHitY - template.yPos;
|
|
80
|
+
const movementDiff = Math.sqrt(distX * distX + distY * distY);
|
|
81
|
+
const maxDistX = searchWidth - template.width / 2;
|
|
82
|
+
const maxDistY = searchHeight - template.height / 2;
|
|
83
|
+
const maximumMovement = Math.sqrt(maxDistX * maxDistX + maxDistY * maxDistY);
|
|
84
|
+
let movementPercentage = movementDiff / maximumMovement * 100;
|
|
85
|
+
if (movementPercentage > 100)
|
|
86
|
+
movementPercentage = 100;
|
|
87
|
+
return movementPercentage;
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function takePicture(video: HTMLVideoElement, mirror?: boolean): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function takePicture(video, mirror = false) {
|
|
2
|
+
const canvas = document.createElement("canvas");
|
|
3
|
+
const context = canvas.getContext("2d");
|
|
4
|
+
canvas.width = video.videoWidth;
|
|
5
|
+
canvas.height = video.videoHeight;
|
|
6
|
+
if (mirror) {
|
|
7
|
+
context.scale(-1, 1);
|
|
8
|
+
context.drawImage(video, 0, 0, canvas.width * -1, canvas.height);
|
|
9
|
+
} else
|
|
10
|
+
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
11
|
+
return canvas.toDataURL("image/jpeg");
|
|
12
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<transition
|
|
3
|
+
name="fade"
|
|
4
|
+
mode="out-in">
|
|
5
|
+
<div
|
|
6
|
+
v-show="model || isToggleable"
|
|
7
|
+
data-testid="collapse"
|
|
8
|
+
class="collapse"
|
|
9
|
+
:class="classNames">
|
|
10
|
+
<slot />
|
|
11
|
+
</div>
|
|
12
|
+
</transition>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import {
|
|
17
|
+
computed,
|
|
18
|
+
defineComponent,
|
|
19
|
+
inject
|
|
20
|
+
} from "vue-demi";
|
|
21
|
+
import { useVModel } from "../input/use-input";
|
|
22
|
+
import { NAVBAR_SETTINGS } from "../navbar/use-navbar";
|
|
23
|
+
import { useMediaQuery } from "@vueuse/core";
|
|
24
|
+
export default defineComponent({
|
|
25
|
+
props: {
|
|
26
|
+
modelValue: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false
|
|
29
|
+
},
|
|
30
|
+
isNav: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
models: {
|
|
36
|
+
prop: "modelValue",
|
|
37
|
+
event: "update:modelValue"
|
|
38
|
+
},
|
|
39
|
+
emits: ["update:modelValue"],
|
|
40
|
+
setup(props) {
|
|
41
|
+
const model = useVModel(props);
|
|
42
|
+
const context = inject(NAVBAR_SETTINGS, void 0, true);
|
|
43
|
+
const lg = useMediaQuery("(min-width: 1024px)");
|
|
44
|
+
const md = useMediaQuery("(min-width: 768px)");
|
|
45
|
+
const sm = useMediaQuery("(min-width: 640px)");
|
|
46
|
+
const isToggleable = computed(() => {
|
|
47
|
+
if (context?.toggleable?.value === "lg")
|
|
48
|
+
return lg.value;
|
|
49
|
+
if (context?.toggleable?.value === "md")
|
|
50
|
+
return md.value;
|
|
51
|
+
if (context?.toggleable?.value === "sm")
|
|
52
|
+
return sm.value;
|
|
53
|
+
return model.value;
|
|
54
|
+
});
|
|
55
|
+
const classNames = computed(() => {
|
|
56
|
+
const result = [""];
|
|
57
|
+
if (model.value)
|
|
58
|
+
result.push("collapse--show");
|
|
59
|
+
if (props.isNav)
|
|
60
|
+
result.push("navbar--collapse");
|
|
61
|
+
return result;
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
model,
|
|
65
|
+
classNames,
|
|
66
|
+
isToggleable
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<style lang="postcss">
|
|
73
|
+
.collapse {
|
|
74
|
+
&&--show {
|
|
75
|
+
@apply block;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&:not(.collapse--show) {
|
|
79
|
+
@apply hidden;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.navbar {
|
|
84
|
+
&--collapse {
|
|
85
|
+
@apply basis-full flex-grow items-center;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare const _default: import("vue-demi").DefineComponent<{
|
|
2
|
+
modelValue: {
|
|
3
|
+
type: BooleanConstructor;
|
|
4
|
+
default: boolean;
|
|
5
|
+
};
|
|
6
|
+
isNav: {
|
|
7
|
+
type: BooleanConstructor;
|
|
8
|
+
default: boolean;
|
|
9
|
+
};
|
|
10
|
+
}, {
|
|
11
|
+
model: import("vue-demi").Ref<boolean>;
|
|
12
|
+
classNames: import("vue-demi").ComputedRef<string[]>;
|
|
13
|
+
isToggleable: import("vue-demi").ComputedRef<boolean>;
|
|
14
|
+
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
15
|
+
modelValue: {
|
|
16
|
+
type: BooleanConstructor;
|
|
17
|
+
default: boolean;
|
|
18
|
+
};
|
|
19
|
+
isNav: {
|
|
20
|
+
type: BooleanConstructor;
|
|
21
|
+
default: boolean;
|
|
22
|
+
};
|
|
23
|
+
}>> & {
|
|
24
|
+
"onUpdate:modelValue"?: (...args: any[]) => any;
|
|
25
|
+
}, {
|
|
26
|
+
modelValue: boolean;
|
|
27
|
+
isNav: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-show="model"
|
|
4
|
+
ref="contextualbar"
|
|
5
|
+
data-testid="contextual-bar"
|
|
6
|
+
class="contextual-bar"
|
|
7
|
+
:class="classNames">
|
|
8
|
+
<div
|
|
9
|
+
data-testid="contextual-bar-wrapper"
|
|
10
|
+
:class="[{ 'contextual-bar__wrapper--with-message' : (message || $slots.message), 'contextual-bar__wrapper--with-action' : $slots.action } ,'contextual-bar__wrapper']">
|
|
11
|
+
<span
|
|
12
|
+
v-if="$slots.icon"
|
|
13
|
+
data-testid="contextual-bar-icon"
|
|
14
|
+
class="contextual-bar__icon">
|
|
15
|
+
<slot name="icon" />
|
|
16
|
+
</span>
|
|
17
|
+
<div class="contextual-bar__content">
|
|
18
|
+
<div
|
|
19
|
+
v-if="title || $slots.title"
|
|
20
|
+
data-testid="contextual-bar-title"
|
|
21
|
+
class="contextual-bar__content__title">
|
|
22
|
+
<slot name="title">
|
|
23
|
+
<p-subheading v-if="message">
|
|
24
|
+
{{ title }}
|
|
25
|
+
</p-subheading>
|
|
26
|
+
<template v-else>
|
|
27
|
+
{{ title }}
|
|
28
|
+
</template>
|
|
29
|
+
</slot>
|
|
30
|
+
</div>
|
|
31
|
+
<div
|
|
32
|
+
v-if="message || $slots.message"
|
|
33
|
+
data-testid="contextual-bar-message"
|
|
34
|
+
class="contextual-bar__content__message">
|
|
35
|
+
<p-caption>
|
|
36
|
+
<slot name="message">
|
|
37
|
+
{{ message }}
|
|
38
|
+
</slot>
|
|
39
|
+
</p-caption>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
<div
|
|
43
|
+
v-if="$slots.action"
|
|
44
|
+
data-testid="contextual-bar-action"
|
|
45
|
+
class="contextual-bar__action">
|
|
46
|
+
<slot name="action" />
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<div
|
|
50
|
+
v-if="dismissable"
|
|
51
|
+
data-testid="contextual-bar-close"
|
|
52
|
+
class="contextual-bar__close"
|
|
53
|
+
@click="close">
|
|
54
|
+
<IconClose />
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
<script>
|
|
60
|
+
import {
|
|
61
|
+
computed,
|
|
62
|
+
defineComponent,
|
|
63
|
+
onMounted,
|
|
64
|
+
watch
|
|
65
|
+
} from "vue-demi";
|
|
66
|
+
import { useVModel } from "../input/use-input";
|
|
67
|
+
import pCaption from "../caption/Caption.vue";
|
|
68
|
+
import pSubheading from "../subheading/Subheading.vue";
|
|
69
|
+
import IconClose from "@carbon/icons-vue/lib/close/20";
|
|
70
|
+
import {
|
|
71
|
+
templateRef,
|
|
72
|
+
until,
|
|
73
|
+
useElementBounding
|
|
74
|
+
} from "@vueuse/core";
|
|
75
|
+
export default defineComponent({
|
|
76
|
+
components: {
|
|
77
|
+
IconClose,
|
|
78
|
+
pCaption,
|
|
79
|
+
pSubheading
|
|
80
|
+
},
|
|
81
|
+
props: {
|
|
82
|
+
variant: {
|
|
83
|
+
type: String,
|
|
84
|
+
default: "light"
|
|
85
|
+
},
|
|
86
|
+
backgroundUrl: {
|
|
87
|
+
type: String,
|
|
88
|
+
default: void 0
|
|
89
|
+
},
|
|
90
|
+
dismissable: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
default: true
|
|
93
|
+
},
|
|
94
|
+
title: {
|
|
95
|
+
type: String,
|
|
96
|
+
default: void 0
|
|
97
|
+
},
|
|
98
|
+
message: {
|
|
99
|
+
type: String,
|
|
100
|
+
default: void 0
|
|
101
|
+
},
|
|
102
|
+
align: {
|
|
103
|
+
type: String,
|
|
104
|
+
default: "left"
|
|
105
|
+
},
|
|
106
|
+
modelValue: {
|
|
107
|
+
type: Boolean,
|
|
108
|
+
default: true
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
models: {
|
|
112
|
+
prop: "modelValue",
|
|
113
|
+
event: "update:modelValue"
|
|
114
|
+
},
|
|
115
|
+
emits: ["update:modelValue", "close"],
|
|
116
|
+
setup(props, { emit }) {
|
|
117
|
+
const model = useVModel(props);
|
|
118
|
+
const contextualbar = templateRef("contextualbar");
|
|
119
|
+
const { height } = useElementBounding(contextualbar);
|
|
120
|
+
async function show() {
|
|
121
|
+
await until(height).changed();
|
|
122
|
+
document.body?.style.setProperty("transform", `translateY(${height.value}px)`);
|
|
123
|
+
document.body?.style.setProperty("transition", "transform 0.15s ease-in-out");
|
|
124
|
+
contextualbar.value?.style.setProperty("transform", `translateY(-${height.value}px)`);
|
|
125
|
+
contextualbar.value?.style.setProperty("transition", "transform 0.15s ease-in-out");
|
|
126
|
+
}
|
|
127
|
+
async function hide() {
|
|
128
|
+
contextualbar.value?.style.setProperty("transform", "translateY(-0px)");
|
|
129
|
+
contextualbar.value?.style.setProperty("transition", "transform 0.15s ease-in-out");
|
|
130
|
+
document.body?.style.removeProperty("transform");
|
|
131
|
+
}
|
|
132
|
+
function close(event) {
|
|
133
|
+
emit("close", event);
|
|
134
|
+
if (!event.defaultPrevented)
|
|
135
|
+
model.value = false;
|
|
136
|
+
}
|
|
137
|
+
const classNames = computed(() => {
|
|
138
|
+
const result = [""];
|
|
139
|
+
if (props.variant)
|
|
140
|
+
result.push(`contextual-bar--${props.variant}`);
|
|
141
|
+
if (props.align)
|
|
142
|
+
result.push(`contextual-bar--align-${props.align}`);
|
|
143
|
+
if (props.backgroundUrl)
|
|
144
|
+
result.push("contextual-bar--background-image");
|
|
145
|
+
return result;
|
|
146
|
+
});
|
|
147
|
+
onMounted(() => {
|
|
148
|
+
if (props.backgroundUrl)
|
|
149
|
+
contextualbar.value?.style.setProperty("background-image", `url('${props.backgroundUrl}')`);
|
|
150
|
+
if (model.value)
|
|
151
|
+
show();
|
|
152
|
+
else
|
|
153
|
+
hide();
|
|
154
|
+
});
|
|
155
|
+
watch(model, (value) => {
|
|
156
|
+
if (value)
|
|
157
|
+
show();
|
|
158
|
+
else
|
|
159
|
+
hide();
|
|
160
|
+
});
|
|
161
|
+
return {
|
|
162
|
+
model,
|
|
163
|
+
classNames,
|
|
164
|
+
close
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
</script>
|
|
169
|
+
|
|
170
|
+
<style lang="postcss">
|
|
171
|
+
.contextual-bar {
|
|
172
|
+
@apply fixed z-[1030] top-0 left-0 p-6 w-full;
|
|
173
|
+
|
|
174
|
+
&--background-image {
|
|
175
|
+
@apply bg-no-repeat bg-cover bg-[top_center];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
&__wrapper {
|
|
179
|
+
@apply px-24 items-center flex mr-9;
|
|
180
|
+
|
|
181
|
+
&--with-message {
|
|
182
|
+
@apply items-start;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&--with-action {
|
|
186
|
+
@apply items-center;
|
|
187
|
+
|
|
188
|
+
&.contextual-bar__wrapper--with-message {
|
|
189
|
+
.contextual-bar__icon {
|
|
190
|
+
@apply self-start;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
&&--align-left {
|
|
197
|
+
.contextual-bar__wrapper {
|
|
198
|
+
@apply justify-start text-left;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
&&--align-center {
|
|
203
|
+
.contextual-bar__wrapper {
|
|
204
|
+
@apply justify-center text-center;
|
|
205
|
+
|
|
206
|
+
&--with-action {
|
|
207
|
+
.contextual-bar__content {
|
|
208
|
+
@apply text-left;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.contextual-bar__action {
|
|
214
|
+
@apply ml-0;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
&&--align-right {
|
|
219
|
+
.contextual-bar__wrapper {
|
|
220
|
+
@apply justify-end text-right;
|
|
221
|
+
|
|
222
|
+
&--with-action {
|
|
223
|
+
.contextual-bar__content {
|
|
224
|
+
@apply text-left;
|
|
225
|
+
}
|
|
226
|
+
.contextual-bar__action {
|
|
227
|
+
@apply ml-0;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
&&--align-center,
|
|
234
|
+
&&--align-right {
|
|
235
|
+
.contextual-bar__wrapper {
|
|
236
|
+
&--with-action {
|
|
237
|
+
@apply gap-3;
|
|
238
|
+
|
|
239
|
+
.contextual-bar__icon {
|
|
240
|
+
@apply mr-0;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.contextual-bar__content {
|
|
246
|
+
@apply flex-grow-0;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
&__content {
|
|
251
|
+
@apply flex-grow;
|
|
252
|
+
|
|
253
|
+
&__title {
|
|
254
|
+
@apply text-base;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
&__action {
|
|
259
|
+
@apply flex flex-shrink-0 ml-auto gap-3;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
&__icon {
|
|
263
|
+
@apply relative mr-4 flex-shrink;
|
|
264
|
+
|
|
265
|
+
img {
|
|
266
|
+
@apply max-w-[20px] w-auto;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
&__close {
|
|
271
|
+
@apply absolute right-6 top-1/2 -translate-y-1/2 cursor-pointer text-black text-opacity-30 hover:text-opacity-50;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
&&--dark {
|
|
275
|
+
@apply bg-black text-white;
|
|
276
|
+
|
|
277
|
+
.contextual-bar__close {
|
|
278
|
+
@apply text-white text-opacity-40 hover:text-opacity-60;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
&&--light {
|
|
283
|
+
@apply bg-background-100 text-body-100;
|
|
284
|
+
|
|
285
|
+
.contextual-bar {
|
|
286
|
+
&__icon {
|
|
287
|
+
@apply text-primary-100;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
</style>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { PropType } from 'vue-demi';
|
|
2
|
+
declare type StyleVariant = 'light' | 'dark';
|
|
3
|
+
declare const _default: import("vue-demi").DefineComponent<{
|
|
4
|
+
variant: {
|
|
5
|
+
type: PropType<StyleVariant>;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
backgroundUrl: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
default: any;
|
|
11
|
+
};
|
|
12
|
+
dismissable: {
|
|
13
|
+
type: BooleanConstructor;
|
|
14
|
+
default: boolean;
|
|
15
|
+
};
|
|
16
|
+
title: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
default: any;
|
|
19
|
+
};
|
|
20
|
+
message: {
|
|
21
|
+
type: StringConstructor;
|
|
22
|
+
default: any;
|
|
23
|
+
};
|
|
24
|
+
align: {
|
|
25
|
+
type: PropType<AlignVariant>;
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
modelValue: {
|
|
29
|
+
type: BooleanConstructor;
|
|
30
|
+
default: boolean;
|
|
31
|
+
};
|
|
32
|
+
}, {
|
|
33
|
+
model: import("vue-demi").Ref<boolean>;
|
|
34
|
+
classNames: import("vue-demi").ComputedRef<string[]>;
|
|
35
|
+
close: (event: Event) => void;
|
|
36
|
+
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, ("close" | "update:modelValue")[], "close" | "update:modelValue", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
37
|
+
variant: {
|
|
38
|
+
type: PropType<StyleVariant>;
|
|
39
|
+
default: string;
|
|
40
|
+
};
|
|
41
|
+
backgroundUrl: {
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
default: any;
|
|
44
|
+
};
|
|
45
|
+
dismissable: {
|
|
46
|
+
type: BooleanConstructor;
|
|
47
|
+
default: boolean;
|
|
48
|
+
};
|
|
49
|
+
title: {
|
|
50
|
+
type: StringConstructor;
|
|
51
|
+
default: any;
|
|
52
|
+
};
|
|
53
|
+
message: {
|
|
54
|
+
type: StringConstructor;
|
|
55
|
+
default: any;
|
|
56
|
+
};
|
|
57
|
+
align: {
|
|
58
|
+
type: PropType<AlignVariant>;
|
|
59
|
+
default: string;
|
|
60
|
+
};
|
|
61
|
+
modelValue: {
|
|
62
|
+
type: BooleanConstructor;
|
|
63
|
+
default: boolean;
|
|
64
|
+
};
|
|
65
|
+
}>> & {
|
|
66
|
+
"onUpdate:modelValue"?: (...args: any[]) => any;
|
|
67
|
+
onClose?: (...args: any[]) => any;
|
|
68
|
+
}, {
|
|
69
|
+
variant: StyleVariant;
|
|
70
|
+
dismissable: boolean;
|
|
71
|
+
modelValue: boolean;
|
|
72
|
+
title: string;
|
|
73
|
+
message: string;
|
|
74
|
+
align: AlignVariant;
|
|
75
|
+
backgroundUrl: string;
|
|
76
|
+
}>;
|
|
77
|
+
export default _default;
|