@privyid/persona 0.20.0 → 0.21.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/accordion/Accordion.vue +118 -0
- package/dist/components/accordion/AccordionItem.vue +184 -0
- package/dist/components/accordion/index.d.ts +14 -0
- package/dist/components/accordion/index.mjs +10 -0
- package/dist/components/badge/Badge.vue.d.ts +1 -1
- package/dist/components/button/Button.vue +102 -65
- package/dist/components/calendar/Calendar.vue.d.ts +2 -2
- package/dist/components/calendar/adapter/adapter.mjs +1 -1
- package/dist/components/camera/Camera.vue.d.ts +4 -4
- package/dist/components/card/Card.vue.d.ts +1 -1
- package/dist/components/card/CardSection.vue.d.ts +1 -1
- package/dist/components/contextual-bar/ContextualBar.vue.d.ts +3 -3
- package/dist/components/datepicker/Datepicker.vue.d.ts +2 -2
- package/dist/components/dialog/index.d.ts +1 -1
- package/dist/components/dot/Dot.vue.d.ts +1 -1
- package/dist/components/dropdown/Dropdown.vue.d.ts +3 -3
- package/dist/components/dropdown-subitem/DropdownSubitem.vue.d.ts +1 -1
- package/dist/components/dropzone/Dropzone.vue.d.ts +2 -2
- package/dist/components/filterbar/pinned/PinnedDate.vue.d.ts +2 -2
- package/dist/components/form-group/FormGroup.vue +92 -65
- package/dist/components/global/store.d.ts +27 -0
- package/dist/components/global/store.mjs +31 -0
- package/dist/components/global/utils/queue.mjs +2 -0
- package/dist/components/input/utils/accept.d.ts +19 -19
- package/dist/components/input-file/InputFile.vue.d.ts +2 -2
- package/dist/components/input-password/InputPassword.vue.d.ts +1 -3
- package/dist/components/input-range/InputRange.vue.d.ts +1 -1
- package/dist/components/label/Label.vue.d.ts +2 -2
- package/dist/components/modal/Modal.vue +1 -1
- package/dist/components/modal/Modal.vue.d.ts +3 -3
- package/dist/components/modal/index.d.ts +1 -0
- package/dist/components/modal/index.mjs +0 -0
- package/dist/components/nav/NavItemDropdown.vue.d.ts +1 -1
- package/dist/components/pdf-text/PdfText.vue +6 -2
- package/dist/components/pdf-text/PdfText.vue.d.ts +3 -2
- package/dist/components/pdf-text/utils/text-to-image.d.ts +1 -1
- package/dist/components/pdf-text/utils/text-to-image.mjs +19 -17
- package/dist/components/pdf-viewer/PdfError.vue +12 -7
- package/dist/components/pdf-viewer/PdfError.vue.d.ts +3 -11
- package/dist/components/pdf-viewer/PdfNavigation.vue +5 -13
- package/dist/components/pdf-viewer/PdfNavigation.vue.d.ts +4 -4
- package/dist/components/pdf-viewer/PdfViewer.vue +42 -5
- package/dist/components/pdf-viewer/PdfViewer.vue.d.ts +4 -1
- package/dist/components/pdf-viewer/index.d.ts +8 -0
- package/dist/components/pdf-viewer/index.mjs +6 -1
- package/dist/components/pdf-viewer/utils/pdfjs.d.ts +8 -0
- package/dist/components/pdf-viewer/utils/pdfjs.mjs +40 -0
- package/dist/components/pdf-viewer/utils/use-viewer.d.ts +0 -2
- package/dist/components/pdf-viewer/utils/use-viewer.mjs +12 -18
- package/dist/components/progressbar/Progressbar.vue.d.ts +1 -1
- package/dist/components/select/Select.vue.d.ts +1 -1
- package/dist/components/sheet/Sheet.vue +231 -0
- package/dist/components/signature-draw/utils/canvas.d.ts +1 -1
- package/dist/components/signature-draw/utils/canvas.mjs +5 -3
- package/dist/components/signature-draw/utils/smooth-line.d.ts +1 -1
- package/dist/components/signature-draw/utils/smooth-line.mjs +6 -1
- package/dist/components/signature-draw/utils/straight-line.mjs +2 -0
- package/dist/components/signature-text/SignatureText.vue +10 -7
- package/dist/components/signature-text/SignatureText.vue.d.ts +2 -1
- package/dist/components/signature-text/utils/generate-text.d.ts +1 -1
- package/dist/components/signature-text/utils/generate-text.mjs +3 -8
- package/dist/components/steps/utils/hook.mjs +1 -0
- package/dist/components/table-flex/TableFlex.vue +36 -23
- package/dist/components/table-static/TableStatic.vue +47 -30
- package/dist/components/tabs/Tab.vue.d.ts +1 -1
- package/dist/components/tour/Tour.vue.d.ts +2 -4
- package/dist/components/tour/TourDialog.vue.d.ts +1 -1
- package/dist/components/tour/core/base.mjs +11 -0
- package/dist/components/tour/core/step/conditional.mjs +1 -0
- package/dist/components/tour/core/step/visit.mjs +1 -4
- package/dist/components/tour/core/step.mjs +1 -4
- package/dist/components/tour/core/tour.mjs +4 -0
- package/dist/components/utils/base64.mjs +3 -3
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.mjs +14 -3
- package/dist/module.d.mts +17 -0
- package/dist/module.d.ts +1 -1
- package/dist/module.json +1 -1
- package/dist/runtime/plugin.mjs +10 -3
- package/dist/types.d.mts +15 -0
- package/package.json +13 -13
- package/dist/components/button/Button.vue.d.ts +0 -74
- package/dist/components/form-group/FormGroup.vue.d.ts +0 -61
- package/dist/components/global/context.d.ts +0 -24
- package/dist/components/global/context.mjs +0 -18
|
@@ -15,7 +15,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
15
15
|
back: () => void;
|
|
16
16
|
reset: () => void;
|
|
17
17
|
canBack: import("vue-demi").ComputedRef<boolean>;
|
|
18
|
-
transition: import("vue-demi").Ref<"
|
|
18
|
+
transition: import("vue-demi").Ref<"none" | "slide-left" | "slide-right">;
|
|
19
19
|
handleOnClick: () => void;
|
|
20
20
|
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, "click"[], "click", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
21
21
|
text: {
|
|
@@ -77,14 +77,14 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
77
77
|
default: boolean;
|
|
78
78
|
};
|
|
79
79
|
}>> & {
|
|
80
|
+
onCancel?: ((...args: any[]) => any) | undefined;
|
|
80
81
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
81
82
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
82
|
-
onCancel?: ((...args: any[]) => any) | undefined;
|
|
83
83
|
}, {
|
|
84
84
|
modelValue: string | string[] | File | File[];
|
|
85
|
+
modelModifiers: ModelModifier;
|
|
85
86
|
disabled: boolean;
|
|
86
87
|
readonly: boolean;
|
|
87
|
-
modelModifiers: ModelModifier;
|
|
88
88
|
multiple: boolean | MultipleType;
|
|
89
89
|
maxlength: string | number;
|
|
90
90
|
accept: string;
|
|
@@ -58,10 +58,10 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
58
58
|
}>> & {
|
|
59
59
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
60
60
|
}, {
|
|
61
|
-
min: Date;
|
|
62
|
-
max: Date;
|
|
63
61
|
modelValue: Date;
|
|
64
62
|
mode: "date" | "month" | "year";
|
|
63
|
+
min: Date;
|
|
64
|
+
max: Date;
|
|
65
65
|
format: string;
|
|
66
66
|
}, {}>;
|
|
67
67
|
export default _default;
|
|
@@ -20,71 +20,86 @@
|
|
|
20
20
|
{{ caption }}</p-caption>
|
|
21
21
|
</label>
|
|
22
22
|
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
<div class="form-group__inputs">
|
|
24
|
+
<slot />
|
|
25
|
+
|
|
26
|
+
<transition
|
|
27
|
+
name="slide-up"
|
|
28
|
+
mode="out-in">
|
|
29
|
+
<p
|
|
30
|
+
v-if="error"
|
|
31
|
+
data-testid="form-group-error"
|
|
32
|
+
class="form-group__error">
|
|
33
|
+
<slot name="error-icon">
|
|
34
|
+
<IconInfo
|
|
35
|
+
v-if="errorIcon"
|
|
36
|
+
data-testid="form-group-error-icon" />
|
|
37
|
+
</slot>
|
|
38
|
+
{{ error }}
|
|
39
|
+
</p>
|
|
40
|
+
<p
|
|
41
|
+
v-else-if="description"
|
|
42
|
+
data-testid="form-group-description"
|
|
43
|
+
class="form-group__description">
|
|
44
|
+
{{ description }}
|
|
45
|
+
</p>
|
|
46
|
+
</transition>
|
|
47
|
+
</div>
|
|
41
48
|
</div>
|
|
42
49
|
</template>
|
|
43
50
|
|
|
44
|
-
<script>
|
|
45
|
-
import IconInfo from
|
|
46
|
-
import pCaption from
|
|
47
|
-
import { pTooltip } from
|
|
48
|
-
import { computed
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
type: Boolean,
|
|
55
|
-
default: false
|
|
56
|
-
},
|
|
57
|
-
label: {
|
|
58
|
-
type: String,
|
|
59
|
-
default: ""
|
|
60
|
-
},
|
|
61
|
-
caption: {
|
|
62
|
-
type: String,
|
|
63
|
-
default: ""
|
|
64
|
-
},
|
|
65
|
-
description: {
|
|
66
|
-
type: String,
|
|
67
|
-
default: ""
|
|
68
|
-
},
|
|
69
|
-
hint: {
|
|
70
|
-
type: String,
|
|
71
|
-
default: ""
|
|
72
|
-
},
|
|
73
|
-
error: {
|
|
74
|
-
type: String,
|
|
75
|
-
default: ""
|
|
76
|
-
}
|
|
51
|
+
<script lang="ts" setup>
|
|
52
|
+
import IconInfo from '@privyid/persona-icon/vue/information-circle-solid/20.vue'
|
|
53
|
+
import pCaption from '../caption/Caption.vue'
|
|
54
|
+
import { pTooltip as vPTooltip } from '../tooltip'
|
|
55
|
+
import { computed } from 'vue-demi'
|
|
56
|
+
|
|
57
|
+
const props = defineProps({
|
|
58
|
+
required: {
|
|
59
|
+
type : Boolean,
|
|
60
|
+
default: false,
|
|
77
61
|
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
62
|
+
label: {
|
|
63
|
+
type : String,
|
|
64
|
+
default: '',
|
|
65
|
+
},
|
|
66
|
+
caption: {
|
|
67
|
+
type : String,
|
|
68
|
+
default: '',
|
|
69
|
+
},
|
|
70
|
+
description: {
|
|
71
|
+
type : String,
|
|
72
|
+
default: '',
|
|
73
|
+
},
|
|
74
|
+
hint: {
|
|
75
|
+
type : String,
|
|
76
|
+
default: '',
|
|
77
|
+
},
|
|
78
|
+
error: {
|
|
79
|
+
type : String,
|
|
80
|
+
default: '',
|
|
81
|
+
},
|
|
82
|
+
horizontal: {
|
|
83
|
+
type : Boolean,
|
|
84
|
+
default: false,
|
|
85
|
+
},
|
|
86
|
+
errorIcon: {
|
|
87
|
+
type : Boolean,
|
|
88
|
+
default: false,
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
const classNames = computed(() => {
|
|
93
|
+
const result: string[] = []
|
|
94
|
+
|
|
95
|
+
if (props.error)
|
|
96
|
+
result.push('form-group--error', 'state--error')
|
|
97
|
+
|
|
98
|
+
if (props.horizontal)
|
|
99
|
+
result.push('form-group--horizontal')
|
|
100
|
+
|
|
101
|
+
return result
|
|
102
|
+
})
|
|
88
103
|
</script>
|
|
89
104
|
|
|
90
105
|
<style lang="postcss">
|
|
@@ -101,19 +116,31 @@ export default defineComponent({
|
|
|
101
116
|
}
|
|
102
117
|
}
|
|
103
118
|
|
|
104
|
-
& > &__description {
|
|
119
|
+
& > &__inputs > &__description {
|
|
105
120
|
@apply text-xs my-2 text-subtle;
|
|
106
121
|
@apply dark:text-dark-subtle;
|
|
107
122
|
}
|
|
108
123
|
|
|
109
|
-
& > &__error {
|
|
110
|
-
@apply text-xs text-danger;
|
|
124
|
+
& > &__inputs > &__error {
|
|
125
|
+
@apply text-xs text-danger flex gap-1 items-center;
|
|
111
126
|
@apply dark:text-dark-danger my-2;
|
|
112
127
|
}
|
|
113
128
|
|
|
114
|
-
&__hint {
|
|
129
|
+
& > &__label > &__hint {
|
|
115
130
|
@apply absolute right-0 text-info cursor-pointer focus:outline-none;
|
|
116
131
|
@apply dark:text-dark-info;
|
|
117
132
|
}
|
|
133
|
+
|
|
134
|
+
&&--horizontal {
|
|
135
|
+
@apply flex-row items-baseline;
|
|
136
|
+
|
|
137
|
+
& > .form-group__label {
|
|
138
|
+
@apply mb-0 mr-2 basis-1/3;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
& > .form-group__inputs {
|
|
142
|
+
@apply flex-grow;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
118
145
|
}
|
|
119
146
|
</style>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Ref } from 'vue-demi';
|
|
2
|
+
type Lang = 'id' | 'en';
|
|
3
|
+
/**
|
|
4
|
+
* Simple vuex-like-store for global configuration
|
|
5
|
+
*/
|
|
6
|
+
export interface State {
|
|
7
|
+
lang: Lang;
|
|
8
|
+
}
|
|
9
|
+
export declare function createStore(): Ref<State>;
|
|
10
|
+
export declare function setStore(state: Ref<State>): void;
|
|
11
|
+
export declare function initStore(): Ref<State>;
|
|
12
|
+
export declare function useStore(): Ref<State>;
|
|
13
|
+
export declare function setLang(lang: Lang): void;
|
|
14
|
+
export declare function getLang(): Lang;
|
|
15
|
+
/**
|
|
16
|
+
* Return reactive global lang setting
|
|
17
|
+
* @example
|
|
18
|
+
* const lang = useLang()
|
|
19
|
+
*
|
|
20
|
+
* // set lang
|
|
21
|
+
* lang.value = 'en'
|
|
22
|
+
*
|
|
23
|
+
* // get lang
|
|
24
|
+
* console.log(lang.value)
|
|
25
|
+
*/
|
|
26
|
+
export declare function useLang(): Ref<Lang>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
effectScope,
|
|
3
|
+
ref,
|
|
4
|
+
toRef
|
|
5
|
+
} from "vue-demi";
|
|
6
|
+
let globalState;
|
|
7
|
+
export function createStore() {
|
|
8
|
+
const scope = effectScope(true);
|
|
9
|
+
const state = scope.run(() => ref({ lang: "en" }));
|
|
10
|
+
return state;
|
|
11
|
+
}
|
|
12
|
+
export function setStore(state) {
|
|
13
|
+
globalState = state;
|
|
14
|
+
}
|
|
15
|
+
export function initStore() {
|
|
16
|
+
const store = createStore();
|
|
17
|
+
setStore(store);
|
|
18
|
+
return store;
|
|
19
|
+
}
|
|
20
|
+
export function useStore() {
|
|
21
|
+
return globalState;
|
|
22
|
+
}
|
|
23
|
+
export function setLang(lang) {
|
|
24
|
+
globalState.value.lang = lang;
|
|
25
|
+
}
|
|
26
|
+
export function getLang() {
|
|
27
|
+
return globalState?.value.lang ?? "en";
|
|
28
|
+
}
|
|
29
|
+
export function useLang() {
|
|
30
|
+
return toRef(globalState.value, "lang");
|
|
31
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { LiteralUnion } from 'type-fest';
|
|
2
2
|
export declare const AcceptPresets: {
|
|
3
|
-
readonly num:
|
|
4
|
-
readonly numeric:
|
|
5
|
-
readonly digit:
|
|
6
|
-
readonly alpha:
|
|
7
|
-
readonly 'alpha-num':
|
|
8
|
-
readonly 'alpha-num-space':
|
|
9
|
-
readonly 'alpha-num-space-symbol':
|
|
10
|
-
readonly 'alpha-numeric':
|
|
11
|
-
readonly 'alpha-numeric-space':
|
|
12
|
-
readonly 'alpha-numeric-space-symbol':
|
|
13
|
-
readonly 'alpha-space':
|
|
14
|
-
readonly 'alpha-space-symbol':
|
|
15
|
-
readonly 'num-space':
|
|
16
|
-
readonly 'num-space-symbol':
|
|
17
|
-
readonly 'numeric-space':
|
|
18
|
-
readonly 'numeric-space-symbol':
|
|
19
|
-
readonly 'non-numeric':
|
|
20
|
-
readonly 'non-alpha':
|
|
21
|
-
readonly text:
|
|
3
|
+
readonly num: "\\d";
|
|
4
|
+
readonly numeric: "\\d";
|
|
5
|
+
readonly digit: "\\d";
|
|
6
|
+
readonly alpha: "A-Za-z";
|
|
7
|
+
readonly 'alpha-num': "A-Za-z\\d";
|
|
8
|
+
readonly 'alpha-num-space': "A-Za-z\\d\\s";
|
|
9
|
+
readonly 'alpha-num-space-symbol': "A-Za-z\\d\\s!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-";
|
|
10
|
+
readonly 'alpha-numeric': "A-Za-z\\d";
|
|
11
|
+
readonly 'alpha-numeric-space': "A-Za-z\\d\\s";
|
|
12
|
+
readonly 'alpha-numeric-space-symbol': "A-Za-z\\d\\s!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-";
|
|
13
|
+
readonly 'alpha-space': "A-Za-z\\s";
|
|
14
|
+
readonly 'alpha-space-symbol': "A-Za-z\\s!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-";
|
|
15
|
+
readonly 'num-space': "\\d\\s";
|
|
16
|
+
readonly 'num-space-symbol': "\\d\\s!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-";
|
|
17
|
+
readonly 'numeric-space': "\\d\\s";
|
|
18
|
+
readonly 'numeric-space-symbol': "\\d\\s!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-";
|
|
19
|
+
readonly 'non-numeric': "A-Za-z\\s!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-";
|
|
20
|
+
readonly 'non-alpha': "\\d\\s!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-";
|
|
21
|
+
readonly text: "A-Za-z\\d\\s!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-";
|
|
22
22
|
};
|
|
23
23
|
export type AcceptVariant = LiteralUnion<keyof typeof AcceptPresets, string>;
|
|
24
24
|
export declare function isAccepted(accept: AcceptVariant | undefined, text: string): boolean;
|
|
@@ -113,17 +113,17 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
113
113
|
default: string;
|
|
114
114
|
};
|
|
115
115
|
}>> & {
|
|
116
|
+
onCancel?: ((...args: any[]) => any) | undefined;
|
|
116
117
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
117
118
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
118
|
-
onCancel?: ((...args: any[]) => any) | undefined;
|
|
119
119
|
onClear?: ((...args: any[]) => any) | undefined;
|
|
120
120
|
}, {
|
|
121
121
|
error: boolean;
|
|
122
122
|
size: SizeVariant;
|
|
123
123
|
modelValue: string | string[] | File | File[];
|
|
124
|
+
modelModifiers: ModelModifier;
|
|
124
125
|
disabled: boolean;
|
|
125
126
|
readonly: boolean;
|
|
126
|
-
modelModifiers: ModelModifier;
|
|
127
127
|
multiple: boolean | MultipleType;
|
|
128
128
|
placeholder: string;
|
|
129
129
|
maxlength: string | number;
|
|
@@ -3,7 +3,5 @@ type Bindings = {
|
|
|
3
3
|
isShow: Ref<boolean>;
|
|
4
4
|
toggle: () => void;
|
|
5
5
|
};
|
|
6
|
-
declare const _default: import("vue-demi").DefineComponent<any, Bindings, {}, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, {}, string, import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps,
|
|
7
|
-
[x: string]: any;
|
|
8
|
-
}, {}>;
|
|
6
|
+
declare const _default: import("vue-demi").DefineComponent<any, Bindings, {}, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, {}, string, import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, any, any, {}>;
|
|
9
7
|
export default _default;
|
|
@@ -95,11 +95,11 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
95
95
|
"onUpdate:end"?: ((...args: any[]) => any) | undefined;
|
|
96
96
|
}, {
|
|
97
97
|
error: boolean;
|
|
98
|
+
modelValue: number | [number, number];
|
|
98
99
|
start: number;
|
|
99
100
|
end: number;
|
|
100
101
|
min: string | number;
|
|
101
102
|
max: string | number;
|
|
102
|
-
modelValue: number | [number, number];
|
|
103
103
|
disabled: boolean;
|
|
104
104
|
readonly: boolean;
|
|
105
105
|
step: string | number;
|
|
@@ -42,9 +42,9 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
42
42
|
}>> & {
|
|
43
43
|
onDismissed?: ((...args: any[]) => any) | undefined;
|
|
44
44
|
}, {
|
|
45
|
+
color: ColorVariant;
|
|
45
46
|
variant: StyleVariant;
|
|
46
|
-
dismissable: boolean;
|
|
47
47
|
size: SizeVariant;
|
|
48
|
-
|
|
48
|
+
dismissable: boolean;
|
|
49
49
|
}, {}>;
|
|
50
50
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PropType } from 'vue-demi';
|
|
2
|
-
|
|
2
|
+
import { SizeVariant } from '.';
|
|
3
3
|
declare const _default: import("vue-demi").DefineComponent<{
|
|
4
4
|
title: {
|
|
5
5
|
type: StringConstructor;
|
|
@@ -91,13 +91,13 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
91
91
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
92
92
|
onClose?: ((...args: any[]) => any) | undefined;
|
|
93
93
|
}, {
|
|
94
|
+
size: SizeVariant;
|
|
94
95
|
dismissable: boolean;
|
|
95
96
|
banner: boolean;
|
|
96
|
-
size: SizeVariant;
|
|
97
97
|
text: string;
|
|
98
|
-
modelValue: boolean;
|
|
99
98
|
title: string;
|
|
100
99
|
centered: boolean;
|
|
100
|
+
modelValue: boolean;
|
|
101
101
|
noCloseOnEsc: boolean;
|
|
102
102
|
noCloseOnBackdrop: boolean;
|
|
103
103
|
modalBodyScrollable: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SizeVariant = 'sm' | 'md' | 'lg' | 'xl';
|
|
File without changes
|
|
@@ -90,8 +90,8 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
90
90
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
91
91
|
}, {
|
|
92
92
|
variant: StyleVariant;
|
|
93
|
-
icon: boolean;
|
|
94
93
|
size: SizeVariant;
|
|
94
|
+
icon: boolean;
|
|
95
95
|
divider: boolean;
|
|
96
96
|
text: string;
|
|
97
97
|
modelValue: boolean;
|
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
:width="width"
|
|
5
5
|
:height="height"
|
|
6
6
|
:src="preview"
|
|
7
|
+
:srcset="srcset"
|
|
7
8
|
:alt="text">
|
|
8
9
|
</template>
|
|
9
10
|
|
|
10
11
|
<script>
|
|
11
12
|
import {
|
|
12
13
|
defineComponent,
|
|
13
|
-
onMounted
|
|
14
|
+
onMounted,
|
|
15
|
+
ref
|
|
14
16
|
} from "vue-demi";
|
|
15
17
|
import { createSpinner } from "../avatar/utils/create-image";
|
|
16
18
|
import { usePreview } from "../cropper";
|
|
@@ -92,6 +94,7 @@ export default defineComponent({
|
|
|
92
94
|
setup(props) {
|
|
93
95
|
const model = useVModel(props);
|
|
94
96
|
const preview = usePreview(model, createSpinner(props.width, props.height));
|
|
97
|
+
const srcset = ref("");
|
|
95
98
|
watchDebounced(() => [
|
|
96
99
|
props.text,
|
|
97
100
|
props.width,
|
|
@@ -116,8 +119,9 @@ export default defineComponent({
|
|
|
116
119
|
const result = await generate(props);
|
|
117
120
|
const value = props.modelModifiers.base64 ? result : fromBase64(result);
|
|
118
121
|
model.value = value;
|
|
122
|
+
srcset.value = `${await generate(props, 2)} 2x`;
|
|
119
123
|
}
|
|
120
|
-
return { preview };
|
|
124
|
+
return { preview, srcset };
|
|
121
125
|
}
|
|
122
126
|
});
|
|
123
127
|
</script>
|
|
@@ -74,6 +74,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
74
74
|
};
|
|
75
75
|
}, {
|
|
76
76
|
preview: import("vue-demi").Ref<string>;
|
|
77
|
+
srcset: import("vue-demi").Ref<string>;
|
|
77
78
|
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, {}, string, import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
78
79
|
modelValue: {
|
|
79
80
|
type: (StringConstructor | {
|
|
@@ -147,11 +148,11 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
147
148
|
default: number;
|
|
148
149
|
};
|
|
149
150
|
}>>, {
|
|
151
|
+
color: string;
|
|
150
152
|
size: number;
|
|
151
153
|
text: string;
|
|
152
|
-
color: string;
|
|
153
|
-
modelValue: string | File;
|
|
154
154
|
label: string;
|
|
155
|
+
modelValue: string | File;
|
|
155
156
|
modelModifiers: ModelModifier;
|
|
156
157
|
width: number;
|
|
157
158
|
height: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createCanvas } from "../../signature-draw/utils/canvas.mjs";
|
|
2
2
|
import loadFont from "../../signature-text/utils/load-font.mjs";
|
|
3
3
|
import { clamp } from "lodash-es";
|
|
4
|
-
function wrapText(context, text, fontSize,
|
|
4
|
+
function wrapText(context, text, fontSize, fontFamily, maxWidth) {
|
|
5
5
|
const lines = [];
|
|
6
6
|
context.font = `${fontSize}px ${JSON.stringify(fontFamily)}`;
|
|
7
7
|
context.textBaseline = "top";
|
|
@@ -35,7 +35,7 @@ function wrapText(context, text, fontSize, lineHeight, fontFamily, maxWidth) {
|
|
|
35
35
|
}
|
|
36
36
|
return lines;
|
|
37
37
|
}
|
|
38
|
-
export default async function generate(options) {
|
|
38
|
+
export default async function generate(options, dpi = 1) {
|
|
39
39
|
const {
|
|
40
40
|
text,
|
|
41
41
|
color,
|
|
@@ -47,33 +47,41 @@ export default async function generate(options) {
|
|
|
47
47
|
minSize,
|
|
48
48
|
maxSize,
|
|
49
49
|
fixedSize,
|
|
50
|
-
label
|
|
50
|
+
label,
|
|
51
|
+
lineHeight
|
|
51
52
|
} = options;
|
|
52
53
|
await loadFont(font);
|
|
53
|
-
const canvas = options.canvas ?? createCanvas(width, height);
|
|
54
|
+
const canvas = options.canvas ?? createCanvas(width, height, dpi);
|
|
54
55
|
const context = canvas.getContext("2d");
|
|
56
|
+
const maxWidth = width - padding * 2;
|
|
55
57
|
let y = padding;
|
|
56
58
|
if (label) {
|
|
57
59
|
const labelSize = options.labelSize ?? size;
|
|
58
60
|
const labelFont = options.labelFont ?? font;
|
|
59
61
|
const labelColor = options.labelColor ?? color;
|
|
62
|
+
const labelLines = wrapText(
|
|
63
|
+
context,
|
|
64
|
+
label,
|
|
65
|
+
labelSize,
|
|
66
|
+
labelFont,
|
|
67
|
+
maxWidth
|
|
68
|
+
);
|
|
60
69
|
context.font = `${labelSize}px ${JSON.stringify(labelFont)}`;
|
|
61
70
|
context.textBaseline = "top";
|
|
62
71
|
context.textAlign = "start";
|
|
63
72
|
context.fillStyle = labelColor;
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
for (const line of labelLines) {
|
|
74
|
+
context.fillText(line, padding, y);
|
|
75
|
+
y += labelSize * lineHeight;
|
|
76
|
+
}
|
|
66
77
|
}
|
|
67
78
|
if (text) {
|
|
68
|
-
const maxWidth = width - padding * 2;
|
|
69
79
|
const maxHeight = height - (y + padding);
|
|
70
80
|
let fontSize = size;
|
|
71
|
-
let lineHeight = fontSize * options.lineHeight;
|
|
72
81
|
let lines = wrapText(
|
|
73
82
|
context,
|
|
74
83
|
text,
|
|
75
84
|
fontSize,
|
|
76
|
-
lineHeight,
|
|
77
85
|
font,
|
|
78
86
|
maxWidth
|
|
79
87
|
);
|
|
@@ -89,29 +97,23 @@ export default async function generate(options) {
|
|
|
89
97
|
if (newFontSize === fontSize)
|
|
90
98
|
break;
|
|
91
99
|
fontSize = newFontSize;
|
|
92
|
-
lineHeight = fontSize * options.lineHeight;
|
|
93
100
|
lines = wrapText(
|
|
94
101
|
context,
|
|
95
102
|
text,
|
|
96
103
|
fontSize,
|
|
97
|
-
lineHeight,
|
|
98
104
|
font,
|
|
99
105
|
maxWidth
|
|
100
106
|
);
|
|
101
|
-
textHeight = lines.length * lineHeight;
|
|
107
|
+
textHeight = lines.length * lineHeight * fontSize;
|
|
102
108
|
} while (textHeight > maxHeight && ++count < 5);
|
|
103
109
|
}
|
|
104
110
|
context.font = `${fontSize}px ${JSON.stringify(font)}`;
|
|
105
111
|
context.textBaseline = "top";
|
|
106
112
|
context.textAlign = "start";
|
|
107
113
|
context.fillStyle = color;
|
|
108
|
-
context.font = `${fontSize}px ${JSON.stringify(font)}`;
|
|
109
|
-
context.textBaseline = "top";
|
|
110
|
-
context.textAlign = "start";
|
|
111
|
-
context.fillStyle = color;
|
|
112
114
|
for (const line of lines) {
|
|
113
115
|
context.fillText(line, padding, y);
|
|
114
|
-
y += lineHeight;
|
|
116
|
+
y += fontSize * lineHeight;
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
return canvas.toDataURL("image/png");
|
|
@@ -22,15 +22,20 @@
|
|
|
22
22
|
<dt>
|
|
23
23
|
PDFJS Version:
|
|
24
24
|
</dt>
|
|
25
|
-
<dd><code>{{
|
|
25
|
+
<dd><code>{{ version }}</code></dd>
|
|
26
26
|
</dl>
|
|
27
27
|
</div>
|
|
28
28
|
</template>
|
|
29
29
|
|
|
30
30
|
<script>
|
|
31
31
|
import { pAspectRatio } from "../aspect-ratio";
|
|
32
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
defineComponent,
|
|
34
|
+
onMounted,
|
|
35
|
+
ref
|
|
36
|
+
} from "vue-demi";
|
|
33
37
|
import Heading from "../heading/Heading.vue";
|
|
38
|
+
import { getVersion } from "./utils/pdfjs";
|
|
34
39
|
export default defineComponent({
|
|
35
40
|
directives: { pAspectRatio },
|
|
36
41
|
components: { Heading },
|
|
@@ -39,17 +44,17 @@ export default defineComponent({
|
|
|
39
44
|
type: String,
|
|
40
45
|
default: ""
|
|
41
46
|
},
|
|
42
|
-
pdfJs: {
|
|
43
|
-
type: Object,
|
|
44
|
-
default: () => ({})
|
|
45
|
-
},
|
|
46
47
|
error: {
|
|
47
48
|
type: Object,
|
|
48
49
|
default: () => ({})
|
|
49
50
|
}
|
|
50
51
|
},
|
|
51
52
|
setup() {
|
|
52
|
-
|
|
53
|
+
const version = ref("");
|
|
54
|
+
onMounted(async () => {
|
|
55
|
+
version.value = await getVersion();
|
|
56
|
+
});
|
|
57
|
+
return { version };
|
|
53
58
|
}
|
|
54
59
|
});
|
|
55
60
|
</script>
|