@spectric/ui 0.0.22 → 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/components/query_bar/QueryBar.d.ts +2 -0
- package/dist/components/query_bar/querylanguage/kuery/index.d.ts +2 -1
- package/dist/components/query_bar/querylanguage/outputTypes/toHTML.d.ts +15 -0
- package/dist/components/table/table.d.ts +9 -0
- package/dist/custom-elements.json +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +2084 -1988
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +151 -138
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/input.css +5 -0
- package/src/components/input.ts +1 -2
- package/src/components/query_bar/QueryBar.css +43 -0
- package/src/components/query_bar/QueryBar.ts +21 -8
- package/src/components/query_bar/querylanguage/kuery/index.ts +11 -8
- package/src/components/query_bar/querylanguage/outputTypes/toHTML.ts +126 -0
- package/src/components/table/cell.ts +21 -8
- package/src/components/table/table.css +9 -3
- package/src/components/table/table.ts +14 -0
- package/src/stories/fixtures/ExampleContent.ts +144 -87
- package/src/stories/fixtures/data.ts +40 -7
- package/src/stories/table.stories.ts +8 -8
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-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
package/src/components/input.css
CHANGED
|
@@ -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;
|
package/src/components/input.ts
CHANGED
|
@@ -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
|
`;
|
|
@@ -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
|
|
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
|
-
|
|
527
|
-
|
|
528
|
-
|
|
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
|
-
|
|
536
|
-
|
|
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
|
|
32
|
-
export { nodeTypes } from
|
|
33
|
-
export * from
|
|
34
|
-
export {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export
|
|
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
|
+
};
|
|
@@ -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("
|
|
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
|
|
131
|
+
? html`
|
|
132
132
|
<spectric-button
|
|
133
133
|
@click=${this._handleFilterOut}
|
|
134
|
-
size
|
|
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
|
|
142
|
+
.size=${buttonSize}
|
|
143
143
|
variant="text"
|
|
144
144
|
icon
|
|
145
145
|
tooltip="Filter For Value"
|
|
146
146
|
>+</spectric-button
|
|
147
147
|
>
|
|
148
|
-
|
|
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
|
-
${
|
|
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(.
|
|
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
|
}
|
|
@@ -89,5 +94,6 @@ spectric-table .cell-contents{
|
|
|
89
94
|
overflow: hidden;
|
|
90
95
|
text-overflow: ellipsis;
|
|
91
96
|
font-size: var(--fontSize);
|
|
92
|
-
height: calc(var(--lineClamp) * var(--fontSize));
|
|
97
|
+
line-height: calc(var(--lineClamp) * var(--fontSize));
|
|
98
|
+
height: var(--rowHeight);
|
|
93
99
|
}
|
|
@@ -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"
|