kempo-ui 0.0.2 → 0.0.3

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 (193) hide show
  1. package/.github/copilot-instructions.md +149 -149
  2. package/.github/workflows/publish-npm.yml +44 -44
  3. package/CONTRIBUTING.md +149 -149
  4. package/README.md +0 -0
  5. package/dist/kempo-vars.css +0 -0
  6. package/dist/src/components/FocusCapture.js +7 -0
  7. package/dist/src/components/Icon.js +10 -0
  8. package/dist/src/components/Import.js +1 -0
  9. package/dist/src/components/ShadowComponent.js +1 -0
  10. package/dist/src/components/SideMenu.js +97 -0
  11. package/dist/src/lit-all.min.js +120 -0
  12. package/docs/components/accordion.html +122 -0
  13. package/docs/components/card.html +91 -0
  14. package/docs/components/component.html +90 -0
  15. package/docs/components/content-slider.html +193 -0
  16. package/docs/components/dialog.html +245 -0
  17. package/docs/components/directory-viewer.html +90 -0
  18. package/docs/components/focus-capture.html +68 -0
  19. package/docs/components/icon.html +161 -0
  20. package/docs/components/import.html +78 -0
  21. package/docs/components/lazy-component.html +84 -0
  22. package/docs/components/reactive-component.html +69 -0
  23. package/docs/components/reactive-lazy-component.html +69 -0
  24. package/docs/components/resize.html +152 -0
  25. package/docs/components/search.html +102 -0
  26. package/docs/components/show-more.html +123 -0
  27. package/docs/components/side-menu.html +168 -0
  28. package/docs/components/sortable.html +96 -0
  29. package/docs/components/split.html +126 -0
  30. package/docs/components/table.html +312 -0
  31. package/docs/components/tableControls.html +77 -0
  32. package/docs/components/tableCustomFields.html +113 -0
  33. package/docs/components/tableFetchRecords.html +114 -0
  34. package/docs/components/tableFieldSortHide.html +75 -0
  35. package/docs/components/tablePagination.html +100 -0
  36. package/docs/components/tableRecordEditing.html +144 -0
  37. package/docs/components/tableRecordFiltering.html +75 -0
  38. package/docs/components/tableRecordHiding.html +80 -0
  39. package/docs/components/tableRecordSearching.html +75 -0
  40. package/docs/components/tableRecordSelection.html +75 -0
  41. package/docs/components/tableRowControls.html +78 -0
  42. package/docs/components/tableSorting.html +73 -0
  43. package/docs/components/tabs.html +163 -0
  44. package/docs/components/tags.html +94 -0
  45. package/docs/components/theme-switcher.html +129 -0
  46. package/docs/components/timestamp.html +86 -0
  47. package/docs/components/toast.html +328 -0
  48. package/docs/components/toggle.html +155 -0
  49. package/docs/dev.config.json +20 -0
  50. package/docs/icons/add.svg +1 -0
  51. package/docs/icons/arrow-back.svg +1 -0
  52. package/docs/icons/arrow-down-double.svg +1 -0
  53. package/docs/icons/arrow-down.svg +1 -0
  54. package/docs/icons/arrow-forward.svg +1 -0
  55. package/docs/icons/arrow-up-double.svg +1 -0
  56. package/docs/icons/arrow-up.svg +1 -0
  57. package/docs/icons/cards.svg +1 -0
  58. package/docs/icons/check.svg +1 -0
  59. package/docs/icons/chevron-left.svg +1 -0
  60. package/docs/icons/chevron-right.svg +1 -0
  61. package/docs/icons/close.svg +2 -0
  62. package/docs/icons/compare.svg +1 -0
  63. package/docs/icons/delete.svg +1 -0
  64. package/docs/icons/drag-handle.svg +1 -0
  65. package/docs/icons/drawing2.svg +124 -0
  66. package/docs/icons/edit.svg +1 -0
  67. package/docs/icons/error.svg +1 -0
  68. package/docs/icons/export-file.svg +1 -0
  69. package/docs/icons/file-text.svg +1 -0
  70. package/docs/icons/file.svg +1 -0
  71. package/docs/icons/filter-off.svg +1 -0
  72. package/docs/icons/filter.svg +1 -0
  73. package/docs/icons/first.svg +1 -0
  74. package/docs/icons/folder-clear.svg +1 -0
  75. package/docs/icons/folder-create.svg +1 -0
  76. package/docs/icons/folder-open.svg +1 -0
  77. package/docs/icons/folder.svg +1 -0
  78. package/docs/icons/hide.svg +1 -0
  79. package/docs/icons/image.svg +1 -0
  80. package/docs/icons/label-add.svg +1 -0
  81. package/docs/icons/label.svg +1 -0
  82. package/docs/icons/last.svg +1 -0
  83. package/docs/icons/menu.svg +1 -0
  84. package/docs/icons/mode-auto.svg +1 -0
  85. package/docs/icons/mode-dark.svg +1 -0
  86. package/docs/icons/mode-light.svg +1 -0
  87. package/docs/icons/open-in-browser.svg +1 -0
  88. package/docs/icons/pause.svg +1 -0
  89. package/docs/icons/play.svg +1 -0
  90. package/docs/icons/refresh.svg +1 -0
  91. package/docs/icons/remove.svg +1 -0
  92. package/docs/icons/save.svg +1 -0
  93. package/docs/icons/search.svg +1 -0
  94. package/docs/icons/settings.svg +1 -0
  95. package/docs/icons/show.svg +1 -0
  96. package/docs/icons/storage.svg +1 -0
  97. package/docs/icons/table-visibility.svg +1 -0
  98. package/docs/icons/tag.svg +1 -0
  99. package/docs/icons/tools.svg +1 -0
  100. package/docs/icons/trash-x.svg +1 -0
  101. package/docs/icons/warning.svg +1 -0
  102. package/docs/index.html +28 -21
  103. package/docs/nav.inc.html +73 -0
  104. package/docs/nav.inc.js +4 -0
  105. package/{config/production.json → docs/prod.config.json} +20 -16
  106. package/docs/src/components/FocusCapture.js +7 -0
  107. package/docs/src/components/HybridComponent.js +1 -0
  108. package/docs/src/components/Icon.js +10 -0
  109. package/docs/src/components/Import.js +1 -0
  110. package/docs/src/components/LightComponent.js +1 -0
  111. package/docs/src/components/ShadowComponent.js +1 -0
  112. package/docs/src/components/SideMenu.js +97 -0
  113. package/docs/src/lit-all.min.js +120 -0
  114. package/docs/src/utils/cli.js +1 -0
  115. package/docs/src/utils/fs-utils.js +1 -0
  116. package/docs/styles.css +6 -0
  117. package/icons/add.svg +1 -0
  118. package/icons/arrow-back.svg +1 -0
  119. package/icons/arrow-down-double.svg +1 -0
  120. package/icons/arrow-down.svg +1 -0
  121. package/icons/arrow-forward.svg +1 -0
  122. package/icons/arrow-up-double.svg +1 -0
  123. package/icons/arrow-up.svg +1 -0
  124. package/icons/cards.svg +1 -0
  125. package/icons/check.svg +1 -0
  126. package/icons/chevron-left.svg +1 -0
  127. package/icons/chevron-right.svg +1 -0
  128. package/icons/close.svg +2 -0
  129. package/icons/compare.svg +1 -0
  130. package/icons/delete.svg +1 -0
  131. package/icons/drag-handle.svg +1 -0
  132. package/icons/drawing2.svg +124 -0
  133. package/icons/edit.svg +1 -0
  134. package/icons/error.svg +1 -0
  135. package/icons/export-file.svg +1 -0
  136. package/icons/file-text.svg +1 -0
  137. package/icons/file.svg +1 -0
  138. package/icons/filter-off.svg +1 -0
  139. package/icons/filter.svg +1 -0
  140. package/icons/first.svg +1 -0
  141. package/icons/folder-clear.svg +1 -0
  142. package/icons/folder-create.svg +1 -0
  143. package/icons/folder-open.svg +1 -0
  144. package/icons/folder.svg +1 -0
  145. package/icons/hide.svg +1 -0
  146. package/icons/image.svg +1 -0
  147. package/icons/label-add.svg +1 -0
  148. package/icons/label.svg +1 -0
  149. package/icons/last.svg +1 -0
  150. package/icons/menu.svg +1 -0
  151. package/icons/mode-auto.svg +1 -0
  152. package/icons/mode-dark.svg +1 -0
  153. package/icons/mode-light.svg +1 -0
  154. package/icons/open-in-browser.svg +1 -0
  155. package/icons/pause.svg +1 -0
  156. package/icons/play.svg +1 -0
  157. package/icons/refresh.svg +1 -0
  158. package/icons/remove.svg +1 -0
  159. package/icons/save.svg +1 -0
  160. package/icons/search.svg +1 -0
  161. package/icons/settings.svg +1 -0
  162. package/icons/show.svg +1 -0
  163. package/icons/storage.svg +1 -0
  164. package/icons/table-visibility.svg +1 -0
  165. package/icons/tag.svg +1 -0
  166. package/icons/tools.svg +1 -0
  167. package/icons/trash-x.svg +1 -0
  168. package/icons/warning.svg +1 -0
  169. package/package.json +2 -2
  170. package/scripts/build.js +109 -138
  171. package/scripts/docs.js +60 -60
  172. package/src/components/Card.js +66 -0
  173. package/src/components/FocusCapture.js +23 -0
  174. package/src/components/HybridComponent.js +40 -40
  175. package/src/components/Icon.js +155 -0
  176. package/src/components/Import.js +104 -0
  177. package/src/components/LightComponent.js +32 -32
  178. package/src/components/ShadowComponent.js +30 -17
  179. package/src/components/SideMenu.js +167 -0
  180. package/src/components/ThemeSwitcher.js +108 -0
  181. package/src/kempo-hljs.css +146 -0
  182. package/src/utils/cli.js +43 -43
  183. package/src/utils/fs-utils.js +41 -41
  184. package/src/utils/propConverters.js +11 -0
  185. package/tests/HybridComponent.browser-test.js +214 -214
  186. package/tests/LightComponent.browser-test.js +169 -169
  187. package/tests/ShadowComponent.browser-test.js +130 -130
  188. package/config/development.json +0 -14
  189. package/docs/components/ShadowComponent.js +0 -1
  190. /package/{docs → dist/src}/components/HybridComponent.js +0 -0
  191. /package/{docs → dist/src}/components/LightComponent.js +0 -0
  192. /package/{docs → dist/src}/utils/cli.js +0 -0
  193. /package/{docs → dist/src}/utils/fs-utils.js +0 -0
@@ -0,0 +1,312 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Table - Components - Kempo Docs - A Web Components Solution</title>
7
+ <link rel="stylesheet" href="../src/kempo-vars.css" />
8
+ <link rel="stylesheet" href="../kempo.min.css" />
9
+ <link rel="stylesheet" href="../src/kempo-hljs.css" />`n <link rel="stylesheet" href="../styles.css" />
10
+ <script type="module" src="../src/components/Table.js"></script>
11
+ <script type="module">
12
+ import Import from '../src/components/Import.js';
13
+ import Icon from '../src/components/Icon.js';
14
+ Import.replacements.root = '../';
15
+ Icon.pathToIcons = ['../icons'];
16
+ </script>
17
+ <script>
18
+
19
+ window.contacts = [];
20
+ function generateContact(){
21
+ const maleNames = [
22
+ "Liam", "Noah", "Oliver", "Elijah", "William", "James", "Benjamin",
23
+ "Lucas", "Henry", "Alexander", "Mason", "Michael", "Ethan", "Daniel",
24
+ "Jacob", "Logan", "Jackson", "Levi", "Sebastian", "Mateo", "Jack",
25
+ "Owen", "Theodore", "Aiden", "Samuel", "Joseph", "John", "David",
26
+ "Wyatt", "Matthew"
27
+ ];
28
+ const femaleNames = [
29
+ "Olivia", "Emma", "Ava", "Sophia", "Isabella", "Mia", "Amelia",
30
+ "Harper", "Evelyn", "Abigail", "Emily", "Ella", "Elizabeth",
31
+ "Camila", "Luna", "Sofia", "Avery", "Mila", "Aria", "Scarlett",
32
+ "Penelope", "Layla", "Chloe", "Victoria", "Madison", "Eleanor",
33
+ "Grace", "Nora", "Riley", "Zoey"
34
+ ];
35
+ const lastNames = [
36
+ "Smith", "Johnson", "Williams", "Brown", "Jones", "Garcia", "Miller",
37
+ "Davis", "Rodriguez", "Martinez", "Hernandez", "Lopez", "Gonzalez",
38
+ "Wilson", "Anderson", "Thomas", "Taylor", "Moore", "Jackson", "Martin",
39
+ "Lee", "Perez", "Thompson", "White", "Harris", "Sanchez", "Clark",
40
+ "Ramirez", "Lewis", "Robinson"
41
+ ];
42
+ const gender = Math.random() > 0.5 ? 'm' : 'f';
43
+ const firstName = gender === 'm' ? maleNames[Math.floor(Math.random() * maleNames.length)] : femaleNames[Math.floor(Math.random() * femaleNames.length)];
44
+ const lastName = lastNames[Math.floor(Math.random() * lastNames.length)];
45
+ const name = `${firstName} ${lastName}`;
46
+ const email = `${firstName.toLowerCase()}.${lastName.toLowerCase()}@mailserver.com`;
47
+ const birthday = `${Math.floor(Math.random() * 100) + 1920}-${String(Math.floor(Math.random() * 12) + 1).padStart(2, '0')}-${String(Math.floor(Math.random() * 28) + 1).padStart(2, '0')}`;
48
+ const phoneNumber = `(${Math.floor(Math.random() * 900) + 100}) ${Math.floor(Math.random() * 900) + 100}-${Math.floor(Math.random() * 9000) + 1000}`;
49
+ return { name, email, birthday, phoneNumber, gender };
50
+ }
51
+ for (let i = 0; i < 100; i++) {
52
+ contacts.push(generateContact());
53
+ };
54
+ </script>
55
+ </head>
56
+ <body>
57
+ <k-import src="../nav.inc.html"></k-import>
58
+ <h1 class="ta-center">Table</h1>
59
+ <main>
60
+ <details
61
+ class="b r mb"
62
+ >
63
+ <summary class="p">Table of Contents</summary>
64
+ <div class="m mt0 pl">
65
+ <h6>Examples</h6>
66
+ <a href="#basicUsage">Basic Usage</a><br />
67
+ <a href="tableCustomFields.html">Custom Fields</a><br />
68
+ <a href="tableControls.html">Top and Bottom Controls</a><br />
69
+ <a href="tableRowControls.html">Row Controls</a><br />
70
+ <a href="tablePagination.html">Pagination</a><br />
71
+ <a href="tableRecordSelection.html">Record Selection</a><br />
72
+ <a href="tableRecordEditing.html">Record Editing</a><br />
73
+ <a href="tableRecordHiding.html">Record Hiding</a><br />
74
+ <a href="tableRecordFiltering.html">Record Filtering</a><br />
75
+ <a href="tableRecordSearching.html">Record Searching</a><br />
76
+ <a href="tableSorting.html">Sorting</a><br />
77
+ <a href="tableFieldSortHide.html">Field Sorting and Hiding</a><br />
78
+ <a href="tableFetchRecords.html">Fetching Records</a><br />
79
+ <h6 class="mt">JavaScript Reference</h6>
80
+ <a href="#constructor">Constructor</a><br />
81
+ <a href="#requirements">Requirements</a><br />
82
+ <a href="#properties">Properties</a><br />
83
+ <a href="#methods">Methods</a><br />
84
+ </div>
85
+ </details>
86
+
87
+ <h3>Description</h3>
88
+ <p>The <code>&lt;k-table></code> component is used to render data into a <code>&lt;table></code> using JavaScript.</p>
89
+
90
+ <h3 id="basicUsage"><a href="#basicUsage" class="no-link">Basic Usage</a></h3>
91
+ <p>In HTML create a <code>&lt;k-table></code>, and then in JavaScript call the <code>setData</code> method passing in an options object containing your data.</p>
92
+
93
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-table</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"basicUsageExample"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">k-table</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-built_in">document</span>.getElementById(<span class="hljs-string">'basicUsageExample'</span>).setData({<br /> records: [<br /> {<br /> <span class="hljs-attr">name</span>: <span class="hljs-string">"Dustin"</span>,<br /> <span class="hljs-attr">phoneNumber</span>: <span class="hljs-string">"(111) 111-1111"</span>,<br /> <span class="hljs-attr">emailAddress</span>: <span class="hljs-string">"dustin@mailserver.com"</span>,<br /> <span class="hljs-attr">gender</span>: <span class="hljs-string">"Male"</span><br /> },<br /> {<br /> <span class="hljs-attr">name</span>: <span class="hljs-string">"Kayla"</span>,<br /> <span class="hljs-attr">phoneNumber</span>: <span class="hljs-string">"(222) 222-2222"</span>,<br /> <span class="hljs-attr">emailAddress</span>: <span class="hljs-string">"kayla@mailserver.com"</span>,<br /> <span class="hljs-attr">gender</span>: <span class="hljs-string">"Female"</span><br /> },<br /> {<br /> <span class="hljs-attr">name</span>: <span class="hljs-string">"Alexander"</span>,<br /> <span class="hljs-attr">phoneNumber</span>: <span class="hljs-string">"(333) 333-33333"</span>,<br /> <span class="hljs-attr">emailAddress</span>: <span class="hljs-string">"alex@mailserver.com"</span>,<br /> <span class="hljs-attr">gender</span>: <span class="hljs-string">"Male"</span><br /> },<br /> {<br /> <span class="hljs-attr">name</span>: <span class="hljs-string">"Amelia"</span>,<br /> <span class="hljs-attr">phoneNumber</span>: <span class="hljs-string">"(444) 444-44444"</span>,<br /> <span class="hljs-attr">emailAddress</span>: <span class="hljs-string">"amelia@mailserver.com"</span>,<br /> <span class="hljs-attr">gender</span>: <span class="hljs-string">"Female"</span><br /> },<br /> ]<br /> });<br /></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre>
94
+ <k-table id="basicUsageExample"></k-table>
95
+ <script type="module">
96
+ document.getElementById('basicUsageExample').setData({
97
+ records: [
98
+ {
99
+ name: "Dustin",
100
+ phoneNumber: "(111) 111-1111",
101
+ emailAddress: "dustin@mailserver.com",
102
+ gender: "Male"
103
+ },
104
+ {
105
+ name: "Kayla",
106
+ phoneNumber: "(222) 222-2222",
107
+ emailAddress: "kayla@mailserver.com",
108
+ gender: "Female"
109
+ },
110
+ {
111
+ name: "Alexander",
112
+ phoneNumber: "(333) 333-33333",
113
+ emailAddress: "alex@mailserver.com",
114
+ gender: "Male"
115
+ },
116
+ {
117
+ name: "Amelia",
118
+ phoneNumber: "(444) 444-44444",
119
+ emailAddress: "amelia@mailserver.com",
120
+ gender: "Female"
121
+ },
122
+ ]
123
+ });
124
+ </script>
125
+
126
+ <h3>Examples</h3>
127
+ <ul>
128
+ <li><a href="tableCustomFields.html">Custom Fields Example</a></li>
129
+ <li><a href="tableControls.html">Top and Bottom Controls</a></li>
130
+ <li><a href="tableRowControls.html">Row Controls</a></li>
131
+ <li><a href="tablePagination.html">Pagination</a></li>
132
+ <li><a href="tableRecordSelection.html">Record Selection</a></li>
133
+ <li><a href="tableRecordEditing.html">Record Editing</a></li>
134
+ <li><a href="tableRecordHiding.html">Record Hiding</a></li>
135
+ <li><a href="tableRecordFiltering.html">Record Filtering</a></li>
136
+ <li><a href="tableRecordSearching.html">Record Searching</a></li>
137
+ <li><a href="tableSorting.html">Sorting</a></li>
138
+ <li><a href="tableFieldSortHide.html">Field Sorting and Hiding</a></li>
139
+ <li><a href="tableFetchRecords.html">Fetching Records</a></li>
140
+ </ul>
141
+
142
+ <br />
143
+ <hr class="my" />
144
+
145
+ <h2>JavaScript Reference</h2>
146
+ <h3 id="constructor"><a href="#constructor" class="no-link">Constructor</a></h3>
147
+ <h6>Extends <a href="./component.html">Component</a></h6>
148
+ <h5>
149
+ <code>new Table()</code><br />
150
+ <code>new Table(<i>&lt;Array>object</i> options)</code>
151
+ </h5>
152
+
153
+ <h4>Parameters</h4>
154
+ <h5><code><i>object</i> options</code></h5>
155
+ <p>An object containing the initial configuration for the table. The options object can contain the following properties:</p>
156
+ <ul>
157
+ <li><code>records</code>: An array of objects representing the records to be shown in the table.</li>
158
+ <li><code>fields</code>: An array of objects representing the fields of the table, each object must contain a <code>name</code> and a <code>label</code>. If this property is omitted, the fields will be automatically generated from the first 100 records.</li>
159
+ <li><code>controls</code>: An object containing optional arrays of controls to be displayed before and/or after each row. Each control is defined by an icon name, a callback function, and optionally an HTML string or a render function. The <code>controls</code> object can contain the optional <code>before</code> and <code>after</code> properties, which are arrays of objects containing the <code>icon</code> (string), <code>action</code> (function), <code>html</code> (string), and <code>render</code> (function). If <code>html</code> is present, it overrides the icon and is rendered in its place. If <code>render</code> is present, it is used to render the control.</li>
160
+ <li><code>pageSize</code>: The number of records to display per page.</li>
161
+ <li><code>pageSizeOptions</code>: An array of numbers representing the available page size options.</li>
162
+ </ul>
163
+
164
+ <h3 id="requirements"><a href="#requirements" class="no-link">Requirements</a></h3>
165
+ <ul>
166
+ <li><a href="../utils/string.html"><code>toTitleCase</code> <i>from string.js</i></a></li>
167
+ </ul>
168
+
169
+ <h3 id="properties"><a href="#properties" class="no-link">Properties</a></h3>
170
+ <h5><code>fields<i>: &lt;Array>object</i></code></h5>
171
+ <p>An array of objects containing a <code>name</code>, <code>label</code>, <code>renderer</code> function, and <code>calculator</code> function that represent the fields to be displayed. The <code>renderer</code> function can be used to customize the display of the field, and the <code>calculator</code> function can be used to calculate the value of the field based on other fields in the record.</p>
172
+
173
+ <h5><code>records<i>: &lt;Array>object</i></code></h5>
174
+ <p>An array of objects containing the data that will be the records of the table, where the object keys match the field names.</p>
175
+
176
+ <h5><code>controls<i>: object</i></code></h5>
177
+ <p>An object containing optional arrays of controls to be displayed before and/or after each row, or above and below the table. Each control is defined by an icon name, a callback function, and optionally an HTML string or a render function. The <code>controls</code> object can contain the optional <code>before</code>, <code>after</code>, <code>top</code>, and <code>bottom</code> properties, which are arrays of objects containing the <code>icon</code> (string), <code>action</code> (function), <code>html</code> (string), and <code>render</code> (function). If <code>html</code> is present, it overrides the icon and is rendered in its place. If <code>render</code> is present, it is used to render the control. Controls in the <code>before</code> or <code>after</code> arrays receive the record and index as the 2nd and 3rd parameters in the action function and the renderer function.</p>
178
+
179
+ <h5><code>pageSize<i>: number</i></code></h5>
180
+ <p>The number of records to display per page.</p>
181
+
182
+ <h5><code>pageSizeOptions<i>: &lt;Array>number</i></code></h5>
183
+ <p>An array of numbers representing the available page size options.</p>
184
+
185
+ <h3 id="methods"><a href="#methods" class="no-link">Methods</a></h3>
186
+
187
+ <h5><code>setData(<i>object</i> options)<i>: undefined</i></code></h5>
188
+ <p>Sets the records and the fields and renders the table. If no fields are provided, they will be automatically generated from the keys of the first 100 records. The options object can contain the following properties:</p>
189
+ <ul>
190
+ <li><code>records</code>: An array of objects representing the records to be shown in the table.</li>
191
+ <li><code>fields</code>: An array of objects representing the fields of the table, each object must contain a <code>name</code> and a <code>label</code>. If this property is omitted, the fields will be automatically generated from the first 100 records.</li>
192
+ <li><code>filters</code>: An array of filter objects to apply to the records.</li>
193
+ <li><code>pageSize</code>: The number of records to display per page.</li>
194
+ <li><code>pageSizeOptions</code>: An array of numbers representing the available page size options.</li>
195
+ <li><code>currentPage</code>: The current page to display.</li>
196
+ <li><code>enableSelection</code>: A boolean to enable or disable record selection.</li>
197
+ <li><code>enablePages</code>: A boolean to enable or disable pagination.</li>
198
+ </ul>
199
+
200
+ <h5><code>renderFields()<i>: undefined</i></code></h5>
201
+ <p>Renders the fields as table headers. This is called automatically by setData, you should never have to call it.</p>
202
+
203
+ <h5><code>renderRecords()<i>: undefined</i></code></h5>
204
+ <p>Renders the records as table rows. This is called automatically by setData, you should never have to call it.</p>
205
+
206
+ <h5><code>addRecord(<i>object</i> record)<i>: undefined</i></code></h5>
207
+ <p>Adds a new record to the table.</p>
208
+
209
+ <h5><code>updateRecord(<i>object</i> record, <i>object</i> newData)<i>: undefined</i></code></h5>
210
+ <p>Updates an existing record with new data.</p>
211
+
212
+ <h5><code>deleteRecord(<i>object</i> record)<i>: undefined</i></code></h5>
213
+ <p>Deletes a record from the table.</p>
214
+
215
+ <h5><code>setRecords(<i>Array</i> records)<i>: undefined</i></code></h5>
216
+ <p>Sets the records for the table and re-renders the rows.</p>
217
+
218
+ <h5><code>setPageSize(<i>number</i> pageSize)<i>: undefined</i></code></h5>
219
+ <p>Sets the number of records to display per page.</p>
220
+
221
+ <h5><code>setPage(<i>number</i> page)<i>: undefined</i></code></h5>
222
+ <p>Sets the current page to display.</p>
223
+
224
+ <h5><code>nextPage()<i>: undefined</i></code></h5>
225
+ <p>Moves to the next page.</p>
226
+
227
+ <h5><code>prevPage()<i>: undefined</i></code></h5>
228
+ <p>Moves to the previous page.</p>
229
+
230
+ <h5><code>getCurrentPage()<i>: number</i></code></h5>
231
+ <p>Returns the current page number.</p>
232
+
233
+ <h5><code>getTotalPages()<i>: number</i></code></h5>
234
+ <p>Returns the total number of pages.</p>
235
+
236
+ <h5><code>getSelectedRecords()<i>: Array</i></code></h5>
237
+ <p>Returns an array of the currently selected records.</p>
238
+
239
+ <h5><code>deleteSelected()<i>: undefined</i></code></h5>
240
+ <p>Deletes all currently selected records from the table.</p>
241
+
242
+ <h5><code>selectAllOnPage()<i>: undefined</i></code></h5>
243
+ <p>Selects all the records on the current page.</p>
244
+
245
+ <h5><code>deselectAllOnPage()<i>: undefined</i></code></h5>
246
+ <p>Deselects all the records on the current page.</p>
247
+
248
+ <h5><code>allOnPageSelected()<i>: boolean</i></code></h5>
249
+ <p>Returns <code>true</code> if all the records on the current page are selected, and <code>false</code> if they are not.</p>
250
+
251
+ <h5><code>editRecord(<i>object</i> record)<i>: undefined</i></code></h5>
252
+ <p>Enables editing mode for a record.</p>
253
+
254
+ <h5><code>saveEditedRecord(<i>object</i> record)<i>: undefined</i></code></h5>
255
+ <p>Saves the changes made to an edited record.</p>
256
+
257
+ <h5><code>cancelEditedRecord(<i>object</i> record)<i>: undefined</i></code></h5>
258
+ <p>Cancels the editing mode for a record.</p>
259
+
260
+ <h5><code>recordIsEditing(<i>object</i> record)<i>: boolean</i></code></h5>
261
+ <p>Returns <code>true</code> if the record is in editing mode, and <code>false</code> if it is not.</p>
262
+
263
+ <h5><code>hideRecord(<i>object</i> record)<i>: undefined</i></code></h5>
264
+ <p>Hides a record from the table.</p>
265
+
266
+ <h5><code>showRecord(<i>object</i> record)<i>: undefined</i></code></h5>
267
+ <p>Shows a hidden record in the table.</p>
268
+
269
+ <h5><code>showAllRecords()<i>: undefined</i></code></h5>
270
+ <p>Shows all hidden records in the table.</p>
271
+
272
+ <h5><code>addFilter(<i>string</i> field, <i>string</i> condition, <i>any</i> value)<i>: undefined</i></code></h5>
273
+ <p>Adds a filter to the table.</p>
274
+
275
+ <h5><code>removeFilter(<i>string</i> field, <i>string</i> condition, <i>any</i> value)<i>: undefined</i></code></h5>
276
+ <p>Removes a filter from the table.</p>
277
+
278
+ <h5><code>removeAllFilters()<i>: undefined</i></code></h5>
279
+ <p>Removes all filters from the table.</p>
280
+
281
+ <h5><code>search(<i>string</i> term)<i>: undefined</i></code></h5>
282
+ <p>Searches the records for the specified term.</p>
283
+
284
+ <h5><code>getDisplayedRecords()<i>: Array</i></code></h5>
285
+ <p>Returns an array of the records currently displayed in the table.</p>
286
+
287
+ <h5><code>getHiddenRecords()<i>: Array</i></code></h5>
288
+ <p>Returns an array of the hidden records in the table.</p>
289
+
290
+ <h5><code>setupFetchRecords(<i>number</i> totalRecords, <i>function</i> callback)<i>: undefined</i></code></h5>
291
+ <p>Sets up the table to fetch records dynamically.</p>
292
+
293
+ <h5><code>sortBy(<i>string</i> field, <i>boolean</i> asc)<i>: undefined</i></code></h5>
294
+ <p>Sorts the records by the specified field in ascending or descending order.</p>
295
+
296
+ <h5><code>setFieldHiddenState(<i>string</i> fieldName, <i>boolean</i> hidden)<i>: undefined</i></code></h5>
297
+ <p>Sets the hidden state of a field.</p>
298
+
299
+ <h5><code>hideField(<i>string</i> fieldName)<i>: undefined</i></code></h5>
300
+ <p>Hides a field in the table.</p>
301
+
302
+ <h5><code>showField(<i>string</i> fieldName)<i>: undefined</i></code></h5>
303
+ <p>Shows a hidden field in the table.</p>
304
+
305
+ <h5><code>reorderFields(<i>Array</i> newOrder)<i>: undefined</i></code></h5>
306
+ <p>Reorders the fields in the table based on the new order array.</p>
307
+
308
+ </main>
309
+ <div style="height: 33.333vh"></div>
310
+ <script type="module" src="../src/components/Import.js"></script>
311
+ </body>
312
+ </html>
@@ -0,0 +1,77 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Top and Bottom Controls - Table - Kempo Docs</title>
7
+ <link rel="stylesheet" href="../src/kempo-vars.css" />
8
+ <link rel="stylesheet" href="../kempo.min.css" />
9
+ <link rel="stylesheet" href="../src/kempo-hljs.css" />`n <link rel="stylesheet" href="../styles.css" />
10
+ <script type="module" src="../src/components/Table.js"></script>
11
+ <script type="module">
12
+ import Import from '../src/components/Import.js';
13
+ import Icon from '../src/components/Icon.js';
14
+ Import.replacements.root = '../';
15
+ Icon.pathToIcons = ['../icons'];
16
+ </script>
17
+ <script>
18
+ window.contacts = [];
19
+ function generateContact(){
20
+ const maleNames = [
21
+ "Liam", "Noah", "Oliver", "Elijah", "William", "James", "Benjamin",
22
+ "Lucas", "Henry", "Alexander", "Mason", "Michael", "Ethan", "Daniel",
23
+ "Jacob", "Logan", "Jackson", "Levi", "Sebastian", "Mateo", "Jack",
24
+ "Owen", "Theodore", "Aiden", "Samuel", "Joseph", "John", "David",
25
+ "Wyatt", "Matthew"
26
+ ];
27
+ const femaleNames = [
28
+ "Olivia", "Emma", "Ava", "Sophia", "Isabella", "Mia", "Amelia",
29
+ "Harper", "Evelyn", "Abigail", "Emily", "Ella", "Elizabeth",
30
+ "Camila", "Luna", "Sofia", "Avery", "Mila", "Aria", "Scarlett",
31
+ "Penelope", "Layla", "Chloe", "Victoria", "Madison", "Eleanor",
32
+ "Grace", "Nora", "Riley", "Zoey"
33
+ ];
34
+ const lastNames = [
35
+ "Smith", "Johnson", "Williams", "Brown", "Jones", "Garcia", "Miller",
36
+ "Davis", "Rodriguez", "Martinez", "Hernandez", "Lopez", "Gonzalez",
37
+ "Wilson", "Anderson", "Thomas", "Taylor", "Moore", "Jackson", "Martin",
38
+ "Lee", "Perez", "Thompson", "White", "Harris", "Sanchez", "Clark",
39
+ "Ramirez", "Lewis", "Robinson"
40
+ ];
41
+ const gender = Math.random() > 0.5 ? 'm' : 'f';
42
+ const firstName = gender === 'm' ? maleNames[Math.floor(Math.random() * maleNames.length)] : femaleNames[Math.floor(Math.random() * femaleNames.length)];
43
+ const lastName = lastNames[Math.floor(Math.random() * lastNames.length)];
44
+ const name = `${firstName} ${lastName}`;
45
+ const email = `${firstName.toLowerCase()}.${lastName.toLowerCase()}@mailserver.com`;
46
+ const birthday = `${Math.floor(Math.random() * 100) + 1920}-${String(Math.floor(Math.random() * 12) + 1).padStart(2, '0')}-${String(Math.floor(Math.random() * 28) + 1).padStart(2, '0')}`;
47
+ const phoneNumber = `(${Math.floor(Math.random() * 900) + 100}) ${Math.floor(Math.random() * 900) + 100}-${Math.floor(Math.random() * 9000) + 1000}`;
48
+ return { name, email, birthday, phoneNumber, gender };
49
+ }
50
+ for (let i = 0; i < 10; i++) {
51
+ contacts.push(generateContact());
52
+ };
53
+ </script>
54
+ </head>
55
+ <body>
56
+ <k-import src="../nav.inc.html"></k-import>
57
+ <h1 class="ta-center">Table - Top and Bottom Controls</h1>
58
+ <main>
59
+
60
+ <a href="./table.html"><h5>Back to Table Component Documentation</h5></a>
61
+
62
+ <p>The table component supports controls at both the top and bottom. These controls can handle pagination, adding new records, or other actions. They are web components that interact with their parent <code>k-table</code> by accessing its methods and listening for its events.</p>
63
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-table</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"topBottomControlsExample"</span>&gt;</span><br /> <span class="hljs-tag">&lt;<span class="hljs-name">k-tc-export-json</span> <span class="hljs-attr">slot</span>=<span class="hljs-string">"top"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">k-tc-export-json</span>&gt;</span><br /> <span class="hljs-tag">&lt;<span class="hljs-name">k-tc-export-csv</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">k-tc-export-csv</span>&gt;</span><br /><span class="hljs-tag">&lt;/<span class="hljs-name">k-table</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> <span class="hljs-attr">src</span>=<span class="hljs-string">"../src/components/tableControls/ExportJson.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</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> <span class="hljs-attr">src</span>=<span class="hljs-string">"../src/components/tableControls/ExportCsv.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</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-built_in">document</span>.getElementById(<span class="hljs-string">'topBottomControlsExample'</span>).setRecords(contacts);<br /></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre>
64
+ <k-table id="topBottomControlsExample">
65
+ <k-tc-export-json slot="top"></k-tc-export-json>
66
+ <k-tc-export-csv></k-tc-export-csv>
67
+ </k-table>
68
+ <script type="module" src="../src/components/tableControls/ExportJson.js"></script>
69
+ <script type="module" src="../src/components/tableControls/ExportCsv.js"></script>
70
+ <script type="module">
71
+ document.getElementById('topBottomControlsExample').setRecords(contacts);
72
+ </script>
73
+ </main>
74
+ <div style="height: 33.333vh"></div>
75
+ <script type="module" src="../src/components/Import.js"></script>
76
+ </body>
77
+ </html>
@@ -0,0 +1,113 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Custom Fields - Table - Kempo Docs</title>
7
+ <link rel="stylesheet" href="../src/kempo-vars.css" />
8
+ <link rel="stylesheet" href="../kempo.min.css" />
9
+ <link rel="stylesheet" href="../src/kempo-hljs.css" />`n <link rel="stylesheet" href="../styles.css" />
10
+ <script type="module" src="../src/components/Table.js"></script>
11
+ <script type="module">
12
+ import Import from '../src/components/Import.js';
13
+ import Icon from '../src/components/Icon.js';
14
+ Import.replacements.root = '../';
15
+ Icon.pathToIcons = ['../icons'];
16
+ </script>
17
+ <script>
18
+ window.contacts = [];
19
+ function generateContact(){
20
+ const maleNames = [
21
+ "Liam", "Noah", "Oliver", "Elijah", "William", "James", "Benjamin",
22
+ "Lucas", "Henry", "Alexander", "Mason", "Michael", "Ethan", "Daniel",
23
+ "Jacob", "Logan", "Jackson", "Levi", "Sebastian", "Mateo", "Jack",
24
+ "Owen", "Theodore", "Aiden", "Samuel", "Joseph", "John", "David",
25
+ "Wyatt", "Matthew"
26
+ ];
27
+ const femaleNames = [
28
+ "Olivia", "Emma", "Ava", "Sophia", "Isabella", "Mia", "Amelia",
29
+ "Harper", "Evelyn", "Abigail", "Emily", "Ella", "Elizabeth",
30
+ "Camila", "Luna", "Sofia", "Avery", "Mila", "Aria", "Scarlett",
31
+ "Penelope", "Layla", "Chloe", "Victoria", "Madison", "Eleanor",
32
+ "Grace", "Nora", "Riley", "Zoey"
33
+ ];
34
+ const lastNames = [
35
+ "Smith", "Johnson", "Williams", "Brown", "Jones", "Garcia", "Miller",
36
+ "Davis", "Rodriguez", "Martinez", "Hernandez", "Lopez", "Gonzalez",
37
+ "Wilson", "Anderson", "Thomas", "Taylor", "Moore", "Jackson", "Martin",
38
+ "Lee", "Perez", "Thompson", "White", "Harris", "Sanchez", "Clark",
39
+ "Ramirez", "Lewis", "Robinson"
40
+ ];
41
+ const gender = Math.random() > 0.5 ? 'm' : 'f';
42
+ const firstName = gender === 'm' ? maleNames[Math.floor(Math.random() * maleNames.length)] : femaleNames[Math.floor(Math.random() * femaleNames.length)];
43
+ const lastName = lastNames[Math.floor(Math.random() * lastNames.length)];
44
+ const name = `${firstName} ${lastName}`;
45
+ const email = `${firstName.toLowerCase()}.${lastName.toLowerCase()}@mailserver.com`;
46
+ const birthday = `${Math.floor(Math.random() * 100) + 1920}-${String(Math.floor(Math.random() * 12) + 1).padStart(2, '0')}-${String(Math.floor(Math.random() * 28) + 1).padStart(2, '0')}`;
47
+ const phoneNumber = `(${Math.floor(Math.random() * 900) + 100}) ${Math.floor(Math.random() * 900) + 100}-${Math.floor(Math.random() * 9000) + 1000}`;
48
+ return { name, email, birthday, phoneNumber, gender };
49
+ }
50
+ for (let i = 0; i < 10; i++) {
51
+ contacts.push(generateContact());
52
+ };
53
+ </script>
54
+ </head>
55
+ <body>
56
+ <k-import src="../nav.inc.html"></k-import>
57
+ <h1 class="ta-center">Table - Custom Fields</h1>
58
+ <main>
59
+
60
+ <a href="./table.html"><h5>Back to Table Component Documentation</h5></a>
61
+
62
+ <p>Use the <code>fields</code> property of the options object in <code>setData</code> to define custom fields. This is useful for hiding fields, reordering fields, changing the labels, formatting the output, or creating a calculated field.</p>
63
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-table</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"customFieldsExample"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">k-table</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-built_in">document</span>.getElementById(<span class="hljs-string">'customFieldsExample'</span>).setData({<br /> <span class="hljs-attr">records</span>: contacts,<br /> <span class="hljs-attr">fields</span>: [<br /> {<br /> <span class="hljs-attr">name</span>: <span class="hljs-string">"name"</span>,<br /> <span class="hljs-attr">label</span>: <span class="hljs-string">"Name"</span><br /> },<br /> {<br /> <span class="hljs-attr">name</span>: <span class="hljs-string">'phoneNumber'</span>,<br /> <span class="hljs-attr">label</span>: <span class="hljs-string">'Phone Number'</span><br /> },<br /> {<br /> <span class="hljs-attr">name</span>: <span class="hljs-string">'email'</span>,<br /> <span class="hljs-attr">label</span>: <span class="hljs-string">'Email Address'</span><br /> },<br /> {<br /> <span class="hljs-attr">name</span>: <span class="hljs-string">'birthday'</span>,<br /> <span class="hljs-attr">label</span>: <span class="hljs-string">'Birthday'</span><br /> },<br /> {<br /> <span class="hljs-attr">name</span>: <span class="hljs-string">'age'</span>,<br /> <span class="hljs-attr">label</span>: <span class="hljs-string">'Age'</span>,<br /> <span class="hljs-attr">calculator</span>: <span class="hljs-function">(<span class="hljs-params">record</span>) =&gt;</span> {<br /> <span class="hljs-comment">// record.birthday is a string in the format "YYYY-MM-DD"</span><br /> <span class="hljs-keyword">const</span> today = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>();<br /> <span class="hljs-keyword">const</span> birthDate = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(record.birthday);<br /> <span class="hljs-keyword">let</span> age = today.getFullYear() - birthDate.getFullYear();<br /> <span class="hljs-keyword">const</span> monthDifference = today.getMonth() - birthDate.getMonth();<br /> <span class="hljs-keyword">if</span> (monthDifference &lt; <span class="hljs-number">0</span> || (monthDifference === <span class="hljs-number">0</span> &amp;&amp; today.getDate() &lt; birthDate.getDate())) {<br /> age--;<br /> }<br /> <span class="hljs-keyword">return</span> age;<br /> }<br /> },<br /> {<br /> <span class="hljs-attr">name</span>: <span class="hljs-string">'gender'</span>,<br /> <span class="hljs-attr">label</span>: <span class="hljs-string">'Gender'</span>,<br /> <span class="hljs-attr">formatter</span>: <span class="hljs-function">(<span class="hljs-params">v</span>) =&gt;</span> v===<span class="hljs-string">'m'</span>?<span class="hljs-string">'Male'</span>:<span class="hljs-string">'Female'</span> <span class="hljs-comment">// original value is "m" or "f"</span><br /> }<br /> ]<br /> });<br /></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre>
64
+ <k-table id="customFieldsExample"></k-table>
65
+ <script type="module">
66
+ document.getElementById('customFieldsExample').setData({
67
+ records: contacts,
68
+ fields: [
69
+ {
70
+ name: "name",
71
+ label: "Name",
72
+ size: 300
73
+ },
74
+ {
75
+ name: 'phoneNumber',
76
+ label: 'Phone Number'
77
+ },
78
+ {
79
+ name: 'email',
80
+ label: 'Email Address'
81
+ },
82
+ {
83
+ name: 'birthday',
84
+ label: 'Birthday'
85
+ },
86
+ {
87
+ name: 'age',
88
+ label: 'Age',
89
+ calculator: (record) => {
90
+ // record.birthday is a string in the format "YYYY-MM-DD"
91
+ const today = new Date();
92
+ const birthDate = new Date(record.birthday);
93
+ let age = today.getFullYear() - birthDate.getFullYear();
94
+ const monthDifference = today.getMonth() - birthDate.getMonth();
95
+ if (monthDifference < 0 || (monthDifference === 0 && today.getDate() < birthDate.getDate())) {
96
+ age--;
97
+ }
98
+ return age;
99
+ }
100
+ },
101
+ {
102
+ name: 'gender',
103
+ label: 'Gender',
104
+ formatter: (v) => v==='m'?'Male':'Female' // original value is "m" or "f"
105
+ }
106
+ ]
107
+ });
108
+ </script>
109
+ </main>
110
+ <div style="height: 33.333vh"></div>
111
+ <script type="module" src="../src/components/Import.js"></script>
112
+ </body>
113
+ </html>