@resee-movies/nuxt-ux 0.4.1 → 0.6.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 (75) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +9 -2
  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 +0 -1
  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/ToggleButton.vue +45 -0
  27. package/dist/runtime/components/ToggleButton.vue.d.ts +30 -0
  28. package/dist/runtime/components/form/Form.vue +79 -0
  29. package/dist/runtime/components/form/Form.vue.d.ts +35 -0
  30. package/dist/runtime/components/form/FormField.vue +96 -0
  31. package/dist/runtime/components/form/FormField.vue.d.ts +42 -0
  32. package/dist/runtime/components/form/FormFieldCheckbox.vue +56 -0
  33. package/dist/runtime/components/form/FormFieldCheckbox.vue.d.ts +17 -0
  34. package/dist/runtime/components/form/FormFieldSelect.vue +86 -0
  35. package/dist/runtime/components/form/FormFieldSelect.vue.d.ts +40 -0
  36. package/dist/runtime/components/form/FormFieldSelectButton.vue +76 -0
  37. package/dist/runtime/components/form/FormFieldSelectButton.vue.d.ts +16 -0
  38. package/dist/runtime/components/form/FormFieldText.vue +56 -0
  39. package/dist/runtime/components/form/FormFieldText.vue.d.ts +16 -0
  40. package/dist/runtime/components/form/FormFieldToggleSwitch.vue +47 -0
  41. package/dist/runtime/components/form/FormFieldToggleSwitch.vue.d.ts +15 -0
  42. package/dist/runtime/components/form/FormLabelInputPair.vue +42 -0
  43. package/dist/runtime/components/form/FormLabelInputPair.vue.d.ts +22 -0
  44. package/dist/runtime/components/form/FormSubmitButton.vue +26 -0
  45. package/dist/runtime/components/form/FormSubmitButton.vue.d.ts +8 -0
  46. package/dist/runtime/components/form/FormValidationMessage.vue +24 -0
  47. package/dist/runtime/components/form/FormValidationMessage.vue.d.ts +15 -0
  48. package/dist/runtime/components/form/element/FormElementSelectButton.vue +110 -0
  49. package/dist/runtime/components/form/element/FormElementSelectButton.vue.d.ts +33 -0
  50. package/dist/runtime/components/form/element/FormElementSelectOptions.vue +256 -0
  51. package/dist/runtime/components/form/element/FormElementSelectOptions.vue.d.ts +24 -0
  52. package/dist/runtime/composables/use-load-image.js +1 -0
  53. package/dist/runtime/composables/use-resee-ux.d.ts +25 -0
  54. package/dist/runtime/composables/use-resee-ux.js +23 -0
  55. package/dist/runtime/constants.d.ts +3 -0
  56. package/dist/runtime/constants.js +3 -0
  57. package/dist/runtime/server/plugins/teleport-targets.d.ts +3 -0
  58. package/dist/runtime/server/plugins/teleport-targets.js +6 -0
  59. package/dist/runtime/theme/css/brand/form.css +3 -0
  60. package/dist/runtime/theme/css/brand/menu.css +1 -0
  61. package/dist/runtime/theme/css/brand/mobile.css +1 -0
  62. package/dist/runtime/theme/css/brand/transition.css +1 -1
  63. package/dist/runtime/theme/css/brand/utilities.css +1 -1
  64. package/dist/runtime/theme/css/styles.css +1 -1
  65. package/dist/runtime/types/form.d.ts +23 -0
  66. package/dist/runtime/types/form.js +0 -0
  67. package/dist/runtime/utils/dom.d.ts +9 -0
  68. package/dist/runtime/utils/dom.js +25 -0
  69. package/dist/runtime/utils/form.d.ts +34 -0
  70. package/dist/runtime/utils/form.js +34 -0
  71. package/dist/runtime/utils/string.d.ts +6 -0
  72. package/dist/runtime/utils/string.js +3 -0
  73. package/dist/runtime/utils/validation.d.ts +21 -0
  74. package/dist/runtime/utils/validation.js +56 -0
  75. package/package.json +26 -24
@@ -0,0 +1,45 @@
1
+ <template>
2
+ <Button
3
+ :text = "currentText"
4
+ :icon = "currentIcon"
5
+ :aria-pressed = "pressed"
6
+ @click = "handleClick"
7
+ >
8
+ <template #default v-if="slots.default">
9
+ <slot />
10
+ </template>
11
+ </Button>
12
+ </template>
13
+
14
+ <script>
15
+
16
+ </script>
17
+
18
+ <script setup>
19
+ import { computed, useSlots, watch } from "vue";
20
+ import Button from "./Button.vue";
21
+ const props = defineProps({
22
+ onIcon: { type: String, required: false, default: void 0 },
23
+ offIcon: { type: String, required: false, default: void 0 },
24
+ onText: { type: String, required: false, default: void 0 },
25
+ offText: { type: String, required: false, default: void 0 }
26
+ });
27
+ const emits = defineEmits(["click", "change"]);
28
+ const pressed = defineModel("pressed", { type: Boolean, ...{ default: false } });
29
+ const slots = useSlots();
30
+ const currentText = computed(() => {
31
+ return pressed.value ? props.onText ?? props.text : props.offText ?? props.text;
32
+ });
33
+ const currentIcon = computed(() => {
34
+ return pressed.value ? props.onIcon ?? props.icon : props.offIcon ?? props.icon;
35
+ });
36
+ watch(pressed, (newVal, oldVal) => {
37
+ if (newVal !== oldVal) {
38
+ emits("change", newVal);
39
+ }
40
+ });
41
+ function handleClick() {
42
+ pressed.value = !pressed.value;
43
+ emits("click", pressed.value);
44
+ }
45
+ </script>
@@ -0,0 +1,30 @@
1
+ import type { ButtonProps } from './Button.vue.js';
2
+ export interface ToggleButtonProps extends /* @vue-ignore */ Omit<ButtonProps, 'onClick' | 'trailingIcon' | 'trailingIconSize'> {
3
+ onIcon?: string;
4
+ offIcon?: string;
5
+ onText?: string;
6
+ offText?: string;
7
+ }
8
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ToggleButtonProps & {
9
+ pressed?: boolean;
10
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
11
+ "update:pressed": (value: boolean) => any;
12
+ } & {
13
+ change: (pressed: boolean) => any;
14
+ click: (pressed: boolean) => any;
15
+ }, string, import("vue").PublicProps, Readonly<ToggleButtonProps & {
16
+ pressed?: boolean;
17
+ }> & Readonly<{
18
+ onChange?: ((pressed: boolean) => any) | undefined;
19
+ onClick?: ((pressed: boolean) => any) | undefined;
20
+ "onUpdate:pressed"?: ((value: boolean) => any) | undefined;
21
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
22
+ default?: (props: {}) => any;
23
+ }>;
24
+ declare const _default: typeof __VLS_export;
25
+ export default _default;
26
+ type __VLS_WithSlots<T, S> = T & {
27
+ new (): {
28
+ $slots: S;
29
+ };
30
+ };
@@ -0,0 +1,79 @@
1
+ <template>
2
+ <PrimeForm
3
+ v-slot = "$form"
4
+ ref = "form"
5
+ novalidate = "true"
6
+ :validate-on-mount = "true"
7
+ :validate-on-submit = "true"
8
+ :validate-on-value-update = "true"
9
+ :validate-on-blur = "false"
10
+ :initial-values = "props.initialValues"
11
+ :aria-disabled = "props.disabled"
12
+ @submit = "handleFormSubmit"
13
+ >
14
+ <slot :state="$form" />
15
+ </PrimeForm>
16
+ </template>
17
+
18
+ <script>
19
+ export * from "../../types/form";
20
+ </script>
21
+
22
+ <script setup>
23
+ import PrimeForm, {} from "@primevue/forms/form";
24
+ import { toNonNullableArray } from "@resee-movies/utilities/arrays/to-non-nullable-array";
25
+ import { isPromiseLike } from "@resee-movies/utilities/objects/is-promise-like";
26
+ import { syncRefs, watchDebounced } from "@vueuse/core";
27
+ import { useTemplateRef, watchEffect } from "vue";
28
+ import { provideFormInstance, getValuesFromFormState } from "../../utils/form";
29
+ const props = defineProps({
30
+ disabled: { type: Boolean, required: false },
31
+ initialValues: { type: Object, required: false },
32
+ onSubmit: { type: [Function, Array], required: false },
33
+ onChange: { type: Function, required: false },
34
+ onChangeDebounce: { type: Number, required: false, default: 32 }
35
+ });
36
+ defineEmits(["submit", "change"]);
37
+ const formInstance = provideFormInstance();
38
+ syncRefs(() => props.disabled, formInstance.isDisabled);
39
+ const form = useTemplateRef("form");
40
+ let oldValues = void 0;
41
+ const changeHandles = watchDebounced(
42
+ () => form.value?.states,
43
+ (newState) => {
44
+ const newValues = newState ? getValuesFromFormState(newState) : null;
45
+ const stringify = JSON.stringify(newValues);
46
+ if (stringify !== oldValues) {
47
+ props.onChange?.(newValues);
48
+ oldValues = stringify;
49
+ }
50
+ },
51
+ {
52
+ debounce: props.onChangeDebounce,
53
+ deep: 2
54
+ }
55
+ );
56
+ watchEffect(() => {
57
+ changeHandles[props.onChange ? "resume" : "pause"]();
58
+ });
59
+ async function handleFormSubmit(event) {
60
+ if (props.disabled) {
61
+ return;
62
+ }
63
+ formInstance.hasSubmitted.value = true;
64
+ if (!event.valid) {
65
+ return;
66
+ }
67
+ if (props.onSubmit) {
68
+ const handlers = toNonNullableArray(props.onSubmit);
69
+ const values = getValuesFromFormState(event.states);
70
+ const newEvent = { ...event, values };
71
+ const results = handlers.map((handler) => handler(newEvent));
72
+ if (!!results.find((result) => isPromiseLike(result))) {
73
+ formInstance.isSubmitting.value = true;
74
+ await Promise.allSettled(results);
75
+ formInstance.isSubmitting.value = false;
76
+ }
77
+ }
78
+ }
79
+ </script>
@@ -0,0 +1,35 @@
1
+ import type { FormValues, FormSubmitHandler, FormSubmitEvent } from '../../types/form.js';
2
+ export * from '../../types/form.js';
3
+ export interface FormProps<T extends FormValues = FormValues> {
4
+ disabled?: boolean;
5
+ initialValues?: Record<string, unknown>;
6
+ onSubmit?: FormSubmitHandler<T> | FormSubmitHandler<T>[];
7
+ onChange?: (values: T | null) => void;
8
+ onChangeDebounce?: number;
9
+ }
10
+ declare const __VLS_export: <T extends FormValues>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
11
+ props: __VLS_PrettifyLocal<FormProps<T> & __VLS_EmitsToProps<__VLS_NormalizeEmits<{
12
+ (e: "submit", evt: FormSubmitEvent<T>): (void | Promise<void>);
13
+ (e: "change", values: T): void;
14
+ }>>> & import("vue").PublicProps & (typeof globalThis extends {
15
+ __VLS_PROPS_FALLBACK: infer P;
16
+ } ? P : {});
17
+ expose: (exposed: {}) => void;
18
+ attrs: any;
19
+ slots: {
20
+ default?: (props: {
21
+ state: any;
22
+ }) => any;
23
+ };
24
+ emit: {
25
+ (e: "submit", evt: FormSubmitEvent<T>): (void | Promise<void>);
26
+ (e: "change", values: T): void;
27
+ };
28
+ }>) => import("vue").VNode & {
29
+ __ctx?: Awaited<typeof __VLS_setup>;
30
+ };
31
+ declare const _default: typeof __VLS_export;
32
+ export default _default;
33
+ type __VLS_PrettifyLocal<T> = {
34
+ [K in keyof T as K]: T[K];
35
+ } & {};
@@ -0,0 +1,96 @@
1
+ <template>
2
+ <PrimeFormField
3
+ v-slot = "$field"
4
+ :as = "props.is"
5
+ :name = "props.name"
6
+ :resolver = "validatorFunction"
7
+ :initial-value = "props.initialValue"
8
+ :class = "['input-field', props.class, { disabled: isDisabled, readonly: isReadonly, required: props.required }]"
9
+ >
10
+ <FormLabelInputPair
11
+ :input-id = "inputId"
12
+ :label-id = "labelId"
13
+ :label-text = "labelText"
14
+ :label-position = "props.labelPosition"
15
+ :label-sr-only = "props.labelSrOnly"
16
+ :disabled = "isDisabled && !isReadonly"
17
+ :required = "props.required"
18
+ :faux-label = "props.fauxLabel"
19
+ >
20
+ <template #label>
21
+ <slot name="label" />
22
+ </template>
23
+
24
+ <template #input>
25
+ <slot
26
+ name = "default"
27
+ :input-name = "props.name"
28
+ :input-id = "inputId"
29
+ :label-id = "labelId"
30
+ :label-text = "labelText"
31
+ :message-id = "$field.error ? messageId : void 0"
32
+ :disabled = "isDisabled"
33
+ :readonly = "isReadonly"
34
+ :invalid = "$field.invalid"
35
+ :on-blur = "$field.props.onBlur"
36
+ :on-change = "$field.props.onChange"
37
+ :on-input = "$field.props.onInput"
38
+ :on-invalid = "$field.props.onInvalid"
39
+ />
40
+ </template>
41
+ </FormLabelInputPair>
42
+
43
+ <FormValidationMessage
44
+ v-if = "$field.error"
45
+ :id = "messageId"
46
+ :visible = "$field.touched || formState.hasSubmitted.value"
47
+ :message = "$field.error.message"
48
+ />
49
+ </PrimeFormField>
50
+ </template>
51
+
52
+ <script>
53
+ import { computed } from "vue";
54
+ </script>
55
+
56
+ <script setup>
57
+ import PrimeFormField, {} from "@primevue/forms/formfield";
58
+ import { humanize } from "@resee-movies/utilities/strings/humanize";
59
+ import { useId } from "vue";
60
+ import { injectFormInstance } from "../../utils/form";
61
+ import FormLabelInputPair from "./FormLabelInputPair.vue";
62
+ import FormValidationMessage from "./FormValidationMessage.vue";
63
+ defineOptions({
64
+ inheritAttrs: false
65
+ });
66
+ const props = defineProps({
67
+ name: { type: String, required: true },
68
+ label: { type: String, required: false, default: void 0 },
69
+ is: { type: String, required: false, default: "div" },
70
+ initialValue: { type: null, required: false, default: void 0 },
71
+ required: { type: Boolean, required: false, default: false },
72
+ disabled: { type: Boolean, required: false, default: false },
73
+ readonly: { type: Boolean, required: false, default: false },
74
+ fauxLabel: { type: Boolean, required: false },
75
+ labelSrOnly: { type: Boolean, required: false },
76
+ labelPosition: { type: String, required: false },
77
+ validator: { type: Function, required: false, default: void 0 },
78
+ class: { type: null, required: false }
79
+ });
80
+ const formState = injectFormInstance();
81
+ const inputId = useId();
82
+ const labelId = `${inputId}_label`;
83
+ const messageId = `${inputId}_message`;
84
+ const labelText = computed(() => props.label ?? humanize(props.name));
85
+ const isDisabled = computed(() => props.disabled || formState.isDisabled.value);
86
+ const isReadonly = computed(() => props.readonly || formState.isSubmitting.value);
87
+ const validatorFunction = computed(() => {
88
+ return ({ value }) => {
89
+ const result = props?.validator?.(value, labelText.value)?.safeParse(value);
90
+ if (result?.error?.issues.length) {
91
+ return { errors: result.error.issues };
92
+ }
93
+ return void 0;
94
+ };
95
+ });
96
+ </script>
@@ -0,0 +1,42 @@
1
+ import type { ZodMiniType } from 'zod/mini';
2
+ import type { HintedString, HTMLElementClassNames } from '../../types/index.js';
3
+ import type { FormLabelInputPairProps } from './FormLabelInputPair.vue.js';
4
+ export interface FormFieldProps {
5
+ name: string;
6
+ label?: string;
7
+ is?: HintedString<'div'>;
8
+ initialValue?: unknown;
9
+ required?: boolean;
10
+ disabled?: boolean;
11
+ readonly?: boolean;
12
+ fauxLabel?: boolean;
13
+ labelSrOnly?: boolean;
14
+ labelPosition?: FormLabelInputPairProps['labelPosition'];
15
+ validator?: (value: unknown, label: string) => undefined | ZodMiniType;
16
+ class?: HTMLElementClassNames;
17
+ }
18
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<FormFieldProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FormFieldProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
19
+ label?: (props: {}) => any;
20
+ } & {
21
+ default?: (props: {
22
+ inputName: string;
23
+ inputId: any;
24
+ labelId: any;
25
+ labelText: any;
26
+ messageId: any;
27
+ disabled: any;
28
+ readonly: any;
29
+ invalid: any;
30
+ onBlur: any;
31
+ onChange: any;
32
+ onInput: any;
33
+ onInvalid: any;
34
+ }) => any;
35
+ }>;
36
+ declare const _default: typeof __VLS_export;
37
+ export default _default;
38
+ type __VLS_WithSlots<T, S> = T & {
39
+ new (): {
40
+ $slots: S;
41
+ };
42
+ };
@@ -0,0 +1,56 @@
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
+ <PrimeCheckbox
9
+ :input-id = "inputId"
10
+ :value = "props.value"
11
+ :true-value = "props.trueValue"
12
+ :false-value = "props.falseValue"
13
+ :binary = "props.binary"
14
+ :aria-describedby = "messageId"
15
+ :disabled = "disabled || readonly"
16
+ :readonly = "readonly"
17
+ class = "input-group"
18
+ >
19
+ <template #icon="{ checked }">
20
+ <Icon v-if="checked" name="i-ph-check-bold" />
21
+ </template>
22
+ </PrimeCheckbox>
23
+ </template>
24
+ </FormField>
25
+ </template>
26
+
27
+ <script>
28
+ import { computed } from "vue";
29
+ </script>
30
+
31
+ <script setup>
32
+ import PrimeCheckbox from "primevue/checkbox";
33
+ import { createBooleanValidator } from "../../utils/validation";
34
+ import FormField from "./FormField.vue";
35
+ import Icon from "../Icon.vue";
36
+ const props = defineProps({
37
+ value: { type: null, required: false, default: void 0 },
38
+ trueValue: { type: null, required: false, default: () => true },
39
+ falseValue: { type: null, required: false, default: () => false },
40
+ binary: { type: Boolean, required: false, default: () => true },
41
+ name: { type: String, required: true },
42
+ label: { type: String, required: false },
43
+ is: { type: String, required: false },
44
+ initialValue: { type: null, required: false, default: () => false },
45
+ required: { type: Boolean, required: false },
46
+ disabled: { type: Boolean, required: false },
47
+ readonly: { type: Boolean, required: false },
48
+ fauxLabel: { type: Boolean, required: false },
49
+ labelSrOnly: { type: Boolean, required: false },
50
+ labelPosition: { type: String, required: false, default: "after" },
51
+ class: { type: null, required: false }
52
+ });
53
+ const validatorFunction = computed(() => {
54
+ return () => createBooleanValidator({ required: props.required });
55
+ });
56
+ </script>
@@ -0,0 +1,17 @@
1
+ import type { FormFieldProps } from './FormField.vue.js';
2
+ export interface FormFieldCheckboxProps extends Omit<FormFieldProps, 'validator'> {
3
+ value?: unknown;
4
+ trueValue?: unknown;
5
+ falseValue?: unknown;
6
+ binary?: boolean;
7
+ }
8
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<FormFieldCheckboxProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FormFieldCheckboxProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
9
+ label?: (props: {}) => any;
10
+ }>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;
13
+ type __VLS_WithSlots<T, S> = T & {
14
+ new (): {
15
+ $slots: S;
16
+ };
17
+ };
@@ -0,0 +1,86 @@
1
+ <template>
2
+ <FormField v-bind="props" :validator="validatorFunction">
3
+ <template #label>
4
+ <slot name="label" />
5
+ </template>
6
+
7
+ <template #default="{ inputName, inputId, labelId, messageId, disabled, readonly }">
8
+ <FormElementSelectOptions
9
+ :name = "inputName"
10
+ :input-id = "inputId"
11
+ :label-id = "labelId"
12
+ :disabled = "disabled"
13
+ :readonly = "readonly"
14
+ :aria-describedby = "messageId"
15
+ :multiple = "props.multiple"
16
+ :options = "props.options"
17
+ :option-label = "props.optionLabel"
18
+ :option-value = "props.optionValue"
19
+ :option-disabled = "props.optionDisabled"
20
+ :data-key = "props.dataKey"
21
+ :placeholder = "props.placeholder"
22
+ :show-clear = "props.showClear"
23
+ :show-option-footer = "props.showOptionFilter"
24
+ :filter-placeholder = "props.filterPlaceholder"
25
+ :loading = "props.loading"
26
+ :selection-limit = "props.maxRequired"
27
+ >
28
+ <template #option="{ option, selected, index }" v-if="slots.option">
29
+ <slot
30
+ name = "option"
31
+ :option = "option"
32
+ :selected = "selected"
33
+ :index = "index"
34
+ />
35
+ </template>
36
+ </FormElementSelectOptions>
37
+ </template>
38
+ </FormField>
39
+ </template>
40
+
41
+ <script>
42
+ import {} from "./FormField.vue";
43
+ </script>
44
+
45
+ <script setup>
46
+ import { computed, useSlots } from "vue";
47
+ import { createBooleanValidator, createListValidator } from "../../utils/validation";
48
+ import FormField from "./FormField.vue";
49
+ import FormElementSelectOptions from "./element/FormElementSelectOptions.vue";
50
+ const props = defineProps({
51
+ options: { type: Array, required: false },
52
+ optionLabel: { type: String, required: false },
53
+ optionValue: { type: String, required: false },
54
+ optionDisabled: { type: String, required: false },
55
+ dataKey: { type: String, required: false },
56
+ placeholder: { type: String, required: false },
57
+ showClear: { type: Boolean, required: false, default: true },
58
+ showOptionFilter: { type: Boolean, required: false, default: void 0 },
59
+ filterPlaceholder: { type: String, required: false },
60
+ loading: { type: Boolean, required: false },
61
+ multiple: { type: Boolean, required: false, default: false },
62
+ minRequired: { type: [String, Number], required: false },
63
+ maxRequired: { type: [String, Number], required: false },
64
+ name: { type: String, required: true },
65
+ label: { type: String, required: false },
66
+ is: { type: String, required: false },
67
+ initialValue: { type: null, required: false },
68
+ required: { type: Boolean, required: false },
69
+ disabled: { type: Boolean, required: false },
70
+ readonly: { type: Boolean, required: false },
71
+ fauxLabel: { type: Boolean, required: false, default: true },
72
+ labelSrOnly: { type: Boolean, required: false },
73
+ labelPosition: { type: String, required: false },
74
+ class: { type: null, required: false }
75
+ });
76
+ const slots = useSlots();
77
+ const validatorFunction = computed(() => {
78
+ return props.multiple ? () => createListValidator({
79
+ required: props.required,
80
+ minRequired: props.minRequired,
81
+ maxRequired: props.maxRequired
82
+ }) : () => createBooleanValidator({
83
+ required: props.required
84
+ });
85
+ });
86
+ </script>
@@ -0,0 +1,40 @@
1
+ import { type FormFieldProps } from './FormField.vue.js';
2
+ export interface FormFieldSelectProps<T = unknown> extends Omit<FormFieldProps, 'validator'> {
3
+ options?: T[];
4
+ optionLabel?: string;
5
+ optionValue?: string;
6
+ optionDisabled?: string;
7
+ dataKey?: string;
8
+ placeholder?: string;
9
+ showClear?: boolean;
10
+ showOptionFilter?: boolean;
11
+ filterPlaceholder?: string;
12
+ loading?: boolean;
13
+ multiple?: boolean;
14
+ minRequired?: string | number;
15
+ maxRequired?: string | number;
16
+ }
17
+ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
18
+ props: __VLS_PrettifyLocal<FormFieldSelectProps<T>> & import("vue").PublicProps & (typeof globalThis extends {
19
+ __VLS_PROPS_FALLBACK: infer P;
20
+ } ? P : {});
21
+ expose: (exposed: {}) => void;
22
+ attrs: any;
23
+ slots: {
24
+ label?: (props: {}) => any;
25
+ } & {
26
+ option?: (props: {
27
+ option: T;
28
+ selected: any;
29
+ index: any;
30
+ }) => any;
31
+ };
32
+ emit: {};
33
+ }>) => import("vue").VNode & {
34
+ __ctx?: Awaited<typeof __VLS_setup>;
35
+ };
36
+ declare const _default: typeof __VLS_export;
37
+ export default _default;
38
+ type __VLS_PrettifyLocal<T> = {
39
+ [K in keyof T as K]: T[K];
40
+ } & {};
@@ -0,0 +1,76 @@
1
+ <template>
2
+ <FormField v-bind="props" :validator="validatorFunction">
3
+ <template #label>
4
+ <slot name="label" />
5
+ </template>
6
+
7
+ <template #default="{ labelId, messageId, invalid, disabled, readonly, onChange, onBlur }">
8
+ <FormElementSelectButton
9
+ :aria-labelledby = "labelId"
10
+ :aria-describedby = "messageId"
11
+ :aria-invalid = "invalid"
12
+ :disabled = "disabled"
13
+ :readonly = "readonly"
14
+ :options = "props.options"
15
+ :option-label = "props.optionLabel"
16
+ :option-icon = "props.optionIcon"
17
+ :option-value = "props.optionValue"
18
+ :option-disabled = "props.optionDisabled"
19
+ :option-data-key = "props.optionDataKey"
20
+ :icon-only = "props.iconOnly"
21
+ :multiple = "props.multiple"
22
+ :selection-limit = "props.maxRequired ? toInteger(props.maxRequired) : void 0"
23
+ @change = "onChange"
24
+ @focusout = "onBlur"
25
+ />
26
+ </template>
27
+ </FormField>
28
+ </template>
29
+
30
+ <script>
31
+ import {} from "./element/FormElementSelectButton.vue";
32
+ import {} from "./FormField.vue";
33
+ </script>
34
+
35
+ <script setup>
36
+ import { toInteger } from "@resee-movies/utilities/numbers/to-integer";
37
+ import { computed } from "vue";
38
+ import { createBooleanValidator, createListValidator } from "../../utils/validation";
39
+ import FormField from "./FormField.vue";
40
+ import FormElementSelectButton from "./element/FormElementSelectButton.vue";
41
+ const props = defineProps({
42
+ minRequired: { type: [String, Number], required: false },
43
+ maxRequired: { type: [String, Number], required: false },
44
+ name: { type: String, required: true },
45
+ label: { type: String, required: false },
46
+ is: { type: String, required: false },
47
+ initialValue: { type: null, required: false },
48
+ required: { type: Boolean, required: false },
49
+ disabled: { type: Boolean, required: false },
50
+ readonly: { type: Boolean, required: false },
51
+ fauxLabel: { type: Boolean, required: false, default: true },
52
+ labelSrOnly: { type: Boolean, required: false },
53
+ labelPosition: { type: String, required: false },
54
+ class: { type: null, required: false },
55
+ options: { type: Array, required: true },
56
+ optionLabel: { type: String, required: false },
57
+ optionIcon: { type: String, required: false },
58
+ optionValue: { type: String, required: false },
59
+ optionDisabled: { type: String, required: false },
60
+ optionDataKey: { type: String, required: false },
61
+ iconOnly: { type: Boolean, required: false, default: false },
62
+ multiple: { type: Boolean, required: false, default: false },
63
+ ariaLabelledby: { type: String, required: false },
64
+ ariaDescribedby: { type: String, required: false },
65
+ selectionLimit: { type: Number, required: false }
66
+ });
67
+ const validatorFunction = computed(() => {
68
+ return props.multiple ? () => createListValidator({
69
+ required: props.required,
70
+ minRequired: props.minRequired,
71
+ maxRequired: props.maxRequired
72
+ }) : () => createBooleanValidator({
73
+ required: props.required
74
+ });
75
+ });
76
+ </script>
@@ -0,0 +1,16 @@
1
+ import { type FormElementSelectButtonProps } from './element/FormElementSelectButton.vue.js';
2
+ import { type FormFieldProps } from './FormField.vue.js';
3
+ export interface FormFieldSelectButtonProps extends Omit<FormFieldProps, 'validator'>, FormElementSelectButtonProps {
4
+ minRequired?: string | number;
5
+ maxRequired?: string | number;
6
+ }
7
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<FormFieldSelectButtonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FormFieldSelectButtonProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
8
+ label?: (props: {}) => any;
9
+ }>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
12
+ type __VLS_WithSlots<T, S> = T & {
13
+ new (): {
14
+ $slots: S;
15
+ };
16
+ };