@oscarpalmer/oui 0.23.1 → 0.25.0
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/css/{tooltip.css → floatable.css} +59 -24
- package/dist/css/reset.css +17 -0
- package/dist/js/dialog.d.mts +38 -0
- package/dist/js/dialog.mjs +92 -0
- package/dist/js/embedded-84gxpReS.d.mts +64 -0
- package/dist/js/embedded-BpwzMSEF.d.mts +26 -0
- package/dist/js/floatable/embedded.d.mts +2 -0
- package/dist/js/floatable/embedded.mjs +146 -0
- package/dist/js/floatable/standalone.d.mts +2 -0
- package/dist/js/floatable/standalone.mjs +2 -0
- package/dist/js/focus-trap/embedded.d.mts +1 -25
- package/dist/js/focus-trap/embedded.mjs +1 -1
- package/dist/js/index.d.mts +5 -2
- package/dist/js/index.mjs +7 -4
- package/dist/js/internal/attributable.mjs +4 -3
- package/dist/js/internal/draggable.mjs +1 -1
- package/dist/js/popover.d.mts +38 -1
- package/dist/js/popover.mjs +81 -38
- package/dist/js/sortable.mjs +7 -5
- package/dist/js/splitter.mjs +18 -14
- package/dist/js/tooltip.d.mts +33 -1
- package/dist/js/tooltip.mjs +91 -48
- package/package.json +2 -2
- package/src/css/{tooltip.scss → floatable.scss} +47 -5
- package/src/css/mixins.scss +0 -2
- package/src/css/reset.scss +17 -0
- package/src/js/dialog.ts +188 -0
- package/src/js/floatable/embedded.ts +302 -0
- package/src/js/floatable/standalone.ts +1 -0
- package/src/js/index.ts +4 -2
- package/src/js/internal/attributable.ts +5 -3
- package/src/js/popover.ts +146 -48
- package/src/js/sortable.ts +8 -5
- package/src/js/splitter.ts +26 -9
- package/src/js/tooltip.ts +138 -51
- package/dist/css/popover.css +0 -30
- package/dist/js/internal/floatable.d.mts +0 -18
- package/dist/js/internal/floatable.mjs +0 -67
- package/src/css/popover.scss +0 -10
- package/src/js/internal/floatable.ts +0 -118
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//#region src/js/internal/floatable.d.ts
|
|
2
|
-
declare class Floatable {
|
|
3
|
-
anchor: HTMLElement;
|
|
4
|
-
content: HTMLElement;
|
|
5
|
-
options: FloatableOptions;
|
|
6
|
-
constructor(anchor: HTMLElement, content: HTMLElement, options: FloatableOptions);
|
|
7
|
-
destroy(): void;
|
|
8
|
-
update(): void;
|
|
9
|
-
}
|
|
10
|
-
type FloatableOptions = {
|
|
11
|
-
attribute: string;
|
|
12
|
-
position: FloatablePosition;
|
|
13
|
-
};
|
|
14
|
-
type FloatablePosition = 'above' | 'above-end' | 'above-start' | 'below' | 'below-end' | 'below-start' | 'end' | 'end-bottom' | 'end-top' | 'start' | 'start-bottom' | 'start-top';
|
|
15
|
-
declare function createFloatable(anchor: HTMLElement | null, content: HTMLElement, options: FloatableOptions): Floatable | undefined;
|
|
16
|
-
declare function removeFloatable(content: HTMLElement): void;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { Floatable, FloatableOptions, FloatablePosition, createFloatable, removeFloatable };
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
//#region src/js/internal/floatable.ts
|
|
2
|
-
var Floatable = class {
|
|
3
|
-
anchor;
|
|
4
|
-
content;
|
|
5
|
-
options;
|
|
6
|
-
constructor(anchor, content, options) {
|
|
7
|
-
this.anchor = anchor;
|
|
8
|
-
this.content = content;
|
|
9
|
-
this.options = options;
|
|
10
|
-
const anchorName = getAnchorName(anchor);
|
|
11
|
-
anchor.style.anchorName = anchorName;
|
|
12
|
-
content.style.positionAnchor = anchorName;
|
|
13
|
-
}
|
|
14
|
-
destroy() {
|
|
15
|
-
this.anchor = null;
|
|
16
|
-
this.content = null;
|
|
17
|
-
}
|
|
18
|
-
update() {
|
|
19
|
-
setPosition(this);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
function createFloatable(anchor, content, options) {
|
|
23
|
-
if (anchor == null) return;
|
|
24
|
-
let floatable = instances.get(content);
|
|
25
|
-
if (floatable == null) {
|
|
26
|
-
floatable = new Floatable(anchor, content, options);
|
|
27
|
-
instances.set(content, floatable);
|
|
28
|
-
}
|
|
29
|
-
return floatable;
|
|
30
|
-
}
|
|
31
|
-
function getAnchorName(anchor) {
|
|
32
|
-
let { anchorName } = anchor.style;
|
|
33
|
-
if (anchorName.length > 0) return anchorName;
|
|
34
|
-
index += 1;
|
|
35
|
-
return `--oui-floatable-anchor-${index}`;
|
|
36
|
-
}
|
|
37
|
-
function removeFloatable(content) {
|
|
38
|
-
instances.get(content)?.destroy();
|
|
39
|
-
instances.delete(content);
|
|
40
|
-
}
|
|
41
|
-
function setPosition(floatable) {
|
|
42
|
-
let position = floatable.anchor.getAttribute(floatable.options.attribute) ?? floatable.options.position;
|
|
43
|
-
if (AREAS[position] == null) position = floatable.options.position;
|
|
44
|
-
const area = AREAS[position];
|
|
45
|
-
floatable.content.style.positionArea = area;
|
|
46
|
-
floatable.content.setAttribute(ATTRIBUTE, POSITIONS[area]);
|
|
47
|
-
}
|
|
48
|
-
const AREAS = {
|
|
49
|
-
above: "block-start",
|
|
50
|
-
"above-end": "start span-start",
|
|
51
|
-
"above-start": "start span-end",
|
|
52
|
-
below: "block-end",
|
|
53
|
-
"below-end": "end span-start",
|
|
54
|
-
"below-start": "end span-end",
|
|
55
|
-
end: "center end",
|
|
56
|
-
"end-bottom": "span-start end",
|
|
57
|
-
"end-top": "span-end end",
|
|
58
|
-
start: "center start",
|
|
59
|
-
"start-bottom": "span-start start",
|
|
60
|
-
"start-top": "span-end start"
|
|
61
|
-
};
|
|
62
|
-
const ATTRIBUTE = "oui-position";
|
|
63
|
-
const POSITIONS = Object.fromEntries(Object.entries(AREAS).map(([position, area]) => [area, position]));
|
|
64
|
-
const instances = /* @__PURE__ */ new WeakMap();
|
|
65
|
-
let index = 0;
|
|
66
|
-
//#endregion
|
|
67
|
-
export { Floatable, createFloatable, removeFloatable };
|
package/src/css/popover.scss
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
export class Floatable {
|
|
2
|
-
constructor(
|
|
3
|
-
public anchor: HTMLElement,
|
|
4
|
-
public content: HTMLElement,
|
|
5
|
-
public options: FloatableOptions,
|
|
6
|
-
) {
|
|
7
|
-
const anchorName = getAnchorName(anchor);
|
|
8
|
-
|
|
9
|
-
anchor.style.anchorName = anchorName;
|
|
10
|
-
content.style.positionAnchor = anchorName;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
destroy(): void {
|
|
14
|
-
this.anchor = null as never;
|
|
15
|
-
this.content = null as never;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
update(): void {
|
|
19
|
-
setPosition(this);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type FloatableOptions = {
|
|
24
|
-
attribute: string;
|
|
25
|
-
position: FloatablePosition;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type FloatablePosition =
|
|
29
|
-
| 'above'
|
|
30
|
-
| 'above-end'
|
|
31
|
-
| 'above-start'
|
|
32
|
-
| 'below'
|
|
33
|
-
| 'below-end'
|
|
34
|
-
| 'below-start'
|
|
35
|
-
| 'end'
|
|
36
|
-
| 'end-bottom'
|
|
37
|
-
| 'end-top'
|
|
38
|
-
| 'start'
|
|
39
|
-
| 'start-bottom'
|
|
40
|
-
| 'start-top';
|
|
41
|
-
|
|
42
|
-
export function createFloatable(
|
|
43
|
-
anchor: HTMLElement | null,
|
|
44
|
-
content: HTMLElement,
|
|
45
|
-
options: FloatableOptions,
|
|
46
|
-
): Floatable | undefined {
|
|
47
|
-
if (anchor == null) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let floatable = instances.get(content);
|
|
52
|
-
|
|
53
|
-
if (floatable == null) {
|
|
54
|
-
floatable = new Floatable(anchor, content, options);
|
|
55
|
-
|
|
56
|
-
instances.set(content, floatable);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return floatable;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function getAnchorName(anchor: HTMLElement): string {
|
|
63
|
-
let {anchorName} = anchor.style;
|
|
64
|
-
|
|
65
|
-
if (anchorName.length > 0) {
|
|
66
|
-
return anchorName;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
index += 1;
|
|
70
|
-
|
|
71
|
-
return `--oui-floatable-anchor-${index}`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function removeFloatable(content: HTMLElement): void {
|
|
75
|
-
instances.get(content)?.destroy();
|
|
76
|
-
instances.delete(content);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function setPosition(floatable: Floatable): void {
|
|
80
|
-
let position: FloatablePosition =
|
|
81
|
-
(floatable.anchor.getAttribute(floatable.options.attribute) as FloatablePosition) ??
|
|
82
|
-
floatable.options.position;
|
|
83
|
-
|
|
84
|
-
if (AREAS[position] == null) {
|
|
85
|
-
position = floatable.options.position;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const area = AREAS[position];
|
|
89
|
-
|
|
90
|
-
floatable.content.style.positionArea = area;
|
|
91
|
-
|
|
92
|
-
floatable.content.setAttribute(ATTRIBUTE, POSITIONS[area]);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const AREAS: Record<FloatablePosition, string> = {
|
|
96
|
-
above: 'block-start',
|
|
97
|
-
'above-end': 'start span-start',
|
|
98
|
-
'above-start': 'start span-end',
|
|
99
|
-
below: 'block-end',
|
|
100
|
-
'below-end': 'end span-start',
|
|
101
|
-
'below-start': 'end span-end',
|
|
102
|
-
end: 'center end',
|
|
103
|
-
'end-bottom': 'span-start end',
|
|
104
|
-
'end-top': 'span-end end',
|
|
105
|
-
start: 'center start',
|
|
106
|
-
'start-bottom': 'span-start start',
|
|
107
|
-
'start-top': 'span-end start',
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const ATTRIBUTE = 'oui-position';
|
|
111
|
-
|
|
112
|
-
const POSITIONS = Object.fromEntries(
|
|
113
|
-
Object.entries(AREAS).map(([position, area]) => [area, position]),
|
|
114
|
-
) as Record<string, FloatablePosition>;
|
|
115
|
-
|
|
116
|
-
const instances = new WeakMap<HTMLElement, Floatable>();
|
|
117
|
-
|
|
118
|
-
let index = 0;
|