@mekari/pixel3-popover 0.0.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/chunk-2ZUCITXI.mjs +8 -0
- package/dist/chunk-3VISLXE6.mjs +94 -0
- package/dist/chunk-6AOSFLZR.mjs +55 -0
- package/dist/chunk-7E4KFP32.mjs +10045 -0
- package/dist/chunk-E2N74NQW.mjs +29 -0
- package/dist/chunk-EOUKE4WB.mjs +308 -0
- package/dist/chunk-KRK533DP.mjs +25 -0
- package/dist/chunk-OBEDLACV.mjs +44 -0
- package/dist/chunk-QZ7VFGWC.mjs +6 -0
- package/dist/chunk-SMKHJPNG.mjs +55 -0
- package/dist/content.d.mts +8 -0
- package/dist/content.d.ts +8 -0
- package/dist/content.js +233 -0
- package/dist/content.mjs +10 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +10607 -0
- package/dist/index.mjs +30 -0
- package/dist/list-item.d.mts +8 -0
- package/dist/list-item.d.ts +8 -0
- package/dist/list-item.js +10593 -0
- package/dist/list-item.mjs +15 -0
- package/dist/list.d.mts +5 -0
- package/dist/list.d.ts +5 -0
- package/dist/list.js +71 -0
- package/dist/list.mjs +9 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/modules/popover.context.d.mts +13 -0
- package/dist/modules/popover.context.d.ts +13 -0
- package/dist/modules/popover.context.js +33 -0
- package/dist/modules/popover.context.mjs +9 -0
- package/dist/modules/popover.hooks.d.mts +111 -0
- package/dist/modules/popover.hooks.d.ts +111 -0
- package/dist/modules/popover.hooks.js +337 -0
- package/dist/modules/popover.hooks.mjs +18 -0
- package/dist/modules/popover.props.d.mts +153 -0
- package/dist/modules/popover.props.d.ts +153 -0
- package/dist/modules/popover.props.js +121 -0
- package/dist/modules/popover.props.mjs +13 -0
- package/dist/popover.d.mts +126 -0
- package/dist/popover.d.ts +126 -0
- package/dist/popover.js +213 -0
- package/dist/popover.mjs +10 -0
- package/dist/singleton-popover.d.mts +135 -0
- package/dist/singleton-popover.d.ts +135 -0
- package/dist/singleton-popover.js +197 -0
- package/dist/singleton-popover.mjs +10 -0
- package/dist/trigger.d.mts +5 -0
- package/dist/trigger.d.ts +5 -0
- package/dist/trigger.js +115 -0
- package/dist/trigger.mjs +9 -0
- package/package.json +42 -0
package/dist/content.js
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/content.tsx
|
|
22
|
+
var content_exports = {};
|
|
23
|
+
__export(content_exports, {
|
|
24
|
+
MpPopoverContent: () => MpPopoverContent
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(content_exports);
|
|
27
|
+
var import_vue3 = require("vue");
|
|
28
|
+
var import_vue4 = require("vue");
|
|
29
|
+
|
|
30
|
+
// src/modules/popover.hooks.ts
|
|
31
|
+
var import_vue = require("vue");
|
|
32
|
+
var import_vue2 = require("@floating-ui/vue");
|
|
33
|
+
var import_pixel3_utils2 = require("@mekari/pixel3-utils");
|
|
34
|
+
var import_recipes = require("@mekari/pixel3-styled-system/recipes");
|
|
35
|
+
var import_patterns = require("@mekari/pixel3-styled-system/patterns");
|
|
36
|
+
|
|
37
|
+
// src/modules/popover.context.ts
|
|
38
|
+
var import_pixel3_utils = require("@mekari/pixel3-utils");
|
|
39
|
+
var [PopoverProvider, usePopoverContext] = (0, import_pixel3_utils.usePixelCreateContext)("PopoverContext");
|
|
40
|
+
|
|
41
|
+
// src/modules/popover.hooks.ts
|
|
42
|
+
function usePopoverContent(props, emit) {
|
|
43
|
+
const {
|
|
44
|
+
isOpen,
|
|
45
|
+
isHovering,
|
|
46
|
+
setHovering,
|
|
47
|
+
triggerNode,
|
|
48
|
+
contentNode,
|
|
49
|
+
floatingStyles,
|
|
50
|
+
onOpenPopover,
|
|
51
|
+
onClosePopover,
|
|
52
|
+
rootProps: popoverProps2
|
|
53
|
+
} = usePopoverContext();
|
|
54
|
+
const {
|
|
55
|
+
id,
|
|
56
|
+
closeOnBlur,
|
|
57
|
+
closeOnEscape,
|
|
58
|
+
trigger,
|
|
59
|
+
isAdaptiveWidth,
|
|
60
|
+
usePortal
|
|
61
|
+
} = popoverProps2;
|
|
62
|
+
const restContentNode = (0, import_vue.computed)(() => isOpen.value ? contentNode.value : null);
|
|
63
|
+
const getId = (0, import_vue.computed)(() => (id == null ? void 0 : id.value) ? `popover-content-${id.value}` : `popover-content-${(0, import_pixel3_utils2.useId)(4)}`);
|
|
64
|
+
(0, import_pixel3_utils2.onClickOutside)(restContentNode, (e) => {
|
|
65
|
+
emit("blur", e);
|
|
66
|
+
if (closeOnBlur.value) {
|
|
67
|
+
onClosePopover();
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
(0, import_pixel3_utils2.onKeyStroke)("Escape", (e) => {
|
|
71
|
+
if (isOpen.value) {
|
|
72
|
+
emit("escape");
|
|
73
|
+
if (closeOnEscape.value) {
|
|
74
|
+
onClosePopover();
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const rootAttrs = (0, import_vue.computed)(() => {
|
|
80
|
+
const triggerEl = (0, import_pixel3_utils2.unrefElement)(triggerNode);
|
|
81
|
+
const adaptiveWidthStyle = isAdaptiveWidth.value ? {
|
|
82
|
+
width: "max-content",
|
|
83
|
+
minWidth: (usePortal == null ? void 0 : usePortal.value) ? `${triggerEl == null ? void 0 : triggerEl.clientWidth}px` : "100%",
|
|
84
|
+
maxWidth: "90vw"
|
|
85
|
+
} : {};
|
|
86
|
+
return {
|
|
87
|
+
ref: contentNode,
|
|
88
|
+
"data-pixel-component": "MpPopoverContent",
|
|
89
|
+
id: getId.value,
|
|
90
|
+
class: (0, import_recipes.popoverContentRecipe)({
|
|
91
|
+
isDark: props.isDark,
|
|
92
|
+
isUnstyled: props.isUnstyled
|
|
93
|
+
}),
|
|
94
|
+
style: {
|
|
95
|
+
display: isOpen.value ? "unset" : "none",
|
|
96
|
+
...floatingStyles.value,
|
|
97
|
+
...adaptiveWidthStyle
|
|
98
|
+
},
|
|
99
|
+
onMouseenter: () => {
|
|
100
|
+
if (trigger.value === "hover") {
|
|
101
|
+
setHovering(true);
|
|
102
|
+
setTimeout(() => {
|
|
103
|
+
onOpenPopover();
|
|
104
|
+
}, 300);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
onMouseleave: () => {
|
|
108
|
+
if (trigger.value === "hover") {
|
|
109
|
+
setHovering(false);
|
|
110
|
+
setTimeout(() => {
|
|
111
|
+
if (isHovering.value === false) {
|
|
112
|
+
onClosePopover();
|
|
113
|
+
}
|
|
114
|
+
}, 300);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
rootAttrs,
|
|
121
|
+
popoverProps: popoverProps2,
|
|
122
|
+
isOpen,
|
|
123
|
+
floatingStyles
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
__name(usePopoverContent, "usePopoverContent");
|
|
127
|
+
|
|
128
|
+
// src/modules/popover.props.ts
|
|
129
|
+
var popoverProps = {
|
|
130
|
+
placement: {
|
|
131
|
+
type: String,
|
|
132
|
+
default: "bottom-start"
|
|
133
|
+
},
|
|
134
|
+
id: {
|
|
135
|
+
type: String
|
|
136
|
+
},
|
|
137
|
+
trigger: {
|
|
138
|
+
type: String,
|
|
139
|
+
default: "click"
|
|
140
|
+
},
|
|
141
|
+
triggerId: {
|
|
142
|
+
type: String
|
|
143
|
+
},
|
|
144
|
+
defaultIsOpen: {
|
|
145
|
+
type: Boolean
|
|
146
|
+
},
|
|
147
|
+
isManual: {
|
|
148
|
+
type: Boolean
|
|
149
|
+
},
|
|
150
|
+
isOpen: {
|
|
151
|
+
type: Boolean
|
|
152
|
+
},
|
|
153
|
+
returnFocusOnClose: {
|
|
154
|
+
type: Boolean
|
|
155
|
+
},
|
|
156
|
+
initialFocusRef: {
|
|
157
|
+
type: Boolean
|
|
158
|
+
},
|
|
159
|
+
closeOnBlur: {
|
|
160
|
+
type: Boolean,
|
|
161
|
+
default: true
|
|
162
|
+
},
|
|
163
|
+
closeOnEscape: {
|
|
164
|
+
type: Boolean,
|
|
165
|
+
default: true
|
|
166
|
+
},
|
|
167
|
+
closeOnSelect: {
|
|
168
|
+
type: Boolean,
|
|
169
|
+
default: false
|
|
170
|
+
},
|
|
171
|
+
usePortal: {
|
|
172
|
+
type: Boolean,
|
|
173
|
+
default: false
|
|
174
|
+
},
|
|
175
|
+
isKeepAlive: {
|
|
176
|
+
type: Boolean,
|
|
177
|
+
default: true
|
|
178
|
+
},
|
|
179
|
+
isAdaptiveWidth: {
|
|
180
|
+
type: Boolean,
|
|
181
|
+
default: false
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
var singletonPopoverProps = {
|
|
185
|
+
triggerNode: {
|
|
186
|
+
type: Object
|
|
187
|
+
},
|
|
188
|
+
...popoverProps
|
|
189
|
+
};
|
|
190
|
+
var popoverContentProps = {
|
|
191
|
+
isDark: {
|
|
192
|
+
type: Boolean
|
|
193
|
+
},
|
|
194
|
+
isUnstyled: {
|
|
195
|
+
type: Boolean
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// src/content.tsx
|
|
200
|
+
var MpPopoverContent = (0, import_vue4.defineComponent)({
|
|
201
|
+
name: "MpPopoverContent",
|
|
202
|
+
inheritAttrs: false,
|
|
203
|
+
props: popoverContentProps,
|
|
204
|
+
emits: ["blur", "escape"],
|
|
205
|
+
setup(props, {
|
|
206
|
+
slots,
|
|
207
|
+
attrs,
|
|
208
|
+
emit
|
|
209
|
+
}) {
|
|
210
|
+
const {
|
|
211
|
+
rootAttrs,
|
|
212
|
+
popoverProps: popoverProps2,
|
|
213
|
+
isOpen
|
|
214
|
+
} = usePopoverContent(props, emit);
|
|
215
|
+
const {
|
|
216
|
+
isKeepAlive,
|
|
217
|
+
usePortal
|
|
218
|
+
} = popoverProps2;
|
|
219
|
+
return () => {
|
|
220
|
+
const node = (0, import_vue3.createVNode)(import_vue3.Fragment, null, [(0, import_vue3.createVNode)("div", (0, import_vue3.mergeProps)(rootAttrs.value, attrs), [slots.default()])]);
|
|
221
|
+
const renderNode = usePortal.value ? (0, import_vue3.createVNode)(import_vue4.Teleport, {
|
|
222
|
+
"to": "body"
|
|
223
|
+
}, {
|
|
224
|
+
default: () => [(0, import_vue3.createTextVNode)(" "), node, (0, import_vue3.createTextVNode)(" ")]
|
|
225
|
+
}) : node;
|
|
226
|
+
return isKeepAlive.value ? renderNode : isOpen.value ? renderNode : null;
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
231
|
+
0 && (module.exports = {
|
|
232
|
+
MpPopoverContent
|
|
233
|
+
});
|
package/dist/content.mjs
ADDED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { PopoverContentProps } from './modules/popover.props.mjs';
|
|
2
|
+
export { MpPopover } from './popover.mjs';
|
|
3
|
+
export { MpPopoverTrigger } from './trigger.mjs';
|
|
4
|
+
export { MpPopoverContent } from './content.mjs';
|
|
5
|
+
export { MpPopoverList } from './list.mjs';
|
|
6
|
+
export { MpPopoverListItem } from './list-item.mjs';
|
|
7
|
+
export { MpSingletonPopover } from './singleton-popover.mjs';
|
|
8
|
+
import 'vue';
|
|
9
|
+
import '@floating-ui/vue';
|
|
10
|
+
import '@mekari/pixel3-utils';
|
|
11
|
+
import '@floating-ui/dom';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { PopoverContentProps } from './modules/popover.props.js';
|
|
2
|
+
export { MpPopover } from './popover.js';
|
|
3
|
+
export { MpPopoverTrigger } from './trigger.js';
|
|
4
|
+
export { MpPopoverContent } from './content.js';
|
|
5
|
+
export { MpPopoverList } from './list.js';
|
|
6
|
+
export { MpPopoverListItem } from './list-item.js';
|
|
7
|
+
export { MpSingletonPopover } from './singleton-popover.js';
|
|
8
|
+
import 'vue';
|
|
9
|
+
import '@floating-ui/vue';
|
|
10
|
+
import '@mekari/pixel3-utils';
|
|
11
|
+
import '@floating-ui/dom';
|