kempo-ui 0.0.25 → 0.0.27
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.
|
@@ -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";import"./FocusCapture.js";const firstFocusable=e=>e.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=e=>{const{target:t}=e,o=t.id||t.closest("[id]")?.id;"overlay"===o&&this.overlayClose||"close"===o?this.close():"cancel"===o?(this.cancelAction(e),e.defaultPrevented||this.close()):"confirm"===o&&(this.confirmAction(e),e.defaultPrevented||this.close())};handleKeydown=e=>{27
|
|
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=e=>e.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},disableKeyboardClose:{type:Boolean,reflect:!0,attribute:"disable-keyboard-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.disableKeyboardClose=!1,this.confirmText="",this.confirmClasses="success ml",this.cancelText="",this.cancelClasses="",this.confirmAction=()=>{},this.cancelAction=()=>{},this.closeCallback=()=>{},this.previousFocus=null}handleClick=e=>{const{target:t}=e,o=t.id||t.closest("[id]")?.id;"overlay"===o&&this.overlayClose||"close"===o?this.close():"cancel"===o?(this.cancelAction(e),e.defaultPrevented||this.close()):"confirm"===o&&(this.confirmAction(e),e.defaultPrevented||this.close())};handleKeydown=e=>{this.disableKeyboardClose||27!==e.keyCode||this.close()};connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.handleKeydown)}updated(e){super.updated(e),e.has("opened")&&this.dispatchEvent(new CustomEvent(this.opened?"opened":"close"))}open(){this.opened=!0,window.addEventListener("keydown",this.handleKeydown);const e=this.updateComplete||this.requestUpdate();e&&e.then?e.then(()=>{const e=this.shadowRoot.querySelector("[autofocus]")||firstFocusable(this.shadowRoot);e&&e.focus()}):setTimeout(()=>{const e=this.shadowRoot.querySelector("[autofocus]")||firstFocusable(this.shadowRoot);e&&e.focus()},0)}close(){this.opened=!1,this.blur(),this.closeCallback(),window.removeEventListener("keydown",this.handleKeydown)}toggle(){this.opened?this.close():this.open()}focus(){const e=firstFocusable(this.shadowRoot);e&&(this.previousFocus=document.activeElement,e.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;
|
|
@@ -117,4 +117,4 @@ import ShadowComponent from"./ShadowComponent.js";import{html,css}from"../lit-al
|
|
|
117
117
|
</div>
|
|
118
118
|
</k-focus-capture>
|
|
119
119
|
</div>
|
|
120
|
-
`}static create(e="",t={}){!1!==t.closeExisting&&document.querySelectorAll("k-dialog").forEach(e=>e.close());const{removeOnClose:o=!0,closeCallback:s=()=>{},title:i="",titleClasses:l="pyh px m0"}=t,
|
|
120
|
+
`}static create(e="",t={}){!1!==t.closeExisting&&document.querySelectorAll("k-dialog").forEach(e=>e.close());const{removeOnClose:o=!0,closeCallback:s=()=>{},title:i="",titleClasses:l="pyh px m0"}=t,a=new Dialog;if(Object.assign(a,{opened:!0,...t,closeCallback:(...e)=>{o&&a.remove(),s(...e)}}),i){const e=document.createElement("h5");e.slot="title",e.className=l,i instanceof HTMLElement?e.appendChild(i):e.innerHTML=i,a.appendChild(e)}if(e instanceof HTMLElement||e instanceof DocumentFragment)a.appendChild(e);else if(e){if(/<[^>]+>/.test(e))a.innerHTML+=e;else{const t=document.createElement("p");t.className="p",t.textContent=e,a.appendChild(t)}}return t.width&&a.style.setProperty("--width",t.width),t.minWidth&&a.style.setProperty("--min_width",t.minWidth),t.maxWidth&&a.style.setProperty("--max_width",t.maxWidth),t.height&&a.style.setProperty("--height",t.height),t.minHeight&&a.style.setProperty("--min_height",t.minHeight),t.maxHeight&&a.style.setProperty("--max_height",t.maxHeight),document.body.appendChild(a),a.open(),a}static confirm(e,t,o={}){return Dialog.create(e,{title:o.title||"Confirm",closeBtn:!1,overlayClose:!1,disableKeyboardClose:!0,confirmText:"Yes",confirmClasses:"success ml",confirmAction:()=>t(!0),cancelText:"No",cancelClasses:"danger",cancelAction:()=>t(!1),...o})}static alert(e,t=()=>{},o={}){return Dialog.create(e,{title:o.title||"Alert",closeCallback:t,cancelText:"Ok",...o})}static error(e,t=()=>{},o={}){return Dialog.create(e,{title:o.title||"Error",titleClasses:"pyh px m0 tc-danger",closeCallback:t,cancelText:"Ok",...o})}static success(e,t=()=>{},o={}){return Dialog.create(e,{title:o.title||"Success",titleClasses:"pyh px m0 tc-success",closeCallback:t,cancelText:"Ok",...o})}}customElements.define("k-dialog",Dialog);
|
|
@@ -156,8 +156,7 @@
|
|
|
156
156
|
<h3 id="accordion-ref" class="bb pb">Accordion</h3>
|
|
157
157
|
<h4>Properties</h4>
|
|
158
158
|
<ul>
|
|
159
|
-
<li><code>multiple: boolean</code>
|
|
160
|
-
<li><code>persistentId: string</code>  If set, open panel state is saved/restored via localStorage.</li>
|
|
159
|
+
<li><code>multiple: boolean</code> — If present, allows multiple panels to be open.</li>
|
|
161
160
|
</ul>
|
|
162
161
|
<h4>Methods</h4>
|
|
163
162
|
<ul>
|
|
@@ -177,9 +176,9 @@
|
|
|
177
176
|
<h3 id="accordion-header-ref" class="bb pb">AccordionHeader</h3>
|
|
178
177
|
<h4>Properties</h4>
|
|
179
178
|
<ul>
|
|
180
|
-
<li><code>forPanel: string</code>
|
|
181
|
-
<li><code>active: boolean</code>
|
|
182
|
-
<li><code>accordion: Accordion | null</code> <i>(read only)</i>
|
|
179
|
+
<li><code>forPanel: string</code> — The panel name this header controls.</li>
|
|
180
|
+
<li><code>active: boolean</code> — Whether this header is active.</li>
|
|
181
|
+
<li><code>accordion: Accordion | null</code> <i>(read only)</i> — Parent accordion.</li>
|
|
183
182
|
</ul>
|
|
184
183
|
<h4>Event Handlers</h4>
|
|
185
184
|
<ul>
|
|
@@ -191,13 +190,13 @@
|
|
|
191
190
|
<h3 id="accordion-panel-ref" class="bb pb">AccordionPanel</h3>
|
|
192
191
|
<h4>Properties</h4>
|
|
193
192
|
<ul>
|
|
194
|
-
<li><code>name: string</code>
|
|
195
|
-
<li><code>active: boolean</code>
|
|
196
|
-
<li><code>transitioning: boolean</code>
|
|
193
|
+
<li><code>name: string</code> — Unique panel identifier.</li>
|
|
194
|
+
<li><code>active: boolean</code> — Whether this panel is open.</li>
|
|
195
|
+
<li><code>transitioning: boolean</code> — Whether this panel is animating.</li>
|
|
197
196
|
</ul>
|
|
198
197
|
<h4>Methods</h4>
|
|
199
198
|
<ul>
|
|
200
|
-
<li><code>accordion: Accordion | null</code> (getter)
|
|
199
|
+
<li><code>accordion: Accordion | null</code> (getter) — Returns parent accordion.</li>
|
|
201
200
|
</ul>
|
|
202
201
|
|
|
203
202
|
<h3 id="events"><a href="#events" class="no-link">Events</a></h3>
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
<a href="#basicUsage">Basic Usage</a><br />
|
|
25
25
|
<a href="#titles">Titles</a><br />
|
|
26
26
|
<a href="#actionButtons">Action Buttons</a><br />
|
|
27
|
+
<a href="#disableKeyboardClose">Disabling Keyboard Close</a><br />
|
|
27
28
|
<a href="#jsUsage">JavaScript Usage</a><br />
|
|
28
29
|
<a href="#confirmDialog">Confirm Dialog</a><br />
|
|
29
30
|
|
|
@@ -92,6 +93,14 @@
|
|
|
92
93
|
<p class="p">Ranch is gross</p>
|
|
93
94
|
</k-dialog>
|
|
94
95
|
|
|
96
|
+
<h3 id="disableKeyboardClose"><a href="#disableKeyboardClose" class="no-link">Disabling Keyboard Close</a></h3>
|
|
97
|
+
<p>You can disable closing the dialog with the ESC key by adding the <code>disable-keyboard-close</code> attribute. This is useful for dialogs that require explicit user action.</p>
|
|
98
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-dialog</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d10"</span> <span class="hljs-attr">disable-keyboard-close</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"p"</span>></span>This dialog cannot be closed with ESC<span class="hljs-tag"></<span class="hljs-name">p</span>></span><br /><span class="hljs-tag"></<span class="hljs-name">k-dialog</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">onclick</span>=<span class="hljs-string">"document.getElementById('d10').open()"</span>></span>Open Dialog<span class="hljs-tag"></<span class="hljs-name">button</span>></span></code></pre>
|
|
99
|
+
<button class="openDialog mb" data-dialog="d10" slot="right">Open Dialog</button>
|
|
100
|
+
<k-dialog id="d10" disable-keyboard-close>
|
|
101
|
+
<p class="p">This dialog cannot be closed with ESC</p>
|
|
102
|
+
</k-dialog>
|
|
103
|
+
|
|
95
104
|
<h3 id="jsUsage"><a href="#jsUsage" class="no-link">JavaScript Usage</a></h3>
|
|
96
105
|
<h5>Create Dialog</h5>
|
|
97
106
|
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d7"</span>></span>Open Dialog<span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Dialog <span class="hljs-keyword">from</span> <span class="hljs-string">'/src/components/Dialog.js'</span>;<br /> <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'d7'</span>).addEventListener(<span class="hljs-string">'click'</span>, () => {<br /> Dialog.create(<span class="hljs-string">'Hello World'</span>);<br /> });<br /></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
@@ -180,6 +189,9 @@
|
|
|
180
189
|
<h5><code>overlay-close<i>: boolean</i></code></h5>
|
|
181
190
|
<p>Whether clicking the overlay closes the dialog. Default is <code>true</code>.</p>
|
|
182
191
|
|
|
192
|
+
<h5><code>disable-keyboard-close<i>: boolean</i></code></h5>
|
|
193
|
+
<p>Whether to disable closing the dialog with the ESC key. Default is <code>false</code>.</p>
|
|
194
|
+
|
|
183
195
|
<h5><code>confirm-text<i>: string</i></code></h5>
|
|
184
196
|
<p>Text for the confirm button.</p>
|
|
185
197
|
|
|
@@ -199,6 +211,9 @@
|
|
|
199
211
|
<h5><code>cancelAction<i>: function</i></code></h5>
|
|
200
212
|
<p>Action to perform on cancel. If the function calls <code>event.preventDefault()</code>, the dialog will not close automatically.</p>
|
|
201
213
|
|
|
214
|
+
<h5><code>disableKeyboardClose<i>: boolean</i></code></h5>
|
|
215
|
+
<p>Whether to disable closing the dialog with the ESC key. Default is <code>false</code>.</p>
|
|
216
|
+
|
|
202
217
|
<h5><code>closeCallback<i>: function</i></code></h5>
|
|
203
218
|
<p>Callback to execute when the dialog is closed.</p>
|
|
204
219
|
|
|
@@ -239,6 +254,7 @@
|
|
|
239
254
|
<li><code>opened</code>: <i>boolean</i> - Whether the dialog is initially opened. Default is <code>true</code>.</li>
|
|
240
255
|
<li><code>closeBtn</code>: <i>boolean</i> - Whether to show the close button.</li>
|
|
241
256
|
<li><code>overlayClose</code>: <i>boolean</i> - Whether clicking the overlay closes the dialog.</li>
|
|
257
|
+
<li><code>disableKeyboardClose</code>: <i>boolean</i> - Whether to disable closing the dialog with the ESC key.</li>
|
|
242
258
|
<li><code>confirmText</code>: <i>string</i> - Text for the confirm button.</li>
|
|
243
259
|
<li><code>confirmClasses</code>: <i>string</i> - Classes for the confirm button.</li>
|
|
244
260
|
<li><code>confirmAction</code>: <i>function</i> - Action to perform on confirm.</li>
|
|
@@ -257,7 +273,7 @@
|
|
|
257
273
|
</ul>
|
|
258
274
|
|
|
259
275
|
<h5><code>Dialog.confirm(text, responseCallback, options)<i>: Dialog</i></code></h5>
|
|
260
|
-
<p>Creates and opens a confirmation dialog with the specified text and options. The response callback receives a boolean value indicating whether the user confirmed (<code>true</code>) or canceled (<code>false</code>).</p>
|
|
276
|
+
<p>Creates and opens a confirmation dialog with the specified text and options. The response callback receives a boolean value indicating whether the user confirmed (<code>true</code>) or canceled (<code>false</code>). By default, the close button and overlay close are disabled, and keyboard close (ESC key) is disabled to ensure the user must explicitly choose Yes or No.</p>
|
|
261
277
|
|
|
262
278
|
<h6>Parameters</h6>
|
|
263
279
|
<ul>
|
|
@@ -275,6 +291,7 @@
|
|
|
275
291
|
<li><code>cancelClasses</code>: <i>string</i> - Classes for the cancel button. Default is <code>'danger'</code>.</li>
|
|
276
292
|
<li><code>closeBtn</code>: <i>boolean</i> - Whether to show the close button. Default is <code>false</code>.</li>
|
|
277
293
|
<li><code>overlayClose</code>: <i>boolean</i> - Whether clicking the overlay closes the dialog. Default is <code>false</code>.</li>
|
|
294
|
+
<li><code>disableKeyboardClose</code>: <i>boolean</i> - Whether to disable closing the dialog with the ESC key. Default is <code>true</code>.</li>
|
|
278
295
|
</ul>
|
|
279
296
|
|
|
280
297
|
<h5><code>Dialog.alert(text, responseCallback, options)<i>: Dialog</i></code></h5>
|
|
@@ -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";import"./FocusCapture.js";const firstFocusable=e=>e.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=e=>{const{target:t}=e,o=t.id||t.closest("[id]")?.id;"overlay"===o&&this.overlayClose||"close"===o?this.close():"cancel"===o?(this.cancelAction(e),e.defaultPrevented||this.close()):"confirm"===o&&(this.confirmAction(e),e.defaultPrevented||this.close())};handleKeydown=e=>{27
|
|
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=e=>e.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},disableKeyboardClose:{type:Boolean,reflect:!0,attribute:"disable-keyboard-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.disableKeyboardClose=!1,this.confirmText="",this.confirmClasses="success ml",this.cancelText="",this.cancelClasses="",this.confirmAction=()=>{},this.cancelAction=()=>{},this.closeCallback=()=>{},this.previousFocus=null}handleClick=e=>{const{target:t}=e,o=t.id||t.closest("[id]")?.id;"overlay"===o&&this.overlayClose||"close"===o?this.close():"cancel"===o?(this.cancelAction(e),e.defaultPrevented||this.close()):"confirm"===o&&(this.confirmAction(e),e.defaultPrevented||this.close())};handleKeydown=e=>{this.disableKeyboardClose||27!==e.keyCode||this.close()};connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.handleKeydown)}updated(e){super.updated(e),e.has("opened")&&this.dispatchEvent(new CustomEvent(this.opened?"opened":"close"))}open(){this.opened=!0,window.addEventListener("keydown",this.handleKeydown);const e=this.updateComplete||this.requestUpdate();e&&e.then?e.then(()=>{const e=this.shadowRoot.querySelector("[autofocus]")||firstFocusable(this.shadowRoot);e&&e.focus()}):setTimeout(()=>{const e=this.shadowRoot.querySelector("[autofocus]")||firstFocusable(this.shadowRoot);e&&e.focus()},0)}close(){this.opened=!1,this.blur(),this.closeCallback(),window.removeEventListener("keydown",this.handleKeydown)}toggle(){this.opened?this.close():this.open()}focus(){const e=firstFocusable(this.shadowRoot);e&&(this.previousFocus=document.activeElement,e.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;
|
|
@@ -117,4 +117,4 @@ import ShadowComponent from"./ShadowComponent.js";import{html,css}from"../lit-al
|
|
|
117
117
|
</div>
|
|
118
118
|
</k-focus-capture>
|
|
119
119
|
</div>
|
|
120
|
-
`}static create(e="",t={}){!1!==t.closeExisting&&document.querySelectorAll("k-dialog").forEach(e=>e.close());const{removeOnClose:o=!0,closeCallback:s=()=>{},title:i="",titleClasses:l="pyh px m0"}=t,
|
|
120
|
+
`}static create(e="",t={}){!1!==t.closeExisting&&document.querySelectorAll("k-dialog").forEach(e=>e.close());const{removeOnClose:o=!0,closeCallback:s=()=>{},title:i="",titleClasses:l="pyh px m0"}=t,a=new Dialog;if(Object.assign(a,{opened:!0,...t,closeCallback:(...e)=>{o&&a.remove(),s(...e)}}),i){const e=document.createElement("h5");e.slot="title",e.className=l,i instanceof HTMLElement?e.appendChild(i):e.innerHTML=i,a.appendChild(e)}if(e instanceof HTMLElement||e instanceof DocumentFragment)a.appendChild(e);else if(e){if(/<[^>]+>/.test(e))a.innerHTML+=e;else{const t=document.createElement("p");t.className="p",t.textContent=e,a.appendChild(t)}}return t.width&&a.style.setProperty("--width",t.width),t.minWidth&&a.style.setProperty("--min_width",t.minWidth),t.maxWidth&&a.style.setProperty("--max_width",t.maxWidth),t.height&&a.style.setProperty("--height",t.height),t.minHeight&&a.style.setProperty("--min_height",t.minHeight),t.maxHeight&&a.style.setProperty("--max_height",t.maxHeight),document.body.appendChild(a),a.open(),a}static confirm(e,t,o={}){return Dialog.create(e,{title:o.title||"Confirm",closeBtn:!1,overlayClose:!1,disableKeyboardClose:!0,confirmText:"Yes",confirmClasses:"success ml",confirmAction:()=>t(!0),cancelText:"No",cancelClasses:"danger",cancelAction:()=>t(!1),...o})}static alert(e,t=()=>{},o={}){return Dialog.create(e,{title:o.title||"Alert",closeCallback:t,cancelText:"Ok",...o})}static error(e,t=()=>{},o={}){return Dialog.create(e,{title:o.title||"Error",titleClasses:"pyh px m0 tc-danger",closeCallback:t,cancelText:"Ok",...o})}static success(e,t=()=>{},o={}){return Dialog.create(e,{title:o.title||"Success",titleClasses:"pyh px m0 tc-success",closeCallback:t,cancelText:"Ok",...o})}}customElements.define("k-dialog",Dialog);
|
package/package.json
CHANGED
package/scripts/docs.js
CHANGED
|
@@ -6,26 +6,33 @@ import { getArgs, runChildNodeProcessScript } from 'kempo-server/utils/cli';
|
|
|
6
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = dirname(__filename);
|
|
8
8
|
|
|
9
|
+
/*
|
|
10
|
+
Configuration
|
|
11
|
+
*/
|
|
9
12
|
const options = getArgs({
|
|
10
13
|
p: 'port',
|
|
11
14
|
b: 'build',
|
|
12
|
-
s: 'src'
|
|
13
|
-
'no-build': 'noBuild'
|
|
15
|
+
s: 'src'
|
|
14
16
|
});
|
|
15
17
|
|
|
16
18
|
const {
|
|
17
19
|
port = 8083,
|
|
18
|
-
build =
|
|
19
|
-
noBuild = false,
|
|
20
|
+
build = null,
|
|
20
21
|
src = false
|
|
21
22
|
} = options;
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
/*
|
|
25
|
+
Build Logic
|
|
26
|
+
*/
|
|
27
|
+
if(build === null ? !src : build === 'true' || build === true){
|
|
24
28
|
console.log('Building component files...');
|
|
25
29
|
await runChildNodeProcessScript(join(__dirname, 'build.js'));
|
|
26
30
|
console.log('Component files built!');
|
|
27
31
|
}
|
|
28
32
|
|
|
33
|
+
/*
|
|
34
|
+
Server Startup
|
|
35
|
+
*/
|
|
29
36
|
const rootDir = 'docs';
|
|
30
37
|
const configFile = src ?
|
|
31
38
|
join(__dirname, '../docs/dev.config.json') :
|
package/src/components/Dialog.js
CHANGED
|
@@ -19,6 +19,7 @@ export default class Dialog extends ShadowComponent {
|
|
|
19
19
|
opened: { type: Boolean, reflect: true, converter: boolExists },
|
|
20
20
|
closeBtn: { type: Boolean, reflect: true, attribute: 'close-btn', converter: boolExists },
|
|
21
21
|
overlayClose: { type: Boolean, reflect: true, attribute: 'overlay-close', converter: boolExists },
|
|
22
|
+
disableKeyboardClose: { type: Boolean, reflect: true, attribute: 'disable-keyboard-close', converter: boolExists },
|
|
22
23
|
confirmText: { type: String, reflect: true, attribute: 'confirm-text' },
|
|
23
24
|
confirmClasses: { type: String, reflect: true, attribute: 'confirm-classes' },
|
|
24
25
|
cancelText: { type: String, reflect: true, attribute: 'cancel-text' },
|
|
@@ -30,6 +31,7 @@ export default class Dialog extends ShadowComponent {
|
|
|
30
31
|
this.opened = false;
|
|
31
32
|
this.closeBtn = true;
|
|
32
33
|
this.overlayClose = true;
|
|
34
|
+
this.disableKeyboardClose = false;
|
|
33
35
|
this.confirmText = '';
|
|
34
36
|
this.confirmClasses = 'success ml';
|
|
35
37
|
this.cancelText = '';
|
|
@@ -59,7 +61,7 @@ export default class Dialog extends ShadowComponent {
|
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
handleKeydown = event => {
|
|
62
|
-
if(event.keyCode === 27) {
|
|
64
|
+
if(!this.disableKeyboardClose && event.keyCode === 27) {
|
|
63
65
|
this.close();
|
|
64
66
|
}
|
|
65
67
|
}
|
|
@@ -347,6 +349,7 @@ export default class Dialog extends ShadowComponent {
|
|
|
347
349
|
title: options.title || 'Confirm',
|
|
348
350
|
closeBtn: false,
|
|
349
351
|
overlayClose: false,
|
|
352
|
+
disableKeyboardClose: true,
|
|
350
353
|
confirmText: 'Yes',
|
|
351
354
|
confirmClasses: 'success ml',
|
|
352
355
|
confirmAction: () => responseCallback(true),
|