@spectric/ui 0.0.23 → 0.0.24

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;box-sizing:border-box;font-size:.875rem;letter-spacing:.16px;padding:0 1rem;font-family:inherit;inline-size:100%;block-size:2.5rem;content:no-close-quote;vertical-align:baseline;display:flex;align-items:center;pointer-events:none}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.24",
4
4
  "type": "module",
5
5
  "main": "./dist/index.es.js",
6
6
  "module": "./dist/index.es.js",
@@ -49,4 +49,47 @@ 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
+ box-sizing: border-box;
75
+ font-size: .875rem;
76
+ letter-spacing: .16px;
77
+ padding: 0 1rem;
78
+ font-family: inherit;
79
+ inline-size: 100%;
80
+ block-size: 2.5rem;
81
+ content: no-close-quote;
82
+ vertical-align: baseline;
83
+ display: flex;
84
+ align-items: center;
85
+ pointer-events: none;
86
+ }
87
+ spectric-query:focus-within .syntax-highlighter{
88
+ display: none;
89
+ }
90
+ spectric-query spectric-input .inputWrapper input{
91
+ color: transparent;
92
+ }
93
+ spectric-query:focus-within spectric-input .inputWrapper input{
94
+ color: initial;
52
95
  }
@@ -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}
@@ -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,126 @@
1
+ import { FieldTypes, GeospatialOperators, KueryNode } from "../..";
2
+ import { wildcardSymbol } from "../kuery/node_types/wildcard";
3
+
4
+ export const KQL_WILDCARD_SYMBOL = wildcardSymbol;
5
+ export const KQL_NODE_TYPE_WILDCARD = "wildcard";
6
+ export type FunctionName =
7
+ | "is"
8
+ | "and"
9
+ | "or"
10
+ | "not"
11
+ | "range"
12
+ | "exists"
13
+ | "nested";
14
+ const and = (node: KueryNode, fields?: FieldTypes[]) => {
15
+ const children = node.arguments || [];
16
+ return (
17
+ "<span class='and-expression'>" +
18
+ children
19
+ .map((child: KueryNode) => {
20
+ return toHTML(child, fields);
21
+ })
22
+ .join(" AND ") +
23
+ "</span>"
24
+ );
25
+ };
26
+ const is = (node: KueryNode, fields?: FieldTypes[]) => {
27
+ var {
28
+ arguments: [fieldNameArg, valueArg, isPhrase],
29
+ } = node;
30
+ let operator = ":";
31
+ let value = toHTML(valueArg);
32
+ if (isPhrase.value) {
33
+ value = `"${value}"`;
34
+ }
35
+ let fieldName = toHTML(fieldNameArg);
36
+ if (fields && fields.find((f) => f.name === fieldName)?.type === "boolean") {
37
+ value = `<span class="value-constant">${valueArg.value}</span>`;
38
+ }
39
+
40
+ return `<span class="is-expression"><span class="field-name">${fieldName}</span>${operator}<span class="expression-value">${value}</span></span>`;
41
+ };
42
+
43
+ const or = (node: KueryNode, fields?: FieldTypes[]) => {
44
+ const children = node.arguments || [];
45
+ let args = children
46
+ .map((child: KueryNode) => {
47
+ return toHTML(child, fields);
48
+ })
49
+ .join(" OR ");
50
+ return `<span class="or-expression">${args}</span>`;
51
+ };
52
+ const not = (node: KueryNode, fields?: FieldTypes[]) => {
53
+ const [argument] = node.arguments;
54
+ return `<span class="not-expression">not ${toHTML(argument, fields)}</span>`;
55
+ };
56
+
57
+ const AST_TO_CQL = {
58
+ gt: ">",
59
+ lt: "<",
60
+ gte: ">=",
61
+ lte: "<=",
62
+ };
63
+ const range = (node: KueryNode) => {
64
+ const [fieldNameArg, operator] = node.arguments;
65
+ let valueArg = operator.value;
66
+ // @ts-ignore
67
+ const opsign = AST_TO_CQL[operator.name];
68
+ let value = toHTML(valueArg);
69
+ if (valueArg.type === "literal") {
70
+ value = `${value}`;
71
+ }
72
+ //double check that its a number else quote it
73
+ if (Number.isNaN(parseFloat(value))) {
74
+ value = `<span class="expression-value">"${value}"</span>`;
75
+ }
76
+ return `<span class="range-expression"><span class="field-name">${fieldNameArg.value}</span> ${opsign} <span class="field-numeric">${value}</span></span>`;
77
+ };
78
+
79
+ const exists = (node: KueryNode) => {
80
+ const [fieldNameArg] = node.arguments;
81
+ return `<span class="exists-expression"><span class="field-name">${fieldNameArg.value}</span>: *</span>`;
82
+ };
83
+ const nested = (node: KueryNode) => {
84
+ //nested types don't exist in CQL
85
+ console.warn("Nested types dont exist in CQL", node);
86
+ return "";
87
+ };
88
+ const geospatial = (node: KueryNode) => {
89
+ const [fieldName, operator, value] = node.arguments;
90
+ console.log(fieldName, operator, value);
91
+ let opsine = GeospatialOperators[operator].value;
92
+ return `<span><span class="field-name">${fieldName.value}</span> ${opsine}<span title="${value.value}">--GEOMETRY--</span></span>`;
93
+ if (operator === "within") return `WITHIN(${fieldName.value},${value.value})`;
94
+ throw Error(`Unsupported GEO Operator:${operator}`);
95
+ };
96
+ export const functions = {
97
+ is,
98
+ and,
99
+ or,
100
+ not,
101
+ range,
102
+ exists,
103
+ nested,
104
+ geospatial,
105
+ };
106
+ const nodeTypes = {
107
+ function: (node: KueryNode, fields?: FieldTypes[]) => {
108
+ // @ts-ignore
109
+ return functions[node.function as FunctionName](node, fields);
110
+ },
111
+ literal: (node: KueryNode) => {
112
+ return node.value;
113
+ },
114
+ wildcard: (node: KueryNode) => {
115
+ const { value } = node;
116
+ return `<span class="wild-card">${value
117
+ .split(KQL_WILDCARD_SYMBOL)
118
+ .join("*")}</span>`;
119
+ },
120
+ };
121
+
122
+ export const toHTML = (node: KueryNode, fields?: FieldTypes[]): string => {
123
+ //@ts-ignore
124
+ const nodeType = nodeTypes[node.type] as unknown as any;
125
+ return nodeType(node, fields);
126
+ };
@@ -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
  }
@@ -1,108 +1,130 @@
1
-
2
- import { filterByColumn, tablecolumns, tabledata, TestData } from "./data";
1
+ import { filterByColumn, getTableColumns, tabledata, TestData } from "./data";
3
2
  import { ExampleBits } from "./Bits";
4
3
  import { FieldTypes, SpectricQuery } from "../../components/query_bar/QueryBar";
5
4
 
6
- import { html, LitElement } from 'lit';
5
+ import { html, LitElement } from "lit";
7
6
 
8
- import { customElement, property, query, state } from 'lit/decorators.js';
9
- import "./lorumipsum"
7
+ import { customElement, property, query, state } from "lit/decorators.js";
8
+ import "./lorumipsum";
10
9
  import { PaginationProps } from "../../components/pagination";
11
10
  import { FilterEvent } from "../../components/table/cell";
12
11
  import { TableDataOptions, SpectricTableElement } from "../../components/table";
12
+ const tablecolumns = getTableColumns();
13
13
  type Props = {
14
- frameWidth: number
15
- }
16
- @customElement('spectric-storybook-example-content')
17
- export class SpectricStorybookExampleContent extends LitElement implements Props {
14
+ frameWidth: number;
15
+ };
16
+ @customElement("spectric-storybook-example-content")
17
+ export class SpectricStorybookExampleContent
18
+ extends LitElement
19
+ implements Props
20
+ {
18
21
  protected createRenderRoot(): HTMLElement | DocumentFragment {
19
- return this
22
+ return this;
20
23
  }
21
24
  @property({ type: Number, reflect: true })
22
25
  frameWidth: number = 10;
23
26
 
24
27
  @query("spectric-query")
25
- query!: SpectricQuery
28
+ query!: SpectricQuery;
26
29
 
27
- private dataSorter = SpectricTableElement.getDefaultDataSorterAndPaginatior<TestData>(tabledata)
30
+ private dataSorter =
31
+ SpectricTableElement.getDefaultDataSorterAndPaginatior<TestData>(tabledata);
28
32
  @state()
29
33
  dialogOpen: boolean = false;
30
34
  get tableData() {
31
- return this.dataSorter(this)
35
+ return this.dataSorter(this);
32
36
  }
33
37
 
34
- columns = tablecolumns
38
+ columns = tablecolumns;
35
39
  pagination: PaginationProps = {
36
40
  page: 1,
37
41
  pageSize: 3,
38
42
  size: "xsmall",
39
43
  totalItems: tabledata.length,
40
- }
44
+ };
41
45
  _handleFilter = (e: CustomEvent<FilterEvent<any>>) => {
42
- let include = e.detail.include ? "" : "not "
46
+ let include = e.detail.include ? "" : "not ";
43
47
  if (e.detail.column.key && e.detail.value) {
44
48
  if (this.query.value.trim() !== "") {
45
- this.query.value = `${this.query.value} and ${include}${e.detail.column.key}: '${e.detail.value}'`
49
+ this.query.value = `${this.query.value} and ${include}${e.detail.column.key}: '${e.detail.value}'`;
46
50
  } else {
47
- this.query.value = `${include}${e.detail.column.key}: '${e.detail.value}'`
51
+ this.query.value = `${include}${e.detail.column.key}: '${e.detail.value}'`;
48
52
  }
49
53
  }
50
- }
54
+ };
51
55
  _handlePaginationChange = (e: CustomEvent<TableDataOptions<TestData>>) => {
52
- let { pagination, columns } = e.detail
53
- this.pagination = { ...this.pagination, ...pagination }
54
- this.columns = columns
55
- this.requestUpdate()
56
- }
56
+ let { pagination, columns } = e.detail;
57
+ this.pagination = { ...this.pagination, ...pagination };
58
+ this.columns = columns;
59
+ this.requestUpdate();
60
+ };
57
61
  render() {
58
62
  return html`
59
- <spectric-dialog
60
- ?open=${this.dialogOpen} title="Are you sure you want to delete?" ?dismissable=${true} @close=${() => {
61
- this.dialogOpen = false;
62
- }}>
63
- <lorum-ipsum></lorum-ipsum>
64
- <lorum-ipsum></lorum-ipsum>
65
- <lorum-ipsum></lorum-ipsum>
66
- <lorum-ipsum></lorum-ipsum>
67
- <lorum-ipsum></lorum-ipsum>
68
- <lorum-ipsum></lorum-ipsum>
69
- <lorum-ipsum></lorum-ipsum>
63
+ <spectric-dialog
64
+ ?open=${this.dialogOpen}
65
+ title="Are you sure you want to delete?"
66
+ ?dismissable=${true}
67
+ @close=${() => {
68
+ this.dialogOpen = false;
69
+ }}
70
+ >
71
+ <lorum-ipsum></lorum-ipsum>
72
+ <lorum-ipsum></lorum-ipsum>
73
+ <lorum-ipsum></lorum-ipsum>
74
+ <lorum-ipsum></lorum-ipsum>
75
+ <lorum-ipsum></lorum-ipsum>
76
+ <lorum-ipsum></lorum-ipsum>
77
+ <lorum-ipsum></lorum-ipsum>
70
78
  <div slot="footer" style="display:flex;justify-content: space-around;">
71
- <spectric-button danger @click=${() => {
72
- this.dialogOpen = false;
73
- setTimeout(() => alert("deleted"), 300)
74
- }}>Delete</spectric-button><spectric-button variant="text" @click=${() => {
75
- this.dialogOpen = false;
76
- }}>Cancel</spectric-button>
77
- </div>
79
+ <spectric-button
80
+ danger
81
+ @click=${() => {
82
+ this.dialogOpen = false;
83
+ setTimeout(() => alert("deleted"), 300);
84
+ }}
85
+ >Delete</spectric-button
86
+ ><spectric-button
87
+ variant="text"
88
+ @click=${() => {
89
+ this.dialogOpen = false;
90
+ }}
91
+ >Cancel</spectric-button
92
+ >
93
+ </div>
78
94
  </spectric-dialog>
79
- <h2>Pages in Spectric UI</h2>
80
- <p>
81
- We recommend building UIs with a
82
- <a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
83
- <strong>component-driven</strong> </a
84
- >process starting with atomic components and ending with pages.
85
- </p>
86
- <spectric-panel>
87
- Query
95
+ <h2>Pages in Spectric UI</h2>
96
+ <p>
97
+ We recommend building UIs with a
98
+ <a
99
+ href="https://componentdriven.org"
100
+ target="_blank"
101
+ rel="noopener noreferrer"
102
+ >
103
+ <strong>component-driven</strong> </a
104
+ >process starting with atomic components and ending with pages.
105
+ </p>
106
+ <spectric-panel>
107
+ Query
88
108
  <spectric-query
89
- .fields=${[{ name: "modulations", type: "string" }, { name: "signal", type: "string" }] as FieldTypes[]}
109
+ .fields=${[
110
+ { name: "modulations", type: "string" },
111
+ { name: "signal", type: "string" },
112
+ ] as FieldTypes[]}
90
113
  .getValuesForField=${filterByColumn}
91
- @change=${(e: CustomEvent<any>) => {
92
- }}
114
+ @change=${(e: CustomEvent<any>) => {}}
93
115
  outputLanguage=${"toDSL"}
94
- >
95
-
96
- </spectric-query>
97
- <spectric-table
116
+ >
117
+ </spectric-query>
118
+ <spectric-table
98
119
  style="height:200px;"
99
- .data=${this.tableData}
100
- .columns=${tablecolumns}
120
+ .data=${this.tableData}
121
+ .columns=${tablecolumns}
101
122
  @filter=${this._handleFilter}
102
123
  @change=${this._handlePaginationChange}
103
- .pagination=${this.pagination}></spectric-table>
124
+ .pagination=${this.pagination}
125
+ ></spectric-table>
104
126
  <spectric-panel style="display:flex">
105
- <spectric-bit-display
127
+ <spectric-bit-display
106
128
  frameWidth=${this.frameWidth}
107
129
  scale=${2}
108
130
  .arrayBuffer=${ExampleBits.buffer}
@@ -111,35 +133,70 @@ export class SpectricStorybookExampleContent extends LitElement implements Props
111
133
  >
112
134
  </spectric-bit-display>
113
135
  <spectric-splitview id="splitview-1">
114
- <div style="flex-grow:1">
115
- <h4>Main Settings here</h4>
116
- <spectric-input variant="number" .value=${this.frameWidth} @change=${(e) => this.frameWidth = e.target.value} placeholder="frameWidth" helpertext="Adjust the framewidth" label="Frame Width" >
117
- Input label
118
- </spectric-input>
119
- <spectric-button size="small" >Submit</spectric-button><spectric-button size="small" variant="secondary">Continue</spectric-button><spectric-button size="small" variant="text">Cancel</spectric-button>
120
- </div>
121
- <spectric-panel>
122
- <h4>OtherSettings here</h4>
123
-
124
- <spectric-input variant="number" .value=${this.frameWidth} @change=${(e) => this.frameWidth = e.target.value} placeholder="frameWidth" helpertext="Adjust the framewidth" label="Frame Width" style="flex-grow:1">
125
- Input label
126
- </spectric-input>
127
- <spectric-button size="small" >Submit</spectric-button><spectric-button size="small" variant="secondary">Continue</spectric-button><spectric-button size="small" variant="text">Cancel</spectric-button>
128
- </spectric-panel>
136
+ <div style="flex-grow:1">
137
+ <h4>Main Settings here</h4>
138
+ <spectric-input
139
+ variant="number"
140
+ .value=${this.frameWidth}
141
+ @change=${(e) => (this.frameWidth = e.target.value)}
142
+ placeholder="frameWidth"
143
+ helpertext="Adjust the framewidth"
144
+ label="Frame Width"
145
+ >
146
+ Input label
147
+ </spectric-input>
148
+ <spectric-button size="small">Submit</spectric-button
149
+ ><spectric-button size="small" variant="secondary"
150
+ >Continue</spectric-button
151
+ ><spectric-button size="small" variant="text"
152
+ >Cancel</spectric-button
153
+ >
154
+ </div>
155
+ <spectric-panel>
156
+ <h4>OtherSettings here</h4>
157
+
158
+ <spectric-input
159
+ variant="number"
160
+ .value=${this.frameWidth}
161
+ @change=${(e) => (this.frameWidth = e.target.value)}
162
+ placeholder="frameWidth"
163
+ helpertext="Adjust the framewidth"
164
+ label="Frame Width"
165
+ style="flex-grow:1"
166
+ >
167
+ Input label
168
+ </spectric-input>
169
+ <spectric-button size="small">Submit</spectric-button
170
+ ><spectric-button size="small" variant="secondary"
171
+ >Continue</spectric-button
172
+ ><spectric-button size="small" variant="text"
173
+ >Cancel</spectric-button
174
+ >
175
+ </spectric-panel>
129
176
  </spectric-splitview>
130
- <spectric-calendar></spectric-calendar>
177
+ <spectric-calendar></spectric-calendar>
131
178
  </spectric-panel>
132
179
  <div style="display:flex">
133
180
  <span style="flex-grow:1"></span>
134
181
  <spectric-input variant="color" .value=${"#00FF00"}></spectric-input>
135
- <spectric-button size="small" danger @click=${() => {
136
- this.dialogOpen = true
137
- this.requestUpdate()
138
- }}>Delete (show modal)</spectric-button>
139
- <spectric-button size="small" danger variant="secondary">Override</spectric-button>
140
- <spectric-button size="small" danger variant="text">Disable</spectric-button>
182
+ <spectric-button
183
+ size="small"
184
+ danger
185
+ @click=${() => {
186
+ this.dialogOpen = true;
187
+ this.requestUpdate();
188
+ }}
189
+ >Delete (show modal)</spectric-button
190
+ >
191
+ <spectric-button size="small" danger variant="secondary"
192
+ >Override</spectric-button
193
+ >
194
+ <spectric-button size="small" danger variant="text"
195
+ >Disable</spectric-button
196
+ >
141
197
  <spectric-button size="small" variant="text">test</spectric-button>
142
- </div></spectric-panel>
143
- `
198
+ </div></spectric-panel
199
+ >
200
+ `;
144
201
  }
145
- }
202
+ }