@resee-movies/nuxt-ux 0.7.1 → 0.8.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/module.json +1 -1
- package/dist/module.mjs +1 -0
- package/dist/runtime/components/form/FormField.vue +1 -0
- package/dist/runtime/components/form/FormField.vue.d.ts +1 -0
- package/dist/runtime/components/form/FormFieldSelectButton.vue +2 -1
- package/dist/runtime/components/form/FormFieldTextarea.vue +58 -0
- package/dist/runtime/components/form/FormFieldTextarea.vue.d.ts +18 -0
- package/dist/runtime/components/form/FormFieldTurnstile.vue +37 -0
- package/dist/runtime/components/form/FormFieldTurnstile.vue.d.ts +15 -0
- package/dist/runtime/components/form/element/FormElementTurnstile.vue +53 -0
- package/dist/runtime/components/form/element/FormElementTurnstile.vue.d.ts +6 -0
- package/dist/runtime/composables/use-cloudflare-turnstile.d.ts +55 -0
- package/dist/runtime/composables/use-cloudflare-turnstile.js +62 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
<slot name="label" />
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
|
-
<template #default="{ labelId, messageId, invalid, disabled, readonly, onChange, onBlur }">
|
|
7
|
+
<template #default="{ value, labelId, messageId, invalid, disabled, readonly, onChange, onBlur }">
|
|
8
8
|
<FormElementSelectButton
|
|
9
|
+
:value = "value"
|
|
9
10
|
:aria-labelledby = "labelId"
|
|
10
11
|
:aria-describedby = "messageId"
|
|
11
12
|
:aria-invalid = "invalid"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormField v-bind="props" :validator="validatorFunction">
|
|
3
|
+
<template #label>
|
|
4
|
+
<slot name="label" />
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<template #default="{ inputId, messageId, disabled, readonly }">
|
|
8
|
+
<PrimeInputTextarea
|
|
9
|
+
:id = "inputId"
|
|
10
|
+
:placeholder = "props.placeholder"
|
|
11
|
+
:rows = "props.rows"
|
|
12
|
+
:auto-resize = "props.autoResize"
|
|
13
|
+
:aria-describedby = "messageId"
|
|
14
|
+
:disabled = "disabled"
|
|
15
|
+
:readonly = "readonly"
|
|
16
|
+
:required = "props.required"
|
|
17
|
+
:minlength = "props.minLength"
|
|
18
|
+
:maxlength = "props.maxLength"
|
|
19
|
+
class = "input-control"
|
|
20
|
+
/>
|
|
21
|
+
</template>
|
|
22
|
+
</FormField>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script>
|
|
26
|
+
import {} from "./FormField.vue";
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<script setup>
|
|
30
|
+
import PrimeInputTextarea from "primevue/textarea";
|
|
31
|
+
import { computed } from "vue";
|
|
32
|
+
import FormField from "./FormField.vue";
|
|
33
|
+
import { createTextValidator } from "../../utils/validation";
|
|
34
|
+
const props = defineProps({
|
|
35
|
+
placeholder: { type: String, required: false, default: void 0 },
|
|
36
|
+
rows: { type: [String, Number], required: false, default: 5 },
|
|
37
|
+
autoResize: { type: Boolean, required: false, default: true },
|
|
38
|
+
minLength: { type: [String, Number], required: false, default: void 0 },
|
|
39
|
+
maxLength: { type: [String, Number], required: false, default: void 0 },
|
|
40
|
+
name: { type: String, required: true },
|
|
41
|
+
label: { type: String, required: false },
|
|
42
|
+
is: { type: String, required: false },
|
|
43
|
+
required: { type: Boolean, required: false },
|
|
44
|
+
disabled: { type: Boolean, required: false },
|
|
45
|
+
readonly: { type: Boolean, required: false },
|
|
46
|
+
fauxLabel: { type: Boolean, required: false },
|
|
47
|
+
labelSrOnly: { type: Boolean, required: false },
|
|
48
|
+
labelPosition: { type: String, required: false },
|
|
49
|
+
class: { type: null, required: false }
|
|
50
|
+
});
|
|
51
|
+
const validatorFunction = computed(() => {
|
|
52
|
+
return () => createTextValidator({
|
|
53
|
+
required: props.required,
|
|
54
|
+
minLength: props.minLength,
|
|
55
|
+
maxLength: props.maxLength
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type FormFieldProps } from './FormField.vue.js';
|
|
2
|
+
export interface FormFieldTextareaProps extends Omit<FormFieldProps, 'validator'> {
|
|
3
|
+
placeholder?: string;
|
|
4
|
+
rows?: string | number;
|
|
5
|
+
autoResize?: boolean;
|
|
6
|
+
minLength?: string | number;
|
|
7
|
+
maxLength?: string | number;
|
|
8
|
+
}
|
|
9
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<FormFieldTextareaProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FormFieldTextareaProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
10
|
+
label?: (props: {}) => any;
|
|
11
|
+
}>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
14
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
15
|
+
new (): {
|
|
16
|
+
$slots: S;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormField v-bind="props" :validator="() => createTextValidator({ required: true })">
|
|
3
|
+
<template #label>
|
|
4
|
+
<slot name="label" />
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<template #default="{ inputName, onChange }">
|
|
8
|
+
<FormElementTurnstile
|
|
9
|
+
:sitekey = "props.sitekey"
|
|
10
|
+
:response-field-name = "inputName"
|
|
11
|
+
:callback = "(token) => onChange({ value: token })"
|
|
12
|
+
/>
|
|
13
|
+
</template>
|
|
14
|
+
</FormField>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<script setup>
|
|
22
|
+
import { createTextValidator } from "../../utils/validation";
|
|
23
|
+
import FormField from "./FormField.vue";
|
|
24
|
+
import FormElementTurnstile from "./element/FormElementTurnstile.vue";
|
|
25
|
+
const props = defineProps({
|
|
26
|
+
sitekey: { type: String, required: true },
|
|
27
|
+
name: { type: String, required: false, default: "cf-turnstile-response" },
|
|
28
|
+
label: { type: String, required: false },
|
|
29
|
+
is: { type: String, required: false },
|
|
30
|
+
disabled: { type: Boolean, required: false },
|
|
31
|
+
readonly: { type: Boolean, required: false },
|
|
32
|
+
fauxLabel: { type: Boolean, required: false, default: true },
|
|
33
|
+
labelSrOnly: { type: Boolean, required: false, default: true },
|
|
34
|
+
labelPosition: { type: String, required: false },
|
|
35
|
+
class: { type: null, required: false }
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FormFieldProps } from './FormField.vue.js';
|
|
2
|
+
export interface FormFieldTurnstileProps extends Omit<FormFieldProps, 'validator' | 'required' | 'name'> {
|
|
3
|
+
sitekey: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<FormFieldTurnstileProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FormFieldTurnstileProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
7
|
+
label?: (props: {}) => any;
|
|
8
|
+
}>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
12
|
+
new (): {
|
|
13
|
+
$slots: S;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:id = "widgetId"
|
|
4
|
+
:class = "[
|
|
5
|
+
'w-fit',
|
|
6
|
+
props.size === 'compact' ? 'h-[140px]' : 'h-[65px]'
|
|
7
|
+
]"
|
|
8
|
+
/>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<script setup>
|
|
16
|
+
import { onUnmounted, useId } from "#imports";
|
|
17
|
+
import { useCloudflareTurnstile } from "../../../composables/use-cloudflare-turnstile";
|
|
18
|
+
const props = defineProps({
|
|
19
|
+
sitekey: { type: String, required: true },
|
|
20
|
+
action: { type: String, required: false },
|
|
21
|
+
cData: { type: String, required: false },
|
|
22
|
+
callback: { type: Function, required: false },
|
|
23
|
+
"error-callback": { type: Function, required: false },
|
|
24
|
+
execution: { type: String, required: false, default: "render" },
|
|
25
|
+
"expired-callback": { type: Function, required: false },
|
|
26
|
+
"before-interactive-callback": { type: Function, required: false },
|
|
27
|
+
"after-interactive-callback": { type: Function, required: false },
|
|
28
|
+
"unsupported-callback": { type: Function, required: false },
|
|
29
|
+
theme: { type: String, required: false, default: "auto" },
|
|
30
|
+
language: { type: String, required: false },
|
|
31
|
+
tabindex: { type: Number, required: false },
|
|
32
|
+
"timeout-callback": { type: Function, required: false },
|
|
33
|
+
"response-field": { type: Boolean, required: false },
|
|
34
|
+
"response-field-name": { type: String, required: false },
|
|
35
|
+
size: { type: String, required: false, default: "flexible" },
|
|
36
|
+
retry: { type: String, required: false, default: "auto" },
|
|
37
|
+
"retry-interval": { type: Number, required: false, default: 8e3 },
|
|
38
|
+
"refresh-expired": { type: String, required: false, default: "auto" },
|
|
39
|
+
"refresh-timeout": { type: String, required: false, default: "auto" },
|
|
40
|
+
appearance: { type: String, required: false, default: "always" },
|
|
41
|
+
"feedback-enabled": { type: Boolean, required: false }
|
|
42
|
+
});
|
|
43
|
+
const widgetId = useId();
|
|
44
|
+
const { onReady } = useCloudflareTurnstile();
|
|
45
|
+
let turnstile = void 0;
|
|
46
|
+
onReady((ts) => {
|
|
47
|
+
ts.render(`#${widgetId}`, { ...props });
|
|
48
|
+
turnstile = ts;
|
|
49
|
+
});
|
|
50
|
+
onUnmounted(() => {
|
|
51
|
+
turnstile?.remove(`#${widgetId}`);
|
|
52
|
+
});
|
|
53
|
+
</script>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TurnstileRenderOptions } from '../../../composables/use-cloudflare-turnstile.js';
|
|
2
|
+
export interface FormFieldTurnstileProps extends TurnstileRenderOptions {
|
|
3
|
+
}
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<FormFieldTurnstileProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FormFieldTurnstileProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
turnstile?: Turnstile;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Configurable options for Turnstile's `render` function.
|
|
8
|
+
* @see https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/widget-configurations/#complete-configuration-reference
|
|
9
|
+
*/
|
|
10
|
+
export interface TurnstileRenderOptions {
|
|
11
|
+
'sitekey': string;
|
|
12
|
+
'action'?: string;
|
|
13
|
+
'cData'?: string;
|
|
14
|
+
'callback'?: (token: string) => void;
|
|
15
|
+
'error-callback'?: () => void;
|
|
16
|
+
'execution'?: 'render' | 'execute';
|
|
17
|
+
'expired-callback'?: () => void;
|
|
18
|
+
'before-interactive-callback'?: () => void;
|
|
19
|
+
'after-interactive-callback'?: () => void;
|
|
20
|
+
'unsupported-callback'?: () => void;
|
|
21
|
+
'theme'?: 'auto' | 'light' | 'dark';
|
|
22
|
+
'language'?: string;
|
|
23
|
+
'tabindex'?: number;
|
|
24
|
+
'timeout-callback'?: () => void;
|
|
25
|
+
'response-field'?: boolean;
|
|
26
|
+
'response-field-name'?: string;
|
|
27
|
+
'size'?: 'normal' | 'flexible' | 'compact';
|
|
28
|
+
'retry'?: 'auto' | 'never';
|
|
29
|
+
'retry-interval'?: number;
|
|
30
|
+
'refresh-expired'?: 'auto' | 'manual' | 'never';
|
|
31
|
+
'refresh-timeout'?: 'auto' | 'manual' | 'never';
|
|
32
|
+
'appearance'?: 'always' | 'execute' | 'interaction-only';
|
|
33
|
+
'feedback-enabled'?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The Cloudflare Turnstile global instance.
|
|
37
|
+
* @see https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/#explicit-rendering
|
|
38
|
+
*/
|
|
39
|
+
export interface Turnstile {
|
|
40
|
+
render: (widgetId: string, options: TurnstileRenderOptions) => void;
|
|
41
|
+
reset: (widgetId: string) => void;
|
|
42
|
+
remove: (widgetId: string) => void;
|
|
43
|
+
getResponse: (widgetId: string) => string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The return type of the {@link useCloudflareTurnstile} composable.
|
|
47
|
+
*/
|
|
48
|
+
export interface UseCloudflareTurnstileReturn {
|
|
49
|
+
onReady: (callback: (turnstile: Turnstile) => void) => void;
|
|
50
|
+
onError: (callback: (error: unknown) => void) => void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Utilize Cloudflare's Turnstile widget via the returned `onReady` and `onError` methods.
|
|
54
|
+
*/
|
|
55
|
+
export declare function useCloudflareTurnstile(): UseCloudflareTurnstileReturn;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useHead } from "#imports";
|
|
2
|
+
export function useCloudflareTurnstile() {
|
|
3
|
+
if (import.meta.server) {
|
|
4
|
+
useHead({
|
|
5
|
+
link: [{ href: "https://challenges.cloudflare.com", rel: "preconnect" }]
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
const onReady = function onTurnstileReady(callback) {
|
|
9
|
+
if (import.meta.client) {
|
|
10
|
+
readyTurnstile().then((turnstile) => callback(turnstile));
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const onError = function onTurnstileError(callback) {
|
|
14
|
+
if (import.meta.client) {
|
|
15
|
+
readyTurnstile().catch((e) => callback(e));
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
return { onReady, onError };
|
|
19
|
+
}
|
|
20
|
+
let pending = void 0;
|
|
21
|
+
function readyTurnstile() {
|
|
22
|
+
if (window.turnstile) {
|
|
23
|
+
return Promise.resolve(window.turnstile);
|
|
24
|
+
}
|
|
25
|
+
if (pending) {
|
|
26
|
+
return pending;
|
|
27
|
+
}
|
|
28
|
+
pending = new Promise((resolve, reject) => {
|
|
29
|
+
const onScriptLoad = () => {
|
|
30
|
+
pending = void 0;
|
|
31
|
+
try {
|
|
32
|
+
if (window.turnstile) {
|
|
33
|
+
return resolve(window.turnstile);
|
|
34
|
+
}
|
|
35
|
+
reject(new Error("Turnstile script loaded, but global is not available."));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const onScriptError = (e) => {
|
|
41
|
+
pending = void 0;
|
|
42
|
+
reject(e);
|
|
43
|
+
};
|
|
44
|
+
try {
|
|
45
|
+
useHead({
|
|
46
|
+
script: [{
|
|
47
|
+
src: "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",
|
|
48
|
+
async: true,
|
|
49
|
+
defer: true,
|
|
50
|
+
fetchpriority: "low",
|
|
51
|
+
crossorigin: "anonymous",
|
|
52
|
+
referrerpolicy: "no-referrer",
|
|
53
|
+
onload: onScriptLoad,
|
|
54
|
+
onerror: onScriptError
|
|
55
|
+
}]
|
|
56
|
+
});
|
|
57
|
+
} catch (e) {
|
|
58
|
+
reject(e);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return pending;
|
|
62
|
+
}
|
package/package.json
CHANGED