kempo-ui 0.3.5 → 0.3.7

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.
Files changed (146) hide show
  1. package/AGENTS.md +2 -1
  2. package/dist/components/Aside.js +1 -1
  3. package/dist/components/Main.js +1 -1
  4. package/docs/components/accordion.html +240 -8
  5. package/docs/components/aside-items.html +13 -9
  6. package/docs/components/aside-menu.html +13 -9
  7. package/docs/components/aside-push.html +11 -6
  8. package/docs/components/aside.html +289 -115
  9. package/docs/components/card.html +238 -7
  10. package/docs/components/color-picker.html +245 -14
  11. package/docs/components/content-slider.html +240 -8
  12. package/docs/components/context.html +241 -7
  13. package/docs/components/dialog.html +238 -7
  14. package/docs/components/dropdown.html +238 -7
  15. package/docs/components/filter-list.html +239 -10
  16. package/docs/components/focus-capture.html +241 -10
  17. package/docs/components/html-editor.html +266 -35
  18. package/docs/components/hybrid-component.html +238 -6
  19. package/docs/components/icon.html +239 -9
  20. package/docs/components/import.html +239 -8
  21. package/docs/components/light-component.html +239 -7
  22. package/docs/components/nav.html +240 -8
  23. package/docs/components/photo-viewer.html +239 -9
  24. package/docs/components/resize.html +240 -9
  25. package/docs/components/shadow-component.html +239 -7
  26. package/docs/components/show-more.html +237 -8
  27. package/docs/components/sortable.html +239 -8
  28. package/docs/components/spinner.html +237 -6
  29. package/docs/components/split.html +241 -10
  30. package/docs/components/table.html +241 -11
  31. package/docs/components/tableControls.html +240 -7
  32. package/docs/components/tableCustomFields.html +241 -8
  33. package/docs/components/tableFetchRecords.html +239 -7
  34. package/docs/components/tableFieldSortHide.html +239 -7
  35. package/docs/components/tablePagination.html +246 -13
  36. package/docs/components/tablePlaceholder.html +241 -8
  37. package/docs/components/tableRecordEditing.html +241 -8
  38. package/docs/components/tableRecordFiltering.html +239 -7
  39. package/docs/components/tableRecordHiding.html +241 -9
  40. package/docs/components/tableRecordSearching.html +239 -7
  41. package/docs/components/tableRecordSelection.html +240 -7
  42. package/docs/components/tableRowControls.html +241 -8
  43. package/docs/components/tableServerSync.html +245 -11
  44. package/docs/components/tableSorting.html +239 -7
  45. package/docs/components/tabs.html +240 -7
  46. package/docs/components/tags.html +239 -7
  47. package/docs/components/theme-select.html +239 -7
  48. package/docs/components/theme-switcher.html +240 -8
  49. package/docs/components/timestamp.html +239 -8
  50. package/docs/components/toast.html +240 -8
  51. package/docs/components/toggle.html +240 -9
  52. package/docs/components/tree.html +239 -8
  53. package/docs/index.html +244 -6
  54. package/docs/prod.config.json +0 -4
  55. package/docs/src/components/Aside.js +1 -1
  56. package/docs/src/components/Main.js +1 -1
  57. package/docs/utils/context.html +237 -6
  58. package/docs/utils/cookie.html +251 -21
  59. package/docs/utils/debounce.html +236 -5
  60. package/docs/utils/drag.html +236 -5
  61. package/docs/utils/elevation.html +238 -6
  62. package/docs/utils/formatTimestamp.html +239 -9
  63. package/docs/utils/object.html +236 -5
  64. package/docs/utils/propConverters.html +233 -3
  65. package/docs/utils/string.html +236 -5
  66. package/docs/utils/theme.html +237 -6
  67. package/docs/utils/toTitleCase.html +239 -9
  68. package/docs/utils/type.html +236 -5
  69. package/docs/utils/wait.html +236 -5
  70. package/docs-src/.config.js +16 -0
  71. package/docs-src/bare.template.html +16 -0
  72. package/docs-src/components/accordion.page.html +201 -0
  73. package/docs-src/components/aside-items.page.html +36 -0
  74. package/docs-src/components/aside-menu.page.html +36 -0
  75. package/docs-src/components/aside-push.page.html +20 -0
  76. package/docs-src/components/aside.page.html +494 -0
  77. package/docs-src/components/card.page.html +78 -0
  78. package/docs-src/components/color-picker.page.html +559 -0
  79. package/docs-src/components/content-slider.page.html +266 -0
  80. package/docs-src/components/context.page.html +214 -0
  81. package/docs-src/components/dialog.page.html +365 -0
  82. package/docs-src/components/dropdown.page.html +300 -0
  83. package/docs-src/components/filter-list.page.html +117 -0
  84. package/docs-src/components/focus-capture.page.html +97 -0
  85. package/docs-src/components/html-editor.page.html +423 -0
  86. package/docs-src/components/hybrid-component.page.html +96 -0
  87. package/docs-src/components/icon.page.html +208 -0
  88. package/docs-src/components/import.page.html +76 -0
  89. package/docs-src/components/light-component.page.html +99 -0
  90. package/docs-src/components/nav.page.html +106 -0
  91. package/docs-src/components/photo-viewer.page.html +253 -0
  92. package/docs-src/components/resize.page.html +161 -0
  93. package/docs-src/components/shadow-component.page.html +84 -0
  94. package/docs-src/components/show-more.page.html +113 -0
  95. package/docs-src/components/sortable.page.html +117 -0
  96. package/docs-src/components/spinner.page.html +197 -0
  97. package/docs-src/components/split.page.html +195 -0
  98. package/docs-src/components/table.page.html +283 -0
  99. package/docs-src/components/tableControls.page.html +64 -0
  100. package/docs-src/components/tableCustomFields.page.html +124 -0
  101. package/docs-src/components/tableFetchRecords.page.html +95 -0
  102. package/docs-src/components/tableFieldSortHide.page.html +56 -0
  103. package/docs-src/components/tablePagination.page.html +85 -0
  104. package/docs-src/components/tablePlaceholder.page.html +73 -0
  105. package/docs-src/components/tableRecordEditing.page.html +161 -0
  106. package/docs-src/components/tableRecordFiltering.page.html +69 -0
  107. package/docs-src/components/tableRecordHiding.page.html +65 -0
  108. package/docs-src/components/tableRecordSearching.page.html +56 -0
  109. package/docs-src/components/tableRecordSelection.page.html +60 -0
  110. package/docs-src/components/tableRowControls.page.html +62 -0
  111. package/docs-src/components/tableServerSync.page.html +129 -0
  112. package/docs-src/components/tableSorting.page.html +54 -0
  113. package/docs-src/components/tabs.page.html +201 -0
  114. package/docs-src/components/tags.page.html +157 -0
  115. package/docs-src/components/theme-select.page.html +106 -0
  116. package/docs-src/components/theme-switcher.page.html +122 -0
  117. package/docs-src/components/timestamp.page.html +109 -0
  118. package/docs-src/components/toast.page.html +338 -0
  119. package/docs-src/components/toggle.page.html +177 -0
  120. package/docs-src/components/tree.page.html +356 -0
  121. package/docs-src/default.template.html +28 -0
  122. package/docs-src/index.page.html +312 -0
  123. package/docs-src/nav.fragment.html +228 -0
  124. package/docs-src/utils/context.page.html +143 -0
  125. package/docs-src/utils/cookie.page.html +128 -0
  126. package/docs-src/utils/debounce.page.html +42 -0
  127. package/docs-src/utils/drag.page.html +64 -0
  128. package/docs-src/utils/elevation.page.html +144 -0
  129. package/docs-src/utils/formatTimestamp.page.html +76 -0
  130. package/docs-src/utils/object.page.html +76 -0
  131. package/docs-src/utils/propConverters.page.html +73 -0
  132. package/docs-src/utils/string.page.html +66 -0
  133. package/docs-src/utils/theme.page.html +136 -0
  134. package/docs-src/utils/toTitleCase.page.html +52 -0
  135. package/docs-src/utils/type.page.html +31 -0
  136. package/docs-src/utils/wait.page.html +31 -0
  137. package/package.json +4 -4
  138. package/scripts/build.js +5 -0
  139. package/scripts/docs.js +5 -52
  140. package/src/components/Aside.js +12 -1
  141. package/src/components/Main.js +1 -1
  142. package/tests/components/Aside.browser-test.js +75 -0
  143. package/docs/dev.config.json +0 -20
  144. package/docs/nav-1.inc.html +0 -168
  145. package/docs/nav.inc.html +0 -168
  146. package/docs/nav.inc.js +0 -70
@@ -0,0 +1,365 @@
1
+ <page pageName="Dialog" title="Dialog - Components - Kempo Docs - A Web Components Solution">
2
+ <content location="header"></content>
3
+ <content>
4
+ <h1 class="ta-center">Dialog</h1>
5
+
6
+ <k-accordion persistent-id="toc" class="b r mb">
7
+ <k-accordion-header for-panel="toc-panel">Table of Contents</k-accordion-header>
8
+ <k-accordion-panel name="toc-panel">
9
+ <div class="m ">
10
+ <h6>Examples</h6>
11
+ <a href="#basicUsage">Basic Usage</a><br />
12
+ <a href="#titles">Titles</a><br />
13
+ <a href="#actionButtons">Action Buttons</a><br />
14
+ <a href="#disableKeyboardClose">Disabling Keyboard Close</a><br />
15
+ <a href="#jsUsage">JavaScript Usage</a><br />
16
+ <a href="#litTemplate">Lit Template Content</a><br />
17
+ <a href="#confirmDialog">Confirm Dialog</a><br />
18
+
19
+ <h6 class="mt"><a href="#jsRef" class="no-link">JavaScript Reference</a></h6>
20
+ <a href="#constructor">Constructor</a><br />
21
+ <a href="#requirements">Requirements</a><br />
22
+ <a href="#attributes">Attributes</a><br />
23
+ <a href="#properties">Properties</a><br />
24
+ <a href="#methods">Methods</a><br />
25
+ <a href="#staticMethods">Static Methods</a><br />
26
+ </div>
27
+ </k-accordion-panel>
28
+ </k-accordion>
29
+
30
+ <h3 id="basicUsage"><a href="#basicUsage" class="no-link">Basic Usage</a></h3>
31
+ <p>Create dialogs using the <code>k-dialog</code> component. Open the dialog by calling the <code>open()</code> method, and close it by calling the <code>close()</code> method. Or it can be closed using the dialog's GUI (clicking the overlay, clicking the close button, or the cancel or confirm action buttons).</p>
32
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-dialog</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d1"</span>&gt;</span><br /> <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"p"</span>&gt;</span>Hello World<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br /><span class="hljs-tag">&lt;/<span class="hljs-name">k-dialog</span>&gt;</span><br /><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onclick</span>=<span class="hljs-string">"document.getElementById('d1').open()"</span>&gt;</span>Open Dialog<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></code></pre>
33
+ <button class="openDialog mb" data-dialog="d1" slot="right">Open Dialog</button>
34
+ <k-dialog id="d1">
35
+ <p class="p">Hello World</p>
36
+ </k-dialog>
37
+
38
+ <h3 id="titles"><a href="#titles" class="no-link">Titles</a></h3>
39
+ <p>Assign an element to the <code>title</code> slot to have it appear as the dialog title.</p>
40
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-dialog</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d2"</span>&gt;</span><br /> <span class="hljs-tag">&lt;<span class="hljs-name">h6</span><br /> <span class="hljs-attr">class</span>=<span class="hljs-string">"m0 px"</span><br /> <span class="hljs-attr">slot</span>=<span class="hljs-string">"title"</span><br /> &gt;</span>This is a fact<span class="hljs-tag">&lt;/<span class="hljs-name">h6</span>&gt;</span><br /> <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"p"</span>&gt;</span>A hotdog is a sandwhich<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br /><span class="hljs-tag">&lt;/<span class="hljs-name">k-dialog</span>&gt;</span></code></pre>
41
+ <button class="openDialog mb" data-dialog="d2" slot="right">Open Dialog</button>
42
+ <k-dialog
43
+ id="d2"
44
+ >
45
+ <h6
46
+ class="m0 px"
47
+ slot="title"
48
+ >This is a fact</h6>
49
+ <p class="p">A hotdog is a sandwhich</p>
50
+ </k-dialog>
51
+
52
+ <h3 id="actionButtons"><a href="#actionButtons" class="no-link">Action Buttons</a></h3>
53
+ <p>Add a cancel button using the <code>cancel-text</code> attribute.</p>
54
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-dialog</span><br /> <span class="hljs-attr">id</span>=<span class="hljs-string">"d4"</span><br /> <span class="hljs-attr">cancel-text</span>=<span class="hljs-string">"Absolutly Not"</span><br />&gt;</span><br /> <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"p"</span>&gt;</span>Mint and Chocolate belong together<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br /><span class="hljs-tag">&lt;/<span class="hljs-name">k-dialog</span>&gt;</span></code></pre>
55
+ <button class="openDialog mb" data-dialog="d4" slot="right">Open Dialog</button>
56
+ <k-dialog
57
+ id="d4"
58
+ cancel-text="Absolutly Not"
59
+ >
60
+ <p class="p">Mint and Chocolate belong together</p>
61
+ </k-dialog>
62
+
63
+ <p>Add a confirm button using the <code>confirm-text</code> attribute.</p>
64
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-dialog</span><br /> <span class="hljs-attr">id</span>=<span class="hljs-string">"d5"</span><br /> <span class="hljs-attr">confirm-text</span>=<span class="hljs-string">"Confirm"</span><br />&gt;</span><br /> <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"p"</span>&gt;</span>Spaghetti is the greatest food<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br /><span class="hljs-tag">&lt;/<span class="hljs-name">k-dialog</span>&gt;</span></code></pre>
65
+ <button class="openDialog mb" data-dialog="d5" slot="right">Open Dialog</button>
66
+ <k-dialog
67
+ id="d5"
68
+ confirm-text="Confirm"
69
+ >
70
+ <p class="p">Spaghetti is the greatest food</p>
71
+ </k-dialog>
72
+
73
+ <p>Try it with both a cancel and confirm button.</p>
74
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-dialog</span><br /> <span class="hljs-attr">id</span>=<span class="hljs-string">"d6"</span><br /> <span class="hljs-attr">cancel-text</span>=<span class="hljs-string">"It should be outlawed"</span><br /> <span class="hljs-attr">confirm-text</span>=<span class="hljs-string">"Of course it is"</span><br />&gt;</span><br /> <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"p"</span>&gt;</span>Ranch is gross<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br /><span class="hljs-tag">&lt;/<span class="hljs-name">k-dialog</span>&gt;</span></code></pre>
75
+ <button class="openDialog mb" data-dialog="d6" slot="right">Open Dialog</button>
76
+ <k-dialog
77
+ id="d6"
78
+ cancel-text="It should be outlawed"
79
+ confirm-text="Of course it is"
80
+ >
81
+ <p class="p">Ranch is gross</p>
82
+ </k-dialog>
83
+
84
+ <h3 id="disableKeyboardClose"><a href="#disableKeyboardClose" class="no-link">Disabling Keyboard Close</a></h3>
85
+ <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>
86
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<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>&gt;</span><br /> <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"p"</span>&gt;</span>This dialog cannot be closed with ESC<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br /><span class="hljs-tag">&lt;/<span class="hljs-name">k-dialog</span>&gt;</span><br /><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onclick</span>=<span class="hljs-string">"document.getElementById('d10').open()"</span>&gt;</span>Open Dialog<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></code></pre>
87
+ <button class="openDialog mb" data-dialog="d10" slot="right">Open Dialog</button>
88
+ <k-dialog id="d10" disable-keyboard-close>
89
+ <p class="p">This dialog cannot be closed with ESC</p>
90
+ </k-dialog>
91
+
92
+ <h3 id="jsUsage"><a href="#jsUsage" class="no-link">JavaScript Usage</a></h3>
93
+ <h5>Create Dialog</h5>
94
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d7"</span>&gt;</span>Open Dialog<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span><br /><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>&gt;</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>, () =&gt; {<br /> Dialog.create(<span class="hljs-string">'Hello World'</span>);<br /> });<br /></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre>
95
+ <button id="d7" class="mb">Open Dialog</button>
96
+ <script type="module">
97
+ import Dialog from '{{pathToRoot}}src/components/Dialog.js';
98
+ document.getElementById('d7').addEventListener('click', () => {
99
+ Dialog.create('Hello World');
100
+ });
101
+ </script>
102
+
103
+ <h5>Dialog with Title</h5>
104
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d7b"</span>&gt;</span>Open Dialog with Title<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span><br /><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>&gt;</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">'d7b'</span>).addEventListener(<span class="hljs-string">'click'</span>, () =&gt; {<br /> Dialog.create(<span class="hljs-string">'This is the dialog content'</span>, {<br /> <span class="hljs-attr">title</span>: <span class="hljs-string">'My Dialog Title'</span><br /> });<br /> });<br /></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre>
105
+ <button id="d7b" class="mb">Open Dialog with Title</button>
106
+ <script type="module">
107
+ import Dialog from '{{pathToRoot}}src/components/Dialog.js';
108
+ document.getElementById('d7b').addEventListener('click', () => {
109
+ Dialog.create('This is the dialog content', {
110
+ title: 'My Dialog Title'
111
+ });
112
+ });
113
+ </script>
114
+
115
+ <h5>Error Dialog</h5>
116
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d8"</span>&gt;</span>Open Dialog<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span><br /><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>&gt;</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">'d8'</span>).addEventListener(<span class="hljs-string">'click'</span>, () =&gt; {<br /> Dialog.error(<span class="hljs-string">"Oh no, don't do that!"</span>);<br /> });<br /></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre>
117
+ <button id="d8" class="mb">Open Dialog</button>
118
+ <script type="module">
119
+ import Dialog from '{{pathToRoot}}src/components/Dialog.js';
120
+ document.getElementById('d8').addEventListener('click', () => {
121
+ Dialog.error("Oh no, don't do that!");
122
+ });
123
+ </script>
124
+
125
+ <h3 id="litTemplate"><a href="#litTemplate" class="no-link">Lit Template Content</a></h3>
126
+ <p>You can pass a Lit <code>html</code> tagged template literal directly as the content to any of the static methods (<code>Dialog.create</code>, <code>Dialog.confirm</code>, <code>Dialog.alert</code>, <code>Dialog.error</code>, <code>Dialog.success</code>).</p>
127
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d11"</span>&gt;</span>Open Dialog with Lit Template<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span><br /><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>&gt;</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-keyword">import</span> { html } <span class="hljs-keyword">from</span> <span class="hljs-string">'/src/lit-all.min.js'</span>;<br /> <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'d11'</span>).addEventListener(<span class="hljs-string">'click'</span>, <span class="hljs-function">() =&gt;</span> {<br /> Dialog.create(html<span class="hljs-string">`<br /> &lt;div class="p"&gt;<br /> &lt;h6&gt;Custom Lit Content&lt;/h6&gt;<br /> &lt;p&gt;This was created with a Lit template.&lt;/p&gt;<br /> &lt;/div&gt;<br /> `</span>, {<br /> <span class="hljs-attr">title</span>: <span class="hljs-string">'Lit Template Dialog'</span><br /> });<br /> });<br /></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre>
128
+ <button id="d11" class="mb">Open Dialog with Lit Template</button>
129
+ <script type="module">
130
+ import Dialog from '{{pathToRoot}}src/components/Dialog.js';
131
+ import { html } from '{{pathToRoot}}src/lit-all.min.js';
132
+ document.getElementById('d11').addEventListener('click', () => {
133
+ Dialog.create(html`
134
+ <div class="p">
135
+ <h6>Custom Lit Content</h6>
136
+ <p>This was created with a Lit template.</p>
137
+ </div>
138
+ `, {
139
+ title: 'Lit Template Dialog'
140
+ });
141
+ });
142
+ </script>
143
+
144
+ <h3 id="confirmDialog"><a href="#confirmDialog" class="no-link">Confirm Dialog</a></h3>
145
+ <p>Use the <code>Dialog.confirm</code> static method to create a confirmation dialog. This method takes a text message, a response callback, and an options object.</p>
146
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d9"</span>&gt;</span>Open Confirm Dialog<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span><br /><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>&gt;</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">'d9'</span>).addEventListener(<span class="hljs-string">'click'</span>, () =&gt; {<br /> Dialog.confirm(<span class="hljs-string">"Are you sure you want to proceed?"</span>, <span class="hljs-function"><span class="hljs-params">response</span> =&gt;</span> {<br /> <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"User response:"</span>, response);<br /> });<br /> });<br /></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre>
147
+ <button id="d9" class="mb">Open Confirm Dialog</button>
148
+ <script type="module">
149
+ import Dialog from '{{pathToRoot}}src/components/Dialog.js';
150
+ document.getElementById('d9').addEventListener('click', () => {
151
+ Dialog.confirm("Are you sure you want to proceed?", response => {
152
+ console.log("User response:", response);
153
+ });
154
+ });
155
+ </script>
156
+
157
+ <h2 id="jsRef"><a href="#jsRef" class="no-link">JavaScript Reference</a></h2>
158
+
159
+ <h3 id="constructor"><a href="#constructor" class="no-link">Constructor</a></h3>
160
+ <h6>Extends <a href="./components/shadow-component.html">ShadowComponent</a></h6>
161
+ <h5>
162
+ <code>new Dialog()</code><br />
163
+ <code>new Dialog(<i>object</i> options)</code>
164
+ </h5>
165
+
166
+ <h4>Parameters</h4>
167
+ <h5><code>options<i>: object</i></code></h5>
168
+ <p>An object containing the initial configuration for the dialog. The options object can contain the following properties:</p>
169
+ <ul>
170
+ <li><code>opened</code>: <i>boolean</i> - Whether the dialog is initially opened.</li>
171
+ <li><code>closeBtn</code>: <i>boolean</i> - Whether to show the close button.</li>
172
+ <li><code>overlayClose</code>: <i>boolean</i> - Whether clicking the overlay closes the dialog.</li>
173
+ <li><code>confirmText</code>: <i>string</i> - Text for the confirm button.</li>
174
+ <li><code>confirmClasses</code>: <i>string</i> - Classes for the confirm button.</li>
175
+ <li><code>confirmAction</code>: <i>function</i> - Action to perform on confirm.</li>
176
+ <li><code>cancelText</code>: <i>string</i> - Text for the cancel button.</li>
177
+ <li><code>cancelClasses</code>: <i>string</i> - Classes for the cancel button.</li>
178
+ <li><code>cancelAction</code>: <i>function</i> - Action to perform on cancel.</li>
179
+ <li><code>closeCallback</code>: <i>function</i> - Callback to execute when the dialog is closed.</li>
180
+ </ul>
181
+
182
+ <h3 id="requirements"><a href="#requirements" class="no-link">Requirements</a></h3>
183
+ <ul>
184
+ <li><a href="./components/shadow-component.html">ShadowComponent</a></li>
185
+ <li><a href="./components/icon.html">Icon</a></li>
186
+ <li><a href="./components/focus-capture.html">FocusCapture</a></li>
187
+ </ul>
188
+
189
+ <h3 id="attributes"><a href="#attributes" class="no-link">Attributes</a></h3>
190
+ <h5><code>opened<i>: boolean</i></code></h5>
191
+ <p>Whether the dialog is opened.</p>
192
+
193
+ <h5><code>close-btn<i>: boolean</i></code></h5>
194
+ <p>Whether to show the close button. Default is <code>true</code>.</p>
195
+
196
+ <h5><code>overlay-close<i>: boolean</i></code></h5>
197
+ <p>Whether clicking the overlay closes the dialog. Default is <code>true</code>.</p>
198
+
199
+ <h5><code>disable-keyboard-close<i>: boolean</i></code></h5>
200
+ <p>Whether to disable closing the dialog with the ESC key. Default is <code>false</code>.</p>
201
+
202
+ <h5><code>confirm-text<i>: string</i></code></h5>
203
+ <p>Text for the confirm button.</p>
204
+
205
+ <h5><code>confirm-classes<i>: string</i></code></h5>
206
+ <p>Classes for the confirm button. Default is <code>'success ml'</code>.</p>
207
+
208
+ <h5><code>cancel-text<i>: string</i></code></h5>
209
+ <p>Text for the cancel button.</p>
210
+
211
+ <h5><code>cancel-classes<i>: string</i></code></h5>
212
+ <p>Classes for the cancel button.</p>
213
+
214
+ <h3 id="properties"><a href="#properties" class="no-link">Properties</a></h3>
215
+ <h5><code>confirmAction<i>: function</i></code></h5>
216
+ <p>Action to perform on confirm. If the function calls <code>event.preventDefault()</code>, the dialog will not close automatically.</p>
217
+
218
+ <h5><code>cancelAction<i>: function</i></code></h5>
219
+ <p>Action to perform on cancel. If the function calls <code>event.preventDefault()</code>, the dialog will not close automatically.</p>
220
+
221
+ <h5><code>disableKeyboardClose<i>: boolean</i></code></h5>
222
+ <p>Whether to disable closing the dialog with the ESC key. Default is <code>false</code>.</p>
223
+
224
+ <h5><code>closeCallback<i>: function</i></code></h5>
225
+ <p>Callback to execute when the dialog is closed.</p>
226
+
227
+ <h5><code>previousFocus<i>: HTMLElement</i></code></h5>
228
+ <p>Reference to the element that had focus before the dialog was opened.</p>
229
+
230
+ <h3 id="methods"><a href="#methods" class="no-link">Methods</a></h3>
231
+ <h5><code>open()<i>: void</i></code></h5>
232
+ <p>Opens the dialog and sets focus to the first focusable element or an element with the <code>autofocus</code> attribute.</p>
233
+
234
+ <h5><code>close()<i>: void</i></code></h5>
235
+ <p>Closes the dialog and calls the <code>closeCallback</code>.</p>
236
+
237
+ <h5><code>toggle()<i>: void</i></code></h5>
238
+ <p>Toggles the dialog open or closed.</p>
239
+
240
+ <h5><code>focus()<i>: void</i></code></h5>
241
+ <p>Focuses the first focusable element in the dialog and saves the previously focused element.</p>
242
+
243
+ <h5><code>blur()<i>: void</i></code></h5>
244
+ <p>Returns focus to the element that had focus before the dialog was opened.</p>
245
+
246
+ <h3 id="staticMethods"><a href="#staticMethods" class="no-link">Static Methods</a></h3>
247
+ <h5><code>Dialog.create(contents, options)<i>: Dialog</i></code></h5>
248
+ <p>Creates and opens a new dialog with the specified contents and options. Returns the created Dialog instance.</p>
249
+ <p>If <code>contents</code> is plain text (no HTML tags), it will automatically be wrapped in a <code>&lt;p class="p"&gt;</code> tag. If it contains HTML, it will be inserted as-is. If it's an HTMLElement or DocumentFragment, it will be appended directly. You can also pass a Lit <code>html</code> tagged template literal (<code>TemplateResult</code>), which will be rendered using Lit's <code>render()</code>.</p>
250
+
251
+ <h6>Parameters</h6>
252
+ <ul>
253
+ <li><code>contents<i>: string | HTMLElement | DocumentFragment | TemplateResult</i></code> - The content to display in the dialog. Plain text will be wrapped in a paragraph tag automatically.</li>
254
+ <li><code>options<i>: object</i></code> - Configuration options for the dialog.</li>
255
+ </ul>
256
+
257
+ <h6>Options</h6>
258
+ <ul>
259
+ <li><code>title</code>: <i>string | HTMLElement</i> - The title to display in the dialog header. Will be wrapped in an <code>&lt;h5&gt;</code> tag with the <code>title</code> slot.</li>
260
+ <li><code>titleClasses</code>: <i>string</i> - CSS classes for the title element. Default is <code>'pyh px m0'</code>.</li>
261
+ <li><code>opened</code>: <i>boolean</i> - Whether the dialog is initially opened. Default is <code>true</code>.</li>
262
+ <li><code>closeBtn</code>: <i>boolean</i> - Whether to show the close button.</li>
263
+ <li><code>overlayClose</code>: <i>boolean</i> - Whether clicking the overlay closes the dialog.</li>
264
+ <li><code>disableKeyboardClose</code>: <i>boolean</i> - Whether to disable closing the dialog with the ESC key.</li>
265
+ <li><code>confirmText</code>: <i>string</i> - Text for the confirm button.</li>
266
+ <li><code>confirmClasses</code>: <i>string</i> - Classes for the confirm button.</li>
267
+ <li><code>confirmAction</code>: <i>function</i> - Action to perform on confirm.</li>
268
+ <li><code>cancelText</code>: <i>string</i> - Text for the cancel button.</li>
269
+ <li><code>cancelClasses</code>: <i>string</i> - Classes for the cancel button.</li>
270
+ <li><code>cancelAction</code>: <i>function</i> - Action to perform on cancel.</li>
271
+ <li><code>closeCallback</code>: <i>function</i> - Callback to execute when the dialog is closed.</li>
272
+ <li><code>removeOnClose</code>: <i>boolean</i> - Whether to remove the dialog from the DOM when closed. Default is <code>true</code>.</li>
273
+ <li><code>closeExisting</code>: <i>boolean</i> - Whether to close existing dialogs before opening this one. Default is <code>true</code>.</li>
274
+ <li><code>width</code>: <i>string</i> - CSS width value for the dialog.</li>
275
+ <li><code>minWidth</code>: <i>string</i> - CSS min-width value for the dialog.</li>
276
+ <li><code>maxWidth</code>: <i>string</i> - CSS max-width value for the dialog.</li>
277
+ <li><code>height</code>: <i>string</i> - CSS height value for the dialog.</li>
278
+ <li><code>minHeight</code>: <i>string</i> - CSS min-height value for the dialog.</li>
279
+ <li><code>maxHeight</code>: <i>string</i> - CSS max-height value for the dialog.</li>
280
+ </ul>
281
+
282
+ <h5><code>Dialog.confirm(text, responseCallback, options)<i>: Dialog</i></code></h5>
283
+ <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>
284
+
285
+ <h6>Parameters</h6>
286
+ <ul>
287
+ <li><code>text<i>: string | TemplateResult</i></code> - The message to display in the dialog.</li>
288
+ <li><code>responseCallback<i>: function</i></code> - Function called with the user's response (<code>true</code> for confirm, <code>false</code> for cancel).</li>
289
+ <li><code>options<i>: object</i></code> - Configuration options.</li>
290
+ </ul>
291
+
292
+ <h6>Options</h6>
293
+ <ul>
294
+ <li><code>title</code>: <i>string</i> - The title of the dialog. Default is <code>'Confirm'</code>.</li>
295
+ <li><code>confirmText</code>: <i>string</i> - Text for the confirm button. Default is <code>'Yes'</code>.</li>
296
+ <li><code>confirmClasses</code>: <i>string</i> - Classes for the confirm button. Default is <code>'success ml'</code>.</li>
297
+ <li><code>cancelText</code>: <i>string</i> - Text for the cancel button. Default is <code>'No'</code>.</li>
298
+ <li><code>cancelClasses</code>: <i>string</i> - Classes for the cancel button. Default is <code>'danger'</code>.</li>
299
+ <li><code>closeBtn</code>: <i>boolean</i> - Whether to show the close button. Default is <code>false</code>.</li>
300
+ <li><code>overlayClose</code>: <i>boolean</i> - Whether clicking the overlay closes the dialog. Default is <code>false</code>.</li>
301
+ <li><code>disableKeyboardClose</code>: <i>boolean</i> - Whether to disable closing the dialog with the ESC key. Default is <code>true</code>.</li>
302
+ </ul>
303
+
304
+ <h5><code>Dialog.alert(text, responseCallback, options)<i>: Dialog</i></code></h5>
305
+ <p>Creates and opens an alert dialog with the specified text and options.</p>
306
+
307
+ <h6>Parameters</h6>
308
+ <ul>
309
+ <li><code>text<i>: string | TemplateResult</i></code> - The message to display in the dialog.</li>
310
+ <li><code>responseCallback<i>: function</i></code> - Function called when the dialog is closed.</li>
311
+ <li><code>options<i>: object</i></code> - Configuration options.</li>
312
+ </ul>
313
+
314
+ <h6>Options</h6>
315
+ <ul>
316
+ <li><code>title</code>: <i>string</i> - The title of the dialog. Default is <code>'Alert'</code>.</li>
317
+ <li><code>cancelText</code>: <i>string</i> - Text for the OK button. Default is <code>'Ok'</code>.</li>
318
+ </ul>
319
+
320
+ <h5><code>Dialog.error(text, responseCallback, options)<i>: Dialog</i></code></h5>
321
+ <p>Creates and opens an error dialog with the specified text and options. The title is displayed in red.</p>
322
+
323
+ <h6>Parameters</h6>
324
+ <ul>
325
+ <li><code>text<i>: string | TemplateResult</i></code> - The error message to display in the dialog.</li>
326
+ <li><code>responseCallback<i>: function</i></code> - Function called when the dialog is closed.</li>
327
+ <li><code>options<i>: object</i></code> - Configuration options.</li>
328
+ </ul>
329
+
330
+ <h6>Options</h6>
331
+ <ul>
332
+ <li><code>title</code>: <i>string</i> - The title of the dialog. Default is <code>'Error'</code>.</li>
333
+ <li><code>cancelText</code>: <i>string</i> - Text for the OK button. Default is <code>'Ok'</code>.</li>
334
+ </ul>
335
+
336
+ <h5><code>Dialog.success(text, responseCallback, options)<i>: Dialog</i></code></h5>
337
+ <p>Creates and opens a success dialog with the specified text and options. The title is displayed in green.</p>
338
+
339
+ <h6>Parameters</h6>
340
+ <ul>
341
+ <li><code>text<i>: string | TemplateResult</i></code> - The success message to display in the dialog.</li>
342
+ <li><code>responseCallback<i>: function</i></code> - Function called when the dialog is closed.</li>
343
+ <li><code>options<i>: object</i></code> - Configuration options.</li>
344
+ </ul>
345
+
346
+ <h6>Options</h6>
347
+ <ul>
348
+ <li><code>title</code>: <i>string</i> - The title of the dialog. Default is <code>'Success'</code>.</li>
349
+ <li><code>cancelText</code>: <i>string</i> - Text for the OK button. Default is <code>'Ok'</code>.</li>
350
+ </ul>
351
+ </content>
352
+ <content location="scripts">
353
+ <script type="module" src="{{pathToRoot}}src/components/Dialog.js"></script>
354
+ <script type="module" src="{{pathToRoot}}src/components/Accordion.js"></script>
355
+ <script type="module" src="{{pathToRoot}}src/components/Card.js"></script>
356
+ <script>
357
+ document.querySelectorAll('.openDialog').forEach( $btn => {
358
+ $btn.addEventListener('click', () => {
359
+ const $dialog = document.getElementById($btn.dataset.dialog);
360
+ if($dialog) $dialog.open();
361
+ });
362
+ });
363
+ </script>
364
+ </content>
365
+ </page>