diff --git a/lib/basic/index.styl b/lib/basic/index.styl index 6297720..42fe32f 100644 --- a/lib/basic/index.styl +++ b/lib/basic/index.styl @@ -1,7 +1,8 @@ @require "./oui-card.styl"; +@require "./oui-checkbox.styl"; +@require "./oui-file.styl"; @require "./oui-form-item.styl"; @require "./oui-form.styl"; -@require "./oui-file.styl"; @require "./oui-input-group.styl"; @require "./oui-log.styl"; @require "./oui-notice.styl"; diff --git a/lib/basic/oui-checkbox.styl b/lib/basic/oui-checkbox.styl new file mode 100644 index 0000000..31436bb --- /dev/null +++ b/lib/basic/oui-checkbox.styl @@ -0,0 +1,8 @@ +@require "../../stylus/index.styl"; + +.oui-form-item-checkbox { + &._disabled { + color: var(--s2-fg); + cursor: not-allowed; + } +} \ No newline at end of file diff --git a/lib/basic/oui-checkbox.vue b/lib/basic/oui-checkbox.vue index f4ed0ab..c00dfa7 100644 --- a/lib/basic/oui-checkbox.vue +++ b/lib/basic/oui-checkbox.vue @@ -2,6 +2,7 @@ import { computed } from 'vue' import './oui-form.styl' +import './oui-checkbox.styl' defineOptions({ inheritAttrs: false, @@ -40,7 +41,7 @@ const klass = computed(() => { diff --git a/lib/basic/oui-file.styl b/lib/basic/oui-file.styl index cdb8a42..d53488d 100644 --- a/lib/basic/oui-file.styl +++ b/lib/basic/oui-file.styl @@ -30,4 +30,9 @@ color: var(--p1-fg); border-color: var(--input-border-hover); } + + &._disabled { + color: var(--s2-fg); + cursor: not-allowed; + } } \ No newline at end of file diff --git a/lib/basic/oui-file.vue b/lib/basic/oui-file.vue index 8e15040..283a6dc 100644 --- a/lib/basic/oui-file.vue +++ b/lib/basic/oui-file.vue @@ -20,11 +20,13 @@ const props = withDefaults(defineProps<{ accept?: string // multiple?: boolean // preview?: boolean + disabled?: boolean required?: boolean id?: string }>(), { accept: 'image/*', multiple: false, + disabled: false, }) // const emit = defineEmits<{ @@ -35,10 +37,6 @@ const log: LoggerInterface = Logger('oui-file') const dropZoneRef = ref() -// const filename = ref() -// const filesize = ref() -// const filetype = ref() - const model = defineModel({ required: true }) const modelFilename = defineModel('filename', { required: false }) @@ -52,9 +50,6 @@ async function fileToDataURI(file: File): Promise { const datauri = await promise if (datauri) { modelFilename.value = file.name - // filesize.value = `${(file.size / 1024).toFixed(2)} KB` - // filetype.value = file.type - // return `${datauri}?type=${encodeURIComponent(file.type)}&name=${encodeURIComponent(file.name)}&size=${file.size}` } return datauri } @@ -79,6 +74,9 @@ const { files, open, reset, onChange } = useFileDialog({ }) onChange(async () => { + if (props.disabled) { + return + } const file = files.value?.[0] if (file) { const url = await fileToDataURI(file) @@ -89,6 +87,9 @@ onChange(async () => { }) function doSelect() { + if (props.disabled) { + return + } log('select') open() } @@ -96,7 +97,7 @@ function doSelect() {