@spectric/ui 0.0.20 → 0.0.22

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.
Files changed (48) hide show
  1. package/dist/components/Banner.d.ts +1 -1
  2. package/dist/components/dialog/dialog.d.ts +2 -1
  3. package/dist/components/pagination/pagination.d.ts +1 -1
  4. package/dist/components/query_bar/QueryBar.d.ts +31 -11
  5. package/dist/components/query_bar/dateTimePopup.d.ts +2 -0
  6. package/dist/components/query_bar/geojsonPopup.d.ts +2 -0
  7. package/dist/components/query_bar/querylanguage/kuery/functions/geospatial.d.ts +19 -0
  8. package/dist/components/query_bar/querylanguage/outputTypes/toCQL.d.ts +2 -1
  9. package/dist/components/query_bar/querylanguage/outputTypes/toMongo.d.ts +6 -1
  10. package/dist/components/symbols.d.ts +6 -0
  11. package/dist/components/table/cell.d.ts +2 -2
  12. package/dist/components/table/header.d.ts +2 -1
  13. package/dist/components/table/table.d.ts +14 -7
  14. package/dist/custom-elements.json +8 -8
  15. package/dist/index.d.ts +4 -0
  16. package/dist/index.es.js +4556 -2834
  17. package/dist/index.es.js.map +1 -1
  18. package/dist/index.umd.js +424 -248
  19. package/dist/index.umd.js.map +1 -1
  20. package/dist/style.css +1 -1
  21. package/package.json +6 -1
  22. package/src/components/Banner.ts +46 -31
  23. package/src/components/dialog/dialog.css.ts +29 -29
  24. package/src/components/dialog/dialog.ts +165 -135
  25. package/src/components/input.ts +49 -39
  26. package/src/components/pagination/pagination.ts +167 -113
  27. package/src/components/query_bar/QueryBar.ts +441 -185
  28. package/src/components/query_bar/dateTimePopup.ts +54 -0
  29. package/src/components/query_bar/geojsonPopup.ts +44 -0
  30. package/src/components/query_bar/querylanguage/kuery/ast/_generated_/kuery.js +1836 -2745
  31. package/src/components/query_bar/querylanguage/kuery/ast/ast.ts +15 -13
  32. package/src/components/query_bar/querylanguage/kuery/ast/kuery.peg +92 -126
  33. package/src/components/query_bar/querylanguage/kuery/functions/geospatial.ts +25 -0
  34. package/src/components/query_bar/querylanguage/kuery/functions/index.ts +9 -7
  35. package/src/components/query_bar/querylanguage/outputTypes/toCQL.ts +56 -34
  36. package/src/components/query_bar/querylanguage/outputTypes/toMongo.ts +46 -34
  37. package/src/components/symbols.ts +6 -0
  38. package/src/components/table/__tests__/table.spec.ts +143 -55
  39. package/src/components/table/cell.ts +188 -145
  40. package/src/components/table/header.ts +163 -152
  41. package/src/components/table/table.css +4 -2
  42. package/src/components/table/table.ts +415 -262
  43. package/src/components/table/virtualBody.ts +170 -115
  44. package/src/components/tooltip/popover.ts +263 -225
  45. package/src/stories/Dialog.stories.ts +59 -0
  46. package/src/stories/QueryBar.stories.ts +46 -37
  47. package/src/stories/fixtures/data.ts +195 -36
  48. package/src/stories/table.stories.ts +70 -22
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 tr{height:var(--rowHeight)}spectric-table td{height:var(--rowHeight);padding:1px;border:1px solid transparent}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}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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectric/ui",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
5
  "main": "./dist/index.es.js",
6
6
  "module": "./dist/index.es.js",
@@ -12,6 +12,7 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "build": "tsc && vite build",
15
+ "build:peg": "npx grunt peg",
15
16
  "start": "storybook dev -p 6006",
16
17
  "test-setup": "storybook dev -p 6006 --no-open --ci --loglevel verbose",
17
18
  "storybook:build": "web-component-analyzer src --outFiles .storybook/build/custom-elements.json && storybook build --output-dir public",
@@ -20,6 +21,7 @@
20
21
  "type-check": "tsc --noemit"
21
22
  },
22
23
  "dependencies": {
24
+ "@terraformer/wkt": "^2.2.1",
23
25
  "lit": "^3.2.1"
24
26
  },
25
27
  "devDependencies": {
@@ -32,6 +34,9 @@
32
34
  "@storybook/web-components": "^8.4.6",
33
35
  "@storybook/web-components-vite": "^8.4.6",
34
36
  "@types/react": "^18.3.12",
37
+ "@types/terraformer__wkt": "^2.0.3",
38
+ "grunt": "^1.6.1",
39
+ "peggy": "^5.0.6",
35
40
  "storybook": "^8.4.6",
36
41
  "typescript": "~5.6.2",
37
42
  "vite": "^5.4.10",
@@ -1,35 +1,35 @@
1
- import { html, LitElement } from 'lit';
2
- import { StyleInfo, styleMap } from 'lit/directives/style-map.js';
3
- import "./Button"
4
- import { customElement, property } from 'lit/decorators.js';
5
- import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from './types';
1
+ import { html, LitElement } from "lit";
2
+ import { StyleInfo, styleMap } from "lit/directives/style-map.js";
3
+ import "./Button";
4
+ import { customElement, property } from "lit/decorators.js";
5
+ import {
6
+ HTMLElementTagWithEvents,
7
+ ReactElementWithPropsAndEvents,
8
+ } from "./types";
6
9
 
7
10
  export interface BannerProps {
8
11
  /**What is returned in the event details when a banner is dismissed */
9
- bannerId?: any,
12
+ bannerId?: any;
10
13
  /** Banner Text to display */
11
14
  text?: string;
12
15
  /** What background color to use */
13
16
  headerStyle?: StyleInfo;
14
17
  /** Can be dismissed */
15
18
  dismissable?: boolean;
16
-
17
19
  }
18
20
 
19
-
20
-
21
21
  const DEFAULT_STYLE: StyleInfo = {
22
22
  display: "flex",
23
23
  alignItems: "center",
24
24
  backgroundColor: "black",
25
25
  color: "white",
26
- textAlign: "center"
27
- }
26
+ textAlign: "center",
27
+ };
28
28
 
29
29
  /**
30
30
  * @slot text - Banner Text content
31
31
  */
32
- @customElement('spectric-banner')
32
+ @customElement("spectric-banner")
33
33
  export class SpectricBanner extends LitElement implements BannerProps {
34
34
  @property({ type: Boolean, reflect: true })
35
35
  dismissable: boolean = false;
@@ -45,40 +45,47 @@ export class SpectricBanner extends LitElement implements BannerProps {
45
45
  private _dismissed: boolean = false;
46
46
 
47
47
  private onDismiss = (e: PointerEvent) => {
48
- e.preventDefault()
49
- e.stopPropagation()
48
+ e.preventDefault();
49
+ e.stopPropagation();
50
50
  const options = {
51
51
  bubbles: true,
52
52
  composed: true,
53
53
  };
54
54
  this._dismissed = true;
55
- let { bannerId, text, headerStyle, dismissable }: BannerProps = this
56
- this.dispatchEvent(new CustomEvent<BannerProps>('bannerDismissed', {
57
- detail: { bannerId, text, headerStyle, dismissable },
58
- ...options
59
- }));
60
- }
55
+ let { bannerId, text, headerStyle, dismissable }: BannerProps = this;
56
+ this.dispatchEvent(
57
+ new CustomEvent<BannerProps>("bannerDismissed", {
58
+ detail: { bannerId, text, headerStyle, dismissable },
59
+ ...options,
60
+ })
61
+ );
62
+ };
61
63
  protected render(): unknown {
62
64
  if (this._dismissed) {
63
- return
65
+ return;
64
66
  }
65
67
  return html`
66
- <header style=${styleMap({ ...DEFAULT_STYLE, ...this.headerStyle })}>
67
- <div style="flex-grow:1"><slot name="text">${this.text}</slot><slot></slot></div>
68
- ${this.dismissable ? html`<spectric-button size="small" @click=${this.onDismiss}>X</spectric-button>` : null}
69
- </header>
68
+ <header style=${styleMap({ ...DEFAULT_STYLE, ...this.headerStyle })}>
69
+ <div style="flex-grow:1">
70
+ <slot name="text">${this.text}</slot><slot></slot>
71
+ </div>
72
+ ${this.dismissable
73
+ ? html`<spectric-button size="small" @click=${this.onDismiss} icon
74
+ >X</spectric-button
75
+ >`
76
+ : null}
77
+ </header>
70
78
  `;
71
79
  }
72
80
  }
73
81
 
74
82
  export interface BannerEventMap {
75
- 'bannerDismissed': (event: CustomEvent<BannerProps>) => void
83
+ bannerDismissed: (event: CustomEvent<BannerProps>) => void;
76
84
  }
77
85
 
78
86
  declare global {
79
-
80
87
  interface HTMLElementTagNameMap {
81
- "spectric-banner": HTMLElementTagWithEvents<SpectricBanner, BannerEventMap>
88
+ "spectric-banner": HTMLElementTagWithEvents<SpectricBanner, BannerEventMap>;
82
89
  }
83
90
 
84
91
  namespace JSX {
@@ -86,7 +93,11 @@ declare global {
86
93
  /**
87
94
  * {@link SpectricBanner}
88
95
  */
89
- "spectric-banner": ReactElementWithPropsAndEvents<SpectricBanner, BannerProps, BannerEventMap>;
96
+ "spectric-banner": ReactElementWithPropsAndEvents<
97
+ SpectricBanner,
98
+ BannerProps,
99
+ BannerEventMap
100
+ >;
90
101
  }
91
102
  }
92
103
  namespace React {
@@ -95,8 +106,12 @@ declare global {
95
106
  /**
96
107
  * {@link SpectricBanner}
97
108
  */
98
- "spectric-banner": ReactElementWithPropsAndEvents<SpectricBanner, BannerProps, BannerEventMap>;
109
+ "spectric-banner": ReactElementWithPropsAndEvents<
110
+ SpectricBanner,
111
+ BannerProps,
112
+ BannerEventMap
113
+ >;
99
114
  }
100
115
  }
101
116
  }
102
- }
117
+ }
@@ -1,50 +1,50 @@
1
1
  import { css } from "lit";
2
2
 
3
3
  export const style = css`
4
- :host {
4
+ :host {
5
5
  --dialog-padding: var(--spectric-dialog-padding, 5px);
6
- --dialog-background:var(--spectric-background,rgb(246, 249, 252));
7
- }
8
- dialog {
9
- border: 0px solid var(--background-inverse);
6
+ --dialog-background: var(--spectric-background, rgb(246, 249, 252));
7
+ --dialog-border-radius: var(--spectric-border-radius, 0.4em);
8
+ }
9
+ dialog {
10
+ border: 0px;
10
11
  --spectric-background: var(--dialog-background);
11
- --panel-color:var(--dialog-background);
12
+ --panel-color: var(--dialog-background);
12
13
  padding: 0;
13
- border-radius: var(--spectric-border-radius);
14
- overflow:hidden;
15
-
16
- }
17
- dialog[open]{
18
- display:flex;
19
- }
20
- spectric-panel{
21
- margin:0px
22
- }
23
- dialog::backdrop {
14
+ border-radius: var(--dialog-border-radius);
15
+ overflow: hidden;
16
+ }
17
+ dialog[open] {
18
+ display: flex;
19
+ }
20
+ spectric-panel {
21
+ margin: 0px;
22
+ }
23
+ dialog::backdrop {
24
24
  background-color: transparent;
25
- }
26
- dialog.backdrop::backdrop {
25
+ }
26
+ dialog.backdrop::backdrop {
27
27
  background-color: rgba(0, 0, 0, 0.5);
28
- }
29
- .modal{
28
+ }
29
+ .modal {
30
30
  display: flex;
31
31
  overflow: hidden;
32
32
  flex-direction: column;
33
33
  height: 100%;
34
- }
35
- .content{
34
+ }
35
+ .content {
36
36
  flex-shrink: 1;
37
37
  overflow: auto;
38
- }
38
+ }
39
39
 
40
- h3 {
40
+ h3 {
41
41
  padding: 1em var(--dialog-padding);
42
42
  margin: 0;
43
- }
43
+ }
44
44
 
45
- spectric-button{
45
+ spectric-button {
46
46
  position: absolute;
47
47
  right: 0;
48
48
  top: 0;
49
- }
50
- `;
49
+ }
50
+ `;
@@ -1,163 +1,193 @@
1
- import { CSSResultGroup, html, LitElement, PropertyValues, render } from 'lit';
1
+ import { CSSResultGroup, html, LitElement, PropertyValues, render } from "lit";
2
2
  import "../Button";
3
- import { customElement, property, queryAsync } from 'lit/decorators.js';
4
- import { style } from './dialog.css';
5
- import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
6
- export const DialogElementTag = "spectric-dialog"
7
- export type { DialogProps as Props, DialogEvents }
3
+ import { customElement, property, queryAsync } from "lit/decorators.js";
4
+ import { style } from "./dialog.css";
5
+ import {
6
+ HTMLElementTagWithEvents,
7
+ ReactElementWithPropsAndEvents,
8
+ } from "../types";
9
+ import "../Panel";
10
+ export const DialogElementTag = "spectric-dialog";
11
+ export type { DialogProps as Props, DialogEvents };
8
12
  interface DialogProps {
9
- open?: boolean;
10
- dismissable?: boolean;
11
- hideBackdrop?: boolean;
12
- title?: string;
13
- closeOnEscape?: boolean;
14
- closeOnOutsideClick?: boolean;
13
+ open?: boolean;
14
+ dismissable?: boolean;
15
+ hideBackdrop?: boolean;
16
+ title?: string;
17
+ closeOnEscape?: boolean;
18
+ closeOnOutsideClick?: boolean;
15
19
  }
16
20
 
17
-
18
-
19
21
  /**
20
22
  * Dialog Element
21
23
  * @slot title - sets the title of the dialog attribute/property can also be use for setting the title to a string
24
+ * @slot footer - Space at the bottom of the dialog that you can put buttons or other tools
22
25
  */
23
26
  @customElement(DialogElementTag)
24
27
  export class DialogElement extends LitElement implements DialogProps {
25
- static styles: CSSResultGroup = style;
26
- static display(props: DialogProps, body: any) {
27
- let dialog = document.createElement(DialogElementTag);
28
- dialog.addEventListener("close", () => {
29
- dialog.remove()
30
- });
31
- for (let prop in props) {
32
- //@ts-ignore
33
- dialog[prop] = props[prop];
28
+ static styles: CSSResultGroup = style;
29
+ static display(props: DialogProps, body: any) {
30
+ let dialog = document.createElement(DialogElementTag);
31
+ dialog.addEventListener("close", () => {
32
+ dialog.remove();
33
+ });
34
+ for (let prop in props) {
35
+ //@ts-ignore
36
+ dialog[prop] = props[prop];
37
+ }
38
+ let frag = document.createDocumentFragment();
39
+ render(body, frag);
40
+ dialog.appendChild(frag);
41
+ dialog.open = true;
42
+ document.body.appendChild(dialog);
43
+ return dialog;
44
+ }
45
+ @property({ type: Boolean, reflect: true })
46
+ open: boolean = false;
47
+
48
+ @property({ type: Boolean, reflect: true })
49
+ dismissable: boolean = true;
50
+
51
+ @property({ type: Boolean, reflect: true })
52
+ hideBackdrop: boolean = false;
53
+
54
+ @property({ type: String, reflect: true })
55
+ title: string = "";
56
+
57
+ @property({ type: Boolean, reflect: true })
58
+ closeOnEscape: boolean = true;
59
+
60
+ @property({ type: Boolean, reflect: true })
61
+ closeOnOutsideClick: boolean = true;
62
+
63
+ @queryAsync("dialog")
64
+ dialogElement!: Promise<HTMLDialogElement>;
65
+
66
+ connectedCallback(): void {
67
+ super.connectedCallback();
68
+ this.dialogElement.then((dialog) =>
69
+ dialog.addEventListener("keydown", this._handleKeyDown)
70
+ );
71
+ }
72
+
73
+ disconnectedCallback(): void {
74
+ super.disconnectedCallback();
75
+ this.dialogElement.then((dialog) =>
76
+ dialog.removeEventListener("keydown", this._handleKeyDown)
77
+ );
78
+ }
79
+
80
+ protected updated(_changedProperties: PropertyValues): void {
81
+ if (_changedProperties.has("open")) {
82
+ this.dialogElement.then((dialog) => {
83
+ if (this.open) {
84
+ dialog.showModal();
85
+ } else {
86
+ dialog.close();
34
87
  }
35
- let frag = document.createDocumentFragment()
36
- render(body, frag);
37
- dialog.appendChild(frag)
38
- dialog.open = true;
39
- document.body.appendChild(dialog)
40
- return dialog
88
+ });
41
89
  }
42
- @property({ type: Boolean, reflect: true })
43
- open: boolean = false;
44
-
45
- @property({ type: Boolean, reflect: true })
46
- dismissable: boolean = true;
47
-
48
- @property({ type: Boolean, reflect: true })
49
- hideBackdrop: boolean = false;
50
-
51
- @property({ type: String, reflect: true })
52
- title: string = "";
90
+ }
53
91
 
54
- @property({ type: Boolean, reflect: true })
55
- closeOnEscape: boolean = true;
56
-
57
- @property({ type: Boolean, reflect: true })
58
- closeOnOutsideClick: boolean = true;
59
-
60
- @queryAsync("dialog")
61
- dialogElement!: Promise<HTMLDialogElement>;
62
-
63
- connectedCallback(): void {
64
- super.connectedCallback();
65
- this.dialogElement.then(dialog => dialog.addEventListener('keydown', this._handleKeyDown));
92
+ private clickHandler = async (e: PointerEvent): Promise<void> => {
93
+ const dialog = await this.dialogElement;
94
+ if (!this.dismissable || !this.closeOnOutsideClick) {
95
+ return;
66
96
  }
67
-
68
- disconnectedCallback(): void {
69
- super.disconnectedCallback();
70
- this.dialogElement.then(dialog => dialog.removeEventListener('keydown', this._handleKeyDown));
97
+ if (dialog === e.target) {
98
+ // clicked on backdrop
99
+ this.open = false;
71
100
  }
101
+ };
72
102
 
73
- protected updated(_changedProperties: PropertyValues): void {
74
- if (_changedProperties.has("open")) {
75
- this.dialogElement.then(dialog => {
76
- if (this.open) {
77
- dialog.showModal();
78
- } else {
79
- dialog.close();
80
- }
81
- });
82
- }
103
+ private _handleKeyDown = (e: KeyboardEvent): void => {
104
+ if (!this.closeOnEscape) {
105
+ e.preventDefault();
83
106
  }
84
-
85
- private clickHandler = async (e: PointerEvent): Promise<void> => {
86
- const dialog = await this.dialogElement;
87
- if (!this.dismissable || !this.closeOnOutsideClick) {
88
- return;
89
- }
90
- if (dialog === e.target) {
91
- // clicked on backdrop
92
- this.open = false;
93
- }
94
- };
95
-
96
- private _handleKeyDown = (e: KeyboardEvent): void => {
97
- if (!this.closeOnEscape) {
98
- e.preventDefault()
99
- }
100
- if (this.open && this.closeOnEscape && e.key === 'Escape') {
101
- this.open = false;
102
- }
103
- };
104
-
105
- private _onClose = (e: PointerEvent): void => {
106
- e.preventDefault();
107
- e.stopPropagation();
108
- this.open = false;
109
- this.dispatchEvent(new CustomEvent('close', {
110
- bubbles: true,
111
- composed: true,
112
- }));
113
- };
114
-
115
- protected render(): unknown {
116
- return html`
117
- <dialog class=${this.hideBackdrop ? '' : 'backdrop'} @close=${this._onClose} @click=${this.clickHandler}>
118
- <spectric-panel>
119
- <div class="modal">
120
- ${this.dismissable ? html`<spectric-button variant="text" size="small" @click=${() => { this.open = false }}>X</spectric-button>` : null}
121
- <h3 >
122
- <slot name="title">
123
- ${this.title.length ? this.title : null}
124
- </slot>
125
- </h3>
126
-
127
- <div class="content"><slot></slot></div>
128
- <div class="footer"><slot name="footer"></slot></div>
129
- </div>
130
- </spectric-panel>
131
- </dialog>
132
- `;
107
+ if (this.open && this.closeOnEscape && e.key === "Escape") {
108
+ this.open = false;
133
109
  }
110
+ };
111
+
112
+ private _onClose = (e: PointerEvent): void => {
113
+ e.preventDefault();
114
+ e.stopPropagation();
115
+ this.open = false;
116
+ this.dispatchEvent(
117
+ new CustomEvent("close", {
118
+ bubbles: true,
119
+ composed: true,
120
+ })
121
+ );
122
+ };
123
+
124
+ protected render(): unknown {
125
+ return html`
126
+ <dialog
127
+ class=${this.hideBackdrop ? "" : "backdrop"}
128
+ @close=${this._onClose}
129
+ @click=${this.clickHandler}
130
+ >
131
+ <spectric-panel>
132
+ <div class="modal">
133
+ ${this.dismissable
134
+ ? html`<spectric-button
135
+ variant="text"
136
+ size="xsmall"
137
+ @click=${() => {
138
+ this.open = false;
139
+ }}
140
+ icon
141
+ >X</spectric-button
142
+ >`
143
+ : null}
144
+ <h3>
145
+ <slot name="title">
146
+ ${this.title.length ? this.title : null}
147
+ </slot>
148
+ </h3>
149
+
150
+ <div class="content"><slot></slot></div>
151
+ <div class="footer"><slot name="footer"></slot></div>
152
+ </div>
153
+ </spectric-panel>
154
+ </dialog>
155
+ `;
156
+ }
134
157
  }
135
158
 
136
159
  interface DialogEvents {
137
- 'close': (event: CustomEvent) => void;
160
+ close: (event: CustomEvent) => void;
138
161
  }
139
162
 
140
163
  declare global {
141
- interface HTMLElementTagNameMap {
142
- [DialogElementTag]: HTMLElementTagWithEvents<DialogElement, DialogEvents>
143
-
164
+ interface HTMLElementTagNameMap {
165
+ [DialogElementTag]: HTMLElementTagWithEvents<DialogElement, DialogEvents>;
166
+ }
167
+ namespace JSX {
168
+ interface IntrinsicElements {
169
+ /**
170
+ * @see {@link DialogElement}
171
+ */
172
+ [DialogElementTag]: ReactElementWithPropsAndEvents<
173
+ DialogElement,
174
+ DialogProps,
175
+ DialogEvents
176
+ >;
144
177
  }
178
+ }
179
+ namespace React {
145
180
  namespace JSX {
146
- interface IntrinsicElements {
147
- /**
148
- * @see {@link DialogElement}
149
- */
150
- [DialogElementTag]: ReactElementWithPropsAndEvents<DialogElement, DialogProps, DialogEvents>;
151
- }
152
- }
153
- namespace React {
154
- namespace JSX {
155
- interface IntrinsicElements {
156
- /**
157
- * @see {@link DialogElement}
158
- */
159
- [DialogElementTag]: ReactElementWithPropsAndEvents<DialogElement, DialogProps, DialogEvents>
160
- }
161
- }
181
+ interface IntrinsicElements {
182
+ /**
183
+ * @see {@link DialogElement}
184
+ */
185
+ [DialogElementTag]: ReactElementWithPropsAndEvents<
186
+ DialogElement,
187
+ DialogProps,
188
+ DialogEvents
189
+ >;
190
+ }
162
191
  }
192
+ }
163
193
  }