@studiometa/ui 0.2.1 → 0.2.4
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/atoms/AnchorScrollTo/AnchorScrollTo.cjs +47 -0
- package/atoms/AnchorScrollTo/AnchorScrollTo.d.ts +31 -0
- package/atoms/AnchorScrollTo/AnchorScrollTo.js +1 -0
- package/atoms/Cursor/Cursor.cjs +14 -22
- package/atoms/Cursor/Cursor.d.ts +2 -2
- package/atoms/Cursor/Cursor.js +1 -103
- package/atoms/Figure/Figure.cjs +9 -14
- package/atoms/Figure/Figure.d.ts +1 -1
- package/atoms/Figure/Figure.js +1 -27
- package/atoms/LargeText/LargeText.cjs +82 -0
- package/atoms/LargeText/LargeText.d.ts +94 -0
- package/atoms/LargeText/LargeText.js +1 -0
- package/atoms/LazyInclude/LazyInclude.cjs +67 -0
- package/atoms/LazyInclude/LazyInclude.d.ts +64 -0
- package/atoms/LazyInclude/LazyInclude.js +1 -0
- package/atoms/Prefetch/AbstractPrefetch.cjs +79 -0
- package/atoms/Prefetch/AbstractPrefetch.d.ts +52 -0
- package/atoms/Prefetch/AbstractPrefetch.js +1 -0
- package/atoms/Prefetch/PrefetchWhenOver.cjs +43 -0
- package/atoms/Prefetch/PrefetchWhenOver.d.ts +21 -0
- package/atoms/Prefetch/PrefetchWhenOver.js +1 -0
- package/atoms/Prefetch/PrefetchWhenVisible.cjs +44 -0
- package/atoms/Prefetch/PrefetchWhenVisible.d.ts +21 -0
- package/atoms/Prefetch/PrefetchWhenVisible.js +1 -0
- package/atoms/Prefetch/index.cjs +33 -0
- package/atoms/Prefetch/index.d.ts +3 -0
- package/atoms/Prefetch/index.js +1 -0
- package/atoms/index.cjs +19 -18
- package/atoms/index.d.ts +5 -1
- package/atoms/index.js +1 -6
- package/index.cjs +11 -15
- package/index.js +1 -3
- package/molecules/Accordion/Accordion.cjs +12 -34
- package/molecules/Accordion/Accordion.js +1 -35
- package/molecules/Accordion/AccordionCore.cjs +8 -13
- package/molecules/Accordion/AccordionCore.d.ts +2 -2
- package/molecules/Accordion/AccordionCore.js +1 -34
- package/molecules/Accordion/AccordionItem.cjs +70 -114
- package/molecules/Accordion/AccordionItem.d.ts +15 -16
- package/molecules/Accordion/AccordionItem.js +1 -178
- package/molecules/Menu/Menu.cjs +148 -0
- package/molecules/Menu/Menu.d.ts +140 -0
- package/molecules/Menu/Menu.js +1 -0
- package/molecules/Menu/MenuBtn.cjs +53 -0
- package/molecules/Menu/MenuBtn.d.ts +39 -0
- package/molecules/Menu/MenuBtn.js +1 -0
- package/molecules/Menu/MenuList.cjs +134 -0
- package/molecules/Menu/MenuList.d.ts +101 -0
- package/molecules/Menu/MenuList.js +1 -0
- package/molecules/Menu/index.cjs +33 -0
- package/molecules/Menu/index.d.ts +3 -0
- package/molecules/Menu/index.js +1 -0
- package/molecules/Modal/Modal.cjs +42 -72
- package/molecules/Modal/Modal.d.ts +11 -11
- package/molecules/Modal/Modal.js +1 -151
- package/molecules/Modal/ModalWithTransition.cjs +70 -0
- package/molecules/Modal/ModalWithTransition.d.ts +29 -0
- package/molecules/Modal/ModalWithTransition.js +1 -0
- package/molecules/Panel/Panel.cjs +114 -0
- package/molecules/Panel/Panel.d.ts +42 -0
- package/molecules/Panel/Panel.js +1 -0
- package/molecules/Slider/AbstractSliderChild.cjs +64 -0
- package/molecules/Slider/AbstractSliderChild.d.ts +59 -0
- package/molecules/Slider/AbstractSliderChild.js +1 -0
- package/molecules/Slider/Slider.cjs +230 -0
- package/molecules/Slider/Slider.d.ts +245 -0
- package/molecules/Slider/Slider.js +1 -0
- package/molecules/Slider/SliderBtn.cjs +58 -0
- package/molecules/Slider/SliderBtn.d.ts +31 -0
- package/molecules/Slider/SliderBtn.js +1 -0
- package/molecules/Slider/SliderCount.cjs +43 -0
- package/molecules/Slider/SliderCount.d.ts +21 -0
- package/molecules/Slider/SliderCount.js +1 -0
- package/molecules/Slider/SliderDots.cjs +48 -0
- package/molecules/Slider/SliderDots.d.ts +33 -0
- package/molecules/Slider/SliderDots.js +1 -0
- package/molecules/Slider/SliderDrag.cjs +40 -0
- package/molecules/Slider/SliderDrag.d.ts +16 -0
- package/molecules/Slider/SliderDrag.js +1 -0
- package/molecules/Slider/SliderItem.cjs +107 -0
- package/molecules/Slider/SliderItem.d.ts +106 -0
- package/molecules/Slider/SliderItem.js +1 -0
- package/molecules/Slider/SliderProgress.cjs +47 -0
- package/molecules/Slider/SliderProgress.d.ts +27 -0
- package/molecules/Slider/SliderProgress.js +1 -0
- package/molecules/Slider/index.cjs +43 -0
- package/molecules/Slider/index.d.ts +8 -0
- package/molecules/Slider/index.js +1 -0
- package/molecules/Sticky/Sticky.cjs +11 -19
- package/molecules/Sticky/Sticky.d.ts +8 -8
- package/molecules/Sticky/Sticky.js +1 -107
- package/molecules/TableOfContent/TableOfContent.cjs +66 -0
- package/molecules/TableOfContent/TableOfContent.d.ts +59 -0
- package/molecules/TableOfContent/TableOfContent.js +1 -0
- package/molecules/TableOfContent/TableOfContentAnchor.cjs +60 -0
- package/molecules/TableOfContent/TableOfContentAnchor.d.ts +36 -0
- package/molecules/TableOfContent/TableOfContentAnchor.js +1 -0
- package/molecules/TableOfContent/index.cjs +31 -0
- package/molecules/TableOfContent/index.d.ts +2 -0
- package/molecules/TableOfContent/index.js +1 -0
- package/molecules/Tabs/Tabs.cjs +54 -82
- package/molecules/Tabs/Tabs.d.ts +7 -8
- package/molecules/Tabs/Tabs.js +1 -126
- package/molecules/index.cjs +18 -17
- package/molecules/index.d.ts +6 -1
- package/molecules/index.js +1 -12
- package/organisms/Frame/Frame.cjs +171 -0
- package/organisms/Frame/Frame.d.ts +119 -0
- package/organisms/Frame/Frame.js +1 -0
- package/organisms/Frame/FrameAnchor.cjs +43 -0
- package/organisms/Frame/FrameAnchor.d.ts +35 -0
- package/organisms/Frame/FrameAnchor.js +1 -0
- package/organisms/Frame/FrameForm.cjs +43 -0
- package/organisms/Frame/FrameForm.d.ts +32 -0
- package/organisms/Frame/FrameForm.js +1 -0
- package/organisms/Frame/FrameTarget.cjs +92 -0
- package/organisms/Frame/FrameTarget.d.ts +47 -0
- package/organisms/Frame/FrameTarget.js +1 -0
- package/organisms/Frame/index.cjs +35 -0
- package/organisms/Frame/index.d.ts +4 -0
- package/organisms/Frame/index.js +1 -0
- package/organisms/index.cjs +9 -12
- package/organisms/index.d.ts +1 -1
- package/organisms/index.js +1 -0
- package/package.json +3 -4
- package/primitives/Draggable/Draggable.cjs +15 -28
- package/primitives/Draggable/Draggable.d.ts +0 -5
- package/primitives/Draggable/Draggable.js +1 -38
- package/primitives/Sentinel/Sentinel.cjs +8 -13
- package/primitives/Sentinel/Sentinel.js +1 -15
- package/primitives/Transition/Transition.cjs +66 -0
- package/primitives/Transition/Transition.d.ts +67 -0
- package/primitives/Transition/Transition.js +1 -0
- package/primitives/index.cjs +12 -17
- package/primitives/index.d.ts +1 -0
- package/primitives/index.js +1 -6
|
@@ -3,24 +3,19 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
7
6
|
var __export = (target, all) => {
|
|
8
7
|
for (var name in all)
|
|
9
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
9
|
};
|
|
11
|
-
var
|
|
12
|
-
if (
|
|
13
|
-
for (let key of __getOwnPropNames(
|
|
14
|
-
if (!__hasOwnProp.call(
|
|
15
|
-
__defProp(
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
15
|
}
|
|
17
|
-
return
|
|
16
|
+
return to;
|
|
18
17
|
};
|
|
19
|
-
var __toCommonJS =
|
|
20
|
-
return (module2, temp) => {
|
|
21
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
22
|
-
};
|
|
23
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
19
|
var __publicField = (obj, key, value) => {
|
|
25
20
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
26
21
|
return value;
|
|
@@ -31,14 +26,12 @@ var Sticky_exports = {};
|
|
|
31
26
|
__export(Sticky_exports, {
|
|
32
27
|
default: () => Sticky
|
|
33
28
|
});
|
|
29
|
+
module.exports = __toCommonJS(Sticky_exports);
|
|
34
30
|
var import_js_toolkit = require("@studiometa/js-toolkit");
|
|
35
31
|
var import_primitives = require("../../primitives/index.cjs");
|
|
36
32
|
var _Sticky = class extends import_js_toolkit.Base {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
__publicField(this, "isSticky", false);
|
|
40
|
-
__publicField(this, "isVisible", true);
|
|
41
|
-
}
|
|
33
|
+
isSticky = false;
|
|
34
|
+
isVisible = true;
|
|
42
35
|
set y(value) {
|
|
43
36
|
this.$refs.inner.style.transform = `translateY(${value}px) translateZ(0px)`;
|
|
44
37
|
}
|
|
@@ -99,7 +92,7 @@ var _Sticky = class extends import_js_toolkit.Base {
|
|
|
99
92
|
return;
|
|
100
93
|
}
|
|
101
94
|
const { instances } = this;
|
|
102
|
-
index = index
|
|
95
|
+
index = index ?? instances.findIndex((instance) => instance === this);
|
|
103
96
|
this.y = instances.slice(0, index).filter((instance) => instance.isSticky && !instance.isVisible).reduce((y, instance) => {
|
|
104
97
|
return y - instance.$refs.inner.offsetHeight;
|
|
105
98
|
}, this.isVisible ? 0 : this.$refs.inner.offsetHeight * -1);
|
|
@@ -129,5 +122,4 @@ __publicField(Sticky, "config", {
|
|
|
129
122
|
}
|
|
130
123
|
});
|
|
131
124
|
__publicField(Sticky, "instances", /* @__PURE__ */ new Set());
|
|
132
|
-
module.exports = __toCommonJS(Sticky_exports);
|
|
133
125
|
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -66,23 +66,23 @@ export default class Sticky extends Base {
|
|
|
66
66
|
* Mounted hook.
|
|
67
67
|
* @this {StickyInterface}
|
|
68
68
|
*/
|
|
69
|
-
mounted(): void;
|
|
69
|
+
mounted(this: StickyInterface): void;
|
|
70
70
|
/**
|
|
71
71
|
* Resized hook.
|
|
72
72
|
* @this {StickyInterface}
|
|
73
73
|
* @returns {void}
|
|
74
74
|
*/
|
|
75
|
-
resized(): void;
|
|
75
|
+
resized(this: StickyInterface): void;
|
|
76
76
|
/**
|
|
77
77
|
* Destroyed hook.
|
|
78
78
|
* @this {StickyInterface}
|
|
79
79
|
*/
|
|
80
|
-
destroyed(): void;
|
|
80
|
+
destroyed(this: StickyInterface): void;
|
|
81
81
|
/**
|
|
82
82
|
* Scrolled hook.
|
|
83
83
|
* @this {StickyInterface}
|
|
84
84
|
*/
|
|
85
|
-
scrolled(props: any): void;
|
|
85
|
+
scrolled(this: StickyInterface, props: any): void;
|
|
86
86
|
/**
|
|
87
87
|
* Listen to the sentinel's `intersected` event to set the `isSticky` value.
|
|
88
88
|
*
|
|
@@ -94,17 +94,17 @@ export default class Sticky extends Base {
|
|
|
94
94
|
* Hide the sticky component when another one is sticky.
|
|
95
95
|
* @this {StickyInterface}
|
|
96
96
|
*/
|
|
97
|
-
hide(): void;
|
|
97
|
+
hide(this: StickyInterface): void;
|
|
98
98
|
/**
|
|
99
99
|
* Show the sticky component when the other one is not sticky anymore.
|
|
100
100
|
* @this {StickyInterface}
|
|
101
101
|
*/
|
|
102
|
-
show(): void;
|
|
102
|
+
show(this: StickyInterface): void;
|
|
103
103
|
/**
|
|
104
104
|
* Set the sentinel height based on the previous instances.
|
|
105
105
|
* @this {StickyInterface}
|
|
106
106
|
*/
|
|
107
|
-
setSentinelSize(): void;
|
|
107
|
+
setSentinelSize(this: StickyInterface): void;
|
|
108
108
|
/**
|
|
109
109
|
* Set the component's position.
|
|
110
110
|
*
|
|
@@ -112,7 +112,7 @@ export default class Sticky extends Base {
|
|
|
112
112
|
* @param {number} [index] The instance index in all the pages' instances.
|
|
113
113
|
* @returns {void}
|
|
114
114
|
*/
|
|
115
|
-
setPosition(index?: number): void;
|
|
115
|
+
setPosition(this: StickyInterface, index?: number): void;
|
|
116
116
|
/**
|
|
117
117
|
* Find the first parent which has a relative position.
|
|
118
118
|
*
|
|
@@ -1,107 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
import { Base } from "@studiometa/js-toolkit";
|
|
8
|
-
import { Sentinel } from "../../primitives/index.js";
|
|
9
|
-
const _Sticky = class extends Base {
|
|
10
|
-
constructor() {
|
|
11
|
-
super(...arguments);
|
|
12
|
-
__publicField(this, "isSticky", false);
|
|
13
|
-
__publicField(this, "isVisible", true);
|
|
14
|
-
}
|
|
15
|
-
set y(value) {
|
|
16
|
-
this.$refs.inner.style.transform = `translateY(${value}px) translateZ(0px)`;
|
|
17
|
-
}
|
|
18
|
-
get instances() {
|
|
19
|
-
return Array.from(_Sticky.instances);
|
|
20
|
-
}
|
|
21
|
-
mounted() {
|
|
22
|
-
_Sticky.instances.add(this);
|
|
23
|
-
this.setSentinelSize();
|
|
24
|
-
}
|
|
25
|
-
resized() {
|
|
26
|
-
this.setSentinelSize();
|
|
27
|
-
}
|
|
28
|
-
destroyed() {
|
|
29
|
-
_Sticky.instances.delete(this);
|
|
30
|
-
}
|
|
31
|
-
scrolled(props) {
|
|
32
|
-
if (!this.isSticky || props.y === props.last.y) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if (props.direction.y === "DOWN" && this.$options.hideWhenDown || props.direction.y === "UP" && this.$options.hideWhenUp) {
|
|
36
|
-
this.hide();
|
|
37
|
-
} else {
|
|
38
|
-
this.show();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
onSentinelIntersected([entry]) {
|
|
42
|
-
this.isSticky = entry.isIntersecting && entry.boundingClientRect.y < 0;
|
|
43
|
-
this.setPosition();
|
|
44
|
-
}
|
|
45
|
-
hide() {
|
|
46
|
-
if (!this.isVisible) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
this.isVisible = false;
|
|
50
|
-
this.$el.classList.add("pointer-events-none");
|
|
51
|
-
this.instances.forEach((instance, index) => instance.setPosition(index));
|
|
52
|
-
}
|
|
53
|
-
show() {
|
|
54
|
-
if (this.isVisible) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
this.isVisible = true;
|
|
58
|
-
this.$el.classList.remove("pointer-events-none");
|
|
59
|
-
this.instances.forEach((instance, index) => instance.setPosition(index));
|
|
60
|
-
}
|
|
61
|
-
setSentinelSize() {
|
|
62
|
-
const { instances } = this;
|
|
63
|
-
const index = instances.findIndex((instance) => instance === this);
|
|
64
|
-
const height = instances.slice(0, index).filter((instance) => this.closestRelativeElement(instance.$el).contains(this.$el)).reduce((acc, instance) => acc + instance.$el.offsetHeight, 0);
|
|
65
|
-
this.$refs.sentinelRef.style.height = `${height + 1}px`;
|
|
66
|
-
this.$el.style.top = `${height}px`;
|
|
67
|
-
this.$el.style.zIndex = String(this.$options.zIndex - index);
|
|
68
|
-
}
|
|
69
|
-
setPosition(index) {
|
|
70
|
-
if (!this.isSticky) {
|
|
71
|
-
this.y = 0;
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const { instances } = this;
|
|
75
|
-
index = index != null ? index : instances.findIndex((instance) => instance === this);
|
|
76
|
-
this.y = instances.slice(0, index).filter((instance) => instance.isSticky && !instance.isVisible).reduce((y, instance) => {
|
|
77
|
-
return y - instance.$refs.inner.offsetHeight;
|
|
78
|
-
}, this.isVisible ? 0 : this.$refs.inner.offsetHeight * -1);
|
|
79
|
-
}
|
|
80
|
-
closestRelativeElement(element) {
|
|
81
|
-
let parent = element.parentElement;
|
|
82
|
-
while (getComputedStyle(parent).position !== "relative" && parent.parentElement) {
|
|
83
|
-
parent = parent.parentElement;
|
|
84
|
-
}
|
|
85
|
-
return parent;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
let Sticky = _Sticky;
|
|
89
|
-
__publicField(Sticky, "config", {
|
|
90
|
-
name: "Sticky",
|
|
91
|
-
refs: ["inner", "sentinelRef"],
|
|
92
|
-
components: {
|
|
93
|
-
Sentinel
|
|
94
|
-
},
|
|
95
|
-
options: {
|
|
96
|
-
zIndex: {
|
|
97
|
-
type: Number,
|
|
98
|
-
default: 100
|
|
99
|
-
},
|
|
100
|
-
hideWhenUp: Boolean,
|
|
101
|
-
hideWhenDown: Boolean
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
__publicField(Sticky, "instances", /* @__PURE__ */ new Set());
|
|
105
|
-
export {
|
|
106
|
-
Sticky as default
|
|
107
|
-
};
|
|
1
|
+
import{Base as o}from"@studiometa/js-toolkit";import{Sentinel as h}from"../../primitives/index.js";class n extends o{static config={name:"Sticky",refs:["inner","sentinelRef"],components:{Sentinel:h},options:{zIndex:{type:Number,default:100},hideWhenUp:Boolean,hideWhenDown:Boolean}};static instances=new Set;isSticky=!1;isVisible=!0;set y(e){this.$refs.inner.style.transform=`translateY(${e}px) translateZ(0px)`}get instances(){return Array.from(n.instances)}mounted(){n.instances.add(this),this.setSentinelSize()}resized(){this.setSentinelSize()}destroyed(){n.instances.delete(this)}scrolled(e){!this.isSticky||e.y===e.last.y||(e.direction.y==="DOWN"&&this.$options.hideWhenDown||e.direction.y==="UP"&&this.$options.hideWhenUp?this.hide():this.show())}onSentinelIntersected([e]){this.isSticky=e.isIntersecting&&e.boundingClientRect.y<0,this.setPosition()}hide(){!this.isVisible||(this.isVisible=!1,this.$el.classList.add("pointer-events-none"),this.instances.forEach((e,t)=>e.setPosition(t)))}show(){this.isVisible||(this.isVisible=!0,this.$el.classList.remove("pointer-events-none"),this.instances.forEach((e,t)=>e.setPosition(t)))}setSentinelSize(){const{instances:e}=this,t=e.findIndex(s=>s===this),i=e.slice(0,t).filter(s=>this.closestRelativeElement(s.$el).contains(this.$el)).reduce((s,l)=>s+l.$el.offsetHeight,0);this.$refs.sentinelRef.style.height=`${i+1}px`,this.$el.style.top=`${i}px`,this.$el.style.zIndex=String(this.$options.zIndex-t)}setPosition(e){if(!this.isSticky){this.y=0;return}const{instances:t}=this;e=e??t.findIndex(i=>i===this),this.y=t.slice(0,e).filter(i=>i.isSticky&&!i.isVisible).reduce((i,s)=>i-s.$refs.inner.offsetHeight,this.isVisible?0:this.$refs.inner.offsetHeight*-1)}closestRelativeElement(e){let t=e.parentElement;for(;getComputedStyle(t).position!=="relative"&&t.parentElement;)t=t.parentElement;return t}}export{n as default};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __publicField = (obj, key, value) => {
|
|
23
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// packages/ui/molecules/TableOfContent/TableOfContent.js
|
|
28
|
+
var TableOfContent_exports = {};
|
|
29
|
+
__export(TableOfContent_exports, {
|
|
30
|
+
default: () => TableOfContent
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(TableOfContent_exports);
|
|
33
|
+
var import_js_toolkit = require("@studiometa/js-toolkit");
|
|
34
|
+
var import_TableOfContentAnchor = __toESM(require("./TableOfContentAnchor.cjs"), 1);
|
|
35
|
+
var TableOfContent = class extends import_js_toolkit.Base {
|
|
36
|
+
mounted() {
|
|
37
|
+
if (this.$options.withTemplate) {
|
|
38
|
+
this.generateAnchors();
|
|
39
|
+
this.$update();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
generateAnchors() {
|
|
43
|
+
document.querySelectorAll(this.$options.contentSelector).forEach((section) => {
|
|
44
|
+
const tpl = document.createElement("div");
|
|
45
|
+
tpl.innerHTML = this.$refs.itemTemplate.innerHTML;
|
|
46
|
+
const li = tpl.querySelector("li");
|
|
47
|
+
const anchor = li.querySelector("a");
|
|
48
|
+
anchor.href = `#${section.id}`;
|
|
49
|
+
anchor.innerHTML = section.textContent;
|
|
50
|
+
anchor.dataset.component = "TableOfContentAnchor";
|
|
51
|
+
this.$refs.list.appendChild(li);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
__publicField(TableOfContent, "config", {
|
|
56
|
+
name: "TableOfContent",
|
|
57
|
+
refs: ["itemTemplate", "list"],
|
|
58
|
+
components: {
|
|
59
|
+
TableOfContentAnchor: import_TableOfContentAnchor.default
|
|
60
|
+
},
|
|
61
|
+
options: {
|
|
62
|
+
contentSelector: String,
|
|
63
|
+
withTemplate: Boolean
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {TableOfContent & {
|
|
3
|
+
* $refs: {
|
|
4
|
+
* itemTemplate: HTMLTemplateElement,
|
|
5
|
+
* list: HTMLUListElement
|
|
6
|
+
* },
|
|
7
|
+
* $options: {
|
|
8
|
+
* contentSelector: string,
|
|
9
|
+
* withTemplate: boolean,
|
|
10
|
+
* }
|
|
11
|
+
* }} TableOfContentInterface
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* TableOfContent class.
|
|
15
|
+
*/
|
|
16
|
+
export default class TableOfContent extends Base {
|
|
17
|
+
/**
|
|
18
|
+
* Config.
|
|
19
|
+
*/
|
|
20
|
+
static config: {
|
|
21
|
+
name: string;
|
|
22
|
+
refs: string[];
|
|
23
|
+
components: {
|
|
24
|
+
TableOfContentAnchor: typeof TableOfContentAnchor;
|
|
25
|
+
};
|
|
26
|
+
options: {
|
|
27
|
+
contentSelector: StringConstructor;
|
|
28
|
+
withTemplate: BooleanConstructor;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Generate anchors on mount and update the component to instantiate the
|
|
33
|
+
* `TableOfContentAnchor` components.
|
|
34
|
+
* @returns {void}
|
|
35
|
+
*/
|
|
36
|
+
mounted(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Generate all anchors.
|
|
39
|
+
*
|
|
40
|
+
* @todo Read anchor template from a ref?
|
|
41
|
+
* @todo Better API to easily override the template function, maybe a `render` function?
|
|
42
|
+
*
|
|
43
|
+
* @this {TableOfContentInterface}
|
|
44
|
+
* @returns {void}
|
|
45
|
+
*/
|
|
46
|
+
generateAnchors(this: TableOfContentInterface): void;
|
|
47
|
+
}
|
|
48
|
+
export type TableOfContentInterface = TableOfContent & {
|
|
49
|
+
$refs: {
|
|
50
|
+
itemTemplate: HTMLTemplateElement;
|
|
51
|
+
list: HTMLUListElement;
|
|
52
|
+
};
|
|
53
|
+
$options: {
|
|
54
|
+
contentSelector: string;
|
|
55
|
+
withTemplate: boolean;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
import { Base } from "@studiometa/js-toolkit";
|
|
59
|
+
import TableOfContentAnchor from "./TableOfContentAnchor.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Base as r}from"@studiometa/js-toolkit";import i from"./TableOfContentAnchor.js";class l extends r{static config={name:"TableOfContent",refs:["itemTemplate","list"],components:{TableOfContentAnchor:i},options:{contentSelector:String,withTemplate:Boolean}};mounted(){this.$options.withTemplate&&(this.generateAnchors(),this.$update())}generateAnchors(){document.querySelectorAll(this.$options.contentSelector).forEach(t=>{const n=document.createElement("div");n.innerHTML=this.$refs.itemTemplate.innerHTML;const o=n.querySelector("li"),e=o.querySelector("a");e.href=`#${t.id}`,e.innerHTML=t.textContent,e.dataset.component="TableOfContentAnchor",this.$refs.list.appendChild(o)})}}export{l as default};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __publicField = (obj, key, value) => {
|
|
20
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// packages/ui/molecules/TableOfContent/TableOfContentAnchor.js
|
|
25
|
+
var TableOfContentAnchor_exports = {};
|
|
26
|
+
__export(TableOfContentAnchor_exports, {
|
|
27
|
+
default: () => TableOfContentAnchor
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(TableOfContentAnchor_exports);
|
|
30
|
+
var import_atoms = require("../../atoms/index.cjs");
|
|
31
|
+
var TableOfContentAnchor = class extends import_atoms.AnchorScrollTo {
|
|
32
|
+
get sentinel() {
|
|
33
|
+
return document.querySelector(this.targetSelector);
|
|
34
|
+
}
|
|
35
|
+
mounted() {
|
|
36
|
+
if (!this.sentinel) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
this.observer = new IntersectionObserver(([entry]) => {
|
|
40
|
+
const shouldActivate = entry.isIntersecting && entry.boundingClientRect.y < 100 && entry.boundingClientRect.y > 100;
|
|
41
|
+
this.$el.classList.toggle(this.$options.activeClass, shouldActivate);
|
|
42
|
+
this.$emit("should-activate", shouldActivate);
|
|
43
|
+
});
|
|
44
|
+
this.observer.observe(this.sentinel);
|
|
45
|
+
}
|
|
46
|
+
destroyed() {
|
|
47
|
+
this.observer.disconnect();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
__publicField(TableOfContentAnchor, "config", {
|
|
51
|
+
name: "TableOfContentAnchor",
|
|
52
|
+
emits: ["should-activate"],
|
|
53
|
+
options: {
|
|
54
|
+
activeClass: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: "is-active"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TableOfContentAnchor class.
|
|
3
|
+
*/
|
|
4
|
+
export default class TableOfContentAnchor extends AnchorScrollTo {
|
|
5
|
+
/**
|
|
6
|
+
* Config.
|
|
7
|
+
*/
|
|
8
|
+
static config: {
|
|
9
|
+
name: string;
|
|
10
|
+
emits: string[];
|
|
11
|
+
options: {
|
|
12
|
+
activeClass: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Get the sentinel.
|
|
20
|
+
* @returns {HTMLElement}
|
|
21
|
+
*/
|
|
22
|
+
get sentinel(): HTMLElement;
|
|
23
|
+
/**
|
|
24
|
+
* Init observer on mount.
|
|
25
|
+
* @returns {void}
|
|
26
|
+
*/
|
|
27
|
+
mounted(): void;
|
|
28
|
+
observer: IntersectionObserver;
|
|
29
|
+
/**
|
|
30
|
+
* Destroy observer on destroy.
|
|
31
|
+
*
|
|
32
|
+
* @returns {void}
|
|
33
|
+
*/
|
|
34
|
+
destroyed(): void;
|
|
35
|
+
}
|
|
36
|
+
import { AnchorScrollTo } from "../../atoms/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{AnchorScrollTo as s}from"../../atoms/index.js";class i extends s{static config={name:"TableOfContentAnchor",emits:["should-activate"],options:{activeClass:{type:String,default:"is-active"}}};get sentinel(){return document.querySelector(this.targetSelector)}mounted(){!this.sentinel||(this.observer=new IntersectionObserver(([e])=>{const t=e.isIntersecting&&e.boundingClientRect.y<100&&e.boundingClientRect.y>100;this.$el.classList.toggle(this.$options.activeClass,t),this.$emit("should-activate",t)}),this.observer.observe(this.sentinel))}destroyed(){this.observer.disconnect()}}export{i as default};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// packages/ui/molecules/TableOfContent/index.js
|
|
23
|
+
var TableOfContent_exports = {};
|
|
24
|
+
__export(TableOfContent_exports, {
|
|
25
|
+
TableOfContent: () => import_TableOfContent.default,
|
|
26
|
+
TableOfContentAnchor: () => import_TableOfContentAnchor.default
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(TableOfContent_exports);
|
|
29
|
+
var import_TableOfContent = __toESM(require("./TableOfContent.cjs"), 1);
|
|
30
|
+
var import_TableOfContentAnchor = __toESM(require("./TableOfContentAnchor.cjs"), 1);
|
|
31
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as o}from"./TableOfContent.js";import{default as f}from"./TableOfContentAnchor.js";export{o as TableOfContent,f as TableOfContentAnchor};
|