@spectric/ui 0.0.18 → 0.0.20

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 (42) hide show
  1. package/dist/components/Button.d.ts +2 -1
  2. package/dist/components/Panel.d.ts +6 -3
  3. package/dist/components/calendar/calendar.d.ts +58 -0
  4. package/dist/components/calendar/index.d.ts +1 -0
  5. package/dist/components/color_picker/ColorPicker.d.ts +7 -6
  6. package/dist/components/index.d.ts +1 -0
  7. package/dist/components/input.d.ts +24 -20
  8. package/dist/components/query_bar/QueryBar.d.ts +2 -1
  9. package/dist/components/table/table.d.ts +3 -0
  10. package/dist/components/tooltip/popover.d.ts +32 -2
  11. package/dist/components/tooltip/tooltip.d.ts +1 -32
  12. package/dist/custom-elements.json +59 -14
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.es.js +2842 -2564
  15. package/dist/index.es.js.map +1 -1
  16. package/dist/index.umd.js +298 -178
  17. package/dist/index.umd.js.map +1 -1
  18. package/dist/style.css +1 -1
  19. package/package.json +1 -1
  20. package/src/components/Button.ts +14 -13
  21. package/src/components/Panel.ts +25 -18
  22. package/src/components/button.css.ts +13 -0
  23. package/src/components/calendar/calendar.css +50 -0
  24. package/src/components/calendar/calendar.ts +281 -0
  25. package/src/components/calendar/index.ts +1 -0
  26. package/src/components/color_picker/ColorPicker.css +36 -3
  27. package/src/components/color_picker/ColorPicker.ts +46 -15
  28. package/src/components/index.ts +2 -1
  29. package/src/components/input.css +1 -1
  30. package/src/components/input.ts +203 -142
  31. package/src/components/panel.css.ts +7 -5
  32. package/src/components/query_bar/QueryBar.css +6 -2
  33. package/src/components/query_bar/QueryBar.ts +25 -13
  34. package/src/components/table/table.ts +43 -35
  35. package/src/components/table/virtualBody.ts +5 -4
  36. package/src/components/tooltip/popover.ts +70 -30
  37. package/src/components/tooltip/tooltip.css +7 -2
  38. package/src/components/tooltip/tooltip.ts +3 -37
  39. package/src/stories/Calendar.stories.ts +70 -0
  40. package/src/stories/fixtures/ExampleContent.ts +1 -1
  41. package/src/stories/table.stories.ts +10 -5
  42. package/src/stories/tooltip.stories.ts +9 -2
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[variant=password] spectric-button{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:-18px 0 0;position:fixed;top:anchor(bottom);justify-self:anchor-center;text-align:center}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{position:fixed;z-index:9999;--spectric-tooltip-background-color: var(--spectric-tooltip-background, var(--spectric-background,#000000));--spectric-tooltip-text-color: var(--spectric-tooltip-text, var(--spectric-text-primary, white));--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]::-webkit-slider-runnable-track{background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red)}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}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% }
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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectric/ui",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "type": "module",
5
5
  "main": "./dist/index.es.js",
6
6
  "module": "./dist/index.es.js",
@@ -1,4 +1,4 @@
1
- import { CSSResultGroup, html } from 'lit';
1
+ import { CSSResultGroup, html, PropertyValues, render } from 'lit';
2
2
  import { styleMap } from 'lit/directives/style-map.js';
3
3
 
4
4
  import style from './button.css';
@@ -70,30 +70,31 @@ export class SpectricButton extends DisposableElement implements ButtonProps {
70
70
  constructor() {
71
71
  super()
72
72
  this.addDisposableListener(this, "click", this._onClick, { capture: true })
73
+ this._onClick = this._onClick.bind(this)
73
74
  }
74
75
 
75
- private _onClick = (e: MouseEvent) => {
76
+ //@eventOptions({ capture: true })
77
+ private _onClick(e: MouseEvent) {
76
78
  if (e instanceof CustomEvent) {
77
79
  return
78
80
  }
79
- e.preventDefault()
80
- e.stopImmediatePropagation()
81
- e.stopPropagation()
82
81
  if (this.disabled) {
82
+ e.preventDefault()
83
+ e.stopImmediatePropagation()
84
+ e.stopPropagation()
83
85
  return
84
86
  }
85
- const options: CustomEventInit = {
86
- bubbles: true,
87
- composed: true,
88
- detail: e
89
- };
90
- this.dispatchEvent(new CustomEvent<MouseEvent>('click', options));
91
- }
92
87
 
88
+ }
89
+ protected updated(_changedProperties: PropertyValues): void {
90
+ if (this.tooltip && this.tooltip !== "") {
91
+ render(html`<spectric-tooltip slot="tooltip" .text=${this.tooltip} .position=${this.tooltipPosition || "right"}></spectric-tooltip>`, this)
92
+ }
93
+ }
93
94
  protected render(): unknown {
94
95
  const mode = MODES[this.variant] || 'spectric-button--primary';
95
96
  return html`
96
- ${this.tooltip && this.tooltip !== "" ? html`<spectric-tooltip .text=${this.tooltip} .position=${this.tooltipPosition || "right"} .triggerTarget=${this}></spectric-tooltip>` : null}
97
+ <slot name="tooltip"></slot>
97
98
  <button
98
99
  type="button"
99
100
  ?disabled=${this.disabled}
@@ -1,7 +1,8 @@
1
- import { CSSResultGroup, html, LitElement } from 'lit';
1
+ import { CSSResultGroup, html, PropertyValues } from 'lit';
2
2
  import styles from './panel.css.ts';
3
3
  import { customElement } from 'lit/decorators/custom-element.js';
4
4
  import { property } from 'lit/decorators/property.js';
5
+ import { DisposableElement } from '../classes/DisposibleElement.ts';
5
6
 
6
7
 
7
8
 
@@ -10,7 +11,7 @@ import { property } from 'lit/decorators/property.js';
10
11
  * Spectric Panel visually seperates content areas and automatically adjusts the component colors that are nested inside.
11
12
  * */
12
13
  @customElement("spectric-panel")
13
- export class SpectricPanel extends LitElement {
14
+ export class SpectricPanel extends DisposableElement {
14
15
  static styles?: CSSResultGroup | undefined = styles;
15
16
 
16
17
  /**
@@ -21,23 +22,17 @@ export class SpectricPanel extends LitElement {
21
22
 
22
23
  @property({ attribute: false })
23
24
  layers?: NodeListOf<SpectricPanel>;
24
-
25
- updated() {
26
- if (!this.layers) {
27
- this.layers = this.querySelectorAll(
28
- "spectric-panel"
29
- );
30
- }
31
-
32
- this.layers.forEach((item: SpectricPanel) => {
33
- (item).setAttribute(
34
- 'level',
35
- ((this.level + 1) % 4).toString()
36
- );
37
- });
38
-
25
+ constructor() {
26
+ super()
27
+ //@ts-ignore FIXME, make DisposableElement generic and add event map to DisposableElement so it knows about the events and the eveent handlers
28
+ this.addDisposableListener(this, "layer-add", () => {
29
+ this.layers = this.querySelectorAll("spectric-panel")
30
+ }, { capture: true })
31
+ }
32
+ connectedCallback(): void {
33
+ super.connectedCallback()
39
34
  this.dispatchEvent(
40
- new CustomEvent("use-layer", {
35
+ new CustomEvent("layer-add", {
41
36
  bubbles: true,
42
37
  cancelable: true,
43
38
  composed: true,
@@ -48,6 +43,18 @@ export class SpectricPanel extends LitElement {
48
43
  })
49
44
  );
50
45
  }
46
+ update(changed: PropertyValues) {
47
+ this.layers = this.querySelectorAll(
48
+ "spectric-panel"
49
+ );
50
+ this.layers.forEach((item: SpectricPanel) => {
51
+ (item).setAttribute(
52
+ 'level',
53
+ ((this.level + 1) % 4).toString()
54
+ );
55
+ });
56
+ super.update(changed)
57
+ }
51
58
 
52
59
  render() {
53
60
  return html` <slot></slot> `;
@@ -114,27 +114,40 @@ export default css`
114
114
  :host([icon][size="tiny"]) .spectric-button{
115
115
  width: 10px;
116
116
  height: 10px;
117
+ font-size:8px;
118
+ line-height:8px
117
119
  }
118
120
  :host([icon][size="xxsmall"]) .spectric-button{
119
121
  width: 16px;
120
122
  height: 16px;
123
+ font-size: 10px;
124
+ line-height: 10px;
121
125
  }
122
126
  :host([icon][size="xsmall"]) .spectric-button{
123
127
  width: 28px;
124
128
  height: 28px;
129
+ font-size: 16px;
130
+ line-height: 16px;
125
131
  }
126
132
  :host([icon][size="small"]) .spectric-button{
127
133
  width: 34px;
128
134
  height: 34px;
135
+ font-size: 20px;
136
+ line-height: 20px;
137
+
129
138
  }
130
139
  :host([icon][size="medium"]) .spectric-button{
131
140
  width: 40px;
132
141
  height: 40px;
142
+ font-size: 28px;
143
+ line-height: 28px;
133
144
  }
134
145
 
135
146
  :host([icon][size="large"]) .spectric-button{
136
147
  width: 48px;
137
148
  height: 48px;
149
+ line-height: 32px;
150
+ font-size: 32px;
138
151
  }
139
152
 
140
153
  .spectric-button:disabled{
@@ -0,0 +1,50 @@
1
+
2
+ spectric-calendar{
3
+ display: flex;
4
+ justify-content: center;
5
+ --default-text-on-color:var(--spectric-text-on-color, #ffffff);
6
+ }
7
+ spectric-calendar .header {
8
+ display: flex;
9
+ justify-content: space-between;
10
+ align-items: center;
11
+ margin-bottom: 10px;
12
+ }
13
+
14
+ spectric-calendar .month-year {
15
+ display: flex;
16
+ align-items: center;
17
+ gap: 10px;
18
+ }
19
+
20
+ spectric-calendar select {
21
+ font-size: 14px;
22
+ padding: 2px;
23
+ }
24
+
25
+ spectric-calendar .days {
26
+ display: grid;
27
+ grid-template-columns: repeat(7, 34px);
28
+ grid-template-rows: repeat(7, 34px);
29
+ text-align: center;
30
+ background:radial-gradient(
31
+ circle at var(--x, 200%) var(--y, 200%),
32
+ var(--spectric-background-inverse,#ffffff) 0%,
33
+ var(--spectric-background,#f4f4f4) 25%
34
+ );
35
+ transition: background 0.1s ease;
36
+ --spectric-text-on-color: var(--spectric-primary,#1ea7fd);
37
+ }
38
+
39
+ spectric-calendar .day {
40
+ font-weight: bold;
41
+ padding: 5px;
42
+ background-color: var(--spectric-background);
43
+ }
44
+ spectric-calendar .date.active{
45
+ --spectric-text-on-color: var(--default-text-on-color, #ffffff);
46
+ }
47
+ spectric-calendar .date {
48
+ margin: 2px;
49
+ }
50
+
@@ -0,0 +1,281 @@
1
+ import { html, PropertyValues } from "lit";
2
+ import { customElement, queryAsync, property, state } from "lit/decorators.js";
3
+ import "./calendar.css";
4
+ import { DisposableElement } from "../../classes";
5
+ import { debounceAnimation } from "../../utils";
6
+ import {
7
+ HTMLElementTagWithEvents,
8
+ ReactElementWithPropsAndEvents,
9
+ } from "../types";
10
+ import { SpectricButton } from "../Button";
11
+ import { PopoverElement } from "../tooltip/popover";
12
+ import { DomEvent } from "../table";
13
+ export interface SpectricCalendarProps {
14
+ /**
15
+ * Sets the starting day for the calendar (default:Today)
16
+ */
17
+ currentDate?: Date | string | number;
18
+ /**
19
+ * Will display a button with a popup
20
+ */
21
+ popup?: boolean;
22
+ disabled?: boolean;
23
+ }
24
+
25
+ @customElement("spectric-calendar")
26
+ export class SpectricCalendar extends DisposableElement {
27
+ @queryAsync(".days")
28
+ calendarElement!: Promise<HTMLDivElement>;
29
+
30
+ constructor() {
31
+ super();
32
+ this.addDisposableListener(
33
+ this.calendarElement,
34
+ "mousemove",
35
+ this.handleMouseMove
36
+ );
37
+ this.addDisposableListener(
38
+ this.calendarElement,
39
+ "mouseleave",
40
+ this.resetMouseMove
41
+ );
42
+ }
43
+ @property({ attribute: false })
44
+ currentDate?: Date | string | number = new Date();
45
+ @state()
46
+ private date: Date = new Date()
47
+ @property({ type: Boolean, reflect: true })
48
+ popup: boolean = false;
49
+ @property({ type: Boolean, reflect: true })
50
+ disabled: boolean = false;
51
+ protected createRenderRoot(): HTMLElement | DocumentFragment {
52
+ return this;
53
+ }
54
+ private getMonthDays(year: number, month: number): (number | "")[] {
55
+ const date = new Date(year, month, 1);
56
+ const days: (number | "")[] = [];
57
+ const firstDay = date.getUTCDay();
58
+ const lastDate = new Date(year, month + 1, 0).getUTCDate();
59
+
60
+ for (let i = 0; i < firstDay; i++) {
61
+ days.push("");
62
+ }
63
+
64
+ for (let i = 1; i <= lastDate; i++) {
65
+ days.push(i);
66
+ }
67
+
68
+ return days;
69
+ }
70
+
71
+ private changeMonth(offset: number): void {
72
+ const newDate = new Date(this.date);
73
+ newDate.setUTCMonth(newDate.getUTCMonth() + offset);
74
+ this.currentDate = newDate;
75
+ }
76
+
77
+ private changeYear(event: Event): void {
78
+ const selectedYear = parseInt(
79
+ (event.target as HTMLSelectElement).value,
80
+ 10
81
+ );
82
+ const newDate = new Date(this.date);
83
+ newDate.setUTCFullYear(selectedYear);
84
+ this.currentDate = newDate;
85
+ }
86
+
87
+ private handleMouseMove = debounceAnimation(async (e: MouseEvent) => {
88
+ const target = await this.calendarElement;
89
+ const rect = target.getBoundingClientRect();
90
+ const x = ((e.clientX - rect.left) / rect.width) * 100;
91
+ const y = ((e.clientY - rect.top) / rect.height) * 100;
92
+ target.style.setProperty("--x", `${x}%`);
93
+ target.style.setProperty("--y", `${y}%`);
94
+ });
95
+
96
+ private resetMouseMove = async () => {
97
+ const target = await this.calendarElement;
98
+ target.style.setProperty("--x", `200%`);
99
+ target.style.setProperty("--y", `200%`);
100
+ };
101
+ private selectDay(day: number) {
102
+ let year = this.date.getUTCFullYear();
103
+ let monthIndex = this.date.getUTCMonth();
104
+ let hours = this.date.getUTCHours()
105
+ let minutes = this.date.getUTCMinutes()
106
+ let seconds = this.date.getUTCSeconds()
107
+ let ms = this.date.getUTCMilliseconds()
108
+ let date = new Date();
109
+ date.setUTCFullYear(year, monthIndex, day);
110
+ date.setUTCHours(hours, minutes, seconds, ms);
111
+ console.log(date.toISOString(), year, monthIndex, day)
112
+ this.date = date
113
+ let popover = this.querySelector<PopoverElement>("spectric-popover");
114
+ if (popover) {
115
+ popover.hidePopover();
116
+ }
117
+ this.dispatchEvent(new CustomEvent("select", { detail: date }));
118
+ }
119
+ protected update(changedProperties: PropertyValues): void {
120
+ if (changedProperties.has("currentDate")) {
121
+ if (this.currentDate === undefined) {
122
+ this.date = new Date()
123
+ } else {
124
+ this.date = new Date(this.currentDate)
125
+ }
126
+ }
127
+ super.update(changedProperties)
128
+ }
129
+ render() {
130
+ const year = this.date.getUTCFullYear();
131
+ const month = this.date.getUTCMonth();
132
+ const day = this.date.getUTCDate()
133
+ this.date.toUTCString()
134
+ const monthName = (new Date(year, month, day)).toLocaleString("default", {
135
+ month: "long",
136
+ });
137
+ const days = this.getMonthDays(year, month);
138
+ const yearOptions = Array.from({ length: 21 }, (_, i) => year - 10 + i);
139
+ const calendar = html`<spectric-panel class="calendar">
140
+ <div class="header">
141
+ <spectric-button
142
+ ?disabled=${this.disabled}
143
+ size="xsmall"
144
+ icon
145
+ variant="primary"
146
+ @click=${() => this.changeMonth(-1)}
147
+ >🠈</spectric-button
148
+ >
149
+ <div class="month-year">
150
+ <span>${monthName}</span>
151
+ <select ?disabled=${this.disabled} @change=${this.changeYear}>
152
+ ${yearOptions.map(
153
+ (y) =>
154
+ html`<option value=${y} ?selected=${y === year}>${y}</option>`
155
+ )}
156
+ </select>
157
+ </div>
158
+ <spectric-button ?disabled=${this.disabled} size="xsmall" icon @click=${() => this.changeMonth(1)}
159
+ >🠊</spectric-button
160
+ >
161
+ </div>
162
+ <div class="days">
163
+ ${["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"].map(
164
+ (day) => html`<div class="day">${day}</div>`
165
+ )}
166
+ ${days.map((date) =>
167
+ date == ""
168
+ ? html`<span></span>`
169
+ : html`<spectric-button
170
+ ?disabled=${this.disabled}
171
+ @click=${() => this.selectDay(date)}
172
+ .backgroundColor=${date === day ? undefined : "var(--spectric-background,#f4f4f4)"}
173
+ icon
174
+ size="xsmall"
175
+ class="date ${date === day ? "active" : ""}"
176
+ >${date}</spectric-button
177
+ >`
178
+ )}
179
+ </div>
180
+ </spectric-panel>`;
181
+ if (!this.popup) {
182
+ return calendar;
183
+ }
184
+ return html`
185
+ <spectric-button
186
+ class="input-button-right"
187
+ icon
188
+ size="small"
189
+ variant="text"
190
+ type="button"
191
+ ?disabled=${this.disabled}
192
+ @click=${(e: DomEvent<SpectricButton>) => {
193
+ let popover = this.querySelector<PopoverElement>("spectric-popover");
194
+ if (popover && e.target) {
195
+ popover.triggerTarget = e.target;
196
+ popover.showPopover();
197
+ }
198
+ }}
199
+ ><svg
200
+ xmlns="http://www.w3.org/2000/svg"
201
+ xmlns:xlink="http://www.w3.org/1999/xlink"
202
+ viewBox="0 0 96 96"
203
+ style="
204
+ fill: var(--button-primary, #1ea7fd);
205
+ "
206
+ >
207
+ <defs>
208
+ <rect id="vcalendar-b" width="64" height="78" x="0" y="0"></rect>
209
+ <filter
210
+ id="vcalendar-a"
211
+ width="110.9%"
212
+ height="109%"
213
+ x="-5.5%"
214
+ y="-3.2%"
215
+ filterUnits="objectBoundingBox"
216
+ >
217
+ <feOffset
218
+ dy="1"
219
+ in="SourceAlpha"
220
+ result="shadowOffsetOuter1"
221
+ ></feOffset>
222
+ <feGaussianBlur
223
+ in="shadowOffsetOuter1"
224
+ result="shadowBlurOuter1"
225
+ stdDeviation="1"
226
+ ></feGaussianBlur>
227
+ <feColorMatrix
228
+ in="shadowBlurOuter1"
229
+ values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"
230
+ ></feColorMatrix>
231
+ </filter>
232
+ </defs>
233
+ <g fill-rule="evenodd">
234
+ <path
235
+ d="M36,36 L36,36.9983345 C36,38.642909 37.3431458,40 39,40 C40.6684055,40 42,38.6561086 42,36.9983345 L42,36 L54,36 L54,36.9983345 C54,38.642909 55.3431458,40 57,40 C58.6684055,40 60,38.6561086 60,36.9983345 L60,36 L64.0132046,36 C65.1104814,36 66,36.8892617 66,38.0017433 L66,65.9982567 C66,67.103789 65.1101074,68 64.0132046,68 L31.9867954,68 C30.8895186,68 30,67.1107383 30,65.9982567 L30,38.0017433 C30,36.896211 30.8898926,36 31.9867954,36 L36,36 Z M64,42 L32,42 L32,66 L64,66 L64,42 Z M50,56 L50,60 L46,60 L46,56 L50,56 Z M40,56 L40,60 L36,60 L36,56 L40,56 Z M60,56 L60,60 L56,60 L56,56 L60,56 Z M40,48 L40,52 L36,52 L36,48 L40,48 Z M50,48 L50,52 L46,52 L46,48 L50,48 Z M60,48 L60,52 L56,52 L56,48 L60,48 Z M39,32 C39.5522847,32 40,32.4509752 40,32.990778 L40,37.009222 C40,37.5173285 39.6172798,37.9361019 39.1173326,37.9933343 L39,38 C38.4477153,38 38,37.5490248 38,37.009222 L38,32.990778 C38,32.4826715 38.3827202,32.0638981 38.8826674,32.0066657 L39,32 Z M57,32 C57.5522847,32 58,32.4509752 58,32.990778 L58,37.009222 C58,37.5173285 57.6172798,37.9361019 57.1173326,37.9933343 L57,38 C56.4477153,38 56,37.5490248 56,37.009222 L56,32.990778 C56,32.4826715 56.3827202,32.0638981 56.8826674,32.0066657 L57,32 Z"
236
+ ></path>
237
+ </g></svg>
238
+ </spectric-button>
239
+ <spectric-popover position="left" .text=${calendar}></spectric-popover>
240
+ `;
241
+ }
242
+ }
243
+
244
+ interface CalendarEvents {
245
+ select: (event: CustomEvent<Date>) => void;
246
+ }
247
+
248
+ declare global {
249
+ interface HTMLElementTagNameMap {
250
+ "spectric-calendar": HTMLElementTagWithEvents<
251
+ SpectricCalendar,
252
+ CalendarEvents
253
+ >;
254
+ }
255
+ namespace JSX {
256
+ interface IntrinsicElements {
257
+ /**
258
+ * @see {@link SpectricCalendar}
259
+ */
260
+ "spectric-calendar": ReactElementWithPropsAndEvents<
261
+ SpectricCalendar,
262
+ SpectricCalendarProps,
263
+ CalendarEvents
264
+ >;
265
+ }
266
+ }
267
+ namespace React {
268
+ namespace JSX {
269
+ interface IntrinsicElements {
270
+ /**
271
+ * @see {@link SpectricCalendar}
272
+ */
273
+ "spectric-calendar": ReactElementWithPropsAndEvents<
274
+ SpectricCalendar,
275
+ SpectricCalendarProps,
276
+ CalendarEvents
277
+ >;
278
+ }
279
+ }
280
+ }
281
+ }
@@ -0,0 +1 @@
1
+ export * from "./calendar"
@@ -1,4 +1,4 @@
1
- spectric-input.hue-gradient input[type="range"]::-webkit-slider-runnable-track {
1
+ spectric-input.hue-gradient input[type=range]::-moz-range-track {
2
2
  background: linear-gradient(
3
3
  to right,
4
4
  hsl(0, 100%, 50%), /* Red */
@@ -8,7 +8,21 @@ spectric-input.hue-gradient input[type="range"]::-webkit-slider-runnable-track {
8
8
  hsl(240, 100%, 50%), /* Blue */
9
9
  hsl(300, 100%, 50%), /* Magenta */
10
10
  hsl(360, 100%, 50%) /* Red (completes the circle) */
11
- )
11
+ );
12
+ height: 15px;
13
+ }
14
+ spectric-input.hue-gradient input[type="range"]::-webkit-slider-runnable-track{
15
+ background: linear-gradient(
16
+ to right,
17
+ hsl(0, 100%, 50%), /* Red */
18
+ hsl(60, 100%, 50%), /* Yellow */
19
+ hsl(120, 100%, 50%), /* Green */
20
+ hsl(180, 100%, 50%), /* Cyan */
21
+ hsl(240, 100%, 50%), /* Blue */
22
+ hsl(300, 100%, 50%), /* Magenta */
23
+ hsl(360, 100%, 50%) /* Red (completes the circle) */
24
+ );
25
+ height: 15px;
12
26
  }
13
27
 
14
28
  spectric-input.alpha-gradient input[type="range"]::-webkit-slider-runnable-track {
@@ -22,6 +36,22 @@ spectric-input.alpha-gradient input[type="range"]::-webkit-slider-runnable-track
22
36
  #fff 50% 75%, /* White for the third quarter */
23
37
  #000 75% 100% /* Black for the fourth quarter */
24
38
  ) 50% / 10px 10px;
39
+ height: 15px;
40
+
41
+ }
42
+
43
+ spectric-input.alpha-gradient input[type=range]::-moz-range-track{
44
+ background:
45
+ /* Alpha gradient from transparent to opaque */
46
+ linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%),
47
+ /* Checkerboard */
48
+ repeating-conic-gradient(
49
+ #fff 0% 25%, /* White for the first quarter */
50
+ #000 25% 50%, /* Black for the second quarter */
51
+ #fff 50% 75%, /* White for the third quarter */
52
+ #000 75% 100% /* Black for the fourth quarter */
53
+ ) 50% / 10px 10px;
54
+ height: 15px;
25
55
 
26
56
  }
27
57
  spectric-input.alpha-gradient input[type="range"],spectric-input.hue-gradient input[type="range"]{ -webkit-appearance: none; /* For WebKit browsers (Chrome, Safari) */
@@ -36,5 +66,8 @@ spectric-input.alpha-gradient input[type="range"],spectric-input.hue-gradient in
36
66
  cursor: crosshair;
37
67
  }
38
68
  .color-picker-eyedropper{
39
- --button-border-radius:50%
69
+ --button-border-radius:50%;
70
+ }
71
+ .color-picker-eyedropper.hidden{
72
+ display:none;
40
73
  }