@destyler/popper 0.0.1-beta.9 → 0.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-PRESENT Elone Hoo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index.cjs');
4
+ require('vue');
5
+ require('@destyler/shared');
6
+ require('@destyler/primitive');
7
+ require('@destyler/composition');
8
+ require('@floating-ui/vue');
9
+ require('@destyler/arrow');
10
+
11
+
12
+
13
+ exports.DestylerPopperAnchor = index.DestylerPopperAnchor;
14
+ exports.DestylerPopperArrow = index.DestylerPopperArrow;
15
+ exports.DestylerPopperContent = index.DestylerPopperContent;
16
+ exports.DestylerPopperRoot = index.DestylerPopperRoot;
@@ -0,0 +1,5 @@
1
+ export { DestylerPopperAnchor, DestylerPopperAnchorProps, DestylerPopperArrow, DestylerPopperArrowProps, DestylerPopperContent, DestylerPopperContentProps, DestylerPopperRoot } from './index.cjs';
2
+ import 'vue';
3
+ import '@destyler/primitive';
4
+ import '@destyler/shared';
5
+ import '@floating-ui/vue';
@@ -0,0 +1,5 @@
1
+ export { DestylerPopperAnchor, DestylerPopperAnchorProps, DestylerPopperArrow, DestylerPopperArrowProps, DestylerPopperContent, DestylerPopperContentProps, DestylerPopperRoot } from './index.mjs';
2
+ import 'vue';
3
+ import '@destyler/primitive';
4
+ import '@destyler/shared';
5
+ import '@floating-ui/vue';
@@ -0,0 +1,5 @@
1
+ export { DestylerPopperAnchor, DestylerPopperAnchorProps, DestylerPopperArrow, DestylerPopperArrowProps, DestylerPopperContent, DestylerPopperContentProps, DestylerPopperRoot } from './index.js';
2
+ import 'vue';
3
+ import '@destyler/primitive';
4
+ import '@destyler/shared';
5
+ import '@floating-ui/vue';
@@ -0,0 +1,7 @@
1
+ export { DestylerPopperAnchor, DestylerPopperArrow, DestylerPopperContent, DestylerPopperRoot } from './index.mjs';
2
+ import 'vue';
3
+ import '@destyler/shared';
4
+ import '@destyler/primitive';
5
+ import '@destyler/composition';
6
+ import '@floating-ui/vue';
7
+ import '@destyler/arrow';
package/dist/index.cjs CHANGED
@@ -23,7 +23,16 @@ const DestylerPopperRoot = vue.defineComponent({
23
23
  });
24
24
 
25
25
  const destylerPopperAnchorProps = {
26
- ...primitive.destylerPrimitiveProps,
26
+ as: {
27
+ type: [String, Object],
28
+ required: false,
29
+ default: "div"
30
+ },
31
+ asChild: {
32
+ type: Boolean,
33
+ required: false,
34
+ default: false
35
+ },
27
36
  element: {
28
37
  type: Object
29
38
  }
@@ -32,21 +41,23 @@ const DestylerPopperAnchor = vue.defineComponent({
32
41
  name: "DestylerPopperAnchor",
33
42
  props: destylerPopperAnchorProps,
34
43
  setup(props) {
35
- const { customElement, currentElement } = composition.useCustomElement();
44
+ const { forwardRef, currentElement } = composition.useForwardExpose();
36
45
  const rootContext = injectPopperRootContext();
37
46
  vue.watch(currentElement, () => {
38
47
  rootContext.onAnchorChange(props.element ?? currentElement.value);
39
48
  });
40
49
  return {
41
- customElement
50
+ forwardRef
42
51
  };
43
52
  },
44
53
  render() {
45
54
  return vue.h(primitive.DestylerPrimitive, {
46
55
  as: this.$props.as,
47
56
  asChild: this.$props.asChild,
48
- ref: "customElement"
49
- }, this.$slots.default?.());
57
+ ref: (el) => this.forwardRef(el)
58
+ }, {
59
+ default: () => this.$slots.default?.()
60
+ });
50
61
  }
51
62
  });
52
63
 
@@ -93,7 +104,16 @@ function getSideAndAlignFromPlacement(placement) {
93
104
 
94
105
  const [injectPopperContentContext, providePopperContentContext] = shared.createContext("DestylerPopperContent");
95
106
  const destylerPopperContentProps = {
96
- ...primitive.destylerPrimitiveProps,
107
+ as: {
108
+ type: [String, Object],
109
+ required: false,
110
+ default: "div"
111
+ },
112
+ asChild: {
113
+ type: Boolean,
114
+ required: false,
115
+ default: false
116
+ },
97
117
  side: {
98
118
  type: String,
99
119
  required: false,
@@ -165,8 +185,7 @@ const DestylerPopperContent = vue.defineComponent({
165
185
  props: destylerPopperContentProps,
166
186
  setup(props, { attrs }) {
167
187
  const rootContext = injectPopperRootContext();
168
- const forwardRef = composition.useForwardRef();
169
- const { customElement, currentElement: contentElement } = composition.useCustomElement();
188
+ const { forwardRef, currentElement: contentElement } = composition.useForwardExpose();
170
189
  const floatingRef = vue.ref();
171
190
  const arrow = vue.ref();
172
191
  const { width: arrowWidth, height: arrowHeight } = composition.useSize(arrow);
@@ -280,14 +299,13 @@ const DestylerPopperContent = vue.defineComponent({
280
299
  contentZIndex,
281
300
  middlewareData,
282
301
  forwardRef,
283
- customElement,
284
302
  placedSide,
285
303
  placedAlign,
286
304
  attrStyle: attrs.style
287
305
  };
288
306
  },
289
307
  render() {
290
- return vue.h("div", vue.mergeProps(this.$attrs, {
308
+ return vue.h("div", {
291
309
  "data-destyler-popper-content-wrapper": "",
292
310
  "ref": "floatingRef",
293
311
  "style": {
@@ -300,11 +318,8 @@ const DestylerPopperContent = vue.defineComponent({
300
318
  this.middlewareData.transformOrigin?.y
301
319
  ].join(" ")
302
320
  }
303
- }), vue.h(primitive.DestylerPrimitive, vue.mergeProps(this.$attrs, {
304
- "ref": (vnode) => {
305
- this.forwardRef(vnode);
306
- this.customElement = vnode;
307
- },
321
+ }, vue.h(primitive.DestylerPrimitive, vue.mergeProps(this.$attrs, {
322
+ "ref": (el) => this.forwardRef(el),
308
323
  "as": this.$props.as,
309
324
  "asChild": this.$props.asChild,
310
325
  "data-side": this.placedSide,
@@ -313,7 +328,9 @@ const DestylerPopperContent = vue.defineComponent({
313
328
  animation: !this.isPositioned ? "none" : void 0,
314
329
  opacity: this.middlewareData.hide?.referenceHidden ? 0 : void 0
315
330
  }
316
- }), this.$slots.default?.()));
331
+ }), {
332
+ default: () => this.$slots.default?.()
333
+ }));
317
334
  }
318
335
  });
319
336
 
@@ -324,8 +341,21 @@ const OPPOSITE_SIDE = {
324
341
  left: "right"
325
342
  };
326
343
  const destylerPopperArrowProps = {
327
- ...primitive.destylerPrimitiveProp,
328
- ...arrow.destylerArrowProps,
344
+ asChild: {
345
+ type: Boolean,
346
+ required: false,
347
+ default: false
348
+ },
349
+ width: {
350
+ type: Number,
351
+ required: false,
352
+ default: 5
353
+ },
354
+ height: {
355
+ type: Number,
356
+ required: false,
357
+ default: 10
358
+ },
329
359
  as: {
330
360
  type: [String, Object],
331
361
  required: false,
@@ -377,36 +407,13 @@ const DestylerPopperArrow = vue.defineComponent({
377
407
  style: {
378
408
  display: "block"
379
409
  }
380
- }), this.$slots.default?.()));
410
+ }), {
411
+ default: () => this.$slots.default?.()
412
+ }));
381
413
  }
382
414
  });
383
415
 
384
- const name = "@destyler/popper";
385
-
386
- const packageName = name;
387
- function DestylerPopperResolver() {
388
- return {
389
- type: "component",
390
- resolve: (name2) => {
391
- if (name2 === "DestylerTemplate")
392
- return { name: name2, from: packageName };
393
- }
394
- };
395
- }
396
-
397
416
  exports.DestylerPopperAnchor = DestylerPopperAnchor;
398
417
  exports.DestylerPopperArrow = DestylerPopperArrow;
399
418
  exports.DestylerPopperContent = DestylerPopperContent;
400
- exports.DestylerPopperResolver = DestylerPopperResolver;
401
419
  exports.DestylerPopperRoot = DestylerPopperRoot;
402
- exports.OPPOSITE_SIDE = OPPOSITE_SIDE;
403
- exports.destylerPopperAnchorProps = destylerPopperAnchorProps;
404
- exports.destylerPopperArrowProps = destylerPopperArrowProps;
405
- exports.destylerPopperContentProps = destylerPopperContentProps;
406
- exports.getSideAndAlignFromPlacement = getSideAndAlignFromPlacement;
407
- exports.injectPopperContentContext = injectPopperContentContext;
408
- exports.injectPopperRootContext = injectPopperRootContext;
409
- exports.isNotNull = isNotNull;
410
- exports.providePopperContentContext = providePopperContentContext;
411
- exports.providePopperRootContext = providePopperRootContext;
412
- exports.transformOrigin = transformOrigin;