@spectric/ui 0.0.21 → 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.
- package/dist/components/dialog/dialog.d.ts +1 -0
- package/dist/components/pagination/pagination.d.ts +1 -1
- package/dist/components/query_bar/QueryBar.d.ts +30 -10
- package/dist/components/query_bar/dateTimePopup.d.ts +2 -0
- package/dist/components/query_bar/geojsonPopup.d.ts +2 -0
- package/dist/components/query_bar/querylanguage/kuery/functions/geospatial.d.ts +19 -0
- package/dist/components/query_bar/querylanguage/outputTypes/toCQL.d.ts +2 -1
- package/dist/components/query_bar/querylanguage/outputTypes/toMongo.d.ts +6 -1
- package/dist/components/symbols.d.ts +6 -0
- package/dist/components/table/cell.d.ts +1 -1
- package/dist/components/table/table.d.ts +5 -1
- package/dist/custom-elements.json +5 -5
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +4382 -2795
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +349 -248
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +6 -1
- package/src/components/dialog/dialog.css.ts +29 -29
- package/src/components/dialog/dialog.ts +3 -1
- package/src/components/input.ts +49 -39
- package/src/components/pagination/pagination.ts +167 -113
- package/src/components/query_bar/QueryBar.ts +438 -187
- package/src/components/query_bar/dateTimePopup.ts +54 -0
- package/src/components/query_bar/geojsonPopup.ts +44 -0
- package/src/components/query_bar/querylanguage/kuery/ast/_generated_/kuery.js +1836 -2745
- package/src/components/query_bar/querylanguage/kuery/ast/ast.ts +15 -13
- package/src/components/query_bar/querylanguage/kuery/ast/kuery.peg +92 -126
- package/src/components/query_bar/querylanguage/kuery/functions/geospatial.ts +25 -0
- package/src/components/query_bar/querylanguage/kuery/functions/index.ts +9 -7
- package/src/components/query_bar/querylanguage/outputTypes/toCQL.ts +56 -34
- package/src/components/query_bar/querylanguage/outputTypes/toMongo.ts +46 -34
- package/src/components/symbols.ts +6 -0
- package/src/components/table/__tests__/table.spec.ts +2 -2
- package/src/components/table/cell.ts +7 -3
- package/src/components/table/header.ts +3 -2
- package/src/components/table/table.css +4 -2
- package/src/components/table/table.ts +61 -5
- package/src/components/table/virtualBody.ts +8 -3
- package/src/components/tooltip/popover.ts +263 -225
- package/src/stories/Dialog.stories.ts +59 -0
- package/src/stories/QueryBar.stories.ts +46 -37
- package/src/stories/fixtures/data.ts +195 -36
- package/src/stories/table.stories.ts +70 -22
|
@@ -1,261 +1,299 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export const PopoverElementTag = "spectric-popover"
|
|
1
|
+
import { customElement, property, query } from "lit/decorators.js";
|
|
2
|
+
import "./tooltip.css";
|
|
3
|
+
export const PopoverElementTag = "spectric-popover";
|
|
5
4
|
import { css, CSSResultGroup, html } from "lit-element";
|
|
6
5
|
import { DomRenderable } from "../table";
|
|
7
|
-
import { DisposableElement } from
|
|
8
|
-
import {
|
|
9
|
-
|
|
6
|
+
import { DisposableElement } from "../../classes/DisposibleElement";
|
|
7
|
+
import {
|
|
8
|
+
HTMLElementTagWithEvents,
|
|
9
|
+
ReactElementWithPropsAndEvents,
|
|
10
|
+
} from "../types";
|
|
11
|
+
export type { TooltipProps, PopOverEvents };
|
|
10
12
|
export enum TooltipPostions {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
top = "top",
|
|
14
|
+
bottom = "bottom",
|
|
15
|
+
left = "left",
|
|
16
|
+
right = "right",
|
|
17
|
+
mouse = "mouse",
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
export type TooltipPostionsTypes = `${TooltipPostions}
|
|
20
|
+
export type TooltipPostionsTypes = `${TooltipPostions}`;
|
|
19
21
|
interface TooltipProps {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
22
|
+
/**
|
|
23
|
+
* How long you need to hover before the tooltip displays
|
|
24
|
+
*/
|
|
25
|
+
delay?: number;
|
|
26
|
+
/**
|
|
27
|
+
* How long the fade in animation should run
|
|
28
|
+
*/
|
|
29
|
+
animationDuration?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Tooltip contents
|
|
32
|
+
*/
|
|
33
|
+
text: DomRenderable;
|
|
34
|
+
/**
|
|
35
|
+
* Where to anchor the tooltip
|
|
36
|
+
*/
|
|
37
|
+
position?: TooltipPostionsTypes;
|
|
38
|
+
/**
|
|
39
|
+
* Sets a max width for the contents you can disable this by setting to 0 or -1
|
|
40
|
+
*/
|
|
41
|
+
maxWidth?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Container the tool tip will be attached to.
|
|
44
|
+
*/
|
|
45
|
+
portalTarget?: HTMLElement;
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
/**
|
|
48
|
+
* 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
|
|
49
|
+
*/
|
|
50
|
+
triggerTarget?: HTMLElement;
|
|
51
|
+
mouseOffsetX?: number;
|
|
52
|
+
mouseOffsetY?: number;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
/**
|
|
54
|
-
* Spectric tooltip will add a tooltip to any container
|
|
56
|
+
* Spectric tooltip will add a tooltip to any container
|
|
55
57
|
*/
|
|
56
58
|
@customElement(PopoverElementTag)
|
|
57
59
|
export class PopoverElement extends DisposableElement implements TooltipProps {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
protected timer?: number;
|
|
82
|
-
protected open: boolean = false;
|
|
83
|
-
protected mouseframe?: number;
|
|
84
|
-
isOpen() {
|
|
85
|
-
return this.open
|
|
60
|
+
@property({ type: Number, reflect: true })
|
|
61
|
+
delay: number = 100;
|
|
62
|
+
@property({ type: Number, reflect: true })
|
|
63
|
+
animationDuration: number = 0;
|
|
64
|
+
@property({ type: String, reflect: false })
|
|
65
|
+
text: DomRenderable = "";
|
|
66
|
+
@property({ type: String, reflect: true })
|
|
67
|
+
position: TooltipPostionsTypes = "right";
|
|
68
|
+
@property({ type: Number, reflect: true })
|
|
69
|
+
maxWidth?: number = 300;
|
|
70
|
+
@property({ type: Number, reflect: false })
|
|
71
|
+
mouseOffsetX = 10;
|
|
72
|
+
@property({ type: Number, reflect: false })
|
|
73
|
+
mouseOffsetY = 0;
|
|
74
|
+
@query(".spectric-popover-portal")
|
|
75
|
+
protected portalElement!: HTMLDivElement;
|
|
76
|
+
protected mouseLocation?: { left: number; top: number };
|
|
77
|
+
static styles?: CSSResultGroup | undefined = css`
|
|
78
|
+
:host {
|
|
79
|
+
max-height: 0px;
|
|
80
|
+
max-width: 0px;
|
|
81
|
+
display: none;
|
|
82
|
+
pointer-events: none;
|
|
86
83
|
}
|
|
84
|
+
`;
|
|
85
|
+
@property({ attribute: false })
|
|
86
|
+
portalTarget: HTMLElement = document.body;
|
|
87
|
+
protected timer?: number;
|
|
88
|
+
protected open: boolean = false;
|
|
89
|
+
protected mouseframe?: number;
|
|
90
|
+
isOpen() {
|
|
91
|
+
return this.open;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @default parentElement
|
|
95
|
+
*/
|
|
96
|
+
@property({ attribute: false })
|
|
97
|
+
triggerTarget!: HTMLElement;
|
|
98
|
+
protected get target() {
|
|
99
|
+
return this.triggerTarget || this.parentElement;
|
|
100
|
+
}
|
|
101
|
+
constructor() {
|
|
102
|
+
super();
|
|
87
103
|
/**
|
|
88
|
-
*
|
|
104
|
+
* Public method to trigger showing the tooltip programatically
|
|
89
105
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
106
|
+
this.showPopover = this.showPopover.bind(this);
|
|
107
|
+
this.hidePopover = this.hidePopover.bind(this);
|
|
108
|
+
this.addDisposableListener(
|
|
109
|
+
() => this.target,
|
|
110
|
+
"mousemove",
|
|
111
|
+
this._getMousePosition
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
protected createRenderRoot(): HTMLElement | DocumentFragment {
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
connectedCallback(): void {
|
|
118
|
+
super.connectedCallback();
|
|
119
|
+
//this.portalElement = document.createElement("div")
|
|
120
|
+
//this.portalElement.className = "spectric-tooltip-portal"
|
|
121
|
+
}
|
|
122
|
+
disconnectedCallback(): void {
|
|
123
|
+
super.disconnectedCallback();
|
|
124
|
+
//this.portalElement.remove()
|
|
125
|
+
//@ts-ignore
|
|
126
|
+
//this.portalElement = undefined
|
|
127
|
+
}
|
|
128
|
+
protected _getMousePosition = (ev: MouseEvent) => {
|
|
129
|
+
this.mouseLocation = {
|
|
130
|
+
left: ev.clientX,
|
|
131
|
+
top: ev.clientY,
|
|
132
|
+
};
|
|
133
|
+
if (this.position == "mouse" && this.open && !this.mouseframe) {
|
|
134
|
+
this.mouseframe = requestAnimationFrame(() => this.positionTooltip());
|
|
94
135
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.addDisposableListener(() => this.target, "mousemove", this._getMousePosition)
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Public method to trigger hide the tooltip programatically
|
|
139
|
+
*/
|
|
140
|
+
public hidePopover() {
|
|
141
|
+
if (this.timer) {
|
|
142
|
+
clearTimeout(this.timer);
|
|
103
143
|
}
|
|
104
|
-
|
|
105
|
-
|
|
144
|
+
this.open = false;
|
|
145
|
+
this.portalElement.hidePopover();
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Public method to trigger showing the tooltip programatically
|
|
149
|
+
*/
|
|
150
|
+
public async showPopover() {
|
|
151
|
+
if (this.timer) {
|
|
152
|
+
clearTimeout(this.timer);
|
|
106
153
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
154
|
+
await new Promise((resolve) => {
|
|
155
|
+
this.timer = window.setTimeout(resolve, this.delay);
|
|
156
|
+
});
|
|
157
|
+
// this.portalElement.className = `spectric-popover-portal ${this.position}`
|
|
158
|
+
// const tooltip = html`<div class="tooltip-container">
|
|
159
|
+
// <span class="tooltip-caret"></span>
|
|
160
|
+
// <div class="tooltip-content">${this.text}</div>
|
|
161
|
+
// </div>`
|
|
162
|
+
// render(tooltip, this.portalElement)
|
|
163
|
+
// //with the delay it is possible that the triggering element was removed or hidden lets check that it is visible
|
|
164
|
+
// if (!this.target || !this.target.checkVisibility()) {
|
|
165
|
+
// return
|
|
166
|
+
// }
|
|
167
|
+
// //We need to append our tooltip and let the css updates apply before we can take measurements
|
|
168
|
+
// this.portalTarget.appendChild(this.portalElement)
|
|
169
|
+
if (!this.isConnected) {
|
|
170
|
+
return;
|
|
111
171
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
172
|
+
this.portalElement.showPopover();
|
|
173
|
+
this.open = true;
|
|
174
|
+
requestAnimationFrame(this.positionTooltip);
|
|
175
|
+
}
|
|
176
|
+
protected applyStyle = (style: Record<string, string>) => {
|
|
177
|
+
Object.entries(style).forEach(([prop, value]) => {
|
|
178
|
+
this.portalElement.style.setProperty(prop, value);
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
protected positionTooltip = () => {
|
|
182
|
+
if (!this.target) {
|
|
183
|
+
//We got detached before the animation frame completed
|
|
184
|
+
return;
|
|
117
185
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Public method to trigger hide the tooltip programatically
|
|
129
|
-
*/
|
|
130
|
-
public hidePopover() {
|
|
131
|
-
if (this.timer) {
|
|
132
|
-
clearTimeout(this.timer)
|
|
133
|
-
}
|
|
134
|
-
this.open = false
|
|
135
|
-
this.portalElement.hidePopover()
|
|
186
|
+
//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
|
|
187
|
+
|
|
188
|
+
let styles: Record<string, string> = {};
|
|
189
|
+
const bounds = this.target.getBoundingClientRect();
|
|
190
|
+
const portalBounds = this.portalElement.getBoundingClientRect();
|
|
191
|
+
if (this.target !== document.body) {
|
|
192
|
+
if (this.maxWidth && this.maxWidth > 0) {
|
|
193
|
+
portalBounds.width = Math.min(portalBounds.width, this.maxWidth);
|
|
194
|
+
}
|
|
136
195
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
196
|
+
let location: {
|
|
197
|
+
left: string;
|
|
198
|
+
top: string;
|
|
199
|
+
};
|
|
200
|
+
if (this.position === "mouse" && this.mouseLocation) {
|
|
201
|
+
this.mouseframe = undefined;
|
|
202
|
+
location = {
|
|
203
|
+
left: this.mouseLocation.left + this.mouseOffsetX + "px",
|
|
204
|
+
top:
|
|
205
|
+
this.mouseLocation.top +
|
|
206
|
+
this.mouseOffsetY -
|
|
207
|
+
portalBounds.height / 2 +
|
|
208
|
+
"px",
|
|
209
|
+
};
|
|
210
|
+
} else if (this.position === "top") {
|
|
211
|
+
location = {
|
|
212
|
+
top: bounds.top - portalBounds.height + "px",
|
|
213
|
+
left: bounds.left + bounds.width / 2 - portalBounds.width / 2 + "px",
|
|
214
|
+
};
|
|
215
|
+
} else if (this.position === "bottom") {
|
|
216
|
+
location = {
|
|
217
|
+
top: bounds.bottom + "px",
|
|
218
|
+
left: bounds.left + bounds.width / 2 - portalBounds.width / 2 + "px",
|
|
219
|
+
};
|
|
220
|
+
} else if (this.position === "left") {
|
|
221
|
+
location = {
|
|
222
|
+
top:
|
|
223
|
+
Math.max(
|
|
224
|
+
0,
|
|
225
|
+
bounds.top + bounds.height / 2 - portalBounds.height / 2
|
|
226
|
+
) + "px",
|
|
227
|
+
left: bounds.left - portalBounds.width + "px",
|
|
228
|
+
};
|
|
229
|
+
} else if (this.position === "right") {
|
|
230
|
+
location = {
|
|
231
|
+
top:
|
|
232
|
+
Math.max(
|
|
233
|
+
0,
|
|
234
|
+
bounds.top + bounds.height / 2 - portalBounds.height / 2
|
|
235
|
+
) + "px",
|
|
236
|
+
left: bounds.right + "px",
|
|
237
|
+
};
|
|
238
|
+
} else {
|
|
239
|
+
location = { left: "0px", top: "0px" };
|
|
240
|
+
console.error("Unknown position... Maybe we sould implement auto?");
|
|
162
241
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
242
|
+
this.applyStyle({ ...styles, ...location });
|
|
243
|
+
if (this.position !== "mouse") {
|
|
244
|
+
this.portalElement.animate(
|
|
245
|
+
{ opacity: [0, 1] },
|
|
246
|
+
{ duration: this.animationDuration }
|
|
247
|
+
);
|
|
167
248
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
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
|
|
174
|
-
|
|
175
|
-
let styles: Record<string, string> = {
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
const bounds = this.target.getBoundingClientRect()
|
|
179
|
-
const portalBounds = this.portalElement.getBoundingClientRect()
|
|
180
|
-
if (this.target !== document.body) {
|
|
181
|
-
if (this.maxWidth && this.maxWidth > 0) {
|
|
182
|
-
portalBounds.width = Math.min(portalBounds.width, this.maxWidth)
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
let location: {
|
|
186
|
-
left: string;
|
|
187
|
-
top: string;
|
|
188
|
-
};
|
|
189
|
-
if (this.position === "mouse" && this.mouseLocation) {
|
|
190
|
-
this.mouseframe = undefined
|
|
191
|
-
location = { left: this.mouseLocation.left + this.mouseOffsetX + "px", top: this.mouseLocation.top + this.mouseOffsetY - (portalBounds.height / 2) + "px" }
|
|
192
|
-
} else if (this.position === "top") {
|
|
193
|
-
location = {
|
|
194
|
-
top: bounds.top - portalBounds.height + "px",
|
|
195
|
-
left: (bounds.left + (bounds.width / 2)) - (portalBounds.width / 2) + "px"
|
|
196
|
-
}
|
|
197
|
-
} else if (this.position === "bottom") {
|
|
198
|
-
location = {
|
|
199
|
-
top: bounds.bottom + "px",
|
|
200
|
-
left: (bounds.left + (bounds.width / 2)) - (portalBounds.width / 2) + "px"
|
|
201
|
-
}
|
|
202
|
-
} else if (this.position === "left") {
|
|
203
|
-
location = {
|
|
204
|
-
top: Math.max(0, bounds.top + bounds.height / 2 - portalBounds.height / 2) + "px",
|
|
205
|
-
left: bounds.left - (portalBounds.width) + "px"
|
|
206
|
-
}
|
|
207
|
-
} else if (this.position === "right") {
|
|
208
|
-
location = {
|
|
209
|
-
top: Math.max(0, bounds.top + bounds.height / 2 - portalBounds.height / 2) + "px",
|
|
210
|
-
left: bounds.right + "px"
|
|
211
|
-
}
|
|
212
|
-
} else {
|
|
213
|
-
location = { left: "0px", top: "0px" };
|
|
214
|
-
console.error("Unknown position... Maybe we sould implement auto?")
|
|
215
|
-
}
|
|
216
|
-
this.applyStyle({ ...styles, ...location })
|
|
217
|
-
if (this.position !== "mouse") {
|
|
218
|
-
this.portalElement.animate({ opacity: [0, 1] }, { duration: this.animationDuration })
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
protected render() {
|
|
222
|
-
return html`<!-- ToolTip -->
|
|
223
|
-
<div class="spectric-popover-portal ${this.position}" popover>
|
|
249
|
+
};
|
|
250
|
+
protected render() {
|
|
251
|
+
return html`<!-- ToolTip -->
|
|
252
|
+
<div class="spectric-popover-portal ${this.position}" popover>
|
|
224
253
|
<div class="tooltip-container">
|
|
225
|
-
|
|
226
|
-
|
|
254
|
+
<span class="tooltip-caret"></span>
|
|
255
|
+
<div class="tooltip-content">${this.text}<slot></slot></div>
|
|
227
256
|
</div>
|
|
228
|
-
|
|
229
|
-
|
|
257
|
+
</div>`;
|
|
258
|
+
}
|
|
230
259
|
}
|
|
231
260
|
|
|
232
261
|
interface PopOverEvents {
|
|
233
|
-
|
|
234
|
-
|
|
262
|
+
//'open': (event: CustomEvent<{ pagination: PaginationChangeProps }>) => void;
|
|
263
|
+
//'filter': (event: CustomEvent<FilterEvent>) => void;
|
|
235
264
|
}
|
|
236
265
|
|
|
237
|
-
|
|
238
266
|
declare global {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
267
|
+
interface HTMLElementTagNameMap {
|
|
268
|
+
[PopoverElementTag]: HTMLElementTagWithEvents<
|
|
269
|
+
PopoverElement,
|
|
270
|
+
PopOverEvents
|
|
271
|
+
>;
|
|
272
|
+
}
|
|
273
|
+
namespace JSX {
|
|
274
|
+
interface IntrinsicElements {
|
|
275
|
+
/**
|
|
276
|
+
* @see {@link TooltipElement}
|
|
277
|
+
*/
|
|
278
|
+
[PopoverElementTag]: ReactElementWithPropsAndEvents<
|
|
279
|
+
PopoverElement,
|
|
280
|
+
TooltipProps,
|
|
281
|
+
PopOverEvents
|
|
282
|
+
>;
|
|
242
283
|
}
|
|
284
|
+
}
|
|
285
|
+
namespace React {
|
|
243
286
|
namespace JSX {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* @see {@link TooltipElement}
|
|
256
|
-
*/
|
|
257
|
-
[PopoverElementTag]: ReactElementWithPropsAndEvents<PopoverElement, TooltipProps, PopOverEvents>
|
|
258
|
-
}
|
|
259
|
-
}
|
|
287
|
+
interface IntrinsicElements {
|
|
288
|
+
/**
|
|
289
|
+
* @see {@link TooltipElement}
|
|
290
|
+
*/
|
|
291
|
+
[PopoverElementTag]: ReactElementWithPropsAndEvents<
|
|
292
|
+
PopoverElement,
|
|
293
|
+
TooltipProps,
|
|
294
|
+
PopOverEvents
|
|
295
|
+
>;
|
|
296
|
+
}
|
|
260
297
|
}
|
|
298
|
+
}
|
|
261
299
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/web-components";
|
|
2
|
+
import { useArgs } from "@storybook/client-api";
|
|
3
|
+
import { type Props } from "../components/dialog";
|
|
4
|
+
import "../components/dialog";
|
|
5
|
+
import { html } from "lit";
|
|
6
|
+
import "./fixtures/ExampleContent";
|
|
7
|
+
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "UI/Dialog",
|
|
10
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
11
|
+
tags: ["autodocs"],
|
|
12
|
+
component: "spectric-dialog",
|
|
13
|
+
render: () => {
|
|
14
|
+
const [args, updateArgs] = useArgs();
|
|
15
|
+
console.log(args);
|
|
16
|
+
return html`
|
|
17
|
+
<spectric-dialog
|
|
18
|
+
@close=${() => updateArgs({ open: false })}
|
|
19
|
+
?open=${args.open}
|
|
20
|
+
?closeOnEscape=${args.closeOnEscape}
|
|
21
|
+
?closeOnOutsideClick=${args.closeOnOutsideClick}
|
|
22
|
+
?hideBackdrop=${args.hideBackdrop}
|
|
23
|
+
?dismissable=${args.dismissable}
|
|
24
|
+
title=${args.title || ""}
|
|
25
|
+
>
|
|
26
|
+
<div>
|
|
27
|
+
This is my content
|
|
28
|
+
<lorum-ipsum style="width:400px;display:block"></lorum-ipsum>
|
|
29
|
+
</div>
|
|
30
|
+
${args.footer && args.footer != ""
|
|
31
|
+
? html` <div slot="footer">${html`${unsafeHTML(args.footer)}`}</div> `
|
|
32
|
+
: null}
|
|
33
|
+
</spectric-dialog>
|
|
34
|
+
`;
|
|
35
|
+
},
|
|
36
|
+
args: {
|
|
37
|
+
closeOnEscape: false,
|
|
38
|
+
closeOnOutsideClick: false,
|
|
39
|
+
dismissable: true,
|
|
40
|
+
hideBackdrop: false,
|
|
41
|
+
open: true,
|
|
42
|
+
title: "Basic Dialog",
|
|
43
|
+
footer: "<spectric-button>hello</spectric-button>",
|
|
44
|
+
},
|
|
45
|
+
argTypes: {
|
|
46
|
+
closeOnEscape: { control: { type: "boolean" } },
|
|
47
|
+
closeOnOutsideClick: { control: { type: "boolean" } },
|
|
48
|
+
dismissable: { control: { type: "boolean" } },
|
|
49
|
+
hideBackdrop: { control: { type: "boolean" } },
|
|
50
|
+
open: { control: { type: "boolean" } },
|
|
51
|
+
title: { control: { type: "text" } },
|
|
52
|
+
footer: { control: { type: "text" } },
|
|
53
|
+
},
|
|
54
|
+
} satisfies Meta<Props>;
|
|
55
|
+
|
|
56
|
+
export default meta;
|
|
57
|
+
type Story = StoryObj<Props>;
|
|
58
|
+
|
|
59
|
+
export const Default: Story = {};
|