jb-grid 0.4.1 → 0.5.0

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 (117) hide show
  1. package/README.md +138 -11
  2. package/package.json +5 -8
  3. package/react/README.md +207 -202
  4. package/react/dist/Content.d.ts +1 -2
  5. package/react/dist/Footer.d.ts +1 -2
  6. package/react/dist/Header.d.ts +3 -16
  7. package/react/dist/JBGrid.cjs.js +3631 -1
  8. package/react/dist/JBGrid.cjs.js.map +1 -1
  9. package/react/dist/JBGrid.d.ts +288 -26
  10. package/react/dist/JBGrid.js +3624 -1
  11. package/react/dist/JBGrid.js.map +1 -1
  12. package/react/dist/JBGrid.umd.js +3641 -1
  13. package/react/dist/JBGrid.umd.js.map +1 -1
  14. package/react/dist/JBGridData.d.ts +1 -5
  15. package/react/dist/JBGridViewModel.d.ts +28 -25
  16. package/react/dist/types.d.ts +17 -49
  17. package/react/lib/Components/Cell.tsx +17 -15
  18. package/react/lib/Components/ColumnHeader.tsx +44 -0
  19. package/react/lib/Components/ExpandToggle.tsx +14 -10
  20. package/react/lib/Components/FullscreenIcon.tsx +28 -0
  21. package/react/lib/Components/JBLoading.tsx +5 -4
  22. package/react/lib/Components/Pagination.tsx +1 -1
  23. package/react/lib/Components/PaginationInfo.tsx +71 -0
  24. package/react/lib/Components/RefreshIcon.tsx +11 -0
  25. package/react/lib/Components/Row.tsx +17 -15
  26. package/react/lib/Components/TableHeader.tsx +21 -0
  27. package/react/lib/Components/blob-loading.css +27 -23
  28. package/react/lib/Components/cell.css +7 -7
  29. package/react/lib/Components/content-error/ContentError.tsx +19 -16
  30. package/react/lib/Components/content-error/content-error.css +5 -11
  31. package/react/lib/Components/module-declaration.ts +61 -13
  32. package/react/lib/Content.tsx +23 -47
  33. package/react/lib/Footer.tsx +52 -79
  34. package/react/lib/Header.tsx +11 -24
  35. package/react/lib/JBGrid.tsx +129 -70
  36. package/react/lib/JBGridViewModel.ts +189 -452
  37. package/react/lib/footer.css +25 -55
  38. package/react/lib/header.css +20 -20
  39. package/react/lib/jb-grid.css +69 -55
  40. package/react/lib/types.ts +32 -129
  41. package/react/lib/variables.css +6 -0
  42. package/react/package.json +14 -10
  43. package/react/tsconfig.json +5 -4
  44. package/web-component/dist/index.cjs.js +559 -1
  45. package/web-component/dist/index.cjs.js.br +0 -0
  46. package/web-component/dist/index.cjs.js.gz +0 -0
  47. package/web-component/dist/index.cjs.js.map +1 -1
  48. package/web-component/dist/index.d.ts +161 -4
  49. package/web-component/dist/index.d.ts.map +1 -1
  50. package/web-component/dist/index.js +561 -1
  51. package/web-component/dist/index.js.br +0 -0
  52. package/web-component/dist/index.js.gz +0 -0
  53. package/web-component/dist/index.js.map +1 -1
  54. package/web-component/dist/index.umd.js +567 -1
  55. package/web-component/dist/index.umd.js.br +0 -0
  56. package/web-component/dist/index.umd.js.gz +0 -0
  57. package/web-component/dist/index.umd.js.map +1 -1
  58. package/web-component/dist/row/row.d.ts.map +1 -1
  59. package/web-component/dist/row/types.d.ts +3 -5
  60. package/web-component/dist/row/types.d.ts.map +1 -1
  61. package/web-component/dist/row/utils.d.ts +1 -2
  62. package/web-component/dist/row/utils.d.ts.map +1 -1
  63. package/web-component/dist/table-header/render.d.ts +2 -0
  64. package/web-component/dist/table-header/render.d.ts.map +1 -0
  65. package/web-component/dist/table-header/table-header.d.ts +9 -0
  66. package/web-component/dist/table-header/table-header.d.ts.map +1 -0
  67. package/web-component/dist/table-header/types.d.ts +4 -0
  68. package/web-component/dist/table-header/types.d.ts.map +1 -0
  69. package/web-component/dist/types.d.ts +6 -0
  70. package/web-component/dist/types.d.ts.map +1 -0
  71. package/web-component/dist/utils.d.ts +8 -0
  72. package/web-component/dist/utils.d.ts.map +1 -0
  73. package/web-component/lib/cell/cell.ts +10 -5
  74. package/web-component/lib/cell/style.css +2 -1
  75. package/web-component/lib/column-header/column-header.ts +117 -0
  76. package/web-component/lib/column-header/render.ts +14 -0
  77. package/web-component/lib/column-header/style.css +60 -0
  78. package/web-component/lib/column-header/types.ts +10 -0
  79. package/web-component/lib/fullscreen-icon/fullscreen-icon.ts +72 -0
  80. package/web-component/lib/fullscreen-icon/render.ts +23 -0
  81. package/web-component/lib/fullscreen-icon/style.css +44 -0
  82. package/web-component/lib/fullscreen-icon/types.ts +1 -0
  83. package/web-component/lib/i18n.ts +38 -0
  84. package/web-component/lib/index.ts +9 -4
  85. package/web-component/lib/pagination/README.md +4 -0
  86. package/web-component/lib/pagination/pagination.ts +25 -15
  87. package/web-component/lib/pagination/render.ts +13 -10
  88. package/web-component/lib/pagination/style.css +43 -31
  89. package/web-component/lib/pagination/types.ts +1 -1
  90. package/web-component/lib/pagination/variables.css +10 -0
  91. package/web-component/lib/pagination-info/pagination-info.ts +191 -0
  92. package/web-component/lib/pagination-info/render.ts +16 -0
  93. package/web-component/lib/pagination-info/style.css +47 -0
  94. package/web-component/lib/pagination-info/types.ts +12 -0
  95. package/web-component/lib/refresh-icon/refresh-icon.ts +79 -0
  96. package/web-component/lib/refresh-icon/render.ts +10 -0
  97. package/web-component/lib/refresh-icon/style.css +21 -0
  98. package/web-component/lib/row/render.ts +3 -3
  99. package/web-component/lib/row/row.ts +29 -15
  100. package/web-component/lib/row/style.css +30 -30
  101. package/web-component/lib/row/types.ts +7 -8
  102. package/web-component/lib/row/utils.ts +1 -40
  103. package/web-component/lib/row/variables.css +13 -0
  104. package/web-component/lib/table-header/render.ts +9 -0
  105. package/web-component/lib/table-header/style.css +29 -0
  106. package/web-component/lib/table-header/table-header.ts +50 -0
  107. package/web-component/lib/table-header/types.ts +4 -0
  108. package/web-component/lib/toggle/expand-toggle.ts +17 -13
  109. package/web-component/lib/toggle/render.ts +18 -13
  110. package/web-component/lib/toggle/style.css +18 -5
  111. package/web-component/lib/types.ts +6 -0
  112. package/web-component/lib/utils.ts +46 -0
  113. package/react/lib/JBGridBridgeExample.js +0 -90
  114. package/react/lib/JBGridData.ts +0 -51
  115. package/react/lib/global.d.ts +0 -15
  116. package/web-component/lib/global.d.ts +0 -15
  117. package/web-component/tsconfig.json +0 -17
@@ -0,0 +1,47 @@
1
+ :host {
2
+ display: block;
3
+ height: 100%;
4
+ color: #7b7b7b;
5
+ font-size: 1rem;
6
+ container-type: inline-size;
7
+ }
8
+
9
+ .jb-pagination-info-web-component {
10
+ display: flex;
11
+ align-items: center;
12
+ height: 100%;
13
+ }
14
+
15
+ .page-size-section {
16
+ padding: 0 1rem;
17
+ display: flex;
18
+ align-items: center;
19
+ height: 100%;
20
+ }
21
+
22
+ .page-size-select {
23
+ background-color: transparent;
24
+ font-family: inherit;
25
+ color: inherit;
26
+ font-size: inherit;
27
+ border: none;
28
+ }
29
+
30
+ .items-information-section {
31
+ display: flex;
32
+ align-items: center;
33
+ height: 100%;
34
+ white-space: nowrap;
35
+ }
36
+
37
+ @container (max-width: 16.25rem) {
38
+ .page-size-section {
39
+ display: none;
40
+ }
41
+ }
42
+
43
+ @container (max-width: 10rem) {
44
+ .items-information-section {
45
+ display: none;
46
+ }
47
+ }
@@ -0,0 +1,12 @@
1
+ export type JBPaginationInfoElements = {
2
+ pageSizeSelect: HTMLSelectElement,
3
+ pageSizeSection: HTMLElement,
4
+ startItemIndex: HTMLSpanElement,
5
+ endItemIndex: HTMLSpanElement,
6
+ fromLabel: HTMLSpanElement,
7
+ totalItemsCount: HTMLSpanElement,
8
+ }
9
+
10
+ export type JBPaginationInfoPageSizeChangeEventDetail = {
11
+ pageSize: number
12
+ }
@@ -0,0 +1,79 @@
1
+ import { renderHTML } from './render.js';
2
+ import CSS from './style.css';
3
+ import { registerDefaultVariables } from 'jb-core/theme';
4
+ import { i18n } from "jb-core/i18n";
5
+ import { dictionary } from "../i18n";
6
+
7
+ export class JBRefreshIconWebComponent extends HTMLElement {
8
+ #internals?: ElementInternals;
9
+ #icon!: SVGSVGElement;
10
+ #animation: Animation | null = null;
11
+ #animationDuration = 400;
12
+
13
+ constructor() {
14
+ super();
15
+ if (typeof this.attachInternals === "function") {
16
+ this.#internals = this.attachInternals();
17
+ this.#internals.role = "img";
18
+ this.#internals.ariaLabel = dictionary.get(i18n, "refreshData");
19
+ this.#internals.ariaBusy = "false";
20
+ }
21
+ this.#init();
22
+ }
23
+
24
+ #init() {
25
+ const shadowRoot = this.attachShadow({ mode: 'open', delegatesFocus: true, clonable: true, serializable: true });
26
+ registerDefaultVariables();
27
+ this.#render();
28
+ this.#icon = shadowRoot.querySelector(".refresh-icon")!;
29
+ }
30
+
31
+ #render() {
32
+ const html = `<style>${CSS}</style>\n${renderHTML()}`;
33
+ const element = document.createElement("template");
34
+ element.innerHTML = html;
35
+ this.shadowRoot!.appendChild(element.content.cloneNode(true));
36
+ }
37
+
38
+ play() {
39
+ if (this.#internals) this.#internals.ariaBusy = "true";
40
+ if (!this.#animation) {
41
+ this.#animation = this.#icon.animate(
42
+ [{ transform: "rotate(0deg)" }, { transform: "rotate(360deg)" }],
43
+ { id: "rotate", duration: this.#animationDuration, direction: "reverse", iterations: Infinity }
44
+ );
45
+ return;
46
+ }
47
+ this.#animation.effect?.updateTiming({ iterations: Infinity });
48
+ this.#animation.onfinish = null;
49
+ this.#animation.play();
50
+ }
51
+
52
+ pause() {
53
+ this.#animation?.pause();
54
+ }
55
+
56
+ stop() {
57
+ if (!this.#animation) {
58
+ return;
59
+ }
60
+ const animation = this.#animation;
61
+ const currentTime = typeof animation.currentTime === "number" ? animation.currentTime : 0;
62
+ const nextIteration = Math.max(1, Math.floor(currentTime / this.#animationDuration) + 1);
63
+
64
+ animation.effect?.updateTiming({ iterations: nextIteration });
65
+ animation.onfinish = () => {
66
+ if (this.#animation === animation) {
67
+ animation.cancel();
68
+ this.#animation = null;
69
+ if (this.#internals) this.#internals.ariaBusy = "false";
70
+ }
71
+ };
72
+ animation.play();
73
+ }
74
+ }
75
+
76
+ const myElementNotExists = !customElements.get('jb-refresh-icon');
77
+ if (myElementNotExists) {
78
+ window.customElements.define('jb-refresh-icon', JBRefreshIconWebComponent);
79
+ }
@@ -0,0 +1,10 @@
1
+ export function renderHTML(): string {
2
+ return /* html */ `
3
+ <svg class="refresh-icon" x="0px" y="0px" viewBox="0 0 305.836 305.836" part="icon">
4
+ <title>Refresh Data</title>
5
+ <g>
6
+ <path d="M152.924,300.748c84.319,0,152.912-68.6,152.912-152.918c0-39.476-15.312-77.231-42.346-105.564 c0,0,3.938-8.857,8.814-19.783c4.864-10.926-2.138-18.636-15.648-17.228l-79.125,8.289c-13.511,1.411-17.999,11.467-10.021,22.461 l46.741,64.393c7.986,10.992,17.834,12.31,22.008,2.937l7.56-16.964c12.172,18.012,18.976,39.329,18.976,61.459 c0,60.594-49.288,109.875-109.87,109.875c-60.591,0-109.882-49.287-109.882-109.875c0-19.086,4.96-37.878,14.357-54.337 c5.891-10.325,2.3-23.467-8.025-29.357c-10.328-5.896-23.464-2.3-29.36,8.031C6.923,95.107,0,121.27,0,147.829 C0,232.148,68.602,300.748,152.924,300.748z" />
7
+ </g>
8
+ </svg>
9
+ `;
10
+ }
@@ -0,0 +1,21 @@
1
+ :host {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ width: 1.5rem;
6
+ height: 1.5rem;
7
+ color: #7b7b7b;
8
+ }
9
+
10
+ :host(:hover) {
11
+ color: #2e3139;
12
+ }
13
+
14
+ .refresh-icon {
15
+ width: 100%;
16
+ height: 100%;
17
+ display: block;
18
+ fill: currentColor;
19
+ transform-box: fill-box;
20
+ transform-origin: center;
21
+ }
@@ -1,12 +1,12 @@
1
1
  export function renderHTML(): string {
2
2
  return /* html */ `
3
3
  <div class="jb-row-web-component">
4
- <div class="grid-row" part="row">
4
+ <div class="grid-row" part="row">
5
5
  <slot name="cell"></slot>
6
6
  </div>
7
- <div class="expand-wrapper --hidden">
7
+ <div class="expand-wrapper --hidden" role="region" aria-hidden="true">
8
8
  <slot name="expand"></slot>
9
9
  </div>
10
10
  </div>
11
11
  `;
12
- }
12
+ }
@@ -1,11 +1,13 @@
1
- import { renderHTML } from './render.js';
2
- import CSS from './style.css';
1
+ import { renderHTML } from './render.js';
2
+ import CSS from './style.css';
3
+ import VariablesCSS from './variables.css';
3
4
  import { registerDefaultVariables } from 'jb-core/theme';
4
5
  import type { JBRowElements, RowTemplate} from './types.js';
5
6
  import { createTemplateStylesheet } from './utils.js';
6
7
 
7
8
  export * from "./types.js";
8
- export class JBRowWebComponent extends HTMLElement {
9
+ export class JBRowWebComponent extends HTMLElement {
10
+ #internals?: ElementInternals;
9
11
  #elements!: JBRowElements;
10
12
  #templateSheet = new CSSStyleSheet();
11
13
  #RowTemplate:RowTemplate = []
@@ -13,8 +15,10 @@ export class JBRowWebComponent extends HTMLElement {
13
15
  get isOpen(){
14
16
  return this.#isOpen;
15
17
  }
16
- set isOpen(value:boolean){
17
- this.#isOpen = value;
18
+ set isOpen(value:boolean){
19
+ this.#isOpen = value;
20
+ if (this.#internals) this.#internals.ariaExpanded = value ? "true" : "false";
21
+ this.#elements.expandWrapper.setAttribute("aria-hidden", value ? "false" : "true");
18
22
  if(value){
19
23
  this.#elements.expandWrapper.classList.remove('--hidden');
20
24
  }else{
@@ -24,13 +28,20 @@ export class JBRowWebComponent extends HTMLElement {
24
28
  get rowTemplate(){
25
29
  return this.#RowTemplate
26
30
  }
27
- set rowTemplate(value:RowTemplate){
28
- this.#RowTemplate = value;
29
- createTemplateStylesheet(this.#templateSheet,value);
31
+ set rowTemplate(value:RowTemplate){
32
+ this.#RowTemplate = value;
33
+ createTemplateStylesheet(this.#templateSheet, value, {
34
+ selector: ".grid-row",
35
+ autoModeVariableName: "--jb-row-grid-mode"
36
+ });
30
37
  }
31
- constructor() {
32
- super();
33
- this.#init();
38
+ constructor() {
39
+ super();
40
+ if (typeof this.attachInternals === "function") {
41
+ this.#internals = this.attachInternals();
42
+ this.#internals.role = "row";
43
+ }
44
+ this.#init();
34
45
  }
35
46
  #init() {
36
47
  const shadowRoot = this.attachShadow({ mode: 'open', delegatesFocus: true, clonable:true, serializable:true });
@@ -40,11 +51,14 @@ export class JBRowWebComponent extends HTMLElement {
40
51
  this.#elements = {
41
52
  expandWrapper: shadowRoot.querySelector(".expand-wrapper")!
42
53
  }
43
- createTemplateStylesheet(this.#templateSheet,null);
54
+ createTemplateStylesheet(this.#templateSheet, null, {
55
+ selector: ".grid-row",
56
+ autoModeVariableName: "--jb-row-grid-mode"
57
+ });
44
58
  this.#registerEventListener();
45
59
  }
46
- #render() {
47
- const html = `<style>${CSS}</style>\n${renderHTML()}`;
60
+ #render() {
61
+ const html = `<style>${VariablesCSS} ${CSS}</style>\n${renderHTML()}`;
48
62
  const element = document.createElement("template");
49
63
  element.innerHTML = html;
50
64
  this.shadowRoot!.appendChild(element.content.cloneNode(true));
@@ -58,4 +72,4 @@ export class JBRowWebComponent extends HTMLElement {
58
72
  const myElementNotExists = !customElements.get('jb-row');
59
73
  if (myElementNotExists) {
60
74
  window.customElements.define('jb-row', JBRowWebComponent);
61
- }
75
+ }
@@ -1,18 +1,18 @@
1
- @custom-media --tablet-until (max-width: 768px);
2
-
3
- :host {
4
- width: 100%;
5
- background-color: var(--jb-white);
6
- display: block;
7
- }
8
-
9
- :host(:nth-of-type(even)) {
10
- background: var(--jb-neutral-10);
11
-
12
- @media(--tablet-until) {
13
- background: var(--jb-white);
14
- }
15
- }
1
+ @custom-media --tablet-until (max-width: 48rem);
2
+
3
+ :host {
4
+ width: 100%;
5
+ background-color: var(--bg-color);
6
+ display: block;
7
+ }
8
+
9
+ :host(:nth-of-type(even)) {
10
+ background: var(--bg-color-even);
11
+
12
+ @media(--tablet-until) {
13
+ background: var(--bg-color-even-tablet);
14
+ }
15
+ }
16
16
 
17
17
  .jb-row-web-component {
18
18
  .grid-row {
@@ -20,12 +20,12 @@
20
20
  box-sizing: border-box;
21
21
  grid-auto-rows: minmax(3rem, auto);
22
22
 
23
- @media(--tablet-until) {
24
- grid-template-columns: auto !important;
25
- grid-template-rows: auto;
26
- border-radius: var(--jb-radius);
27
- box-shadow: 0px 0px 1px 0px #d8d8d8;
28
- }
23
+ @media(--tablet-until) {
24
+ grid-template-columns: auto !important;
25
+ grid-template-rows: auto;
26
+ border-radius: var(--border-radius);
27
+ box-shadow: 0px 0px 1px 0px var(--shadow-color);
28
+ }
29
29
  }
30
30
 
31
31
  .expand-wrapper {
@@ -42,14 +42,14 @@
42
42
  }
43
43
 
44
44
  slot[name="expand"]::slotted(*) {
45
- width: 100%;
46
- min-height: 4rem;
47
- padding-block: 1rem;
48
- padding-inline: 2rem;
49
- border-bottom: 1px solid #ebebeb;
50
- box-sizing: border-box;
51
- overflow: auto;
52
- }
45
+ width: 100%;
46
+ min-height: 4rem;
47
+ padding-block: var(--expand-padding-block);
48
+ padding-inline: var(--expand-padding-inline);
49
+ border-bottom: 1px solid var(--expand-border-color);
50
+ box-sizing: border-box;
51
+ overflow: auto;
52
+ }
53
53
  }
54
54
 
55
- }
55
+ }
@@ -1,8 +1,7 @@
1
- export type JBRowElements = {
2
- expandWrapper: HTMLDivElement
3
- }
4
- export type RowTemplateItem = {
5
- name:string,
6
- size?:string|number
7
- }
8
- export type RowTemplate = RowTemplateItem[];
1
+ import type { GridTemplate, GridTemplateItem } from "../types.js";
2
+
3
+ export type JBRowElements = {
4
+ expandWrapper: HTMLDivElement
5
+ }
6
+ export type RowTemplateItem = GridTemplateItem;
7
+ export type RowTemplate = GridTemplate;
@@ -1,40 +1 @@
1
- import type { RowTemplate } from "./types";
2
-
3
- export function createTemplateStylesheet(sheet: CSSStyleSheet, template: RowTemplate | null) {
4
- if (template === null) {
5
- const css = /* css */ `
6
- .grid-row{
7
- display:grid;
8
- grid-auto-columns: 1fr;
9
- grid-auto-flow: column;
10
- grid-template-rows: 1fr;
11
- --jb-row-grid-mode: auto;
12
- }
13
- `
14
- sheet.replaceSync(css);
15
- return sheet;
16
- }
17
- let gridTemplateColumns = "";
18
- const gridTemplateAreas = template.map(t => `${t.name}`).join(" ");
19
- template.forEach((item) => {
20
- if (item.size != null || item.size != undefined) {
21
- if (typeof item.size == "number") {
22
- gridTemplateColumns += ` ${item.size}px`;
23
- } else {
24
- gridTemplateColumns += ` ${item.size}`;
25
- }
26
-
27
- } else {
28
- gridTemplateColumns += " 1fr";
29
- }
30
- });
31
- const css = /* css */ `
32
- .grid-row{
33
- display:grid;
34
- grid-template-columns: ${gridTemplateColumns};
35
- grid-template-areas: "${gridTemplateAreas}"
36
- }
37
- `
38
- sheet.replaceSync(css);
39
- return sheet;
40
- }
1
+ export { createTemplateStylesheet } from "../utils.js";
@@ -0,0 +1,13 @@
1
+ :host {
2
+ /* Theme/Color */
3
+ --bg-color: var(--jb-row-bg-color, var(--jb-white));
4
+ --bg-color-even: var(--jb-row-bg-color-even, var(--jb-neutral-10));
5
+ --bg-color-even-tablet: var(--jb-row-bg-color-even-tablet, var(--bg-color));
6
+ --expand-border-color: var(--jb-row-expand-border-color, #ebebeb);
7
+ --shadow-color: var(--jb-row-shadow-color, #d8d8d8);
8
+
9
+ /* Size */
10
+ --border-radius: var(--jb-row-border-radius, var(--jb-radius));
11
+ --expand-padding-block: var(--jb-row-expand-padding-block, 1rem);
12
+ --expand-padding-inline: var(--jb-row-expand-padding-inline, 2rem);
13
+ }
@@ -0,0 +1,9 @@
1
+ export function renderHTML(): string {
2
+ return /* html */ `
3
+ <div class="jb-table-header-web-component">
4
+ <div class="table-header-row" part="row" role="row">
5
+ <slot></slot>
6
+ </div>
7
+ </div>
8
+ `;
9
+ }
@@ -0,0 +1,29 @@
1
+ @custom-media --tablet-until (max-width: 48rem);
2
+
3
+ :host {
4
+ display: block;
5
+ width: 100%;
6
+ height: 100%;
7
+ box-sizing: border-box;
8
+ }
9
+
10
+ .jb-table-header-web-component {
11
+ width: 100%;
12
+ height: 100%;
13
+
14
+ .table-header-row {
15
+ width: 100%;
16
+ height: 100%;
17
+ box-sizing: border-box;
18
+ line-height: 2rem;
19
+
20
+ @media(--tablet-until) {
21
+ display: none;
22
+ }
23
+ }
24
+
25
+ .table-header-row ::slotted(*) {
26
+ box-sizing: border-box;
27
+ min-width: 0;
28
+ }
29
+ }
@@ -0,0 +1,50 @@
1
+ import { renderHTML } from './render.js';
2
+ import CSS from './style.css';
3
+ import { registerDefaultVariables } from 'jb-core/theme';
4
+ import type { TableHeaderTemplate } from './types.js';
5
+ import { createTemplateStylesheet } from '../utils.js';
6
+
7
+ export * from "./types.js";
8
+
9
+ export class JBTableHeaderWebComponent extends HTMLElement {
10
+ #templateSheet = new CSSStyleSheet();
11
+ #headerTemplate: TableHeaderTemplate = [];
12
+
13
+ get headerTemplate() {
14
+ return this.#headerTemplate;
15
+ }
16
+
17
+ set headerTemplate(value: TableHeaderTemplate) {
18
+ this.#headerTemplate = value;
19
+ createTemplateStylesheet(this.#templateSheet, value, {
20
+ selector: ".table-header-row"
21
+ });
22
+ }
23
+
24
+ constructor() {
25
+ super();
26
+ this.#init();
27
+ }
28
+
29
+ #init() {
30
+ const shadowRoot = this.attachShadow({ mode: 'open', delegatesFocus: true, clonable: true, serializable: true });
31
+ shadowRoot.adoptedStyleSheets = [this.#templateSheet];
32
+ registerDefaultVariables();
33
+ this.#render();
34
+ createTemplateStylesheet(this.#templateSheet, null, {
35
+ selector: ".table-header-row"
36
+ });
37
+ }
38
+
39
+ #render() {
40
+ const html = `<style>${CSS}</style>\n${renderHTML()}`;
41
+ const element = document.createElement("template");
42
+ element.innerHTML = html;
43
+ this.shadowRoot!.appendChild(element.content.cloneNode(true));
44
+ }
45
+ }
46
+
47
+ const myElementNotExists = !customElements.get('jb-table-header');
48
+ if (myElementNotExists) {
49
+ window.customElements.define('jb-table-header', JBTableHeaderWebComponent);
50
+ }
@@ -0,0 +1,4 @@
1
+ import type { GridTemplate, GridTemplateItem } from "../types.js";
2
+
3
+ export type TableHeaderTemplateItem = GridTemplateItem;
4
+ export type TableHeaderTemplate = GridTemplate;
@@ -1,17 +1,19 @@
1
1
  import { renderHTML } from './render.js';
2
2
  import CSS from './style.css';
3
3
  import { registerDefaultVariables } from 'jb-core/theme';
4
- import { JBRowWebComponent } from '../row/row.js';
5
- export class JBExpandToggleWebComponent extends HTMLElement {
6
- constructor() {
7
- super();
8
- this.#init();
4
+ import { JBRowWebComponent } from '../row/row.js';
5
+ export class JBExpandToggleWebComponent extends HTMLElement {
6
+ #button!: HTMLButtonElement;
7
+ constructor() {
8
+ super();
9
+ this.#init();
9
10
  }
10
11
  #init() {
11
12
  const shadowRoot = this.attachShadow({ mode: 'open', delegatesFocus: true, clonable:true, serializable:true });
12
- registerDefaultVariables();
13
- this.#render();
14
- this.#registerEventListener();
13
+ registerDefaultVariables();
14
+ this.#render();
15
+ this.#button = shadowRoot.querySelector(".toggle-button")!;
16
+ this.#registerEventListener();
15
17
  }
16
18
  #render() {
17
19
  const html = `<style>${CSS}</style>\n${renderHTML()}`;
@@ -22,8 +24,9 @@ export class JBExpandToggleWebComponent extends HTMLElement {
22
24
  #parentRow:JBRowWebComponent|null = null;
23
25
  connectedCallback() {
24
26
  this.#parentRow = this.#findParentRow(this);
25
- if(this.#parentRow?.isOpen){
26
- this.setAttribute('open','');
27
+ if(this.#parentRow?.isOpen){
28
+ this.setAttribute('open','');
29
+ this.#button.setAttribute("aria-expanded", "true");
27
30
  }
28
31
  }
29
32
  #findParentRow(element:Element|null):JBRowWebComponent|null{
@@ -37,17 +40,18 @@ export class JBExpandToggleWebComponent extends HTMLElement {
37
40
  }
38
41
  }
39
42
  #registerEventListener() {
40
- this.addEventListener('click', ()=>this.toggle(), {passive:true});
43
+ this.#button.addEventListener('click', ()=>this.toggle());
41
44
  }
42
45
  toggle(){
43
46
  if(this.#parentRow){
44
47
  const value = !this.#parentRow?.isOpen;
45
48
  this.#parentRow.isOpen = value
46
- value?this.setAttribute('open',''):this.removeAttribute('open');
49
+ value?this.setAttribute('open',''):this.removeAttribute('open');
50
+ this.#button.setAttribute("aria-expanded", value ? "true" : "false");
47
51
  }
48
52
  }
49
53
  }
50
54
  const myElementNotExists = !customElements.get('jb-expand-toggle');
51
55
  if (myElementNotExists) {
52
56
  window.customElements.define('jb-expand-toggle', JBExpandToggleWebComponent);
53
- }
57
+ }
@@ -1,13 +1,18 @@
1
- export function renderHTML(): string {
2
- return /* html */ `
3
- <slot>
4
- <svg class="arrow-icon" viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg">
5
- <path d="M35,10 L15,25 L35,40 Z"
6
- fill="currentColor"
7
- stroke="currentColor"
8
- stroke-width="6"
9
- stroke-linejoin="round" />
10
- </svg>
11
- </slot>
12
- `;
13
- }
1
+ import { dictionary } from "../i18n";
2
+ import { i18n } from "jb-core/i18n";
3
+
4
+ export function renderHTML(): string {
5
+ return /* html */ `
6
+ <button class="toggle-button" type="button" aria-label="${dictionary.get(i18n, "toggleRowDetails")}" aria-expanded="false">
7
+ <slot>
8
+ <svg class="arrow-icon" viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
9
+ <path d="M35,10 L15,25 L35,40 Z"
10
+ fill="currentColor"
11
+ stroke="currentColor"
12
+ stroke-width="6"
13
+ stroke-linejoin="round" />
14
+ </svg>
15
+ </slot>
16
+ </button>
17
+ `;
18
+ }
@@ -1,9 +1,22 @@
1
1
  :host {
2
2
  width: 1.5rem;
3
- height: 1.5rem;
4
- display: block;
5
- cursor: pointer;
6
- }
3
+ height: 1.5rem;
4
+ display: block;
5
+ }
6
+
7
+ .toggle-button {
8
+ all: unset;
9
+ box-sizing: border-box;
10
+ display: block;
11
+ width: 100%;
12
+ height: 100%;
13
+ cursor: pointer;
14
+
15
+ &:focus-visible {
16
+ outline: 2px solid var(--jb-grid-focus-ring-color, Highlight);
17
+ outline-offset: 2px;
18
+ }
19
+ }
7
20
 
8
21
  :host([open]) {
9
22
  .arrow-icon {
@@ -22,4 +35,4 @@
22
35
  &:dir(ltr) {
23
36
  transform: rotateY(180deg)
24
37
  }
25
- }
38
+ }
@@ -0,0 +1,6 @@
1
+ export type GridTemplateItem = {
2
+ name: string,
3
+ size?: string | number
4
+ }
5
+
6
+ export type GridTemplate = GridTemplateItem[];