@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
|
@@ -8,6 +8,7 @@ import "./QueryBar.css"
|
|
|
8
8
|
import { DialogElement } from "../dialog";
|
|
9
9
|
import { createRef, ref } from "lit/directives/ref.js";
|
|
10
10
|
import { SpectricButton } from "../Button";
|
|
11
|
+
import { PopoverElement } from "../tooltip/popover";
|
|
11
12
|
export type FieldTypes = {
|
|
12
13
|
name: string;
|
|
13
14
|
type: "string" | "number" | "boolean"
|
|
@@ -120,7 +121,7 @@ export class SpectricQuery extends LitElement implements IQueryProps {
|
|
|
120
121
|
fields: FieldTypes[] = [];
|
|
121
122
|
|
|
122
123
|
@query(".autocomplete")
|
|
123
|
-
_autocomplete?:
|
|
124
|
+
_autocomplete?: PopoverElement
|
|
124
125
|
|
|
125
126
|
@queryAsync(".autocomplete")
|
|
126
127
|
//@ts-expect-error
|
|
@@ -182,7 +183,7 @@ export class SpectricQuery extends LitElement implements IQueryProps {
|
|
|
182
183
|
if (suggestion.type !== "cursor") {
|
|
183
184
|
return
|
|
184
185
|
}
|
|
185
|
-
let completions = []
|
|
186
|
+
let completions: Completion[] = []
|
|
186
187
|
this.suggestion = suggestion
|
|
187
188
|
let { start, end } = suggestion
|
|
188
189
|
for (let type of suggestion.suggestionTypes) {
|
|
@@ -260,14 +261,17 @@ export class SpectricQuery extends LitElement implements IQueryProps {
|
|
|
260
261
|
}
|
|
261
262
|
this.completions = completions
|
|
262
263
|
if (this.completions.length && this._autocomplete) {
|
|
263
|
-
let { width
|
|
264
|
+
let { width } = this._input.getBoundingClientRect();
|
|
265
|
+
this._autocomplete.maxWidth = width
|
|
264
266
|
this._autocomplete.showPopover();
|
|
265
|
-
|
|
266
|
-
if (!("anchorName" in document.documentElement.style)) {
|
|
267
|
-
this._autocomplete.style.left = `${left + 3.75}px`
|
|
268
|
-
this._autocomplete.style.top = `${bottom}px`
|
|
269
|
-
}
|
|
267
|
+
|
|
270
268
|
this._autocomplete.style.width = `${width - 15}px`;
|
|
269
|
+
let popover = this._autocomplete.querySelector<HTMLElement>("[popover]")
|
|
270
|
+
if (popover) {
|
|
271
|
+
popover.style.width = `${width - 15}px`;
|
|
272
|
+
}
|
|
273
|
+
} else {
|
|
274
|
+
this._autocomplete?.hidePopover()
|
|
271
275
|
}
|
|
272
276
|
}
|
|
273
277
|
protected updated(changed: PropertyValues): void {
|
|
@@ -345,14 +349,22 @@ export class SpectricQuery extends LitElement implements IQueryProps {
|
|
|
345
349
|
protected render() {
|
|
346
350
|
return html`
|
|
347
351
|
<spectric-input .value=${this.value} .placeholder=${this.placeholder} style=${`anchor-name:--${this.uuid};`} autocomplete="off" @input=${this._parseQuery} @keydown=${this._handleArrows} @change=${(e: Event) => e.stopPropagation()}></spectric-input>
|
|
348
|
-
<
|
|
349
|
-
${this.completions.map((option: Completion, index) =>
|
|
352
|
+
<spectric-popover position="bottom" class="autocomplete" .text=${this.completions.map((option: Completion, index) =>
|
|
350
353
|
html`<div @click=${() => {
|
|
351
354
|
this.completionIndex = index;
|
|
352
355
|
this._selectCompletion()
|
|
353
|
-
}}
|
|
354
|
-
|
|
355
|
-
</
|
|
356
|
+
}}
|
|
357
|
+
class=${this.completionIndex == index ? "option active" : "option"}>
|
|
358
|
+
<span class="optiontype ${option.type}">${option.type}</span>
|
|
359
|
+
<span class="value">${option.value}</span>
|
|
360
|
+
<span class="label">${option.label}</span>
|
|
361
|
+
</div>
|
|
362
|
+
`
|
|
363
|
+
)
|
|
364
|
+
}>
|
|
365
|
+
|
|
366
|
+
</spectric-popover>
|
|
367
|
+
`
|
|
356
368
|
}
|
|
357
369
|
}
|
|
358
370
|
|
|
@@ -33,6 +33,7 @@ export enum TableSortDirection {
|
|
|
33
33
|
}
|
|
34
34
|
export type TableSortDirectionTypes = `${TableSortDirection}`
|
|
35
35
|
export type ColumnSettings<T> = {
|
|
36
|
+
[TABLE_CREATED_SELECTION_COLUMN]?: boolean
|
|
36
37
|
width?: number
|
|
37
38
|
/**
|
|
38
39
|
* Enabled/disables resizing by dragging column header Default true
|
|
@@ -73,6 +74,9 @@ interface TableProps<T> extends TableDataOptions<T> {
|
|
|
73
74
|
export type DomEvent<T> = Event & {
|
|
74
75
|
target: T
|
|
75
76
|
}
|
|
77
|
+
|
|
78
|
+
export const TD_BorderAndPadding = 4;
|
|
79
|
+
const TABLE_CREATED_SELECTION_COLUMN = Symbol("spectric-table-selection-column")
|
|
76
80
|
/**
|
|
77
81
|
* React example
|
|
78
82
|
* <iframe width="100%" height="400px" src="https://stackblitz.com/edit/react-ts-2ue7azag?ctl=1&embed=1&file=App.tsx&hideExplorer=1&hideNavigation=1"/>
|
|
@@ -215,6 +219,42 @@ export class SpectricTableElement<T = any> extends LitElement implements TablePr
|
|
|
215
219
|
}
|
|
216
220
|
}
|
|
217
221
|
protected update(changedProperties: PropertyValues): void {
|
|
222
|
+
if (changedProperties.has("columns")) {
|
|
223
|
+
if (this.select !== TableSelectOptions.none) {
|
|
224
|
+
if (!this.columns.find(col => col[TABLE_CREATED_SELECTION_COLUMN])) {
|
|
225
|
+
this.columns.unshift({
|
|
226
|
+
[TABLE_CREATED_SELECTION_COLUMN]: true,
|
|
227
|
+
title: this.select === "multi" ? html`<spectric-input variant="checkbox" @change=${this._handleSelectAllChange} .helperText=${"Select All"}></spectric-input>` : null,
|
|
228
|
+
render: (row) => {
|
|
229
|
+
let container = document.createElement("div")
|
|
230
|
+
let checked = this.selected.includes(row)
|
|
231
|
+
let template = html`<spectric-input variant="checkbox" class="table-checkbox-${this.select}" .helperText=${""} ${spreadProps({ checked })} @change=${(e: DomEvent<HTMLInputElement>) => {
|
|
232
|
+
e.stopPropagation()
|
|
233
|
+
let index = this.selected.findIndex(value => value === row)
|
|
234
|
+
if (e.target.checked && index !== -1) {
|
|
235
|
+
return
|
|
236
|
+
}
|
|
237
|
+
else if (!e.target.checked && index === -1) {
|
|
238
|
+
return
|
|
239
|
+
}
|
|
240
|
+
else if (!e.target.checked && index !== -1) {
|
|
241
|
+
this.selected.splice(index, 1)
|
|
242
|
+
}
|
|
243
|
+
if (e.target.checked) {
|
|
244
|
+
if (this.select === "single") {
|
|
245
|
+
this.selected = []
|
|
246
|
+
}
|
|
247
|
+
this.selected.push(row)
|
|
248
|
+
}
|
|
249
|
+
this.dispatchEvent(new CustomEvent("selected", { detail: [...this.selected] }))
|
|
250
|
+
}}></spectric-input>`
|
|
251
|
+
render(template, container)
|
|
252
|
+
return template
|
|
253
|
+
}
|
|
254
|
+
})
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
218
258
|
if (changedProperties.has("select")) {
|
|
219
259
|
if (this.select === "single" && this.selected.length > 1) {
|
|
220
260
|
this.selected = [this.selected[0]]
|
|
@@ -225,41 +265,9 @@ export class SpectricTableElement<T = any> extends LitElement implements TablePr
|
|
|
225
265
|
}
|
|
226
266
|
protected render(): unknown {
|
|
227
267
|
let columns = this.columns.filter(column => !column.hidden)
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
render: (row) => {
|
|
232
|
-
let container = document.createElement("div")
|
|
233
|
-
let checked = this.selected.includes(row)
|
|
234
|
-
let template = html`<spectric-input variant="checkbox" class="table-checkbox-${this.select}" .helperText=${""} ${spreadProps({ checked })} @change=${(e: DomEvent<HTMLInputElement>) => {
|
|
235
|
-
e.stopPropagation()
|
|
236
|
-
let index = this.selected.findIndex(value => value === row)
|
|
237
|
-
if (e.target.checked && index !== -1) {
|
|
238
|
-
return
|
|
239
|
-
}
|
|
240
|
-
else if (!e.target.checked && index === -1) {
|
|
241
|
-
return
|
|
242
|
-
}
|
|
243
|
-
else if (!e.target.checked && index !== -1) {
|
|
244
|
-
this.selected.splice(index, 1)
|
|
245
|
-
}
|
|
246
|
-
if (e.target.checked) {
|
|
247
|
-
if (this.select === "single") {
|
|
248
|
-
this.selected = []
|
|
249
|
-
}
|
|
250
|
-
this.selected.push(row)
|
|
251
|
-
}
|
|
252
|
-
this.dispatchEvent(new CustomEvent("selected", { detail: [...this.selected] }))
|
|
253
|
-
}}></spectric-input>`
|
|
254
|
-
render(template, container)
|
|
255
|
-
return template
|
|
256
|
-
}
|
|
257
|
-
})
|
|
258
|
-
}
|
|
259
|
-
const tdBorderAndPadding = 4;
|
|
260
|
-
let rowHeight = this.rowHeight - tdBorderAndPadding;
|
|
261
|
-
if (rowHeight < this.fontSize + tdBorderAndPadding) {
|
|
262
|
-
rowHeight = this.fontSize + tdBorderAndPadding
|
|
268
|
+
let rowHeight = this.rowHeight - TD_BorderAndPadding;
|
|
269
|
+
if (rowHeight < this.fontSize + TD_BorderAndPadding) {
|
|
270
|
+
rowHeight = this.fontSize + TD_BorderAndPadding
|
|
263
271
|
}
|
|
264
272
|
return html`
|
|
265
273
|
<div class="table-wrapper" style="--rowHeight:${rowHeight}px;--fontSize:${this.fontSize}px;--lineClamp:${Math.floor(rowHeight / this.fontSize)}">
|
|
@@ -3,7 +3,7 @@ import { customElement, property, } from 'lit/decorators.js';
|
|
|
3
3
|
import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
|
|
4
4
|
export const TableBodyElementTag = "spectric-table-virtual-body"
|
|
5
5
|
import "./cell"
|
|
6
|
-
import { ColumnSettings, SpectricTableElement } from './table';
|
|
6
|
+
import { ColumnSettings, SpectricTableElement, TD_BorderAndPadding } from './table';
|
|
7
7
|
import { repeat } from 'lit/directives/repeat.js';
|
|
8
8
|
import { DisposableElement } from '../../classes/DisposibleElement';
|
|
9
9
|
import "./virtualBody.css"
|
|
@@ -50,10 +50,11 @@ export class TableVirtualBodyElement<T> extends DisposableElement implements Bod
|
|
|
50
50
|
let rect = cells[index].getBoundingClientRect()
|
|
51
51
|
if (rect.width > 0) {
|
|
52
52
|
this.columnsMeasured = true
|
|
53
|
-
col.width = rect.width
|
|
53
|
+
col.width = rect.width - TD_BorderAndPadding
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
})
|
|
57
|
+
this.columns = [...this.columns]
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
2
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
3
3
|
import "./tooltip.css"
|
|
4
4
|
export const PopoverElementTag = "spectric-popover"
|
|
5
|
-
import { css, CSSResultGroup, html
|
|
5
|
+
import { css, CSSResultGroup, html } from "lit-element";
|
|
6
6
|
import { DomRenderable } from "../table";
|
|
7
7
|
import { DisposableElement } from '../../classes/DisposibleElement';
|
|
8
|
-
import {
|
|
9
|
-
export type { TooltipProps,
|
|
8
|
+
import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
|
|
9
|
+
export type { TooltipProps, PopOverEvents }
|
|
10
10
|
export enum TooltipPostions {
|
|
11
11
|
top = "top",
|
|
12
12
|
bottom = "bottom",
|
|
@@ -46,6 +46,8 @@ interface TooltipProps {
|
|
|
46
46
|
* The element that triggers the tooltip. This is used for special cases like in the shadow dom if you want to target a host element instead of the immediate parent element
|
|
47
47
|
*/
|
|
48
48
|
triggerTarget?: HTMLElement
|
|
49
|
+
mouseOffsetX?: number
|
|
50
|
+
mouseOffsetY?: number
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
/**
|
|
@@ -63,6 +65,11 @@ export class PopoverElement extends DisposableElement implements TooltipProps {
|
|
|
63
65
|
position: TooltipPostionsTypes = "right";
|
|
64
66
|
@property({ type: Number, reflect: true })
|
|
65
67
|
maxWidth?: number = 300;
|
|
68
|
+
@property({ type: Number, reflect: false })
|
|
69
|
+
mouseOffsetX = 10
|
|
70
|
+
@property({ type: Number, reflect: false })
|
|
71
|
+
mouseOffsetY = 0
|
|
72
|
+
@query(".spectric-popover-portal")
|
|
66
73
|
protected portalElement!: HTMLDivElement
|
|
67
74
|
protected mouseLocation?: { left: number; top: number; };
|
|
68
75
|
static styles?: CSSResultGroup | undefined = css`:host{max-height: 0px;
|
|
@@ -74,6 +81,9 @@ export class PopoverElement extends DisposableElement implements TooltipProps {
|
|
|
74
81
|
protected timer?: number;
|
|
75
82
|
protected open: boolean = false;
|
|
76
83
|
protected mouseframe?: number;
|
|
84
|
+
isOpen() {
|
|
85
|
+
return this.open
|
|
86
|
+
}
|
|
77
87
|
/**
|
|
78
88
|
* @default parentElement
|
|
79
89
|
*/
|
|
@@ -91,16 +101,19 @@ export class PopoverElement extends DisposableElement implements TooltipProps {
|
|
|
91
101
|
this.hidePopover = this.hidePopover.bind(this)
|
|
92
102
|
this.addDisposableListener(() => this.target, "mousemove", this._getMousePosition)
|
|
93
103
|
}
|
|
104
|
+
protected createRenderRoot(): HTMLElement | DocumentFragment {
|
|
105
|
+
return this
|
|
106
|
+
}
|
|
94
107
|
connectedCallback(): void {
|
|
95
108
|
super.connectedCallback()
|
|
96
|
-
this.portalElement = document.createElement("div")
|
|
97
|
-
this.portalElement.className = "spectric-tooltip-portal"
|
|
109
|
+
//this.portalElement = document.createElement("div")
|
|
110
|
+
//this.portalElement.className = "spectric-tooltip-portal"
|
|
98
111
|
}
|
|
99
112
|
disconnectedCallback(): void {
|
|
100
113
|
super.disconnectedCallback();
|
|
101
|
-
this.portalElement.remove()
|
|
114
|
+
//this.portalElement.remove()
|
|
102
115
|
//@ts-ignore
|
|
103
|
-
this.portalElement = undefined
|
|
116
|
+
//this.portalElement = undefined
|
|
104
117
|
}
|
|
105
118
|
protected _getMousePosition = (ev: MouseEvent) => {
|
|
106
119
|
this.mouseLocation = {
|
|
@@ -119,7 +132,7 @@ export class PopoverElement extends DisposableElement implements TooltipProps {
|
|
|
119
132
|
clearTimeout(this.timer)
|
|
120
133
|
}
|
|
121
134
|
this.open = false
|
|
122
|
-
this.portalElement.
|
|
135
|
+
this.portalElement.hidePopover()
|
|
123
136
|
}
|
|
124
137
|
/**
|
|
125
138
|
* Public method to trigger showing the tooltip programatically
|
|
@@ -131,18 +144,19 @@ export class PopoverElement extends DisposableElement implements TooltipProps {
|
|
|
131
144
|
await new Promise(resolve => {
|
|
132
145
|
this.timer = window.setTimeout(resolve, this.delay)
|
|
133
146
|
})
|
|
134
|
-
this.portalElement.className = `spectric-popover-portal ${this.position}`
|
|
135
|
-
const tooltip = html`<div class="tooltip-container">
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
</div>`
|
|
139
|
-
render(tooltip, this.portalElement)
|
|
140
|
-
//with the delay it is possible that the triggering element was removed or hidden lets check that it is visible
|
|
141
|
-
if (!this.target || !this.target.checkVisibility()) {
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
//We need to append our tooltip and let the css updates apply before we can take measurements
|
|
145
|
-
this.portalTarget.appendChild(this.portalElement)
|
|
147
|
+
// this.portalElement.className = `spectric-popover-portal ${this.position}`
|
|
148
|
+
// const tooltip = html`<div class="tooltip-container">
|
|
149
|
+
// <span class="tooltip-caret"></span>
|
|
150
|
+
// <div class="tooltip-content">${this.text}</div>
|
|
151
|
+
// </div>`
|
|
152
|
+
// render(tooltip, this.portalElement)
|
|
153
|
+
// //with the delay it is possible that the triggering element was removed or hidden lets check that it is visible
|
|
154
|
+
// if (!this.target || !this.target.checkVisibility()) {
|
|
155
|
+
// return
|
|
156
|
+
// }
|
|
157
|
+
// //We need to append our tooltip and let the css updates apply before we can take measurements
|
|
158
|
+
// this.portalTarget.appendChild(this.portalElement)
|
|
159
|
+
this.portalElement.showPopover()
|
|
146
160
|
this.open = true
|
|
147
161
|
requestAnimationFrame(this.positionTooltip)
|
|
148
162
|
}
|
|
@@ -157,14 +171,10 @@ export class PopoverElement extends DisposableElement implements TooltipProps {
|
|
|
157
171
|
return
|
|
158
172
|
}
|
|
159
173
|
//Since we are attaching to a body we need to send the correct styles from the target portion of the dom to the portal element
|
|
160
|
-
let computedStyle = getComputedStyle(this)
|
|
161
174
|
|
|
162
175
|
let styles: Record<string, string> = {
|
|
163
176
|
|
|
164
177
|
}
|
|
165
|
-
SPECTRIC_CSS_VARIABLES.forEach(v => {
|
|
166
|
-
styles[v] = computedStyle.getPropertyValue(v)
|
|
167
|
-
})
|
|
168
178
|
const bounds = this.target.getBoundingClientRect()
|
|
169
179
|
const portalBounds = this.portalElement.getBoundingClientRect()
|
|
170
180
|
if (this.target !== document.body) {
|
|
@@ -178,7 +188,7 @@ export class PopoverElement extends DisposableElement implements TooltipProps {
|
|
|
178
188
|
};
|
|
179
189
|
if (this.position === "mouse" && this.mouseLocation) {
|
|
180
190
|
this.mouseframe = undefined
|
|
181
|
-
location = { left: this.mouseLocation.left +
|
|
191
|
+
location = { left: this.mouseLocation.left + this.mouseOffsetX + "px", top: this.mouseLocation.top + this.mouseOffsetY - (portalBounds.height / 2) + "px" }
|
|
182
192
|
} else if (this.position === "top") {
|
|
183
193
|
location = {
|
|
184
194
|
top: bounds.top - portalBounds.height + "px",
|
|
@@ -209,13 +219,43 @@ export class PopoverElement extends DisposableElement implements TooltipProps {
|
|
|
209
219
|
}
|
|
210
220
|
}
|
|
211
221
|
protected render() {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
222
|
+
return html`<!-- ToolTip -->
|
|
223
|
+
<div class="spectric-popover-portal ${this.position}" popover>
|
|
224
|
+
<div class="tooltip-container">
|
|
225
|
+
<span class="tooltip-caret"></span>
|
|
226
|
+
<div class="tooltip-content">${this.text}<slot></slot></div>
|
|
227
|
+
</div>
|
|
228
|
+
</div>`
|
|
215
229
|
}
|
|
216
230
|
}
|
|
217
231
|
|
|
218
|
-
interface
|
|
232
|
+
interface PopOverEvents {
|
|
219
233
|
//'open': (event: CustomEvent<{ pagination: PaginationChangeProps }>) => void;
|
|
220
234
|
//'filter': (event: CustomEvent<FilterEvent>) => void;
|
|
221
235
|
}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
declare global {
|
|
239
|
+
interface HTMLElementTagNameMap {
|
|
240
|
+
[PopoverElementTag]: HTMLElementTagWithEvents<PopoverElement, PopOverEvents>
|
|
241
|
+
|
|
242
|
+
}
|
|
243
|
+
namespace JSX {
|
|
244
|
+
interface IntrinsicElements {
|
|
245
|
+
/**
|
|
246
|
+
* @see {@link TooltipElement}
|
|
247
|
+
*/
|
|
248
|
+
[PopoverElementTag]: ReactElementWithPropsAndEvents<PopoverElement, TooltipProps, PopOverEvents>;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
namespace React {
|
|
252
|
+
namespace JSX {
|
|
253
|
+
interface IntrinsicElements {
|
|
254
|
+
/**
|
|
255
|
+
* @see {@link TooltipElement}
|
|
256
|
+
*/
|
|
257
|
+
[PopoverElementTag]: ReactElementWithPropsAndEvents<PopoverElement, TooltipProps, PopOverEvents>
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
.spectric-popover-portal{
|
|
2
|
+
margin: 0px;
|
|
3
|
+
border: 0px;
|
|
4
|
+
padding: 0px;
|
|
2
5
|
position: fixed;
|
|
3
6
|
z-index: 9999;
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
background: transparent;
|
|
8
|
+
pointer-events: all;
|
|
9
|
+
--spectric-tooltip-background-color: var(--spectric-tooltip-background, var(--spectric-background,#ffffff));
|
|
10
|
+
--spectric-tooltip-text-color: var(--spectric-tooltip-text, var(--spectric-text-primary, rgb(0, 0, 0)));
|
|
6
11
|
--spectric-tooltip-accent-color: var(--spectric-tooltip-accent, var(--spectric-primary, #1ea7fd));
|
|
7
12
|
}
|
|
8
13
|
.spectric-popover-portal.spectric-tooltip-portal{
|
|
@@ -3,9 +3,9 @@ import { customElement, property } from 'lit/decorators.js';
|
|
|
3
3
|
import { HTMLElementTagWithEvents, ReactElementWithPropsAndEvents } from '../types';
|
|
4
4
|
import "./tooltip.css"
|
|
5
5
|
export const TooltipElementTag = "spectric-tooltip"
|
|
6
|
-
import { css, CSSResultGroup
|
|
6
|
+
import { css, CSSResultGroup } from "lit-element";
|
|
7
7
|
import { DomRenderable } from "../table";
|
|
8
|
-
import { PopoverElement } from './popover';
|
|
8
|
+
import { PopoverElement, TooltipProps } from './popover';
|
|
9
9
|
export type { TooltipProps, TooltipEvents }
|
|
10
10
|
export enum TooltipPostions {
|
|
11
11
|
top = "top",
|
|
@@ -16,37 +16,7 @@ export enum TooltipPostions {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export type TooltipPostionsTypes = `${TooltipPostions}`
|
|
19
|
-
interface TooltipProps {
|
|
20
|
-
/**
|
|
21
|
-
* How long you need to hover before the tooltip displays
|
|
22
|
-
*/
|
|
23
|
-
delay?: number;
|
|
24
|
-
/**
|
|
25
|
-
* How long the fade in animation should run
|
|
26
|
-
*/
|
|
27
|
-
animationDuration?: number;
|
|
28
|
-
/**
|
|
29
|
-
* Tooltip contents
|
|
30
|
-
*/
|
|
31
|
-
text: DomRenderable
|
|
32
|
-
/**
|
|
33
|
-
* Where to anchor the tooltip
|
|
34
|
-
*/
|
|
35
|
-
position?: TooltipPostionsTypes
|
|
36
|
-
/**
|
|
37
|
-
* Sets a max width for the contents you can disable this by setting to 0 or -1
|
|
38
|
-
*/
|
|
39
|
-
maxWidth?: number
|
|
40
|
-
/**
|
|
41
|
-
* Container the tool tip will be attached to.
|
|
42
|
-
*/
|
|
43
|
-
portalTarget?: HTMLElement
|
|
44
19
|
|
|
45
|
-
/**
|
|
46
|
-
* The element that triggers the tooltip. This is used for special cases like in the shadow dom if you want to target a host element instead of the immediate parent element
|
|
47
|
-
*/
|
|
48
|
-
triggerTarget?: HTMLElement
|
|
49
|
-
}
|
|
50
20
|
|
|
51
21
|
/**
|
|
52
22
|
* Spectric tooltip will add a tooltip to any container
|
|
@@ -94,11 +64,7 @@ export class TooltipElement extends PopoverElement implements TooltipProps {
|
|
|
94
64
|
this.portalElement.classList.add("spectric-tooltip-portal")
|
|
95
65
|
}
|
|
96
66
|
|
|
97
|
-
|
|
98
|
-
//We don't need to render anything here this is just a placeholder element the content is displayed in a portal attached to the body.
|
|
99
|
-
// See showTooltip for the real rendering
|
|
100
|
-
return html`<!-- ToolTip -->`
|
|
101
|
-
}
|
|
67
|
+
|
|
102
68
|
}
|
|
103
69
|
|
|
104
70
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/web-components";
|
|
2
|
+
|
|
3
|
+
import { type SpectricCalendarProps as Props } from "../components/calendar";
|
|
4
|
+
import { html } from "lit";
|
|
5
|
+
import '../components';
|
|
6
|
+
import { useArgs } from "@storybook/client-api";
|
|
7
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
8
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
9
|
+
const meta = {
|
|
10
|
+
title: "UI/Calendar",
|
|
11
|
+
tags: ["autodocs"],
|
|
12
|
+
component: "spectric-calendar",
|
|
13
|
+
render: (args) => {
|
|
14
|
+
const [_, updateArgs] = useArgs();
|
|
15
|
+
|
|
16
|
+
return html`
|
|
17
|
+
<spectric-calendar
|
|
18
|
+
?popup=${args.popup}
|
|
19
|
+
?disabled=${args.disabled}
|
|
20
|
+
.currentDate=${args.currentDate}
|
|
21
|
+
@select=${(e: CustomEvent<Date>) => {
|
|
22
|
+
updateArgs({ ...e.detail });
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
</spectric-calendar>
|
|
26
|
+
`;
|
|
27
|
+
},
|
|
28
|
+
argTypes: {
|
|
29
|
+
popup: {
|
|
30
|
+
control: { type: 'boolean' },
|
|
31
|
+
},
|
|
32
|
+
disabled: {
|
|
33
|
+
control: { type: 'boolean' },
|
|
34
|
+
},
|
|
35
|
+
currentDate: {
|
|
36
|
+
control: { type: "date" }
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
args: {
|
|
40
|
+
popup: false,
|
|
41
|
+
disabled: false,
|
|
42
|
+
currentDate: new Date()
|
|
43
|
+
},
|
|
44
|
+
} satisfies Meta<Props>;
|
|
45
|
+
|
|
46
|
+
export default meta;
|
|
47
|
+
type Story = StoryObj<Props>;
|
|
48
|
+
|
|
49
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
50
|
+
export const Basic: Story = {
|
|
51
|
+
args: {
|
|
52
|
+
popup: false,
|
|
53
|
+
currentDate: new Date()
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
export const Popup: Story = {
|
|
57
|
+
args: {
|
|
58
|
+
popup: true,
|
|
59
|
+
currentDate: new Date()
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* When the total items is unknown pagination will only shows page size
|
|
64
|
+
*/
|
|
65
|
+
export const Disabled: Story = {
|
|
66
|
+
args: {
|
|
67
|
+
disabled: true,
|
|
68
|
+
currentDate: new Date()
|
|
69
|
+
},
|
|
70
|
+
};
|
|
@@ -127,7 +127,7 @@ export class SpectricStorybookExampleContent extends LitElement implements Props
|
|
|
127
127
|
<spectric-button size="small" >Submit</spectric-button><spectric-button size="small" variant="secondary">Continue</spectric-button><spectric-button size="small" variant="text">Cancel</spectric-button>
|
|
128
128
|
</spectric-panel>
|
|
129
129
|
</spectric-splitview>
|
|
130
|
-
|
|
130
|
+
<spectric-calendar></spectric-calendar>
|
|
131
131
|
</spectric-panel>
|
|
132
132
|
<div style="display:flex">
|
|
133
133
|
<span style="flex-grow:1"></span>
|
|
@@ -20,8 +20,10 @@ const meta = {
|
|
|
20
20
|
<spectric-tooltip
|
|
21
21
|
position=${p}
|
|
22
22
|
text=${args.text || p}
|
|
23
|
-
delay=${args.delay}
|
|
23
|
+
delay=${ifDefined(args.delay)}
|
|
24
24
|
animationDuration=${ifDefined(args.animationDuration)}
|
|
25
|
+
mouseOffsetX=${ifDefined(args.mouseOffsetX)}
|
|
26
|
+
mouseOffsetY=${ifDefined(args.mouseOffsetY)}
|
|
25
27
|
>
|
|
26
28
|
</spectric-tooltip>
|
|
27
29
|
${p}
|
|
@@ -31,7 +33,12 @@ const meta = {
|
|
|
31
33
|
})}
|
|
32
34
|
`;
|
|
33
35
|
},
|
|
34
|
-
argTypes: {
|
|
36
|
+
argTypes: {
|
|
37
|
+
mouseOffsetX: { "control": { "type": "number" } },
|
|
38
|
+
mouseOffsetY: { "control": { "type": "number" } },
|
|
39
|
+
maxWidth: { "control": { "type": "number" } },
|
|
40
|
+
text: { "control": { "type": "text" } }
|
|
41
|
+
},
|
|
35
42
|
args: {
|
|
36
43
|
animationDuration: 500,
|
|
37
44
|
delay: 100
|