@nysds/nys-table 1.15.0 → 1.16.0-alpha4

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/dist/nys-table.js CHANGED
@@ -5,16 +5,16 @@ import { property as u, state as h } from "lit/decorators.js";
5
5
  * █ █ █ █▄▄▄█ ▀▀▀▄▄ █ █ ▀▀▀▄▄
6
6
  * █ ▀█ █ █▄▄▄█ █▄▄▀ █▄▄▄█
7
7
  *
8
- * Table Component
8
+ * Table Component v1.16.0-alpha4
9
9
  * Part of the New York State Design System
10
10
  * Repository: https://github.com/its-hcd/nysds
11
11
  * License: MIT
12
12
  */
13
- const w = ':host{--_nys-table-width: 100%;--_nys-table-radius: var(--nys-radius-xl, 12px);--_nys-table-padding: var(--nys-space-100, 8px);--_nys-table-border-color: transparent;--_nys-table-border-width: 0;--_nys-table-font-family: var(--nys-font-family-ui, var(--nys-font-family-sans, "Proxima Nova", "Helvetica Neue", Helvetica, Arial, sans-serif));--_nys-table-font-size: var(--nys-font-size-ui-md, 16px);--_nys-table-font-weight: var(--nys-font-weight-regular, 400);--_nys-table-line-height: var(--nys-font-line-height-ui, 24px);--_nys-table-padding--caption: var(--nys-space-250, 20px) var(--nys-space-150, 12px);--_nys-table-font-size--caption: var(--nys-font-size-ui-lg, 18px);--_nys-table-font-weight--caption: var(--nys-font-weight-bold, 700);--_nys-table-padding--cell--x: var(--nys-space-150, 12px);--_nys-table-padding--cell--y: var(--nys-space-200, 16px);--_nys-table-background-color: var(--nys-color-ink-reverse, #ffffff);--_nys-table-background-color--striped: var(--nys-color-neutral-10, #f6f6f6);--_nys-table-color--code: var(--nys-color-red-600, #b52c2c);--_nys-table-background-color--code: var(--nys-color-neutral-10, #f6f6f6)}:host([bordered]){--_nys-table-border-color: var(--nys-color-neutral-100, #d0d0ce);--_nys-table-border-width: var(--nys-space-1px, 1px)}:host([download]){display:flex;flex-direction:column;gap:var(--nys-space-150, 12px)}.nys-table{width:var(--_nys-table-width);font:var(--_nys-table-font-weight) var(--_nys-table-font-size)/var(--_nys-table-line-height) var(--_nys-table-font-family)}.nys-table table{width:var(--_nys-table-width);border-collapse:collapse;background-color:var(--_nys-table-background-color)}.nys-table caption{padding:var(--_nys-table-padding--caption);font-size:var(--_nys-table-font-size--caption);font-weight:var(--_nys-table-font-weight--caption);text-align:start}.nys-table caption div{display:flex;justify-content:space-between;align-items:center}.nys-table td{padding:var(--_nys-table-padding--cell--y) var(--_nys-table-padding--cell--x);border:var(--_nys-table-border-width) solid var(--_nys-table-border-color)}.nys-table td code{color:var(--_nys-table-color--code);background-color:var(--_nys-table-background-color--code);padding:var(--nys-space-1px) var(--nys-space-2px);border-radius:var(--nys-radius-md)}.nys-table th{border:var(--_nys-table-border-width) solid var(--_nys-table-border-color);overflow:hidden;text-overflow:ellipsis;padding:var(--_nys-table-padding--cell--y) var(--_nys-table-padding--cell--x);text-align:left}.nys-table th:has(nys-button){padding:0}.nys-table th p{margin:0}.nys-table th nys-button{margin:0;width:-moz-available;width:-webkit-fill-available;width:fill-available;justify-content:space-between;--_nys-button-border-width: 0;--_nys-button-border-radius--start: 0;--_nys-button-border-radius--end: 0;--_nys-button-padding--x: var(--_nys-table-padding--cell--x);--_nys-button-justify-content: space-between;--_nys-button-outline-offset: -2px}.nys-table th.nys-table__sortedcolumn{background-color:var(--nys-color-theme-weak, #cddde9)}.nys-table td.nys-table__sortedcolumn{position:relative;z-index:0}.nys-table td.nys-table__sortedcolumn:after{content:"";position:absolute;inset:0;background-color:var(--nys-color-theme, #154973);opacity:.1;pointer-events:none;z-index:-1}:host([striped]) .nys-table tbody tr:nth-child(odd){background-color:var(--_nys-table-background-color--striped)}:host([sortable]) .nys-table th{cursor:pointer}.sr-only{border:0!important;clip-path:inset(50%)!important;height:1px!important;overflow:hidden!important;margin:-1px!important;padding:0!important;position:absolute!important;width:1px!important;white-space:nowrap!important}';
13
+ const w = ':host{--_nys-table-width: 100%;--_nys-table-radius: var(--nys-radius-xl, 12px);--_nys-table-padding: var(--nys-space-100, 8px);--_nys-table-border-color: transparent;--_nys-table-border-width: 0;--_nys-table-font-family: var(--nys-font-family-ui, var(--nys-font-family-sans, "Proxima Nova", "Helvetica Neue", Helvetica, Arial, sans-serif));--_nys-table-font-size: var(--nys-font-size-ui-md, 16px);--_nys-table-font-weight: var(--nys-font-weight-regular, 400);--_nys-table-line-height: var(--nys-font-lineheight-ui-md, 24px);--_nys-table-padding--caption: var(--nys-space-250, 20px) var(--nys-space-150, 12px);--_nys-table-font-size--caption: var(--nys-font-size-ui-lg, 18px);--_nys-table-font-weight--caption: var(--nys-font-weight-bold, 700);--_nys-table-padding--cell--x: var(--nys-space-150, 12px);--_nys-table-padding--cell--y: var(--nys-table-padding--cell--y, var(--nys-space-200, 16px));--_nys-table-background-color: var(--nys-color-ink-reverse, #ffffff);--_nys-table-background-color--striped: var(--nys-color-neutral-10, #f6f6f6);--_nys-table-color--code: var(--nys-color-red-600, #b52c2c);--_nys-table-background-color--code: var(--nys-color-neutral-10, #f6f6f6)}:host([bordered]){--_nys-table-border-color: var(--nys-color-neutral-100, #d0d0ce);--_nys-table-border-width: var(--nys-space-1px, 1px)}:host([download]){display:flex;flex-direction:column;gap:var(--nys-space-150, 12px)}.nys-table{width:var(--_nys-table-width);font:var(--_nys-table-font-weight) var(--_nys-table-font-size)/var(--_nys-table-line-height) var(--_nys-table-font-family)}.nys-table table{width:var(--_nys-table-width);border-collapse:collapse;background-color:var(--_nys-table-background-color)}.nys-table caption{padding:var(--_nys-table-padding--caption);font-size:var(--_nys-table-font-size--caption);font-weight:var(--_nys-table-font-weight--caption);text-align:start}.nys-table caption div{display:flex;justify-content:space-between;align-items:center}.nys-table td{padding:var(--_nys-table-padding--cell--y) var(--_nys-table-padding--cell--x);border:var(--_nys-table-border-width) solid var(--_nys-table-border-color)}.nys-table td code{color:var(--_nys-table-color--code);background-color:var(--_nys-table-background-color--code);padding:var(--nys-space-1px) var(--nys-space-2px);border-radius:var(--nys-radius-md)}.nys-table th{border:var(--_nys-table-border-width) solid var(--_nys-table-border-color);overflow:hidden;text-overflow:ellipsis;padding:var(--_nys-table-padding--cell--y) var(--_nys-table-padding--cell--x);text-align:left}.nys-table th:has(nys-button){padding:0}.nys-table th p{margin:0}.nys-table th nys-button{margin:0;width:-moz-available;width:-webkit-fill-available;width:fill-available;justify-content:space-between;--_nys-button-border-width: 0;--_nys-button-border-radius--start: 0;--_nys-button-border-radius--end: 0;--_nys-button-padding--x: var(--_nys-table-padding--cell--x);--_nys-button-justify-content: space-between;--_nys-button-outline-offset: -2px}.nys-table th.nys-table__sortedcolumn{background-color:var(--nys-color-theme-weak, #cddde9)}.nys-table td.nys-table__sortedcolumn{position:relative;z-index:0}.nys-table td.nys-table__sortedcolumn:after{content:"";position:absolute;inset:0;background-color:var(--nys-color-theme, #154973);opacity:.1;pointer-events:none;z-index:-1}:host([striped]) .nys-table tbody tr:nth-child(odd){background-color:var(--_nys-table-background-color--striped)}:host([sortable]) .nys-table th{cursor:pointer}.sr-only{border:0!important;clip-path:inset(50%)!important;height:1px!important;overflow:hidden!important;margin:-1px!important;padding:0!important;position:absolute!important;width:1px!important;white-space:nowrap!important}';
14
14
  var x = Object.defineProperty, y = (m, t, s, r) => {
15
- for (var o = void 0, n = m.length - 1, e; n >= 0; n--)
16
- (e = m[n]) && (o = e(t, s, o) || o);
17
- return o && x(t, s, o), o;
15
+ for (var e = void 0, n = m.length - 1, o; n >= 0; n--)
16
+ (o = m[n]) && (e = o(t, s, e) || e);
17
+ return e && x(t, s, e), e;
18
18
  };
19
19
  let C = 0;
20
20
  const f = class f extends v {
@@ -39,48 +39,48 @@ const f = class f extends v {
39
39
  );
40
40
  if (!t || !s) return;
41
41
  s.innerHTML = "";
42
- const o = t.assignedElements({ flatten: !0 }).find((e) => e.tagName === "TABLE");
43
- if (!o) return;
44
- const n = o.cloneNode(!0);
42
+ const e = t.assignedElements({ flatten: !0 }).find((o) => o.tagName === "TABLE");
43
+ if (!e) return;
44
+ const n = e.cloneNode(!0);
45
45
  this._normalizeTableDOM(n), this.sortable && this._addSortIcons(n), s.appendChild(n);
46
46
  }
47
47
  _normalizeTableDOM(t) {
48
48
  const s = t.querySelector("thead"), r = t.querySelector("tbody");
49
49
  if (s && r) return;
50
- const o = t.querySelector(
50
+ const e = t.querySelector(
51
51
  "caption"
52
52
  ), n = Array.from(t.querySelectorAll("tr"));
53
53
  if (n.length === 0) return;
54
- const e = document.createElement("thead"), l = document.createElement("tbody"), p = n.findIndex((a) => a.querySelector("th"));
55
- if (p === -1)
56
- n.forEach((a) => l.appendChild(a));
54
+ const o = document.createElement("thead"), i = document.createElement("tbody"), b = n.findIndex((a) => a.querySelector("th"));
55
+ if (b === -1)
56
+ n.forEach((a) => i.appendChild(a));
57
57
  else {
58
- const a = n[p];
58
+ const a = n[b];
59
59
  a.querySelectorAll("th").forEach((d) => {
60
60
  Array.from(d.childNodes).forEach((c) => {
61
61
  if (c.nodeType === Node.TEXT_NODE && c.textContent?.trim()) {
62
- const b = document.createElement("p");
63
- b.textContent = c.textContent, d.replaceChild(b, c);
62
+ const p = document.createElement("p");
63
+ p.textContent = c.textContent, d.replaceChild(p, c);
64
64
  }
65
65
  });
66
- }), e.appendChild(a), n.forEach((d, c) => {
67
- c !== p && l.appendChild(d);
66
+ }), o.appendChild(a), n.forEach((d, c) => {
67
+ c !== b && i.appendChild(d);
68
68
  });
69
69
  }
70
- if (t.innerHTML = "", o && t.appendChild(o), this.sortable) {
70
+ if (t.innerHTML = "", e && t.appendChild(e), this.sortable) {
71
71
  const a = document.createElement("span");
72
- if (a.setAttribute("class", "sr-only"), a.textContent = "Column headers with buttons are sortable.", o)
73
- o.appendChild(a);
72
+ if (a.setAttribute("class", "sr-only"), a.textContent = "Column headers with buttons are sortable.", e)
73
+ e.appendChild(a);
74
74
  else {
75
75
  const d = document.createElement("caption");
76
76
  d.appendChild(a), t.appendChild(d);
77
77
  }
78
78
  }
79
- t.appendChild(e), t.appendChild(l);
79
+ t.appendChild(o), t.appendChild(i);
80
80
  }
81
81
  willUpdate() {
82
82
  const t = Array.from(this.children).find(
83
- (o) => o.tagName === "TABLE"
83
+ (e) => e.tagName === "TABLE"
84
84
  );
85
85
  if (!t) return;
86
86
  const r = t.querySelector("caption")?.textContent?.trim() ?? "";
@@ -88,55 +88,60 @@ const f = class f extends v {
88
88
  }
89
89
  _addSortIcons(t) {
90
90
  const s = Array.from(t.querySelectorAll("thead th"));
91
- s.length !== 0 && s.forEach((r, o) => {
91
+ s.length !== 0 && s.forEach((r, e) => {
92
92
  if (r.querySelector("nys-button[part='sort-button']")) return;
93
93
  const n = r.textContent?.trim();
94
94
  if (!n) return;
95
95
  r.textContent = "";
96
- const e = document.createElement("nys-button");
97
- e.setAttribute("part", "sort-button"), e.setAttribute("variant", "ghost"), e.setAttribute("label", n), e.setAttribute("suffixIcon", "slotted"), e.setAttribute("fullWidth", "true");
98
- const l = document.createElement("nys-icon");
99
- l.setAttribute("slot", "suffix-icon"), l.setAttribute("name", "height"), l.setAttribute("size", "24"), l.setAttribute("color", "var(--nys-color-text-weak, #4a4d4f)"), e.appendChild(l), e.addEventListener("nys-click", (p) => {
100
- p.stopPropagation(), this._onSortClick(o, t);
101
- }), r.appendChild(e);
96
+ const o = document.createElement("nys-button");
97
+ o.setAttribute("part", "sort-button"), o.setAttribute("variant", "ghost"), o.setAttribute("label", n), o.setAttribute("suffixIcon", "slotted"), o.setAttribute("fullWidth", "true");
98
+ const i = document.createElement("nys-icon");
99
+ i.setAttribute("slot", "suffix-icon"), i.setAttribute("name", "height"), i.setAttribute("size", "24"), i.setAttribute("color", "var(--nys-color-text-weak, #4a4d4f)"), o.appendChild(i), o.addEventListener("nys-click", (b) => {
100
+ b.stopPropagation(), this._onSortClick(e, t);
101
+ }), r.appendChild(o);
102
102
  });
103
103
  }
104
104
  _updateSortIcons(t) {
105
- t.querySelectorAll("thead th").forEach((r, o) => {
106
- const n = r.querySelector("nys-button[part='sort-button']"), e = n?.querySelector(
105
+ t.querySelectorAll("thead th").forEach((r, e) => {
106
+ const n = r.querySelector("nys-button[part='sort-button']"), o = n?.querySelector(
107
107
  "nys-icon[slot='suffix-icon']"
108
108
  );
109
- if (!(!n || !e))
110
- if (o === this._sortColumn)
109
+ if (!(!n || !o))
110
+ if (e === this._sortColumn)
111
111
  switch (r.classList.add("nys-table__sortedcolumn"), this._sortDirection) {
112
112
  case "asc":
113
- e.setAttribute("name", "straight"), e.setAttribute("color", "var(--nys-color-ink, #1b1b1b)"), e.style.transform = "rotate(0deg)", r.setAttribute("aria-sort", "ascending");
113
+ o.setAttribute("name", "straight"), o.setAttribute("color", "var(--nys-color-ink, #1b1b1b)"), o.style.transform = "rotate(0deg)", r.setAttribute("aria-sort", "ascending");
114
114
  break;
115
115
  case "desc":
116
- e.setAttribute("name", "straight"), e.setAttribute("color", "var(--nys-color-ink, #1b1b1b)"), e.style.transform = "rotate(180deg)", r.setAttribute("aria-sort", "descending");
116
+ o.setAttribute("name", "straight"), o.setAttribute("color", "var(--nys-color-ink, #1b1b1b)"), o.style.transform = "rotate(180deg)", r.setAttribute("aria-sort", "descending");
117
117
  break;
118
118
  }
119
119
  else
120
- r.classList.remove("nys-table__sortedcolumn"), e.setAttribute("name", "height"), e.setAttribute("color", "var(--nys-color-text-weak, #4a4d4f)"), e.style.transform = "", r.removeAttribute("aria-sort");
120
+ r.classList.remove("nys-table__sortedcolumn"), o.setAttribute("name", "height"), o.setAttribute("color", "var(--nys-color-text-weak, #4a4d4f)"), o.style.transform = "", r.removeAttribute("aria-sort");
121
121
  });
122
122
  }
123
123
  _onSortClick(t, s) {
124
- this._sortColumn !== t ? (this._sortColumn = t, this._sortDirection = "asc") : this._sortDirection = this._sortDirection === "asc" ? "desc" : "asc", this._updateSortIcons(s), this._sortTable(s, t, this._sortDirection);
124
+ const e = Array.from(s.querySelectorAll("thead th"))[t]?.querySelector("nys-button[part='sort-button']")?.getAttribute("label") ?? "", n = this._sortColumn !== t ? "asc" : this._sortDirection === "asc" ? "desc" : "asc";
125
+ this._emitColumnSortEvent(
126
+ t,
127
+ e,
128
+ n
129
+ ) || (this._sortColumn = t, this._sortDirection = n, this._updateSortIcons(s), this._sortTable(s, t, this._sortDirection));
125
130
  }
126
131
  _sortTable(t, s, r) {
127
- const o = t.querySelector("tbody");
128
- if (!o) return;
129
- const n = Array.from(o.querySelectorAll("tr"));
130
- n.sort((e, l) => {
131
- const p = e.children[s]?.textContent?.trim() ?? "", a = l.children[s]?.textContent?.trim() ?? "", d = Number(p), c = Number(a);
132
- let b;
133
- return !isNaN(d) && !isNaN(c) ? b = d - c : b = p.localeCompare(a), r === "asc" ? b : -b;
134
- }), n.forEach((e) => o.appendChild(e)), this._updateSortedColumnStyles(t);
132
+ const e = t.querySelector("tbody");
133
+ if (!e) return;
134
+ const n = Array.from(e.querySelectorAll("tr"));
135
+ n.sort((o, i) => {
136
+ const b = o.children[s]?.textContent?.trim() ?? "", a = i.children[s]?.textContent?.trim() ?? "", d = Number(b), c = Number(a);
137
+ let p;
138
+ return !isNaN(d) && !isNaN(c) ? p = d - c : p = b.localeCompare(a), r === "asc" ? p : -p;
139
+ }), n.forEach((o) => e.appendChild(o)), this._updateSortedColumnStyles(t);
135
140
  }
136
141
  _updateSortedColumnStyles(t) {
137
142
  t.querySelectorAll("tbody tr").forEach((r) => {
138
- Array.from(r.children).forEach((o, n) => {
139
- n === this._sortColumn ? o.classList.add("nys-table__sortedcolumn") : o.classList.remove("nys-table__sortedcolumn");
143
+ Array.from(r.children).forEach((e, n) => {
144
+ n === this._sortColumn ? e.classList.add("nys-table__sortedcolumn") : e.classList.remove("nys-table__sortedcolumn");
140
145
  });
141
146
  });
142
147
  }
@@ -145,7 +150,23 @@ const f = class f extends v {
145
150
  t.href = this.download, t.download = this.download.split("/").pop() || "table-data.csv", document.body.appendChild(t), t.click(), document.body.removeChild(t);
146
151
  }
147
152
  /****************** Event Handlers ******************/
148
- // Placeholder for event handlers if needed
153
+ /**
154
+ * Dispatches the `nys-column-sort` custom event.
155
+ *
156
+ * @param columnIndex - Zero-based index of the sorted column.
157
+ * @param columnLabel - The text label of the sorted column header.
158
+ * @param sortDirection - The new sort direction: "asc", "desc", or "none".
159
+ */
160
+ _emitColumnSortEvent(t, s, r) {
161
+ const e = new CustomEvent("nys-column-sort", {
162
+ detail: { columnIndex: t, columnLabel: s, sortDirection: r },
163
+ bubbles: !0,
164
+ composed: !0,
165
+ cancelable: !0
166
+ });
167
+ return this.dispatchEvent(e), e.defaultPrevented;
168
+ }
169
+ /****************** Render ******************/
149
170
  render() {
150
171
  return _`
151
172
  <div class="nys-table">
@@ -165,36 +186,36 @@ const f = class f extends v {
165
186
  }
166
187
  };
167
188
  f.styles = g(w);
168
- let i = f;
189
+ let l = f;
169
190
  y([
170
191
  u({ type: String, reflect: !0 })
171
- ], i.prototype, "id");
192
+ ], l.prototype, "id");
172
193
  y([
173
194
  u({ type: String, reflect: !0 })
174
- ], i.prototype, "name");
195
+ ], l.prototype, "name");
175
196
  y([
176
197
  u({ type: Boolean, reflect: !0 })
177
- ], i.prototype, "striped");
198
+ ], l.prototype, "striped");
178
199
  y([
179
200
  u({ type: Boolean, reflect: !0 })
180
- ], i.prototype, "sortable");
201
+ ], l.prototype, "sortable");
181
202
  y([
182
203
  u({ type: Boolean, reflect: !0 })
183
- ], i.prototype, "bordered");
204
+ ], l.prototype, "bordered");
184
205
  y([
185
206
  u({ type: String, reflect: !0 })
186
- ], i.prototype, "download");
207
+ ], l.prototype, "download");
187
208
  y([
188
209
  h()
189
- ], i.prototype, "_sortColumn");
210
+ ], l.prototype, "_sortColumn");
190
211
  y([
191
212
  h()
192
- ], i.prototype, "_sortDirection");
213
+ ], l.prototype, "_sortDirection");
193
214
  y([
194
215
  h()
195
- ], i.prototype, "_captionText");
196
- customElements.get("nys-table") || customElements.define("nys-table", i);
216
+ ], l.prototype, "_captionText");
217
+ customElements.get("nys-table") || customElements.define("nys-table", l);
197
218
  export {
198
- i as NysTable
219
+ l as NysTable
199
220
  };
200
221
  //# sourceMappingURL=nys-table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nys-table.js","sources":["../src/nys-table.ts"],"sourcesContent":["import { LitElement, html, unsafeCSS } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\n// @ts-ignore: SCSS module imported via bundler as inline\nimport styles from \"./nys-table.scss?inline\";\n\nlet componentIdCounter = 0;\n\n/**\n * `<nys-table>` is a responsive table component that can display native HTML tables,\n * supports striped and bordered styling, sortable columns, and CSV download.\n *\n * @slot - Accepts a `<table>` element. Only the first table is rendered.\n *\n * @fires nys-click - Fired when the download button or sortable headers are clicked.\n *\n * @method downloadFile - Triggers download of the CSV file if `download` is set.\n */\nexport class NysTable extends LitElement {\n static styles = unsafeCSS(styles);\n\n @property({ type: String, reflect: true }) id = \"\";\n @property({ type: String, reflect: true }) name = \"\";\n @property({ type: Boolean, reflect: true }) striped = false;\n @property({ type: Boolean, reflect: true }) sortable = false;\n @property({ type: Boolean, reflect: true }) bordered = false;\n @property({ type: String, reflect: true }) download = \"\";\n\n @state() private _sortColumn: number | null = null;\n @state() private _sortDirection: \"asc\" | \"desc\" | \"none\" = \"none\";\n @state() private _captionText = \"\";\n\n /**************** Lifecycle Methods ****************/\n constructor() {\n super();\n }\n\n // Generate a unique ID if one is not provided\n connectedCallback() {\n super.connectedCallback();\n if (!this.id) {\n this.id = `nys-table-${Date.now()}-${componentIdCounter++}`;\n }\n }\n\n /******************** Functions ********************/\n // Placeholder for generic functions (component-specific)\n\n firstUpdated() {\n const slot = this.shadowRoot?.querySelector(\"slot\");\n slot?.addEventListener(\"slotchange\", () => this._handleSlotChange());\n this._handleSlotChange();\n }\n\n _handleSlotChange() {\n const slot = this.shadowRoot?.querySelector(\n \"slot\",\n ) as HTMLSlotElement | null;\n const container = this.shadowRoot?.querySelector(\n \".table-container\",\n ) as HTMLElement | null;\n\n if (!slot || !container) return;\n\n container.innerHTML = \"\";\n\n const assigned = slot.assignedElements({ flatten: true });\n const tableEl = assigned.find((el) => el.tagName === \"TABLE\") as\n | HTMLTableElement\n | undefined;\n\n if (!tableEl) return;\n\n const table = tableEl.cloneNode(true) as HTMLTableElement;\n\n this._normalizeTableDOM(table);\n\n if (this.sortable) {\n this._addSortIcons(table);\n }\n\n container.appendChild(table);\n }\n\n _normalizeTableDOM(table: HTMLTableElement) {\n const hasThead = table.querySelector(\"thead\");\n const hasTbody = table.querySelector(\"tbody\");\n\n if (hasThead && hasTbody) return;\n\n // Pull caption first\n const caption = table.querySelector(\n \"caption\",\n ) as HTMLTableCaptionElement | null;\n\n // Collect all rows\n const rows = Array.from(table.querySelectorAll(\"tr\"));\n if (rows.length === 0) return;\n\n const thead = document.createElement(\"thead\");\n const tbody = document.createElement(\"tbody\");\n\n // Find first row containing th\n const headerRowIndex = rows.findIndex((r) => r.querySelector(\"th\"));\n\n if (headerRowIndex === -1) {\n rows.forEach((r) => tbody.appendChild(r));\n } else {\n const headerRow = rows[headerRowIndex];\n\n // Wrap text nodes in <p> for each <th>\n headerRow.querySelectorAll(\"th\").forEach((th) => {\n // Only wrap text nodes, leave icons or other children\n Array.from(th.childNodes).forEach((node) => {\n if (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()) {\n const p = document.createElement(\"p\");\n p.textContent = node.textContent;\n th.replaceChild(p, node);\n }\n });\n });\n\n thead.appendChild(headerRow);\n\n // Move remaining rows to tbody\n rows.forEach((r, i) => {\n if (i !== headerRowIndex) tbody.appendChild(r);\n });\n }\n\n // Wipe original table content\n table.innerHTML = \"\";\n\n // Handle caption and sortable message\n if (caption) {\n table.appendChild(caption);\n }\n\n if (this.sortable) {\n const srOnly = document.createElement(\"span\");\n srOnly.setAttribute(\"class\", \"sr-only\");\n srOnly.textContent = \"Column headers with buttons are sortable.\";\n\n if (caption) {\n caption.appendChild(srOnly);\n } else {\n const nextCaption = document.createElement(\"caption\");\n nextCaption.appendChild(srOnly);\n table.appendChild(nextCaption);\n }\n }\n\n table.appendChild(thead);\n table.appendChild(tbody);\n }\n\n willUpdate() {\n const table = Array.from(this.children).find(\n (el) => el.tagName === \"TABLE\",\n ) as HTMLTableElement | undefined;\n\n if (!table) return;\n\n const caption = table.querySelector(\"caption\");\n const nextCaption = caption?.textContent?.trim() ?? \"\";\n\n if (this._captionText !== nextCaption) {\n this._captionText = nextCaption;\n }\n }\n\n _addSortIcons(table: HTMLTableElement) {\n const ths = Array.from(table.querySelectorAll(\"thead th\"));\n if (ths.length === 0) return;\n\n ths.forEach((th, index) => {\n // Prevent duplicates on slotchange or re-render\n if (th.querySelector(\"nys-button[part='sort-button']\")) return;\n\n // Get existing text content\n const label = th.textContent?.trim();\n if (!label) return;\n\n // Clear existing content\n th.textContent = \"\";\n\n const button = document.createElement(\"nys-button\");\n button.setAttribute(\"part\", \"sort-button\");\n button.setAttribute(\"variant\", \"ghost\");\n button.setAttribute(\"label\", label);\n button.setAttribute(\"suffixIcon\", \"slotted\");\n button.setAttribute(\"fullWidth\", \"true\");\n\n const icon = document.createElement(\"nys-icon\");\n icon.setAttribute(\"slot\", \"suffix-icon\");\n icon.setAttribute(\"name\", \"height\");\n icon.setAttribute(\"size\", \"24\");\n icon.setAttribute(\"color\", \"var(--nys-color-text-weak, #4a4d4f)\");\n\n button.appendChild(icon);\n\n button.addEventListener(\"nys-click\", (e) => {\n e.stopPropagation();\n this._onSortClick(index, table);\n });\n\n th.appendChild(button);\n });\n }\n\n _updateSortIcons(table: HTMLTableElement) {\n const ths = table.querySelectorAll(\"thead th\");\n\n ths.forEach((th, index) => {\n const button = th.querySelector(\"nys-button[part='sort-button']\");\n const icon = button?.querySelector(\n \"nys-icon[slot='suffix-icon']\",\n ) as HTMLElement | null;\n\n if (!button || !icon) return;\n\n if (index === this._sortColumn) {\n th.classList.add(\"nys-table__sortedcolumn\");\n switch (this._sortDirection) {\n case \"asc\":\n icon.setAttribute(\"name\", \"straight\");\n icon.setAttribute(\"color\", \"var(--nys-color-ink, #1b1b1b)\");\n icon.style.transform = \"rotate(0deg)\";\n th.setAttribute(\"aria-sort\", \"ascending\");\n break;\n case \"desc\":\n icon.setAttribute(\"name\", \"straight\");\n icon.setAttribute(\"color\", \"var(--nys-color-ink, #1b1b1b)\");\n icon.style.transform = \"rotate(180deg)\";\n th.setAttribute(\"aria-sort\", \"descending\");\n break;\n }\n } else {\n // Reset for all other columns\n th.classList.remove(\"nys-table__sortedcolumn\");\n icon.setAttribute(\"name\", \"height\");\n icon.setAttribute(\"color\", \"var(--nys-color-text-weak, #4a4d4f)\");\n icon.style.transform = \"\";\n th.removeAttribute(\"aria-sort\");\n }\n });\n }\n\n _onSortClick(columnIndex: number, table: HTMLTableElement) {\n if (this._sortColumn !== columnIndex) {\n // New column → start with ascending\n this._sortColumn = columnIndex;\n this._sortDirection = \"asc\";\n } else {\n // Same column → toggle\n this._sortDirection = this._sortDirection === \"asc\" ? \"desc\" : \"asc\";\n }\n\n this._updateSortIcons(table);\n this._sortTable(table, columnIndex, this._sortDirection);\n }\n\n _sortTable(\n table: HTMLTableElement,\n columnIndex: number,\n direction: \"asc\" | \"desc\",\n ) {\n const tbody = table.querySelector(\"tbody\");\n if (!tbody) return;\n\n const rows = Array.from(tbody.querySelectorAll(\"tr\"));\n\n rows.sort((a, b) => {\n const aText = a.children[columnIndex]?.textContent?.trim() ?? \"\";\n const bText = b.children[columnIndex]?.textContent?.trim() ?? \"\";\n\n const aNum = Number(aText);\n const bNum = Number(bText);\n\n let result;\n\n if (!isNaN(aNum) && !isNaN(bNum)) {\n result = aNum - bNum;\n } else {\n result = aText.localeCompare(bText);\n }\n\n return direction === \"asc\" ? result : -result;\n });\n\n // Re-append sorted rows\n rows.forEach((r) => tbody.appendChild(r));\n this._updateSortedColumnStyles(table);\n }\n\n _updateSortedColumnStyles(table: HTMLTableElement) {\n const rows = table.querySelectorAll(\"tbody tr\");\n\n rows.forEach((row) => {\n Array.from(row.children).forEach((cell, index) => {\n if (index === this._sortColumn) {\n cell.classList.add(\"nys-table__sortedcolumn\");\n } else {\n cell.classList.remove(\"nys-table__sortedcolumn\");\n }\n });\n });\n }\n\n downloadFile() {\n // read file from this.download and trigger download\n const link = document.createElement(\"a\");\n link.href = this.download;\n link.download = this.download.split(\"/\").pop() || \"table-data.csv\";\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n }\n\n /****************** Event Handlers ******************/\n // Placeholder for event handlers if needed\n\n render() {\n return html`\n <div class=\"nys-table\">\n <div class=\"table-container\"></div>\n </div>\n ${this.download\n ? html` <nys-button\n id=\"${this.id}-download-button\"\n label=\"Download table\"\n aria-label=${this._captionText\n ? `Download ${this._captionText}`\n : \"Download table\"}\n size=\"sm\"\n variant=\"outline\"\n prefixIcon=\"download\"\n @nys-click=${this.downloadFile}\n ></nys-button>`\n : \"\"}\n <slot style=\"display:none\"></slot>\n `;\n }\n}\n\nif (!customElements.get(\"nys-table\")) {\n customElements.define(\"nys-table\", NysTable);\n}\n"],"names":["componentIdCounter","_NysTable","LitElement","slot","container","tableEl","el","table","hasThead","hasTbody","caption","rows","thead","tbody","headerRowIndex","r","headerRow","th","node","p","i","srOnly","nextCaption","ths","index","label","button","icon","e","columnIndex","direction","a","b","aText","bText","aNum","bNum","result","row","cell","link","html","unsafeCSS","styles","NysTable","__decorateClass","property","state"],"mappings":";;;;;;;;;;;;;;;;;;AAKA,IAAIA,IAAqB;AAYlB,MAAMC,IAAN,MAAMA,UAAiBC,EAAW;AAAA;AAAA,EAevC,cAAc;AACZ,UAAA,GAbyC,KAAA,KAAK,IACL,KAAA,OAAO,IACN,KAAA,UAAU,IACV,KAAA,WAAW,IACX,KAAA,WAAW,IACZ,KAAA,WAAW,IAE7C,KAAQ,cAA6B,MACrC,KAAQ,iBAA0C,QAClD,KAAQ,eAAe;AAAA,EAKhC;AAAA;AAAA,EAGA,oBAAoB;AAClB,UAAM,kBAAA,GACD,KAAK,OACR,KAAK,KAAK,aAAa,KAAK,KAAK,IAAIF,GAAoB;AAAA,EAE7D;AAAA;AAAA;AAAA,EAKA,eAAe;AAEb,IADa,KAAK,YAAY,cAA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DC,EAAA;AAAA,EAA1CC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GAR9BF,EAQgC,WAAA,UAAA;AAE1BC,EAAA;AAAA,EAAhBE,EAAA;AAAM,GAVIH,EAUM,WAAA,aAAA;AACAC,EAAA;AAAA,EAAhBE,EAAA;AAAM,GAXIH,EAWM,WAAA,gBAAA;AACAC,EAAA;AAAA,EAAhBE,EAAA;AAAM,GAZIH,EAYM,WAAA,cAAA;AA2Td,eAAe,IAAI,WAAW,KACjC,eAAe,OAAO,aAAaA,CAAQ;"}
1
+ {"version":3,"file":"nys-table.js","sources":["../src/nys-table.ts"],"sourcesContent":["import { LitElement, html, unsafeCSS } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\n// @ts-ignore: SCSS module imported via bundler as inline\nimport styles from \"./nys-table.scss?inline\";\n\nlet componentIdCounter = 0;\n\n/**\n * `<nys-table>` is a responsive table component that can display native HTML tables,\n * supports striped and bordered styling, sortable columns, and CSV download.\n *\n * @slot - Accepts a `<table>` element. Only the first table is rendered.\n *\n * @fires nys-click - Fired when the download button or sortable headers are clicked.\n * @fires nys-column-sort - Fired when a sortable column header is clicked. Can be prevented by calling `event.preventDefault()` to override default sort behavior.\n * Detail: { columnIndex: number, columnLabel: string, sortDirection: \"asc\" | \"desc\" | \"none\" }\n *\n * @method downloadFile - Triggers download of the CSV file if `download` is set.\n */\nexport class NysTable extends LitElement {\n static styles = unsafeCSS(styles);\n\n @property({ type: String, reflect: true }) id = \"\";\n @property({ type: String, reflect: true }) name = \"\";\n @property({ type: Boolean, reflect: true }) striped = false;\n @property({ type: Boolean, reflect: true }) sortable = false;\n @property({ type: Boolean, reflect: true }) bordered = false;\n @property({ type: String, reflect: true }) download = \"\";\n\n @state() private _sortColumn: number | null = null;\n @state() private _sortDirection: \"asc\" | \"desc\" | \"none\" = \"none\";\n @state() private _captionText = \"\";\n\n /**************** Lifecycle Methods ****************/\n constructor() {\n super();\n }\n\n // Generate a unique ID if one is not provided\n connectedCallback() {\n super.connectedCallback();\n if (!this.id) {\n this.id = `nys-table-${Date.now()}-${componentIdCounter++}`;\n }\n }\n\n /******************** Functions ********************/\n // Placeholder for generic functions (component-specific)\n\n firstUpdated() {\n const slot = this.shadowRoot?.querySelector(\"slot\");\n slot?.addEventListener(\"slotchange\", () => this._handleSlotChange());\n this._handleSlotChange();\n }\n\n _handleSlotChange() {\n const slot = this.shadowRoot?.querySelector(\n \"slot\",\n ) as HTMLSlotElement | null;\n const container = this.shadowRoot?.querySelector(\n \".table-container\",\n ) as HTMLElement | null;\n\n if (!slot || !container) return;\n\n container.innerHTML = \"\";\n\n const assigned = slot.assignedElements({ flatten: true });\n const tableEl = assigned.find((el) => el.tagName === \"TABLE\") as\n | HTMLTableElement\n | undefined;\n\n if (!tableEl) return;\n\n const table = tableEl.cloneNode(true) as HTMLTableElement;\n\n this._normalizeTableDOM(table);\n\n if (this.sortable) {\n this._addSortIcons(table);\n }\n\n container.appendChild(table);\n }\n\n _normalizeTableDOM(table: HTMLTableElement) {\n const hasThead = table.querySelector(\"thead\");\n const hasTbody = table.querySelector(\"tbody\");\n\n if (hasThead && hasTbody) return;\n\n // Pull caption first\n const caption = table.querySelector(\n \"caption\",\n ) as HTMLTableCaptionElement | null;\n\n // Collect all rows\n const rows = Array.from(table.querySelectorAll(\"tr\"));\n if (rows.length === 0) return;\n\n const thead = document.createElement(\"thead\");\n const tbody = document.createElement(\"tbody\");\n\n // Find first row containing th\n const headerRowIndex = rows.findIndex((r) => r.querySelector(\"th\"));\n\n if (headerRowIndex === -1) {\n rows.forEach((r) => tbody.appendChild(r));\n } else {\n const headerRow = rows[headerRowIndex];\n\n // Wrap text nodes in <p> for each <th>\n headerRow.querySelectorAll(\"th\").forEach((th) => {\n // Only wrap text nodes, leave icons or other children\n Array.from(th.childNodes).forEach((node) => {\n if (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()) {\n const p = document.createElement(\"p\");\n p.textContent = node.textContent;\n th.replaceChild(p, node);\n }\n });\n });\n\n thead.appendChild(headerRow);\n\n // Move remaining rows to tbody\n rows.forEach((r, i) => {\n if (i !== headerRowIndex) tbody.appendChild(r);\n });\n }\n\n // Wipe original table content\n table.innerHTML = \"\";\n\n // Handle caption and sortable message\n if (caption) {\n table.appendChild(caption);\n }\n\n if (this.sortable) {\n const srOnly = document.createElement(\"span\");\n srOnly.setAttribute(\"class\", \"sr-only\");\n srOnly.textContent = \"Column headers with buttons are sortable.\";\n\n if (caption) {\n caption.appendChild(srOnly);\n } else {\n const nextCaption = document.createElement(\"caption\");\n nextCaption.appendChild(srOnly);\n table.appendChild(nextCaption);\n }\n }\n\n table.appendChild(thead);\n table.appendChild(tbody);\n }\n\n willUpdate() {\n const table = Array.from(this.children).find(\n (el) => el.tagName === \"TABLE\",\n ) as HTMLTableElement | undefined;\n\n if (!table) return;\n\n const caption = table.querySelector(\"caption\");\n const nextCaption = caption?.textContent?.trim() ?? \"\";\n\n if (this._captionText !== nextCaption) {\n this._captionText = nextCaption;\n }\n }\n\n _addSortIcons(table: HTMLTableElement) {\n const ths = Array.from(table.querySelectorAll(\"thead th\"));\n if (ths.length === 0) return;\n\n ths.forEach((th, index) => {\n // Prevent duplicates on slotchange or re-render\n if (th.querySelector(\"nys-button[part='sort-button']\")) return;\n\n // Get existing text content\n const label = th.textContent?.trim();\n if (!label) return;\n\n // Clear existing content\n th.textContent = \"\";\n\n const button = document.createElement(\"nys-button\");\n button.setAttribute(\"part\", \"sort-button\");\n button.setAttribute(\"variant\", \"ghost\");\n button.setAttribute(\"label\", label);\n button.setAttribute(\"suffixIcon\", \"slotted\");\n button.setAttribute(\"fullWidth\", \"true\");\n\n const icon = document.createElement(\"nys-icon\");\n icon.setAttribute(\"slot\", \"suffix-icon\");\n icon.setAttribute(\"name\", \"height\");\n icon.setAttribute(\"size\", \"24\");\n icon.setAttribute(\"color\", \"var(--nys-color-text-weak, #4a4d4f)\");\n\n button.appendChild(icon);\n\n button.addEventListener(\"nys-click\", (e) => {\n e.stopPropagation();\n this._onSortClick(index, table);\n });\n\n th.appendChild(button);\n });\n }\n\n _updateSortIcons(table: HTMLTableElement) {\n const ths = table.querySelectorAll(\"thead th\");\n\n ths.forEach((th, index) => {\n const button = th.querySelector(\"nys-button[part='sort-button']\");\n const icon = button?.querySelector(\n \"nys-icon[slot='suffix-icon']\",\n ) as HTMLElement | null;\n\n if (!button || !icon) return;\n\n if (index === this._sortColumn) {\n th.classList.add(\"nys-table__sortedcolumn\");\n switch (this._sortDirection) {\n case \"asc\":\n icon.setAttribute(\"name\", \"straight\");\n icon.setAttribute(\"color\", \"var(--nys-color-ink, #1b1b1b)\");\n icon.style.transform = \"rotate(0deg)\";\n th.setAttribute(\"aria-sort\", \"ascending\");\n break;\n case \"desc\":\n icon.setAttribute(\"name\", \"straight\");\n icon.setAttribute(\"color\", \"var(--nys-color-ink, #1b1b1b)\");\n icon.style.transform = \"rotate(180deg)\";\n th.setAttribute(\"aria-sort\", \"descending\");\n break;\n }\n } else {\n // Reset for all other columns\n th.classList.remove(\"nys-table__sortedcolumn\");\n icon.setAttribute(\"name\", \"height\");\n icon.setAttribute(\"color\", \"var(--nys-color-text-weak, #4a4d4f)\");\n icon.style.transform = \"\";\n th.removeAttribute(\"aria-sort\");\n }\n });\n }\n\n private _onSortClick(columnIndex: number, table: HTMLTableElement) {\n const ths = Array.from(table.querySelectorAll(\"thead th\"));\n const columnLabel =\n ths[columnIndex]\n ?.querySelector(\"nys-button[part='sort-button']\")\n ?.getAttribute(\"label\") ?? \"\";\n\n const nextDirection: \"asc\" | \"desc\" =\n this._sortColumn !== columnIndex\n ? \"asc\"\n : this._sortDirection === \"asc\"\n ? \"desc\"\n : \"asc\";\n\n const prevented = this._emitColumnSortEvent(\n columnIndex,\n columnLabel,\n nextDirection,\n );\n\n if (prevented) return;\n\n this._sortColumn = columnIndex;\n this._sortDirection = nextDirection;\n\n this._updateSortIcons(table);\n this._sortTable(table, columnIndex, this._sortDirection);\n }\n\n _sortTable(\n table: HTMLTableElement,\n columnIndex: number,\n direction: \"asc\" | \"desc\",\n ) {\n const tbody = table.querySelector(\"tbody\");\n if (!tbody) return;\n\n const rows = Array.from(tbody.querySelectorAll(\"tr\"));\n\n rows.sort((a, b) => {\n const aText = a.children[columnIndex]?.textContent?.trim() ?? \"\";\n const bText = b.children[columnIndex]?.textContent?.trim() ?? \"\";\n\n const aNum = Number(aText);\n const bNum = Number(bText);\n\n let result;\n\n if (!isNaN(aNum) && !isNaN(bNum)) {\n result = aNum - bNum;\n } else {\n result = aText.localeCompare(bText);\n }\n\n return direction === \"asc\" ? result : -result;\n });\n\n // Re-append sorted rows\n rows.forEach((r) => tbody.appendChild(r));\n this._updateSortedColumnStyles(table);\n }\n\n _updateSortedColumnStyles(table: HTMLTableElement) {\n const rows = table.querySelectorAll(\"tbody tr\");\n\n rows.forEach((row) => {\n Array.from(row.children).forEach((cell, index) => {\n if (index === this._sortColumn) {\n cell.classList.add(\"nys-table__sortedcolumn\");\n } else {\n cell.classList.remove(\"nys-table__sortedcolumn\");\n }\n });\n });\n }\n\n downloadFile() {\n // read file from this.download and trigger download\n const link = document.createElement(\"a\");\n link.href = this.download;\n link.download = this.download.split(\"/\").pop() || \"table-data.csv\";\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n }\n\n /****************** Event Handlers ******************/\n\n /**\n * Dispatches the `nys-column-sort` custom event.\n *\n * @param columnIndex - Zero-based index of the sorted column.\n * @param columnLabel - The text label of the sorted column header.\n * @param sortDirection - The new sort direction: \"asc\", \"desc\", or \"none\".\n */\n private _emitColumnSortEvent(\n columnIndex: number,\n columnLabel: string,\n sortDirection: \"asc\" | \"desc\" | \"none\",\n ): boolean {\n const event = new CustomEvent(\"nys-column-sort\", {\n detail: { columnIndex, columnLabel, sortDirection },\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n\n this.dispatchEvent(event);\n return event.defaultPrevented;\n }\n\n /****************** Render ******************/\n\n render() {\n return html`\n <div class=\"nys-table\">\n <div class=\"table-container\"></div>\n </div>\n ${this.download\n ? html` <nys-button\n id=\"${this.id}-download-button\"\n label=\"Download table\"\n aria-label=${this._captionText\n ? `Download ${this._captionText}`\n : \"Download table\"}\n size=\"sm\"\n variant=\"outline\"\n prefixIcon=\"download\"\n @nys-click=${this.downloadFile}\n ></nys-button>`\n : \"\"}\n <slot style=\"display:none\"></slot>\n `;\n }\n}\n\nif (!customElements.get(\"nys-table\")) {\n customElements.define(\"nys-table\", NysTable);\n}\n"],"names":["componentIdCounter","_NysTable","LitElement","slot","container","tableEl","el","table","hasThead","hasTbody","caption","rows","thead","tbody","headerRowIndex","r","headerRow","th","node","i","srOnly","nextCaption","ths","index","label","button","icon","e","columnIndex","columnLabel","nextDirection","direction","a","b","aText","bText","aNum","bNum","result","row","cell","link","sortDirection","event","html","unsafeCSS","styles","NysTable","__decorateClass","property","state"],"mappings":";;;;;;;;;;;;;;;;;;AAKA,IAAIA,IAAqB;AAclB,MAAMC,IAAN,MAAMA,UAAiBC,EAAW;AAAA;AAAA,EAevC,cAAc;AACZ,UAAA,GAbyC,KAAA,KAAK,IACL,KAAA,OAAO,IACN,KAAA,UAAU,IACV,KAAA,WAAW,IACX,KAAA,WAAW,IACZ,KAAA,WAAW,IAE7C,KAAQ,cAA6B,MACrC,KAAQ,iBAA0C,QAClD,KAAQ,eAAe;AAAA,EAKhC;AAAA;AAAA,EAGA,oBAAoB;AAClB,UAAM,kBAAA,GACD,KAAK,OACR,KAAK,KAAK,aAAa,KAAK,KAAK,IAAIF,GAAoB;AAAA,EAE7D;AAAA;AAAA;AAAA,EAKA,eAAe;AAEb,IADa,KAAK,YAAY,cAAc,MAAM,GAC5C,iBAAiB,cAAc,MAAM,KAAK,mBAAmB,GACnE,KAAK,kBAAA;AAAA,EACP;AAAA,EAEA,oBAAoB;AAClB,UAAMG,IAAO,KAAK,YAAY;AAAA,MAC5B;AAAA,IAAA,GAEIC,IAAY,KAAK,YAAY;AAAA,MACjC;AAAA,IAAA;AAGF,QAAI,CAACD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M,SAAS,SAAS,IAAM;AAAA,GAL/BF,EAKiC,WAAA,SAAA;AACAC,EAAA;AAAA,EAA3CC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GAN/BF,EAMiC,WAAA,UAAA;AACAC,EAAA;AAAA,EAA3CC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GAP/BF,EAOiC,WAAA,UAAA;AACDC,EAAA;AAAA,EAA1CC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GAR9BF,EAQgC,WAAA,UAAA;AAE1BC,EAAA;AAAA,EAAhBE,EAAA;AAAM,GAVIH,EAUM,WAAA,aAAA;AACAC,EAAA;AAAA,EAAhBE,EAAA;AAAM,GAXIH,EAWM,WAAA,gBAAA;AACAC,EAAA;AAAA,EAAhBE,EAAA;AAAM,GAZIH,EAYM,WAAA,cAAA;AAkWd,eAAe,IAAI,WAAW,KACjC,eAAe,OAAO,aAAaA,CAAQ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nysds/nys-table",
3
- "version": "1.15.0",
3
+ "version": "1.16.0-alpha4",
4
4
  "description": "The Table component from the NYS Design System.",
5
5
  "module": "dist/nys-table.js",
6
6
  "types": "dist/index.d.ts",
@@ -16,15 +16,15 @@
16
16
  ],
17
17
  "scripts": {
18
18
  "dev": "tsc --emitDeclarationOnly && vite",
19
- "build": "tsc --emitDeclarationOnly && vite build",
19
+ "build": "vite build",
20
20
  "test": "vite build && wtr",
21
21
  "build:watch": "tsc --emitDeclarationOnly && vite build --watch",
22
22
  "test:watch": "vite build && wtr --watch",
23
23
  "lit-analyze": "lit-analyzer '*.ts'"
24
24
  },
25
25
  "dependencies": {
26
- "@nysds/nys-icon": "^1.15.0",
27
- "@nysds/nys-button": "^1.15.0"
26
+ "@nysds/nys-icon": "^1.16.0-alpha4",
27
+ "@nysds/nys-button": "^1.16.0-alpha4"
28
28
  },
29
29
  "devDependencies": {
30
30
  "lit": "^3.3.1",
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./nys-table";
@@ -1,39 +0,0 @@
1
- import { LitElement } from "lit";
2
- /**
3
- * `<nys-table>` is a responsive table component that can display native HTML tables,
4
- * supports striped and bordered styling, sortable columns, and CSV download.
5
- *
6
- * @slot - Accepts a `<table>` element. Only the first table is rendered.
7
- *
8
- * @fires nys-click - Fired when the download button or sortable headers are clicked.
9
- *
10
- * @method downloadFile - Triggers download of the CSV file if `download` is set.
11
- */
12
- export declare class NysTable extends LitElement {
13
- static styles: import("lit").CSSResult;
14
- id: string;
15
- name: string;
16
- striped: boolean;
17
- sortable: boolean;
18
- bordered: boolean;
19
- download: string;
20
- private _sortColumn;
21
- private _sortDirection;
22
- private _captionText;
23
- /**************** Lifecycle Methods ****************/
24
- constructor();
25
- connectedCallback(): void;
26
- /******************** Functions ********************/
27
- firstUpdated(): void;
28
- _handleSlotChange(): void;
29
- _normalizeTableDOM(table: HTMLTableElement): void;
30
- willUpdate(): void;
31
- _addSortIcons(table: HTMLTableElement): void;
32
- _updateSortIcons(table: HTMLTableElement): void;
33
- _onSortClick(columnIndex: number, table: HTMLTableElement): void;
34
- _sortTable(table: HTMLTableElement, columnIndex: number, direction: "asc" | "desc"): void;
35
- _updateSortedColumnStyles(table: HTMLTableElement): void;
36
- downloadFile(): void;
37
- /****************** Event Handlers ******************/
38
- render(): import("lit-html").TemplateResult<1>;
39
- }
@@ -1 +0,0 @@
1
- export {};