Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion resources/js/components/fieldtypes/IconFieldtype.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { Button, Combobox, Icon, Input, Modal } from '@/components/ui';

const emit = defineEmits(Fieldtype.emits);
const props = defineProps(Fieldtype.props);
const { isReadOnly, update } = Fieldtype.use(emit, props);
const { isReadOnly, update, expose } = Fieldtype.use(emit, props);
defineExpose(expose);

const icons = ref([]);
const loading = ref(true);
Expand Down
3 changes: 2 additions & 1 deletion resources/js/components/fieldtypes/SelectFieldtype.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import { computed } from 'vue';

const emit = defineEmits(Fieldtype.emits);
const props = defineProps(Fieldtype.props);
const { isReadOnly, defineReplicatorPreview, update } = Fieldtype.use(emit, props);
const { isReadOnly, defineReplicatorPreview, update, expose } = Fieldtype.use(emit, props);
defineExpose(expose);

const selectedOptions = computed(() => {
let selections = props.value === null ? [] : props.value;
Expand Down
22 changes: 22 additions & 0 deletions resources/js/tests/components/fieldtypes/SelectFieldtype.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { mount } from '@vue/test-utils';
import { expect, test } from 'vitest';
import { h, ref } from 'vue';
import SelectFieldtype from '@/components/fieldtypes/SelectFieldtype.vue';

window.__ = (key) => key;

test('replicator preview is exposed to the parent field', () => {
const fieldtype = ref();

mount(() =>
h(SelectFieldtype, {
ref: fieldtype,
value: 'two',
handle: 'select',
config: { options: { one: 'One', two: 'Two' } },
showFieldPreviews: true,
}),
);

expect(fieldtype.value.replicatorPreview).toBe('Two');
});
Loading