@spectric/ui 0.0.23 → 0.0.25

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;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}
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-query span.field-name{color:#50b8f1}spectric-query span.expression-value{color:#c5937b}spectric-query span.field-numeric{color:#bacdab}spectric-query span.wild-card{color:#a94230}spectric-query span.value-constant{color:#3a7cc5}spectric-query .syntax-highlighter{color:#bc89bd;position:absolute;z-index:100;font-size:.875rem;letter-spacing:.16px;padding:0 1rem;font-family:inherit;inline-size:calc(100% - .5rem);block-size:2.5rem;content:no-close-quote;vertical-align:baseline;display:flex;align-items:center;pointer-events:none;white-space:nowrap;box-sizing:border-box}spectric-query .syntax-highlighter>*{overflow:hidden}spectric-query:focus-within .syntax-highlighter{display:none}spectric-query spectric-input .inputWrapper input{color:transparent}spectric-query:focus-within spectric-input .inputWrapper input{color:initial}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);line-height:calc(var(--lineClamp) * var(--fontSize));height:var(--rowHeight)}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.23",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "main": "./dist/index.es.js",
6
6
  "module": "./dist/index.es.js",
@@ -250,7 +250,7 @@ export class SpectricInput extends LitElement implements InputProps {
250
250
  changedProperties.has("checked") &&
251
251
  changedProperties.get("checked") !== undefined
252
252
  ) {
253
- this.dispatchEvent(new Event("change", { bubbles: true }));
253
+ //this.dispatchEvent(new Event("change", { bubbles: true }));
254
254
  }
255
255
  }
256
256
  @eventOptions({ capture: true })
@@ -404,6 +404,7 @@ export class SpectricInput extends LitElement implements InputProps {
404
404
  @click=${() => {
405
405
  this.checked = !this.checked;
406
406
  this.value = Boolean(this.checked);
407
+ this.dispatchEvent(new Event("change", { bubbles: true }));
407
408
  }} icon size=${this.size || "xxsmall"} variant=${
408
409
  this.checked ? "primary" : "secondary"
409
410
  }>${this.checked ? "✓" : "\u00A0"}</spectric-button>
@@ -49,4 +49,51 @@ spectric-query .autocomplete .option {
49
49
  .query-bar-date-quick-select {
50
50
  display: flex;
51
51
  justify-content: space-evenly;
52
+ }
53
+ spectric-query span.field-name {
54
+ color: #50b8f1;
55
+ }
56
+
57
+ spectric-query span.expression-value {
58
+ color: #c5937b;
59
+ }
60
+
61
+ spectric-query span.field-numeric {
62
+ color: #bacdab;
63
+ }
64
+ spectric-query span.wild-card {
65
+ color: #a94230;
66
+ }
67
+ spectric-query span.value-constant {
68
+ color: #3a7cc5;
69
+ }
70
+ spectric-query .syntax-highlighter{
71
+ color: #bc89bd;
72
+ position: absolute;
73
+ z-index: 100;
74
+ font-size: .875rem;
75
+ letter-spacing: .16px;
76
+ padding: 0 1rem;
77
+ font-family: inherit;
78
+ inline-size: calc(100% - .5rem);
79
+ block-size: 2.5rem;
80
+ content: no-close-quote;
81
+ vertical-align: baseline;
82
+ display: flex;
83
+ align-items: center;
84
+ pointer-events: none;
85
+ white-space: nowrap;
86
+ box-sizing: border-box;
87
+ }
88
+ spectric-query .syntax-highlighter >*{
89
+ overflow: hidden;
90
+ }
91
+ spectric-query:focus-within .syntax-highlighter{
92
+ display: none;
93
+ }
94
+ spectric-query spectric-input .inputWrapper input{
95
+ color: transparent;
96
+ }
97
+ spectric-query:focus-within spectric-input .inputWrapper input{
98
+ color: initial;
52
99
  }
@@ -19,6 +19,7 @@ import { PopoverElement } from "../tooltip/popover";
19
19
  import { DateTimePopup } from "./dateTimePopup";
20
20
  import { GeoJSONPopup } from "./geojsonPopup";
21
21
  import { DELETE, EDIT } from "../symbols";
22
+ import { unsafeHTML } from "lit/directives/unsafe-html.js";
22
23
  export type FieldTypes = {
23
24
  name: string;
24
25
  type: "string" | "number" | "boolean" | "integer" | "object";
@@ -87,7 +88,7 @@ type Completion = LabelValue & {
87
88
  start: number;
88
89
  end: number;
89
90
  type: SuggestionType;
90
- onSelect?: () => Promise<string | undefined | number | LabelValue>;
91
+ onSelect?: () => Promise<string | undefined | number>;
91
92
  };
92
93
  export const toLabelValue = (value: LabelValueOrString) => {
93
94
  if (typeof value === "string") {
@@ -103,7 +104,7 @@ const NumberOperators: Record<string, LabelValue> = {
103
104
  gte: { value: " >= ", label: " is greater than or equal to some value" },
104
105
  lte: { value: " <= ", label: " is less than or equal to some value" },
105
106
  };
106
- const GeospatialOperators: Record<string, LabelValue> = {
107
+ export const GeospatialOperators: Record<string, LabelValue> = {
107
108
  within: { value: " <@ ", label: " is contained within geometry" },
108
109
  };
109
110
  const ObjectOperators: Record<string, LabelValue> = {
@@ -137,6 +138,8 @@ export class SpectricQuery extends LitElement implements IQueryProps {
137
138
  placeholder: string = "";
138
139
  @state()
139
140
  valueHelper: any;
141
+ @state()
142
+ highlightedSyntax: any;
140
143
  constructor() {
141
144
  super();
142
145
  this.uuid = crypto.randomUUID();
@@ -322,6 +325,11 @@ export class SpectricQuery extends LitElement implements IQueryProps {
322
325
  output = kuery[this.outputLanguage](ast, this.fields);
323
326
  }
324
327
  let event = new CustomEvent("change", { detail: output });
328
+ if (this.value.trim().length) {
329
+ this.highlightedSyntax = unsafeHTML(kuery.toHTML(ast, this.fields));
330
+ }else{
331
+ this.highlightedSyntax = ""
332
+ }
325
333
  this.dispatchEvent(event);
326
334
  };
327
335
 
@@ -522,18 +530,22 @@ export class SpectricQuery extends LitElement implements IQueryProps {
522
530
  if (completion.onSelect) {
523
531
  let value = await completion.onSelect();
524
532
  if (value !== undefined) {
533
+ value = String(value);
525
534
  this.value += value;
526
- setTimeout(() => {
527
- this._input.focus();
528
- this._showValueHelper(this._getSuggestion());
529
- });
535
+ this._input.setSelectionRange(
536
+ insertIndex + value.length,
537
+ insertIndex + value.length
538
+ );
530
539
  }
531
540
  }
532
541
  this._autocomplete?.hidePopover();
533
542
  this.completionIndex = 0;
534
543
  this.completions = [];
535
- this._parseQuery();
536
- this._input.focus();
544
+ setTimeout(() => {
545
+ this._parseQuery();
546
+ this._input.focus();
547
+ this._showValueHelper(this._getSuggestion());
548
+ });
537
549
  };
538
550
  _handleArrows = (e: KeyboardEvent) => {
539
551
  if (e.key === "Escape") {
@@ -577,6 +589,7 @@ export class SpectricQuery extends LitElement implements IQueryProps {
577
589
  };
578
590
  protected render() {
579
591
  return html`
592
+ <div class="syntax-highlighter">${this.highlightedSyntax}</div>
580
593
  <spectric-input
581
594
  .value=${this.value}
582
595
  .placeholder=${this.placeholder}
@@ -266,7 +266,8 @@ function peg$parse(input, options) {
266
266
  rule:"SubQuery"
267
267
  };
268
268
  }
269
- return query;
269
+ group++
270
+ return {...query,group};
270
271
  }
271
272
  function peg$f5(field, query, trailing) {
272
273
  if (query.type === 'cursor') {
@@ -384,7 +385,8 @@ function peg$parse(input, options) {
384
385
  rule:"OrListOfValues"
385
386
  };
386
387
  }
387
- return (field) => buildFunctionNode('or', [partialLeft(field), partialRight(field)]);
388
+ group++
389
+ return (field) => ({...buildFunctionNode('or', [partialLeft(field), partialRight(field)]),group});
388
390
  }
389
391
  function peg$f13(partialLeft, partialRight) {
390
392
  const cursor = [partialLeft, partialRight].find(node => node.type === 'cursor');
@@ -395,7 +397,8 @@ function peg$parse(input, options) {
395
397
  rule:"AndListOfValues"
396
398
  };
397
399
  }
398
- return (field) => buildFunctionNode('and', [partialLeft(field), partialRight(field)]);
400
+ group++
401
+ return (field) => ({...buildFunctionNode('and', [partialLeft(field), partialRight(field)]),group});
399
402
  }
400
403
  function peg$f14(partial) {
401
404
  if (partial.type === 'cursor') {
@@ -2234,6 +2237,7 @@ function peg$parse(input, options) {
2234
2237
  const buildWildcardNode = nodeTypes.wildcard.buildNode;
2235
2238
  const buildNamedArgNode = nodeTypes.namedArg.buildNode;
2236
2239
  const { wildcardSymbol } = nodeTypes.wildcard;
2240
+ var group = 0
2237
2241
 
2238
2242
  peg$result = peg$startRuleFunction();
2239
2243
 
@@ -11,6 +11,7 @@
11
11
  const buildWildcardNode = nodeTypes.wildcard.buildNode;
12
12
  const buildNamedArgNode = nodeTypes.namedArg.buildNode;
13
13
  const { wildcardSymbol } = nodeTypes.wildcard;
14
+ var group = 0
14
15
  }
15
16
 
16
17
  start
@@ -58,7 +59,8 @@ SubQuery
58
59
  rule:"SubQuery"
59
60
  };
60
61
  }
61
- return query;
62
+ group++
63
+ return {...query,group};
62
64
  }
63
65
  / NestedQuery
64
66
 
@@ -203,7 +205,8 @@ OrListOfValues
203
205
  rule:"OrListOfValues"
204
206
  };
205
207
  }
206
- return (field) => buildFunctionNode('or', [partialLeft(field), partialRight(field)]);
208
+ group++
209
+ return (field) => ({...buildFunctionNode('or', [partialLeft(field), partialRight(field)]),group});
207
210
  }
208
211
  / AndListOfValues
209
212
 
@@ -217,7 +220,8 @@ AndListOfValues
217
220
  rule:"AndListOfValues"
218
221
  };
219
222
  }
220
- return (field) => buildFunctionNode('and', [partialLeft(field), partialRight(field)]);
223
+ group++
224
+ return (field) => ({...buildFunctionNode('and', [partialLeft(field), partialRight(field)]),group});
221
225
  }
222
226
  / NotListOfValues
223
227
 
@@ -28,11 +28,14 @@
28
28
  * under the License.
29
29
  */
30
30
 
31
- export { DQLSyntaxError } from './kuery_syntax_error';
32
- export { nodeTypes } from './node_types';
33
- export * from './ast';
34
- export { fromKueryExpression as parse, toOpenSearchQuery as toDSL } from './ast';
35
- export { toCql } from "../outputTypes/toCQL"
36
- export { toMongo } from "../outputTypes/toMongo"
37
-
38
- export * from './types';
31
+ export { DQLSyntaxError } from "./kuery_syntax_error";
32
+ export { nodeTypes } from "./node_types";
33
+ export * from "./ast";
34
+ export {
35
+ fromKueryExpression as parse,
36
+ toOpenSearchQuery as toDSL,
37
+ } from "./ast";
38
+ export { toCql } from "../outputTypes/toCQL";
39
+ export { toMongo } from "../outputTypes/toMongo";
40
+ export { toHTML } from "../outputTypes/toHTML";
41
+ export * from "./types";
@@ -0,0 +1,201 @@
1
+ import { FieldTypes, GeospatialOperators, KueryNode } from "../..";
2
+ import { LiteralTypeBuildNode } from "../kuery";
3
+ import { wildcardSymbol } from "../kuery/node_types/wildcard";
4
+
5
+ export const KQL_WILDCARD_SYMBOL = wildcardSymbol;
6
+ export const KQL_NODE_TYPE_WILDCARD = "wildcard";
7
+ export type FunctionName =
8
+ | "is"
9
+ | "and"
10
+ | "or"
11
+ | "not"
12
+ | "range"
13
+ | "exists"
14
+ | "nested";
15
+ const and = (node: KueryNode, fields?: FieldTypes[]) => {
16
+ const children = node.arguments || [];
17
+ let html =
18
+ "<span class='and-expression'>" +
19
+ children
20
+ .map((child: KueryNode) => {
21
+ return toHTML(child, fields);
22
+ })
23
+ .join(" AND ") +
24
+ "</span>";
25
+ if (node.group !== undefined) {
26
+ try {
27
+ let { fieldName, values } = groupVariables(children);
28
+ return `<span class="or-expression">${fieldName}:(${values.join(
29
+ " OR "
30
+ )})</span>`;
31
+ } catch (error) {
32
+ console.log(error);
33
+ }
34
+ return `( ${html} )`;
35
+ }
36
+ return html;
37
+ };
38
+
39
+ const or = (node: KueryNode, fields?: FieldTypes[]) => {
40
+ const children = node.arguments || [];
41
+ let args = children
42
+ .map((child: KueryNode) => {
43
+ return toHTML(child, fields);
44
+ })
45
+ .join(" OR ");
46
+ let html = `<span class="or-expression">${args}</span>`;
47
+ if (node.group !== undefined) {
48
+ try {
49
+ let { fieldName, values } = groupVariables(children);
50
+ return `<span class="or-expression">${fieldName}:(${values.join(
51
+ " OR "
52
+ )})</span>`;
53
+ } catch (error) {
54
+ console.log(error);
55
+ }
56
+ return `( ${html} )`;
57
+ }
58
+
59
+ return html;
60
+ };
61
+
62
+ const extractLiteralValue = (
63
+ fieldName: string,
64
+ valueArg: LiteralTypeBuildNode,
65
+ isPhrase: LiteralTypeBuildNode,
66
+ fields?: FieldTypes[]
67
+ ) => {
68
+ let value = toHTML(valueArg);
69
+ if (isPhrase.value) {
70
+ value = `"${value}"`;
71
+ }
72
+ if (fields && fields.find((f) => f.name === fieldName)?.type === "boolean") {
73
+ value = `<span class="value-constant">${valueArg.value}</span>`;
74
+ }
75
+ return `<span class="expression-value">${value}</span>`;
76
+ };
77
+ const extractFieldName = (fieldNameArg: any) => {
78
+ let fieldName = toHTML(fieldNameArg);
79
+ return `<span class="field-name">${fieldName}</span>`;
80
+ };
81
+ const is = (node: KueryNode, fields?: FieldTypes[]) => {
82
+ var {
83
+ arguments: [fieldNameArg, valueArg, isPhrase],
84
+ } = node;
85
+ let operator = ":";
86
+ let fieldName = extractFieldName(fieldNameArg);
87
+ let value = extractLiteralValue(fieldName, valueArg, isPhrase, fields);
88
+ return `<span class="is-expression">${fieldName}${operator}${value}</span>`;
89
+ };
90
+
91
+ const not = (node: KueryNode, fields?: FieldTypes[]) => {
92
+ const [argument] = node.arguments;
93
+ return `<span class="not-expression">not ${toHTML(argument, fields)}</span>`;
94
+ };
95
+
96
+ const groupVariables = (
97
+ nodes: KueryNode[],
98
+ fieldName: string | undefined = undefined,
99
+ fields?: FieldTypes[]
100
+ ) => {
101
+ let values: string[] = [];
102
+ if (!fieldName && nodes[0].function == "is") {
103
+ fieldName = extractFieldName(nodes[0].arguments[0]);
104
+ }
105
+ if (!fieldName) {
106
+ throw Error(
107
+ "Cannot group variables because they don't have a groupable field"
108
+ );
109
+ }
110
+ for (let node of nodes) {
111
+ var {
112
+ arguments: [fieldNameArg, valueArg, isPhrase],
113
+ } = node;
114
+ if (node.function == "is") {
115
+ if (extractFieldName(fieldNameArg) !== fieldName) {
116
+ throw Error(
117
+ "Cannot group variables because they aren't for the same field"
118
+ );
119
+ }
120
+ let value = extractLiteralValue(fieldName, valueArg, isPhrase, fields);
121
+ values.push(value);
122
+ } else if (node.function === "or" || node.function === "and") {
123
+ let grouped = groupVariables(node.arguments, fieldName, fields);
124
+ values.push(...grouped.values);
125
+ } else {
126
+ throw Error(
127
+ "Cannot group variables because they aren't for the same field"
128
+ );
129
+ }
130
+ }
131
+ return { fieldName, values };
132
+ };
133
+
134
+ const AST_TO_CQL = {
135
+ gt: ">",
136
+ lt: "<",
137
+ gte: ">=",
138
+ lte: "<=",
139
+ };
140
+ const range = (node: KueryNode) => {
141
+ const [fieldNameArg, operator] = node.arguments;
142
+ let valueArg = operator.value;
143
+ // @ts-ignore
144
+ const opsign = AST_TO_CQL[operator.name];
145
+ let value = toHTML(valueArg);
146
+ if (valueArg.type === "literal") {
147
+ value = `${value}`;
148
+ }
149
+ //double check that its a number else quote it
150
+ if (Number.isNaN(parseFloat(value))) {
151
+ value = `<span class="expression-value">"${value}"</span>`;
152
+ }
153
+ return `<span class="range-expression"><span class="field-name">${fieldNameArg.value}</span> ${opsign} <span class="field-numeric">${value}</span></span>`;
154
+ };
155
+
156
+ const exists = (node: KueryNode) => {
157
+ const [fieldNameArg] = node.arguments;
158
+ return `<span class="exists-expression"><span class="field-name">${fieldNameArg.value}</span>: *</span>`;
159
+ };
160
+ const nested = (node: KueryNode) => {
161
+ //nested types don't exist in CQL
162
+ console.warn("Nested types dont exist in CQL", node);
163
+ return "";
164
+ };
165
+ const geospatial = (node: KueryNode) => {
166
+ const [fieldName, operator, value] = node.arguments;
167
+ console.log(fieldName, operator, value);
168
+ let opsine = GeospatialOperators[operator].value;
169
+ return `<span><span class="field-name">${fieldName.value}</span> ${opsine}<span title="${value.value}">--GEOMETRY--</span></span>`;
170
+ };
171
+ export const functions = {
172
+ is,
173
+ and,
174
+ or,
175
+ not,
176
+ range,
177
+ exists,
178
+ nested,
179
+ geospatial,
180
+ };
181
+ const nodeTypes = {
182
+ function: (node: KueryNode, fields?: FieldTypes[]) => {
183
+ // @ts-ignore
184
+ return functions[node.function as FunctionName](node, fields);
185
+ },
186
+ literal: (node: KueryNode) => {
187
+ return node.value;
188
+ },
189
+ wildcard: (node: KueryNode) => {
190
+ const { value } = node;
191
+ return `<span class="wild-card">${value
192
+ .split(KQL_WILDCARD_SYMBOL)
193
+ .join("*")}</span>`;
194
+ },
195
+ };
196
+
197
+ export const toHTML = (node: KueryNode, fields?: FieldTypes[]): string => {
198
+ //@ts-ignore
199
+ const nodeType = nodeTypes[node.type] as unknown as any;
200
+ return nodeType(node, fields);
201
+ };
@@ -94,5 +94,6 @@ spectric-table .cell-contents{
94
94
  overflow: hidden;
95
95
  text-overflow: ellipsis;
96
96
  font-size: var(--fontSize);
97
- height: calc(var(--lineClamp) * var(--fontSize));
97
+ line-height: calc(var(--lineClamp) * var(--fontSize));
98
+ height: var(--rowHeight);
98
99
  }
@@ -258,6 +258,7 @@ export class SpectricTableElement<T = any>
258
258
  );
259
259
  if (index !== -1) {
260
260
  this.columns[index] = { ...this.selectColumnConfig };
261
+ this.columns = [...this.columns];
261
262
  }
262
263
  }
263
264
  setSelected(selected: T[]) {
@@ -268,13 +269,11 @@ export class SpectricTableElement<T = any>
268
269
  return this.selected;
269
270
  }
270
271
  deselectAll() {
271
- this.selected = [];
272
- this.forceRefreshofSelectionColumn();
272
+ this.setSelected([]);
273
273
  this.dispatchEvent(new CustomEvent("selected", { detail: this.selected }));
274
274
  }
275
275
  selectAll() {
276
- this.selected = [...this.data];
277
- this.forceRefreshofSelectionColumn();
276
+ this.setSelected([...this.data]);
278
277
  this.dispatchEvent(new CustomEvent("selected", { detail: this.selected }));
279
278
  }
280
279
  async scrollToRow(row: T | number) {
@@ -337,11 +336,14 @@ export class SpectricTableElement<T = any>
337
336
  allowResize: false,
338
337
  filterable: false,
339
338
  width: 39,
340
- title: (table) => {
341
- return table.select === "multi"
339
+ title: (table: SpectricTableElement<T>) => {
340
+ return table.select === TableSelectOptions.multi
342
341
  ? html`<spectric-input
343
342
  variant="checkbox"
344
343
  @change=${table._handleSelectAllChange}
344
+ ${spreadProps({
345
+ checked: table.selected.length === table.data.length,
346
+ })}
345
347
  .helperText=${"Select All"}
346
348
  ></spectric-input>`
347
349
  : null;
@@ -366,10 +368,10 @@ export class SpectricTableElement<T = any>
366
368
  if (e.target.checked) {
367
369
  if (table.select === "single") {
368
370
  table.selected = [];
369
- table.forceRefreshofSelectionColumn();
370
371
  }
371
372
  table.selected.push(row);
372
373
  }
374
+ table.setSelected([...table.selected]);
373
375
  table.dispatchEvent(
374
376
  new CustomEvent("selected", { detail: [...table.selected] })
375
377
  );
@@ -395,10 +397,29 @@ export class SpectricTableElement<T = any>
395
397
  }
396
398
  }
397
399
  if (changedProperties.has("select")) {
398
- if (this.select === "single" && this.selected.length > 1) {
399
- this.selected = [this.selected[0]];
400
+ let selectIndex = this.columns.findIndex(
401
+ (col) => col[TABLE_CREATED_SELECTION_COLUMN]
402
+ );
403
+ if (this.select !== TableSelectOptions.none) {
404
+ this.forceRefreshofSelectionColumn();
405
+ if (!this.columns.find((col) => col[TABLE_CREATED_SELECTION_COLUMN])) {
406
+ this.columns.unshift(this.selectColumnConfig);
407
+ this.columns = [...this.columns];
408
+ }
409
+ } else {
410
+ if (selectIndex !== -1) {
411
+ this.columns.splice(selectIndex, 1);
412
+ this.columns = [...this.columns];
413
+ this.setSelected([]);
414
+ }
415
+ }
416
+ if (
417
+ this.select === TableSelectOptions.single &&
418
+ this.selected.length > 1
419
+ ) {
420
+ this.setSelected([this.selected[0]]);
400
421
  this.dispatchEvent(
401
- new CustomEvent("selected", { detail: [...this.selected] })
422
+ new CustomEvent("selected", { detail: [this.selected[0]] })
402
423
  );
403
424
  }
404
425
  }