kempo-ui 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/Dialog.js +35 -28
- package/dist/src/components/ShadowComponent.js +1 -1
- package/dist/src/components/Sortable.js +45 -0
- package/dist/src/components/Table.js +151 -0
- package/dist/src/components/Toast.js +141 -0
- package/dist/src/components/Toggle.js +74 -0
- package/dist/src/components/tableControls/DeleteRecord.js +7 -0
- package/dist/src/components/tableControls/Edit.js +18 -0
- package/dist/src/components/tableControls/ExportCSV.js +8 -0
- package/dist/src/components/tableControls/ExportJson.js +8 -0
- package/dist/src/components/tableControls/FieldSortHide.js +26 -0
- package/dist/src/components/tableControls/Filters.js +47 -0
- package/dist/src/components/tableControls/FirstPage.js +9 -0
- package/dist/src/components/tableControls/HiddenCount.js +3 -0
- package/dist/src/components/tableControls/Hide.js +5 -0
- package/dist/src/components/tableControls/LastPage.js +9 -0
- package/dist/src/components/tableControls/NextPage.js +9 -0
- package/dist/src/components/tableControls/PageSelect.js +22 -0
- package/dist/src/components/tableControls/PageSize.js +5 -0
- package/dist/src/components/tableControls/PrevPage.js +9 -0
- package/dist/src/components/tableControls/Search.js +9 -0
- package/dist/src/components/tableControls/ShowAll.js +5 -0
- package/dist/src/components/tableControls/TableControl.js +16 -0
- package/dist/src/utils/toTitleCase.js +1 -0
- package/docs/components/focus-capture.html +58 -13
- package/docs/components/hybrid-component.html +112 -0
- package/docs/components/icon.html +0 -2
- package/docs/components/light-component.html +99 -0
- package/docs/components/shadow-component.html +88 -0
- package/docs/components/sortable.html +132 -0
- package/docs/icons/error.svg +1 -1
- package/docs/icons/warning.svg +1 -1
- package/docs/index.html +197 -5
- package/docs/kempo.min.css +1 -1
- package/docs/nav.inc.html +11 -10
- package/docs/src/components/Dialog.js +35 -28
- package/docs/src/components/ShadowComponent.js +1 -1
- package/docs/src/components/Sortable.js +45 -0
- package/docs/src/components/Table.js +151 -0
- package/docs/src/components/Toast.js +141 -0
- package/docs/src/components/Toggle.js +74 -0
- package/docs/src/components/tableControls/DeleteRecord.js +7 -0
- package/docs/src/components/tableControls/Edit.js +18 -0
- package/docs/src/components/tableControls/ExportCSV.js +8 -0
- package/docs/src/components/tableControls/ExportJson.js +8 -0
- package/docs/src/components/tableControls/FieldSortHide.js +26 -0
- package/docs/src/components/tableControls/Filters.js +47 -0
- package/docs/src/components/tableControls/FirstPage.js +9 -0
- package/docs/src/components/tableControls/HiddenCount.js +3 -0
- package/docs/src/components/tableControls/Hide.js +5 -0
- package/docs/src/components/tableControls/LastPage.js +9 -0
- package/docs/src/components/tableControls/NextPage.js +9 -0
- package/docs/src/components/tableControls/PageSelect.js +22 -0
- package/docs/src/components/tableControls/PageSize.js +5 -0
- package/docs/src/components/tableControls/PrevPage.js +9 -0
- package/docs/src/components/tableControls/Search.js +9 -0
- package/docs/src/components/tableControls/ShowAll.js +5 -0
- package/docs/src/components/tableControls/TableControl.js +16 -0
- package/docs/src/utils/toTitleCase.js +1 -0
- package/docs/utils/drag.html +13 -28
- package/docs/utils/toTitleCase.html +71 -0
- package/package.json +1 -1
- package/scripts/build.js +3 -0
- package/src/components/Dialog.js +35 -27
- package/docs/src/utils/cli.js +0 -1
- package/docs/src/utils/fs-utils.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ShadowComponent from"./ShadowComponent.js";import{html,css}from"../lit-all.min.js";import{boolExists}from"../utils/propConverters.js";import"./Icon.js";const firstFocusable=t=>t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')[0];export default class Dialog extends ShadowComponent{static properties={opened:{type:Boolean,reflect:!0,converter:boolExists},closeBtn:{type:Boolean,reflect:!0,attribute:"close-btn",converter:boolExists},overlayClose:{type:Boolean,reflect:!0,attribute:"overlay-close",converter:boolExists},confirmText:{type:String,reflect:!0,attribute:"confirm-text"},confirmClasses:{type:String,reflect:!0,attribute:"confirm-classes"},cancelText:{type:String,reflect:!0,attribute:"cancel-text"},cancelClasses:{type:String,reflect:!0,attribute:"cancel-classes"}};constructor(){super(),this.opened=!1,this.closeBtn=!0,this.overlayClose=!0,this.confirmText="",this.confirmClasses="success ml",this.cancelText="",this.cancelClasses="",this.confirmAction=()=>{},this.cancelAction=()=>{},this.closeCallback=()=>{},this.previousFocus=null}handleClick=t=>{const{target:e}=t,o=e.id||e.closest("[id]")?.id;"overlay"===o&&this.overlayClose||"close"===o?this.close():"cancel"===o?(this.cancelAction(t),t.defaultPrevented||this.close()):"confirm"===o&&(this.confirmAction(t),t.defaultPrevented||this.close())};handleKeydown=t=>{27===t.keyCode&&this.close()};connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.handleKeydown)}updated(t){super.updated(t),t.has("opened")&&this.dispatchEvent(new CustomEvent(this.opened?"opened":"close"))}open(){this.opened=!0,window.addEventListener("keydown",this.handleKeydown);const t=this.updateComplete||this.requestUpdate();t&&t.then?t.then(()=>{const t=this.shadowRoot.querySelector("[autofocus]")||firstFocusable(this.shadowRoot);t&&t.focus()}):setTimeout(()=>{const t=this.shadowRoot.querySelector("[autofocus]")||firstFocusable(this.shadowRoot);t&&t.focus()},0)}close(){this.opened=!1,this.blur(),this.closeCallback(),window.removeEventListener("keydown",this.handleKeydown)}toggle(){this.opened?this.close():this.open()}focus(){const t=firstFocusable(this.shadowRoot);t&&(this.previousFocus=document.activeElement,t.focus())}blur(){this.previousFocus&&this.previousFocus.focus()}hasTitle(){return!!this.querySelector('[slot="title"]')}static styles=css`
|
|
1
|
+
import ShadowComponent from"./ShadowComponent.js";import{html,css}from"../lit-all.min.js";import{boolExists}from"../utils/propConverters.js";import"./Icon.js";import"./FocusCapture.js";const firstFocusable=t=>t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')[0];export default class Dialog extends ShadowComponent{static properties={opened:{type:Boolean,reflect:!0,converter:boolExists},closeBtn:{type:Boolean,reflect:!0,attribute:"close-btn",converter:boolExists},overlayClose:{type:Boolean,reflect:!0,attribute:"overlay-close",converter:boolExists},confirmText:{type:String,reflect:!0,attribute:"confirm-text"},confirmClasses:{type:String,reflect:!0,attribute:"confirm-classes"},cancelText:{type:String,reflect:!0,attribute:"cancel-text"},cancelClasses:{type:String,reflect:!0,attribute:"cancel-classes"}};constructor(){super(),this.opened=!1,this.closeBtn=!0,this.overlayClose=!0,this.confirmText="",this.confirmClasses="success ml",this.cancelText="",this.cancelClasses="",this.confirmAction=()=>{},this.cancelAction=()=>{},this.closeCallback=()=>{},this.previousFocus=null}handleClick=t=>{const{target:e}=t,o=e.id||e.closest("[id]")?.id;"overlay"===o&&this.overlayClose||"close"===o?this.close():"cancel"===o?(this.cancelAction(t),t.defaultPrevented||this.close()):"confirm"===o&&(this.confirmAction(t),t.defaultPrevented||this.close())};handleKeydown=t=>{27===t.keyCode&&this.close()};connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.handleKeydown)}updated(t){super.updated(t),t.has("opened")&&this.dispatchEvent(new CustomEvent(this.opened?"opened":"close"))}open(){this.opened=!0,window.addEventListener("keydown",this.handleKeydown);const t=this.updateComplete||this.requestUpdate();t&&t.then?t.then(()=>{const t=this.shadowRoot.querySelector("[autofocus]")||firstFocusable(this.shadowRoot);t&&t.focus()}):setTimeout(()=>{const t=this.shadowRoot.querySelector("[autofocus]")||firstFocusable(this.shadowRoot);t&&t.focus()},0)}close(){this.opened=!1,this.blur(),this.closeCallback(),window.removeEventListener("keydown",this.handleKeydown)}toggle(){this.opened?this.close():this.open()}focus(){const t=firstFocusable(this.shadowRoot);t&&(this.previousFocus=document.activeElement,t.focus())}blur(){this.previousFocus&&this.previousFocus.focus()}hasTitle(){return!!this.querySelector('[slot="title"]')}static styles=css`
|
|
2
2
|
:host {
|
|
3
3
|
position: fixed;
|
|
4
4
|
top: 0;
|
|
@@ -57,6 +57,11 @@ import ShadowComponent from"./ShadowComponent.js";import{html,css}from"../lit-al
|
|
|
57
57
|
background: transparent;
|
|
58
58
|
box-shadow: 0 0 0 transparent;
|
|
59
59
|
color: var(--tc);
|
|
60
|
+
transition: box-shadow var(--animation_ms);
|
|
61
|
+
border-radius: var(--radius);
|
|
62
|
+
}
|
|
63
|
+
#close:focus {
|
|
64
|
+
box-shadow: var(--focus_shadow);
|
|
60
65
|
}
|
|
61
66
|
#close k-icon {
|
|
62
67
|
pointer-events: none;
|
|
@@ -78,36 +83,38 @@ import ShadowComponent from"./ShadowComponent.js";import{html,css}from"../lit-al
|
|
|
78
83
|
aria-modal="true"
|
|
79
84
|
aria-labelledby="title"
|
|
80
85
|
>
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
`:""}
|
|
93
|
-
</div>
|
|
94
|
-
<div id="body">
|
|
95
|
-
<slot></slot>
|
|
96
|
-
</div>
|
|
97
|
-
${this.cancelText||this.confirmText?html`
|
|
98
|
-
<div id="footer">
|
|
99
|
-
${this.cancelText?html`
|
|
100
|
-
<button id="cancel" class="${this.cancelClasses}" @click=${this.handleClick}>
|
|
101
|
-
${this.cancelText}
|
|
102
|
-
</button>
|
|
103
|
-
`:""}
|
|
104
|
-
${this.confirmText?html`
|
|
105
|
-
<button id="confirm" class="${this.confirmClasses}" @click=${this.handleClick}>
|
|
106
|
-
${this.confirmText}
|
|
86
|
+
<k-focus-capture>
|
|
87
|
+
<div
|
|
88
|
+
id="header"
|
|
89
|
+
class="${this.hasTitle()?"has-title":""}"
|
|
90
|
+
>
|
|
91
|
+
<div id="title">
|
|
92
|
+
<slot name="title"></slot>
|
|
93
|
+
</div>
|
|
94
|
+
${this.closeBtn?html`
|
|
95
|
+
<button id="close" @click=${this.handleClick}>
|
|
96
|
+
<k-icon name="close"></k-icon>
|
|
107
97
|
</button>
|
|
108
98
|
`:""}
|
|
109
99
|
</div>
|
|
110
|
-
|
|
100
|
+
<div id="body">
|
|
101
|
+
<slot></slot>
|
|
102
|
+
</div>
|
|
103
|
+
${this.cancelText||this.confirmText?html`
|
|
104
|
+
<div id="footer">
|
|
105
|
+
${this.cancelText?html`
|
|
106
|
+
<button id="cancel" class="${this.cancelClasses}" @click=${this.handleClick}>
|
|
107
|
+
${this.cancelText}
|
|
108
|
+
</button>
|
|
109
|
+
`:""}
|
|
110
|
+
${this.confirmText?html`
|
|
111
|
+
<button id="confirm" class="${this.confirmClasses}" @click=${this.handleClick}>
|
|
112
|
+
${this.confirmText}
|
|
113
|
+
</button>
|
|
114
|
+
`:""}
|
|
115
|
+
</div>
|
|
116
|
+
`:""}
|
|
117
|
+
</k-focus-capture>
|
|
111
118
|
</div>
|
|
112
119
|
</div>
|
|
113
120
|
`}static create(t="",e={}){!1!==e.closeExisting&&document.querySelectorAll("k-dialog").forEach(t=>t.close());const{removeOnClose:o=!0,closeCallback:s=()=>{}}=e,i=new Dialog;return Object.assign(i,{opened:!0,...e,closeCallback:(...t)=>{o&&i.remove(),s(...t)}}),t instanceof HTMLElement||t instanceof DocumentFragment?i.appendChild(t):t&&(i.innerHTML=t),e.width&&i.style.setProperty("--width",e.width),e.minWidth&&i.style.setProperty("--min_width",e.minWidth),e.maxWidth&&i.style.setProperty("--max_width",e.maxWidth),e.height&&i.style.setProperty("--height",e.height),e.minHeight&&i.style.setProperty("--min_height",e.minHeight),e.maxHeight&&i.style.setProperty("--max_height",e.maxHeight),document.body.appendChild(i),i.open(),i}static confirm(t,e,o={}){const s=o.title||"Confirm";return Dialog.create(`\n\t\t\t<h5 slot="title" class="pyh px m0">${s}</h5>\n\t\t\t<p class="p">${t}</p>\n\t\t`,{closeBtn:!1,overlayClose:!1,confirmText:"Yes",confirmClasses:"success ml",confirmAction:()=>e(!0),cancelText:"No",cancelClasses:"danger",cancelAction:()=>e(!1),...o})}static alert(t,e,o={}){const s=o.title||"Alert";return Dialog.create(`\n\t\t\t<h5 slot="title" class="pyh px m0">${s}</h5>\n\t\t\t<p class="p">${t}</p>\n\t\t`,{closeCallback:e,cancelText:"Ok",...o})}static error(t,e,o={}){const s=o.title||"Error";return Dialog.create(`\n\t\t\t<h5 slot="title" class="pyh px m0 tc-danger">${s}</h5>\n\t\t\t<p class="p">${t}</p>\n\t\t`,{closeCallback:e,cancelText:"Ok",...o})}static success(t,e,o={}){const s=o.title||"Success";return Dialog.create(`\n\t\t\t<h5 slot="title" class="pyh px m0 tc-success">${s}</h5>\n\t\t\t<p class="p">${t}</p>\n\t\t`,{closeCallback:e,cancelText:"Ok",...o})}}customElements.define("k-dialog",Dialog);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LitElement}from"../lit-all.min.js";export default class ShadowComponent extends LitElement{createRenderRoot(){const
|
|
1
|
+
import{LitElement}from"../lit-all.min.js";export default class ShadowComponent extends LitElement{static stylesheetPath="/kempo.min.css";createRenderRoot(){const t=this.attachShadow({mode:"open"}),e=document.createElement("link");e.rel="stylesheet",e.href=this.constructor.stylesheetPath,t.appendChild(e);const n=this.constructor.styles;if(n){const e=document.createElement("style");Array.isArray(n)?e.textContent=n.map(t=>t.cssText||t).join("\n"):e.textContent=n.cssText||n,t.appendChild(e)}const s=document.createElement("div");return s.style.display="contents",t.appendChild(s),s}}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import{LitElement,html,css}from"../lit-all.min.js";import drag from"../utils/drag.js";export class Sortable extends LitElement{getCursorElement(){const t=Array.from(this.children).filter(t=>"K-SORTABLE-ITEM"===t.tagName&&!t.hasAttribute("sorting"));if(0===t.length)return null;const e=event.clientY;if(e<t[0].getBoundingClientRect().top)return[t[0],"before"];if(e>t[t.length-1].getBoundingClientRect().bottom)return[t[t.length-1],"after"];for(const r of t){const t=r.getBoundingClientRect();if(e<t.top+t.height/2)return[r,"before"];if(e<t.bottom)return[r,"after"]}return null}render(){return html`<slot></slot>`}static styles=css`
|
|
2
|
+
:host {
|
|
3
|
+
display: block;
|
|
4
|
+
}
|
|
5
|
+
`}customElements.define("k-sortable",Sortable);export class SortableItem extends LitElement{static properties={sorting:{type:Boolean,reflect:!0}};constructor(){super(),this.cleanupDrag=null}firstUpdated(){this.setupDrag()}updated(t){super.updated(t),t.has("sorting")&&!this.sorting&&this.setupDrag()}disconnectedCallback(){super.disconnectedCallback(),this.cleanupDrag&&(this.cleanupDrag(),this.cleanupDrag=null)}setupDrag(){this.cleanupDrag&&this.cleanupDrag();const t=this.shadowRoot.getElementById("handle");t&&(this.cleanupDrag=drag({element:t,startCallback:this.handleDragStart,moveCallback:this.handleDragMove,endCallback:this.handleDragEnd}))}handleDragStart=()=>{this.sorting=!0};handleDragMove=({y:t})=>{this.style.transform=`translateY(${t}px)`,this.style.zIndex="9999";const[e,r]=this.sortable.getCursorElement();Array.from(this.sortable.children).forEach(t=>{t.classList.remove("target-before","target-after")}),e&&e.classList.add(`target-${r}`)};handleDragEnd=()=>{this.sorting=!1,this.style.transform="",this.style.zIndex="";const[t,e]=this.sortable.getCursorElement();Array.from(this.sortable.children).forEach(t=>{t.classList.remove("target-before","target-after")}),t&&("before"===e?this.sortable.insertBefore(this,t):"after"===e&&this.sortable.insertBefore(this,t.nextSibling),this.sortable.dispatchEvent(new CustomEvent("sort",{bubbles:!0})))};get sortable(){return this.closest("k-sortable")}render(){return html`
|
|
6
|
+
<div id="handle">
|
|
7
|
+
<k-icon name="drag-handle"></k-icon>
|
|
8
|
+
</div>
|
|
9
|
+
<div id="content" class="p pl0">
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</div>
|
|
12
|
+
`}static styles=css`
|
|
13
|
+
:host {
|
|
14
|
+
display: block;
|
|
15
|
+
border: 1px solid var(--c_border);
|
|
16
|
+
user-select: none;
|
|
17
|
+
position: relative;
|
|
18
|
+
}
|
|
19
|
+
:host([sorting]){
|
|
20
|
+
opacity: 0.8;
|
|
21
|
+
}
|
|
22
|
+
#handle {
|
|
23
|
+
display: inline-block;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
padding: var(--spacer);
|
|
26
|
+
}
|
|
27
|
+
#content {
|
|
28
|
+
display: inline-block;
|
|
29
|
+
}
|
|
30
|
+
:host(.target-before)::before,
|
|
31
|
+
:host(.target-after)::after {
|
|
32
|
+
content: '';
|
|
33
|
+
position: absolute;
|
|
34
|
+
left: 0;
|
|
35
|
+
right: 0;
|
|
36
|
+
height: 4px;
|
|
37
|
+
background-color: var(--c_primary);
|
|
38
|
+
}
|
|
39
|
+
:host(.target-before)::before {
|
|
40
|
+
top: -2px;
|
|
41
|
+
}
|
|
42
|
+
:host(.target-after)::after {
|
|
43
|
+
bottom: -2px;
|
|
44
|
+
}
|
|
45
|
+
`}customElements.define("k-sortable-item",SortableItem);
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import{html,css,unsafeStatic,literal}from"../lit-all.min.js";import ShadowComponent from"./ShadowComponent.js";import toTitleCase from"../utils/toTitleCase.js";import{boolExists}from"../utils/propConverters.js";const selected=Symbol("selected"),hidden=Symbol("hidden"),index=Symbol("index"),editing=Symbol("editing");export default class Table extends ShadowComponent{static properties={enablePages:{type:Boolean,reflect:!0,converter:boolExists,attribute:"enable-pages"},pageSize:{type:Number,reflect:!0,attribute:"page-size"},currentPage:{type:Number,reflect:!0,attribute:"current-page"},pageSizeOptions:{type:Array,attribute:"page-size-options"},enableSelection:{type:Boolean,reflect:!0,converter:boolExists,attribute:"enable-selection"},enableSorting:{type:Boolean,reflect:!0,converter:boolExists,attribute:"enable-sorting"},caseSensitiveFilters:{type:Boolean,reflect:!0,converter:boolExists,attribute:"case-sensitive-filters"},fields:{type:Array},records:{type:Array},filters:{type:Array},sort:{type:Array},columnSizes:{type:Object},fetchPending:{type:Boolean}};static styles=css`
|
|
2
|
+
:host {
|
|
3
|
+
display: block;
|
|
4
|
+
width: 100%;
|
|
5
|
+
overflow: auto;
|
|
6
|
+
margin-bottom: var(--spacer);
|
|
7
|
+
}
|
|
8
|
+
#wrapper {
|
|
9
|
+
width: min-content;
|
|
10
|
+
border: 1px solid var(--c_border);
|
|
11
|
+
border-radius: var(--radius);
|
|
12
|
+
}
|
|
13
|
+
#table {
|
|
14
|
+
width: min-content;
|
|
15
|
+
}
|
|
16
|
+
#fields,
|
|
17
|
+
.record {
|
|
18
|
+
display: flex;
|
|
19
|
+
}
|
|
20
|
+
#fields {
|
|
21
|
+
background-color: var(--c_bg__alt);
|
|
22
|
+
border-bottom: 1px solid var(--c_border);
|
|
23
|
+
}
|
|
24
|
+
.record:not([editing="true"]) .cell:not(.controls),
|
|
25
|
+
#fields .cell:not(.controls) {
|
|
26
|
+
padding: calc(0.5 * var(--spacer)) var(--spacer);
|
|
27
|
+
}
|
|
28
|
+
.cell {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
}
|
|
32
|
+
.cell:not(:first-child) {
|
|
33
|
+
border-left: 1px solid var(--c_border);
|
|
34
|
+
}
|
|
35
|
+
.record:not(:last-child) .cell {
|
|
36
|
+
border-bottom: 1px solid var(--c_border);
|
|
37
|
+
}
|
|
38
|
+
#top, #bottom {
|
|
39
|
+
display: flex;
|
|
40
|
+
width: 100%;
|
|
41
|
+
}
|
|
42
|
+
#top slot {
|
|
43
|
+
display: block;
|
|
44
|
+
width: 100%;
|
|
45
|
+
border-bottom: 1px solid var(--c_border);
|
|
46
|
+
}
|
|
47
|
+
#bottom slot {
|
|
48
|
+
display: block;
|
|
49
|
+
width: 100%;
|
|
50
|
+
border-top: 1px solid var(--c_border);
|
|
51
|
+
}
|
|
52
|
+
:host(:not([top-controls])) #top,
|
|
53
|
+
:host(:not([bottom-controls])) #bottom {
|
|
54
|
+
display: none;
|
|
55
|
+
}
|
|
56
|
+
.field-select,
|
|
57
|
+
.selection {
|
|
58
|
+
display: flex;
|
|
59
|
+
justify-content: center;
|
|
60
|
+
align-items: center;
|
|
61
|
+
}
|
|
62
|
+
.field-select input,
|
|
63
|
+
.selection input {
|
|
64
|
+
width: 1.25rem;
|
|
65
|
+
height: 1.25rem;
|
|
66
|
+
}
|
|
67
|
+
.icon-sort {
|
|
68
|
+
float: right;
|
|
69
|
+
opacity: 0.5;
|
|
70
|
+
}
|
|
71
|
+
`;constructor(e={}){super(),void 0===this.pageSize&&(this.pageSize=50),void 0===this.currentPage&&(this.currentPage=1),void 0===this.pageSizeOptions&&(this.pageSizeOptions=[10,25,50,100,500]),void 0===this.records&&(this.records=e.records||[]),void 0===this.fields&&(this.fields=e.fields||[]),void 0===this.filters&&(this.filters=e.filters||[]),void 0===this.sort&&(this.sort=[]),void 0===this.columnSizes&&(this.columnSizes={}),void 0===this.fetchPending&&(this.fetchPending=!1)}handleSelectAllChange=e=>{e.target.checked?this.selectAllOnPage():this.deselectAllOnPage()};handleFieldClick=e=>{const t=this.sort.find(t=>t.name===e),s=!t||!t.asc;this.sortBy(e,s)};handleRecordSelectionChange=(e,t)=>{e[selected]=!!t.target.checked,this.dispatchEvent(new CustomEvent("selectionChange",{bubbles:!0}))};firstUpdated(){this.setData({records:this.records,fields:this.fields,filters:this.filters})}updated(e){if(super.updated(e),this.enableSelection){const e=this.shadowRoot.getElementById("select-all");e&&(e.checked=this.allOnPageSelected())}this.updateContainerWidths()}updateContainerWidths(){const e=this.columnSizes.total+"px",t=this.shadowRoot.getElementById("fields"),s=this.shadowRoot.getElementById("top"),i=this.shadowRoot.getElementById("bottom"),r=this.shadowRoot.getElementById("records");t&&(t.style.width=e),s&&(s.style.width=e),i&&(i.style.width=e),r&&(r.style.width=e)}renderFieldsTemplate(){this.calculateColumnSizes(),this.hasTopControls()?this.setAttribute("top-controls","true"):this.removeAttribute("top-controls"),this.hasBottomControls()?this.setAttribute("bottom-controls","true"):this.removeAttribute("bottom-controls");const e=[];return this.enableSelection&&e.push(html`
|
|
72
|
+
<div class="field controls cell field-select" style="width: 40px">
|
|
73
|
+
<input
|
|
74
|
+
type="checkbox"
|
|
75
|
+
id="select-all"
|
|
76
|
+
@change=${this.handleSelectAllChange}
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
`),this.hasBeforeControls()&&e.push(html`
|
|
80
|
+
<div class="field cell field-before-controls" style="width: ${this.columnSizes.beforeControls}px"></div>
|
|
81
|
+
`),this.fields.forEach(({name:t,label:s,hidden:i})=>{if(i)return;const r=this.sort.find(e=>e.name===t),o=this.sort.length>0&&this.sort[this.sort.length-1].name===t,l=r?r.asc?"sort-asc":"sort-desc":"";e.push(html`
|
|
82
|
+
<div
|
|
83
|
+
class="field cell ${l}"
|
|
84
|
+
style="width: ${this.columnSizes[t]}px; ${this.enableSorting?"cursor: pointer;":""}"
|
|
85
|
+
@click=${this.enableSorting?()=>this.handleFieldClick(t):null}
|
|
86
|
+
>
|
|
87
|
+
${s}
|
|
88
|
+
${o?html`<k-icon name="${r.asc?"arrow-down":"arrow-up"}" class="icon-sort"></k-icon>`:""}
|
|
89
|
+
</div>
|
|
90
|
+
`)}),this.hasAfterControls()&&e.push(html`
|
|
91
|
+
<div class="field cell field-after-controls" style="width: ${this.columnSizes.afterControls}px"></div>
|
|
92
|
+
`),e}renderRecordsTemplate(){let e=this.getDisplayedRecords(),t=0,s=this.pageSize;this.enablePages&&(t=(this.currentPage-1)*this.pageSize,s=t+this.pageSize,e=e.slice(t,s));let i=null,r=0;const o=e.map((e,s)=>null!==e?this.renderRecordTemplate(e):(null===i&&(i=t+s),r++,html`<div class="record fetching"><div class="cell">Loading...</div></div>`));return null===i||this.fetchPending||setTimeout(()=>{this.fetchPending||this.dispatchEvent(new CustomEvent("fetchRecords",{detail:{start:i,count:r},bubbles:!0}))},0),o}renderRecordTemplate(e){const t=[];return this.enableSelection&&t.push(html`
|
|
93
|
+
<div class="cell selection controls" style="width: 40px">
|
|
94
|
+
<input
|
|
95
|
+
type="checkbox"
|
|
96
|
+
.checked=${e[selected]}
|
|
97
|
+
@change=${t=>this.handleRecordSelectionChange(e,t)}
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
100
|
+
`),this.hasBeforeControls()&&t.push(this.renderBeforeControlsTemplate()),this.fields.forEach(({name:s,formatter:i,calculator:r,type:o,editor:l,hidden:n})=>{if(n)return;let d=e[s]||"";t.push(html`
|
|
101
|
+
<div class="cell" data-field=${s} style="width: ${this.columnSizes[s]}px">
|
|
102
|
+
${e[editing]?this.renderEditingCell(e,s,d,r,l,o):this.renderDisplayCell(e,s,d,r,i)}
|
|
103
|
+
</div>
|
|
104
|
+
`)}),this.hasAfterControls()&&t.push(this.renderAfterControlsTemplate()),html`
|
|
105
|
+
<div class="record ${e[editing]?"editing":""}" data-index=${e[index]}>
|
|
106
|
+
${t}
|
|
107
|
+
</div>
|
|
108
|
+
`}renderEditingCell(e,t,s,i,r,o){if(i)return html`<input disabled .value=${i(e,this)} />`;if(r){const e=r(s);return html`${e}`}switch(o||typeof s){case"number":return html`<input type="number" .value=${s} />`;case"date":return html`<input type="date" .value=${s} />`;case"boolean":return html`
|
|
109
|
+
<select .value=${s}>
|
|
110
|
+
<option value="true" ?selected=${s}>True</option>
|
|
111
|
+
<option value="false" ?selected=${!s}>False</option>
|
|
112
|
+
</select>
|
|
113
|
+
`;default:return html`<input type="text" .value=${s} />`}}renderDisplayCell(e,t,s,i,r){return i?i(e,this):r?r(s):s}renderBeforeControlsTemplate(){const e=[];return this.querySelectorAll('[slot="before"]').forEach(t=>{const s=new t.constructor;Array.from(t.attributes).forEach(e=>{"slot"!==e.name&&s.setAttribute(e.name,e.value)}),t.innerHTML&&(s.innerHTML=t.innerHTML),e.push(s)}),html`
|
|
114
|
+
<div class="cell controls controls-before" style="width: ${this.columnSizes.beforeControls}px">
|
|
115
|
+
${e}
|
|
116
|
+
</div>
|
|
117
|
+
`}renderAfterControlsTemplate(){const e=[];return this.querySelectorAll('[slot="after"]').forEach(t=>{const s=new t.constructor;Array.from(t.attributes).forEach(e=>{"slot"!==e.name&&s.setAttribute(e.name,e.value)}),t.innerHTML&&(s.innerHTML=t.innerHTML),e.push(s)}),html`
|
|
118
|
+
<div class="cell controls controls-after" style="width: ${this.columnSizes.afterControls}px">
|
|
119
|
+
${e}
|
|
120
|
+
</div>
|
|
121
|
+
`}hasBeforeControls(){return!!this.querySelector('[slot="before"]')}hasAfterControls(){return!!this.querySelector('[slot="after"]')}hasTopControls(){return!!this.querySelector('[slot="top"]')}hasBottomControls(){return!!this.querySelector(":scope > :not([slot])")}editRecord(e){e[editing]=!0;const t=this.shadowRoot.querySelector(`.record[data-index="${e[index]}"]`);t&&(t.classList.add("editing"),t.setAttribute("editing","true"),t.querySelectorAll(".cell[data-field]").forEach(t=>{const s=t.dataset.field,i=this.fields.find(e=>e.name===s);if(i){const r=e[s]||"";if(t.innerHTML="",i.calculator){const s=document.createElement("input");s.disabled=!0,s.value=i.calculator(e,this),t.appendChild(s)}else if(i.editor)t.appendChild(i.editor(r));else{const e=i.type||typeof r,s=Table.editors[e]||Table.editors.string;t.appendChild(s(r))}}})),this.dispatchEvent(new CustomEvent("editingChange",{detail:{record:e,editing:!0},bubbles:!0}))}saveEditedRecord(e){const t=this.shadowRoot.querySelector(`.record[data-index="${e[index]}"]`);t&&(t.querySelectorAll(".cell[data-field]").forEach(t=>{const s=t.dataset.field,i=this.fields.find(e=>e.name===s);if(i&&!i.calculator){const i=t.querySelector("input, select");i&&(e[s]=i.value)}}),e[editing]=!1,t.classList.remove("editing"),t.removeAttribute("editing"),t.querySelectorAll(".cell[data-field]").forEach(t=>{const s=t.dataset.field,i=this.fields.find(e=>e.name===s);if(i){const r=e[s]||"";i.calculator?t.textContent=i.calculator(e,this):i.formatter?t.innerHTML=i.formatter(r):t.textContent=r}})),this.dispatchEvent(new CustomEvent("editingChange",{detail:{record:e,editing:!1},bubbles:!0}))}cancelEditedRecord(e){e[editing]=!1;const t=this.shadowRoot.querySelector(`.record[data-index="${e[index]}"]`);t&&(t.classList.remove("editing"),t.removeAttribute("editing"),t.querySelectorAll(".cell[data-field]").forEach(t=>{const s=t.dataset.field,i=this.fields.find(e=>e.name===s);if(i){const r=e[s]||"";i.calculator?t.textContent=i.calculator(e,this):i.formatter?t.innerHTML=i.formatter(r):t.textContent=r}})),this.dispatchEvent(new CustomEvent("editingChange",{detail:{record:e,editing:!1},bubbles:!0}))}recordIsEditing(e){return e[editing]}getCurrentPage(){return this.currentPage}getTotalPages(){return Math.ceil(this.getDisplayedRecords().length/this.pageSize)}setPage(e){e<1||e>this.getTotalPages()||(this.currentPage=e,this.requestUpdate(),this.dispatchEvent(new CustomEvent("pageChange",{bubbles:!0})))}firstPage(){1!==this.currentPage&&this.setPage(1)}nextPage(){this.currentPage<this.getTotalPages()&&this.setPage(this.currentPage+1)}prevPage(){this.currentPage>1&&this.setPage(this.currentPage-1)}lastPage(){this.currentPage!==this.getTotalPages()&&this.setPage(this.getTotalPages())}setPageSize(e){this.pageSize=e,this.currentPage=1,this.requestUpdate(),this.dispatchEvent(new CustomEvent("pageSizeChange",{bubbles:!0}))}getPageSize(){return this.pageSize}getPageSizeOptions(){return this.pageSizeOptions}setPageSizeOptions(e){this.pageSizeOptions=e,this.requestUpdate()}setData({records:e=!1,fields:t=!1,pageSize:s=!1,pageSizeOptions:i=!1,currentPage:r=!1,enableSelection:o}={}){let l=!1,n=this.getTotalPages(),d=this.currentPage;e&&(this.records=e.map(e=>({...e})),this.records.forEach((e,t)=>{e[index]=t,e[selected]=!1,e[hidden]=!1,e[editing]=!1}),this.fields=t||Table.extractFieldsFromRecords(this.records),l=!0),s&&(this.pageSize=s,l=!0),i&&(this.pageSizeOptions=i),r&&(this.currentPage=r,l=!0),void 0!==o&&(this.enableSelection=o,l=!0),l&&this.requestUpdate();const a=this.getTotalPages();a!==n&&this.dispatchEvent(new CustomEvent("pageCountChanged",{detail:{totalPages:this.getTotalPages()},bubbles:!0})),d>a&&this.setPage(a)}setRecords(e,t){let s=this.getTotalPages(),i=this.currentPage;this.records=e.map(e=>({...e})),this.records.forEach((e,t)=>{e[index]=t,e[selected]=!1,e[hidden]=!1,e[editing]=!1}),this.fields=t||Table.extractFieldsFromRecords(this.records),this.requestUpdate(),this.dispatchEvent(new CustomEvent("recordsSet",{detail:{records:e},bubbles:!0}));const r=this.getTotalPages();r!==s&&this.dispatchEvent(new CustomEvent("pageCountChanged",{detail:{totalPages:this.getTotalPages()},bubbles:!0})),i>r&&this.setPage(r)}setupFetchRecords(e,t){const s=this.records.length,i=this.getTotalPages();if(s<e){this.records.length=e,this.records.fill(null,s),this.requestUpdate();const t=this.getTotalPages();t!==i&&setTimeout(()=>{this.dispatchEvent(new CustomEvent("pageCountChanged",{detail:{totalPages:t},bubbles:!0}))},0)}this.addEventListener("fetchRecords",async e=>{if(this.fetchPending)return;this.fetchPending=!0;const{start:s,count:i}=e.detail,r=await t(s,i);r.forEach((e,t)=>{e[index]=s+t,void 0===e[selected]&&(e[selected]=!1),void 0===e[hidden]&&(e[hidden]=!1),void 0===e[editing]&&(e[editing]=!1)}),this.records.splice(s,r.length,...r),this.fetchPending=!1,this.requestUpdate()})}addRecord(e){e[selected]=!1,e[hidden]=!1,e[index]=this.records.length,this.records.push(e),this.requestUpdate(),this.dispatchEvent(new CustomEvent("recordAdded",{detail:{record:e},bubbles:!0}))}updateRecord(e,t){let s=!1,i=this.records.find(t=>t===e);if(i||void 0===e[index]||(i=this.records[e[index]]),Object.keys(t).forEach(e=>{i.hasOwnProperty(e)&&(i[e]=t[e],s=!0)}),s){const e=(this.currentPage-1)*this.pageSize,t=e+this.pageSize;(!this.enablePages||i[index]>=e&&i[index]<t)&&this.requestUpdate()}}deleteRecord(e){let t=this.records.find(t=>t===e),s=this.getTotalPages();if(t||void 0===e[index]||(t=this.records[e[index]]),t){const e=this.records.indexOf(t);this.records.splice(e,1),this.records.forEach((e,t)=>{e[index]=t}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("selectionChange",{bubbles:!0})),this.dispatchEvent(new CustomEvent("recordDeleted",{detail:{index:e},bubbles:!0}));const i=this.getTotalPages();this.currentPage>i&&this.setPage(i),i!==s&&this.dispatchEvent(new CustomEvent("pageCountChanged",{detail:{totalPages:i},bubbles:!0}))}}deleteSelected(){let e=this.getTotalPages();this.getSelectedRecords().forEach(e=>{let t=this.records.find(t=>t===e);if(t||void 0===e[index]||(t=this.records[e[index]]),t){const e=this.records.indexOf(t);this.records.splice(e,1)}}),this.records.forEach((e,t)=>{e[index]=t}),this.requestUpdate();const t=this.getTotalPages();this.currentPage>t&&this.setPage(t),t!==e&&this.dispatchEvent(new CustomEvent("pageCountChanged",{detail:{totalPages:t},bubbles:!0})),this.dispatchEvent(new CustomEvent("selectionChange",{bubbles:!0}))}getSelectedRecords(){return this.records.filter(e=>e[selected])}selectAllOnPage(){const e=(this.currentPage-1)*this.pageSize,t=Math.min(e+this.pageSize,this.records.length);for(let s=e;s<t;s++)this.records[s][selected]=!0;this.requestUpdate(),setTimeout(()=>{this.dispatchEvent(new CustomEvent("selectionChange",{bubbles:!0}))},0)}deselectAllOnPage(){const e=(this.currentPage-1)*this.pageSize,t=Math.min(e+this.pageSize,this.records.length);for(let s=e;s<t;s++)this.records[s][selected]=!1;this.requestUpdate(),setTimeout(()=>{this.dispatchEvent(new CustomEvent("selectionChange",{bubbles:!0}))},0)}allOnPageSelected(){const e=(this.currentPage-1)*this.pageSize,t=Math.min(e+this.pageSize,this.records.length);for(let s=e;s<t;s++)if(!this.records[s][selected])return!1;return!0}sortBy(e,t=!0){this.sort=this.sort.filter(t=>t.name!==e),this.sort.push({name:e,asc:t}),this.requestUpdate()}hideRecord(e){let t=this.records.find(t=>t===e);t||void 0===e[index]||(t=this.records[e[index]]),t&&(t[hidden]=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("recordHidden",{bubbles:!0})))}showRecord(e){let t=this.records.find(t=>t===e);t||void 0===e[index]||(t=this.records[e[index]]),t&&(t[hidden]=!1,this.requestUpdate(),this.dispatchEvent(new CustomEvent("recordShown",{bubbles:!0})))}showAllRecords(){this.records.forEach(e=>{e[hidden]=!1}),this.filters.length&&(this.filters=[],this.dispatchEvent(new CustomEvent("filterRemoved",{bubbles:!0})),this.dispatchEvent(new CustomEvent("filterChange",{bubbles:!0}))),this.requestUpdate(),this.dispatchEvent(new CustomEvent("recordShown",{bubbles:!0})),this.dispatchEvent(new CustomEvent("allRecordsShown",{bubbles:!0}))}addFilter(e,t,s){this.filters.push({field:e,condition:t,value:s}),this.dispatchEvent(new CustomEvent("filterAdded",{bubbles:!0})),this.dispatchEvent(new CustomEvent("filterChange",{bubbles:!0})),this.requestUpdate()}removeFilter(e,t,s,i=!0){const r=this.filters.findIndex(i=>i.field===e&&i.condition===t&&i.value===s);-1!==r&&(this.records.forEach(i=>{this.testFilter(i,e,t,s)||(i[hidden]=!1)}),this.filters.splice(r,1),this.dispatchEvent(new CustomEvent("filterRemoved",{bubbles:!0})),this.dispatchEvent(new CustomEvent("filterChange",{bubbles:!0})),i&&this.requestUpdate())}testFilter(e,t,s,i){let r=e[t],o=i;switch(this.caseSensitiveFilters||"string"!=typeof r||"string"!=typeof i||(r=r.toLowerCase(),o=i.toLowerCase()),s){case"equals":return r===o;case"not-equals":return r!==o;case"contains":return r.includes(o);case"not-contains":return!r.includes(o);case"greater-than":return r>o;case"less-than":return r<o;case"greater-than-or-equal":return r>=o;case"less-than-or-equal":return r<=o;default:return!0}}removeAllFilters(){this.filters.length&&(this.filters.forEach(({field:e,condition:t,value:s})=>{this.removeFilter(e,t,s,!1)}),this.requestUpdate())}search(e){const t=e.trim().toLowerCase();let s=!1;this.records.forEach(e=>{if(e[hidden])return;let i=!1;this.fields.forEach(({name:s})=>{(e[s]?.toString().toLowerCase()||"").includes(t)&&(i=!0)}),e[hidden]!==!i&&(e[hidden]=!i,s=!0)}),s&&(this.dispatchEvent(new CustomEvent("recordHidden",{bubbles:!0})),this.requestUpdate()),this.dispatchEvent(new CustomEvent("search",{detail:{term:e},bubbles:!0}))}getDisplayedRecords(){this.filters.forEach(({field:e,condition:t,value:s})=>{this.records.forEach(i=>{null!==i&&(this.testFilter(i,e,t,s)||(i[hidden]=!0))})});let e=this.records.filter(e=>null===e||!e[hidden]);return this.sort.forEach(({name:t,asc:s})=>{e.sort((e,i)=>null===e||null===i?0:e[t]<i[t]?s?-1:1:e[t]>i[t]?s?1:-1:0)}),e}getHiddenRecords(){return this.records.filter(e=>e[hidden])}calculateColumnSizes(){return this.columnSizes={},this.columnSizes.total=0,this.enableSelection&&(this.columnSizes.total+=40),this.columnSizes.beforeControls=Array.from(this.querySelectorAll('[slot="before"]')).reduce((e,t)=>e+(t.maxWidth||40),0),this.columnSizes.afterControls=Array.from(this.querySelectorAll('[slot="after"]')).reduce((e,t)=>e+(t.maxWidth||40),0),this.hasBeforeControls()&&(this.columnSizes.total+=this.columnSizes.beforeControls),this.hasAfterControls()&&(this.columnSizes.total+=this.columnSizes.afterControls),this.fields.forEach(e=>{if(e.size)this.columnSizes[e.name]=e.size,this.columnSizes.total+=e.size;else{let t=0;this.records.slice(0,100).forEach(s=>{if(null===s)return;let i=s[e.name];e.calculator&&(i=e.calculator(s,this)),e.formatter&&(i=e.formatter(i)),i&&i.toString().length>t&&(t=i.toString().length)}),this.columnSizes[e.name]=Math.max(10*t+32,128),e.hidden||(this.columnSizes.total+=this.columnSizes[e.name])}}),this.columnSizes}setFieldHiddenState(e,t){const s=this.fields.find(t=>t.name===e);s&&(s.hidden=t,this.calculateColumnSizes(),this.requestUpdate(),this.dispatchEvent(new CustomEvent("fieldVisibilityChanged",{detail:{field:s},bubbles:!0})),this.dispatchEvent(new CustomEvent(t?"fieldHidden":"fieldShown",{detail:{field:s},bubbles:!0})))}hideField(e){this.setFieldHiddenState(e,!0)}showField(e){this.setFieldHiddenState(e,!1)}reorderFields(e){const t=[];e.forEach(e=>{const s=this.fields.find(t=>t.name===e);s&&t.push(s)}),this.fields=t,this.requestUpdate()}render(){return this.records&&this.fields?(this.calculateColumnSizes(),this.hasTopControls()?this.setAttribute("top-controls","true"):this.removeAttribute("top-controls"),this.hasBottomControls()?this.setAttribute("bottom-controls","true"):this.removeAttribute("bottom-controls"),html`
|
|
122
|
+
<div id="wrapper">
|
|
123
|
+
<div id="top" style="width: ${this.columnSizes.total}px"><slot name="top"></slot></div>
|
|
124
|
+
<div id="table">
|
|
125
|
+
<div id="fields" style="width: ${this.columnSizes.total}px">
|
|
126
|
+
${this.renderFieldsTemplate()}
|
|
127
|
+
</div>
|
|
128
|
+
<div id="records" style="width: ${this.columnSizes.total}px">
|
|
129
|
+
${this.renderRecordsTemplate()}
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
<div id="bottom" style="width: ${this.columnSizes.total}px"><slot></slot></div>
|
|
133
|
+
</div>
|
|
134
|
+
<div style="display: none">
|
|
135
|
+
<slot name="before"></slot>
|
|
136
|
+
<slot name="after"></slot>
|
|
137
|
+
</div>
|
|
138
|
+
`):html`
|
|
139
|
+
<div id="wrapper">
|
|
140
|
+
<div id="top"><slot name="top"></slot></div>
|
|
141
|
+
<div id="table">
|
|
142
|
+
<div id="fields"></div>
|
|
143
|
+
<div id="records"></div>
|
|
144
|
+
</div>
|
|
145
|
+
<div id="bottom"><slot></slot></div>
|
|
146
|
+
</div>
|
|
147
|
+
<div style="display: none">
|
|
148
|
+
<slot name="before"></slot>
|
|
149
|
+
<slot name="after"></slot>
|
|
150
|
+
</div>
|
|
151
|
+
`}static extractFieldsFromRecords(e,t=100){const s=new Set;return e.slice(0,t).forEach(e=>{Object.keys(e).forEach(e=>s.add(e))}),[...s].map(e=>({name:e,label:toTitleCase(e)}))}static format(e){return(Array.isArray(e)?Table.formatters.array:Table.formatters[typeof e])(e)}static formatters={string:e=>e,number:e=>`${e}`,date:e=>e.toLocaleDateString(),boolean:e=>e?"True":"False",array:e=>e.map(e=>Table.format(e)).join(", "),undefined:e=>"",null:e=>"<code>null</code>"};static editors={string:e=>{const t=document.createElement("input");return t.value=e,t},number:e=>{const t=document.createElement("input");return t.type="number",t.value=e,t},date:e=>{const t=document.createElement("input");return t.type="date",t.value=e,t},boolean:e=>{const t=document.createElement("select");return t.innerHTML=`\n <option value="true" ${e?"selected":""}>True</option>\n <option value="false" ${e?"":"selected"}>False</option>\n `,t.value=e,t},calculated:e=>{const t=document.createElement("input");return t.disabled=!0,t.value=e,t}}}window.customElements.define("k-table",Table);
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import{html,css}from"../lit-all.min.js";import ShadowComponent from"./ShadowComponent.js";import"./Icon.js";export default class Toast extends ShadowComponent{static properties={actionHtml:{type:String,reflect:!0,attribute:"action-html"},closeHtml:{type:String,reflect:!0,attribute:"close-html"},timeout:{type:Number,reflect:!0},opened:{type:Boolean,reflect:!0},hasAction:{type:Boolean,reflect:!0,attribute:"has-action"},hasClose:{type:Boolean,reflect:!0,attribute:"has-close"},hasIcon:{type:Boolean,reflect:!0,attribute:"has-icon"},position:{type:String,reflect:!0},animating:{type:String,reflect:!0}};static styles=css`
|
|
2
|
+
@keyframes toast-show-bottom {
|
|
3
|
+
from { opacity: 0; transform: translateY(20px); }
|
|
4
|
+
to { opacity: 1; transform: translateY(0); }
|
|
5
|
+
}
|
|
6
|
+
@keyframes toast-hide-bottom {
|
|
7
|
+
from { opacity: 1; transform: translateY(0); }
|
|
8
|
+
to { opacity: 0; transform: translateY(20px); }
|
|
9
|
+
}
|
|
10
|
+
@keyframes toast-show-top {
|
|
11
|
+
from { opacity: 0; transform: translateY(-20px); }
|
|
12
|
+
to { opacity: 1; transform: translateY(0); }
|
|
13
|
+
}
|
|
14
|
+
@keyframes toast-hide-top {
|
|
15
|
+
from { opacity: 1; transform: translateY(0); }
|
|
16
|
+
to { opacity: 0; transform: translateY(-20px); }
|
|
17
|
+
}
|
|
18
|
+
@keyframes toast-show-left {
|
|
19
|
+
from { opacity: 0; transform: translateX(-20px); }
|
|
20
|
+
to { opacity: 1; transform: translateX(0); }
|
|
21
|
+
}
|
|
22
|
+
@keyframes toast-hide-left {
|
|
23
|
+
from { opacity: 1; transform: translateX(0); }
|
|
24
|
+
to { opacity: 0; transform: translateX(-20px); }
|
|
25
|
+
}
|
|
26
|
+
@keyframes toast-show-right {
|
|
27
|
+
from { opacity: 0; transform: translateX(20px); }
|
|
28
|
+
to { opacity: 1; transform: translateX(0); }
|
|
29
|
+
}
|
|
30
|
+
@keyframes toast-hide-right {
|
|
31
|
+
from { opacity: 1; transform: translateX(0); }
|
|
32
|
+
to { opacity: 0; transform: translateX(20px); }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
:host {
|
|
36
|
+
display: none;
|
|
37
|
+
min-width: 16rem;
|
|
38
|
+
max-width: calc(100% - (2 * var(--spacer, 1rem)));
|
|
39
|
+
background-color: var(--c_bg, #ffffff);
|
|
40
|
+
border-radius: var(--radius, 0.375rem);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:host([opened]) {
|
|
44
|
+
display: flex;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:host([animating="in"][position*="bottom"]) {
|
|
48
|
+
animation: toast-show-bottom var(--animation_ms, 300ms) ease forwards;
|
|
49
|
+
}
|
|
50
|
+
:host([animating="out"][position*="bottom"]) {
|
|
51
|
+
animation: toast-hide-bottom var(--animation_ms, 300ms) ease forwards;
|
|
52
|
+
}
|
|
53
|
+
:host([animating="in"][position*="top"]) {
|
|
54
|
+
animation: toast-show-top var(--animation_ms, 300ms) ease forwards;
|
|
55
|
+
}
|
|
56
|
+
:host([animating="out"][position*="top"]) {
|
|
57
|
+
animation: toast-hide-top var(--animation_ms, 300ms) ease forwards;
|
|
58
|
+
}
|
|
59
|
+
:host([animating="in"][position*="left"]:not([position*="top"]):not([position*="bottom"])) {
|
|
60
|
+
animation: toast-show-left var(--animation_ms, 300ms) ease forwards;
|
|
61
|
+
}
|
|
62
|
+
:host([animating="out"][position*="left"]:not([position*="top"]):not([position*="bottom"])) {
|
|
63
|
+
animation: toast-hide-left var(--animation_ms, 300ms) ease forwards;
|
|
64
|
+
}
|
|
65
|
+
:host([animating="in"][position*="right"]:not([position*="top"]):not([position*="bottom"])) {
|
|
66
|
+
animation: toast-show-right var(--animation_ms, 300ms) ease forwards;
|
|
67
|
+
}
|
|
68
|
+
:host([animating="out"][position*="right"]:not([position*="top"]):not([position*="bottom"])) {
|
|
69
|
+
animation: toast-hide-right var(--animation_ms, 300ms) ease forwards;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#icon {
|
|
73
|
+
padding: var(--spacer, 1rem);
|
|
74
|
+
padding-right: 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
#message {
|
|
78
|
+
padding: var(--spacer, 1rem);
|
|
79
|
+
flex: 1 1 auto;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
:host(:not([has-close])) #close,
|
|
83
|
+
:host(:not([has-action])) #action,
|
|
84
|
+
:host(:not([has-icon])) #icon {
|
|
85
|
+
display: none;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
#action {
|
|
89
|
+
background: transparent;
|
|
90
|
+
border: none;
|
|
91
|
+
color: var(--tc_primary, blue);
|
|
92
|
+
cursor: pointer;
|
|
93
|
+
padding: var(--spacer, 1rem);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
#action:hover {
|
|
97
|
+
color: var(--tc_primary__hover, lightblue);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
#close {
|
|
101
|
+
background: transparent;
|
|
102
|
+
border: none;
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
padding: var(--spacer, 1rem);
|
|
105
|
+
opacity: 0.7;
|
|
106
|
+
transition: opacity var(--animation_ms, 300ms);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
#close:hover {
|
|
110
|
+
opacity: 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* Theme classes */
|
|
114
|
+
:host(.bg-success) {
|
|
115
|
+
background-color: var(--c_success, #dcfce7);
|
|
116
|
+
color: var(--tc_on_success, #166534);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
:host(.bg-warning) {
|
|
120
|
+
background-color: var(--c_warning, #fef3c7);
|
|
121
|
+
color: var(--tc_on_warning, #92400e);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
:host(.bg-danger) {
|
|
125
|
+
background-color: var(--c_danger, #fee2e2);
|
|
126
|
+
color: var(--tc_on_danger, #991b1b);
|
|
127
|
+
}
|
|
128
|
+
`;constructor(){super(),this.actionHtml="",this.closeHtml="",this.timeout=0,this.opened=!1,this.hasAction=!1,this.hasClose=!1,this.hasIcon=!1,this.position="bottom center",this.animating="",this.actionCallback=()=>{},this.closeCallback=()=>{},this.timeoutId=null,this.closing=!1}updated(t){super.updated(t),t.has("opened")&&this.opened&&(this.hasAction=!!this.querySelector('[slot="action"]'),this.hasClose=!!this.querySelector('[slot="close"]'),this.hasIcon=!!this.querySelector('[slot="icon"]'))}connectedCallback(){super.connectedCallback(),this.addEventListener("animationend",this.handleAnimationEnd)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("animationend",this.handleAnimationEnd),clearTimeout(this.timeoutId)}handleActionClick=()=>{!1!==this.actionCallback()&&this.close()};handleCloseClick=()=>{this.close()};handleAnimationEnd=t=>{t.animationName.includes("toast-hide")?(this.animating="",this.opened=!1,this.dispatchEvent(new CustomEvent("close")),this.dispatchEvent(new CustomEvent("openchange")),this.closeCallback(),this.closing=!1):t.animationName.includes("toast-show")&&(this.animating="")};open(){this.closing=!1,this.animating="in",this.opened=!0,this.timeout&&(clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.close()},this.timeout)),this.dispatchEvent(new CustomEvent("open")),this.dispatchEvent(new CustomEvent("openchange"))}close(){clearTimeout(this.timeoutId),this.opened&&!this.closing&&(this.closing=!0,this.animating="out")}render(){return html`
|
|
129
|
+
<div id="icon">
|
|
130
|
+
<slot name="icon"></slot>
|
|
131
|
+
</div>
|
|
132
|
+
<div id="message">
|
|
133
|
+
<slot></slot>
|
|
134
|
+
</div>
|
|
135
|
+
<button id="action" class="no-style" @click="${this.handleActionClick}">
|
|
136
|
+
<slot name="action"></slot>
|
|
137
|
+
</button>
|
|
138
|
+
<button id="close" class="no-style" @click="${this.handleCloseClick}">
|
|
139
|
+
<slot name="close"></slot>
|
|
140
|
+
</button>
|
|
141
|
+
`}static create(t,o={}){let{position:e="auto",removeOnClose:n=!0,closeCallback:s=()=>{},action:a=!1,close:i=!1,icon:r=!1,timeout:c=5e3}=o;"auto"===e&&(e=window.innerWidth<=768?"bottom center":"top right");let l=document.querySelector(`k-toast-container[position="${e}"]`);l||(l=new ToastContainer(e),document.body.appendChild(l));const m=new Toast;m.position=e,m.timeout=c,m.innerHTML=t,m.actionCallback=o.actionCallback||(()=>{});const h=s;if(m.closeCallback=(...t)=>{n&&(m.remove(),0===l.children.length&&l.remove()),h(...t)},r){const t=document.createElement("span");t.slot="icon",r instanceof HTMLElement?t.appendChild(r):t.innerHTML=r,m.appendChild(t)}if(a){const t=document.createElement("span");t.slot="action",a instanceof HTMLElement?t.appendChild(a):t.innerHTML=a,m.appendChild(t)}if(i){const t=document.createElement("span");t.slot="close",i instanceof HTMLElement?t.appendChild(i):t.innerHTML=i,m.appendChild(t)}return l.appendChild(m),m.open(),m}static success(t,o={}){const e=Toast.create(t,{icon:'<k-icon name="check"></k-icon>',...o});return e.classList.add("bg-success"),e}static warning(t,o={}){const e=Toast.create(t,{icon:'<k-icon name="warning"></k-icon>',...o});return e.classList.add("bg-warning"),e}static error(t,o={}){const e=Toast.create(t,{icon:'<k-icon name="error"></k-icon>',...o});return e.classList.add("bg-danger"),e}}class ToastContainer extends HTMLElement{constructor(t="bottom center"){super(),this.position=t.toLowerCase(),this.setAttribute("position",this.position),this.applyStyles()}applyStyles(){this.style.cssText="\n position: fixed;\n display: flex;\n flex-direction: column;\n gap: 8px;\n z-index: 1000;\n pointer-events: auto;\n padding: 32px;\n box-sizing: border-box;\n max-width: 100%;\n max-height: 100%;\n overflow: visible;\n ";new MutationObserver(()=>{Array.from(this.children).forEach(t=>{"K-TOAST"===t.tagName&&(t.style.filter="drop-shadow(0 10px 15px rgba(0, 0, 0, 0.1)) drop-shadow(0 4px 6px rgba(0, 0, 0, 0.05))")})}).observe(this,{childList:!0}),Array.from(this.children).forEach(t=>{"K-TOAST"===t.tagName&&(t.style.filter="drop-shadow(0 10px 15px rgba(0, 0, 0, 0.1)) drop-shadow(0 4px 6px rgba(0, 0, 0, 0.05))")});const[t,o]=this.position.split(" ");"top"===t?this.style.top="0":this.style.bottom="0","left"===o?(this.style.left="0",this.style.alignItems="flex-start"):"right"===o?(this.style.right="0",this.style.alignItems="flex-end"):"center"===o&&("top"===t||"bottom"===t?(this.style.left="50%",this.style.transform="translateX(-50%)",this.style.alignItems="center"):(this.style.top="50%",this.style.left="50%",this.style.transform="translate(-50%, -50%)"))}static getContainer(t){let o=document.querySelector(`k-toast-container[position="${t}"]`);return o||(o=new ToastContainer(t),document.body.appendChild(o)),o}}window.customElements.define("k-toast",Toast),window.customElements.define("k-toast-container",ToastContainer);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import{html,css}from"../lit-all.min.js";import ShadowComponent from"./ShadowComponent.js";export default class Toggle extends ShadowComponent{static properties={value:{type:Boolean,reflect:!0}};static styles=css`
|
|
2
|
+
:host {
|
|
3
|
+
--switch_height: 2rem;
|
|
4
|
+
--switch_width: 3rem;
|
|
5
|
+
--switch_border: 1px solid var(--c_border);
|
|
6
|
+
--switch_background__off: var(--c_bg__alt);
|
|
7
|
+
--switch_background__on: var(--c_success);
|
|
8
|
+
--handle_size__off: 1rem;
|
|
9
|
+
--handle_size__on: 1.5rem;
|
|
10
|
+
--handle_border: 1px solid var(--c_border);
|
|
11
|
+
--handle_background__off: var(--c_border);
|
|
12
|
+
--handle_background__on: white;
|
|
13
|
+
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
margin-bottom: var(--spacer);
|
|
18
|
+
border-radius: 999rem;
|
|
19
|
+
outline: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:host(:focus) {
|
|
23
|
+
outline: 2px solid var(--c_primary, blue);
|
|
24
|
+
outline-offset: 2px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#switch {
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
width: var(--switch_width);
|
|
31
|
+
height: var(--switch_height);
|
|
32
|
+
border: var(--switch_border);
|
|
33
|
+
background: var(--switch_background__off);
|
|
34
|
+
border-radius: 999rem;
|
|
35
|
+
margin-right: var(--spacer);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#handle {
|
|
39
|
+
--margin: calc( (var(--switch_height) - var(--handle_size__off)) / 2);
|
|
40
|
+
width: var(--handle_size__off);
|
|
41
|
+
height: var(--handle_size__off);
|
|
42
|
+
border: var(--handle_border);
|
|
43
|
+
background: var(--handle_background__off);
|
|
44
|
+
border-radius: 999rem;
|
|
45
|
+
transform: translateX(var(--margin));
|
|
46
|
+
transition: width var(--animation_ms, 256ms), height var(--animation_ms, 256ms), transform var(--animation_ms, 256ms);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:host([value]) #switch {
|
|
50
|
+
background: var(--switch_background__on);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
:host([value]) #handle {
|
|
54
|
+
--m: calc( (var(--switch_height) - var(--handle_size__on)) / 2);
|
|
55
|
+
--d: calc( var(--switch_width) - var(--handle_size__on) - var(--m));
|
|
56
|
+
width: var(--handle_size__on);
|
|
57
|
+
height: var(--handle_size__on);
|
|
58
|
+
background: var(--handle_background__on);
|
|
59
|
+
transform: translateX(var(--d));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#label {
|
|
63
|
+
display: block;
|
|
64
|
+
flex: 1 1 auto;
|
|
65
|
+
padding: 0;
|
|
66
|
+
}
|
|
67
|
+
`;constructor(){super(),this.value=!1,this.tabIndex=0}updated(e){super.updated(e),e.has("value")&&this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0}))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeyDown)}handleClick=()=>{this.toggle()};handleKeyDown=e=>{["Space","Enter"].includes(e.code)&&(e.preventDefault(),this.toggle())};on(){return this.value=!0,this.dispatchEvent(new CustomEvent("on",{detail:{value:!0},bubbles:!0})),this}off(){return this.value=!1,this.dispatchEvent(new CustomEvent("off",{detail:{value:!1},bubbles:!0})),this}toggle(){return this.value?this.off():this.on(),this.dispatchEvent(new CustomEvent("toggle",{detail:{value:this.value},bubbles:!0})),this}render(){return html`
|
|
68
|
+
<div id="switch">
|
|
69
|
+
<div id="handle"></div>
|
|
70
|
+
</div>
|
|
71
|
+
<label id="label">
|
|
72
|
+
<slot></slot>
|
|
73
|
+
</label>
|
|
74
|
+
`}}window.customElements.define("k-toggle",Toggle);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import TableControl from"./TableControl.js";import{html}from"../../lit-all.min.js";import"../Icon.js";export default class DeleteRecord extends TableControl{delete=()=>{this.record&&this.table.deleteRecord(this.record)};render(){return html`
|
|
2
|
+
<button class="no-btn icon-btn" @click="${this.delete}">
|
|
3
|
+
<slot>
|
|
4
|
+
<k-icon name="delete"></k-icon>
|
|
5
|
+
</slot>
|
|
6
|
+
</button>
|
|
7
|
+
`}}customElements.define("k-tc-delete-record",DeleteRecord);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import TableControl from"./TableControl.js";import{html,css}from"../../lit-all.min.js";import"../Icon.js";export default class Edit extends TableControl{static properties={isEditing:{type:Boolean}};static styles=[TableControl.styles,css`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
width: max-content;
|
|
5
|
+
align-items: baseline;
|
|
6
|
+
}
|
|
7
|
+
`];constructor(){super({maxWidth:80})}connectedCallback(){super.connectedCallback(),this.onTableEvent("editingChange",this.handleEditingChange)}handleEditingChange=t=>{t.detail.record===this.record&&(this.isEditing=t.detail.editing)};handleEdit=()=>{this.record&&this.table.editRecord(this.record)};handleSave=()=>{this.record&&this.table.saveEditedRecord(this.record)};handleCancel=()=>{this.record&&this.table.cancelEditedRecord(this.record)};render(){return this.isEditing?html`
|
|
8
|
+
<button class="no-btn icon-btn bg-success" @click="${this.handleSave}">
|
|
9
|
+
<k-icon name="check"></k-icon>
|
|
10
|
+
</button>
|
|
11
|
+
<button class="no-btn icon-btn bg-danger" @click="${this.handleCancel}">
|
|
12
|
+
<k-icon name="close"></k-icon>
|
|
13
|
+
</button>
|
|
14
|
+
`:html`
|
|
15
|
+
<button class="no-btn icon-btn" @click="${this.handleEdit}">
|
|
16
|
+
<k-icon name="edit"></k-icon>
|
|
17
|
+
</button>
|
|
18
|
+
`}}customElements.define("k-tc-edit",Edit);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import TableControl from"./TableControl.js";import{html}from"../../lit-all.min.js";import"../Icon.js";export default class ExportCSV extends TableControl{constructor(){super(),this.maxWidth=136}getCSV(){const t=this.table;if(!t)return"";let e="";const o=[];if(t.fields.forEach(({name:t,calculator:e})=>{e||o.push(t)}),e+=o.join(",")+"\n",this.record){const t=o.map(t=>this.record[t]||"");e+=t.join(",")+"\n"}else t.records.forEach(t=>{const r=o.map(e=>t[e]||"");e+=r.join(",")+"\n"});return e}export=()=>{const t=this.getCSV(),e=new Blob([t],{type:"text/csv"}),o=URL.createObjectURL(e),r=document.createElement("a");r.href=o,r.download="data.csv",r.click(),URL.revokeObjectURL(o)};render(){return html`
|
|
2
|
+
<button class="no-btn ph" @click="${this.export}">
|
|
3
|
+
<slot>
|
|
4
|
+
<k-icon name="export-file"></k-icon>
|
|
5
|
+
Export CSV
|
|
6
|
+
</slot>
|
|
7
|
+
</button>
|
|
8
|
+
`}}customElements.define("k-tc-export-csv",ExportCSV);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import TableControl from"./TableControl.js";import{html}from"../../lit-all.min.js";import"../Icon.js";export default class ExportJson extends TableControl{constructor(){super(),this.maxWidth=136}export=()=>{const t=this.record;if(t){const e=JSON.stringify(t),o=new Blob([e],{type:"application/json"}),n=URL.createObjectURL(o),r=document.createElement("a");r.href=n,r.download="data.json",r.click(),URL.revokeObjectURL(n)}else{const t=JSON.stringify(this.table.records),e=new Blob([t],{type:"application/json"}),o=URL.createObjectURL(e),n=document.createElement("a");n.href=o,n.download="data.json",n.click(),URL.revokeObjectURL(o)}};render(){return html`
|
|
2
|
+
<button class="no-btn ph" @click="${this.export}">
|
|
3
|
+
<slot>
|
|
4
|
+
<k-icon name="export-file"></k-icon>
|
|
5
|
+
Export JSON
|
|
6
|
+
</slot>
|
|
7
|
+
</button>
|
|
8
|
+
`}}customElements.define("k-tc-export-json",ExportJson);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import TableControl from"./TableControl.js";import{html,render}from"../../lit-all.min.js";import"../Icon.js";import Dialog from"../Dialog.js";export default class FieldSortHide extends TableControl{constructor(){super({maxWidth:40})}handleClick=()=>{this.openDialog()};openDialog=()=>{import("../Sortable.js");const e=document.createElement("div");render(html`
|
|
2
|
+
<h3 class="m0 ph" slot="title">Show / Hide Fields</h3>
|
|
3
|
+
<div class="m">
|
|
4
|
+
<k-sortable id="sorting" @sort="${e=>{const t=Array.from(e.target.querySelectorAll("k-sortable-item")).map(e=>e.getAttribute("data-field"));this.table.reorderFields(t)}}">
|
|
5
|
+
${this.table.fields.map(e=>html`
|
|
6
|
+
<k-sortable-item data-field="${e.name}">
|
|
7
|
+
<label class="field pb0">
|
|
8
|
+
<input
|
|
9
|
+
class="field-visibility"
|
|
10
|
+
data-field="${e.name}"
|
|
11
|
+
type="checkbox"
|
|
12
|
+
.checked="${!e.hidden}"
|
|
13
|
+
@change="${t=>{this.table.setFieldHiddenState(e.name,!t.target.checked)}}"
|
|
14
|
+
style="height: 1.25rem; width: 1.25rem"
|
|
15
|
+
/>
|
|
16
|
+
${e.label}
|
|
17
|
+
</label>
|
|
18
|
+
</k-sortable-item>
|
|
19
|
+
`)}
|
|
20
|
+
</k-sortable>
|
|
21
|
+
</div>
|
|
22
|
+
`,e),Dialog.create(e,{width:"400px",cancelText:"Close"})};render(){return html`
|
|
23
|
+
<button class="no-btn icon-btn" @click="${this.handleClick}">
|
|
24
|
+
<k-icon name="table-visibility"></k-icon>
|
|
25
|
+
</button>
|
|
26
|
+
`}}customElements.define("k-tc-field-sort-hide",FieldSortHide);
|