diff --git a/packages/documentation/pages/usage/components/filters.vue b/packages/documentation/pages/usage/components/filters.vue index 8a35fbd186..923b279beb 100644 --- a/packages/documentation/pages/usage/components/filters.vue +++ b/packages/documentation/pages/usage/components/filters.vue @@ -273,6 +273,7 @@ export default defineComponent({ const component: ComponentValue = { hasActions: false, hasHelpTextSlot: false, + hasOptionSlot: false, name: 'KtFilters', props: cloneDeep(componentProps.value), validation: 'empty', diff --git a/packages/documentation/pages/usage/components/form-fields.vue b/packages/documentation/pages/usage/components/form-fields.vue index 26d6e272ca..3ad2c7c5ff 100644 --- a/packages/documentation/pages/usage/components/form-fields.vue +++ b/packages/documentation/pages/usage/components/form-fields.vue @@ -19,7 +19,11 @@

Component

- + -
Supports HTML via - <template v-slot:helpText> + <template #helpText>
-
+ +
Default Slot
@@ -137,6 +153,111 @@ ]" type="switch" /> + +
+
+

Texts

+ + +
+ + +
+
+ + +
+

Decoration

+
+ + +
+
+ + + + + + +
+ - -
-
-

Texts

- - -
- -
-
- - -
-

Decoration

-
- - -
-
- - -
+
@@ -430,6 +489,7 @@ import { KtFieldDateTime, KtFieldDateTimeRange, KtFieldMultiSelect, + KtFieldMultiSelectRemote, KtFieldNumber, KtFieldPassword, KtFieldRadioGroup, @@ -441,6 +501,7 @@ import { KtFieldToggleGroup, } from '@3yourmind/kotti-ui' import { Yoco } from '@3yourmind/yoco' +import { TimeConversion } from '@metatypes/units' import { defineComponent, ref, computed } from '@vue/composition-api' import cloneDeep from 'lodash/cloneDeep' @@ -508,11 +569,31 @@ const components: Array<{ supports: KtFieldDateTimeRange.meta.supports, }, { - additionalProps: ['actions', 'collapseTagsAfter', 'maximumSelectable'], + additionalProps: [ + 'actions', + 'collapseTagsAfter', + 'hasOptionSlot', + 'isUnsorted', + 'maximumSelectable', + ], formKey: 'multiSelectValue', name: 'KtFieldMultiSelect', supports: KtFieldMultiSelect.meta.supports, }, + { + additionalProps: [ + 'actions', + 'collapseTagsAfter', + 'hasOptionSlot', + 'isLoadingOptions', + 'isUnsorted', + 'maximumSelectable', + 'query', + ], + formKey: 'multiSelectValue', + name: 'KtFieldMultiSelectRemote', + supports: KtFieldMultiSelectRemote.meta.supports, + }, { additionalProps: [ 'numberDecimalPlaces', @@ -539,13 +620,19 @@ const components: Array<{ supports: KtFieldRadioGroup.meta.supports, }, { - additionalProps: ['actions'], + additionalProps: ['actions', 'hasOptionSlot', 'isUnsorted'], formKey: 'singleSelectValue', name: 'KtFieldSingleSelect', supports: KtFieldSingleSelect.meta.supports, }, { - additionalProps: ['actions', 'isLoadingOptions', 'query'], + additionalProps: [ + 'actions', + 'hasOptionSlot', + 'isLoadingOptions', + 'isUnsorted', + 'query', + ], formKey: 'singleSelectValue', name: 'KtFieldSingleSelectRemote', supports: KtFieldSingleSelectRemote.meta.supports, @@ -635,10 +722,15 @@ const radioGroupOptions: Kotti.FieldRadioGroup.Props['options'] = [ ] const singleOrMultiSelectOptions: Kotti.FieldSingleSelect.Props['options'] = [ - { label: 'Key 1', value: 'value1' }, { label: 'Key 2', value: 'value2' }, + { label: 'Key 1', value: 'value1' }, { isDisabled: true, label: 'Key 3', value: 'value3' }, + { label: 'Key 7', value: 'value7' }, { label: 'Key 4', value: 'value4' }, + { label: 'Key 9', value: 'value9' }, + { label: 'Key 6', value: 'value6' }, + { label: 'Key 8', value: 'value8' }, + { label: 'Key 5', value: 'value5' }, ] const toggleGroupOptions: Kotti.FieldToggleGroup.Props['options'] = [ @@ -674,9 +766,11 @@ export default defineComponent({ collapseTagsAfter: Kotti.FieldNumber.Value currencyCurrency: string hasActions: boolean + hasOptionSlot: boolean hideChangeButtons: boolean isInline: boolean isLoadingOptions: boolean + isUnsorted: boolean maximumDate: Kotti.FieldDate.Value maximumSelectable: Kotti.FieldNumber.Value minimumDate: Kotti.FieldDate.Value @@ -708,8 +802,9 @@ export default defineComponent({ placeholder2: Kotti.FieldText.Value prefix: Kotti.FieldText.Value rightIcon: Yoco.Icon | null - size: 'small' | 'medium' | 'large' + size: Kotti.Field.Size suffix: Kotti.FieldText.Value + tabIndex: Kotti.FieldNumber.Value validation: Kotti.Field.Validation.Result['type'] }>({ additionalProps: { @@ -717,9 +812,11 @@ export default defineComponent({ collapseTagsAfter: null, currencyCurrency: 'USD', hasActions: false, + hasOptionSlot: false, hideChangeButtons: false, isInline: false, isLoadingOptions: false, + isUnsorted: false, maximumDate: null, maximumSelectable: null, minimumDate: null, @@ -751,8 +848,9 @@ export default defineComponent({ placeholder2: null, prefix: null, rightIcon: null, - size: 'medium', + size: Kotti.Field.Size.MEDIUM, suffix: null, + tabIndex: null, validation: 'empty', }) @@ -818,6 +916,11 @@ export default defineComponent({ placeholder: settings.value.placeholder, }) + if (componentDefinition.value.supports.tabIndex) + Object.assign(additionalProps, { + tabIndex: settings.value.tabIndex, + }) + if ( componentDefinition.value.additionalProps.includes('toggleType') && settings.value.additionalProps.toggleType !== 'checkbox' // Exclude Default Value @@ -895,13 +998,21 @@ export default defineComponent({ isLoadingOptions: settings.value.additionalProps.isLoadingOptions, }) + if (componentDefinition.value.additionalProps.includes('isUnsorted')) + Object.assign(additionalProps, { + isUnsorted: settings.value.additionalProps.isUnsorted, + }) + if (componentDefinition.value.additionalProps.includes('maximumDate')) Object.assign(additionalProps, { maximumDate: settings.value.additionalProps.maximumDate, }) if ( - componentDefinition.value.additionalProps.includes('maximumSelectable') + componentDefinition.value.additionalProps.includes( + 'maximumSelectable', + ) && + settings.value.additionalProps.maximumSelectable !== null ) Object.assign(additionalProps, { maximumSelectable: settings.value.additionalProps.maximumSelectable, @@ -925,12 +1036,15 @@ export default defineComponent({ if ( [ 'KtFieldMultiSelect', + 'KtFieldMultiSelectRemote', 'KtFieldSingleSelect', 'KtFieldSingleSelectRemote', ].includes(component) ) { const options = ( - component === 'KtFieldSingleSelectRemote' + ['KtFieldMultiSelectRemote', 'KtFieldSingleSelectRemote'].includes( + component, + ) ? singleOrMultiSelectOptions.filter((option) => option.label .toLowerCase() @@ -939,9 +1053,9 @@ export default defineComponent({ ), ) : singleOrMultiSelectOptions - ).map((option) => ({ + ).map((option, index) => ({ ...option, - dataTest: `${String(option.value)}`, + dataTest: index % 2 === 0 ? `${String(option.value)}` : undefined, })) Object.assign(additionalProps, { @@ -949,7 +1063,11 @@ export default defineComponent({ }) } - if (['KtFieldSingleSelectRemote'].includes(component)) { + if ( + ['KtFieldMultiSelectRemote', 'KtFieldSingleSelectRemote'].includes( + component, + ) + ) { Object.assign(additionalProps, { query: remoteSingleSelectQuery.value }) } @@ -987,6 +1105,7 @@ export default defineComponent({ (): ComponentValue => ({ hasActions: settings.value.additionalProps.hasActions, hasHelpTextSlot: settings.value.hasHelpTextSlot, + hasOptionSlot: settings.value.additionalProps.hasOptionSlot, name: settings.value.component, props: cloneDeep(componentProps.value), validation: settings.value.validation, @@ -1003,6 +1122,7 @@ export default defineComponent({ KtFieldDateTimeRange, KtFieldNumber, KtFieldMultiSelect, + KtFieldMultiSelectRemote, KtFieldPassword, KtFieldRadioGroup, KtFieldSingleSelect, @@ -1034,6 +1154,8 @@ export default defineComponent({ }), ), isRangeComponent, + onSubmit: (values: Record) => + window.alert(`@submit: ${JSON.stringify(values, null, '\t')}`), reset: () => { values.value = INITIAL_VALUES }, @@ -1065,6 +1187,16 @@ export default defineComponent({ newQuery: Kotti.FieldSingleSelectRemote.Events.UpdateQuery, ) => { remoteSingleSelectQuery.value = newQuery + settings.value.additionalProps = { + ...settings.value.additionalProps, + isLoadingOptions: true, + } + setTimeout(() => { + settings.value.additionalProps = { + ...settings.value.additionalProps, + isLoadingOptions: false, + } + }, TimeConversion.MILLISECONDS_PER_SECOND) }, values, yocoIconOptions: Object.values(Yoco.Icon).map((icon) => ({ diff --git a/packages/documentation/pages/utilities.ts b/packages/documentation/pages/utilities.ts index c8da0b26e6..d0384a849f 100644 --- a/packages/documentation/pages/utilities.ts +++ b/packages/documentation/pages/utilities.ts @@ -6,6 +6,7 @@ export type ComponentNames = | 'KtFieldDateTime' | 'KtFieldDateTimeRange' | 'KtFieldMultiSelect' + | 'KtFieldMultiSelectRemote' | 'KtFieldNumber' | 'KtFieldPassword' | 'KtFieldRadioGroup' @@ -20,6 +21,7 @@ export type ComponentNames = export type ComponentValue = { hasActions: boolean hasHelpTextSlot: boolean + hasOptionSlot: boolean name: ComponentNames props: Record validation: Kotti.Field.Validation.Result['type'] diff --git a/packages/kotti-ui/source/index.ts b/packages/kotti-ui/source/index.ts index 51aa6cee28..35062447fa 100644 --- a/packages/kotti-ui/source/index.ts +++ b/packages/kotti-ui/source/index.ts @@ -44,8 +44,9 @@ export * from './kotti-field-password' import { KtFieldRadioGroup } from './kotti-field-radio-group' export * from './kotti-field-radio-group' import { - KtFieldSingleSelect, KtFieldMultiSelect, + KtFieldMultiSelectRemote, + KtFieldSingleSelect, KtFieldSingleSelectRemote, } from './kotti-field-select' export * from './kotti-field-select' @@ -132,6 +133,7 @@ export default { KtFieldDateTime, KtFieldDateTimeRange, KtFieldMultiSelect, + KtFieldMultiSelectRemote, KtFieldNumber, KtFieldPassword, KtFieldRadioGroup, diff --git a/packages/kotti-ui/source/kotti-avatar/KtAvatar.vue b/packages/kotti-ui/source/kotti-avatar/KtAvatar.vue index a91c310099..45d4986a13 100644 --- a/packages/kotti-ui/source/kotti-avatar/KtAvatar.vue +++ b/packages/kotti-ui/source/kotti-avatar/KtAvatar.vue @@ -19,10 +19,10 @@ import { Yoco } from '@3yourmind/yoco' import { computed, defineComponent, Ref, ref } from '@vue/composition-api' import { roundArrow } from 'tippy.js' +import { TIPPY_LIGHT_BORDER_ARROW_HEIGHT } from '../constants' import { makeProps } from '../make-props' import { KottiAvatar } from './types' -const ARROW_HEIGHT = 7 const useTooltip = (name: Ref) => { const tooltipTriggerRef = ref(null) @@ -33,7 +33,7 @@ const useTooltip = (name: Ref) => { appendTo: () => document.body, arrow: roundArrow, content: name.value, - offset: [0, ARROW_HEIGHT], + offset: [0, TIPPY_LIGHT_BORDER_ARROW_HEIGHT], theme: 'light-border', ...(name.value === null ? { trigger: 'manual' } : {}), })), diff --git a/packages/kotti-ui/source/kotti-field-select/KtFieldMultiSelect.vue b/packages/kotti-ui/source/kotti-field-select/KtFieldMultiSelect.vue index 6b621c32cb..7a8e1b1f5f 100644 --- a/packages/kotti-ui/source/kotti-field-select/KtFieldMultiSelect.vue +++ b/packages/kotti-ui/source/kotti-field-select/KtFieldMultiSelect.vue @@ -1,229 +1,37 @@