@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.
Files changed (71) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +20 -3
  3. package/dist/runtime/components/Button.vue +15 -9
  4. package/dist/runtime/components/Button.vue.d.ts +2 -12
  5. package/dist/runtime/components/Card.vue.d.ts +1 -4
  6. package/dist/runtime/components/Dialog.vue.d.ts +1 -13
  7. package/dist/runtime/components/Drawer.vue.d.ts +1 -4
  8. package/dist/runtime/components/Heading.vue.d.ts +1 -4
  9. package/dist/runtime/components/Icon.vue +27 -15
  10. package/dist/runtime/components/Icon.vue.d.ts +4 -6
  11. package/dist/runtime/components/IconTextPair.vue +22 -19
  12. package/dist/runtime/components/IconTextPair.vue.d.ts +5 -12
  13. package/dist/runtime/components/Image.vue +1 -1
  14. package/dist/runtime/components/Image.vue.d.ts +1 -17
  15. package/dist/runtime/components/LayoutPageColumn.vue.d.ts +1 -4
  16. package/dist/runtime/components/LayoutPageContainer.vue +12 -2
  17. package/dist/runtime/components/LayoutPageContainer.vue.d.ts +4 -5
  18. package/dist/runtime/components/Lorem.vue.d.ts +1 -11
  19. package/dist/runtime/components/Menu.vue +28 -20
  20. package/dist/runtime/components/Menu.vue.d.ts +4 -7
  21. package/dist/runtime/components/Message.vue.d.ts +2 -2
  22. package/dist/runtime/components/NotificationContainer.vue +10 -3
  23. package/dist/runtime/components/ProgressBar.vue.d.ts +1 -5
  24. package/dist/runtime/components/ProgressSpinner.vue.d.ts +1 -3
  25. package/dist/runtime/components/Tag.vue.d.ts +1 -7
  26. package/dist/runtime/components/form/Form.vue +52 -0
  27. package/dist/runtime/components/form/Form.vue.d.ts +27 -0
  28. package/dist/runtime/components/form/FormField.vue +91 -0
  29. package/dist/runtime/components/form/FormField.vue.d.ts +37 -0
  30. package/dist/runtime/components/form/FormFieldCheckbox.vue +51 -0
  31. package/dist/runtime/components/form/FormFieldCheckbox.vue.d.ts +17 -0
  32. package/dist/runtime/components/form/FormFieldSelect.vue +76 -0
  33. package/dist/runtime/components/form/FormFieldSelect.vue.d.ts +26 -0
  34. package/dist/runtime/components/form/FormFieldText.vue +56 -0
  35. package/dist/runtime/components/form/FormFieldText.vue.d.ts +16 -0
  36. package/dist/runtime/components/form/FormFieldToggleSwitch.vue +47 -0
  37. package/dist/runtime/components/form/FormFieldToggleSwitch.vue.d.ts +15 -0
  38. package/dist/runtime/components/form/FormLabelInputPair.vue +42 -0
  39. package/dist/runtime/components/form/FormLabelInputPair.vue.d.ts +22 -0
  40. package/dist/runtime/components/form/FormSubmitButton.vue +39 -0
  41. package/dist/runtime/components/form/FormSubmitButton.vue.d.ts +6 -0
  42. package/dist/runtime/components/form/FormValidationMessage.vue +24 -0
  43. package/dist/runtime/components/form/FormValidationMessage.vue.d.ts +15 -0
  44. package/dist/runtime/components/form/element/FormElementSelectOptions.vue +250 -0
  45. package/dist/runtime/components/form/element/FormElementSelectOptions.vue.d.ts +13 -0
  46. package/dist/runtime/composables/use-load-image.js +1 -0
  47. package/dist/runtime/composables/use-notification.d.ts +18 -11
  48. package/dist/runtime/composables/use-notification.js +27 -27
  49. package/dist/runtime/composables/use-resee-ux.d.ts +24 -0
  50. package/dist/runtime/composables/use-resee-ux.js +22 -0
  51. package/dist/runtime/constants.d.ts +3 -0
  52. package/dist/runtime/constants.js +3 -0
  53. package/dist/runtime/server/plugins/teleport-targets.d.ts +3 -0
  54. package/dist/runtime/server/plugins/teleport-targets.js +6 -0
  55. package/dist/runtime/theme/css/brand/form.css +1 -0
  56. package/dist/runtime/theme/css/brand/menu.css +1 -0
  57. package/dist/runtime/theme/css/brand/mobile.css +1 -0
  58. package/dist/runtime/theme/css/brand/transition.css +1 -1
  59. package/dist/runtime/theme/css/brand/utilities.css +1 -1
  60. package/dist/runtime/theme/css/styles.css +1 -1
  61. package/dist/runtime/types/form.d.ts +23 -0
  62. package/dist/runtime/types/form.js +0 -0
  63. package/dist/runtime/utils/dom.d.ts +9 -0
  64. package/dist/runtime/utils/dom.js +25 -0
  65. package/dist/runtime/utils/form.d.ts +34 -0
  66. package/dist/runtime/utils/form.js +34 -0
  67. package/dist/runtime/utils/string.d.ts +6 -0
  68. package/dist/runtime/utils/string.js +3 -0
  69. package/dist/runtime/utils/validation.d.ts +21 -0
  70. package/dist/runtime/utils/validation.js +56 -0
  71. 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,3 @@
1
+ export function swapStringPlaceholders(target, placeholders) {
2
+ return placeholders ? target.replace(/\{\s*(\w+?)\s*}/g, (_, token) => String(placeholders[token] || "")) : target;
3
+ }
@@ -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.4.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": "^2.6.5",
52
- "@nuxt/eslint": "^1.9.0",
53
- "@nuxt/eslint-config": "^1.9.0",
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.19.2",
58
- "@release-it/conventional-changelog": "^10.0.1",
59
- "@types/node": "^22.18.8",
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": "^10.0.0",
64
- "eslint": "^9.36.0",
65
- "happy-dom": "^18.0.1",
66
- "nuxt": "^4.1.2",
67
- "release-it": "^19.0.5",
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.0"
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.53",
76
- "@iconify-json/solar": "^1.2.4",
77
- "@nuxt/fonts": "^0.11.4",
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/nuxt-module": "^4.4.0",
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.14",
82
- "@tailwindcss/vite": "^4.1.14",
83
- "@vueuse/core": "^13.9.0",
84
- "primevue": "^4.4.0",
85
- "tailwindcss": "^4.1.14"
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
  }