@spectric/ui 0.0.22 → 0.0.23

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 #helper-text.hidden{display:none}spectric-input .input-button-right{position:absolute;right:4px;bottom:3px}spectric-input .checkbox{display:flex;justify-self:center}spectric-input spectric-colorpicker{display:block}spectric-input[variant=color] .fieldwrapper{display:inline-block}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:0;position:fixed;top:anchor(bottom);justify-self:anchor-center;text-align:center}spectric-query .autocomplete [popover]{overflow:visible}spectric-query .autocomplete .tooltip-content{width:100%}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;line-height:1}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 spectric-table-virtual-body tr:hover{background-color:color-mix(in srgb,var(--spectric-primary, #1ea7fd),transparent 70%)}spectric-table spectric-table-virtual-body tr{height:var(--rowHeight)}spectric-table td{padding:1px;border:1px solid transparent}spectric-table spectric-table-virtual-body td{height:var(--rowHeight)}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-cell .table-cell-actions{position:absolute;display:flex;width:100%;flex-direction:row-reverse;visibility:hidden;top:-10px;z-index:1}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 .cell-contents{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:var(--lineClamp,1);-webkit-box-pack:center;overflow:hidden;text-overflow:ellipsis;font-size:var(--fontSize);height:calc(var(--lineClamp) * var(--fontSize))}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;position:relative}spectric-table-header .header-contents{position:relative}spectric-table-header .header-contents .sort-direction{position:absolute;right:2px;top:calc(50% - 8px)}spectric-table-header .header-contents.sortable{cursor:pointer;padding-right:15px}spectric-table-header .header-contents.resizing{-webkit-user-select:none;user-select:none}spectric-table-header .header-contents.sortable:hover .sort-direction.none:before{content:"⮁"}spectric-table-header td .header-resize-handle{width:2px;position:absolute;right:-1px;top:1px;visibility:hidden;background-color:var(--spectric-primary, #1ea7fd);height:100%;cursor:ew-resize;z-index:1}spectric-table-header td:hover .header-resize-handle{visibility:visible}spectric-table-header td:hover:has(*.header-resize-handle){border-bottom:1px solid var(--spectric-primary, #1ea7fd)}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-popover-portal{margin:0;border:0px;padding:0;position:fixed;z-index:9999;background:transparent;pointer-events:all;--spectric-tooltip-background-color: var(--spectric-tooltip-background, var(--spectric-background,#ffffff));--spectric-tooltip-text-color: var(--spectric-tooltip-text, var(--spectric-text-primary, rgb(0, 0, 0)));--spectric-tooltip-accent-color: var(--spectric-tooltip-accent, var(--spectric-primary, #1ea7fd))}.spectric-popover-portal.spectric-tooltip-portal{pointer-events:none}.spectric-popover-portal .tooltip-container{display:flex;justify-content:center;align-items:center}.spectric-popover-portal.top .tooltip-container{flex-direction:column-reverse}.spectric-popover-portal.bottom .tooltip-container{flex-direction:column}.spectric-popover-portal.left .tooltip-container{flex-direction:row-reverse}.spectric-popover-portal .tooltip-content{background:var(--spectric-tooltip-background-color);border-radius:var(--spectric-border-radius,.4em);border:1px solid color-mix(in srgb,var(--spectric-tooltip-background-color) 90%,var(--spectric-tooltip-accent-color) 90%);box-shadow:0 0 .01em .01em color-mix(in srgb,var(--spectric-tooltip-accent-color) 90%,var(--spectric-text-on-color,#ffffff) 90%);padding:.2em;color:var(--spectric-tooltip-text-color)}.spectric-popover-portal .tooltip-caret{background:color-mix(in srgb,var(--spectric-tooltip-background-color) 90%,var(--spectric-tooltip-accent-color) 90%)}.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-popover-portal.top .tooltip-caret{clip-path:polygon(0 0,50% 100%,100% 0)}.spectric-popover-portal.bottom .tooltip-caret{clip-path:polygon(0 100%,50% 0,100% 100%)}.spectric-popover-portal.left .tooltip-caret{clip-path:polygon(0 0,100% 50%,0 100%)}.spectric-popover-portal.right .tooltip-caret{clip-path:polygon(0 50%,100% 0,100% 100%)}spectric-input.hue-gradient input[type=range]::-moz-range-track{background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);height:15px}spectric-input.hue-gradient input[type=range]::-webkit-slider-runnable-track{background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);height:15px}spectric-input.alpha-gradient input[type=range]::-webkit-slider-runnable-track{background:linear-gradient(to right,#fff0,#fff),repeating-conic-gradient(#fff,#fff 25%,#000 25%,#000 50%,#fff 50%,#fff 75%,#000 75%,#000) 50% / 10px 10px;height:15px}spectric-input.alpha-gradient input[type=range]::-moz-range-track{background:linear-gradient(to right,#fff0,#fff),repeating-conic-gradient(#fff,#fff 25%,#000 25%,#000 50%,#fff 50%,#fff 75%,#000 75%,#000) 50% / 10px 10px;height:15px}spectric-input.alpha-gradient input[type=range],spectric-input.hue-gradient input[type=range]{-webkit-appearance:none;-moz-appearance:none;appearance:none}.color-picker-footer{display:flex;justify-content:space-evenly}.color-picker-saturation-lightness-grid{cursor:crosshair}.color-picker-eyedropper{--button-border-radius:50%}.color-picker-eyedropper.hidden{display:none}spectric-calendar{display:flex;justify-content:center;--default-text-on-color:var(--spectric-text-on-color, #ffffff)}spectric-calendar .header{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px}spectric-calendar .month-year{display:flex;align-items:center;gap:10px}spectric-calendar select{font-size:14px;padding:2px}spectric-calendar .days{display:grid;grid-template-columns:repeat(7,34px);grid-template-rows:repeat(7,34px);text-align:center;background:radial-gradient(circle at var(--x, 200%) var(--y, 200%),var(--spectric-background-inverse,#ffffff) 0%,var(--spectric-background,#f4f4f4) 25%);transition:background .1s ease;--spectric-text-on-color: var(--spectric-primary,#1ea7fd)}spectric-calendar .day{font-weight:700;padding:5px;background-color:var(--spectric-background)}spectric-calendar .date.active{--spectric-text-on-color: var(--default-text-on-color, #ffffff)}spectric-calendar .date{margin:2px}
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 #helper-text.hidden{display:none}spectric-input .input-button-right{position:absolute;right:4px;bottom:3px}spectric-input .checkbox{display:flex;justify-self:center;align-items:center}spectric-input .checkbox spectric-button~span{padding-left:5px}spectric-input spectric-colorpicker{display:block}spectric-input[variant=color] .fieldwrapper{display:inline-block}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:0;position:fixed;top:anchor(bottom);justify-self:anchor-center;text-align:center}spectric-query .autocomplete [popover]{overflow:visible}spectric-query .autocomplete .tooltip-content{width:100%}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;line-height:1}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 spectric-table-virtual-body tr:hover{background-color:color-mix(in srgb,var(--spectric-primary, #1ea7fd),transparent 70%)}spectric-table spectric-table-virtual-body tr{height:var(--rowHeight)}spectric-table td{padding:1px;border:1px solid transparent}spectric-table spectric-table-virtual-body td{height:var(--rowHeight)}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(.hasActions){border:1px solid var(--spectric-primary, #1ea7fd)}spectric-table-cell .table-cell-actions{position:absolute;display:flex;width:100%;flex-direction:row-reverse;visibility:hidden;z-index:1}spectric-table-cell .table-cell-actions.tiny{top:-10px}spectric-table-cell .table-cell-actions.xxsmall{top:-16px}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 .cell-contents{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:var(--lineClamp,1);-webkit-box-pack:center;overflow:hidden;text-overflow:ellipsis;font-size:var(--fontSize);height:calc(var(--lineClamp) * var(--fontSize))}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;position:relative}spectric-table-header .header-contents{position:relative}spectric-table-header .header-contents .sort-direction{position:absolute;right:2px;top:calc(50% - 8px)}spectric-table-header .header-contents.sortable{cursor:pointer;padding-right:15px}spectric-table-header .header-contents.resizing{-webkit-user-select:none;user-select:none}spectric-table-header .header-contents.sortable:hover .sort-direction.none:before{content:"⮁"}spectric-table-header td .header-resize-handle{width:2px;position:absolute;right:-1px;top:1px;visibility:hidden;background-color:var(--spectric-primary, #1ea7fd);height:100%;cursor:ew-resize;z-index:1}spectric-table-header td:hover .header-resize-handle{visibility:visible}spectric-table-header td:hover:has(*.header-resize-handle){border-bottom:1px solid var(--spectric-primary, #1ea7fd)}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-popover-portal{margin:0;border:0px;padding:0;position:fixed;z-index:9999;background:transparent;pointer-events:all;--spectric-tooltip-background-color: var(--spectric-tooltip-background, var(--spectric-background,#ffffff));--spectric-tooltip-text-color: var(--spectric-tooltip-text, var(--spectric-text-primary, rgb(0, 0, 0)));--spectric-tooltip-accent-color: var(--spectric-tooltip-accent, var(--spectric-primary, #1ea7fd))}.spectric-popover-portal.spectric-tooltip-portal{pointer-events:none}.spectric-popover-portal .tooltip-container{display:flex;justify-content:center;align-items:center}.spectric-popover-portal.top .tooltip-container{flex-direction:column-reverse}.spectric-popover-portal.bottom .tooltip-container{flex-direction:column}.spectric-popover-portal.left .tooltip-container{flex-direction:row-reverse}.spectric-popover-portal .tooltip-content{background:var(--spectric-tooltip-background-color);border-radius:var(--spectric-border-radius,.4em);border:1px solid color-mix(in srgb,var(--spectric-tooltip-background-color) 90%,var(--spectric-tooltip-accent-color) 90%);box-shadow:0 0 .01em .01em color-mix(in srgb,var(--spectric-tooltip-accent-color) 90%,var(--spectric-text-on-color,#ffffff) 90%);padding:.2em;color:var(--spectric-tooltip-text-color)}.spectric-popover-portal .tooltip-caret{background:color-mix(in srgb,var(--spectric-tooltip-background-color) 90%,var(--spectric-tooltip-accent-color) 90%)}.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-popover-portal.top .tooltip-caret{clip-path:polygon(0 0,50% 100%,100% 0)}.spectric-popover-portal.bottom .tooltip-caret{clip-path:polygon(0 100%,50% 0,100% 100%)}.spectric-popover-portal.left .tooltip-caret{clip-path:polygon(0 0,100% 50%,0 100%)}.spectric-popover-portal.right .tooltip-caret{clip-path:polygon(0 50%,100% 0,100% 100%)}spectric-input.hue-gradient input[type=range]::-moz-range-track{background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);height:15px}spectric-input.hue-gradient input[type=range]::-webkit-slider-runnable-track{background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);height:15px}spectric-input.alpha-gradient input[type=range]::-webkit-slider-runnable-track{background:linear-gradient(to right,#fff0,#fff),repeating-conic-gradient(#fff,#fff 25%,#000 25%,#000 50%,#fff 50%,#fff 75%,#000 75%,#000) 50% / 10px 10px;height:15px}spectric-input.alpha-gradient input[type=range]::-moz-range-track{background:linear-gradient(to right,#fff0,#fff),repeating-conic-gradient(#fff,#fff 25%,#000 25%,#000 50%,#fff 50%,#fff 75%,#000 75%,#000) 50% / 10px 10px;height:15px}spectric-input.alpha-gradient input[type=range],spectric-input.hue-gradient input[type=range]{-webkit-appearance:none;-moz-appearance:none;appearance:none}.color-picker-footer{display:flex;justify-content:space-evenly}.color-picker-saturation-lightness-grid{cursor:crosshair}.color-picker-eyedropper{--button-border-radius:50%}.color-picker-eyedropper.hidden{display:none}spectric-calendar{display:flex;justify-content:center;--default-text-on-color:var(--spectric-text-on-color, #ffffff)}spectric-calendar .header{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px}spectric-calendar .month-year{display:flex;align-items:center;gap:10px}spectric-calendar select{font-size:14px;padding:2px}spectric-calendar .days{display:grid;grid-template-columns:repeat(7,34px);grid-template-rows:repeat(7,34px);text-align:center;background:radial-gradient(circle at var(--x, 200%) var(--y, 200%),var(--spectric-background-inverse,#ffffff) 0%,var(--spectric-background,#f4f4f4) 25%);transition:background .1s ease;--spectric-text-on-color: var(--spectric-primary,#1ea7fd)}spectric-calendar .day{font-weight:700;padding:5px;background-color:var(--spectric-background)}spectric-calendar .date.active{--spectric-text-on-color: var(--default-text-on-color, #ffffff)}spectric-calendar .date{margin:2px}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectric/ui",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "type": "module",
5
5
  "main": "./dist/index.es.js",
6
6
  "module": "./dist/index.es.js",
@@ -78,6 +78,11 @@ spectric-input .input-button-right {
78
78
  spectric-input .checkbox{
79
79
  display: flex;
80
80
  justify-self: center;
81
+ align-items: center;
82
+ }
83
+ /* Padding for checkbox label */
84
+ spectric-input .checkbox spectric-button ~ span{
85
+ padding-left: 5px;
81
86
  }
82
87
  spectric-input spectric-colorpicker{
83
88
  display: block;
@@ -407,8 +407,7 @@ export class SpectricInput extends LitElement implements InputProps {
407
407
  }} icon size=${this.size || "xxsmall"} variant=${
408
408
  this.checked ? "primary" : "secondary"
409
409
  }>${this.checked ? "✓" : "\u00A0"}</spectric-button>
410
-
411
- ${this.label}
410
+ ${this.label.length ? html`<span>${this.label}</span>` : null}
412
411
  </div>
413
412
  </label>
414
413
  `;
@@ -122,16 +122,16 @@ export class TableCellElement<T> extends LitElement implements CellProps<T> {
122
122
  protected render(): unknown {
123
123
  let rendered = this.getRenderedValue();
124
124
  let classes = ["cell-contents"];
125
- if (this.column.filterable) {
126
- classes.push("filterable");
125
+ if (this.column.filterable || this.column.cellActions?.length) {
126
+ classes.push("hasActions");
127
127
  }
128
-
128
+ const buttonSize = this.table.getCellActionButtonSize();
129
129
  let filterButtons = cache(
130
130
  this.column.filterable
131
- ? html`<div class="table-cell-actions">
131
+ ? html`
132
132
  <spectric-button
133
133
  @click=${this._handleFilterOut}
134
- size="tiny"
134
+ .size=${buttonSize}
135
135
  variant="text"
136
136
  icon
137
137
  tooltip="Filter Out Value"
@@ -139,15 +139,26 @@ export class TableCellElement<T> extends LitElement implements CellProps<T> {
139
139
  >
140
140
  <spectric-button
141
141
  @click=${this._handleFilterFor}
142
- size="tiny"
142
+ .size=${buttonSize}
143
143
  variant="text"
144
144
  icon
145
145
  tooltip="Filter For Value"
146
146
  >+</spectric-button
147
147
  >
148
- </div>`
148
+ `
149
149
  : null
150
150
  );
151
+
152
+ let actions = (this.column.cellActions || []).map((action) => {
153
+ return html`<spectric-button
154
+ @click=${() => action.onClick(this.row, this.column)}
155
+ .size=${buttonSize}
156
+ variant="text"
157
+ icon
158
+ .tooltip=${action.tooltip}
159
+ >${action.icon}</spectric-button
160
+ >`;
161
+ });
151
162
  this.styleRules = {
152
163
  width: this.column.width ? this.column.width + "px" : null,
153
164
  whiteSpace: this.column.whiteSpace || null,
@@ -157,7 +168,9 @@ export class TableCellElement<T> extends LitElement implements CellProps<T> {
157
168
  style=${styleMap(this.styleRules)}
158
169
  @mouseenter=${this._displayOverflowTooltip}
159
170
  >
160
- ${filterButtons}
171
+ <div class="table-cell-actions ${buttonSize}">
172
+ ${actions} ${filterButtons}
173
+ </div>
161
174
  <div class=${classes.join(" ")}>
162
175
  ${this.overflow
163
176
  ? html`<spectric-tooltip .text=${this.overflow}></spectric-tooltip>`
@@ -44,7 +44,7 @@ spectric-table-cell td{
44
44
  position: relative;
45
45
  }
46
46
 
47
- spectric-table td:hover:has(.filterable) {
47
+ spectric-table td:hover:has(.hasActions) {
48
48
  border: 1px solid var(--spectric-primary, #1ea7fd);
49
49
  }
50
50
 
@@ -54,9 +54,14 @@ spectric-table-cell .table-cell-actions{
54
54
  width: 100%;
55
55
  flex-direction: row-reverse;
56
56
  visibility: hidden;
57
- top: -10px;
58
57
  z-index: 1;
59
58
  }
59
+ spectric-table-cell .table-cell-actions.tiny{
60
+ top: -10px;
61
+ }
62
+ spectric-table-cell .table-cell-actions.xxsmall{
63
+ top: -16px;
64
+ }
60
65
  spectric-table-cell td:hover .table-cell-actions{
61
66
  visibility: unset;
62
67
  }
@@ -14,6 +14,7 @@ import { spreadProps } from "../../utils/spread";
14
14
  import { PaginationChangeProps, PaginationProps } from "../pagination";
15
15
  import { FilterEvent } from "./cell";
16
16
  import { createSortChain } from "./sorting";
17
+ import { ButtonSizesTypes } from "../Button";
17
18
 
18
19
  export type { TableProps, TableEvents };
19
20
 
@@ -41,6 +42,11 @@ export enum TableSortDirection {
41
42
  none = "none",
42
43
  }
43
44
  export type TableSortDirectionTypes = `${TableSortDirection}`;
45
+ export type CellAction<T> = {
46
+ tooltip: DomRenderable;
47
+ icon: DomRenderable;
48
+ onClick: (row: T, column: ColumnSettings<T>) => void;
49
+ };
44
50
  export type ColumnSettings<T> = {
45
51
  [TABLE_CREATED_SELECTION_COLUMN]?: boolean;
46
52
  width?: number;
@@ -54,6 +60,7 @@ export type ColumnSettings<T> = {
54
60
  sortDirection?: TableSortDirectionTypes;
55
61
  filterable?: boolean;
56
62
  disableCellOverflowTooltip?: boolean;
63
+ cellActions?: CellAction<T>[];
57
64
  title?: DomRenderable | ((table: SpectricTableElement<T>) => DomRenderable);
58
65
  /**
59
66
  * Key to used for getting data from an object for a cell
@@ -126,6 +133,11 @@ export class SpectricTableElement<T = any>
126
133
  */
127
134
  @property({ type: Number, reflect: true })
128
135
  fontSize: number = 16;
136
+
137
+ protected cellActionButtonSize: ButtonSizesTypes = "xxsmall";
138
+ getCellActionButtonSize() {
139
+ return this.cellActionButtonSize;
140
+ }
129
141
  static getDefaultDataSorterAndPaginatior<T>(data: T[]) {
130
142
  return (props: TableDataOptions<T>) => {
131
143
  //let sorts = props.columns.filter(column => column.sortable && column.sortDirection && column.sortDirection !== TableSortDirection.none)
@@ -322,6 +334,8 @@ export class SpectricTableElement<T = any>
322
334
  };
323
335
  private selectColumnConfig: ColumnSettings<T> = {
324
336
  [TABLE_CREATED_SELECTION_COLUMN]: true,
337
+ allowResize: false,
338
+ filterable: false,
325
339
  width: 39,
326
340
  title: (table) => {
327
341
  return table.select === "multi"
@@ -1,4 +1,6 @@
1
+ import { html, svg } from "lit";
1
2
  import { ColumnSettings } from "../../components/table";
3
+ import { unsafeSVG } from "lit/directives/unsafe-svg.js";
2
4
 
3
5
  export const modulations = [
4
6
  "AM",
@@ -214,10 +216,41 @@ export const tabledata: TestData[] = [
214
216
  years: 100,
215
217
  },
216
218
  ];
217
- export const tablecolumns: ColumnSettings<TestData>[] = [
218
- { title: "Company", key: "company", width: 200 },
219
- { title: "Name", key: "name", sortable: true },
220
- { title: "Contact", key: "contact" },
221
- { title: "Country", key: "location.country", filterable: true },
222
- { title: "Years Employed", key: "years", sortable: true },
223
- ];
219
+ export const getTableColumns = () => {
220
+ const tablecolumns: ColumnSettings<TestData>[] = [
221
+ { title: "Company", key: "company", width: 200 },
222
+ { title: "Name", key: "name", sortable: true },
223
+ {
224
+ title: "Contact",
225
+ key: "contact",
226
+ cellActions: [
227
+ {
228
+ tooltip: "Call",
229
+ onClick: (row, _column) => {
230
+ alert(`Calling ${row.name} at ${row.contact}`);
231
+ },
232
+ icon: html`<svg
233
+ width="16px"
234
+ height="16px"
235
+ viewBox="0 0 24 24"
236
+ fill="none"
237
+ xmlns="http://www.w3.org/2000/svg"
238
+ >
239
+ <g>
240
+ <path
241
+ d="M14.05 6C15.0268 6.19057 15.9244 6.66826 16.6281 7.37194C17.3318 8.07561 17.8095 8.97326 18 9.95M14.05 2C16.0793 2.22544 17.9716 3.13417 19.4163 4.57701C20.8609 6.01984 21.7721 7.91101 22 9.94M18.5 21C9.93959 21 3 14.0604 3 5.5C3 5.11378 3.01413 4.73086 3.04189 4.35173C3.07375 3.91662 3.08968 3.69907 3.2037 3.50103C3.29814 3.33701 3.4655 3.18146 3.63598 3.09925C3.84181 3 4.08188 3 4.56201 3H7.37932C7.78308 3 7.98496 3 8.15802 3.06645C8.31089 3.12515 8.44701 3.22049 8.55442 3.3441C8.67601 3.48403 8.745 3.67376 8.88299 4.05321L10.0491 7.26005C10.2096 7.70153 10.2899 7.92227 10.2763 8.1317C10.2643 8.31637 10.2012 8.49408 10.0942 8.64506C9.97286 8.81628 9.77145 8.93713 9.36863 9.17882L8 10C9.2019 12.6489 11.3501 14.7999 14 16L14.8212 14.6314C15.0629 14.2285 15.1837 14.0271 15.3549 13.9058C15.5059 13.7988 15.6836 13.7357 15.8683 13.7237C16.0777 13.7101 16.2985 13.7904 16.74 13.9509L19.9468 15.117C20.3262 15.255 20.516 15.324 20.6559 15.4456C20.7795 15.553 20.8749 15.6891 20.9335 15.842C21 16.015 21 16.2169 21 16.6207V19.438C21 19.9181 21 20.1582 20.9007 20.364C20.8185 20.5345 20.663 20.7019 20.499 20.7963C20.3009 20.9103 20.0834 20.9262 19.6483 20.9581C19.2691 20.9859 18.8862 21 18.5 21Z"
242
+ stroke="#000000"
243
+ stroke-width="2"
244
+ stroke-linecap="round"
245
+ stroke-linejoin="round"
246
+ ></path>
247
+ </g>
248
+ </svg>`,
249
+ },
250
+ ],
251
+ },
252
+ { title: "Country", key: "location.country", filterable: true },
253
+ { title: "Years Employed", key: "years", sortable: true },
254
+ ];
255
+ return tablecolumns;
256
+ };
@@ -15,7 +15,7 @@ import {
15
15
  import { ifDefined } from "lit/directives/if-defined.js";
16
16
  import { useArgs } from "@storybook/client-api";
17
17
  import { FilterEvent, rowGetValue } from "../components/table/cell";
18
- import { tablecolumns, tabledata } from "./fixtures/data";
18
+ import { getTableColumns, tabledata } from "./fixtures/data";
19
19
  // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
20
20
  const data = JSON.parse(
21
21
  JSON.stringify([
@@ -45,7 +45,7 @@ const data = JSON.parse(
45
45
  ...tabledata,
46
46
  ])
47
47
  );
48
- const columns = tablecolumns;
48
+
49
49
  const getData =
50
50
  SpectricTableElement.getDefaultDataSorterAndPaginatior<(typeof tabledata)[0]>(
51
51
  data
@@ -101,7 +101,7 @@ const meta = {
101
101
  size: "xsmall",
102
102
  totalItems: data.length,
103
103
  },
104
- columns: JSON.parse(JSON.stringify(columns)),
104
+ columns: getTableColumns(),
105
105
  select: TableSelectOptions.none,
106
106
  },
107
107
  } satisfies Meta<Props<(typeof tabledata)[0]>>;
@@ -118,7 +118,7 @@ export const Basic: Story = {
118
118
  size: "xsmall",
119
119
  totalItems: data.length,
120
120
  },
121
- columns: JSON.parse(JSON.stringify(columns)),
121
+ columns: getTableColumns(),
122
122
  },
123
123
  };
124
124
 
@@ -126,21 +126,21 @@ export const Basic: Story = {
126
126
  export const NoPagination: Story = {
127
127
  args: {
128
128
  pagination: undefined,
129
- columns: JSON.parse(JSON.stringify(columns)),
129
+ columns: getTableColumns(),
130
130
  },
131
131
  };
132
132
 
133
133
  export const MultiSelect: Story = {
134
134
  args: {
135
135
  select: "multi",
136
- columns: JSON.parse(JSON.stringify(columns)),
136
+ columns: getTableColumns(),
137
137
  },
138
138
  };
139
139
 
140
140
  export const SingleSelect: Story = {
141
141
  args: {
142
142
  select: "single",
143
- columns: JSON.parse(JSON.stringify(columns)),
143
+ columns: getTableColumns(),
144
144
  },
145
145
  };
146
146
 
@@ -150,7 +150,7 @@ export const SingleSelect: Story = {
150
150
  export const MultiColumnSort: Story = {
151
151
  args: {
152
152
  sort: "multi",
153
- columns: JSON.parse(JSON.stringify(columns)),
153
+ columns: getTableColumns(),
154
154
  pagination: { pageSize: 20, page: 1 },
155
155
  },
156
156
  };