@resee-movies/nuxt-ux 0.4.0 → 0.5.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 +20 -3
- package/dist/runtime/components/Button.vue +15 -9
- package/dist/runtime/components/Button.vue.d.ts +2 -12
- package/dist/runtime/components/Card.vue.d.ts +1 -4
- package/dist/runtime/components/Dialog.vue.d.ts +1 -13
- package/dist/runtime/components/Drawer.vue.d.ts +1 -4
- package/dist/runtime/components/Heading.vue.d.ts +1 -4
- package/dist/runtime/components/Icon.vue +27 -15
- package/dist/runtime/components/Icon.vue.d.ts +4 -6
- package/dist/runtime/components/IconTextPair.vue +22 -19
- package/dist/runtime/components/IconTextPair.vue.d.ts +5 -12
- package/dist/runtime/components/Image.vue +1 -1
- package/dist/runtime/components/Image.vue.d.ts +1 -17
- package/dist/runtime/components/LayoutPageColumn.vue.d.ts +1 -4
- package/dist/runtime/components/LayoutPageContainer.vue +12 -2
- package/dist/runtime/components/LayoutPageContainer.vue.d.ts +4 -5
- package/dist/runtime/components/Lorem.vue.d.ts +1 -11
- package/dist/runtime/components/Menu.vue +28 -20
- package/dist/runtime/components/Menu.vue.d.ts +4 -7
- package/dist/runtime/components/Message.vue.d.ts +2 -2
- package/dist/runtime/components/NotificationContainer.vue +10 -3
- package/dist/runtime/components/ProgressBar.vue.d.ts +1 -5
- package/dist/runtime/components/ProgressSpinner.vue.d.ts +1 -3
- package/dist/runtime/components/Tag.vue.d.ts +1 -7
- package/dist/runtime/components/form/Form.vue +52 -0
- package/dist/runtime/components/form/Form.vue.d.ts +27 -0
- package/dist/runtime/components/form/FormField.vue +91 -0
- package/dist/runtime/components/form/FormField.vue.d.ts +37 -0
- package/dist/runtime/components/form/FormFieldCheckbox.vue +51 -0
- package/dist/runtime/components/form/FormFieldCheckbox.vue.d.ts +17 -0
- package/dist/runtime/components/form/FormFieldSelect.vue +76 -0
- package/dist/runtime/components/form/FormFieldSelect.vue.d.ts +26 -0
- package/dist/runtime/components/form/FormFieldText.vue +56 -0
- package/dist/runtime/components/form/FormFieldText.vue.d.ts +16 -0
- package/dist/runtime/components/form/FormFieldToggleSwitch.vue +47 -0
- package/dist/runtime/components/form/FormFieldToggleSwitch.vue.d.ts +15 -0
- package/dist/runtime/components/form/FormLabelInputPair.vue +42 -0
- package/dist/runtime/components/form/FormLabelInputPair.vue.d.ts +22 -0
- package/dist/runtime/components/form/FormSubmitButton.vue +39 -0
- package/dist/runtime/components/form/FormSubmitButton.vue.d.ts +6 -0
- package/dist/runtime/components/form/FormValidationMessage.vue +24 -0
- package/dist/runtime/components/form/FormValidationMessage.vue.d.ts +15 -0
- package/dist/runtime/components/form/element/FormElementSelectOptions.vue +250 -0
- package/dist/runtime/components/form/element/FormElementSelectOptions.vue.d.ts +13 -0
- package/dist/runtime/composables/use-load-image.js +1 -0
- package/dist/runtime/composables/use-notification.d.ts +18 -11
- package/dist/runtime/composables/use-notification.js +27 -27
- package/dist/runtime/composables/use-resee-ux.d.ts +24 -0
- package/dist/runtime/composables/use-resee-ux.js +22 -0
- package/dist/runtime/constants.d.ts +3 -0
- package/dist/runtime/constants.js +3 -0
- package/dist/runtime/server/plugins/teleport-targets.d.ts +3 -0
- package/dist/runtime/server/plugins/teleport-targets.js +6 -0
- package/dist/runtime/theme/css/brand/form.css +1 -0
- package/dist/runtime/theme/css/brand/menu.css +1 -0
- package/dist/runtime/theme/css/brand/mobile.css +1 -0
- package/dist/runtime/theme/css/brand/transition.css +1 -1
- package/dist/runtime/theme/css/brand/utilities.css +1 -1
- package/dist/runtime/theme/css/styles.css +1 -1
- package/dist/runtime/types/form.d.ts +23 -0
- package/dist/runtime/types/form.js +0 -0
- package/dist/runtime/utils/dom.d.ts +9 -0
- package/dist/runtime/utils/dom.js +25 -0
- package/dist/runtime/utils/form.d.ts +34 -0
- package/dist/runtime/utils/form.js +34 -0
- package/dist/runtime/utils/string.d.ts +6 -0
- package/dist/runtime/utils/string.js +3 -0
- package/dist/runtime/utils/validation.d.ts +21 -0
- package/dist/runtime/utils/validation.js +56 -0
- package/package.json +26 -24
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FormFieldState } from '@primevue/forms';
|
|
2
|
+
import { type InjectionKey } from 'vue';
|
|
3
|
+
import type { FormInstance, FormValues } from '../types/form.js';
|
|
4
|
+
/**
|
|
5
|
+
* The injection key for acquiring a {@link FormInstance} object within the
|
|
6
|
+
* descendant component of a Form. Consider using {@link injectFormInstance}
|
|
7
|
+
* instead.
|
|
8
|
+
*/
|
|
9
|
+
export declare const FormSymbol: InjectionKey<FormInstance>;
|
|
10
|
+
/**
|
|
11
|
+
* Helper method to create a new stateful object for a Form. You shouldn't ever
|
|
12
|
+
* need to use this directly.
|
|
13
|
+
*
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
export declare function createFormInstance(): FormInstance;
|
|
17
|
+
/**
|
|
18
|
+
* Provides the object that a Form uses to convey stateful information to the
|
|
19
|
+
* DI registry. You shouldn't ever need to use this directly.
|
|
20
|
+
*
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
export declare function provideFormInstance(): FormInstance;
|
|
24
|
+
/**
|
|
25
|
+
* Injects the stateful object provided by an ancestor Form instance. If not
|
|
26
|
+
* available, a dummy state object is generated.
|
|
27
|
+
*/
|
|
28
|
+
export declare function injectFormInstance(): FormInstance;
|
|
29
|
+
/**
|
|
30
|
+
* Takes a Primevue Form's `states` object, and extracts the current values
|
|
31
|
+
* of each named property. In doing so, it will deref proxies, and create
|
|
32
|
+
* shallow clones of any arrays/objects it encounters.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getValuesFromFormState<T extends FormValues = FormValues>(state: Record<string, FormFieldState>): T;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isObjectLike } from "@resee-movies/utilities/objects/is-object-like";
|
|
2
|
+
import { inject, provide, ref, toRaw, toValue } from "vue";
|
|
3
|
+
export const FormSymbol = Symbol("form");
|
|
4
|
+
export function createFormInstance() {
|
|
5
|
+
return {
|
|
6
|
+
hasSubmitted: ref(false),
|
|
7
|
+
isSubmitting: ref(false),
|
|
8
|
+
isDisabled: ref(false)
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function provideFormInstance() {
|
|
12
|
+
const instance = createFormInstance();
|
|
13
|
+
provide(FormSymbol, instance);
|
|
14
|
+
return instance;
|
|
15
|
+
}
|
|
16
|
+
export function injectFormInstance() {
|
|
17
|
+
return inject(FormSymbol, () => createFormInstance(), true);
|
|
18
|
+
}
|
|
19
|
+
export function getValuesFromFormState(state) {
|
|
20
|
+
const result = {};
|
|
21
|
+
for (const [key, value] of Object.entries(state)) {
|
|
22
|
+
const rawValue = toRaw(toValue(value.value));
|
|
23
|
+
let processed;
|
|
24
|
+
if (Array.isArray(rawValue)) {
|
|
25
|
+
processed = Array.from(rawValue);
|
|
26
|
+
} else if (isObjectLike(rawValue)) {
|
|
27
|
+
processed = { ...rawValue };
|
|
28
|
+
} else {
|
|
29
|
+
processed = rawValue;
|
|
30
|
+
}
|
|
31
|
+
Object.defineProperty(result, key, { value: processed, enumerable: true });
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Takes a string and replaces all substrings which match the form `{PROPERTY}`,
|
|
3
|
+
* where "PROPERTY" is a key of the provided `placeholders` object, with the value
|
|
4
|
+
* at that key.
|
|
5
|
+
*/
|
|
6
|
+
export declare function swapStringPlaceholders(target: string, placeholders?: Record<string, unknown>): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as z from 'zod/mini';
|
|
2
|
+
export declare function toValidationError(str: string, placeholders?: Record<string, string | number>): {
|
|
3
|
+
error: string;
|
|
4
|
+
};
|
|
5
|
+
export type BooleanInputRequirements = {
|
|
6
|
+
required?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function createBooleanValidator(requirements: BooleanInputRequirements): z.ZodMiniBoolean<unknown> | undefined;
|
|
9
|
+
export type TextInputRequirements = {
|
|
10
|
+
required?: boolean;
|
|
11
|
+
type?: 'text' | 'email' | 'url';
|
|
12
|
+
minLength?: string | number;
|
|
13
|
+
maxLength?: string | number;
|
|
14
|
+
};
|
|
15
|
+
export declare function createTextValidator(requirements: TextInputRequirements): z.ZodMiniString<string> | z.ZodMiniUnion<readonly [z.ZodMiniNull, z.ZodMiniString<string>]>;
|
|
16
|
+
export type ListInputRequirements = {
|
|
17
|
+
required?: boolean;
|
|
18
|
+
minRequired?: string | number;
|
|
19
|
+
maxRequired?: string | number;
|
|
20
|
+
};
|
|
21
|
+
export declare function createListValidator(requirements: ListInputRequirements): z.ZodMiniArray<z.ZodMiniUnknown> | z.ZodMiniUnion<readonly [z.ZodMiniNull, z.ZodMiniArray<z.ZodMiniUnknown>]>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { toInteger } from "@resee-movies/utilities/numbers/to-integer";
|
|
2
|
+
import * as z from "zod/mini";
|
|
3
|
+
import { useReseeUx } from "../composables/use-resee-ux.js";
|
|
4
|
+
import { swapStringPlaceholders } from "./string.js";
|
|
5
|
+
export function toValidationError(str, placeholders) {
|
|
6
|
+
return { error: swapStringPlaceholders(str, placeholders) };
|
|
7
|
+
}
|
|
8
|
+
export function createBooleanValidator(requirements) {
|
|
9
|
+
const { locale } = useReseeUx();
|
|
10
|
+
return requirements.required ? z.coerce.boolean().check(z.refine((val) => val === true, toValidationError(locale.validation.required))) : void 0;
|
|
11
|
+
}
|
|
12
|
+
export function createTextValidator(requirements) {
|
|
13
|
+
const { locale } = useReseeUx();
|
|
14
|
+
const checkFns = [];
|
|
15
|
+
if (requirements.required) {
|
|
16
|
+
checkFns.push(z.minLength(1, toValidationError(locale.validation.required)));
|
|
17
|
+
}
|
|
18
|
+
if (requirements.type === "email") {
|
|
19
|
+
checkFns.push(z.email(toValidationError(locale.validation.invalidEmail)));
|
|
20
|
+
} else if (requirements.type === "url") {
|
|
21
|
+
checkFns.push(z.url(toValidationError(locale.validation.invalidUrl)));
|
|
22
|
+
} else {
|
|
23
|
+
const minLength = toInteger(requirements.minLength);
|
|
24
|
+
const maxLength = toInteger(requirements.maxLength);
|
|
25
|
+
if (minLength) {
|
|
26
|
+
checkFns.push(
|
|
27
|
+
z.minLength(minLength, toValidationError(locale.validation.tooFewChars, { count: minLength }))
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
if (maxLength) {
|
|
31
|
+
checkFns.push(
|
|
32
|
+
z.maxLength(maxLength, toValidationError(locale.validation.tooManyChars, { count: maxLength }))
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const stringSchema = z.string(toValidationError(locale.validation.required)).check(z.trim(), ...checkFns);
|
|
37
|
+
return requirements.required ? stringSchema : z.union([z.null(), stringSchema]);
|
|
38
|
+
}
|
|
39
|
+
export function createListValidator(requirements) {
|
|
40
|
+
const { locale } = useReseeUx();
|
|
41
|
+
const checkFns = [];
|
|
42
|
+
const minRequired = toInteger(requirements.minRequired) || (requirements.required ? 1 : void 0);
|
|
43
|
+
const maxRequired = toInteger(requirements.maxRequired);
|
|
44
|
+
if (minRequired) {
|
|
45
|
+
checkFns.push(
|
|
46
|
+
z.minLength(minRequired, toValidationError(locale.validation.tooFewOptions, { count: minRequired }))
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
if (maxRequired) {
|
|
50
|
+
checkFns.push(
|
|
51
|
+
z.maxLength(maxRequired, toValidationError(locale.validation.tooManyOptions, { count: maxRequired }))
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
const arraySchema = z.array(z.unknown(), toValidationError(locale.validation.required)).check(...checkFns);
|
|
55
|
+
return requirements.required ? arraySchema : z.union([z.null(), arraySchema]);
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@resee-movies/nuxt-ux",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "The next-gen user experience library for ReSee Movies - currently in development. ",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/ReSee-Movies/nuxt-ux.git"
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
38
|
"dev": "npm run dev:prepare && nuxi dev playground",
|
|
39
|
+
"dev:preview": "npm run dev:build && nuxi preview playground",
|
|
39
40
|
"dev:build": "nuxi build playground",
|
|
40
|
-
"dev:preview": "nuxi preview playground",
|
|
41
41
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
42
42
|
"prepare": "nuxt-module-build prepare && nuxt-module-build build",
|
|
43
43
|
"release": "dotenv release-it --",
|
|
@@ -48,40 +48,42 @@
|
|
|
48
48
|
"test:coverage": "vitest run --coverage"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@nuxt/devtools": "^
|
|
52
|
-
"@nuxt/eslint": "^1.
|
|
53
|
-
"@nuxt/eslint-config": "^1.
|
|
51
|
+
"@nuxt/devtools": "^3.1.1",
|
|
52
|
+
"@nuxt/eslint": "^1.11.0",
|
|
53
|
+
"@nuxt/eslint-config": "^1.11.0",
|
|
54
54
|
"@nuxt/kit": "^4.1.3",
|
|
55
55
|
"@nuxt/module-builder": "^1.0.2",
|
|
56
56
|
"@nuxt/schema": "^4.1.3",
|
|
57
|
-
"@nuxt/test-utils": "^3.
|
|
58
|
-
"@release-it/conventional-changelog": "^10.0.
|
|
59
|
-
"@types/node": "^
|
|
57
|
+
"@nuxt/test-utils": "^3.20.1",
|
|
58
|
+
"@release-it/conventional-changelog": "^10.0.2",
|
|
59
|
+
"@types/node": "^24.10.1",
|
|
60
60
|
"@vitest/coverage-v8": "^3.2.4",
|
|
61
|
-
"@vue/language-server": "^3.1.0",
|
|
62
61
|
"@vue/test-utils": "^2.4.6",
|
|
63
|
-
"dotenv-cli": "^
|
|
64
|
-
"eslint": "^9.
|
|
65
|
-
"happy-dom": "^
|
|
66
|
-
"nuxt": "^4.1
|
|
67
|
-
"release-it": "^19.0.
|
|
62
|
+
"dotenv-cli": "^11.0.0",
|
|
63
|
+
"eslint": "^9.39.1",
|
|
64
|
+
"happy-dom": "^20.0.11",
|
|
65
|
+
"nuxt": "^4.2.1",
|
|
66
|
+
"release-it": "^19.0.6",
|
|
68
67
|
"typescript": "^5.9.3",
|
|
68
|
+
"vite-plugin-devtools-json": "^1.0.0",
|
|
69
69
|
"vitest": "^3.2.4",
|
|
70
|
-
"vue-tsc": "^3.1.
|
|
70
|
+
"vue-tsc": "^3.1.5"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@egoist/tailwindcss-icons": "^1.9.0",
|
|
74
74
|
"@iconify-json/ph": "^1.2.2",
|
|
75
|
-
"@iconify-json/simple-icons": "^1.2.
|
|
76
|
-
"@iconify-json/solar": "^1.2.
|
|
77
|
-
"@nuxt/fonts": "^0.
|
|
75
|
+
"@iconify-json/simple-icons": "^1.2.61",
|
|
76
|
+
"@iconify-json/solar": "^1.2.5",
|
|
77
|
+
"@nuxt/fonts": "^0.12.1",
|
|
78
78
|
"@primeuix/utils": "^0.6.1",
|
|
79
|
-
"@primevue/
|
|
79
|
+
"@primevue/forms": "^4.5.1",
|
|
80
|
+
"@primevue/nuxt-module": "^4.5.1",
|
|
80
81
|
"@resee-movies/utilities": "^0.10.0",
|
|
81
|
-
"@tailwindcss/postcss": "^4.1.
|
|
82
|
-
"@tailwindcss/vite": "^4.1.
|
|
83
|
-
"@vueuse/core": "^
|
|
84
|
-
"primevue": "^4.
|
|
85
|
-
"tailwindcss": "^4.1.
|
|
82
|
+
"@tailwindcss/postcss": "^4.1.17",
|
|
83
|
+
"@tailwindcss/vite": "^4.1.17",
|
|
84
|
+
"@vueuse/core": "^14.1.0",
|
|
85
|
+
"primevue": "^4.5.1",
|
|
86
|
+
"tailwindcss": "^4.1.17",
|
|
87
|
+
"zod": "^4.1.13"
|
|
86
88
|
}
|
|
87
89
|
}
|