@studiometa/ui 0.2.47 → 0.2.49
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/Button/Button.twig +15 -5
- package/atoms/FigureVideo/FigureVideo.cjs +132 -0
- package/atoms/FigureVideo/FigureVideo.cjs.map +7 -0
- package/atoms/FigureVideo/FigureVideo.d.ts +51 -0
- package/atoms/FigureVideo/FigureVideo.js +110 -0
- package/atoms/FigureVideo/FigureVideo.js.map +7 -0
- package/atoms/FigureVideo/FigureVideo.twig +152 -0
- package/atoms/FigureVideo/FigureVideoTwicpics.cjs +153 -0
- package/atoms/FigureVideo/FigureVideoTwicpics.cjs.map +7 -0
- package/atoms/FigureVideo/FigureVideoTwicpics.d.ts +57 -0
- package/atoms/FigureVideo/FigureVideoTwicpics.js +135 -0
- package/atoms/FigureVideo/FigureVideoTwicpics.js.map +7 -0
- package/atoms/FigureVideo/FigureVideoTwicpics.twig +98 -0
- package/atoms/FigureVideo/index.cjs +22 -0
- package/atoms/FigureVideo/index.cjs.map +7 -0
- package/atoms/FigureVideo/index.d.ts +2 -0
- package/atoms/FigureVideo/index.js +3 -0
- package/atoms/FigureVideo/index.js.map +7 -0
- package/atoms/Icon/IconInline.twig +11 -4
- package/atoms/Icon/IconInlineImg.twig +44 -41
- package/atoms/index.cjs +1 -0
- package/atoms/index.cjs.map +2 -2
- package/atoms/index.d.ts +1 -0
- package/atoms/index.js +1 -0
- package/atoms/index.js.map +2 -2
- package/molecules/AnchorNav/AnchorNav.cjs +63 -0
- package/molecules/AnchorNav/AnchorNav.cjs.map +7 -0
- package/molecules/AnchorNav/AnchorNav.d.ts +24 -0
- package/molecules/AnchorNav/AnchorNav.js +41 -0
- package/molecules/AnchorNav/AnchorNav.js.map +7 -0
- package/molecules/AnchorNav/AnchorNavLink.cjs +40 -0
- package/molecules/AnchorNav/AnchorNavLink.cjs.map +7 -0
- package/molecules/AnchorNav/AnchorNavLink.d.ts +19 -0
- package/molecules/AnchorNav/AnchorNavLink.js +18 -0
- package/molecules/AnchorNav/AnchorNavLink.js.map +7 -0
- package/molecules/AnchorNav/AnchorNavTarget.cjs +35 -0
- package/molecules/AnchorNav/AnchorNavTarget.cjs.map +7 -0
- package/molecules/AnchorNav/AnchorNavTarget.d.ts +13 -0
- package/molecules/AnchorNav/AnchorNavTarget.js +13 -0
- package/molecules/AnchorNav/AnchorNavTarget.js.map +7 -0
- package/molecules/AnchorNav/index.cjs +23 -0
- package/molecules/AnchorNav/index.cjs.map +7 -0
- package/molecules/AnchorNav/index.d.ts +3 -0
- package/molecules/AnchorNav/index.js +4 -0
- package/molecules/AnchorNav/index.js.map +7 -0
- package/molecules/IconList/IconList.twig +83 -0
- package/molecules/index.cjs +1 -0
- package/molecules/index.cjs.map +2 -2
- package/molecules/index.d.ts +1 -0
- package/molecules/index.js +1 -0
- package/molecules/index.js.map +2 -2
- package/organisms/Frame/Frame.cjs +20 -7
- package/organisms/Frame/Frame.cjs.map +3 -3
- package/organisms/Frame/Frame.d.ts +2 -2
- package/organisms/Frame/Frame.js +20 -7
- package/organisms/Frame/Frame.js.map +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Base } from "@studiometa/js-toolkit";
|
|
2
|
+
import { AnchorNavLink } from "./AnchorNavLink.js";
|
|
3
|
+
import { AnchorNavTarget } from "./AnchorNavTarget.js";
|
|
4
|
+
class AnchorNav extends Base {
|
|
5
|
+
/**
|
|
6
|
+
* Config
|
|
7
|
+
*/
|
|
8
|
+
static config = {
|
|
9
|
+
name: "AnchorNav",
|
|
10
|
+
components: {
|
|
11
|
+
AnchorNavLink,
|
|
12
|
+
AnchorNavTarget
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Listen to the AnchorNavTarget that is mounted
|
|
17
|
+
*/
|
|
18
|
+
onAnchorNavTargetMounted(index) {
|
|
19
|
+
const { id } = this.$children.AnchorNavTarget[index].$el;
|
|
20
|
+
this.$children.AnchorNavLink.forEach((anchorNavLink) => {
|
|
21
|
+
if (id === anchorNavLink.targetId) {
|
|
22
|
+
anchorNavLink.enter();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Listen to the AnchorNavTarget that is destroyed
|
|
28
|
+
*/
|
|
29
|
+
onAnchorNavTargetDestroyed(index) {
|
|
30
|
+
const { id } = this.$children.AnchorNavTarget[index].$el;
|
|
31
|
+
this.$children.AnchorNavLink.forEach((anchorNavLink) => {
|
|
32
|
+
if (id === anchorNavLink.targetId) {
|
|
33
|
+
anchorNavLink.leave();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
AnchorNav
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=AnchorNav.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/ui/molecules/AnchorNav/AnchorNav.ts"],
|
|
4
|
+
"sourcesContent": ["import { Base } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';\nimport { AnchorNavLink } from './AnchorNavLink.js';\nimport { AnchorNavTarget } from './AnchorNavTarget.js';\n\nexport interface AnchorNavProps extends BaseProps {\n $children: {\n AnchorNavLink: AnchorNavLink[];\n AnchorNavTarget: AnchorNavTarget[];\n };\n}\n\nexport class AnchorNav<T extends BaseProps = BaseProps> extends Base<T & AnchorNavProps> {\n /**\n * Config\n */\n static config: BaseConfig = {\n name: 'AnchorNav',\n components: {\n AnchorNavLink,\n AnchorNavTarget,\n },\n };\n\n /**\n * Listen to the AnchorNavTarget that is mounted\n */\n onAnchorNavTargetMounted(index) {\n const { id } = this.$children.AnchorNavTarget[index].$el;\n this.$children.AnchorNavLink.forEach((anchorNavLink) => {\n if (id === anchorNavLink.targetId) {\n anchorNavLink.enter();\n }\n });\n }\n\n /**\n * Listen to the AnchorNavTarget that is destroyed\n */\n onAnchorNavTargetDestroyed(index) {\n const { id } = this.$children.AnchorNavTarget[index].$el;\n this.$children.AnchorNavLink.forEach((anchorNavLink) => {\n if (id === anchorNavLink.targetId) {\n anchorNavLink.leave();\n }\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY;AAErB,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AASzB,MAAM,kBAAmD,KAAyB;AAAA;AAAA;AAAA;AAAA,EAIvF,OAAO,SAAqB;AAAA,IAC1B,MAAM;AAAA,IACN,YAAY;AAAA,MACV;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,yBAAyB,OAAO;AAC9B,UAAM,EAAE,GAAG,IAAI,KAAK,UAAU,gBAAgB,KAAK,EAAE;AACrD,SAAK,UAAU,cAAc,QAAQ,CAAC,kBAAkB;AACtD,UAAI,OAAO,cAAc,UAAU;AACjC,sBAAc,MAAM;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,2BAA2B,OAAO;AAChC,UAAM,EAAE,GAAG,IAAI,KAAK,UAAU,gBAAgB,KAAK,EAAE;AACrD,SAAK,UAAU,cAAc,QAAQ,CAAC,kBAAkB;AACtD,UAAI,OAAO,cAAc,UAAU;AACjC,sBAAc,MAAM;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/ui/molecules/AnchorNav/AnchorNavLink.ts
|
|
20
|
+
var AnchorNavLink_exports = {};
|
|
21
|
+
__export(AnchorNavLink_exports, {
|
|
22
|
+
AnchorNavLink: () => AnchorNavLink
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(AnchorNavLink_exports);
|
|
25
|
+
var import_AnchorScrollTo = require("../../atoms/AnchorScrollTo/AnchorScrollTo.cjs");
|
|
26
|
+
var import_decorators = require("../../decorators/index.cjs");
|
|
27
|
+
var AnchorNavLink = class extends (0, import_decorators.withTransition)(import_AnchorScrollTo.AnchorScrollTo) {
|
|
28
|
+
/**
|
|
29
|
+
* Config.
|
|
30
|
+
*/
|
|
31
|
+
static config = {
|
|
32
|
+
...import_AnchorScrollTo.AnchorScrollTo.config,
|
|
33
|
+
name: "AnchorNavLink"
|
|
34
|
+
};
|
|
35
|
+
get targetId() {
|
|
36
|
+
return this.$el.hash.replace(/^#/, "");
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
40
|
+
//# sourceMappingURL=AnchorNavLink.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/ui/molecules/AnchorNav/AnchorNavLink.ts"],
|
|
4
|
+
"sourcesContent": ["import type { BaseConfig } from '@studiometa/js-toolkit';\nimport { AnchorScrollTo, AnchorScrollToProps } from '../../atoms/AnchorScrollTo/AnchorScrollTo.js';\nimport { withTransition } from '../../decorators/index.js';\n\nexport interface AnchorNavLinkProps extends AnchorScrollToProps {\n $options: {\n id: string;\n };\n}\n\n/**\n * Manage a slider item and its state transition.\n */\nexport class AnchorNavLink extends withTransition(AnchorScrollTo)<AnchorNavLinkProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...AnchorScrollTo.config,\n name: 'AnchorNavLink',\n };\n\n get targetId() {\n return this.$el.hash.replace(/^#/, '');\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4BAAoD;AACpD,wBAA+B;AAWxB,IAAM,gBAAN,kBAA4B,kCAAe,oCAAc,EAAsB;AAAA;AAAA;AAAA;AAAA,EAIpF,OAAO,SAAqB;AAAA,IAC1B,GAAG,qCAAe;AAAA,IAClB,MAAM;AAAA,EACR;AAAA,EAEA,IAAI,WAAW;AACb,WAAO,KAAK,IAAI,KAAK,QAAQ,MAAM,EAAE;AAAA,EACvC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BaseConfig } from '@studiometa/js-toolkit';
|
|
2
|
+
import { AnchorScrollToProps } from '../../atoms/AnchorScrollTo/AnchorScrollTo.js';
|
|
3
|
+
export interface AnchorNavLinkProps extends AnchorScrollToProps {
|
|
4
|
+
$options: {
|
|
5
|
+
id: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
declare const AnchorNavLink_base: import("@studiometa/js-toolkit").BaseDecorator<import("decorators/withTransition.js").TransitionInterface, import("@studiometa/js-toolkit").Base<import("@studiometa/js-toolkit").BaseProps>, import("decorators/withTransition.js").TransitionProps>;
|
|
9
|
+
/**
|
|
10
|
+
* Manage a slider item and its state transition.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AnchorNavLink extends AnchorNavLink_base<AnchorNavLinkProps> {
|
|
13
|
+
/**
|
|
14
|
+
* Config.
|
|
15
|
+
*/
|
|
16
|
+
static config: BaseConfig;
|
|
17
|
+
get targetId(): string;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AnchorScrollTo } from "../../atoms/AnchorScrollTo/AnchorScrollTo.js";
|
|
2
|
+
import { withTransition } from "../../decorators/index.js";
|
|
3
|
+
class AnchorNavLink extends withTransition(AnchorScrollTo) {
|
|
4
|
+
/**
|
|
5
|
+
* Config.
|
|
6
|
+
*/
|
|
7
|
+
static config = {
|
|
8
|
+
...AnchorScrollTo.config,
|
|
9
|
+
name: "AnchorNavLink"
|
|
10
|
+
};
|
|
11
|
+
get targetId() {
|
|
12
|
+
return this.$el.hash.replace(/^#/, "");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
AnchorNavLink
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=AnchorNavLink.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/ui/molecules/AnchorNav/AnchorNavLink.ts"],
|
|
4
|
+
"sourcesContent": ["import type { BaseConfig } from '@studiometa/js-toolkit';\nimport { AnchorScrollTo, AnchorScrollToProps } from '../../atoms/AnchorScrollTo/AnchorScrollTo.js';\nimport { withTransition } from '../../decorators/index.js';\n\nexport interface AnchorNavLinkProps extends AnchorScrollToProps {\n $options: {\n id: string;\n };\n}\n\n/**\n * Manage a slider item and its state transition.\n */\nexport class AnchorNavLink extends withTransition(AnchorScrollTo)<AnchorNavLinkProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...AnchorScrollTo.config,\n name: 'AnchorNavLink',\n };\n\n get targetId() {\n return this.$el.hash.replace(/^#/, '');\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,sBAA2C;AACpD,SAAS,sBAAsB;AAWxB,MAAM,sBAAsB,eAAe,cAAc,EAAsB;AAAA;AAAA;AAAA;AAAA,EAIpF,OAAO,SAAqB;AAAA,IAC1B,GAAG,eAAe;AAAA,IAClB,MAAM;AAAA,EACR;AAAA,EAEA,IAAI,WAAW;AACb,WAAO,KAAK,IAAI,KAAK,QAAQ,MAAM,EAAE;AAAA,EACvC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/ui/molecules/AnchorNav/AnchorNavTarget.ts
|
|
20
|
+
var AnchorNavTarget_exports = {};
|
|
21
|
+
__export(AnchorNavTarget_exports, {
|
|
22
|
+
AnchorNavTarget: () => AnchorNavTarget
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(AnchorNavTarget_exports);
|
|
25
|
+
var import_js_toolkit = require("@studiometa/js-toolkit");
|
|
26
|
+
var AnchorNavTarget = class extends (0, import_js_toolkit.withMountWhenInView)(import_js_toolkit.Base) {
|
|
27
|
+
/**
|
|
28
|
+
* Config.
|
|
29
|
+
*/
|
|
30
|
+
static config = {
|
|
31
|
+
name: "AnchorNavTarget"
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
35
|
+
//# sourceMappingURL=AnchorNavTarget.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/ui/molecules/AnchorNav/AnchorNavTarget.ts"],
|
|
4
|
+
"sourcesContent": ["import { Base, withMountWhenInView } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';\n\n/**\n * Manage a sticky table section.\n */\nexport class AnchorNavTarget extends withMountWhenInView(Base)<BaseProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'AnchorNavTarget',\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA0C;AAMnC,IAAM,kBAAN,kBAA8B,uCAAoB,sBAAI,EAAa;AAAA;AAAA;AAAA;AAAA,EAIxE,OAAO,SAAqB;AAAA,IAC1B,MAAM;AAAA,EACR;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Base } from '@studiometa/js-toolkit';
|
|
2
|
+
import type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';
|
|
3
|
+
declare const AnchorNavTarget_base: import("@studiometa/js-toolkit").BaseDecorator<import("@studiometa/js-toolkit").WithMountWhenInViewInterface, Base<BaseProps>, import("@studiometa/js-toolkit").WithMountWhenInViewProps>;
|
|
4
|
+
/**
|
|
5
|
+
* Manage a sticky table section.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AnchorNavTarget extends AnchorNavTarget_base<BaseProps> {
|
|
8
|
+
/**
|
|
9
|
+
* Config.
|
|
10
|
+
*/
|
|
11
|
+
static config: BaseConfig;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Base, withMountWhenInView } from "@studiometa/js-toolkit";
|
|
2
|
+
class AnchorNavTarget extends withMountWhenInView(Base) {
|
|
3
|
+
/**
|
|
4
|
+
* Config.
|
|
5
|
+
*/
|
|
6
|
+
static config = {
|
|
7
|
+
name: "AnchorNavTarget"
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
AnchorNavTarget
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=AnchorNavTarget.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/ui/molecules/AnchorNav/AnchorNavTarget.ts"],
|
|
4
|
+
"sourcesContent": ["import { Base, withMountWhenInView } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';\n\n/**\n * Manage a sticky table section.\n */\nexport class AnchorNavTarget extends withMountWhenInView(Base)<BaseProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'AnchorNavTarget',\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,MAAM,2BAA2B;AAMnC,MAAM,wBAAwB,oBAAoB,IAAI,EAAa;AAAA;AAAA;AAAA;AAAA,EAIxE,OAAO,SAAqB;AAAA,IAC1B,MAAM;AAAA,EACR;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// packages/ui/molecules/AnchorNav/index.ts
|
|
17
|
+
var AnchorNav_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(AnchorNav_exports);
|
|
19
|
+
__reExport(AnchorNav_exports, require("./AnchorNav.cjs"), module.exports);
|
|
20
|
+
__reExport(AnchorNav_exports, require("./AnchorNavLink.cjs"), module.exports);
|
|
21
|
+
__reExport(AnchorNav_exports, require("./AnchorNavTarget.cjs"), module.exports);
|
|
22
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
23
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/ui/molecules/AnchorNav/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './AnchorNav.js';\nexport * from './AnchorNavLink.js';\nexport * from './AnchorNavTarget.js';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,8BAAc,4BAAd;AACA,8BAAc,gCADd;AAEA,8BAAc,kCAFd;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../packages/ui/molecules/AnchorNav/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './AnchorNav.js';\nexport * from './AnchorNavLink.js';\nexport * from './AnchorNavTarget.js';\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{#
|
|
2
|
+
/**
|
|
3
|
+
* @file
|
|
4
|
+
* Icon list component.
|
|
5
|
+
*
|
|
6
|
+
* @param array $attr Shorthand of $list_attr.
|
|
7
|
+
* @param array $list_attr List attributes.
|
|
8
|
+
* @param array $item_attr List item attributes.
|
|
9
|
+
* @param array $icon_attr Icon attibutes.
|
|
10
|
+
* @param array $action_attr Action attributes.
|
|
11
|
+
* @param string $action_tag Action tag.
|
|
12
|
+
* @param array $items Items:
|
|
13
|
+
* - Use the icon name in key and the url in value for each entry of this array.
|
|
14
|
+
* - You can pass an array instead of the url to pass custom attributes to the action.
|
|
15
|
+
*
|
|
16
|
+
* @block $item
|
|
17
|
+
* Use this block to override the component behavior inside the list items.
|
|
18
|
+
* @block $icon
|
|
19
|
+
* Use this block to override the icons.
|
|
20
|
+
*/
|
|
21
|
+
#}
|
|
22
|
+
|
|
23
|
+
{% set list_attributes =
|
|
24
|
+
merge_html_attributes(
|
|
25
|
+
attr ?? list_attr ?? null,
|
|
26
|
+
{ class: ['flex justify-start items-center gap-3'] }
|
|
27
|
+
)
|
|
28
|
+
%}
|
|
29
|
+
|
|
30
|
+
{% set item_attributes = merge_html_attributes(item_attr ?? null, {}) %}
|
|
31
|
+
|
|
32
|
+
{% set icon_attributes = merge_html_attributes(icon_attr ?? null, { class: 'flex items-center' }) %}
|
|
33
|
+
|
|
34
|
+
<ul {{ html_attributes(list_attributes) }}>
|
|
35
|
+
{% for name, value in items %}
|
|
36
|
+
{%- set rendered_icon -%}
|
|
37
|
+
{%- block icon -%}
|
|
38
|
+
{%- include '@ui/atoms/Icon/IconInline.twig' with {
|
|
39
|
+
name: name,
|
|
40
|
+
attr: icon_attributes,
|
|
41
|
+
ignore_missing: true
|
|
42
|
+
} only -%}
|
|
43
|
+
{%- endblock -%}
|
|
44
|
+
{%- endset -%}
|
|
45
|
+
|
|
46
|
+
{% if rendered_icon is not empty %}
|
|
47
|
+
{% if value is iterable %}
|
|
48
|
+
{% set href = value.attr.href ?? value.href ?? null %}
|
|
49
|
+
{% set label = value.attr.label ?? value.label ?? (name|capitalize) %}
|
|
50
|
+
{% set title = value.attr.title ?? value.title %}
|
|
51
|
+
{% set tag = value.tag
|
|
52
|
+
?? (action_tag|default(href is defined and href is not null ? 'a' : 'button'))
|
|
53
|
+
%}
|
|
54
|
+
{% set current_attr = merge_html_attributes(value.attr ?? {}, action_attr) %}
|
|
55
|
+
{% else %}
|
|
56
|
+
{% set href = value %}
|
|
57
|
+
{% set label = name|capitalize %}
|
|
58
|
+
{% set tag = action_tag|default('a') %}
|
|
59
|
+
{% set current_attr = action_attr %}
|
|
60
|
+
{% endif %}
|
|
61
|
+
|
|
62
|
+
{% set action_attributes =
|
|
63
|
+
merge_html_attributes(
|
|
64
|
+
current_attr ?? null,
|
|
65
|
+
{
|
|
66
|
+
title: title ?? label,
|
|
67
|
+
aria_label: label,
|
|
68
|
+
class: 'block p-1 hover:opacity-80 cursor-pointer'
|
|
69
|
+
}|merge(tag == 'button' ? { type: 'button' } : { href: href })
|
|
70
|
+
)
|
|
71
|
+
%}
|
|
72
|
+
|
|
73
|
+
<li {{ html_attributes(item_attributes) }}>
|
|
74
|
+
{% block item %}
|
|
75
|
+
{% html_element tag with action_attributes %}
|
|
76
|
+
{{ rendered_icon }}
|
|
77
|
+
<span class="sr-only">{{ label }}</span>
|
|
78
|
+
{% end_html_element %}
|
|
79
|
+
{% endblock %}
|
|
80
|
+
</li>
|
|
81
|
+
{% endif %}
|
|
82
|
+
{% endfor %}
|
|
83
|
+
</ul>
|
package/molecules/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ __reExport(molecules_exports, require("./Accordion/AccordionItem.cjs"), module.e
|
|
|
21
21
|
__reExport(molecules_exports, require("./Menu/index.cjs"), module.exports);
|
|
22
22
|
__reExport(molecules_exports, require("./Slider/index.cjs"), module.exports);
|
|
23
23
|
__reExport(molecules_exports, require("./Sticky/Sticky.cjs"), module.exports);
|
|
24
|
+
__reExport(molecules_exports, require("./AnchorNav/index.cjs"), module.exports);
|
|
24
25
|
__reExport(molecules_exports, require("./TableOfContent/index.cjs"), module.exports);
|
|
25
26
|
__reExport(molecules_exports, require("./Tabs/index.cjs"), module.exports);
|
|
26
27
|
__reExport(molecules_exports, require("./Modal/index.cjs"), module.exports);
|
package/molecules/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/ui/molecules/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Accordion/Accordion.js';\nexport * from './Accordion/AccordionItem.js';\nexport * from './Menu/index.js';\nexport * from './Slider/index.js';\nexport * from './Sticky/Sticky.js';\nexport * from './TableOfContent/index.js';\nexport * from './Tabs/index.js';\nexport * from './Modal/index.js';\nexport * from './Panel/index.js';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,8BAAc,sCAAd;AACA,8BAAc,0CADd;AAEA,8BAAc,6BAFd;AAGA,8BAAc,+BAHd;AAIA,8BAAc,gCAJd;AAKA,8BAAc,
|
|
4
|
+
"sourcesContent": ["export * from './Accordion/Accordion.js';\nexport * from './Accordion/AccordionItem.js';\nexport * from './Menu/index.js';\nexport * from './Slider/index.js';\nexport * from './Sticky/Sticky.js';\nexport * from './AnchorNav/index.js';\nexport * from './TableOfContent/index.js';\nexport * from './Tabs/index.js';\nexport * from './Modal/index.js';\nexport * from './Panel/index.js';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,8BAAc,sCAAd;AACA,8BAAc,0CADd;AAEA,8BAAc,6BAFd;AAGA,8BAAc,+BAHd;AAIA,8BAAc,gCAJd;AAKA,8BAAc,kCALd;AAMA,8BAAc,uCANd;AAOA,8BAAc,6BAPd;AAQA,8BAAc,8BARd;AASA,8BAAc,8BATd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/molecules/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './Accordion/AccordionItem.js';
|
|
|
3
3
|
export * from './Menu/index.js';
|
|
4
4
|
export * from './Slider/index.js';
|
|
5
5
|
export * from './Sticky/Sticky.js';
|
|
6
|
+
export * from './AnchorNav/index.js';
|
|
6
7
|
export * from './TableOfContent/index.js';
|
|
7
8
|
export * from './Tabs/index.js';
|
|
8
9
|
export * from './Modal/index.js';
|
package/molecules/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./Accordion/AccordionItem.js";
|
|
|
3
3
|
export * from "./Menu/index.js";
|
|
4
4
|
export * from "./Slider/index.js";
|
|
5
5
|
export * from "./Sticky/Sticky.js";
|
|
6
|
+
export * from "./AnchorNav/index.js";
|
|
6
7
|
export * from "./TableOfContent/index.js";
|
|
7
8
|
export * from "./Tabs/index.js";
|
|
8
9
|
export * from "./Modal/index.js";
|
package/molecules/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/ui/molecules/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Accordion/Accordion.js';\nexport * from './Accordion/AccordionItem.js';\nexport * from './Menu/index.js';\nexport * from './Slider/index.js';\nexport * from './Sticky/Sticky.js';\nexport * from './TableOfContent/index.js';\nexport * from './Tabs/index.js';\nexport * from './Modal/index.js';\nexport * from './Panel/index.js';\n"],
|
|
5
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
4
|
+
"sourcesContent": ["export * from './Accordion/Accordion.js';\nexport * from './Accordion/AccordionItem.js';\nexport * from './Menu/index.js';\nexport * from './Slider/index.js';\nexport * from './Sticky/Sticky.js';\nexport * from './AnchorNav/index.js';\nexport * from './TableOfContent/index.js';\nexport * from './Tabs/index.js';\nexport * from './Modal/index.js';\nexport * from './Panel/index.js';\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -92,7 +92,7 @@ var Frame = class _Frame extends import_js_toolkit.Base {
|
|
|
92
92
|
* Go to the previous URL on `popstate` event.
|
|
93
93
|
*/
|
|
94
94
|
onWindowPopstate(event) {
|
|
95
|
-
this.goTo(window.location.href, event.state);
|
|
95
|
+
this.goTo(window.location.href, null, event.state);
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
* Prevent click on `FrameAnchor`.
|
|
@@ -120,8 +120,13 @@ var Frame = class _Frame extends import_js_toolkit.Base {
|
|
|
120
120
|
event.preventDefault();
|
|
121
121
|
const form = this.$children.FrameForm[index];
|
|
122
122
|
const url = new URL(form.action);
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
if (form.$el.method === "get") {
|
|
124
|
+
url.search = new URLSearchParams(new FormData(form.$el)).toString();
|
|
125
|
+
this.goTo(url.toString());
|
|
126
|
+
}
|
|
127
|
+
if (form.$el.method === "post") {
|
|
128
|
+
this.goTo(url.toString(), new FormData(form.$el));
|
|
129
|
+
}
|
|
125
130
|
}
|
|
126
131
|
/**
|
|
127
132
|
* Parge an HTML string into a DOM object.
|
|
@@ -132,14 +137,14 @@ var Frame = class _Frame extends import_js_toolkit.Base {
|
|
|
132
137
|
/**
|
|
133
138
|
* Go to the given url.
|
|
134
139
|
*/
|
|
135
|
-
async goTo(url, scroll = null) {
|
|
140
|
+
async goTo(url, formData = null, scroll = null) {
|
|
136
141
|
this.$log("goTo", url);
|
|
137
142
|
const parsedUrl = new URL(url);
|
|
138
143
|
if (parsedUrl.origin !== window.location.origin) {
|
|
139
144
|
throw new Error("Cross origin request are not allowed.");
|
|
140
145
|
}
|
|
141
146
|
this.$emit("before-fetch", url);
|
|
142
|
-
const content = await this.fetch(url);
|
|
147
|
+
const content = await this.fetch(url, formData);
|
|
143
148
|
const doc = this.parseHTML(content);
|
|
144
149
|
const el = doc.querySelector(`#${this.id}`);
|
|
145
150
|
const newFrame = new _Frame(el);
|
|
@@ -152,7 +157,7 @@ var Frame = class _Frame extends import_js_toolkit.Base {
|
|
|
152
157
|
this.directChildrenFrameTarget.map(
|
|
153
158
|
(target, index) => target.updateContent(newFrame.directChildrenFrameTarget[index])
|
|
154
159
|
);
|
|
155
|
-
if (this.$options.history) {
|
|
160
|
+
if (this.$options.history && formData === null) {
|
|
156
161
|
document.title = doc.title;
|
|
157
162
|
(0, import_utils.historyPush)({ path: parsedUrl.pathname, search: parsedUrl.searchParams });
|
|
158
163
|
}
|
|
@@ -171,7 +176,15 @@ var Frame = class _Frame extends import_js_toolkit.Base {
|
|
|
171
176
|
/**
|
|
172
177
|
* Fetch the given url.
|
|
173
178
|
*/
|
|
174
|
-
async fetch(url) {
|
|
179
|
+
async fetch(url, formData = null) {
|
|
180
|
+
if (formData) {
|
|
181
|
+
const promise2 = fetch(url, {
|
|
182
|
+
method: "post",
|
|
183
|
+
body: formData
|
|
184
|
+
}).then((response) => response.text());
|
|
185
|
+
const content = await promise2;
|
|
186
|
+
return content;
|
|
187
|
+
}
|
|
175
188
|
const cached = cache.get(url);
|
|
176
189
|
if (cached) {
|
|
177
190
|
if (cached.status === "pending") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/ui/organisms/Frame/Frame.ts"],
|
|
4
|
-
"sourcesContent": ["import { Base, isDirectChild, getDirectChildren } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';\nimport { nextFrame, historyPush } from '@studiometa/js-toolkit/utils';\nimport { FrameAnchor } from './FrameAnchor.js';\nimport { FrameForm } from './FrameForm.js';\nimport { FrameTarget } from './FrameTarget.js';\n\n/**\n * Get the scroll position.\n */\nfunction getScrollPosition() {\n return {\n left: window.pageXOffset,\n top: window.pageYOffset,\n };\n}\n\n/**\n * The fetch cache.\n */\nconst cache: Map<\n string,\n { promise: Promise<string>; status: 'pending' | 'resolved' | 'error'; content: string }\n> = new Map();\n\nexport interface FrameProps extends BaseProps {\n $children: {\n FrameAnchor: FrameAnchor[];\n FrameForm: FrameForm[];\n FrameTarget: FrameTarget[];\n // eslint-disable-next-line no-use-before-define\n Frame: Frame[];\n };\n $options: {\n history: boolean;\n };\n}\n\n/**\n * Class.\n */\nexport class Frame<T extends BaseProps = BaseProps> extends Base<T & FrameProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'Frame',\n emits: [\n 'before-fetch',\n 'after-fetch',\n 'before-leave',\n 'after-leave',\n 'before-content',\n 'after-content',\n 'before-enter',\n 'after-enter',\n ],\n components: {\n FrameAnchor,\n FrameForm,\n FrameTarget,\n Frame,\n },\n options: {\n history: Boolean,\n },\n };\n\n /**\n * Get uniq id.\n */\n get id() {\n return this.$el.id;\n }\n\n /**\n * Get direct `FrameTarget` children.\n */\n get directChildrenFrameTarget(): FrameTarget[] {\n return getDirectChildren(this, 'Frame', 'FrameTarget');\n }\n\n /**\n * Prevent scroll top on unload.\n */\n onWindowUnload() {\n const { history } = window;\n\n if (!history.state) {\n return;\n }\n\n history.replaceState(\n {\n ...history.state,\n scroll: getScrollPosition(),\n },\n '',\n );\n }\n\n /**\n * Go to the previous URL on `popstate` event.\n */\n onWindowPopstate(event: PopStateEvent) {\n this.goTo(window.location.href, event.state);\n }\n\n /**\n * Prevent click on `FrameAnchor`.\n */\n onFrameAnchorClick(index: number, event: MouseEvent) {\n // Prevent propagation of nested frames\n if (!isDirectChild(this, 'Frame', 'FrameAnchor', this.$children.FrameAnchor[index])) {\n return;\n }\n\n this.$log('onAFrameClick', index, event);\n event.preventDefault();\n const anchor = this.$children.FrameAnchor[index];\n\n // Do nothing when clicking links on the same page\n // @todo handle hash change\n if (anchor.href === window.location.href) {\n return;\n }\n\n this.goTo(anchor.href);\n }\n\n /**\n * Prevent submit on forms.\n */\n onFrameFormSubmit(index: number, event: SubmitEvent) {\n // Prevent propagation of nested frames\n if (!isDirectChild(this, 'Frame', 'FrameForm', this.$children.FrameForm[index])) {\n return;\n }\n\n this.$log('onFrameFormFrameSubmit', index, event);\n event.preventDefault();\n const form = this.$children.FrameForm[index];\n const url = new URL(form.action);\n // @ts-ignore\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAuD;AAEvD,mBAAuC;AACvC,yBAA4B;AAC5B,uBAA0B;AAC1B,yBAA4B;AAK5B,SAAS,oBAAoB;AAC3B,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,KAAK,OAAO;AAAA,EACd;AACF;AAKA,IAAM,QAGF,oBAAI,IAAI;AAkBL,IAAM,QAAN,MAAM,eAA+C,uBAAqB;AAAA;AAAA;AAAA;AAAA,EAI/E,OAAO,SAAqB;AAAA,IAC1B,MAAM;AAAA,IACN,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,SAAS;AAAA,IACX;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,KAAK;AACP,WAAO,KAAK,IAAI;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,4BAA2C;AAC7C,eAAO,qCAAkB,MAAM,SAAS,aAAa;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAiB;AACf,UAAM,EAAE,QAAQ,IAAI;AAEpB,QAAI,CAAC,QAAQ,OAAO;AAClB;AAAA,IACF;AAEA,YAAQ;AAAA,MACN;AAAA,QACE,GAAG,QAAQ;AAAA,QACX,QAAQ,kBAAkB;AAAA,MAC5B;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAiB,OAAsB;AACrC,SAAK,KAAK,OAAO,SAAS,MAAM,MAAM,KAAK;AAAA,
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { Base, isDirectChild, getDirectChildren } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';\nimport { nextFrame, historyPush } from '@studiometa/js-toolkit/utils';\nimport { FrameAnchor } from './FrameAnchor.js';\nimport { FrameForm } from './FrameForm.js';\nimport { FrameTarget } from './FrameTarget.js';\n\n/**\n * Get the scroll position.\n */\nfunction getScrollPosition() {\n return {\n left: window.pageXOffset,\n top: window.pageYOffset,\n };\n}\n\n/**\n * The fetch cache.\n */\nconst cache: Map<\n string,\n { promise: Promise<string>; status: 'pending' | 'resolved' | 'error'; content: string }\n> = new Map();\n\nexport interface FrameProps extends BaseProps {\n $children: {\n FrameAnchor: FrameAnchor[];\n FrameForm: FrameForm[];\n FrameTarget: FrameTarget[];\n // eslint-disable-next-line no-use-before-define\n Frame: Frame[];\n };\n $options: {\n history: boolean;\n };\n}\n\n/**\n * Class.\n */\nexport class Frame<T extends BaseProps = BaseProps> extends Base<T & FrameProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'Frame',\n emits: [\n 'before-fetch',\n 'after-fetch',\n 'before-leave',\n 'after-leave',\n 'before-content',\n 'after-content',\n 'before-enter',\n 'after-enter',\n ],\n components: {\n FrameAnchor,\n FrameForm,\n FrameTarget,\n Frame,\n },\n options: {\n history: Boolean,\n },\n };\n\n /**\n * Get uniq id.\n */\n get id() {\n return this.$el.id;\n }\n\n /**\n * Get direct `FrameTarget` children.\n */\n get directChildrenFrameTarget(): FrameTarget[] {\n return getDirectChildren(this, 'Frame', 'FrameTarget');\n }\n\n /**\n * Prevent scroll top on unload.\n */\n onWindowUnload() {\n const { history } = window;\n\n if (!history.state) {\n return;\n }\n\n history.replaceState(\n {\n ...history.state,\n scroll: getScrollPosition(),\n },\n '',\n );\n }\n\n /**\n * Go to the previous URL on `popstate` event.\n */\n onWindowPopstate(event: PopStateEvent) {\n this.goTo(window.location.href, null, event.state);\n }\n\n /**\n * Prevent click on `FrameAnchor`.\n */\n onFrameAnchorClick(index: number, event: MouseEvent) {\n // Prevent propagation of nested frames\n if (!isDirectChild(this, 'Frame', 'FrameAnchor', this.$children.FrameAnchor[index])) {\n return;\n }\n\n this.$log('onAFrameClick', index, event);\n event.preventDefault();\n const anchor = this.$children.FrameAnchor[index];\n\n // Do nothing when clicking links on the same page\n // @todo handle hash change\n if (anchor.href === window.location.href) {\n return;\n }\n\n this.goTo(anchor.href);\n }\n\n /**\n * Prevent submit on forms.\n */\n onFrameFormSubmit(index: number, event: SubmitEvent) {\n // Prevent propagation of nested frames\n if (!isDirectChild(this, 'Frame', 'FrameForm', this.$children.FrameForm[index])) {\n return;\n }\n\n this.$log('onFrameFormFrameSubmit', index, event);\n event.preventDefault();\n const form = this.$children.FrameForm[index];\n const url = new URL(form.action);\n\n if (form.$el.method === 'get') {\n // @ts-ignore\n url.search = new URLSearchParams(new FormData(form.$el)).toString();\n this.goTo(url.toString());\n }\n\n if (form.$el.method === 'post') {\n this.goTo(url.toString(), new FormData(form.$el));\n }\n }\n\n /**\n * Parge an HTML string into a DOM object.\n */\n parseHTML(string = '') {\n return new DOMParser().parseFromString(string, 'text/html');\n }\n\n /**\n * Go to the given url.\n */\n async goTo(url: string, formData: FormData = null, scroll: { top: number; left: number } = null) {\n this.$log('goTo', url);\n const parsedUrl = new URL(url);\n\n if (parsedUrl.origin !== window.location.origin) {\n throw new Error('Cross origin request are not allowed.');\n }\n\n this.$emit('before-fetch', url);\n\n // @todo add option to use content as is or to parse it and extract the new frame\n const content = await this.fetch(url, formData);\n const doc = this.parseHTML(content);\n const el = doc.querySelector(`#${this.id}`);\n // @todo manage el === null\n const newFrame = new Frame(el as HTMLElement);\n newFrame.$children.registerAll();\n\n this.$emit('after-fetch', url, content);\n\n this.$emit('before-leave');\n // Leave all\n await Promise.all(this.directChildrenFrameTarget.map((target) => target.leave()));\n\n this.$emit('after-leave');\n this.$emit('before-content');\n\n // Update content\n // @todo insert non existing FrameTarget as well\n this.directChildrenFrameTarget.map((target, index) =>\n target.updateContent(newFrame.directChildrenFrameTarget[index]),\n );\n\n // Push history\n if (this.$options.history && formData === null) {\n document.title = doc.title;\n historyPush({ path: parsedUrl.pathname, search: parsedUrl.searchParams });\n }\n\n if (scroll) {\n document.scrollingElement.scrollTop = scroll.top;\n document.scrollingElement.scrollLeft = scroll.left;\n }\n\n // Update components\n await nextFrame();\n this.$root.$update();\n await nextFrame();\n\n this.$emit('after-content');\n this.$emit('before-enter');\n\n // Enter all\n await Promise.all(this.directChildrenFrameTarget.map((target) => target.enter()));\n\n this.$emit('after-enter');\n }\n\n /**\n * Fetch the given url.\n */\n async fetch(url: string, formData: FormData = null): Promise<string> {\n // @note skip cache for POST requests.\n if (formData) {\n const promise = fetch(url, {\n method: 'post',\n body: formData,\n }).then((response) => response.text());\n\n const content = await promise;\n return content;\n }\n\n const cached = cache.get(url);\n\n if (cached) {\n if (cached.status === 'pending') {\n return cached.promise;\n }\n\n return cached.content;\n }\n\n const promise = fetch(url).then((response) => response.text());\n\n try {\n cache.set(url, {\n promise,\n status: 'pending',\n content: undefined,\n });\n\n const content = await promise;\n\n cache.set(url, {\n promise,\n status: 'resolved',\n content,\n });\n\n return content;\n } catch (err) {\n cache.set(url, {\n promise,\n status: 'error',\n content: err,\n });\n\n return err;\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAuD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AAC/B,eAAO,OAAO;AAAA,MAChB;AAEA,aAAO,OAAO;AAAA,IAChB;AAEA,UAAM,UAAU,MAAM,GAAG,EAAE,KAAK,CAAC,aAAa,SAAS,KAAK,CAAC;AAE7D,QAAI;AACF,YAAM,IAAI,KAAK;AAAA,QACb;AAAA,QACA,QAAQ;AAAA,QACR,SAAS;AAAA,MACX,CAAC;AAED,YAAM,UAAU,MAAM;AAEtB,YAAM,IAAI,KAAK;AAAA,QACb;AAAA,QACA,QAAQ;AAAA,QACR;AAAA,MACF,CAAC;AAED,aAAO;AAAA,IACT,SAAS,KAAK;AACZ,YAAM,IAAI,KAAK;AAAA,QACb;AAAA,QACA,QAAQ;AAAA,QACR,SAAS;AAAA,MACX,CAAC;AAED,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["promise"]
|
|
7
7
|
}
|
|
@@ -53,12 +53,12 @@ export declare class Frame<T extends BaseProps = BaseProps> extends Base<T & Fra
|
|
|
53
53
|
/**
|
|
54
54
|
* Go to the given url.
|
|
55
55
|
*/
|
|
56
|
-
goTo(url: string, scroll?: {
|
|
56
|
+
goTo(url: string, formData?: FormData, scroll?: {
|
|
57
57
|
top: number;
|
|
58
58
|
left: number;
|
|
59
59
|
}): Promise<void>;
|
|
60
60
|
/**
|
|
61
61
|
* Fetch the given url.
|
|
62
62
|
*/
|
|
63
|
-
fetch(url: string): Promise<string>;
|
|
63
|
+
fetch(url: string, formData?: FormData): Promise<string>;
|
|
64
64
|
}
|
package/organisms/Frame/Frame.js
CHANGED
|
@@ -68,7 +68,7 @@ class Frame extends Base {
|
|
|
68
68
|
* Go to the previous URL on `popstate` event.
|
|
69
69
|
*/
|
|
70
70
|
onWindowPopstate(event) {
|
|
71
|
-
this.goTo(window.location.href, event.state);
|
|
71
|
+
this.goTo(window.location.href, null, event.state);
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Prevent click on `FrameAnchor`.
|
|
@@ -96,8 +96,13 @@ class Frame extends Base {
|
|
|
96
96
|
event.preventDefault();
|
|
97
97
|
const form = this.$children.FrameForm[index];
|
|
98
98
|
const url = new URL(form.action);
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
if (form.$el.method === "get") {
|
|
100
|
+
url.search = new URLSearchParams(new FormData(form.$el)).toString();
|
|
101
|
+
this.goTo(url.toString());
|
|
102
|
+
}
|
|
103
|
+
if (form.$el.method === "post") {
|
|
104
|
+
this.goTo(url.toString(), new FormData(form.$el));
|
|
105
|
+
}
|
|
101
106
|
}
|
|
102
107
|
/**
|
|
103
108
|
* Parge an HTML string into a DOM object.
|
|
@@ -108,14 +113,14 @@ class Frame extends Base {
|
|
|
108
113
|
/**
|
|
109
114
|
* Go to the given url.
|
|
110
115
|
*/
|
|
111
|
-
async goTo(url, scroll = null) {
|
|
116
|
+
async goTo(url, formData = null, scroll = null) {
|
|
112
117
|
this.$log("goTo", url);
|
|
113
118
|
const parsedUrl = new URL(url);
|
|
114
119
|
if (parsedUrl.origin !== window.location.origin) {
|
|
115
120
|
throw new Error("Cross origin request are not allowed.");
|
|
116
121
|
}
|
|
117
122
|
this.$emit("before-fetch", url);
|
|
118
|
-
const content = await this.fetch(url);
|
|
123
|
+
const content = await this.fetch(url, formData);
|
|
119
124
|
const doc = this.parseHTML(content);
|
|
120
125
|
const el = doc.querySelector(`#${this.id}`);
|
|
121
126
|
const newFrame = new Frame(el);
|
|
@@ -128,7 +133,7 @@ class Frame extends Base {
|
|
|
128
133
|
this.directChildrenFrameTarget.map(
|
|
129
134
|
(target, index) => target.updateContent(newFrame.directChildrenFrameTarget[index])
|
|
130
135
|
);
|
|
131
|
-
if (this.$options.history) {
|
|
136
|
+
if (this.$options.history && formData === null) {
|
|
132
137
|
document.title = doc.title;
|
|
133
138
|
historyPush({ path: parsedUrl.pathname, search: parsedUrl.searchParams });
|
|
134
139
|
}
|
|
@@ -147,7 +152,15 @@ class Frame extends Base {
|
|
|
147
152
|
/**
|
|
148
153
|
* Fetch the given url.
|
|
149
154
|
*/
|
|
150
|
-
async fetch(url) {
|
|
155
|
+
async fetch(url, formData = null) {
|
|
156
|
+
if (formData) {
|
|
157
|
+
const promise2 = fetch(url, {
|
|
158
|
+
method: "post",
|
|
159
|
+
body: formData
|
|
160
|
+
}).then((response) => response.text());
|
|
161
|
+
const content = await promise2;
|
|
162
|
+
return content;
|
|
163
|
+
}
|
|
151
164
|
const cached = cache.get(url);
|
|
152
165
|
if (cached) {
|
|
153
166
|
if (cached.status === "pending") {
|