@spectric/ui 0.0.12 → 0.0.13

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/style.css CHANGED
@@ -1 +1 @@
1
- spectric-input{--input-color: var(--spectric-input-color, #f4f4f4);--border-radius: var(--spectric-border-radius, .4em);--input-bottom: var(--spectric-input-bottom, var(--spectric-button-primary, #a8a8a8));--input-bottom-focused: var(--primary, #1ea7fd);--text-on-color: var(--spectric-text-on-color, #ffffff);--text-on-color-disabled: var(--spectric-text-on-color-disabled, #8d8d8d);--text-placeholder: rgba(22, 22, 22, .4);--text-primary: var(--spectric-text-primary, #161616);--text-secondary: var(--spectric-text-secondary, #525252)}spectric-input .inputWrapper{color:var(--text-secondary)}spectric-input .inputWrapper input{box-sizing:border-box;margin:0;vertical-align:baseline;font-size:.875rem;font-weight:400;line-height:1.28572;letter-spacing:.16px;outline:transparent solid 2px;outline-offset:-2px;border:none;padding:0 1rem;background-color:var(--input-color);color:var(--text-primary, #161616);font-family:inherit;inline-size:100%;block-size:2.5rem}spectric-input .inputWrapper .inputContainer:active:after,spectric-input .inputContainer:focus-within:after{border-bottom-color:var(--input-bottom-focused);width:calc(100% - 5px);transition:width .4s ease-in-out}spectric-input .inputWrapper input:read-only{background-color:transparent;border-bottom-color:var(--border-disabled)}spectric-input .inputContainer{position:relative;border-radius:var(--border-radius);overflow:hidden}spectric-input .inputContainer:after{content:"";width:0px;transition:background-color .4s cubic-bezier(.2,0,.38,.9),border-bottom-color .4s cubic-bezier(.2,0,.38,.9);border-bottom-color:var(--input-bottom);border-bottom-style:solid;border-bottom-width:1px;position:absolute;left:2.5px;bottom:0}spectric-input #helper-text{height:18px}spectric-input[variant=password] spectric-button{position:absolute;right:4px;bottom:3px}spectric-input .checkbox{display:flex;justify-self:center}spectric-query{font-family:monospace}spectric-query .autocomplete{color:var(--spectric-text-primary, #161616);border-radius:0em 0em var(--spectric-border-radius, .4em) var(--spectric-border-radius, .4em);background-color:var(--spectric-background, #ffffff);border:1px solid var(--spectric-background-hover, rgba(141, 141, 141, .12));max-height:300px;border-top:0px;margin:-18px 0 0;position:fixed;top:anchor(bottom);justify-self:anchor-center;text-align:center}spectric-query .autocomplete .optiontype{float:left;max-width:10px}spectric-query .autocomplete .label{position:absolute;right:0}spectric-query .autocomplete .option.active,spectric-query .autocomplete .option:hover{background-color:var(--spectric-background-hover, rgba(141, 141, 141, .12));border-bottom:1px solid var(--primary, #1ea7fd)}spectric-query .autocomplete .option{border-bottom:1px solid transparent;padding:8px}.query-bar-date-quick-select{display:flex;justify-content:space-evenly}spectric-pagination .spectric-pagination-container{display:flex;justify-content:space-between;align-items:center}spectric-pagination .spectric-pagination-text{flex-grow:1;text-align:center}spectric-table{display:flex;flex-direction:column;overflow:hidden}spectric-table .table-wrapper{overflow:auto;flex-grow:1;position:relative}spectric-table tr{text-align:center}spectric-table tr.odd{background-color:color-mix(in srgb,var(--spectric-primary, #1ea7fd),transparent 90%)}spectric-table tr:hover{background-color:color-mix(in srgb,var(--spectric-primary, #1ea7fd),transparent 70%)}spectric-table-header{display:table-header-group;font-weight:700;position:sticky;top:0;left:0;z-index:1;background:var(--spectric-background, #ffffff)}spectric-table-header td{vertical-align:middle}spectric-table tr{line-height:var(--rowHeight)}spectric-table td{height:var(--rowHeight)}spectric-table-header .header-contents{position:relative}spectric-table-header .header-contents .sort-direction{position:absolute;right:0}spectric-table-header .header-contents.sortable{cursor:pointer}spectric-table-header .header-contents.sortable:hover .sort-direction.none:before{content:"⮁"}spectric-table div[role=table]{display:table;min-width:100%}spectric-table-cell{display:contents;vertical-align:middle}spectric-table-cell td{position:relative}spectric-table td:hover:has(.filterable){border:1px solid var(--spectric-primary, #1ea7fd)}spectric-table td{border:1px solid transparent}spectric-table-cell .table-cell-actions{position:absolute;display:flex;width:100%;flex-direction:row-reverse;visibility:hidden;top:-10px}spectric-table-cell td:hover .table-cell-actions{visibility:unset}spectric-table .table-checkbox-single spectric-button{--button-border-radius: 50%}spectric-input.table-checkbox-single[checked] spectric-button{--text-on-color: transparent;border-radius:50%;position:relative}spectric-input.table-checkbox-single[checked] spectric-button:before{position:absolute;content:" ";height:50%;width:50%;left:25%;top:25%;border-radius:50%;z-index:1;box-shadow:0 0 0 4px var(--input-color)}spectric-table-body{display:table-row-group}spectric-table-virtual-body{display:contents}spectric-table-virtual-body .virtual-scroll-spacer td{padding:0;border:0px}.spectric-tooltip-portal{position:fixed;z-index:9999;pointer-events:none;--spectric-tooltip-background: color-mix(in srgb,var(--spectric-background-inverse,#f4f4f4) 100%,var(--spectric-primary,#1ea7fd) 90%) }.spectric-tooltip-portal .tooltip-container{display:flex;justify-content:center;align-items:center}.spectric-tooltip-portal.top .tooltip-container{flex-direction:column-reverse}.spectric-tooltip-portal.bottom .tooltip-container{flex-direction:column}.spectric-tooltip-portal.left .tooltip-container{flex-direction:row-reverse}.spectric-tooltip-portal .tooltip-content{background:var(--spectric-tooltip-background);border-radius:var(--spectric-border-radius,.4em);box-shadow:0 0 .01em .01em color-mix(in srgb,var(--spectric-background-hover,rgba(141, 141, 141, .12)) 90%,var(--spectric-text-on-color,#ffffff) 90%);padding:.2em;color:var(--spectric-text-on-color,#ffffff)}.spectric-tooltip-portal .tooltip-caret{background:var(--spectric-tooltip-background)}.spectric-tooltip-portal.top .tooltip-caret,.spectric-tooltip-portal.bottom .tooltip-caret{inline-size:.75rem;block-size:.374rem}.spectric-tooltip-portal.left .tooltip-caret,.spectric-tooltip-portal.right .tooltip-caret{inline-size:.375rem;block-size:.75rem}.spectric-tooltip-portal.top .tooltip-caret{clip-path:polygon(0 0,50% 100%,100% 0)}.spectric-tooltip-portal.bottom .tooltip-caret{clip-path:polygon(0 100%,50% 0,100% 100%)}.spectric-tooltip-portal.left .tooltip-caret{clip-path:polygon(0 0,100% 50%,0 100%)}.spectric-tooltip-portal.right .tooltip-caret{clip-path:polygon(0 50%,100% 0,100% 100%)}
1
+ spectric-input{--input-color: var(--spectric-input-color, #f4f4f4);--border-radius: var(--spectric-border-radius, .4em);--input-bottom: var(--spectric-input-bottom, var(--spectric-button-primary, #a8a8a8));--input-bottom-focused: var(--primary, #1ea7fd);--text-on-color: var(--spectric-text-on-color, #ffffff);--text-on-color-disabled: var(--spectric-text-on-color-disabled, #8d8d8d);--text-placeholder: rgba(22, 22, 22, .4);--text-primary: var(--spectric-text-primary, #161616);--text-secondary: var(--spectric-text-secondary, #525252)}spectric-input .inputWrapper{color:var(--text-secondary)}spectric-input .inputWrapper input{box-sizing:border-box;margin:0;vertical-align:baseline;font-size:.875rem;font-weight:400;line-height:1.28572;letter-spacing:.16px;outline:transparent solid 2px;outline-offset:-2px;border:none;padding:0 1rem;background-color:var(--input-color);color:var(--text-primary, #161616);font-family:inherit;inline-size:100%;block-size:2.5rem}spectric-input .inputWrapper .inputContainer:active:after,spectric-input .inputContainer:focus-within:after{border-bottom-color:var(--input-bottom-focused);width:calc(100% - 5px);transition:width .4s ease-in-out}spectric-input .inputWrapper input:read-only{background-color:transparent;border-bottom-color:var(--border-disabled)}spectric-input .inputContainer{position:relative;border-radius:var(--border-radius);overflow:hidden}spectric-input .inputContainer:after{content:"";width:0px;transition:background-color .4s cubic-bezier(.2,0,.38,.9),border-bottom-color .4s cubic-bezier(.2,0,.38,.9);border-bottom-color:var(--input-bottom);border-bottom-style:solid;border-bottom-width:1px;position:absolute;left:2.5px;bottom:0}spectric-input #helper-text{height:18px}spectric-input[variant=password] spectric-button{position:absolute;right:4px;bottom:3px}spectric-input .checkbox{display:flex;justify-self:center}spectric-query{font-family:monospace}spectric-query .autocomplete{color:var(--spectric-text-primary, #161616);border-radius:0em 0em var(--spectric-border-radius, .4em) var(--spectric-border-radius, .4em);background-color:var(--spectric-background, #ffffff);border:1px solid var(--spectric-background-hover, rgba(141, 141, 141, .12));max-height:300px;border-top:0px;margin:-18px 0 0;position:fixed;top:anchor(bottom);justify-self:anchor-center;text-align:center}spectric-query .autocomplete .optiontype{float:left;max-width:10px}spectric-query .autocomplete .label{position:absolute;right:0}spectric-query .autocomplete .option.active,spectric-query .autocomplete .option:hover{background-color:var(--spectric-background-hover, rgba(141, 141, 141, .12));border-bottom:1px solid var(--primary, #1ea7fd)}spectric-query .autocomplete .option{border-bottom:1px solid transparent;padding:8px}.query-bar-date-quick-select{display:flex;justify-content:space-evenly}spectric-pagination .spectric-pagination-container{display:flex;justify-content:space-between;align-items:center}spectric-pagination .spectric-pagination-text{flex-grow:1;text-align:center}spectric-table{display:flex;flex-direction:column;overflow:hidden}spectric-table .table-wrapper{overflow:auto;flex-grow:1;position:relative}spectric-table tr{text-align:center}spectric-table tr.odd{background-color:color-mix(in srgb,var(--spectric-primary, #1ea7fd),transparent 90%)}spectric-table tr:hover{background-color:color-mix(in srgb,var(--spectric-primary, #1ea7fd),transparent 70%)}spectric-table-header{display:table-header-group;font-weight:700;position:sticky;top:0;left:0;z-index:1;background:var(--spectric-background, #ffffff)}spectric-table-header td{vertical-align:middle}spectric-table tr{line-height:var(--rowHeight)}spectric-table td{height:var(--rowHeight)}spectric-table-header .header-contents{position:relative}spectric-table-header .header-contents .sort-direction{position:absolute;right:0;top:calc(50% - 8px)}spectric-table-header .header-contents.sortable{cursor:pointer;padding-right:15px}spectric-table-header .header-contents.sortable:hover .sort-direction.none:before{content:"⮁"}spectric-table div[role=table]{display:table;min-width:100%}spectric-table-cell{display:contents;vertical-align:middle}spectric-table-cell td{position:relative}spectric-table td:hover:has(.filterable){border:1px solid var(--spectric-primary, #1ea7fd)}spectric-table td{border:1px solid transparent}spectric-table-cell .table-cell-actions{position:absolute;display:flex;width:100%;flex-direction:row-reverse;visibility:hidden;top:-10px}spectric-table-cell td:hover .table-cell-actions{visibility:unset}spectric-table .table-checkbox-single spectric-button{--button-border-radius: 50%}spectric-input.table-checkbox-single[checked] spectric-button{--text-on-color: transparent;border-radius:50%;position:relative}spectric-input.table-checkbox-single[checked] spectric-button:before{position:absolute;content:" ";height:50%;width:50%;left:25%;top:25%;border-radius:50%;z-index:1;box-shadow:0 0 0 4px var(--input-color)}spectric-table-body{display:table-row-group}spectric-table-virtual-body{display:contents}spectric-table-virtual-body .virtual-scroll-spacer td{padding:0;border:0px}.spectric-tooltip-portal{position:fixed;z-index:9999;pointer-events:none;--spectric-tooltip-background: color-mix(in srgb,var(--spectric-background-inverse,#f4f4f4) 100%,var(--spectric-primary,#1ea7fd) 90%) }.spectric-tooltip-portal .tooltip-container{display:flex;justify-content:center;align-items:center}.spectric-tooltip-portal.top .tooltip-container{flex-direction:column-reverse}.spectric-tooltip-portal.bottom .tooltip-container{flex-direction:column}.spectric-tooltip-portal.left .tooltip-container{flex-direction:row-reverse}.spectric-tooltip-portal .tooltip-content{background:var(--spectric-tooltip-background);border-radius:var(--spectric-border-radius,.4em);box-shadow:0 0 .01em .01em color-mix(in srgb,var(--spectric-background-hover,rgba(141, 141, 141, .12)) 90%,var(--spectric-text-on-color,#ffffff) 90%);padding:.2em;color:var(--spectric-text-on-color,#ffffff)}.spectric-tooltip-portal .tooltip-caret{background:var(--spectric-tooltip-background)}.spectric-tooltip-portal.top .tooltip-caret,.spectric-tooltip-portal.bottom .tooltip-caret{inline-size:.75rem;block-size:.374rem}.spectric-tooltip-portal.left .tooltip-caret,.spectric-tooltip-portal.right .tooltip-caret{inline-size:.375rem;block-size:.75rem}.spectric-tooltip-portal.top .tooltip-caret{clip-path:polygon(0 0,50% 100%,100% 0)}.spectric-tooltip-portal.bottom .tooltip-caret{clip-path:polygon(0 100%,50% 0,100% 100%)}.spectric-tooltip-portal.left .tooltip-caret{clip-path:polygon(0 0,100% 50%,0 100%)}.spectric-tooltip-portal.right .tooltip-caret{clip-path:polygon(0 50%,100% 0,100% 100%)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectric/ui",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "main": "./dist/index.es.js",
6
6
  "module": "./dist/index.es.js",
@@ -43,37 +43,37 @@ export class TableCellElement<T> extends LitElement implements CellProps<T> {
43
43
  protected createRenderRoot(): HTMLElement | DocumentFragment {
44
44
  return this
45
45
  }
46
+ _emitFilter(filter: FilterEvent<T>) {
47
+ this.dispatchEvent(new CustomEvent<FilterEvent<T>>("filter", {
48
+ composed: true,
49
+ bubbles: true,
50
+ detail: filter
51
+ }))
52
+ }
46
53
  _handleFilterOut = () => {
47
54
  let value = undefined;
48
55
  if (this.column.key && typeof this.row === "object") {
49
56
  value = rowGetValue(this.row as Record<any, any>, this.column.key)
50
57
  }
51
- this.dispatchEvent(new CustomEvent<FilterEvent<T>>("filter", {
52
- composed: true,
53
- bubbles: true,
54
- detail: {
55
- include: false,
56
- row: this.row,
57
- value,
58
- column: this.column
59
- }
60
- }))
58
+ this._emitFilter({
59
+ include: false,
60
+ row: this.row,
61
+ value,
62
+ column: this.column
63
+ })
64
+
61
65
  }
62
66
  _handleFilterFor = () => {
63
67
  let value = undefined;
64
68
  if (this.column.key && typeof this.row === "object") {
65
69
  value = rowGetValue(this.row as Record<any, any>, this.column.key)
66
70
  }
67
- this.dispatchEvent(new CustomEvent<FilterEvent<T>>("filter", {
68
- composed: true,
69
- bubbles: true,
70
- detail: {
71
- include: true,
72
- row: this.row,
73
- value,
74
- column: this.column
75
- }
76
- }))
71
+ this._emitFilter({
72
+ include: true,
73
+ row: this.row,
74
+ value,
75
+ column: this.column
76
+ })
77
77
  }
78
78
  protected render(): unknown {
79
79
  let rendered
@@ -30,11 +30,15 @@ export class TableHeaderElement<T> extends LitElement implements HeaderProps<T>
30
30
  if (column.sortDirection === TableSortDirection.none || column.sortDirection === undefined) {
31
31
  column.sortDirection = TableSortDirection.ascending
32
32
  } else if (column.sortDirection === TableSortDirection.ascending) {
33
- column.sortDirection = TableSortDirection.decending
34
- } else if (column.sortDirection === TableSortDirection.decending) {
33
+ column.sortDirection = TableSortDirection.descending
34
+ } else if (column.sortDirection === TableSortDirection.descending) {
35
35
  column.sortDirection = TableSortDirection.none
36
36
  }
37
- this.dispatchEvent(new CustomEvent<ColumnSettings<T>>("sortChange", { detail: column }))
37
+ this.dispatchEvent(new CustomEvent<ColumnSettings<T>>("sortChange", {
38
+ composed: true,
39
+ bubbles: true,
40
+ detail: column
41
+ }))
38
42
  }
39
43
  protected render(): unknown {
40
44
  return html`
@@ -48,7 +52,7 @@ export class TableHeaderElement<T> extends LitElement implements HeaderProps<T>
48
52
  classes.push("sortable")
49
53
  }
50
54
  let columnWidth = column.width ? `width:${column.width}px;` : ""
51
- let sortDirection = column.sortDirection === TableSortDirection.ascending ? `🠉` : column.sortDirection == TableSortDirection.decending ? `🠋` : ``
55
+ let sortDirection = column.sortDirection === TableSortDirection.ascending ? `🠉` : column.sortDirection == TableSortDirection.descending ? `🠋` : ``
52
56
  let sortClass = column.sortDirection || TableSortDirection.none
53
57
  return html`
54
58
  <td @click=${() => this._handleSortChange(column)} style="${columnWidth}">
@@ -19,12 +19,12 @@ export const createSortChain = <T>(sorts: ColumnSettings<T>[]) => {
19
19
  if (typeof v1 === "number" || typeof v1 === "bigint" || typeof v1 === "boolean") {
20
20
  //@ts-ignore
21
21
  let sort: number = v1 - v2 as unknown as number
22
- if (sortDirection === TableSortDirection.decending) {
22
+ if (sortDirection === TableSortDirection.descending) {
23
23
  sort = sort * -1
24
24
  }
25
25
  return sort
26
26
  } else if (typeof v1 === "string") {
27
- return v1.localeCompare(v2) * (sortDirection === TableSortDirection.decending ? -1 : 1)
27
+ return v1.localeCompare(v2) * (sortDirection === TableSortDirection.descending ? -1 : 1)
28
28
  }
29
29
  once(() => { console.error(`Unable to sort type ${typeof v1}`) })
30
30
  return undefined
@@ -43,9 +43,11 @@ spectric-table-header .header-contents {
43
43
  spectric-table-header .header-contents .sort-direction {
44
44
  position: absolute;
45
45
  right: 0;
46
+ top: calc(50% - 8px)
46
47
  }
47
48
  spectric-table-header .header-contents.sortable {
48
49
  cursor: pointer;
50
+ padding-right:15px
49
51
  }
50
52
  spectric-table-header .header-contents.sortable:hover .sort-direction.none::before
51
53
  {
@@ -28,7 +28,7 @@ export enum TableSortOption {
28
28
  export type TableSortOptionTypes = `${TableSortOption}`
29
29
  export enum TableSortDirection {
30
30
  ascending = "ascending",
31
- decending = "decending",
31
+ descending = "descending",
32
32
  none = "none"
33
33
  }
34
34
  export type TableSortDirectionTypes = `${TableSortDirection}`
@@ -132,6 +132,7 @@ export class TableElement<T> extends LitElement implements TableProps<T> {
132
132
  }
133
133
  this.pagination = pagination
134
134
  }
135
+ this.dispatchEvent(new CustomEvent<PaginationChangeProps>("paginationChange", { detail: e.detail }))
135
136
  this._emitChange()
136
137
  };
137
138
  private _handleSortChange = (e: CustomEvent<ColumnSettings<T>>) => {
@@ -160,20 +161,28 @@ export class TableElement<T> extends LitElement implements TableProps<T> {
160
161
  private __DO_NOT_USE_filter = () => {
161
162
  //This is only here to document events that bubble up from lower components
162
163
  this.dispatchEvent(new CustomEvent<FilterEvent<T>>("filter"))
164
+ this.dispatchEvent(new CustomEvent<ColumnSettings<T>>("sortChange"))
163
165
  }
164
166
  @state()
165
167
  private selected: T[] = [];
166
168
  protected createRenderRoot(): HTMLElement | DocumentFragment {
167
169
  return this
168
170
  }
171
+ deselectAll() {
172
+ this.selected = []
173
+ this.dispatchEvent(new CustomEvent("selected", { detail: this.selected }))
174
+ }
175
+ selectAll() {
176
+ this.selected = [...this.data]
177
+ this.dispatchEvent(new CustomEvent("selected", { detail: this.selected }))
178
+ }
169
179
  _handleSelectAllChange = (e: DomEvent<HTMLInputElement>) => {
170
180
  e.stopPropagation()
171
181
  if (e.target.checked) {
172
- this.selected = [...this.data]
182
+ this.selectAll()
173
183
  } else {
174
- this.selected = []
184
+ this.deselectAll()
175
185
  }
176
- this.dispatchEvent(new CustomEvent("selected", { detail: this.selected }))
177
186
  }
178
187
  protected update(changedProperties: PropertyValues): void {
179
188
  if (changedProperties.has("select")) {
@@ -235,7 +244,9 @@ export class TableElement<T> extends LitElement implements TableProps<T> {
235
244
 
236
245
  interface TableEvents {
237
246
  'change': (event: CustomEvent<TableDataOptions<any>>) => void;
247
+ 'paginationChange': (event: CustomEvent<PaginationChangeProps>) => void;
238
248
  'filter': (event: CustomEvent<FilterEvent<any>>) => void;
249
+ 'sortChange': (event: CustomEvent<ColumnSettings<any>>) => void;
239
250
  }
240
251
 
241
252
  declare global {