kempo-ui 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -1
- package/docs/components/accordion.html +240 -8
- package/docs/components/aside-items.html +13 -9
- package/docs/components/aside-menu.html +13 -9
- package/docs/components/aside-push.html +11 -6
- package/docs/components/aside.html +239 -8
- package/docs/components/card.html +238 -7
- package/docs/components/color-picker.html +245 -14
- package/docs/components/content-slider.html +240 -8
- package/docs/components/context.html +241 -7
- package/docs/components/dialog.html +238 -7
- package/docs/components/dropdown.html +238 -7
- package/docs/components/filter-list.html +239 -10
- package/docs/components/focus-capture.html +241 -10
- package/docs/components/html-editor.html +266 -35
- package/docs/components/hybrid-component.html +238 -6
- package/docs/components/icon.html +239 -9
- package/docs/components/import.html +239 -8
- package/docs/components/light-component.html +239 -7
- package/docs/components/nav.html +240 -8
- package/docs/components/photo-viewer.html +239 -9
- package/docs/components/resize.html +240 -9
- package/docs/components/shadow-component.html +239 -7
- package/docs/components/show-more.html +237 -8
- package/docs/components/sortable.html +239 -8
- package/docs/components/spinner.html +237 -6
- package/docs/components/split.html +241 -10
- package/docs/components/table.html +241 -11
- package/docs/components/tableControls.html +240 -7
- package/docs/components/tableCustomFields.html +241 -8
- package/docs/components/tableFetchRecords.html +239 -7
- package/docs/components/tableFieldSortHide.html +239 -7
- package/docs/components/tablePagination.html +246 -13
- package/docs/components/tablePlaceholder.html +241 -8
- package/docs/components/tableRecordEditing.html +241 -8
- package/docs/components/tableRecordFiltering.html +239 -7
- package/docs/components/tableRecordHiding.html +241 -9
- package/docs/components/tableRecordSearching.html +239 -7
- package/docs/components/tableRecordSelection.html +240 -7
- package/docs/components/tableRowControls.html +241 -8
- package/docs/components/tableServerSync.html +245 -11
- package/docs/components/tableSorting.html +239 -7
- package/docs/components/tabs.html +240 -7
- package/docs/components/tags.html +239 -7
- package/docs/components/theme-select.html +239 -7
- package/docs/components/theme-switcher.html +240 -8
- package/docs/components/timestamp.html +239 -8
- package/docs/components/toast.html +240 -8
- package/docs/components/toggle.html +240 -9
- package/docs/components/tree.html +239 -8
- package/docs/index.html +244 -6
- package/docs/prod.config.json +0 -4
- package/docs/utils/context.html +237 -6
- package/docs/utils/cookie.html +251 -21
- package/docs/utils/debounce.html +236 -5
- package/docs/utils/drag.html +236 -5
- package/docs/utils/elevation.html +238 -6
- package/docs/utils/formatTimestamp.html +233 -3
- package/docs/utils/object.html +236 -5
- package/docs/utils/propConverters.html +233 -3
- package/docs/utils/string.html +236 -5
- package/docs/utils/theme.html +237 -6
- package/docs/utils/toTitleCase.html +233 -3
- package/docs/utils/type.html +236 -5
- package/docs/utils/wait.html +236 -5
- package/docs-src/.config.js +16 -0
- package/docs-src/bare.template.html +16 -0
- package/docs-src/components/accordion.page.html +201 -0
- package/docs-src/components/aside-items.page.html +36 -0
- package/docs-src/components/aside-menu.page.html +36 -0
- package/docs-src/components/aside-push.page.html +20 -0
- package/docs-src/components/aside.page.html +551 -0
- package/docs-src/components/card.page.html +78 -0
- package/docs-src/components/color-picker.page.html +559 -0
- package/docs-src/components/content-slider.page.html +266 -0
- package/docs-src/components/context.page.html +214 -0
- package/docs-src/components/dialog.page.html +365 -0
- package/docs-src/components/dropdown.page.html +300 -0
- package/docs-src/components/filter-list.page.html +117 -0
- package/docs-src/components/focus-capture.page.html +97 -0
- package/docs-src/components/html-editor.page.html +423 -0
- package/docs-src/components/hybrid-component.page.html +96 -0
- package/docs-src/components/icon.page.html +208 -0
- package/docs-src/components/import.page.html +76 -0
- package/docs-src/components/light-component.page.html +99 -0
- package/docs-src/components/nav.page.html +106 -0
- package/docs-src/components/photo-viewer.page.html +253 -0
- package/docs-src/components/resize.page.html +161 -0
- package/docs-src/components/shadow-component.page.html +84 -0
- package/docs-src/components/show-more.page.html +113 -0
- package/docs-src/components/sortable.page.html +117 -0
- package/docs-src/components/spinner.page.html +197 -0
- package/docs-src/components/split.page.html +195 -0
- package/docs-src/components/table.page.html +283 -0
- package/docs-src/components/tableControls.page.html +64 -0
- package/docs-src/components/tableCustomFields.page.html +124 -0
- package/docs-src/components/tableFetchRecords.page.html +95 -0
- package/docs-src/components/tableFieldSortHide.page.html +56 -0
- package/docs-src/components/tablePagination.page.html +85 -0
- package/docs-src/components/tablePlaceholder.page.html +73 -0
- package/docs-src/components/tableRecordEditing.page.html +161 -0
- package/docs-src/components/tableRecordFiltering.page.html +69 -0
- package/docs-src/components/tableRecordHiding.page.html +65 -0
- package/docs-src/components/tableRecordSearching.page.html +56 -0
- package/docs-src/components/tableRecordSelection.page.html +60 -0
- package/docs-src/components/tableRowControls.page.html +62 -0
- package/docs-src/components/tableServerSync.page.html +129 -0
- package/docs-src/components/tableSorting.page.html +54 -0
- package/docs-src/components/tabs.page.html +201 -0
- package/docs-src/components/tags.page.html +157 -0
- package/docs-src/components/theme-select.page.html +106 -0
- package/docs-src/components/theme-switcher.page.html +122 -0
- package/docs-src/components/timestamp.page.html +109 -0
- package/docs-src/components/toast.page.html +338 -0
- package/docs-src/components/toggle.page.html +177 -0
- package/docs-src/components/tree.page.html +356 -0
- package/docs-src/default.template.html +28 -0
- package/docs-src/index.page.html +312 -0
- package/docs-src/nav.fragment.html +228 -0
- package/docs-src/utils/context.page.html +143 -0
- package/docs-src/utils/cookie.page.html +128 -0
- package/docs-src/utils/debounce.page.html +42 -0
- package/docs-src/utils/drag.page.html +64 -0
- package/docs-src/utils/elevation.page.html +144 -0
- package/docs-src/utils/formatTimestamp.page.html +76 -0
- package/docs-src/utils/object.page.html +76 -0
- package/docs-src/utils/propConverters.page.html +73 -0
- package/docs-src/utils/string.page.html +66 -0
- package/docs-src/utils/theme.page.html +136 -0
- package/docs-src/utils/toTitleCase.page.html +52 -0
- package/docs-src/utils/type.page.html +31 -0
- package/docs-src/utils/wait.page.html +31 -0
- package/package.json +4 -4
- package/scripts/build.js +5 -0
- package/scripts/docs.js +5 -52
- package/docs/dev.config.json +0 -20
- package/docs/nav-1.inc.html +0 -168
- package/docs/nav.inc.html +0 -168
- package/docs/nav.inc.js +0 -70
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<page pageName="Table - Server Sync" title="Server Sync - Table - Kempo Docs - A Web Components Solution">
|
|
2
|
+
<content location="head">
|
|
3
|
+
<script>
|
|
4
|
+
window.contacts = [];
|
|
5
|
+
function generateContact(){
|
|
6
|
+
const maleNames = [
|
|
7
|
+
"Liam", "Noah", "Oliver", "Elijah", "William", "James", "Benjamin",
|
|
8
|
+
"Lucas", "Henry", "Alexander", "Mason", "Michael", "Ethan", "Daniel",
|
|
9
|
+
"Jacob", "Logan", "Jackson", "Levi", "Sebastian", "Mateo", "Jack",
|
|
10
|
+
"Owen", "Theodore", "Aiden", "Samuel", "Joseph", "John", "David",
|
|
11
|
+
"Wyatt", "Matthew"
|
|
12
|
+
];
|
|
13
|
+
const femaleNames = [
|
|
14
|
+
"Olivia", "Emma", "Ava", "Sophia", "Isabella", "Mia", "Amelia",
|
|
15
|
+
"Harper", "Evelyn", "Abigail", "Emily", "Ella", "Elizabeth",
|
|
16
|
+
"Camila", "Luna", "Sofia", "Avery", "Mila", "Aria", "Scarlett",
|
|
17
|
+
"Penelope", "Layla", "Chloe", "Victoria", "Madison", "Eleanor",
|
|
18
|
+
"Grace", "Nora", "Riley", "Zoey"
|
|
19
|
+
];
|
|
20
|
+
const lastNames = [
|
|
21
|
+
"Smith", "Johnson", "Williams", "Brown", "Jones", "Garcia", "Miller",
|
|
22
|
+
"Davis", "Rodriguez", "Martinez", "Hernandez", "Lopez", "Gonzalez",
|
|
23
|
+
"Wilson", "Anderson", "Thomas", "Taylor", "Moore", "Jackson", "Martin",
|
|
24
|
+
"Lee", "Perez", "Thompson", "White", "Harris", "Sanchez", "Clark",
|
|
25
|
+
"Ramirez", "Lewis", "Robinson"
|
|
26
|
+
];
|
|
27
|
+
const gender = Math.random() > 0.5 ? 'm' : 'f';
|
|
28
|
+
const firstName = gender === 'm' ? maleNames[Math.floor(Math.random() * maleNames.length)] : femaleNames[Math.floor(Math.random() * femaleNames.length)];
|
|
29
|
+
const lastName = lastNames[Math.floor(Math.random() * lastNames.length)];
|
|
30
|
+
const name = `${firstName} ${lastName}`;
|
|
31
|
+
const email = `${firstName.toLowerCase()}.${lastName.toLowerCase()}@mailserver.com`;
|
|
32
|
+
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')}`;
|
|
33
|
+
const phoneNumber = `(${Math.floor(Math.random() * 900) + 100}) ${Math.floor(Math.random() * 900) + 100}-${Math.floor(Math.random() * 9000) + 1000}`;
|
|
34
|
+
return { name, email, birthday, phoneNumber, gender };
|
|
35
|
+
}
|
|
36
|
+
for(let i = 0; i < 10; i++){
|
|
37
|
+
contacts.push(generateContact());
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
</content>
|
|
41
|
+
<content>
|
|
42
|
+
|
|
43
|
+
<a href="./table.html"><h5>Back to Table Component Documentation</h5></a>
|
|
44
|
+
|
|
45
|
+
<p>
|
|
46
|
+
The table supports an optional server-sync workflow for saving edits and deleting records. When the
|
|
47
|
+
<code>request-edit</code> attribute is present, calling <code>saveEditedRecord()</code> fires a
|
|
48
|
+
<code>requestSave</code> event instead of applying the changes immediately. When the <code>request-delete</code>
|
|
49
|
+
attribute is present, calling <code>deleteRecord()</code> or <code>deleteSelected()</code> fires a
|
|
50
|
+
<code>requestDelete</code> event instead of deleting immediately.
|
|
51
|
+
</p>
|
|
52
|
+
<p>
|
|
53
|
+
Both events expose an <code>approve()</code> function on <code>event.detail</code>. Call it once the server
|
|
54
|
+
operation succeeds to commit the change. If the operation fails, simply do not call <code>approve()</code> —
|
|
55
|
+
the record stays in its current state so the user can retry. <code>requestSave</code> also provides
|
|
56
|
+
<code>event.detail.record</code> (the original record) and <code>event.detail.newData</code> (the values
|
|
57
|
+
read from the editor inputs). <code>requestDelete</code> provides <code>event.detail.records</code>, an
|
|
58
|
+
array of the records targeted for deletion.
|
|
59
|
+
</p>
|
|
60
|
+
<p>
|
|
61
|
+
The example below mocks a server call that takes 1–3 seconds and randomly fails 50% of the time.
|
|
62
|
+
Toasts are used to notify the user of success or failure.
|
|
63
|
+
</p>
|
|
64
|
+
|
|
65
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-table</span> <span class="hljs-attr">id</span>=<span class="hljs-string">serverSyncExample</span> <span class="hljs-attr">enable-selection</span> <span class="hljs-attr">request-edit</span> <span class="hljs-attr">request-delete</span>></span><span class="hljs-tag"><<span class="hljs-name">k-tc-edit</span> <span class="hljs-attr">slot</span>=<span class="hljs-string">after</span>></span><span class="hljs-tag"></<span class="hljs-name">k-tc-edit</span>></span><span class="hljs-tag"><<span class="hljs-name">k-tc-delete-record</span> <span class="hljs-attr">slot</span>=<span class="hljs-string">after</span>></span><span class="hljs-tag"></<span class="hljs-name">k-tc-delete-record</span>></span><span class="hljs-tag"><<span class="hljs-name">k-tc-delete-selected</span> <span class="hljs-attr">slot</span>=<span class="hljs-string">top</span>></span><span class="hljs-tag"></<span class="hljs-name">k-tc-delete-selected</span>></span><span class="hljs-tag"></<span class="hljs-name">k-table</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="language-javascript"><br> <span class="hljs-keyword">import</span> <span class="hljs-title class_">Toast</span> <span class="hljs-keyword">from</span> <span class="hljs-string">'/src/components/Toast.js'</span>;<br> <span class="hljs-keyword">await</span> <span class="hljs-variable language_">window</span>.<span class="hljs-property">customElements</span>.<span class="hljs-title function_">whenDefined</span>(<span class="hljs-string">'k-table'</span>);<br> <span class="hljs-keyword">const</span> table = <span class="hljs-variable language_">document</span>.<span class="hljs-title function_">getElementById</span>(<span class="hljs-string">'serverSyncExample'</span>);<br> <span class="hljs-keyword">const</span> <span class="hljs-title function_">mockServer</span> = (<span class="hljs-params"></span>) => <span class="hljs-keyword">new</span> <span class="hljs-title class_">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>) =></span> {<br> <span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =></span> {<br> <span class="hljs-title class_">Math</span>.<span class="hljs-title function_">random</span>() < <span class="hljs-number">0.8</span> ? <span class="hljs-title function_">resolve</span>() : <span class="hljs-title function_">reject</span>();<br> }, <span class="hljs-number">1000</span> + <span class="hljs-title class_">Math</span>.<span class="hljs-title function_">random</span>() * <span class="hljs-number">2000</span>);<br> });<br> table.<span class="hljs-title function_">setData</span>({<br> <span class="hljs-attr">records</span>: contacts,<br> <span class="hljs-attr">fields</span>: [{<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> <span class="hljs-attr">name</span>: <span class="hljs-string">'email'</span>,<br> <span class="hljs-attr">label</span>: <span class="hljs-string">'Email'</span><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> <span class="hljs-attr">type</span>: <span class="hljs-string">'date'</span><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> <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> =></span> v === <span class="hljs-string">'m'</span> ? <span class="hljs-string">'Male'</span> : <span class="hljs-string">'Female'</span><br> }]<br> });<br> table.<span class="hljs-title function_">addEventListener</span>(<span class="hljs-string">'requestSave'</span>, <span class="hljs-title function_">async</span> ({<br> <span class="hljs-attr">detail</span>: {<br> approve,<br> reject<br> }<br> }) => {<br> <span class="hljs-keyword">try</span> {<br> <span class="hljs-keyword">await</span> <span class="hljs-title function_">mockServer</span>();<br> <span class="hljs-title function_">approve</span>();<br> <span class="hljs-title class_">Toast</span>.<span class="hljs-title function_">success</span>(<span class="hljs-string">'Record saved.'</span>, {<br> <span class="hljs-attr">timeout</span>: <span class="hljs-number">3000</span><br> });<br> } <span class="hljs-keyword">catch</span> {<br> <span class="hljs-title function_">reject</span>();<br> <span class="hljs-title class_">Toast</span>.<span class="hljs-title function_">error</span>(<span class="hljs-string">'Save failed. The record remains open for editing.'</span>, {<br> <span class="hljs-attr">timeout</span>: <span class="hljs-number">5000</span><br> });<br> }<br> });<br> table.<span class="hljs-title function_">addEventListener</span>(<span class="hljs-string">'requestDelete'</span>, <span class="hljs-title function_">async</span> ({<br> <span class="hljs-attr">detail</span>: {<br> records,<br> approve,<br> reject<br> }<br> }) => {<br> <span class="hljs-keyword">const</span> count = records.<span class="hljs-property">length</span>;<br> <span class="hljs-keyword">try</span> {<br> <span class="hljs-keyword">await</span> <span class="hljs-title function_">mockServer</span>();<br> <span class="hljs-title function_">approve</span>();<br> <span class="hljs-title class_">Toast</span>.<span class="hljs-title function_">success</span>(count === <span class="hljs-number">1</span> ? <span class="hljs-string">'1 record deleted.'</span> : count + <span class="hljs-string">' records deleted.'</span>, {<br> <span class="hljs-attr">timeout</span>: <span class="hljs-number">3000</span><br> });<br> } <span class="hljs-keyword">catch</span> {<br> <span class="hljs-title function_">reject</span>();<br> <span class="hljs-title class_">Toast</span>.<span class="hljs-title function_">error</span>(<span class="hljs-string">'Delete failed. Please try again.'</span>, {<br> <span class="hljs-attr">timeout</span>: <span class="hljs-number">5000</span><br> });<br> }<br> });<br></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
66
|
+
<k-table
|
|
67
|
+
id="serverSyncExample"
|
|
68
|
+
enable-selection
|
|
69
|
+
request-edit
|
|
70
|
+
request-delete
|
|
71
|
+
>
|
|
72
|
+
<k-tc-edit slot="after"></k-tc-edit>
|
|
73
|
+
<k-tc-delete-record slot="after"></k-tc-delete-record>
|
|
74
|
+
<k-tc-delete-selected slot="top"></k-tc-delete-selected>
|
|
75
|
+
</k-table>
|
|
76
|
+
<script type="module">
|
|
77
|
+
import Toast from '{{pathToRoot}}src/components/Toast.js';
|
|
78
|
+
await window.customElements.whenDefined('k-table');
|
|
79
|
+
const table = document.getElementById('serverSyncExample');
|
|
80
|
+
|
|
81
|
+
const mockServer = () => new Promise((resolve, reject) => {
|
|
82
|
+
setTimeout(() => {
|
|
83
|
+
Math.random() < 0.8 ? resolve() : reject();
|
|
84
|
+
}, 1000 + Math.random() * 2000);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
table.setData({
|
|
88
|
+
records: contacts,
|
|
89
|
+
fields: [
|
|
90
|
+
{ name: 'name', label: 'Name' },
|
|
91
|
+
{ name: 'email', label: 'Email' },
|
|
92
|
+
{ name: 'birthday', label: 'Birthday', type: 'date' },
|
|
93
|
+
{ name: 'phoneNumber', label: 'Phone Number' },
|
|
94
|
+
{ name: 'gender', label: 'Gender', formatter: v => v === 'm' ? 'Male' : 'Female' }
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
table.addEventListener('requestSave', async ({ detail: { approve, reject } }) => {
|
|
99
|
+
try {
|
|
100
|
+
await mockServer();
|
|
101
|
+
approve();
|
|
102
|
+
Toast.success('Record saved.', { timeout: 3000 });
|
|
103
|
+
} catch {
|
|
104
|
+
reject();
|
|
105
|
+
Toast.error('Save failed. The record remains open for editing.', { timeout: 5000 });
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
table.addEventListener('requestDelete', async ({ detail: { records, approve, reject } }) => {
|
|
110
|
+
const count = records.length;
|
|
111
|
+
try {
|
|
112
|
+
await mockServer();
|
|
113
|
+
approve();
|
|
114
|
+
Toast.success(count === 1 ? '1 record deleted.' : count + ' records deleted.', { timeout: 3000 });
|
|
115
|
+
} catch {
|
|
116
|
+
reject();
|
|
117
|
+
Toast.error('Delete failed. Please try again.', { timeout: 5000 });
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
</script>
|
|
121
|
+
</content>
|
|
122
|
+
<content location="scripts">
|
|
123
|
+
<script type="module" src="{{pathToRoot}}src/components/Table.js"></script>
|
|
124
|
+
<script type="module" src="{{pathToRoot}}src/components/tableControls/Edit.js"></script>
|
|
125
|
+
<script type="module" src="{{pathToRoot}}src/components/tableControls/DeleteRecord.js"></script>
|
|
126
|
+
<script type="module" src="{{pathToRoot}}src/components/tableControls/DeleteSelected.js"></script>
|
|
127
|
+
<script type="module" src="{{pathToRoot}}src/components/Toast.js"></script>
|
|
128
|
+
</content>
|
|
129
|
+
</page>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<page pageName="Table - Sorting" title="Sorting - Table - Kempo Docs">
|
|
2
|
+
<content location="head">
|
|
3
|
+
<script type="module" src="{{pathToRoot}}src/components/Table.js"></script>
|
|
4
|
+
<script>
|
|
5
|
+
window.contacts = [];
|
|
6
|
+
function generateContact(){
|
|
7
|
+
const maleNames = [
|
|
8
|
+
"Liam", "Noah", "Oliver", "Elijah", "William", "James", "Benjamin",
|
|
9
|
+
"Lucas", "Henry", "Alexander", "Mason", "Michael", "Ethan", "Daniel",
|
|
10
|
+
"Jacob", "Logan", "Jackson", "Levi", "Sebastian", "Mateo", "Jack",
|
|
11
|
+
"Owen", "Theodore", "Aiden", "Samuel", "Joseph", "John", "David",
|
|
12
|
+
"Wyatt", "Matthew"
|
|
13
|
+
];
|
|
14
|
+
const femaleNames = [
|
|
15
|
+
"Olivia", "Emma", "Ava", "Sophia", "Isabella", "Mia", "Amelia",
|
|
16
|
+
"Harper", "Evelyn", "Abigail", "Emily", "Ella", "Elizabeth",
|
|
17
|
+
"Camila", "Luna", "Sofia", "Avery", "Mila", "Aria", "Scarlett",
|
|
18
|
+
"Penelope", "Layla", "Chloe", "Victoria", "Madison", "Eleanor",
|
|
19
|
+
"Grace", "Nora", "Riley", "Zoey"
|
|
20
|
+
];
|
|
21
|
+
const lastNames = [
|
|
22
|
+
"Smith", "Johnson", "Williams", "Brown", "Jones", "Garcia", "Miller",
|
|
23
|
+
"Davis", "Rodriguez", "Martinez", "Hernandez", "Lopez", "Gonzalez",
|
|
24
|
+
"Wilson", "Anderson", "Thomas", "Taylor", "Moore", "Jackson", "Martin",
|
|
25
|
+
"Lee", "Perez", "Thompson", "White", "Harris", "Sanchez", "Clark",
|
|
26
|
+
"Ramirez", "Lewis", "Robinson"
|
|
27
|
+
];
|
|
28
|
+
const gender = Math.random() > 0.5 ? 'm' : 'f';
|
|
29
|
+
const firstName = gender === 'm' ? maleNames[Math.floor(Math.random() * maleNames.length)] : femaleNames[Math.floor(Math.random() * femaleNames.length)];
|
|
30
|
+
const lastName = lastNames[Math.floor(Math.random() * lastNames.length)];
|
|
31
|
+
const name = `${firstName} ${lastName}`;
|
|
32
|
+
const email = `${firstName.toLowerCase()}.${lastName.toLowerCase()}@mailserver.com`;
|
|
33
|
+
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')}`;
|
|
34
|
+
const phoneNumber = `(${Math.floor(Math.random() * 900) + 100}) ${Math.floor(Math.random() * 900) + 100}-${Math.floor(Math.random() * 9000) + 1000}`;
|
|
35
|
+
return { name, email, birthday, phoneNumber, gender };
|
|
36
|
+
}
|
|
37
|
+
for (let i = 0; i < 10; i++) {
|
|
38
|
+
contacts.push(generateContact());
|
|
39
|
+
};
|
|
40
|
+
</script>
|
|
41
|
+
</content>
|
|
42
|
+
<content>
|
|
43
|
+
|
|
44
|
+
<a href="./table.html"><h5>Back to Table Component Documentation</h5></a>
|
|
45
|
+
|
|
46
|
+
<p>The sorting feature allows users to sort the records displayed in the table by clicking on the column headers. This is enabled by setting the <code>enable-sorting="true"</code> attribute.</p>
|
|
47
|
+
<p>Once enabled the user can sort the records by clicking on the fields.</p>
|
|
48
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-table</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"sortingExample"</span> <span class="hljs-attr">enable-sorting</span>=<span class="hljs-string">"true"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-table</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-built_in">document</span>.getElementById(<span class="hljs-string">'sortingExample'</span>).setRecords(contacts);<br /></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
49
|
+
<k-table id="sortingExample" enable-sorting="true"></k-table>
|
|
50
|
+
<script type="module">
|
|
51
|
+
document.getElementById('sortingExample').setRecords(contacts);
|
|
52
|
+
</script>
|
|
53
|
+
</content>
|
|
54
|
+
</page>
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
<page pageName="Tabs" title="Tabs - Components - Kempo Docs - A Web Components Solution">
|
|
2
|
+
<content>
|
|
3
|
+
<k-accordion persistent-id="toc" class="b r mb">
|
|
4
|
+
<k-accordion-header for-panel="toc-panel">Table of Contents</k-accordion-header>
|
|
5
|
+
<k-accordion-panel name="toc-panel">
|
|
6
|
+
<div class="m">
|
|
7
|
+
<h6>Examples</h6>
|
|
8
|
+
<a href="#basicUsage">Basic Usage</a><br />
|
|
9
|
+
<a href="#tabSpacers">Tab Spacers</a><br />
|
|
10
|
+
<a href="#scrollingTabs">Scrolling Tabs</a><br />
|
|
11
|
+
<a href="#fixedHeight">Fixed Height</a><br />
|
|
12
|
+
<h6 class="mt"><a href="#jsRef" class="no-link">JavaScript Reference</a></h6>
|
|
13
|
+
<a href="#constructor">Constructor</a><br />
|
|
14
|
+
<a href="#requirements">Requirements</a><br />
|
|
15
|
+
<a href="#properties">Properties</a><br />
|
|
16
|
+
<a href="#methods">Methods</a><br />
|
|
17
|
+
<a href="#events">Events</a><br />
|
|
18
|
+
</div>
|
|
19
|
+
</k-accordion-panel>
|
|
20
|
+
</k-accordion>
|
|
21
|
+
|
|
22
|
+
<h3 id="basicUsage"><a href="#basicUsage" class="no-link">Basic Usage</a></h3>
|
|
23
|
+
<p>Create tabs using the <code>k-tabs</code> component. Add tabs using the <code>k-tab</code> component and tab contents using the <code>k-tab-content</code> component. Use the <code>for</code> attribute on the <code>k-tab</code> component to link it to the corresponding <code>k-tab-content</code> component.</p>
|
|
24
|
+
<div class="row -mx mb">
|
|
25
|
+
<div class="col d-span-6 m-span-12 px">
|
|
26
|
+
<k-card label="HTML">
|
|
27
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-tabs</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"html"</span>></span>HTML<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"js"</span>></span>JavaScript<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"html"</span>></span><br /> HTML Content<br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"js"</span>></span><br /> JavaScript Content<br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /><span class="hljs-tag"></<span class="hljs-name">k-tabs</span>></span></code></pre>
|
|
28
|
+
</k-card>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="col d-span-6 m-span-12 px">
|
|
31
|
+
<k-card label="Results">
|
|
32
|
+
<k-tabs>
|
|
33
|
+
<k-tab for="html">HTML</k-tab>
|
|
34
|
+
<k-tab for="js">JavaScript</k-tab>
|
|
35
|
+
<k-tab-content name="html">
|
|
36
|
+
<p>HTML Content</p>
|
|
37
|
+
</k-tab-content>
|
|
38
|
+
<k-tab-content name="js">
|
|
39
|
+
<p>JavaScript Content</p>
|
|
40
|
+
</k-tab-content>
|
|
41
|
+
</k-tabs>
|
|
42
|
+
</k-card>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<h3 id="tabSpacers"><a href="#tabSpacers" class="no-link">Tab Spacers</a></h3>
|
|
47
|
+
<p>Use the <code>k-tab-spacer</code> component to create flexible spacing between tabs. This is useful for creating layouts where some tabs are grouped on the left and others on the right.</p>
|
|
48
|
+
<div class="row -mx mb">
|
|
49
|
+
<div class="col d-span-6 m-span-12 px">
|
|
50
|
+
<k-card label="HTML">
|
|
51
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-tabs</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"left1"</span>></span>Home<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"left2"</span>></span>About<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-spacer</span>></span><span class="hljs-tag"></<span class="hljs-name">k-tab-spacer</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"right1"</span>></span>Settings<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"right2"</span>></span>Profile<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"left1"</span>></span><br /> Home Content<br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"left2"</span>></span><br /> About Content<br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"right1"</span>></span><br /> Settings Content<br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"right2"</span>></span><br /> Profile Content<br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /><span class="hljs-tag"></<span class="hljs-name">k-tabs</span>></span></code></pre>
|
|
52
|
+
</k-card>
|
|
53
|
+
</div>
|
|
54
|
+
<div class="col d-span-6 m-span-12 px">
|
|
55
|
+
<k-card label="Results">
|
|
56
|
+
<k-tabs>
|
|
57
|
+
<k-tab for="left1">Home</k-tab>
|
|
58
|
+
<k-tab for="left2">About</k-tab>
|
|
59
|
+
<k-tab-spacer></k-tab-spacer>
|
|
60
|
+
<k-tab for="right1">Settings</k-tab>
|
|
61
|
+
<k-tab for="right2">Profile</k-tab>
|
|
62
|
+
<k-tab-content name="left1">
|
|
63
|
+
<p>Home Content</p>
|
|
64
|
+
</k-tab-content>
|
|
65
|
+
<k-tab-content name="left2">
|
|
66
|
+
<p>About Content</p>
|
|
67
|
+
</k-tab-content>
|
|
68
|
+
<k-tab-content name="right1">
|
|
69
|
+
<p>Settings Content</p>
|
|
70
|
+
</k-tab-content>
|
|
71
|
+
<k-tab-content name="right2">
|
|
72
|
+
<p>Profile Content</p>
|
|
73
|
+
</k-tab-content>
|
|
74
|
+
</k-tabs>
|
|
75
|
+
</k-card>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<h3 id="scrollingTabs"><a href="#scrollingTabs" class="no-link">Scrolling Tabs</a></h3>
|
|
80
|
+
<p>When there are many tabs that don't fit in the available space, the tabs will automatically become scrollable with left/right scroll indicators.</p>
|
|
81
|
+
<div class="row -mx mb">
|
|
82
|
+
<div class="col d-span-6 m-span-12 px">
|
|
83
|
+
<k-card label="HTML">
|
|
84
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-tabs</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"tab1"</span>></span>Tab 1<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"tab2"</span>></span>Tab 2<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"tab3"</span>></span>Tab 3<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"tab4"</span>></span>Tab 4<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"tab5"</span>></span>Tab 5<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"tab6"</span>></span>Tab 6<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"tab7"</span>></span>Tab 7<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"tab8"</span>></span>Tab 8<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"tab1"</span>></span><br /> Content for Tab 1<br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"tab2"</span>></span><br /> Content for Tab 2<br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"tab3"</span>></span><br /> Content for Tab 3<br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"tab4"</span>></span><br /> Content for Tab 4<br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"tab5"</span>></span><br /> Content for Tab 5<br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"tab6"</span>></span><br /> Content for Tab 6<br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"tab7"</span>></span><br /> Content for Tab 7<br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"tab8"</span>></span><br /> Content for Tab 8<br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /><span class="hljs-tag"></<span class="hljs-name">k-tabs</span>></span></code></pre>
|
|
85
|
+
</k-card>
|
|
86
|
+
</div>
|
|
87
|
+
<div class="col d-span-6 m-span-12 px">
|
|
88
|
+
<k-card label="Results" style="max-width: 400px;">
|
|
89
|
+
<k-tabs>
|
|
90
|
+
<k-tab for="tab1">Tab 1</k-tab>
|
|
91
|
+
<k-tab for="tab2">Tab 2</k-tab>
|
|
92
|
+
<k-tab for="tab3">Tab 3</k-tab>
|
|
93
|
+
<k-tab for="tab4">Tab 4</k-tab>
|
|
94
|
+
<k-tab for="tab5">Tab 5</k-tab>
|
|
95
|
+
<k-tab for="tab6">Tab 6</k-tab>
|
|
96
|
+
<k-tab for="tab7">Tab 7</k-tab>
|
|
97
|
+
<k-tab for="tab8">Tab 8</k-tab>
|
|
98
|
+
<k-tab-content name="tab1">
|
|
99
|
+
<p>Content for Tab 1</p>
|
|
100
|
+
</k-tab-content>
|
|
101
|
+
<k-tab-content name="tab2">
|
|
102
|
+
<p>Content for Tab 2</p>
|
|
103
|
+
</k-tab-content>
|
|
104
|
+
<k-tab-content name="tab3">
|
|
105
|
+
<p>Content for Tab 3</p>
|
|
106
|
+
</k-tab-content>
|
|
107
|
+
<k-tab-content name="tab4">
|
|
108
|
+
<p>Content for Tab 4</p>
|
|
109
|
+
</k-tab-content>
|
|
110
|
+
<k-tab-content name="tab5">
|
|
111
|
+
<p>Content for Tab 5</p>
|
|
112
|
+
</k-tab-content>
|
|
113
|
+
<k-tab-content name="tab6">
|
|
114
|
+
<p>Content for Tab 6</p>
|
|
115
|
+
</k-tab-content>
|
|
116
|
+
<k-tab-content name="tab7">
|
|
117
|
+
<p>Content for Tab 7</p>
|
|
118
|
+
</k-tab-content>
|
|
119
|
+
<k-tab-content name="tab8">
|
|
120
|
+
<p>Content for Tab 8</p>
|
|
121
|
+
</k-tab-content>
|
|
122
|
+
</k-tabs>
|
|
123
|
+
</k-card>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<h3 id="fixedHeight"><a href="#fixedHeight" class="no-link">Fixed Height</a></h3>
|
|
128
|
+
<p>Use the <code>fixed-height</code> attribute to make the tabs component fill its container height and enable content scrolling.</p>
|
|
129
|
+
<div class="row -mx mb">
|
|
130
|
+
<div class="col d-span-6 m-span-12 px">
|
|
131
|
+
<k-card label="HTML">
|
|
132
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-tabs</span> <span class="hljs-attr">fixed-height</span>=<span class="hljs-string">"true"</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"height: 200px"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"fixed1"</span>></span>Tab 1<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"fixed2"</span>></span>Tab 2<span class="hljs-tag"></<span class="hljs-name">k-tab</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"fixed1"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">p</span>></span>This content will scroll if it's too long.<span class="hljs-tag"></<span class="hljs-name">p</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">p</span>></span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<span class="hljs-tag"></<span class="hljs-name">p</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">p</span>></span>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<span class="hljs-tag"></<span class="hljs-name">p</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">p</span>></span>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.<span class="hljs-tag"></<span class="hljs-name">p</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">p</span>></span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<span class="hljs-tag"></<span class="hljs-name">p</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">p</span>></span>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<span class="hljs-tag"></<span class="hljs-name">p</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">p</span>></span>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.<span class="hljs-tag"></<span class="hljs-name">p</span>></span><br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">k-tab-content</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"fixed2"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">p</span>></span>Another tab that is not tall enough.<span class="hljs-tag"></<span class="hljs-name">p</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">p</span>></span>Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.<span class="hljs-tag"></<span class="hljs-name">p</span>></span><br /> <span class="hljs-tag"></<span class="hljs-name">k-tab-content</span>></span><br /><span class="hljs-tag"></<span class="hljs-name">k-tabs</span>></span></code></pre>
|
|
133
|
+
</k-card>
|
|
134
|
+
</div>
|
|
135
|
+
<div class="col d-span-6 m-span-12 px">
|
|
136
|
+
<k-card label="Results">
|
|
137
|
+
<k-tabs fixed-height="true" style="height: 200px">
|
|
138
|
+
<k-tab for="fixed1">Tab 1</k-tab>
|
|
139
|
+
<k-tab for="fixed2">Tab 2</k-tab>
|
|
140
|
+
<k-tab-content name="fixed1">
|
|
141
|
+
<p>This content will scroll if it's too long.</p>
|
|
142
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
|
|
143
|
+
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
144
|
+
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p>
|
|
145
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
|
|
146
|
+
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
147
|
+
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p>
|
|
148
|
+
</k-tab-content>
|
|
149
|
+
<k-tab-content name="fixed2">
|
|
150
|
+
<p>Another tab that is not tall enough.</p>
|
|
151
|
+
<p>Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</p>
|
|
152
|
+
</k-tab-content>
|
|
153
|
+
</k-tabs>
|
|
154
|
+
</k-card>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
|
|
158
|
+
<h2 id="jsRef"><a href="#jsRef" class="no-link">JavaScript Reference</a></h2>
|
|
159
|
+
<h3 id="constructor"><a href="#constructor" class="no-link">Constructor</a></h3>
|
|
160
|
+
<h6>Extends <a href="./shadow-component.html">ShadowComponent</a></h6>
|
|
161
|
+
<h5><code>new Tabs()</code></h5>
|
|
162
|
+
|
|
163
|
+
<h3 id="requirements"><a href="#requirements" class="no-link">Requirements</a></h3>
|
|
164
|
+
<ul>
|
|
165
|
+
<li><a href="./shadow-component.html">ShadowComponent</a></li>
|
|
166
|
+
</ul>
|
|
167
|
+
|
|
168
|
+
<h3 id="properties"><a href="#properties" class="no-link">Properties</a></h3>
|
|
169
|
+
<h5><code>active<i>: string</i></code></h5>
|
|
170
|
+
<p>The name of the active tab. Syncs to <code>active</code> attribute.</p>
|
|
171
|
+
<h5><code>fixedHeight<i>: boolean</i></code></h5>
|
|
172
|
+
<p>Whether the tabs component uses fixed height mode. Syncs to <code>fixed-height</code> attribute.</p>
|
|
173
|
+
<h5><code>contents<i>: TabContent[]</i></code></h5>
|
|
174
|
+
<p>Returns an array of all tab content elements.</p>
|
|
175
|
+
<h5><code>tabs<i>: Tab[]</i></code></h5>
|
|
176
|
+
<p>Returns an array of all tab elements.</p>
|
|
177
|
+
|
|
178
|
+
<h3 id="methods"><a href="#methods" class="no-link">Methods</a></h3>
|
|
179
|
+
<h5><code>getActiveTab()<i>: Tab</i></code></h5>
|
|
180
|
+
<p>Returns the currently active tab.</p>
|
|
181
|
+
<h5><code>getTab(id)<i>: Tab</i></code></h5>
|
|
182
|
+
<p>Returns the tab with the specified id.</p>
|
|
183
|
+
<h5><code>getActiveContent()<i>: TabContent</i></code></h5>
|
|
184
|
+
<p>Returns the currently active tab content.</p>
|
|
185
|
+
<h5><code>getContent(id)<i>: TabContent</i></code></h5>
|
|
186
|
+
<p>Returns the tab content with the specified id.</p>
|
|
187
|
+
<h5><code>updateActiveElements()<i>: void</i></code></h5>
|
|
188
|
+
<p>Updates the active state of tabs and content based on the current active property.</p>
|
|
189
|
+
<h5><code>updateScrollIndicators()<i>: void</i></code></h5>
|
|
190
|
+
<p>Updates the visibility of scroll indicators based on tab overflow.</p>
|
|
191
|
+
|
|
192
|
+
<h3 id="events"><a href="#events" class="no-link">Events</a></h3>
|
|
193
|
+
<h5><code>tab</code></h5>
|
|
194
|
+
<p>Fired when the active tab changes. Detail contains <code>{ tab }</code> with the name of the new active tab.</p>
|
|
195
|
+
</content>
|
|
196
|
+
<content location="scripts">
|
|
197
|
+
<script type="module" src="{{pathToRoot}}src/components/Tabs.js"></script>
|
|
198
|
+
<script type="module" src="{{pathToRoot}}src/components/Card.js"></script>
|
|
199
|
+
<script type="module" src="{{pathToRoot}}src/components/Accordion.js"></script>
|
|
200
|
+
</content>
|
|
201
|
+
</page>
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<page pageName="Tags" title="Tags - Components - Kempo Docs - A Web Components Solution">
|
|
2
|
+
<content>
|
|
3
|
+
<k-accordion persistent-id="toc" class="b r mb">
|
|
4
|
+
<k-accordion-header for-panel="toc-panel">Table of Contents</k-accordion-header>
|
|
5
|
+
<k-accordion-panel name="toc-panel">
|
|
6
|
+
<div class="m ">
|
|
7
|
+
<h6>Examples</h6>
|
|
8
|
+
<a href="#basicUsage">Basic Usage</a><br />
|
|
9
|
+
<a href="#allowedTags">Allowed Tags</a><br />
|
|
10
|
+
<a href="#disallowedTags">Disallowed Tags</a><br />
|
|
11
|
+
<a href="#disabled">Disabled</a><br />
|
|
12
|
+
|
|
13
|
+
<h6 class="mt"><a href="#jsRef" class="no-link">JavaScript Reference</a></h6>
|
|
14
|
+
<a href="#constructor">Constructor</a><br />
|
|
15
|
+
<a href="#requirements">Requirements</a><br />
|
|
16
|
+
<a href="#properties">Properties</a><br />
|
|
17
|
+
<a href="#methods">Methods</a><br />
|
|
18
|
+
<a href="#events">Events</a><br />
|
|
19
|
+
</div>
|
|
20
|
+
</k-accordion-panel>
|
|
21
|
+
</k-accordion>
|
|
22
|
+
|
|
23
|
+
<h3>Description</h3>
|
|
24
|
+
<p>The <code>Tags</code> component allows users to add and remove tags. It extends the <a
|
|
25
|
+
href="./shadow-component.html">ShadowComponent</a> class.</p>
|
|
26
|
+
|
|
27
|
+
<h3 id="basicUsage"><a href="#basicUsage" class="no-link">Basic Usage</a></h3>
|
|
28
|
+
<p>Use the <code>Tags</code> component to allow users to add and remove tags. Tags can be added by typing them into
|
|
29
|
+
the input field and pressing Enter or by pasting a comma-separated list of tags. You can delete a tag by clicking
|
|
30
|
+
on it.</p>
|
|
31
|
+
<div class="row -mx mb">
|
|
32
|
+
<div class="col d-span-6 m-span-12 px">
|
|
33
|
+
<k-card label="HTML">
|
|
34
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-tags</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">label</span>></span>Tags<span class="hljs-tag"></<span class="hljs-name">label</span>></span><br /><span class="hljs-tag"></<span class="hljs-name">k-tags</span>></span></code></pre>
|
|
35
|
+
</k-card>
|
|
36
|
+
</div>
|
|
37
|
+
<div class="col d-span-6 m-span-12 px">
|
|
38
|
+
<k-card label="Results">
|
|
39
|
+
<k-tags>
|
|
40
|
+
<label>Tags</label>
|
|
41
|
+
</k-tags>
|
|
42
|
+
</k-card>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<h3 id="allowedTags"><a href="#allowedTags" class="no-link">Allowed Tags</a></h3>
|
|
47
|
+
<p>Use the <code>allowedTags</code> attribute to specify a comma-separated list of allowed tags. Only these tags can
|
|
48
|
+
be added.</p>
|
|
49
|
+
<div class="row -mx mb">
|
|
50
|
+
<div class="col d-span-6 m-span-12 px">
|
|
51
|
+
<k-card label="HTML">
|
|
52
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-tags</span> <span class="hljs-attr">allowed-tags</span>=<span class="hljs-string">"tag1,tag2,tag3"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">label</span>></span>Allowed Tags<span class="hljs-tag"></<span class="hljs-name">label</span>></span><br /><span class="hljs-tag"></<span class="hljs-name">k-tags</span>></span></code></pre>
|
|
53
|
+
</k-card>
|
|
54
|
+
</div>
|
|
55
|
+
<div class="col d-span-6 m-span-12 px">
|
|
56
|
+
<k-card label="Results">
|
|
57
|
+
<k-tags allowed-tags="tag1,tag2,tag3">
|
|
58
|
+
<label>Allowed Tags</label>
|
|
59
|
+
</k-tags>
|
|
60
|
+
</k-card>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
<h3 id="disallowedTags"><a href="#disallowedTags" class="no-link">Disallowed Tags</a></h3>
|
|
67
|
+
<p>Use the <code>disallowedTags</code> attribute to specify a comma-separated list of disallowed tags. These tags
|
|
68
|
+
cannot be added.</p>
|
|
69
|
+
<div class="row -mx mb">
|
|
70
|
+
<div class="col d-span-6 m-span-12 px">
|
|
71
|
+
<k-card label="HTML">
|
|
72
|
+
<k-card label="Results">
|
|
73
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-tags</span> <span class="hljs-attr">disallowed-tags</span>=<span class="hljs-string">"tag1,tag2,tag3"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">label</span>></span>Disallowed Tags<span class="hljs-tag"></<span class="hljs-name">label</span>></span><br /><span class="hljs-tag"></<span class="hljs-name">k-tags</span>></span></code></pre>
|
|
74
|
+
</k-card>
|
|
75
|
+
</k-card>
|
|
76
|
+
</div>
|
|
77
|
+
<div class="col d-span-6 m-span-12 px">
|
|
78
|
+
<k-tags disallowed-tags="tag1,tag2,tag3">
|
|
79
|
+
<label>Disallowed Tags</label>
|
|
80
|
+
</k-tags>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
<h3 id="disabled"><a href="#disabled" class="no-link">Disabled</a></h3>
|
|
87
|
+
<p>Use the <code>disabled</code> attribute to prevent the user from adding or removing tags while still displaying the current value.</p>
|
|
88
|
+
<div class="row -mx mb">
|
|
89
|
+
<div class="col d-span-6 m-span-12 px">
|
|
90
|
+
<k-card label="HTML">
|
|
91
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-tags</span> <span class="hljs-attr">disabled</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"design,ui"</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">label</span>></span>Tags<span class="hljs-tag"></<span class="hljs-name">label</span>></span><br><span class="hljs-tag"></<span class="hljs-name">k-tags</span>></span></code></pre>
|
|
92
|
+
</k-card>
|
|
93
|
+
</div>
|
|
94
|
+
<div class="col d-span-6 m-span-12 px">
|
|
95
|
+
<k-card label="Results">
|
|
96
|
+
<k-tags disabled value="design,ui">
|
|
97
|
+
<label>Tags</label>
|
|
98
|
+
</k-tags>
|
|
99
|
+
</k-card>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
<h2 id="jsRef"><a href="#jsRef" class="no-link">JavaScript Reference</a></h2>
|
|
105
|
+
|
|
106
|
+
<h3 id="constructor"><a href="#constructor" class="no-link">Constructor</a></h3>
|
|
107
|
+
<h6>Extends <a href="./shadow-component.html">ShadowComponent</a></h6>
|
|
108
|
+
<h5>
|
|
109
|
+
<code>new Tags()</code>
|
|
110
|
+
</h5>
|
|
111
|
+
|
|
112
|
+
<h3 id="requirements"><a href="#requirements" class="no-link">Requirements</a></h3>
|
|
113
|
+
<ul>
|
|
114
|
+
<li><a href="./shadow-component.html">ShadowComponent</a></li>
|
|
115
|
+
</ul>
|
|
116
|
+
|
|
117
|
+
<h3 id="properties"><a href="#properties" class="no-link">Properties</a></h3>
|
|
118
|
+
<h5><code>value<i>: string</i></code></h5>
|
|
119
|
+
<p>A comma-separated list of tags. Syncs with the <code>value</code> attribute.</p>
|
|
120
|
+
<h5><code>allowedTags<i>: string</i></code></h5>
|
|
121
|
+
<p>A comma-separated list of allowed tags. If specified, only these tags can be added. Syncs with the
|
|
122
|
+
<code>allowed-tags</code> attribute.</p>
|
|
123
|
+
<h5><code>disallowedTags<i>: string</i></code></h5>
|
|
124
|
+
<p>A comma-separated list of disallowed tags. If specified, these tags cannot be added. Syncs with the
|
|
125
|
+
<code>disallowed-tags</code> attribute.</p>
|
|
126
|
+
<h5><code>disabled<i>: boolean</i></code></h5>
|
|
127
|
+
<p>When <code>true</code>, prevents the user from adding or removing tags. The current value is still displayed. The element appears at 50% opacity. Syncs with the <code>disabled</code> attribute.</p>
|
|
128
|
+
|
|
129
|
+
<h3 id="methods"><a href="#methods" class="no-link">Methods</a></h3>
|
|
130
|
+
<h5><code>addTag(tag)<i>: void</i></code></h5>
|
|
131
|
+
<p>Adds a tag to the list of tags.</p>
|
|
132
|
+
<h5><code>removeTag(tag)<i>: void</i></code></h5>
|
|
133
|
+
<p>Removes a tag from the list of tags.</p>
|
|
134
|
+
<h5><code>validateTags()<i>: string</i></code></h5>
|
|
135
|
+
<p>Validates the list of tags against the allowed and disallowed tags and returns the valid tags as a
|
|
136
|
+
comma-separated string.</p>
|
|
137
|
+
<h5><code>renderTags()<i>: Promise<void></i></code></h5>
|
|
138
|
+
<p>Re-renders the tag elements in the component.</p>
|
|
139
|
+
|
|
140
|
+
<h3 id="events"><a href="#events" class="no-link">Events</a></h3>
|
|
141
|
+
<h5><code>change</code></h5>
|
|
142
|
+
<p>Fired when the value changes. Detail contains <code>{ oldValue, newValue }</code>.</p>
|
|
143
|
+
<h5><code>addtag</code></h5>
|
|
144
|
+
<p>Fired when a tag is added. Detail contains <code>{ tag }</code>.</p>
|
|
145
|
+
<h5><code>removetag</code></h5>
|
|
146
|
+
<p>Fired when a tag is removed. Detail contains <code>{ tag }</code>.</p>
|
|
147
|
+
<h5><code>allowedtagschange</code></h5>
|
|
148
|
+
<p>Fired when the allowed tags list changes. Detail contains <code>{ oldValue, newValue }</code>.</p>
|
|
149
|
+
<h5><code>disallowedtagschange</code></h5>
|
|
150
|
+
<p>Fired when the disallowed tags list changes. Detail contains <code>{ oldValue, newValue }</code>.</p>
|
|
151
|
+
</content>
|
|
152
|
+
<content location="scripts">
|
|
153
|
+
<script type="module" src="{{pathToRoot}}src/components/Tags.js"></script>
|
|
154
|
+
<script type="module" src="{{pathToRoot}}src/components/Accordion.js"></script>
|
|
155
|
+
<script type="module" src="{{pathToRoot}}src/components/Card.js"></script>
|
|
156
|
+
</content>
|
|
157
|
+
</page>
|