/** * @license * Copyright 2022 Superflow.dev * SPDX-License-Identifier: MIT */ import {LitElement, html, css, PropertyValueMap} from 'lit'; // import {customElement, query, queryAssignedElements, property} from 'lit/decorators.js'; // import {customElement, query, queryAssignedElements, property} from 'lit/decorators.js'; import {customElement, property, query} from 'lit/decorators.js'; // import {customElement, query, property} from 'lit/decorators.js'; // import Util from './util'; // import {LitElement, html, css} from 'lit'; // import {customElement} from 'lit/decorators.js'; /* Modes: View, Add, Edit, Delete, Admin DB: partitionKey, rangeKey, values */ /** * SfIMultitextarea element. * @fires renderComplete - When the list is populated * @fires valueChanged - When the value is changed * @property apiId - backend api id * @property label - input label * @property name - name of the input * @property mode - mode of operation * @property selectedId - id to preselect * @property selectedValue - callback function */ @customElement('sf-i-multitextarea') export class SfIMultitextarea extends LitElement { SCROLL_POS = 0; @query('.SfIMultitextareaC') _SfMultitextareaX: any; @property() disabled: boolean = false; @property() hint: string = ""; @property() showFields: number = 3; @property() fields!: string; getFields = () => { return JSON.parse(this.fields); } @property() values!: string; getValues = () => { try { let currValues : any = JSON.parse(/^".*"$/.test(this.values) ? this.values.replace(/\"/g, '') : this.values); for(var i = 0; i < this.getFields().length; i++) { if(currValues[this.getFields()[i]] == null) { currValues[this.getFields()[i]] = ""; } } return currValues; } catch (e: any) { let retValue: any = {}; for(var i = 0; i < this.getFields().length; i++) { retValue[this.getFields()[i]] = this.values; } return retValue; } } @property() flow: string = ""; @property() collapsed: boolean = true; @property() showCollapsed: boolean | null = null; static override styles = css` .SfIMultitextareaC { display: flex; align-items: center; } .flex-grow { flex-grow: 1; } .left-sticky { left: 0px; position: sticky; } .cursor { cursor: pointer; } .hint { font-size: 80%; color: #999; font-weight: 400; padding-left: 5px; } .collapse-content { font-size: 120%; color: gray !important; margin-left: 5px; margin-top: 2px; } .multitextarea-overwrite, .multitextarea-prev, .multitextarea-next { background: transparent; border: none; padding: 2px; color: gray } .multitextarea-input { border: none; padding: 5px; border-radius: 5px; background: white; box-shadow: inset 3px 3px 5px #bbbbbb, inset -5px -5px 8px #ffffff; border-top: solid 1px #e9c4d2; border-left: solid 1px #e9c4d2; border-bottom: solid 1px #e9c4d2; border-right: solid 1px #e9c4d2; transition: 0.3s; } .link { text-decoration: underline; cursor: pointer; } .gone { display: none } .overwrite-hide { display: none; } .overwrite-show { display: block; } .unfocused { width: 40px; font-size: 70%; } .unfocused-label { display: block; width: 40px; font-size: 80%; white-space: nowrap; overflow: hidden; text-transform: capitalize; color: #666; } .focused { width: 150px; } .focused-label { display: block; width: 100px; text-transform: capitalize; color: #666; } .loader-element { position: fixed; right: 10px; top: 10px; margin-left: 5px; } .td-head { text-transform: capitalize; } .td-body { padding: 5px; } .td-dark { background-color: #e9e9e9; } .td-highlight { background-color: black; color: white; } .td-light { background-color: #f6f6f6; } td { white-space: nowrap; } .align-start { align-items: flex-start; } .align-end { align-items: flex-end; } .align-center { align-items: center; } .lds-dual-ring { display: inline-block; width: 50px; height: 50px; } .lds-dual-ring:after { content: " "; display: block; width: 50px; height: 50px; margin: 0px; border-radius: 50%; border: 2px solid #fff; border-color: #888 #ddd #888 #ddd; background-color: white; animation: lds-dual-ring 0.8s linear infinite; } .lds-dual-ring-lg { display: inline-block; width: 30px; height: 30px; } .lds-dual-ring-lg:after { content: " "; display: block; width: 30px; height: 30px; margin: 0px; border-radius: 50%; border: 3px solid #fff; border-color: #888 #ddd #888 #ddd; animation: lds-dual-ring 0.8s linear infinite; } .div-row-error { display: flex; justify-content: center; position: fixed; position: fixed; top: 0px; right: 0px; margin-top: 20px; margin-right: 20px; display: none; align-items:center; background-color: white; border: dashed 1px red; padding: 20px; } .div-row-error-message { color: red; padding: 5px; background-color: white; text-align: center; } .div-row-success { display: flex; justify-content: center; position: fixed; top: 0px; right: 0px; margin-top: 20px; margin-right: 20px; display: none; align-items:center; background-color: white; border: dashed 1px green; padding: 20px; } .div-row-success-message { color: green; padding: 5px; background-color: white; text-align: center; } .d-flex { display: flex; } .flex-col { flex-direction: column; } .justify-center { justify-content: center; } .justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; } @keyframes lds-dual-ring { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } .hide { display: none; } .lb { width: 5% } .rb { width: 5% } @media (orientation: landscape) { .lb { width: 30% } .rb { width: 30% } } .ml-5 { margin-left: 5px; } .mr-5 { margin-right: 5px; } .p-5 { padding: 5px; } `; getFieldsHtml = () => { var html = ''; const jsonFields = this.getFields(); html += '