kempo-ui 0.0.41 → 0.0.43

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 (137) hide show
  1. package/dist/components/Accordion.js +1 -1
  2. package/dist/components/ContentSlider.js +2 -2
  3. package/dist/components/Icon.js +34 -2
  4. package/dist/components/Main.js +24 -0
  5. package/dist/components/PhotoViewer.js +2 -2
  6. package/dist/components/ShowMore.js +8 -8
  7. package/dist/components/SidePanel.js +225 -0
  8. package/dist/components/Table.js +1 -1
  9. package/dist/components/tableControls/FirstPage.js +1 -1
  10. package/dist/components/tableControls/LastPage.js +1 -1
  11. package/dist/components/tableControls/NextPage.js +1 -1
  12. package/dist/components/tableControls/PrevPage.js +1 -1
  13. package/dist/utils/theme.js +1 -1
  14. package/docs/components/accordion.html +0 -1
  15. package/docs/components/card.html +0 -1
  16. package/docs/components/content-slider.html +0 -1
  17. package/docs/components/dialog.html +0 -1
  18. package/docs/components/dropdown.html +0 -1
  19. package/docs/components/focus-capture.html +0 -1
  20. package/docs/components/hybrid-component.html +0 -1
  21. package/docs/components/icon.html +50 -5
  22. package/docs/components/import.html +0 -1
  23. package/docs/components/light-component.html +0 -1
  24. package/docs/components/photo-viewer.html +0 -1
  25. package/docs/components/resize.html +0 -1
  26. package/docs/components/shadow-component.html +0 -1
  27. package/docs/components/show-more.html +0 -1
  28. package/docs/components/side-menu.html +0 -1
  29. package/docs/components/side-panel-basic.html +44 -0
  30. package/docs/components/side-panel-menu.html +50 -0
  31. package/docs/components/side-panel.html +186 -0
  32. package/docs/components/sortable.html +0 -1
  33. package/docs/components/spinner.html +0 -1
  34. package/docs/components/split.html +0 -1
  35. package/docs/components/table.html +24 -25
  36. package/docs/components/tableControls.html +0 -1
  37. package/docs/components/tableCustomFields.html +0 -1
  38. package/docs/components/tableFetchRecords.html +0 -1
  39. package/docs/components/tableFieldSortHide.html +0 -1
  40. package/docs/components/tablePagination.html +0 -1
  41. package/docs/components/tableRecordEditing.html +0 -1
  42. package/docs/components/tableRecordFiltering.html +0 -1
  43. package/docs/components/tableRecordHiding.html +0 -1
  44. package/docs/components/tableRecordSearching.html +0 -1
  45. package/docs/components/tableRecordSelection.html +0 -1
  46. package/docs/components/tableRowControls.html +0 -1
  47. package/docs/components/tableSorting.html +0 -1
  48. package/docs/components/tabs.html +0 -1
  49. package/docs/components/tags.html +0 -1
  50. package/docs/components/theme-switcher.html +0 -1
  51. package/docs/components/timestamp.html +0 -1
  52. package/docs/components/toast.html +0 -1
  53. package/docs/components/toggle.html +0 -1
  54. package/docs/components/tree.html +0 -1
  55. package/docs/dev.config.json +8 -1
  56. package/docs/icons/account-circle.svg +1 -0
  57. package/docs/icons/arrow-circle.svg +1 -0
  58. package/docs/icons/arrow-line.svg +1 -0
  59. package/docs/icons/arrow-menu-close.svg +1 -0
  60. package/docs/icons/arrow-menu-open.svg +1 -0
  61. package/docs/icons/arrow.svg +1 -0
  62. package/docs/icons/chevron-double.svg +1 -0
  63. package/docs/icons/chevron-line.svg +1 -0
  64. package/docs/icons/chevron-up.svg +1 -0
  65. package/docs/icons/key.svg +1 -0
  66. package/docs/icons/login.svg +1 -0
  67. package/docs/icons/logout.svg +1 -0
  68. package/docs/index.html +6 -1
  69. package/docs/nav-1.inc.html +1 -0
  70. package/docs/nav.inc.html +1 -0
  71. package/docs/prod.config.json +4 -0
  72. package/docs/src/components/Accordion.js +1 -1
  73. package/docs/src/components/ContentSlider.js +2 -2
  74. package/docs/src/components/Icon.js +34 -2
  75. package/docs/src/components/Main.js +24 -0
  76. package/docs/src/components/PhotoViewer.js +2 -2
  77. package/docs/src/components/ShowMore.js +8 -8
  78. package/docs/src/components/SidePanel.js +225 -0
  79. package/docs/src/components/Table.js +1 -1
  80. package/docs/src/components/tableControls/FirstPage.js +1 -1
  81. package/docs/src/components/tableControls/LastPage.js +1 -1
  82. package/docs/src/components/tableControls/NextPage.js +1 -1
  83. package/docs/src/components/tableControls/PrevPage.js +1 -1
  84. package/docs/src/utils/theme.js +1 -1
  85. package/docs/utils/context.html +0 -1
  86. package/docs/utils/debounce.html +0 -1
  87. package/docs/utils/drag.html +0 -1
  88. package/docs/utils/formatTimestamp.html +0 -1
  89. package/docs/utils/object.html +0 -1
  90. package/docs/utils/propConverters.html +0 -1
  91. package/docs/utils/string.html +0 -1
  92. package/docs/utils/theme.html +0 -1
  93. package/docs/utils/toTitleCase.html +0 -1
  94. package/docs/utils/type.html +0 -1
  95. package/docs/utils/wait.html +0 -1
  96. package/icons/account-circle.svg +1 -0
  97. package/icons/arrow-circle.svg +1 -0
  98. package/icons/arrow-line.svg +1 -0
  99. package/icons/arrow.svg +1 -0
  100. package/icons/chevron-double.svg +1 -0
  101. package/icons/chevron-line.svg +1 -0
  102. package/icons/chevron.svg +1 -0
  103. package/icons/key.svg +1 -0
  104. package/icons/login.svg +1 -0
  105. package/icons/logout.svg +1 -0
  106. package/package.json +1 -1
  107. package/scripts/build.js +0 -7
  108. package/src/components/Accordion.js +1 -1
  109. package/src/components/ContentSlider.js +2 -2
  110. package/src/components/Icon.js +64 -4
  111. package/src/components/Main.js +87 -0
  112. package/src/components/PhotoViewer.js +2 -2
  113. package/src/components/ShowMore.js +8 -8
  114. package/src/components/SidePanel.js +454 -0
  115. package/src/components/Table.js +1 -1
  116. package/src/components/tableControls/FirstPage.js +1 -1
  117. package/src/components/tableControls/LastPage.js +1 -1
  118. package/src/components/tableControls/NextPage.js +1 -1
  119. package/src/components/tableControls/PrevPage.js +1 -1
  120. package/src/utils/theme.js +22 -9
  121. package/tests/components/Icon.browser-test.js +205 -0
  122. package/tests/components/Main.browser-test.js +345 -0
  123. package/tests/components/SidePanel.browser-test.js +466 -0
  124. package/tests/components/tableControls/PaginationControls.browser-test.js +10 -10
  125. package/dist/kempo-vars.css +0 -1
  126. package/docs/init-1.js +0 -4
  127. package/docs/init.js +0 -4
  128. package/docs/src/kempo-vars.css +0 -1
  129. package/icons/arrow-back.svg +0 -1
  130. package/icons/arrow-down-double.svg +0 -1
  131. package/icons/arrow-down.svg +0 -1
  132. package/icons/arrow-up-double.svg +0 -1
  133. package/icons/arrow-up.svg +0 -1
  134. package/icons/chevron-left.svg +0 -1
  135. package/src/kempo-vars.css +0 -1
  136. /package/{icons/arrow-forward.svg → docs/icons/arrow-right.svg} +0 -0
  137. /package/{icons/chevron-right.svg → docs/icons/chevron.svg} +0 -0
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M800-240v-480h80v480h-80Zm-320 0-57-56 144-144H80v-80h487L424-664l56-56 240 240-240 240Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M647-440H160v-80h487L423-744l57-56 320 320-320 320-57-56 224-224Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M383-480 200-664l56-56 240 240-240 240-56-56 183-184Zm264 0L464-664l56-56 240 240-240 240-56-56 183-184Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="m280-240-56-56 184-184-184-184 56-56 240 240-240 240Zm360 0v-480h80v480h-80Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"/></svg>
package/icons/key.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M280-400q-33 0-56.5-23.5T200-480q0-33 23.5-56.5T280-560q33 0 56.5 23.5T360-480q0 33-23.5 56.5T280-400Zm0 160q-100 0-170-70T40-480q0-100 70-170t170-70q67 0 121.5 33t86.5 87h352l120 120-180 180-80-60-80 60-85-60h-47q-32 54-86.5 87T280-240Zm0-80q56 0 98.5-34t56.5-86h125l58 41 82-61 71 55 75-75-40-40H435q-14-52-56.5-86T280-640q-66 0-113 47t-47 113q0 66 47 113t113 47Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M480-120v-80h280v-560H480v-80h280q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H480Zm-80-160-55-58 102-102H120v-80h327L345-622l55-58 200 200-200 200Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h280v80H200Zm440-160-55-58 102-102H360v-80h327L585-622l55-58 200 200-200 200Z"/></svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kempo-ui",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "type": "module",
5
5
  "description": "A Lit based web-component library",
6
6
  "main": "index.js",
package/scripts/build.js CHANGED
@@ -85,13 +85,6 @@ await Promise.all(allJSFiles.map(async jsFile => {
85
85
  }));
86
86
  process.stdout.write("\n");
87
87
 
88
- console.log('Loading kempo-vars.css');
89
- const kempoVarsCSS = await fs.readFile('./src/kempo-vars.css', 'utf-8');
90
- console.log('Minifying kempo-vars.css');
91
- const minifiedKempoVarsCSS = kempoVarsCSS.replace(/\s*\{\s*/g, '{').replace(/\s*\}\s*/g, '}').replace(/\n/g, '').replace(/\r/g, '').replace(/\s+/g, ' ').replace(/\s*\:\s*/g, ':').replace(/\s*\;\s*/g, ';').replace(/;\}/g, '}');
92
- console.log('Saving kempo-vars.css');
93
- await fs.writeFile('./dist/kempo-vars.css', minifiedKempoVarsCSS, 'utf-8');
94
-
95
88
  console.log('Cleaning docs/src/ directory');
96
89
  await emptyDir('./docs/src/');
97
90
 
@@ -232,7 +232,7 @@ export class AccordionHeader extends ShadowComponent {
232
232
  render() {
233
233
  return html`
234
234
  <slot name="left-icon">
235
- <k-icon id="icon" name="chevron-right"></k-icon>
235
+ <k-icon id="icon" name="chevron"></k-icon>
236
236
  </slot>
237
237
  <slot></slot>
238
238
  <slot name="right-icon"></slot>
@@ -183,7 +183,7 @@ export default class ContentSlider extends ShadowComponent {
183
183
  @click=${this.handlePrevClick}
184
184
  >
185
185
  <slot name="prev">
186
- <k-icon name="chevron-left"></k-icon>
186
+ <k-icon name="chevron" direction="left"></k-icon>
187
187
  </slot>
188
188
  </button>
189
189
  <button
@@ -192,7 +192,7 @@ export default class ContentSlider extends ShadowComponent {
192
192
  @click=${this.handleNextClick}
193
193
  >
194
194
  <slot name="next">
195
- <k-icon name="chevron-right"></k-icon>
195
+ <k-icon name="chevron"></k-icon>
196
196
  </slot>
197
197
  </button>
198
198
  </div>
@@ -26,11 +26,15 @@ const getIconByPath = async (path) => {
26
26
  };
27
27
 
28
28
  const getIconByName = (name) => {
29
- const tryDir = async (dir) => getIconByPath(`${dir}/${name}.svg`);
29
+ const tryDir = async (dir) => {
30
+ // Ensure single slash between dir and filename
31
+ const normalizedDir = dir.endsWith('/') ? dir.slice(0, -1) : dir;
32
+ return getIconByPath(`${normalizedDir}/${name}.svg`);
33
+ };
30
34
 
31
35
  return new Promise(async (resolve, reject) => {
32
36
  let svg;
33
- const pathsToCheck = window.kempo?.pathsToIcons || ['/icons'];
37
+ const pathsToCheck = window.kempo?.pathsToIcons || ['/icons', '../../icons', 'https://cdn.jsdelivr.net/npm/kempo-ui@0.0.32/icons/'];
34
38
  for(let i = 0; i < pathsToCheck.length && !svg; i++){
35
39
  try {
36
40
  svg = await tryDir(pathsToCheck[i]);
@@ -49,6 +53,9 @@ export default class Icon extends ShadowComponent {
49
53
  static properties = {
50
54
  src: { type: String, reflect: true },
51
55
  name: { type: String, reflect: true },
56
+ rotation: { type: String, reflect: true },
57
+ direction: { type: String, reflect: true },
58
+ animation: { type: String, reflect: true },
52
59
  iconContent: { type: String }
53
60
  };
54
61
 
@@ -56,6 +63,9 @@ export default class Icon extends ShadowComponent {
56
63
  super();
57
64
  this.src = '';
58
65
  this.name = name;
66
+ this.rotation = '';
67
+ this.direction = '';
68
+ this.animation = '';
59
69
  this.iconContent = '';
60
70
  }
61
71
 
@@ -119,6 +129,21 @@ export default class Icon extends ShadowComponent {
119
129
  return svgString;
120
130
  }
121
131
 
132
+ /*
133
+ Utility Methods
134
+ */
135
+ getRotationDegrees() {
136
+ if(this.rotation) return this.rotation;
137
+
138
+ const directionMap = {
139
+ 'down': '90',
140
+ 'left': '180',
141
+ 'up': '270'
142
+ };
143
+
144
+ return directionMap[this.direction] || '0';
145
+ }
146
+
122
147
  /*
123
148
  Styles
124
149
  */
@@ -131,18 +156,53 @@ export default class Icon extends ShadowComponent {
131
156
  height: 1.35em;
132
157
  vertical-align: middle;
133
158
  }
159
+
160
+ /* Rotation */
161
+ :host([rotation]) svg,
162
+ :host([direction]) svg {
163
+ transform: rotate(var(--icon-rotation, 0deg));
164
+ }
165
+
166
+ /* Animations */
167
+ :host([animation="spin"]) svg {
168
+ animation: icon-spin 2s linear infinite;
169
+ }
170
+ :host([animation="blink"]) svg {
171
+ animation: icon-blink 1s ease-in-out infinite;
172
+ }
173
+ :host([animation="pulse"]) svg {
174
+ animation: icon-pulse 1.5s ease-in-out infinite;
175
+ }
176
+
177
+ @keyframes icon-spin {
178
+ from { transform: rotate(0deg); }
179
+ to { transform: rotate(360deg); }
180
+ }
181
+
182
+ @keyframes icon-blink {
183
+ 0%, 100% { opacity: 1; }
184
+ 50% { opacity: 0.2; }
185
+ }
186
+
187
+ @keyframes icon-pulse {
188
+ 0%, 100% { transform: scale(1); }
189
+ 50% { transform: scale(1.2); }
190
+ }
134
191
  `;
135
192
 
136
193
  /*
137
194
  Rendering
138
195
  */
139
196
  render() {
197
+ const rotationDegrees = this.getRotationDegrees();
198
+ const style = rotationDegrees !== '0' ? `--icon-rotation: ${rotationDegrees}deg;` : '';
199
+
140
200
  if (!this.iconContent) {
141
201
  // Show slotted content while loading
142
- return html`<slot></slot>`;
202
+ return html`<div style="${style}"><slot></slot></div>`;
143
203
  }
144
204
 
145
- return html`${unsafeHTML(this.iconContent)}`;
205
+ return html`<div style="${style}">${unsafeHTML(this.iconContent)}</div>`;
146
206
  }
147
207
  }
148
208
 
@@ -0,0 +1,87 @@
1
+ import ShadowComponent from './ShadowComponent.js';
2
+ import { html, css } from '../lit-all.min.js';
3
+
4
+ export default class Main extends ShadowComponent {
5
+ static properties = {
6
+ panelWidth: { type: String, state: true },
7
+ panelSide: { type: String, state: true }
8
+ };
9
+
10
+ constructor() {
11
+ super();
12
+ this.panelWidth = '0px';
13
+ this.panelSide = 'left';
14
+ this.handlePanelChange = this.handlePanelChange.bind(this);
15
+ }
16
+
17
+ /*
18
+ Lifecycle Callbacks
19
+ */
20
+ connectedCallback() {
21
+ super.connectedCallback();
22
+ window.addEventListener('side-panel-change', this.handlePanelChange);
23
+
24
+ const panel = document.querySelector('k-side-panel');
25
+ if(panel) {
26
+ this.panelWidth = panel.collapsed ? '3.5rem' : '16rem';
27
+ this.panelSide = panel.side || 'left';
28
+ }
29
+ }
30
+
31
+ disconnectedCallback() {
32
+ super.disconnectedCallback();
33
+ window.removeEventListener('side-panel-change', this.handlePanelChange);
34
+ }
35
+
36
+ /*
37
+ Event Handlers
38
+ */
39
+ handlePanelChange(event) {
40
+ this.panelWidth = event.detail.width;
41
+ this.panelSide = event.detail.side;
42
+ }
43
+
44
+ /*
45
+ Rendering
46
+ */
47
+ render() {
48
+ return html`
49
+ <main>
50
+ <slot></slot>
51
+ </main>
52
+ `;
53
+ }
54
+
55
+ static styles = css`
56
+ :host {
57
+ display: block;
58
+ margin-left: var(--panel-width, 0px);
59
+ transition: margin-left var(--animation_ms, 256ms);
60
+ }
61
+ :host([panel-side="right"]) {
62
+ margin-left: 0;
63
+ margin-right: var(--panel-width, 0px);
64
+ transition: margin-right var(--animation_ms, 256ms);
65
+ }
66
+ main {
67
+ max-width: var(--container_width, 90rem);
68
+ margin-left: auto;
69
+ margin-right: auto;
70
+ padding-top: var(--spacer);
71
+ padding-left: var(--spacer);
72
+ padding-right: var(--spacer);
73
+ }
74
+ `;
75
+
76
+ updated() {
77
+ super.updated();
78
+ this.style.setProperty('--panel-width', this.panelWidth);
79
+ if(this.panelSide === 'right') {
80
+ this.setAttribute('panel-side', 'right');
81
+ } else {
82
+ this.removeAttribute('panel-side');
83
+ }
84
+ }
85
+ }
86
+
87
+ window.customElements.define('k-main', Main);
@@ -343,12 +343,12 @@ export default class PhotoViewer extends ShadowComponent {
343
343
  </button>
344
344
  <button id="prev" class="nav-btn no-btn" @click=${this.handlePrevClick}>
345
345
  <slot name="prev">
346
- <k-icon name="chevron-left"></k-icon>
346
+ <k-icon name="chevron" direction="left"></k-icon>
347
347
  </slot>
348
348
  </button>
349
349
  <button id="next" class="nav-btn no-btn" @click=${this.handleNextClick}>
350
350
  <slot name="next">
351
- <k-icon name="chevron-right"></k-icon>
351
+ <k-icon name="chevron"></k-icon>
352
352
  </slot>
353
353
  </button>
354
354
  <div class="content">
@@ -91,14 +91,14 @@ export default class ShowMore extends ShadowComponent {
91
91
  <div id="content">
92
92
  <slot></slot>
93
93
  </div>
94
- <button id="toggle" @click=${this.handleToggleClick} class="no-btn">
95
- <span id="more">
96
- <slot name="more">Show More <k-icon name="arrow-down-double"></k-icon></slot>
97
- </span>
98
- <span id="less">
99
- <slot name="less">Show Less <k-icon name="arrow-up-double"></k-icon></slot>
100
- </span>
101
- </button>
94
+ <button id="toggle" @click=${this.handleToggleClick} class="no-btn">
95
+ <span id="more">
96
+ <slot name="more">Show More <k-icon name="chevron-double" direction="down"></k-icon></slot>
97
+ </span>
98
+ <span id="less">
99
+ <slot name="less">Show Less <k-icon name="chevron-double" direction="up"></k-icon></slot>
100
+ </span>
101
+ </button>
102
102
  </div>
103
103
  `;
104
104
  }