big change
This commit is contained in:
parent
154cfcfae1
commit
68f4239eb3
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "axp-ui",
|
"name": "axp-ui",
|
||||||
"descriiption": "My helper ui lib",
|
"descriiption": "My helper ui lib",
|
||||||
"version": "1.5.18",
|
"version": "1.6.0",
|
||||||
"homepage": "https://antoxahub.ru/antoxa/axp-ui",
|
"homepage": "https://antoxahub.ru/antoxa/axp-ui",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
44
src/components/Dialog.vue
Normal file
44
src/components/Dialog.vue
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, watch } from 'vue'
|
||||||
|
import UiIcon from './Icon.vue'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
open: { type: Boolean, default: false },
|
||||||
|
close: { type: Boolean, default: false },
|
||||||
|
title: { type: String }
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:open'])
|
||||||
|
|
||||||
|
const dialogState = ref(props.open)
|
||||||
|
|
||||||
|
const closeDialog = () => {
|
||||||
|
dialogState.value = false
|
||||||
|
emit('update:open', false)
|
||||||
|
}
|
||||||
|
|
||||||
|
const clickWrapperHandler = (e: MouseEvent) => {
|
||||||
|
if (e.target instanceof Element) {
|
||||||
|
if (e.target.classList.contains('ui-dialog')) closeDialog()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.open,
|
||||||
|
val => (dialogState.value = val)
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<dialog class="ui-dialog" :open="dialogState" @click="clickWrapperHandler">
|
||||||
|
<div class="ui-dialog-window">
|
||||||
|
<div class="ui-dialog-window-header" v-if="props.title">
|
||||||
|
<h4>{{ title }}</h4>
|
||||||
|
<ui-icon name="close" @click="closeDialog" />
|
||||||
|
</div>
|
||||||
|
<div v-if="$slots.default" class="ui-dialog-window-content">
|
||||||
|
<slot name="default" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</dialog>
|
||||||
|
</template>
|
@ -10,6 +10,7 @@ const props = defineProps<{
|
|||||||
tag?: 'input' | 'textarea' | 'select'
|
tag?: 'input' | 'textarea' | 'select'
|
||||||
checked?: boolean
|
checked?: boolean
|
||||||
options?: { text: string, value: any }[]
|
options?: { text: string, value: any }[]
|
||||||
|
multiple?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
// Emits.
|
// Emits.
|
||||||
@ -57,6 +58,7 @@ const inputHandler = (val: any) => {
|
|||||||
<div v-if="props.label" class="label">{{ props.label }}</div>
|
<div v-if="props.label" class="label">{{ props.label }}</div>
|
||||||
<input
|
<input
|
||||||
v-if="!tag || tag === 'input'"
|
v-if="!tag || tag === 'input'"
|
||||||
|
class="input"
|
||||||
:type="props.type"
|
:type="props.type"
|
||||||
:value="props.modelValue"
|
:value="props.modelValue"
|
||||||
:readonly="props.readonly"
|
:readonly="props.readonly"
|
||||||
@ -64,25 +66,25 @@ const inputHandler = (val: any) => {
|
|||||||
:checked="checked"
|
:checked="checked"
|
||||||
:placeholder="props.placeholder"
|
:placeholder="props.placeholder"
|
||||||
@input="inputHandler"
|
@input="inputHandler"
|
||||||
class="input"
|
|
||||||
/>
|
/>
|
||||||
<textarea
|
<textarea
|
||||||
v-if="tag === 'textarea'"
|
v-if="tag === 'textarea'"
|
||||||
|
class="input"
|
||||||
:value="props.modelValue"
|
:value="props.modelValue"
|
||||||
:readonly="props.readonly"
|
:readonly="props.readonly"
|
||||||
:disabled="props.disabled"
|
:disabled="props.disabled"
|
||||||
:placeholder="props.placeholder"
|
:placeholder="props.placeholder"
|
||||||
@input="inputHandler"
|
@input="inputHandler"
|
||||||
class="input"
|
|
||||||
/>
|
/>
|
||||||
<select
|
<select
|
||||||
v-if="tag === 'select'"
|
v-if="tag === 'select'"
|
||||||
|
class="input"
|
||||||
:value="props.modelValue"
|
:value="props.modelValue"
|
||||||
:readonly="props.readonly"
|
:readonly="props.readonly"
|
||||||
:disabled="props.disabled"
|
:disabled="props.disabled"
|
||||||
:placeholder="props.placeholder"
|
:placeholder="props.placeholder"
|
||||||
|
:multiple="props.multiple"
|
||||||
@input="inputHandler"
|
@input="inputHandler"
|
||||||
class="input"
|
|
||||||
>
|
>
|
||||||
<option v-for="item in props.options" :value="item.value">
|
<option v-for="item in props.options" :value="item.value">
|
||||||
{{ item.text }}
|
{{ item.text }}
|
||||||
|
@ -3,7 +3,8 @@ import { computed } from 'vue'
|
|||||||
import UiField from './Field.vue'
|
import UiField from './Field.vue'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue?: string | number,
|
modelValue?: string | string[] | number | number[],
|
||||||
|
multiple?: boolean
|
||||||
options: { text: string, value: any }[]
|
options: { text: string, value: any }[]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ const displayValue = computed({
|
|||||||
tag="select"
|
tag="select"
|
||||||
class="ui-field-select"
|
class="ui-field-select"
|
||||||
:options="props.options"
|
:options="props.options"
|
||||||
|
:multiple="props.multiple"
|
||||||
v-model="displayValue"
|
v-model="displayValue"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Ref } from 'vue'
|
import type { Ref } from 'vue'
|
||||||
import type { TNotificationItem, BaseFormModel } from 'axp-ts'
|
import type { TNotificationItem, BaseFormModel } from 'axp-ts'
|
||||||
|
|
||||||
import { ref, computed, watch } from 'vue'
|
import { ref, computed, watch } from 'vue'
|
||||||
|
import { colors } from '../colors'
|
||||||
|
|
||||||
import UiBtn from './Btn.vue'
|
import UiBtn from './Btn.vue'
|
||||||
|
import UiAlert from './Alert.vue'
|
||||||
|
|
||||||
// Props.
|
// Props.
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@ -49,7 +52,10 @@ const load = ref(false)
|
|||||||
watch(load, val => emit('update:load', val))
|
watch(load, val => emit('update:load', val))
|
||||||
|
|
||||||
const messages: Ref<TNotificationItem[]> = ref(props.messages || [])
|
const messages: Ref<TNotificationItem[]> = ref(props.messages || [])
|
||||||
watch(() => props.messages, (val) => messages.value = val || [])
|
watch(
|
||||||
|
() => props.messages,
|
||||||
|
val => (messages.value = val || [])
|
||||||
|
)
|
||||||
|
|
||||||
// Handlers.
|
// Handlers.
|
||||||
const submitHandler = async () => {
|
const submitHandler = async () => {
|
||||||
@ -92,6 +98,11 @@ const submitHandler = async () => {
|
|||||||
emit('submit')
|
emit('submit')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Etc.
|
||||||
|
const getColorMessage = (item: TNotificationItem) => {
|
||||||
|
return colors.includes(item.code) ? item.code : 'error'
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -100,9 +111,11 @@ const submitHandler = async () => {
|
|||||||
<h3 class="ui-form-title">{{ title }}</h3>
|
<h3 class="ui-form-title">{{ title }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="messages.length" class="ui-form-messages">
|
<div v-if="messages.length" class="ui-form-messages">
|
||||||
<div v-for="message in messages" :class="'text-' + message.code">
|
<ui-alert
|
||||||
{{ message.text }}
|
v-for="item in messages"
|
||||||
</div>
|
:value="item.text"
|
||||||
|
:color="colors.includes(item.code) ? item.code : 'error'"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-form-body">
|
<div class="ui-form-body">
|
||||||
<component
|
<component
|
||||||
|
@ -30,11 +30,11 @@ const inputHandler = (index: number) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="ui-picker-days">
|
<div class="ui-picker ui-picker-days">
|
||||||
<div v-if="props.label" class="label mb-2">
|
<div v-if="props.label" class="label mb-2">
|
||||||
<span>{{props.label}}:</span>
|
<span>{{props.label}}:</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center">
|
<div class="ui-picker-content flex items-center">
|
||||||
<ui-field-checkbox
|
<ui-field-checkbox
|
||||||
v-for="(item, index) in days"
|
v-for="(item, index) in days"
|
||||||
class="mr-4"
|
class="mr-4"
|
||||||
|
@ -16,3 +16,4 @@ export { default as UiIconVisibility } from './IconVisibility.vue'
|
|||||||
export { default as UiForm } from './Form.vue'
|
export { default as UiForm } from './Form.vue'
|
||||||
export { default as UiCard } from './Card.vue'
|
export { default as UiCard } from './Card.vue'
|
||||||
export { default as UiTable } from './Table.vue'
|
export { default as UiTable } from './Table.vue'
|
||||||
|
export { default as UiDialog } from './Dialog.vue'
|
||||||
|
@ -110,3 +110,26 @@ p
|
|||||||
@apply border-t
|
@apply border-t
|
||||||
td
|
td
|
||||||
@apply p-2
|
@apply p-2
|
||||||
|
&-dialog
|
||||||
|
@apply bg-dark/30
|
||||||
|
@apply flex flex-col justify-center items-center
|
||||||
|
@apply z-50
|
||||||
|
position: fixed
|
||||||
|
width: 100%
|
||||||
|
height: 100%
|
||||||
|
top: 0
|
||||||
|
left: 0
|
||||||
|
&:not([open])
|
||||||
|
@apply hidden
|
||||||
|
&-window
|
||||||
|
@apply bg-white text-dark
|
||||||
|
&-header
|
||||||
|
@apply flex items-center justify-between py-2 px-3
|
||||||
|
> .title
|
||||||
|
@apply text-lg font-normal
|
||||||
|
.ui-icon
|
||||||
|
@apply w-[30px] h-[30px] p-0 border-0
|
||||||
|
&:hover
|
||||||
|
@apply text-dark
|
||||||
|
&-content
|
||||||
|
@apply p-3
|
||||||
|
Loading…
Reference in New Issue
Block a user