@sentropic/design-system-vue 0.9.0 → 0.11.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/ForceGraph.d.ts +104 -0
- package/dist/ForceGraph.d.ts.map +1 -1
- package/dist/ForceGraph.js +193 -4
- package/dist/ForceGraph.js.map +1 -1
- package/dist/Popper.d.ts +170 -0
- package/dist/Popper.d.ts.map +1 -0
- package/dist/Popper.js +216 -0
- package/dist/Popper.js.map +1 -0
- package/dist/Portal.d.ts +51 -0
- package/dist/Portal.d.ts.map +1 -0
- package/dist/Portal.js +26 -0
- package/dist/Portal.js.map +1 -0
- package/dist/SelectableList.d.ts +98 -0
- package/dist/SelectableList.d.ts.map +1 -0
- package/dist/SelectableList.js +174 -0
- package/dist/SelectableList.js.map +1 -0
- package/dist/SelectableRow.d.ts +140 -0
- package/dist/SelectableRow.d.ts.map +1 -0
- package/dist/SelectableRow.js +130 -0
- package/dist/SelectableRow.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/styles.css +172 -0
- package/package.json +1 -1
package/dist/Popper.d.ts
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { type PropType } from "vue";
|
|
2
|
+
export type PopperStrategy = "absolute" | "fixed";
|
|
3
|
+
export type PopperPlacement = "top" | "bottom" | "left" | "right" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end" | "right-start" | "right-end";
|
|
4
|
+
export type PopperSide = "top" | "bottom" | "left" | "right";
|
|
5
|
+
export type PopperAlign = "start" | "center" | "end";
|
|
6
|
+
export type PopperProps = {
|
|
7
|
+
/** Reference element the panel is positioned against. */
|
|
8
|
+
anchor: HTMLElement | null;
|
|
9
|
+
/** Controlled open state. When false (or no anchor) nothing renders. */
|
|
10
|
+
open?: boolean;
|
|
11
|
+
/** Wanted placement of the panel relative to the anchor. */
|
|
12
|
+
placement?: PopperPlacement;
|
|
13
|
+
/** Main-axis distance (px) between the anchor and the panel. */
|
|
14
|
+
offset?: number;
|
|
15
|
+
/** Flip to the opposite side when the panel would overflow the viewport. */
|
|
16
|
+
flip?: boolean;
|
|
17
|
+
/** Shift along the cross axis to keep the panel within the viewport. */
|
|
18
|
+
shift?: boolean;
|
|
19
|
+
/** Expose a positioned arrow element. */
|
|
20
|
+
arrow?: boolean;
|
|
21
|
+
/** CSS positioning strategy. */
|
|
22
|
+
strategy?: PopperStrategy;
|
|
23
|
+
/** Render the panel into `document.body` via a Teleport. */
|
|
24
|
+
portal?: boolean;
|
|
25
|
+
/** Optional class applied to the floating panel. */
|
|
26
|
+
class?: string;
|
|
27
|
+
};
|
|
28
|
+
/** Split a placement into its side and (optional) alignment. */
|
|
29
|
+
export declare function splitPlacement(placement: PopperPlacement): {
|
|
30
|
+
side: PopperSide;
|
|
31
|
+
align: PopperAlign;
|
|
32
|
+
};
|
|
33
|
+
/** Recompose a side + alignment into a placement string. */
|
|
34
|
+
export declare function joinPlacement(side: PopperSide, align: PopperAlign): PopperPlacement;
|
|
35
|
+
export type Rect = {
|
|
36
|
+
top: number;
|
|
37
|
+
left: number;
|
|
38
|
+
right: number;
|
|
39
|
+
bottom: number;
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Pure geometry: compute the panel coordinates (in the chosen strategy's
|
|
45
|
+
* coordinate space) given the anchor rect, the panel size, and options.
|
|
46
|
+
* Returns the resolved placement (after flip) and the top/left coordinates,
|
|
47
|
+
* plus the arrow offset along the main edge.
|
|
48
|
+
*
|
|
49
|
+
* Coordinates are viewport-relative; callers add scroll offsets for the
|
|
50
|
+
* `absolute` strategy. No DOM access here — safe to unit test.
|
|
51
|
+
*/
|
|
52
|
+
export declare function computePosition(anchorRect: Rect, panelWidth: number, panelHeight: number, options: {
|
|
53
|
+
placement: PopperPlacement;
|
|
54
|
+
offset: number;
|
|
55
|
+
flip: boolean;
|
|
56
|
+
shift: boolean;
|
|
57
|
+
viewportWidth: number;
|
|
58
|
+
viewportHeight: number;
|
|
59
|
+
}): {
|
|
60
|
+
placement: PopperPlacement;
|
|
61
|
+
top: number;
|
|
62
|
+
left: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Float a panel next to an anchor element. Positioning is recomputed on open,
|
|
66
|
+
* scroll, and resize via `computePosition` (pure geometry shared across
|
|
67
|
+
* frameworks). Renders nothing unless `open` and an `anchor` are provided.
|
|
68
|
+
* SSR-safe: all DOM access happens inside `onMounted` / watchers.
|
|
69
|
+
*/
|
|
70
|
+
export declare const Popper: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
71
|
+
anchor: {
|
|
72
|
+
type: PropType<HTMLElement | null>;
|
|
73
|
+
default: null;
|
|
74
|
+
};
|
|
75
|
+
open: {
|
|
76
|
+
type: BooleanConstructor;
|
|
77
|
+
default: boolean;
|
|
78
|
+
};
|
|
79
|
+
placement: {
|
|
80
|
+
type: PropType<PopperPlacement>;
|
|
81
|
+
default: string;
|
|
82
|
+
};
|
|
83
|
+
offset: {
|
|
84
|
+
type: NumberConstructor;
|
|
85
|
+
default: number;
|
|
86
|
+
};
|
|
87
|
+
flip: {
|
|
88
|
+
type: BooleanConstructor;
|
|
89
|
+
default: boolean;
|
|
90
|
+
};
|
|
91
|
+
shift: {
|
|
92
|
+
type: BooleanConstructor;
|
|
93
|
+
default: boolean;
|
|
94
|
+
};
|
|
95
|
+
arrow: {
|
|
96
|
+
type: BooleanConstructor;
|
|
97
|
+
default: boolean;
|
|
98
|
+
};
|
|
99
|
+
strategy: {
|
|
100
|
+
type: PropType<PopperStrategy>;
|
|
101
|
+
default: string;
|
|
102
|
+
};
|
|
103
|
+
portal: {
|
|
104
|
+
type: BooleanConstructor;
|
|
105
|
+
default: boolean;
|
|
106
|
+
};
|
|
107
|
+
class: {
|
|
108
|
+
type: StringConstructor;
|
|
109
|
+
default: undefined;
|
|
110
|
+
};
|
|
111
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
112
|
+
[key: string]: any;
|
|
113
|
+
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
114
|
+
placementChange: (_placement: PopperPlacement) => true;
|
|
115
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
116
|
+
anchor: {
|
|
117
|
+
type: PropType<HTMLElement | null>;
|
|
118
|
+
default: null;
|
|
119
|
+
};
|
|
120
|
+
open: {
|
|
121
|
+
type: BooleanConstructor;
|
|
122
|
+
default: boolean;
|
|
123
|
+
};
|
|
124
|
+
placement: {
|
|
125
|
+
type: PropType<PopperPlacement>;
|
|
126
|
+
default: string;
|
|
127
|
+
};
|
|
128
|
+
offset: {
|
|
129
|
+
type: NumberConstructor;
|
|
130
|
+
default: number;
|
|
131
|
+
};
|
|
132
|
+
flip: {
|
|
133
|
+
type: BooleanConstructor;
|
|
134
|
+
default: boolean;
|
|
135
|
+
};
|
|
136
|
+
shift: {
|
|
137
|
+
type: BooleanConstructor;
|
|
138
|
+
default: boolean;
|
|
139
|
+
};
|
|
140
|
+
arrow: {
|
|
141
|
+
type: BooleanConstructor;
|
|
142
|
+
default: boolean;
|
|
143
|
+
};
|
|
144
|
+
strategy: {
|
|
145
|
+
type: PropType<PopperStrategy>;
|
|
146
|
+
default: string;
|
|
147
|
+
};
|
|
148
|
+
portal: {
|
|
149
|
+
type: BooleanConstructor;
|
|
150
|
+
default: boolean;
|
|
151
|
+
};
|
|
152
|
+
class: {
|
|
153
|
+
type: StringConstructor;
|
|
154
|
+
default: undefined;
|
|
155
|
+
};
|
|
156
|
+
}>> & Readonly<{
|
|
157
|
+
onPlacementChange?: ((_placement: PopperPlacement) => any) | undefined;
|
|
158
|
+
}>, {
|
|
159
|
+
open: boolean;
|
|
160
|
+
class: string;
|
|
161
|
+
shift: boolean;
|
|
162
|
+
offset: number;
|
|
163
|
+
flip: boolean;
|
|
164
|
+
anchor: HTMLElement | null;
|
|
165
|
+
placement: PopperPlacement;
|
|
166
|
+
arrow: boolean;
|
|
167
|
+
strategy: PopperStrategy;
|
|
168
|
+
portal: boolean;
|
|
169
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
170
|
+
//# sourceMappingURL=Popper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popper.d.ts","sourceRoot":"","sources":["../src/Popper.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,QAAQ,EACd,MAAM,KAAK,CAAC;AAGb,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,OAAO,CAAC;AAElD,MAAM,MAAM,eAAe,GACvB,KAAK,GACL,QAAQ,GACR,MAAM,GACN,OAAO,GACP,WAAW,GACX,SAAS,GACT,cAAc,GACd,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,aAAa,GACb,WAAW,CAAC;AAEhB,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAC7D,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAErD,MAAM,MAAM,WAAW,GAAG;IACxB,yDAAyD;IACzD,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,wEAAwE;IACxE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4DAA4D;IAC5D,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,wEAAwE;IACxE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yCAAyC;IACzC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,4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IAAI,CAAC;;;;;;;;cAIjB,QAAQ,CAAC,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;cAK1B,QAAQ,CAAC,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;4EAqItD,CAAC"}
|
package/dist/Popper.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { defineComponent, h, onBeforeUnmount, onMounted, ref, watch, Teleport, } from "vue";
|
|
2
|
+
import { classNames } from "./classNames.js";
|
|
3
|
+
/** Split a placement into its side and (optional) alignment. */
|
|
4
|
+
export function splitPlacement(placement) {
|
|
5
|
+
const [side, align] = placement.split("-");
|
|
6
|
+
return { side, align: align ?? "center" };
|
|
7
|
+
}
|
|
8
|
+
/** Recompose a side + alignment into a placement string. */
|
|
9
|
+
export function joinPlacement(side, align) {
|
|
10
|
+
return (align === "center" ? side : `${side}-${align}`);
|
|
11
|
+
}
|
|
12
|
+
const OPPOSITE = {
|
|
13
|
+
top: "bottom",
|
|
14
|
+
bottom: "top",
|
|
15
|
+
left: "right",
|
|
16
|
+
right: "left",
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Pure geometry: compute the panel coordinates (in the chosen strategy's
|
|
20
|
+
* coordinate space) given the anchor rect, the panel size, and options.
|
|
21
|
+
* Returns the resolved placement (after flip) and the top/left coordinates,
|
|
22
|
+
* plus the arrow offset along the main edge.
|
|
23
|
+
*
|
|
24
|
+
* Coordinates are viewport-relative; callers add scroll offsets for the
|
|
25
|
+
* `absolute` strategy. No DOM access here — safe to unit test.
|
|
26
|
+
*/
|
|
27
|
+
export function computePosition(anchorRect, panelWidth, panelHeight, options) {
|
|
28
|
+
const { offset, flip, shift, viewportWidth, viewportHeight } = options;
|
|
29
|
+
let { side, align } = splitPlacement(options.placement);
|
|
30
|
+
const place = (s, a) => {
|
|
31
|
+
let top = 0;
|
|
32
|
+
let left = 0;
|
|
33
|
+
if (s === "top" || s === "bottom") {
|
|
34
|
+
top = s === "top" ? anchorRect.top - panelHeight - offset : anchorRect.bottom + offset;
|
|
35
|
+
if (a === "start")
|
|
36
|
+
left = anchorRect.left;
|
|
37
|
+
else if (a === "end")
|
|
38
|
+
left = anchorRect.right - panelWidth;
|
|
39
|
+
else
|
|
40
|
+
left = anchorRect.left + anchorRect.width / 2 - panelWidth / 2;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
left = s === "left" ? anchorRect.left - panelWidth - offset : anchorRect.right + offset;
|
|
44
|
+
if (a === "start")
|
|
45
|
+
top = anchorRect.top;
|
|
46
|
+
else if (a === "end")
|
|
47
|
+
top = anchorRect.bottom - panelHeight;
|
|
48
|
+
else
|
|
49
|
+
top = anchorRect.top + anchorRect.height / 2 - panelHeight / 2;
|
|
50
|
+
}
|
|
51
|
+
return { top, left };
|
|
52
|
+
};
|
|
53
|
+
// Flip: if the panel overflows on the chosen side, try the opposite side.
|
|
54
|
+
if (flip) {
|
|
55
|
+
const candidate = place(side, align);
|
|
56
|
+
const overflows = (side === "top" && candidate.top < 0) ||
|
|
57
|
+
(side === "bottom" && candidate.top + panelHeight > viewportHeight) ||
|
|
58
|
+
(side === "left" && candidate.left < 0) ||
|
|
59
|
+
(side === "right" && candidate.left + panelWidth > viewportWidth);
|
|
60
|
+
if (overflows) {
|
|
61
|
+
const flipped = OPPOSITE[side];
|
|
62
|
+
const flippedPos = place(flipped, align);
|
|
63
|
+
const flippedOverflows = (flipped === "top" && flippedPos.top < 0) ||
|
|
64
|
+
(flipped === "bottom" && flippedPos.top + panelHeight > viewportHeight) ||
|
|
65
|
+
(flipped === "left" && flippedPos.left < 0) ||
|
|
66
|
+
(flipped === "right" && flippedPos.left + panelWidth > viewportWidth);
|
|
67
|
+
// Only flip if the opposite side fits better.
|
|
68
|
+
if (!flippedOverflows)
|
|
69
|
+
side = flipped;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
let { top, left } = place(side, align);
|
|
73
|
+
// Shift: clamp along the cross axis so the panel stays in the viewport.
|
|
74
|
+
if (shift) {
|
|
75
|
+
if (side === "top" || side === "bottom") {
|
|
76
|
+
const max = Math.max(0, viewportWidth - panelWidth);
|
|
77
|
+
left = Math.min(Math.max(0, left), max);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const max = Math.max(0, viewportHeight - panelHeight);
|
|
81
|
+
top = Math.min(Math.max(0, top), max);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { placement: joinPlacement(side, align), top, left };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Float a panel next to an anchor element. Positioning is recomputed on open,
|
|
88
|
+
* scroll, and resize via `computePosition` (pure geometry shared across
|
|
89
|
+
* frameworks). Renders nothing unless `open` and an `anchor` are provided.
|
|
90
|
+
* SSR-safe: all DOM access happens inside `onMounted` / watchers.
|
|
91
|
+
*/
|
|
92
|
+
export const Popper = defineComponent({
|
|
93
|
+
name: "Popper",
|
|
94
|
+
props: {
|
|
95
|
+
anchor: {
|
|
96
|
+
type: Object,
|
|
97
|
+
default: null,
|
|
98
|
+
},
|
|
99
|
+
open: { type: Boolean, default: false },
|
|
100
|
+
placement: { type: String, default: "bottom" },
|
|
101
|
+
offset: { type: Number, default: 8 },
|
|
102
|
+
flip: { type: Boolean, default: true },
|
|
103
|
+
shift: { type: Boolean, default: true },
|
|
104
|
+
arrow: { type: Boolean, default: false },
|
|
105
|
+
strategy: { type: String, default: "absolute" },
|
|
106
|
+
portal: { type: Boolean, default: true },
|
|
107
|
+
class: { type: String, default: undefined },
|
|
108
|
+
},
|
|
109
|
+
emits: {
|
|
110
|
+
placementChange: (_placement) => true,
|
|
111
|
+
},
|
|
112
|
+
setup(props, { emit, slots }) {
|
|
113
|
+
const panel = ref(null);
|
|
114
|
+
const top = ref(0);
|
|
115
|
+
const left = ref(0);
|
|
116
|
+
// Placement actually applied (may differ from the requested `placement`
|
|
117
|
+
// after a flip). Defaults to the requested placement.
|
|
118
|
+
const resolvedPlacement = ref(props.placement);
|
|
119
|
+
function reposition() {
|
|
120
|
+
if (typeof window === "undefined")
|
|
121
|
+
return;
|
|
122
|
+
if (!props.open || !props.anchor || !panel.value)
|
|
123
|
+
return;
|
|
124
|
+
const anchorRect = props.anchor.getBoundingClientRect();
|
|
125
|
+
const panelRect = panel.value.getBoundingClientRect();
|
|
126
|
+
const result = computePosition({
|
|
127
|
+
top: anchorRect.top,
|
|
128
|
+
left: anchorRect.left,
|
|
129
|
+
right: anchorRect.right,
|
|
130
|
+
bottom: anchorRect.bottom,
|
|
131
|
+
width: anchorRect.width,
|
|
132
|
+
height: anchorRect.height,
|
|
133
|
+
}, panelRect.width, panelRect.height, {
|
|
134
|
+
placement: props.placement,
|
|
135
|
+
offset: props.offset,
|
|
136
|
+
flip: props.flip,
|
|
137
|
+
shift: props.shift,
|
|
138
|
+
viewportWidth: window.innerWidth,
|
|
139
|
+
viewportHeight: window.innerHeight,
|
|
140
|
+
});
|
|
141
|
+
// `absolute` is positioned relative to the document, so add scroll
|
|
142
|
+
// offsets. `fixed` is viewport-relative, so coordinates are used as-is.
|
|
143
|
+
if (props.strategy === "absolute") {
|
|
144
|
+
top.value = result.top + window.scrollY;
|
|
145
|
+
left.value = result.left + window.scrollX;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
top.value = result.top;
|
|
149
|
+
left.value = result.left;
|
|
150
|
+
}
|
|
151
|
+
if (result.placement !== resolvedPlacement.value) {
|
|
152
|
+
resolvedPlacement.value = result.placement;
|
|
153
|
+
emit("placementChange", result.placement);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const onScroll = () => reposition();
|
|
157
|
+
const onResize = () => reposition();
|
|
158
|
+
let listening = false;
|
|
159
|
+
function start() {
|
|
160
|
+
if (typeof window === "undefined")
|
|
161
|
+
return;
|
|
162
|
+
if (!props.open || !props.anchor)
|
|
163
|
+
return;
|
|
164
|
+
// Reset to the requested placement before recomputing so a re-open
|
|
165
|
+
// re-evaluates flips from scratch.
|
|
166
|
+
resolvedPlacement.value = props.placement;
|
|
167
|
+
reposition();
|
|
168
|
+
if (!listening) {
|
|
169
|
+
window.addEventListener("scroll", onScroll, true);
|
|
170
|
+
window.addEventListener("resize", onResize);
|
|
171
|
+
listening = true;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function stop() {
|
|
175
|
+
if (typeof window === "undefined")
|
|
176
|
+
return;
|
|
177
|
+
if (listening) {
|
|
178
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
179
|
+
window.removeEventListener("resize", onResize);
|
|
180
|
+
listening = false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
onMounted(start);
|
|
184
|
+
watch(() => [props.open, props.anchor], () => {
|
|
185
|
+
stop();
|
|
186
|
+
start();
|
|
187
|
+
});
|
|
188
|
+
watch(() => [props.placement, props.offset, props.flip, props.shift, props.strategy], () => reposition());
|
|
189
|
+
onBeforeUnmount(stop);
|
|
190
|
+
return () => {
|
|
191
|
+
if (!props.open || !props.anchor)
|
|
192
|
+
return null;
|
|
193
|
+
const side = splitPlacement(resolvedPlacement.value).side;
|
|
194
|
+
const floating = h("div", {
|
|
195
|
+
ref: panel,
|
|
196
|
+
class: classNames("st-popper", props.class),
|
|
197
|
+
"data-popper-placement": resolvedPlacement.value,
|
|
198
|
+
style: `position: ${props.strategy}; top: ${top.value}px; left: ${left.value}px;`,
|
|
199
|
+
}, [
|
|
200
|
+
slots.default?.(),
|
|
201
|
+
props.arrow
|
|
202
|
+
? h("span", {
|
|
203
|
+
class: "st-popper__arrow",
|
|
204
|
+
"data-popper-side": side,
|
|
205
|
+
"aria-hidden": "true",
|
|
206
|
+
})
|
|
207
|
+
: null,
|
|
208
|
+
]);
|
|
209
|
+
if (props.portal) {
|
|
210
|
+
return h(Teleport, { to: "body" }, floating);
|
|
211
|
+
}
|
|
212
|
+
return floating;
|
|
213
|
+
};
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
//# sourceMappingURL=Popper.js.map
|
|
@@ -0,0 +1 @@
|
|
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K;aAClF,EACD;gBACE,KAAK,CAAC,OAAO,EAAE,EAAE;gBACjB,KAAK,CAAC,KAAK;oBACT,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;wBACR,KAAK,EAAE,kBAAkB;wBACzB,kBAAkB,EAAE,IAAI;wBACxB,aAAa,EAAE,MAAM;qBACtB,CAAC;oBACJ,CAAC,CAAC,IAAI;aACT,CACF,CAAC;YAEF,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;gBACjB,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAC;YAC/C,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/dist/Portal.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type PortalProps = {
|
|
2
|
+
/**
|
|
3
|
+
* Where to teleport the children. A CSS selector string or an actual
|
|
4
|
+
* `HTMLElement`. Defaults to the document `<body>`.
|
|
5
|
+
*/
|
|
6
|
+
target?: string | HTMLElement;
|
|
7
|
+
/** When `true`, render inline in place (no teleportation). */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** Optional class applied to the portal container element. */
|
|
10
|
+
class?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Teleport `children` into another part of the DOM via Vue's native
|
|
14
|
+
* `<Teleport>`. A `target` string is passed straight through as a CSS selector;
|
|
15
|
+
* an `HTMLElement` is accepted as well. When `disabled` is set the children
|
|
16
|
+
* render inline in place. Teleport is SSR-aware, so no manual DOM access here.
|
|
17
|
+
*/
|
|
18
|
+
export declare const Portal: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
19
|
+
target: {
|
|
20
|
+
type: () => string | HTMLElement;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
disabled: {
|
|
24
|
+
type: BooleanConstructor;
|
|
25
|
+
default: boolean;
|
|
26
|
+
};
|
|
27
|
+
class: {
|
|
28
|
+
type: StringConstructor;
|
|
29
|
+
default: undefined;
|
|
30
|
+
};
|
|
31
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
34
|
+
target: {
|
|
35
|
+
type: () => string | HTMLElement;
|
|
36
|
+
default: string;
|
|
37
|
+
};
|
|
38
|
+
disabled: {
|
|
39
|
+
type: BooleanConstructor;
|
|
40
|
+
default: boolean;
|
|
41
|
+
};
|
|
42
|
+
class: {
|
|
43
|
+
type: StringConstructor;
|
|
44
|
+
default: undefined;
|
|
45
|
+
};
|
|
46
|
+
}>> & Readonly<{}>, {
|
|
47
|
+
class: string;
|
|
48
|
+
disabled: boolean;
|
|
49
|
+
target: string | HTMLElement;
|
|
50
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
51
|
+
//# sourceMappingURL=Portal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Portal.d.ts","sourceRoot":"","sources":["../src/Portal.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,WAAW,GAAG;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC9B,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,MAAM;;cAIwB,MAAM,MAAM,GAAG,WAAW;;;;;;;;;;;;;;;cAA1B,MAAM,MAAM,GAAG,WAAW;;;;;;;;;;;;;;;4EAqBnE,CAAC"}
|
package/dist/Portal.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineComponent, h, Teleport } from "vue";
|
|
2
|
+
import { classNames } from "./classNames.js";
|
|
3
|
+
/**
|
|
4
|
+
* Teleport `children` into another part of the DOM via Vue's native
|
|
5
|
+
* `<Teleport>`. A `target` string is passed straight through as a CSS selector;
|
|
6
|
+
* an `HTMLElement` is accepted as well. When `disabled` is set the children
|
|
7
|
+
* render inline in place. Teleport is SSR-aware, so no manual DOM access here.
|
|
8
|
+
*/
|
|
9
|
+
export const Portal = defineComponent({
|
|
10
|
+
name: "Portal",
|
|
11
|
+
props: {
|
|
12
|
+
target: {
|
|
13
|
+
type: [String, Object],
|
|
14
|
+
default: "body",
|
|
15
|
+
},
|
|
16
|
+
disabled: { type: Boolean, default: false },
|
|
17
|
+
class: { type: String, default: undefined },
|
|
18
|
+
},
|
|
19
|
+
setup(props, { slots }) {
|
|
20
|
+
return () => h(Teleport, { to: props.target, disabled: props.disabled }, h("div", {
|
|
21
|
+
class: classNames("st-portal", props.class),
|
|
22
|
+
"data-st-portal": props.disabled ? "inline" : "teleported",
|
|
23
|
+
}, slots.default?.()));
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=Portal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Portal.js","sourceRoot":"","sources":["../src/Portal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAc7C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,eAAe,CAAC;IACpC,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE;QACL,MAAM,EAAE;YACN,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAA0C;YAC/D,OAAO,EAAE,MAAM;SAChB;QACD,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;QAC3C,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE;KAC5C;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,OAAO,GAAG,EAAE,CACV,CAAC,CACC,QAAQ,EACR,EAAE,EAAE,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,EAC9C,CAAC,CACC,KAAK,EACL;YACE,KAAK,EAAE,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC;YAC3C,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY;SAC3D,EACD,KAAK,CAAC,OAAO,EAAE,EAAE,CAClB,CACF,CAAC;IACN,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { type PropType } from "vue";
|
|
2
|
+
export type SelectableListProps = {
|
|
3
|
+
/** Accessible name for the listbox (required for SR users). */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** References the id of an external visible label (alternative to `label`). */
|
|
6
|
+
labelledby?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Allow more than one selected row. Adds aria-multiselectable and toggles
|
|
9
|
+
* each row independently. Defaults to false (single-select).
|
|
10
|
+
*/
|
|
11
|
+
multiple?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Selected value(s). Controlled when provided. For single-select pass a
|
|
14
|
+
* string (or null); for multiple pass a string[]. When omitted the list is
|
|
15
|
+
* uncontrolled and keeps its own internal selection.
|
|
16
|
+
*/
|
|
17
|
+
value?: string | string[] | null;
|
|
18
|
+
/**
|
|
19
|
+
* Fired with the new selection on every change. Receives a string|null for
|
|
20
|
+
* single-select and a string[] for multiple. Required for the controlled
|
|
21
|
+
* pattern; also fires for uncontrolled lists.
|
|
22
|
+
*/
|
|
23
|
+
onChange?: (value: string | string[] | null) => void;
|
|
24
|
+
class?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Accessible listbox that owns selection + a roving tabindex for its
|
|
28
|
+
* {@link SelectableRow} children. Arrow / Home / End move focus (roving),
|
|
29
|
+
* Space / Enter / click toggle the focused row. Single-select by default;
|
|
30
|
+
* `multiple` toggles rows independently. Controlled via `value`/`onChange`,
|
|
31
|
+
* otherwise it keeps its own internal selection. Pilots each child row through
|
|
32
|
+
* provide/inject (role="option" + the computed tabindex / aria-selected).
|
|
33
|
+
*/
|
|
34
|
+
export declare const SelectableList: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
35
|
+
label: {
|
|
36
|
+
type: StringConstructor;
|
|
37
|
+
default: undefined;
|
|
38
|
+
};
|
|
39
|
+
labelledby: {
|
|
40
|
+
type: StringConstructor;
|
|
41
|
+
default: undefined;
|
|
42
|
+
};
|
|
43
|
+
multiple: {
|
|
44
|
+
type: BooleanConstructor;
|
|
45
|
+
default: boolean;
|
|
46
|
+
};
|
|
47
|
+
value: {
|
|
48
|
+
type: PropType<string | string[] | null>;
|
|
49
|
+
default: undefined;
|
|
50
|
+
};
|
|
51
|
+
onChange: {
|
|
52
|
+
type: PropType<(value: string | string[] | null) => void>;
|
|
53
|
+
default: undefined;
|
|
54
|
+
};
|
|
55
|
+
class: {
|
|
56
|
+
type: StringConstructor;
|
|
57
|
+
default: undefined;
|
|
58
|
+
};
|
|
59
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
62
|
+
change: (_value: string | string[] | null) => true;
|
|
63
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
64
|
+
label: {
|
|
65
|
+
type: StringConstructor;
|
|
66
|
+
default: undefined;
|
|
67
|
+
};
|
|
68
|
+
labelledby: {
|
|
69
|
+
type: StringConstructor;
|
|
70
|
+
default: undefined;
|
|
71
|
+
};
|
|
72
|
+
multiple: {
|
|
73
|
+
type: BooleanConstructor;
|
|
74
|
+
default: boolean;
|
|
75
|
+
};
|
|
76
|
+
value: {
|
|
77
|
+
type: PropType<string | string[] | null>;
|
|
78
|
+
default: undefined;
|
|
79
|
+
};
|
|
80
|
+
onChange: {
|
|
81
|
+
type: PropType<(value: string | string[] | null) => void>;
|
|
82
|
+
default: undefined;
|
|
83
|
+
};
|
|
84
|
+
class: {
|
|
85
|
+
type: StringConstructor;
|
|
86
|
+
default: undefined;
|
|
87
|
+
};
|
|
88
|
+
}>> & Readonly<{
|
|
89
|
+
onChange?: ((_value: string | string[] | null) => any) | undefined;
|
|
90
|
+
}>, {
|
|
91
|
+
multiple: boolean;
|
|
92
|
+
class: string;
|
|
93
|
+
onChange: (value: string | string[] | null) => void;
|
|
94
|
+
label: string;
|
|
95
|
+
value: string | string[] | null;
|
|
96
|
+
labelledby: string;
|
|
97
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
98
|
+
//# sourceMappingURL=SelectableList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectableList.d.ts","sourceRoot":"","sources":["../src/SelectableList.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,QAAQ,EACd,MAAM,KAAK,CAAC;AAOb,MAAM,MAAM,mBAAmB,GAAG;IAChC,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IACjC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAkBF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;cASI,QAAQ,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;;;;cAIzC,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC;;;;;;;;;;qBAMtD,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;;;;;;;;;;;;;;;cAVd,QAAQ,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;;;;cAIzC,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC;;;;;;;;;;;;sBAAlC,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,KAAK,IAAI;;;;4EA+IxE,CAAC"}
|