ColumnWrapper.vue
2 years ago
CxVuiCollapseMini.vue
2 years ago
CxVuiDate.vue
2 years ago
CxVuiFSelect.vue
2 years ago
CxVuiPopup.vue
2 years ago
CxVuiSelect.vue
2 years ago
CxVuiTabs.vue
2 years ago
CxVuiTabsPanel.vue
2 years ago
Delimiter.vue
2 years ago
DetailsTable.vue
2 years ago
DetailsTableRow.vue
2 years ago
DetailsTableRowValue.vue
2 years ago
ExternalLink.vue
2 years ago
ListComponents.vue
2 years ago
PrintButton.vue
2 years ago
RowWrapper.vue
2 years ago
Tooltip.vue
2 years ago
RowWrapper.vue
139 lines
| 1 | <template> |
| 2 | <div :class="className"> |
| 3 | <div |
| 4 | v-if="$slots.meta" |
| 5 | class="cx-vui-component__meta" |
| 6 | > |
| 7 | <slot name="meta"></slot> |
| 8 | </div> |
| 9 | <div |
| 10 | v-else-if="$slots.label || $slots.description" |
| 11 | class="cx-vui-component__meta" |
| 12 | > |
| 13 | <label |
| 14 | class="cx-vui-component__label" |
| 15 | v-if="$slots.label" |
| 16 | :for="elementIdData" |
| 17 | > |
| 18 | <template v-if="stateType"> |
| 19 | <Tooltip |
| 20 | :icon="stateType" |
| 21 | :position="'top-right'" |
| 22 | > |
| 23 | <template #help>{{ stateHelp }}</template> |
| 24 | <template #default> |
| 25 | <slot name="label"></slot> |
| 26 | </template> |
| 27 | </Tooltip> |
| 28 | </template> |
| 29 | <template v-else> |
| 30 | <slot name="label"></slot> |
| 31 | </template> |
| 32 | </label> |
| 33 | <div |
| 34 | class="cx-vui-component__desc" |
| 35 | v-if="$slots.description" |
| 36 | > |
| 37 | <slot name="description"></slot> |
| 38 | </div> |
| 39 | </div> |
| 40 | <div class="cx-vui-component__control"> |
| 41 | <slot></slot> |
| 42 | <div |
| 43 | v-if="$slots.actions" |
| 44 | class="cx-vui-component__control-actions" |
| 45 | > |
| 46 | <slot name="actions"></slot> |
| 47 | </div> |
| 48 | </div> |
| 49 | </div> |
| 50 | </template> |
| 51 | |
| 52 | <script> |
| 53 | |
| 54 | import Tooltip from './Tooltip'; |
| 55 | |
| 56 | const isCorrectType = value => [ 'warning-danger', 'warning', 'loading', '' ].includes( value ); |
| 57 | |
| 58 | export default { |
| 59 | name: 'RowWrapper', |
| 60 | components: { Tooltip }, |
| 61 | props: { |
| 62 | elementId: { |
| 63 | type: String, |
| 64 | }, |
| 65 | state: { |
| 66 | type: [ String, Object ], |
| 67 | validator( value ) { |
| 68 | if ( 'string' === typeof value ) { |
| 69 | return isCorrectType( value ); |
| 70 | } |
| 71 | return isCorrectType( value.type ); |
| 72 | }, |
| 73 | default: '', |
| 74 | }, |
| 75 | /** |
| 76 | * Possible values: |
| 77 | * 'size--1-x-2': true, |
| 78 | * 'padding-side-unset': true, |
| 79 | */ |
| 80 | classNames: { |
| 81 | type: Object, |
| 82 | default: () => ( |
| 83 | { 'cx-vui-component--equalwidth': true } |
| 84 | ), |
| 85 | }, |
| 86 | }, |
| 87 | data() { |
| 88 | return { |
| 89 | elementIdData: `cx_${ this.elementId }`, |
| 90 | }; |
| 91 | }, |
| 92 | computed: { |
| 93 | className() { |
| 94 | return { |
| 95 | 'cx-vui-component': true, |
| 96 | [ 'cx-vui-component--is-' + this.stateType ]: this.stateType, |
| 97 | ...this.classNames, |
| 98 | }; |
| 99 | }, |
| 100 | stateType() { |
| 101 | return 'string' === typeof this.state ? this.state : this.state.type; |
| 102 | }, |
| 103 | stateHelp() { |
| 104 | return 'string' === typeof this.state ? '' : this.state.message; |
| 105 | }, |
| 106 | }, |
| 107 | provide() { |
| 108 | return { |
| 109 | elementId: this.elementIdData, |
| 110 | stateType: () => this.stateType, |
| 111 | }; |
| 112 | }, |
| 113 | }; |
| 114 | </script> |
| 115 | |
| 116 | <style lang="scss" scoped> |
| 117 | |
| 118 | .size--1-x-2 { |
| 119 | .cx-vui-component__meta { |
| 120 | flex: 1; |
| 121 | } |
| 122 | |
| 123 | .cx-vui-component__control { |
| 124 | flex: 2; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | .padding-side-unset.cx-vui-component { |
| 129 | padding-left: unset; |
| 130 | padding-right: unset; |
| 131 | } |
| 132 | |
| 133 | .cx-vui-component__control-actions { |
| 134 | display: flex; |
| 135 | justify-content: flex-end; |
| 136 | gap: 1em; |
| 137 | margin-top: 0.5em; |
| 138 | } |
| 139 | </style> |