@spectric/ui 0.0.18 → 0.0.19
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/Button.d.ts +2 -1
- package/dist/components/Panel.d.ts +6 -3
- package/dist/components/calendar/calendar.d.ts +58 -0
- package/dist/components/calendar/index.d.ts +1 -0
- package/dist/components/color_picker/ColorPicker.d.ts +7 -6
- package/dist/components/index.d.ts +1 -0
- package/dist/components/input.d.ts +24 -20
- package/dist/components/query_bar/QueryBar.d.ts +2 -1
- package/dist/components/table/table.d.ts +3 -0
- package/dist/components/tooltip/popover.d.ts +32 -2
- package/dist/components/tooltip/tooltip.d.ts +1 -32
- package/dist/custom-elements.json +59 -14
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +2842 -2564
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +298 -178
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/Button.ts +14 -13
- package/src/components/Panel.ts +25 -18
- package/src/components/button.css.ts +13 -0
- package/src/components/calendar/calendar.css +50 -0
- package/src/components/calendar/calendar.ts +281 -0
- package/src/components/calendar/index.ts +1 -0
- package/src/components/color_picker/ColorPicker.css +36 -3
- package/src/components/color_picker/ColorPicker.ts +46 -15
- package/src/components/index.ts +2 -1
- package/src/components/input.css +1 -1
- package/src/components/input.ts +203 -142
- package/src/components/panel.css.ts +7 -5
- package/src/components/query_bar/QueryBar.css +6 -2
- package/src/components/query_bar/QueryBar.ts +25 -13
- package/src/components/table/table.ts +43 -35
- package/src/components/table/virtualBody.ts +3 -2
- package/src/components/tooltip/popover.ts +70 -30
- package/src/components/tooltip/tooltip.css +7 -2
- package/src/components/tooltip/tooltip.ts +3 -37
- package/src/stories/Calendar.stories.ts +70 -0
- package/src/stories/fixtures/ExampleContent.ts +1 -1
- package/src/stories/tooltip.stories.ts +9 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { html, LitElement, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
-
import { customElement, property, state } from 'lit/decorators.js';
|
|
2
|
+
import { customElement, eventOptions, property, state } from 'lit/decorators.js';
|
|
3
3
|
import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
|
|
4
4
|
import { PopoverElement } from '../tooltip/popover';
|
|
5
5
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
@@ -26,9 +26,9 @@ interface EyeDropper {
|
|
|
26
26
|
|
|
27
27
|
declare var EyeDropper: EyeDropper;
|
|
28
28
|
let eyedropper: EyeDropper | undefined
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
if (window.hasOwnProperty("EyeDropper")) {
|
|
30
|
+
eyedropper = new EyeDropper()
|
|
31
|
+
}
|
|
32
32
|
@customElement('spectric-colorpicker')
|
|
33
33
|
export class SpectricColorPicker extends LitElement implements ColorPickerProps {
|
|
34
34
|
@property({ type: String, reflect: true })
|
|
@@ -51,7 +51,15 @@ export class SpectricColorPicker extends LitElement implements ColorPickerProps
|
|
|
51
51
|
protected createRenderRoot(): HTMLElement | DocumentFragment {
|
|
52
52
|
return this
|
|
53
53
|
}
|
|
54
|
+
constructor() {
|
|
55
|
+
super()
|
|
56
|
+
this._handleAlphaChange = this._handleAlphaChange.bind(this)
|
|
57
|
+
this._handleHueChange = this._handleHueChange.bind(this)
|
|
58
|
+
this._handleApply = this._handleApply.bind(this)
|
|
59
|
+
this._cancel = this._cancel.bind(this)
|
|
60
|
+
this._handleSaturationLightnessClick = this._handleSaturationLightnessClick.bind(this)
|
|
54
61
|
|
|
62
|
+
}
|
|
55
63
|
protected update(changedProperties: PropertyValues): void {
|
|
56
64
|
if (changedProperties.has("value")) {
|
|
57
65
|
let { h, s, l, a } = hexToHsl(this.value)
|
|
@@ -85,7 +93,8 @@ export class SpectricColorPicker extends LitElement implements ColorPickerProps
|
|
|
85
93
|
y += ypix;
|
|
86
94
|
}
|
|
87
95
|
}
|
|
88
|
-
|
|
96
|
+
@eventOptions({ capture: true })
|
|
97
|
+
_handleSaturationLightnessClick(e: PointerEvent) {
|
|
89
98
|
if (!this.canvas.value) {
|
|
90
99
|
return
|
|
91
100
|
}
|
|
@@ -94,30 +103,44 @@ export class SpectricColorPicker extends LitElement implements ColorPickerProps
|
|
|
94
103
|
this.lightness = (this.canvas.value.height - offsetY) / this.canvas.value.height
|
|
95
104
|
this.updateValue()
|
|
96
105
|
}
|
|
97
|
-
|
|
106
|
+
@eventOptions({ capture: true })
|
|
107
|
+
_handleHueChange(e: DomEvent<SpectricInput>) {
|
|
108
|
+
e.stopPropagation()
|
|
98
109
|
this.hue = (parseInt(String(e.target.value)) / 100) * 360
|
|
99
110
|
e.target.style.setProperty("accent-color", `hsl(${this.hue}deg 100% 50%)`)
|
|
100
111
|
this.renderHueSaturationGrid()
|
|
101
112
|
this.updateValue()
|
|
102
113
|
}
|
|
103
114
|
private updateValue() {
|
|
104
|
-
|
|
115
|
+
let hex = hslToHex(this.hue, this.saturation * 100, this.lightness * 100) + (Math.round(this.alpha * 255).toString(16).padStart(2, "0"))
|
|
116
|
+
this.value = hex
|
|
105
117
|
}
|
|
106
|
-
|
|
118
|
+
@eventOptions({ capture: true })
|
|
119
|
+
_handleAlphaChange(e: DomEvent<SpectricInput>) {
|
|
120
|
+
e.stopPropagation()
|
|
107
121
|
this.alpha = parseInt(String(e.target.value)) / 100
|
|
108
122
|
this.updateValue()
|
|
109
123
|
}
|
|
110
|
-
|
|
124
|
+
@eventOptions({ capture: true })
|
|
125
|
+
_handleApply() {
|
|
111
126
|
this.updateValue()
|
|
112
127
|
this.querySelector<PopoverElement>("spectric-popover")?.hidePopover()
|
|
128
|
+
this.dispatchEvent(new Event("change", { bubbles: true }))
|
|
113
129
|
}
|
|
114
|
-
|
|
130
|
+
@eventOptions({ capture: true })
|
|
131
|
+
_cancel() {
|
|
115
132
|
if (this.original) {
|
|
116
133
|
this.value = this.original
|
|
117
134
|
}
|
|
118
135
|
this.querySelector<PopoverElement>("spectric-popover")?.hidePopover()
|
|
136
|
+
this.dispatchEvent(new Event("cancel"))
|
|
119
137
|
}
|
|
120
|
-
|
|
138
|
+
@eventOptions({ capture: true })
|
|
139
|
+
async _openPopover() {
|
|
140
|
+
let popover = this.querySelector<PopoverElement>("spectric-popover")
|
|
141
|
+
if (!popover || popover.isOpen()) {
|
|
142
|
+
return
|
|
143
|
+
}
|
|
121
144
|
this.original = this.value
|
|
122
145
|
this.querySelector<PopoverElement>("spectric-popover")?.showPopover()
|
|
123
146
|
while (!this.canvas.value) {
|
|
@@ -129,13 +152,21 @@ export class SpectricColorPicker extends LitElement implements ColorPickerProps
|
|
|
129
152
|
return html`
|
|
130
153
|
<spectric-input label="Hue" class="hue-gradient" variant="range" .value=${this.hue || 0} style="accent-color:hsl(${this.hue}deg 100% 50%)" @change=${this._handleHueChange}></spectric-input>
|
|
131
154
|
<canvas ${ref(this.canvas)} width=200 height=100 class="color-picker-saturation-lightness-grid" @click=${this._handleSaturationLightnessClick}
|
|
132
|
-
@mousedown=${() => {
|
|
133
|
-
|
|
155
|
+
@mousedown=${(e: MouseEvent) => {
|
|
156
|
+
this.sldown = true
|
|
157
|
+
e.preventDefault()
|
|
158
|
+
e.stopPropagation()
|
|
159
|
+
}}
|
|
160
|
+
@mouseup=${(e: MouseEvent) => {
|
|
161
|
+
this.sldown = false
|
|
162
|
+
e.preventDefault()
|
|
163
|
+
e.stopPropagation()
|
|
164
|
+
}}
|
|
134
165
|
@mousemove=${(e: PointerEvent) => { if (this.sldown) { this._handleSaturationLightnessClick(e) } }}
|
|
135
166
|
></canvas>
|
|
136
167
|
<spectric-input class="alpha-gradient" ?hidden=${!this.showAlpha} label="Opacity" variant="range" .value=${(this.alpha || 1) * 100} @change=${this._handleAlphaChange}></spectric-input>
|
|
137
168
|
<div class="color-picker-footer">
|
|
138
|
-
<spectric-button
|
|
169
|
+
<spectric-button icon class="color-picker-eyedropper ${eyedropper === undefined ? "hidden" : ""}" @click=${async () => {
|
|
139
170
|
if (eyedropper) {
|
|
140
171
|
let result = await eyedropper?.open()
|
|
141
172
|
let { h, s, l, a } = hexToHsl(result.sRGBHex);
|
|
@@ -154,7 +185,7 @@ export class SpectricColorPicker extends LitElement implements ColorPickerProps
|
|
|
154
185
|
|
|
155
186
|
protected render(): unknown {
|
|
156
187
|
return html`
|
|
157
|
-
<spectric-button variant="
|
|
188
|
+
<spectric-button variant="secondary" @click=${this._openPopover} icon>
|
|
158
189
|
<spectric-popover .text=${this.getPopover()} icon variant="text"></spectric-popover>
|
|
159
190
|
<div style="width:15px;height:15px;background-color:${this.value}"></div>
|
|
160
191
|
</spectric-button>
|
package/src/components/index.ts
CHANGED
package/src/components/input.css
CHANGED