Material TreeSelect

pull/6494/head
Cagatay Civici 2024-09-29 01:47:57 +03:00
parent f02f1d0bb1
commit 57dcf2c466
6 changed files with 82 additions and 26 deletions

View File

@ -9,7 +9,7 @@
</FloatLabel> </FloatLabel>
<FloatLabel class="w-full md:w-80" variant="in"> <FloatLabel class="w-full md:w-80" variant="in">
<TreeSelect v-model="value2" inputId="in_label" :options="nodes" class="w-full" /> <TreeSelect v-model="value2" inputId="in_label" :options="nodes" class="w-full" variant="filled" />
<label for="in_label">In Label</label> <label for="in_label">In Label</label>
</FloatLabel> </FloatLabel>
@ -39,7 +39,7 @@ export default {
</FloatLabel> </FloatLabel>
<FloatLabel class="w-full md:w-80" variant="in"> <FloatLabel class="w-full md:w-80" variant="in">
<TreeSelect v-model="value2" inputId="in_label" :options="nodes" class="w-full" /> <TreeSelect v-model="value2" inputId="in_label" :options="nodes" class="w-full" variant="filled" />
<label for="in_label">In Label</label> <label for="in_label">In Label</label>
</FloatLabel> </FloatLabel>
@ -57,7 +57,7 @@ export default {
</FloatLabel> </FloatLabel>
<FloatLabel class="w-full md:w-80" variant="in"> <FloatLabel class="w-full md:w-80" variant="in">
<TreeSelect v-model="value2" inputId="in_label" :options="nodes" class="w-full" /> <TreeSelect v-model="value2" inputId="in_label" :options="nodes" class="w-full" variant="filled" />
<label for="in_label">In Label</label> <label for="in_label">In Label</label>
</FloatLabel> </FloatLabel>
@ -81,7 +81,7 @@ export default {
} }
}, },
mounted() { mounted() {
NodeService.getTreeNodes().then((data) => (this.nodes = data)); NodeService.getTreeNodes().then((data) => (this.nodes = data));
} }
} }
<\/script> <\/script>
@ -95,7 +95,7 @@ export default {
</FloatLabel> </FloatLabel>
<FloatLabel class="w-full md:w-80" variant="in"> <FloatLabel class="w-full md:w-80" variant="in">
<TreeSelect v-model="value2" inputId="in_label" :options="nodes" class="w-full" /> <TreeSelect v-model="value2" inputId="in_label" :options="nodes" class="w-full" variant="filled" />
<label for="in_label">In Label</label> <label for="in_label">In Label</label>
</FloatLabel> </FloatLabel>

View File

@ -4,7 +4,7 @@
</DocSectionText> </DocSectionText>
<div class="card flex justify-center"> <div class="card flex justify-center">
<IftaLabel class="w-full md:w-80"> <IftaLabel class="w-full md:w-80">
<TreeSelect v-model="selectedValue" inputId="t_file" :options="nodes" class="w-full" /> <TreeSelect v-model="selectedValue" inputId="t_file" :options="nodes" class="w-full" variant="filled" />
<label for="t_file">File</label> <label for="t_file">File</label>
</IftaLabel> </IftaLabel>
</div> </div>
@ -22,7 +22,7 @@ export default {
code: { code: {
basic: ` basic: `
<IftaLabel class="w-full md:w-80"> <IftaLabel class="w-full md:w-80">
<TreeSelect v-model="selectedValue" inputId="t_file" :options="nodes" class="w-full" /> <TreeSelect v-model="selectedValue" inputId="t_file" :options="nodes" class="w-full" variant="filled" />
<label for="t_file">File</label> <label for="t_file">File</label>
</IftaLabel> </IftaLabel>
`, `,
@ -30,7 +30,7 @@ export default {
<template> <template>
<div class="card flex justify-center"> <div class="card flex justify-center">
<IftaLabel class="w-full md:w-80"> <IftaLabel class="w-full md:w-80">
<TreeSelect v-model="selectedValue" inputId="t_file" :options="nodes" class="w-full" /> <TreeSelect v-model="selectedValue" inputId="t_file" :options="nodes" class="w-full" variant="filled" />
<label for="t_file">File</label> <label for="t_file">File</label>
</IftaLabel> </IftaLabel>
</div> </div>
@ -47,7 +47,7 @@ export default {
} }
}, },
mounted() { mounted() {
NodeService.getTreeNodes().then((data) => (this.nodes = data)); NodeService.getTreeNodes().then((data) => (this.nodes = data));
} }
} }
<\/script> <\/script>
@ -56,7 +56,7 @@ export default {
<template> <template>
<div class="card flex justify-center"> <div class="card flex justify-center">
<IftaLabel class="w-full md:w-80"> <IftaLabel class="w-full md:w-80">
<TreeSelect v-model="selectedValue" inputId="t_file" :options="nodes" class="w-full" /> <TreeSelect v-model="selectedValue" inputId="t_file" :options="nodes" class="w-full" variant="filled" />
<label for="t_file">File</label> <label for="t_file">File</label>
</IftaLabel> </IftaLabel>
</div> </div>

View File

@ -2,8 +2,9 @@
<DocSectionText v-bind="$attrs"> <DocSectionText v-bind="$attrs">
<p>Invalid state is displayed using the <i>invalid</i> prop to indicate a failed validation. You can use this style when integrating with form validation libraries.</p> <p>Invalid state is displayed using the <i>invalid</i> prop to indicate a failed validation. You can use this style when integrating with form validation libraries.</p>
</DocSectionText> </DocSectionText>
<div class="card flex justify-center"> <div class="card flex flex-wrap justify-center gap-4">
<TreeSelect v-model="selectedValue" :invalid="Object.keys(selectedValue).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" /> <TreeSelect v-model="selectedValue1" :invalid="Object.keys(selectedValue1).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" />
<TreeSelect v-model="selectedValue2" :invalid="Object.keys(selectedValue2).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" variant="filled" />
</div> </div>
<DocSectionCode :code="code" :service="['NodeService']" v-bind="$attrs" /> <DocSectionCode :code="code" :service="['NodeService']" v-bind="$attrs" />
</template> </template>
@ -15,15 +16,18 @@ export default {
data() { data() {
return { return {
nodes: null, nodes: null,
selectedValue: {}, selectedValue1: {},
selectedValue2: {},
code: { code: {
basic: ` basic: `
<TreeSelect v-model="selectedValue" :invalid="Object.keys(selectedValue).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" /> <TreeSelect v-model="selectedValue1" :invalid="Object.keys(selectedValue1).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" />
<TreeSelect v-model="selectedValue2" :invalid="Object.keys(selectedValue2).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" variant="filled" />
`, `,
options: ` options: `
<template> <template>
<div class="card flex justify-center"> <div class="card flex flex-wrap justify-center gap-4">
<TreeSelect v-model="selectedValue" :invalid="Object.keys(selectedValue).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" /> <TreeSelect v-model="selectedValue1" :invalid="Object.keys(selectedValue1).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" />
<TreeSelect v-model="selectedValue2" :invalid="Object.keys(selectedValue2).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" variant="filled" />
</div> </div>
</template> </template>
@ -34,7 +38,8 @@ export default {
data() { data() {
return { return {
nodes: null, nodes: null,
selectedValue: {}, selectedValue1: {},
selectedValue2: {},
} }
}, },
mounted() { mounted() {
@ -45,8 +50,9 @@ export default {
`, `,
composition: ` composition: `
<template> <template>
<div class="card flex justify-center"> <div class="card flex flex-wrap justify-center gap-4">
<TreeSelect v-model="selectedValue" :invalid="Object.keys(selectedValue).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" /> <TreeSelect v-model="selectedValue1" :invalid="Object.keys(selectedValue1).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" />
<TreeSelect v-model="selectedValue2" :invalid="Object.keys(selectedValue2).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" variant="filled" />
</div> </div>
</template> </template>
@ -55,7 +61,8 @@ import { ref, onMounted } from 'vue';
import { NodeService } from './service/NodeService'; import { NodeService } from './service/NodeService';
const nodes = ref(null); const nodes = ref(null);
const selectedValue = ref({}); const selectedValue1 = ref({});
const selectedValue2 = ref({});
onMounted(() => { onMounted(() => {
NodeService.getTreeNodes().then((data) => (nodes.value = data)); NodeService.getTreeNodes().then((data) => (nodes.value = data));

View File

@ -60,6 +60,11 @@ export default {
label: 'Filter', label: 'Filter',
component: FilterDoc component: FilterDoc
}, },
{
id: 'filled',
label: 'Filled',
component: FilledDoc
},
{ {
id: 'floatlabel', id: 'floatlabel',
label: 'Float Label', label: 'Float Label',
@ -70,11 +75,6 @@ export default {
label: 'Ifta Label', label: 'Ifta Label',
component: IftaLabelDoc component: IftaLabelDoc
}, },
{
id: 'filled',
label: 'Filled',
component: FilledDoc
},
{ {
id: 'invalid', id: 'invalid',
label: 'Invalid', label: 'Invalid',

View File

@ -31,6 +31,10 @@ const theme = ({ dt }) => `
background: ${dt('treeselect.filled.background')}; background: ${dt('treeselect.filled.background')};
} }
.p-treeselect.p-variant-filled:not(.p-disabled):hover {
background: ${dt('treeselect.filled.hover.background')};
}
.p-treeselect.p-variant-filled.p-focus { .p-treeselect.p-variant-filled.p-focus {
background: ${dt('treeselect.filled.focus.background')}; background: ${dt('treeselect.filled.focus.background')};
} }

View File

@ -3,6 +3,7 @@ export default {
background: '{form.field.background}', background: '{form.field.background}',
disabledBackground: '{form.field.disabled.background}', disabledBackground: '{form.field.disabled.background}',
filledBackground: '{form.field.filled.background}', filledBackground: '{form.field.filled.background}',
filledHoverBackground: '{form.field.filled.hover.background}',
filledFocusBackground: '{form.field.filled.focus.background}', filledFocusBackground: '{form.field.filled.focus.background}',
borderColor: '{form.field.border.color}', borderColor: '{form.field.border.color}',
hoverBorderColor: '{form.field.hover.border.color}', hoverBorderColor: '{form.field.hover.border.color}',
@ -43,5 +44,49 @@ export default {
}, },
chip: { chip: {
borderRadius: '{border.radius.sm}' borderRadius: '{border.radius.sm}'
} },
style: ({ dt }) => `
.p-treeselect.p-variant-filled {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
border: 1px solid transparent;
background: ${dt('treeselect.filled.background')} no-repeat;
background-image: linear-gradient(to bottom, ${dt('treeselect.focus.border.color')}, ${dt('treeselect.focus.border.color')}), linear-gradient(to bottom, ${dt('treeselect.border.color')}, ${dt('treeselect.border.color')});
background-size: 0 2px, 100% 1px;
background-position: 50% 100%, 50% 100%;
background-origin: border-box;
transition: background-size 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
}
.p-treeselect.p-variant-filled:not(.p-disabled):hover {
background: ${dt('treeselect.filled.hover.background')} no-repeat;
background-image: linear-gradient(to bottom, ${dt('treeselect.focus.border.color')}, ${dt('treeselect.focus.border.color')}), linear-gradient(to bottom, ${dt('treeselect.hover.border.color')}, ${dt('treeselect.hover.border.color')});
background-size: 0 2px, 100% 1px;
background-position: 50% 100%, 50% 100%;
background-origin: border-box;
border-color: transparent;
}
.p-treeselect.p-variant-filled:not(.p-disabled).p-focus {
outline: 0 none;
background: ${dt('treeselect.filled.focus.background')} no-repeat;
background-image: linear-gradient(to bottom, ${dt('treeselect.focus.border.color')}, ${dt('treeselect.focus.border.color')}), linear-gradient(to bottom, ${dt('treeselect.border.color')}, ${dt('treeselect.border.color')});
background-size: 100% 2px, 100% 1px;
background-position: 50% 100%, 50% 100%;
background-origin: border-box;
border-color: transparent;
}
.p-treeselect.p-variant-filled:not(.p-disabled).p-focus:hover {
background-image: linear-gradient(to bottom, ${dt('treeselect.focus.border.color')}, ${dt('treeselect.focus.border.color')}), linear-gradient(to bottom, ${dt('treeselect.hover.border.color')}, ${dt('treeselect.hover.border.color')});
}
.p-treeselect.p-variant-filled.p-invalid {
background-image: linear-gradient(to bottom, ${dt('treeselect.invalid.border.color')}, ${dt('treeselect.invalid.border.color')}), linear-gradient(to bottom, ${dt('treeselect.invalid.border.color')}, ${dt('treeselect.invalid.border.color')});
}
.p-treeselect.p-variant-filled.p-invalid:not(.p-disabled).p-focus {
background-image: linear-gradient(to bottom, ${dt('treeselect.invalid.border.color')}, ${dt('treeselect.invalid.border.color')}), linear-gradient(to bottom, ${dt('treeselect.invalid.border.color')}, ${dt('treeselect.invalid.border.color')});
}
`
}; };