UNPKG

bootstrap-vue-next

Version:

Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development

1 lines 11.6 kB
{"version":3,"file":"BForm-IL7Rf_27.mjs","names":[],"sources":["../src/components/BForm/BFormDatalistBase.vue","../src/components/BForm/BFormDatalistBase.vue","../src/components/BForm/BFormDatalist.vue","../src/components/BForm/BFormDatalist.vue","../src/components/BForm/BFormFloatingLabel.vue","../src/components/BForm/BFormFloatingLabel.vue"],"sourcesContent":["<template>\n <datalist :id=\"computedId\">\n <slot name=\"first\" />\n <BFormSelectOption\n v-for=\"(option, index) in normalizedOptsWrapper\"\n :key=\"index\"\n v-bind=\"option\"\n >\n <slot name=\"option\" v-bind=\"option\">\n {{ 'text' in option ? option.text : '' }}\n </slot>\n </BFormSelectOption>\n <slot />\n </datalist>\n</template>\n\n<script setup lang=\"ts\">\nimport type {BFormDatalistBaseProps} from '../../types/ComponentProps'\nimport {computed} from 'vue'\nimport BFormSelectOption from '../BFormSelect/BFormSelectOption.vue'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {useId} from '../../composables/useId'\nimport {useFormSelect} from '../../composables/useFormSelect'\n\n/**\n * Base component for BFormDatalist - non-generic implementation using useDefaults.\n * Renders a datalist element with normalized options.\n * Filters out complex/grouped options as datalist doesn't support them.\n */\nconst _props = withDefaults(defineProps<BFormDatalistBaseProps>(), {\n disabled: false,\n disabledField: 'disabled',\n id: undefined,\n options: () => [],\n textField: 'text',\n valueField: 'value',\n})\nconst props = useDefaults(_props, 'BFormDatalist')\n\nconst computedId = useId(() => props.id, 'datalist')\n\nconst {normalizedOptions, isComplex} = useFormSelect(\n () => props.options,\n computed(() => ({...props, optionsField: 'options', labelField: 'label'}))\n)\n\nconst normalizedOptsWrapper = computed(() =>\n // Datalist doesn't support complex options\n normalizedOptions.value.filter((opt) => !isComplex(opt))\n)\n</script>\n","<template>\n <datalist :id=\"computedId\">\n <slot name=\"first\" />\n <BFormSelectOption\n v-for=\"(option, index) in normalizedOptsWrapper\"\n :key=\"index\"\n v-bind=\"option\"\n >\n <slot name=\"option\" v-bind=\"option\">\n {{ 'text' in option ? option.text : '' }}\n </slot>\n </BFormSelectOption>\n <slot />\n </datalist>\n</template>\n\n<script setup lang=\"ts\">\nimport type {BFormDatalistBaseProps} from '../../types/ComponentProps'\nimport {computed} from 'vue'\nimport BFormSelectOption from '../BFormSelect/BFormSelectOption.vue'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {useId} from '../../composables/useId'\nimport {useFormSelect} from '../../composables/useFormSelect'\n\n/**\n * Base component for BFormDatalist - non-generic implementation using useDefaults.\n * Renders a datalist element with normalized options.\n * Filters out complex/grouped options as datalist doesn't support them.\n */\nconst _props = withDefaults(defineProps<BFormDatalistBaseProps>(), {\n disabled: false,\n disabledField: 'disabled',\n id: undefined,\n options: () => [],\n textField: 'text',\n valueField: 'value',\n})\nconst props = useDefaults(_props, 'BFormDatalist')\n\nconst computedId = useId(() => props.id, 'datalist')\n\nconst {normalizedOptions, isComplex} = useFormSelect(\n () => props.options,\n computed(() => ({...props, optionsField: 'options', labelField: 'label'}))\n)\n\nconst normalizedOptsWrapper = computed(() =>\n // Datalist doesn't support complex options\n normalizedOptions.value.filter((opt) => !isComplex(opt))\n)\n</script>\n","<template>\n <BFormDatalistBase v-bind=\"forwardedProps\" :options=\"normalizedOptions as any\">\n <!-- Forward all slots -->\n <template #first>\n <slot name=\"first\" />\n </template>\n\n <template #option=\"slotProps\">\n <slot name=\"option\" v-bind=\"slotProps as any\" />\n </template>\n\n <slot />\n </BFormDatalistBase>\n</template>\n\n<script\n setup\n lang=\"ts\"\n generic=\"\n Item = Record<string, unknown> | string | number | boolean,\n ValueKey extends Item extends Record<string, unknown> ? keyof Item : string =\n Item extends Record<string, unknown> ? keyof Item : never\n \"\n>\nimport type {BFormDatalistProps} from '../../types/ComponentProps'\nimport {computed} from 'vue'\nimport BFormDatalistBase from './BFormDatalistBase.vue'\nimport type {SelectOption} from '../../types/SelectTypes'\nimport type {BFormDatalistSlots} from '../../types'\n\n/**\n * Type-safe wrapper component for BFormDatalist.\n * Provides generic type safety for options and field names.\n * Normalizes typed options and forwards to BFormDatalistBase for rendering.\n * Supports both complex objects and simple scalar types (string, number).\n */\nconst props = withDefaults(defineProps<BFormDatalistProps<Item, ValueKey>>(), {\n disabled: false,\n disabledField: 'disabled' as keyof Item & string,\n id: undefined,\n options: () => [],\n textField: 'text' as keyof Item & string,\n // @ts-expect-error - ValueKey default doesn't satisfy InferDefault but works at runtime\n valueField: 'value',\n})\ndefineSlots<\n BFormDatalistSlots<Item extends Record<string, unknown> ? Item[ValueKey & keyof Item] : Item>\n>()\n\n// Type-safe normalization of options\nconst normalizedOptions = computed(() =>\n props.options.map((el) => {\n if (typeof el === 'string') {\n return el\n }\n if (typeof el === 'number') {\n return String(el)\n }\n if (typeof el === 'boolean') {\n return String(el)\n }\n return {\n value: (el as Record<string, unknown>)[props.valueField as string],\n text:\n ((el as Record<string, unknown>)[props.textField as string] as string | undefined) ?? '',\n disabled:\n ((el as Record<string, unknown>)[props.disabledField as string] as boolean | undefined) ??\n false,\n } as SelectOption\n })\n)\n\n// Forward all props except options (which we normalize) and field mappings (already used)\nconst forwardedProps = computed(() => ({\n disabled: props.disabled,\n id: props.id,\n}))\n</script>\n","<template>\n <BFormDatalistBase v-bind=\"forwardedProps\" :options=\"normalizedOptions as any\">\n <!-- Forward all slots -->\n <template #first>\n <slot name=\"first\" />\n </template>\n\n <template #option=\"slotProps\">\n <slot name=\"option\" v-bind=\"slotProps as any\" />\n </template>\n\n <slot />\n </BFormDatalistBase>\n</template>\n\n<script\n setup\n lang=\"ts\"\n generic=\"\n Item = Record<string, unknown> | string | number | boolean,\n ValueKey extends Item extends Record<string, unknown> ? keyof Item : string =\n Item extends Record<string, unknown> ? keyof Item : never\n \"\n>\nimport type {BFormDatalistProps} from '../../types/ComponentProps'\nimport {computed} from 'vue'\nimport BFormDatalistBase from './BFormDatalistBase.vue'\nimport type {SelectOption} from '../../types/SelectTypes'\nimport type {BFormDatalistSlots} from '../../types'\n\n/**\n * Type-safe wrapper component for BFormDatalist.\n * Provides generic type safety for options and field names.\n * Normalizes typed options and forwards to BFormDatalistBase for rendering.\n * Supports both complex objects and simple scalar types (string, number).\n */\nconst props = withDefaults(defineProps<BFormDatalistProps<Item, ValueKey>>(), {\n disabled: false,\n disabledField: 'disabled' as keyof Item & string,\n id: undefined,\n options: () => [],\n textField: 'text' as keyof Item & string,\n // @ts-expect-error - ValueKey default doesn't satisfy InferDefault but works at runtime\n valueField: 'value',\n})\ndefineSlots<\n BFormDatalistSlots<Item extends Record<string, unknown> ? Item[ValueKey & keyof Item] : Item>\n>()\n\n// Type-safe normalization of options\nconst normalizedOptions = computed(() =>\n props.options.map((el) => {\n if (typeof el === 'string') {\n return el\n }\n if (typeof el === 'number') {\n return String(el)\n }\n if (typeof el === 'boolean') {\n return String(el)\n }\n return {\n value: (el as Record<string, unknown>)[props.valueField as string],\n text:\n ((el as Record<string, unknown>)[props.textField as string] as string | undefined) ?? '',\n disabled:\n ((el as Record<string, unknown>)[props.disabledField as string] as boolean | undefined) ??\n false,\n } as SelectOption\n })\n)\n\n// Forward all props except options (which we normalize) and field mappings (already used)\nconst forwardedProps = computed(() => ({\n disabled: props.disabled,\n id: props.id,\n}))\n</script>\n","<template>\n <div class=\"form-floating\">\n <slot />\n <label :for=\"props.labelFor\">\n <slot name=\"label\">\n {{ props.label }}\n </slot>\n </label>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport type {BFormFloatingLabelSlots} from '../../types'\nimport {useDefaults} from '../../composables/useDefaults'\nimport type {BFormFloatingLabelProps} from '../../types/ComponentProps'\n\nconst _props = withDefaults(defineProps<BFormFloatingLabelProps>(), {\n label: undefined,\n labelFor: undefined,\n text: undefined,\n})\nconst props = useDefaults(_props, 'BFormFloatingLabel')\ndefineSlots<BFormFloatingLabelSlots>()\n</script>\n","<template>\n <div class=\"form-floating\">\n <slot />\n <label :for=\"props.labelFor\">\n <slot name=\"label\">\n {{ props.label }}\n </slot>\n </label>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport type {BFormFloatingLabelSlots} from '../../types'\nimport {useDefaults} from '../../composables/useDefaults'\nimport type {BFormFloatingLabelProps} from '../../types/ComponentProps'\n\nconst _props = withDefaults(defineProps<BFormFloatingLabelProps>(), {\n label: undefined,\n labelFor: undefined,\n text: undefined,\n})\nconst props = useDefaults(_props, 'BFormFloatingLabel')\ndefineSlots<BFormFloatingLabelSlots>()\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAqCA,MAAM,QAAQ,YARC,SAQmB,gBAAe;EAEjD,MAAM,aAAa,cAAY,MAAM,IAAI,WAAU;EAEnD,MAAM,EAAC,mBAAmB,cAAa,oBAC/B,MAAM,SACZ,gBAAgB;GAAC,GAAG;GAAO,cAAc;GAAW,YAAY;GAAQ,EAAC,CAC3E;EAEA,MAAM,wBAAwB,eAE5B,kBAAkB,MAAM,QAAQ,QAAQ,CAAC,UAAU,IAAI,CAAA,CACzD;;uBAhDE,mBAYW,YAAA,EAZA,IAAI,MAAA,WAAU,EAAA,EAAA;IACvB,WAAqB,KAAA,QAAA,QAAA;sBACrB,mBAQoB,UAAA,MAAA,WAPQ,sBAAA,QAAlB,QAAQ,UAAK;yBADvB,YAQoB,2BARpB,WAQoB,EANjB,KAAK,OAAK,EAAA,EAAA,SAAA,MAAA,EACH,OAAM,EAAA;6BAIP,CAFP,WAEO,KAAA,QAAA,UAFP,WAEO,EAAA,SAAA,MAAA,EAFqB,OAAM,QAE3B,CAAA,gBAAA,gBAAA,UADQ,SAAS,OAAO,OAAI,GAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA;;;;IAGrC,WAAQ,KAAA,QAAA,UAAA;;;;;;;;;;;;;;;;;;;;;EEwBZ,MAAM,QAAQ;EAcd,MAAM,oBAAoB,eACxB,MAAM,QAAQ,KAAK,OAAO;AACxB,OAAI,OAAO,OAAO,SAChB,QAAO;AAET,OAAI,OAAO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