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(() => { - + {{ ' ' }} {{ title }} diff --git a/lib/basic/oui-datetime.vue b/lib/basic/oui-datetime.vue index 1f44adb..657d693 100644 --- a/lib/basic/oui-datetime.vue +++ b/lib/basic/oui-datetime.vue @@ -53,6 +53,12 @@ const date = computed({ :description="description" :required="required" > - + diff --git a/lib/basic/oui-file.demo.vue b/lib/basic/oui-file.demo.vue index 747a631..dff9144 100644 --- a/lib/basic/oui-file.demo.vue +++ b/lib/basic/oui-file.demo.vue @@ -1,5 +1,5 @@ @@ -21,6 +22,7 @@ const state = useLocalStorage('oui.demo.file', { :multiple="state.multiple" :title="state.title" :accept="state.accept" + :disabled="state.disabled" > Upload an image @@ -37,6 +39,7 @@ const state = useLocalStorage('oui.demo.file', { :title="state.title" :title-choose="state.titleChoose" :accept="state.accept" + :disabled="state.disabled" /> @@ -44,6 +47,6 @@ const state = useLocalStorage('oui.demo.file', { - + 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() { - + {{ titleChoose ?? t('Choose file...', 'oui.file.choose') }} diff --git a/lib/basic/oui-form-item.demo.vue b/lib/basic/oui-form-item.demo.vue index 67baf58..1366c4e 100644 --- a/lib/basic/oui-form-item.demo.vue +++ b/lib/basic/oui-form-item.demo.vue @@ -2,6 +2,7 @@ import { OuiDate, OuiDatetime, OuiDemo, OuiFormItem, OuiInput, OuiInputNumber, OuiPassword, OuiSelect, OuiTextarea } from '@/lib' import { reactive } from 'vue' import { dayFromToday, getTimestamp } from 'zeed' +import OuiCheckbox from './oui-checkbox.vue' const state = reactive({ value1: '', @@ -12,23 +13,26 @@ const state = reactive({ select: '', date: dayFromToday(), datetime: getTimestamp(), + disabled: false, }) - + BODY - - - - - - - - - + + + + + + + + + - + + + diff --git a/lib/basic/oui-form-item.styl b/lib/basic/oui-form-item.styl index 9f133d4..2bc3dfa 100644 --- a/lib/basic/oui-form-item.styl +++ b/lib/basic/oui-form-item.styl @@ -16,6 +16,11 @@ font-size: 13; font-weight: 500; margin-bottom: 4; + + &._disabled { + color: var(--s2-fg); + cursor: not-allowed; + } } &-description { @@ -25,6 +30,10 @@ margin-top: 4; margin-bottom: 12; color: var(--t3-fg); + + &._disabled { + cursor: not-allowed; + } } .oui-select { diff --git a/lib/basic/oui-form-item.vue b/lib/basic/oui-form-item.vue index de0482e..1d27ddb 100644 --- a/lib/basic/oui-form-item.vue +++ b/lib/basic/oui-form-item.vue @@ -6,12 +6,13 @@ defineProps<{ description?: string required?: boolean id?: string + disabled?: boolean }>() - + {{ title }} diff --git a/lib/basic/oui-input.vue b/lib/basic/oui-input.vue index ce4fd71..f501095 100644 --- a/lib/basic/oui-input.vue +++ b/lib/basic/oui-input.vue @@ -63,7 +63,7 @@ function lazyUpdate() { :required="required" > - +