kempo 2.9.2 → 2.9.4

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 (73) hide show
  1. package/dist/components/Accordion.js +1 -1
  2. package/dist/components/Dialog.js +1 -1
  3. package/dist/components/DirectoryViewer.js +1 -1
  4. package/dist/components/FocusCapture.js +1 -1
  5. package/dist/components/Timestamp.js +1 -1
  6. package/dist/components/Toggle.js +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/utils/formatTimestamp.js +1 -1
  9. package/docs/components/_template.html +9 -0
  10. package/docs/components/accordion.html +52 -12
  11. package/docs/components/card.html +68 -8
  12. package/docs/components/component.html +6 -0
  13. package/docs/components/content-slider.html +8 -0
  14. package/docs/components/dialog.html +145 -5
  15. package/docs/components/directory-viewer.html +51 -40
  16. package/docs/components/focus-capture.html +68 -0
  17. package/docs/components/icon.html +76 -5
  18. package/docs/components/import.html +47 -0
  19. package/docs/components/lazy-component.html +45 -15
  20. package/docs/components/reactive-component.html +69 -0
  21. package/docs/components/reactive-lazy-component.html +69 -0
  22. package/docs/components/resize.html +52 -3
  23. package/docs/components/search.html +102 -0
  24. package/docs/components/show-more.html +54 -5
  25. package/docs/components/{sidemenu.html → side-menu.html} +56 -3
  26. package/docs/components/split.html +57 -16
  27. package/docs/components/table.html +20 -20
  28. package/docs/components/tabs.html +72 -4
  29. package/docs/components/tags.html +94 -0
  30. package/docs/components/theme-switcher.html +74 -0
  31. package/docs/components/timestamp.html +86 -0
  32. package/docs/components/toggle.html +37 -34
  33. package/docs/index.html +5 -0
  34. package/docs/kempo/components/Accordion.js +1 -1
  35. package/docs/kempo/components/Dialog.js +1 -1
  36. package/docs/kempo/components/DirectoryViewer.js +1 -1
  37. package/docs/kempo/components/FocusCapture.js +1 -1
  38. package/docs/kempo/components/Timestamp.js +1 -1
  39. package/docs/kempo/components/Toggle.js +1 -1
  40. package/docs/kempo/index.js +1 -1
  41. package/docs/kempo/utils/formatTimestamp.js +1 -1
  42. package/docs/nav-1.inc.html +16 -2
  43. package/docs/nav.inc.html +10 -2
  44. package/docs/search.json +281 -23
  45. package/docs/styles/_template.html +6 -0
  46. package/docs/styles/borders-spacing.html +6 -0
  47. package/docs/styles/buttons.html +6 -0
  48. package/docs/styles/colors.html +6 -0
  49. package/docs/styles/displays-layouts.html +6 -0
  50. package/docs/styles/embed-1.html +6 -0
  51. package/docs/styles/inputs.html +6 -0
  52. package/docs/styles/tables.html +6 -0
  53. package/docs/styles/typography.html +6 -0
  54. package/docs/{components/stacks.html → utils/_template.html} +11 -30
  55. package/docs/utils/cli.html +84 -0
  56. package/docs/utils/cookie.html +87 -0
  57. package/docs/utils/debounce.html +61 -0
  58. package/docs/utils/drag.html +85 -0
  59. package/docs/utils/element.html +124 -0
  60. package/docs/utils/format-timestamp.html +64 -0
  61. package/docs/utils/fuzzy-match.html +60 -0
  62. package/package.json +1 -1
  63. package/src/components/Accordion.js +0 -1
  64. package/src/components/Dialog.js +3 -2
  65. package/src/components/DirectoryViewer.js +21 -92
  66. package/src/components/FocusCapture.js +2 -1
  67. package/src/components/Search.js +4 -1
  68. package/src/components/Timestamp.js +7 -4
  69. package/src/components/Toggle.js +3 -0
  70. package/src/utils/formatTimestamp.js +26 -10
  71. package/docs/table.html +0 -0
  72. package/src/components/Stacks.js +0 -79
  73. package/src/utils/files.js +0 -15
@@ -1,6 +1,6 @@
1
1
  import LazyComponent from './LazyComponent.js';
2
2
  import Component from './Component.js';
3
- import './Icon.js';
3
+ // import './Icon.js';
4
4
  import {
5
5
  onEvent,
6
6
  offEvent,
@@ -10,7 +10,8 @@ import watchDirectoryHandle from '../utils/watchDirectoryHandle.js';
10
10
 
11
11
  const handle = Symbol(),
12
12
  loadDirectoryClickHandler = Symbol(),
13
- selectedHandler = Symbol(),
13
+ openToggleClickHandler = Symbol(),
14
+ fileSelectedHandler = Symbol(),
14
15
  watchId = Symbol(),
15
16
  changeCallback = Symbol(),
16
17
  filters = Symbol();
@@ -36,13 +37,13 @@ export default class DirectoryViewer extends LazyComponent {
36
37
  this[changeCallback] = () => {
37
38
  this.updateContents();
38
39
  }
39
- this[selectedHandler] = (e) => {
40
-
41
- }
42
40
 
43
41
  /* Init */
42
+ this.slot = 'content';
44
43
  this.registerAttributes({
44
+ root: !_handle,
45
45
  hasHandle: !!_handle,
46
+ opened: !_handle,
46
47
  selected: false
47
48
  });
48
49
  }
@@ -50,8 +51,9 @@ export default class DirectoryViewer extends LazyComponent {
50
51
  /* Lifecycle Callbacks */
51
52
  async render(force){
52
53
  if(await super.render(force)){
53
- onEvent(this.shadowRoot, 'fileSelected directorySelected', this[selectedHandler]);
54
+ onEvent(this.shadowRoot, 'fileselected', this[fileSelectedHandler]);
54
55
  onEvent(this.shadowRoot.getElementById('loadDirectory'), 'click', this[loadDirectoryClickHandler]);
56
+ onEvent(this.shadowRoot.getElementById('openToggle'), 'click', this[openToggleClickHandler]);
55
57
  this.renderDirectory();
56
58
  return true;
57
59
  }
@@ -131,6 +133,15 @@ export default class DirectoryViewer extends LazyComponent {
131
133
  }
132
134
  }
133
135
  }
136
+ open(){
137
+ this.opened = true;
138
+ }
139
+ close(){
140
+ if(!this.root) this.opened = false;
141
+ }
142
+ toggleOpen(){
143
+ if(!this.root) this.opened = !this.opened;
144
+ }
134
145
  clearDirectoryHandle(){
135
146
  this[handle] = false;
136
147
  this.hasHandle = false;
@@ -172,11 +183,11 @@ export default class DirectoryViewer extends LazyComponent {
172
183
  }
173
184
  }
174
185
  select(){
175
- const $currentSelection = this.querySelector('k-directory[selected], k-file[selected]');
186
+ const $currentSelection = this.closest('k-directory-viewer[root]').querySelector('k-directory-viewer[selected], k-directory-viewer-file[selected]');
176
187
  if($currentSelection === this) return;
177
188
  if($currentSelection) $currentSelection.selected = false;
178
189
  this.selected = true;
179
- this.dispatchEvent(new CustomEvent('dirSelected', {
190
+ this.dispatchEvent(new CustomEvent('dirselected', {
180
191
  detail: {
181
192
  dirHandle: this[handle],
182
193
  dirComponent: this
@@ -258,83 +269,6 @@ export default class DirectoryViewer extends LazyComponent {
258
269
  }
259
270
  window.customElements.define('k-directory-viewer', DirectoryViewer);
260
271
 
261
- export class Directory extends Component {
262
- constructor(_handle = false){
263
- super();
264
-
265
- /* Private Members */
266
- this[handle] = _handle;
267
-
268
- /* Private Methods */
269
- this[selectDirectoryClickHandler] = () => this.select();
270
-
271
- /* Init */
272
- this.slot = 'content';
273
- this.registerAttribute('selected', false);
274
- }
275
-
276
- /* Lifecycle Callbacks */
277
- async render(force){
278
- if(await super.render(force)){
279
- if(this[handle]){
280
- this.innerHTML = this[handle].name;
281
- onEvent(this.shadowRoot.getElementById('selectDirectory'), 'click', this[selectDirectoryClickHandler]);
282
- }
283
- return true;
284
- }
285
- return false;
286
- }
287
- disconnectedCallback(){
288
- super.disconnectedCallback();
289
- offEvent(this.shadowRoot.getElementById('selectDirectory'), 'click', this[selectDirectoryClickHandler]);
290
- }
291
-
292
- /* Protected Members */
293
- get rootDir(){
294
- return this.closest('k-directory-viewer')
295
- }
296
-
297
- /* Public Methods */
298
- select(){
299
- const $currentSelection = this.rootDir.querySelector('k-directory[selected], k-file[selected]');
300
- if($currentSelection === this) return;
301
- if($currentSelection) $currentSelection.selected = false;
302
- this.selected = true;
303
- this.dispatchEvent(new CustomEvent('directorySelected', {
304
- detail: {
305
- fileHandle: this[handle],
306
- fileComponent: this
307
- },
308
- bubbles: true,
309
- composed: true
310
- }));
311
- }
312
-
313
- /* Shadow DOM */
314
- get shadowTemplate(){
315
- return /*html*/`
316
- <button
317
- id="selectDirectory"
318
- >
319
- <slot name="selectButton">
320
- <k-icon id="extIcon" name="file"></k-icon> ${this[handle].name}
321
- </slot>
322
- </button>
323
- ${super.shadowTemplate}
324
- `;
325
- }
326
- get shadowStyles(){
327
- return /*css*/`
328
- ${super.shadowStyles}
329
- :host([selected]) #selectFile {
330
- background-color: var(--c_primary);
331
- color: var(--tc_on_primary);
332
- border-radius: var(--raidus);
333
- }
334
- `;
335
- }
336
- }
337
-
338
272
  const selectFileClickHandler = Symbol();
339
273
  export class File extends Component {
340
274
  constructor(_handle = false){
@@ -376,18 +310,13 @@ export class File extends Component {
376
310
  offEvent(this.shadowRoot.getElementById('selectFile'), 'click', this[selectFileClickHandler]);
377
311
  }
378
312
 
379
- /* Protected Members */
380
- get rootDir(){
381
- return this.closest('k-directory-viewer')
382
- }
383
-
384
313
  /* Public Methods */
385
314
  select(){
386
- const $currentSelection = this.rootDir.querySelector('k-directory[selected], k-file[selected]');
315
+ const $currentSelection = this.closest('k-directory-viewer[root]').querySelector('k-directory-viewer[selected], k-directory-viewer-file[selected]');
387
316
  if($currentSelection === this) return;
388
317
  if($currentSelection) $currentSelection.selected = false;
389
318
  this.selected = true;
390
- this.dispatchEvent(new CustomEvent('fileSelected', {
319
+ this.dispatchEvent(new CustomEvent('fileselected', {
391
320
  detail: {
392
321
  fileHandle: this[handle],
393
322
  fileComponent: this
@@ -1,4 +1,5 @@
1
1
  import LazyComponent from './LazyComponent.js';
2
+ import { onEvent } from '../utils/element.js';
2
3
 
3
4
  export default class FocusCapture extends LazyComponent {
4
5
  constructor(){
@@ -8,7 +9,7 @@ export default class FocusCapture extends LazyComponent {
8
9
  }
9
10
  render(){
10
11
  super.render();
11
- this.shadowRoot.getElementById('after').addEventListener('focus', () => {
12
+ onEvent(this.shadowRoot.getElementById('after'), 'focus', () => {
12
13
  this.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])').focus();
13
14
  });
14
15
  }
@@ -4,7 +4,10 @@ import debounce from '../utils/debounce.js';
4
4
  const inputHandler = Symbol('inputHandler'),
5
5
  focusHandler = Symbol('focusHandler'),
6
6
  blurHandler = Symbol('blurHandler');
7
+
7
8
  export default class Search extends Component {
9
+ static searchDataUrl = '/search.json';
10
+
8
11
  constructor(){
9
12
  super();
10
13
 
@@ -25,7 +28,7 @@ export default class Search extends Component {
25
28
  }
26
29
  async render(force){
27
30
  if(await super.render(force)){
28
- this.pages = await (await fetch('/search.json')).json();
31
+ this.pages = await (await fetch(Search.searchDataUrl)).json();
29
32
  const $input = this.shadowRoot.getElementById('input')
30
33
  $input.addEventListener('input', this[inputHandler]);
31
34
  $input.addEventListener('focus', this[focusHandler]);
@@ -2,17 +2,20 @@ import Component from './Component.js'
2
2
  import formatTimestamp from '../utils/formatTimestamp.js';
3
3
 
4
4
  export default class Timestamp extends Component {
5
- constructor(timestamp){
5
+ constructor(timestamp = 0, format = '', locale = ''){
6
6
  super();
7
- this.registerAttribute('timestamp', 0);
8
- if(timestamp) this.timestamp = timestamp;
7
+ this.registerAttributes({
8
+ timestamp,
9
+ locale,
10
+ format
11
+ });
9
12
  }
10
13
 
11
14
  /* Lifecycle Callbacks */
12
15
  attributeChangedCallback(n, oV, nV){
13
16
  if(n == 'timestamp'){
14
17
  if(nV){
15
- this.innerHTML = formatTimestamp(nV, 'en-US');
18
+ this.innerHTML = formatTimestamp(nV, this.format, this.locale || navigator.language);
16
19
  } else {
17
20
  this.innerHTML = '';
18
21
  }
@@ -45,15 +45,18 @@ export default class Toggle extends Component {
45
45
  on(){
46
46
  this.value = true;
47
47
  dispatchEvent(this, 'on', { value: true });
48
+ return this;
48
49
  }
49
50
  off(){
50
51
  this.value = false;
51
52
  dispatchEvent(this, 'on', { value: false });
53
+ return this;
52
54
  }
53
55
  toggle(){
54
56
  if(this.value) this.off();
55
57
  else this.on();
56
58
  dispatchEvent(this, 'toggle', { value: this.value });
59
+ return this;
57
60
  }
58
61
 
59
62
  get shadowTemplate(){
@@ -1,11 +1,27 @@
1
- export default (timestamp, forceLocale) => {
2
- return Intl.DateTimeFormat(forceLocale || navigator.language, {
3
- year: 'numeric',
4
- month: '2-digit',
5
- day: '2-digit',
6
- hour: '2-digit',
7
- minute: '2-digit',
8
- second: '2-digit',
9
- millisecond: '3-digit'
10
- }).format(new Date(parseInt(timestamp)));
1
+ export default (timestamp, format, forceLocale) => {
2
+ const date = new Date(parseInt(timestamp));
3
+ if (format) {
4
+ const pad = (num, size) => ('000' + num).slice(size * -1);
5
+ const tokens = {
6
+ YYYY: date.getFullYear(),
7
+ YY: String(date.getFullYear()).slice(-2),
8
+ MM: pad(date.getMonth() + 1, 2),
9
+ M: date.getMonth() + 1,
10
+ DD: pad(date.getDate(), 2),
11
+ D: date.getDate(),
12
+ hh: pad(date.getHours(), 2),
13
+ h: date.getHours(),
14
+ mm: pad(date.getMinutes(), 2),
15
+ m: date.getMinutes(),
16
+ ss: pad(date.getSeconds(), 2),
17
+ s: date.getSeconds(),
18
+ iiii: pad(date.getMilliseconds(), 3),
19
+ iii: pad(date.getMilliseconds(), 3),
20
+ ii: pad(date.getMilliseconds(), 2),
21
+ i: date.getMilliseconds()
22
+ };
23
+ return format.replace(/YYYY|YY|MM|M|DD|D|hh|h|mm|m|ss|s|iiii|iii|ii|i/g, (matched) => tokens[matched]);
24
+ } else {
25
+ return date.toLocaleString(forceLocale || navigator.language);
26
+ }
11
27
  }
package/docs/table.html DELETED
File without changes
@@ -1,79 +0,0 @@
1
- import Component from './Component.js';
2
-
3
- export default class Stacks extends Component {
4
-
5
- /* Public Members */
6
- get panels(){
7
- return [...this.querySelectorAll('k-stack-panel')];
8
- }
9
-
10
- /* Public Methods */
11
- reorderPanels(){
12
- const panels = this.panels;
13
- panels.reverse().forEach((panel, index) => panel.style.setProperty('--order', index));
14
- }
15
-
16
- /* Shadow DOM */
17
- get shadowStyles(){
18
- return /*css*/`
19
- :host {
20
- --stack_width: 16rem;
21
- display: block;
22
- height: 100%;
23
- position: relative;
24
- }
25
- `;
26
- }
27
- }
28
- window.customElements.define('k-stacks', Stacks);
29
-
30
- export class StackPanel extends Component {
31
- constructor(){
32
- super();
33
-
34
- this.registerAttribute('stack', 0);
35
- }
36
-
37
- /* Lifecycle Callbacks */
38
- connectedCallback(){
39
- super.connectedCallback();
40
- const stacks = this.stacks;
41
- if(stacks) stacks.reorderPanels();
42
- }
43
- attributeChangedCallback(n, oV, nV){
44
- super.attributeChangedCallback(n, oV, nV);
45
- if(n ==='stack' && oV !== nV){
46
- this.style.setProperty('--stack', nV);
47
- }
48
- }
49
-
50
- /* Protected Members */
51
- get stacks(){
52
- return this.closest('k-stacks');
53
- }
54
-
55
-
56
- /* Shadow DOM */
57
- get shadowStyles(){
58
- return /*css*/`
59
- :host {
60
- --stack: 0;
61
- display: block;
62
- height: 100%;
63
- width: var(--stack_width);
64
- position: absolute;
65
- top: 0;
66
- left: calc(var(--stack) * var(--stack_width));
67
- transition: left var(--animation_ms) ease-in-out;
68
- z-index: var(--order);
69
- }
70
- `;
71
- }
72
-
73
- /* Static Members */
74
- static observedAttributes = [
75
- ...super.observedAttributes,
76
- 'stack'
77
- ];
78
- }
79
- window.customElements.define('k-stack-panel', StackPanel);
@@ -1,15 +0,0 @@
1
- export const getDir = async () => {
2
-
3
- }
4
- let id,
5
- interval = 1000;
6
- const watchers = new Map();
7
- const poll = () => {
8
-
9
- };
10
- export const watchDir = async (dirHandle, callback, interval = 1000) => {
11
-
12
- }
13
- export const unwatchDir = async (dirHandle, callback) => {
14
-
15
- }