@studiometa/ui 1.0.0-rc.0 → 1.0.0-rc.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/AnchorScrollTo/AnchorScrollTo.d.ts +2 -2
- package/AnchorScrollTo/AnchorScrollTo.js +0 -1
- package/AnchorScrollTo/AnchorScrollTo.js.map +2 -2
- package/Button/Button.twig +12 -9
- package/Button/StyledButton.twig +40 -5
- package/Button/StyledButtonRounded.twig +12 -42
- package/Data/DataBind.js +1 -1
- package/Data/DataBind.js.map +2 -2
- package/Draggable/Draggable.d.ts +39 -9
- package/Draggable/Draggable.js +102 -18
- package/Draggable/Draggable.js.map +2 -2
- package/Figure/Figure.d.ts +1 -0
- package/Figure/Figure.js.map +2 -2
- package/Frame/AbstractFrameTrigger.d.ts +43 -0
- package/Frame/AbstractFrameTrigger.js +76 -0
- package/Frame/AbstractFrameTrigger.js.map +7 -0
- package/Frame/Frame.d.ts +55 -27
- package/Frame/Frame.js +132 -138
- package/Frame/Frame.js.map +3 -3
- package/Frame/FrameAnchor.d.ts +7 -4
- package/Frame/FrameAnchor.js +8 -5
- package/Frame/FrameAnchor.js.map +2 -2
- package/Frame/FrameForm.d.ts +22 -4
- package/Frame/FrameForm.js +45 -6
- package/Frame/FrameForm.js.map +2 -2
- package/Frame/FrameLoader.d.ts +22 -0
- package/Frame/FrameLoader.js +22 -0
- package/Frame/FrameLoader.js.map +7 -0
- package/Frame/FrameTarget.d.ts +6 -17
- package/Frame/FrameTarget.js +25 -60
- package/Frame/FrameTarget.js.map +2 -2
- package/Frame/FrameTriggerLoader.d.ts +13 -0
- package/Frame/FrameTriggerLoader.js +13 -0
- package/Frame/FrameTriggerLoader.js.map +7 -0
- package/Frame/index.d.ts +4 -0
- package/Frame/index.js +4 -0
- package/Frame/index.js.map +2 -2
- package/Frame/types.d.ts +12 -0
- package/Frame/types.js +1 -0
- package/Frame/types.js.map +7 -0
- package/Frame/utils.d.ts +9 -0
- package/Frame/utils.js +13 -0
- package/Frame/utils.js.map +7 -0
- package/README.md +12 -7
- package/Slider/AbstractSliderChild.d.ts +5 -9
- package/Slider/AbstractSliderChild.js +0 -11
- package/Slider/AbstractSliderChild.js.map +2 -2
- package/Slider/Slider.d.ts +23 -30
- package/Slider/Slider.js +40 -100
- package/Slider/Slider.js.map +2 -2
- package/Slider/SliderBtn.d.ts +0 -3
- package/Slider/SliderBtn.js +3 -7
- package/Slider/SliderBtn.js.map +2 -2
- package/Slider/SliderCount.d.ts +0 -2
- package/Slider/SliderCount.js +4 -3
- package/Slider/SliderCount.js.map +2 -2
- package/Slider/SliderDots.d.ts +0 -3
- package/Slider/SliderDots.js +6 -7
- package/Slider/SliderDots.js.map +2 -2
- package/Slider/SliderDrag.d.ts +0 -2
- package/Slider/SliderDrag.js +0 -2
- package/Slider/SliderDrag.js.map +2 -2
- package/Slider/SliderItem.d.ts +10 -26
- package/Slider/SliderItem.js +9 -41
- package/Slider/SliderItem.js.map +2 -2
- package/decorators/withTransition.d.ts +4 -0
- package/decorators/withTransition.js +40 -45
- package/decorators/withTransition.js.map +2 -2
- package/package.json +5 -4
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Base } from '@studiometa/js-toolkit';
|
|
2
2
|
import type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';
|
|
3
|
+
import { scrollTo } from '@studiometa/js-toolkit/utils';
|
|
3
4
|
export interface AnchorScrollToProps extends BaseProps {
|
|
4
5
|
$el: HTMLAnchorElement;
|
|
5
6
|
}
|
|
@@ -10,9 +11,8 @@ export declare class AnchorScrollTo<T extends BaseProps = BaseProps> extends Bas
|
|
|
10
11
|
static config: BaseConfig;
|
|
11
12
|
/**
|
|
12
13
|
* Get the target selector.
|
|
13
|
-
* @returns {string}
|
|
14
14
|
*/
|
|
15
|
-
get targetSelector():
|
|
15
|
+
get targetSelector(): Parameters<typeof scrollTo>[0];
|
|
16
16
|
/**
|
|
17
17
|
* Scroll to the target selector on click.
|
|
18
18
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/ui/AnchorScrollTo/AnchorScrollTo.ts"],
|
|
4
|
-
"sourcesContent": ["import { Base } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';\nimport { scrollTo } from '@studiometa/js-toolkit/utils';\n\nexport interface AnchorScrollToProps extends BaseProps {\n $el: HTMLAnchorElement;\n}\n\n/**\n * AncorScrollTo class.\n */\nexport class AnchorScrollTo<T extends BaseProps = BaseProps> extends Base<AnchorScrollToProps & T> {\n static config: BaseConfig = {\n name: 'AnchorScrollTo',\n };\n\n /**\n * Get the target selector.\n
|
|
5
|
-
"mappings": "AAAA,SAAS,YAAY;AAErB,SAAS,gBAAgB;AASlB,MAAM,uBAAwD,KAA8B;AAAA,EACjG,OAAO,SAAqB;AAAA,IAC1B,MAAM;AAAA,EACR;AAAA;AAAA;AAAA;AAAA
|
|
4
|
+
"sourcesContent": ["import { Base } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';\nimport { scrollTo } from '@studiometa/js-toolkit/utils';\n\nexport interface AnchorScrollToProps extends BaseProps {\n $el: HTMLAnchorElement;\n}\n\n/**\n * AncorScrollTo class.\n */\nexport class AnchorScrollTo<T extends BaseProps = BaseProps> extends Base<AnchorScrollToProps & T> {\n static config: BaseConfig = {\n name: 'AnchorScrollTo',\n };\n\n /**\n * Get the target selector.\n */\n get targetSelector(): Parameters<typeof scrollTo>[0] {\n return this.$el.hash;\n }\n\n /**\n * Scroll to the target selector on click.\n */\n onClick({ event }: { event: MouseEvent }) {\n try {\n scrollTo(this.targetSelector);\n event.preventDefault();\n } catch {\n // Silence is golden.\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY;AAErB,SAAS,gBAAgB;AASlB,MAAM,uBAAwD,KAA8B;AAAA,EACjG,OAAO,SAAqB;AAAA,IAC1B,MAAM;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,iBAAiD;AACnD,WAAO,KAAK,IAAI;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA,EAKA,QAAQ,EAAE,MAAM,GAA0B;AACxC,QAAI;AACF,eAAS,KAAK,cAAc;AAC5B,YAAM,eAAe;AAAA,IACvB,QAAQ;AAAA,IAER;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/Button/Button.twig
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
* @param array $attr
|
|
10
10
|
* @param string $icon
|
|
11
11
|
* @param array $icon_attr
|
|
12
|
-
* @param array|string $icon_classes
|
|
13
12
|
* @param 'start'|'end' $icon_position
|
|
14
13
|
* @param boolean $icon_only
|
|
15
14
|
*/
|
|
@@ -34,26 +33,30 @@
|
|
|
34
33
|
href: tag == 'a' and href is defined ? href : false,
|
|
35
34
|
aria_label: icon_only ? label : false
|
|
36
35
|
},
|
|
37
|
-
{
|
|
36
|
+
{
|
|
37
|
+
class: ['btn']
|
|
38
|
+
}
|
|
38
39
|
)
|
|
39
40
|
%}
|
|
40
41
|
|
|
41
42
|
{% set rendered_icon %}
|
|
42
43
|
{% block icon %}
|
|
43
|
-
{# @TODO: Breaking change -> Delete icon_classes to use only icon_attr #}
|
|
44
44
|
{% include '@ui/Icon/Icon.twig' with {
|
|
45
45
|
name: icon ?? '',
|
|
46
46
|
attr: merge_html_attributes(
|
|
47
47
|
icon_attr ?? null,
|
|
48
48
|
{
|
|
49
|
-
class:
|
|
50
|
-
'
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
class: [
|
|
50
|
+
'h-[0.75lh]',
|
|
51
|
+
{
|
|
52
|
+
'mr-3': not icon_only and icon_position == 'start',
|
|
53
|
+
'ml-3': not icon_only and icon_position == 'end'
|
|
54
|
+
}
|
|
55
|
+
]
|
|
53
56
|
},
|
|
54
57
|
{
|
|
55
|
-
class:
|
|
56
|
-
}
|
|
58
|
+
class: '[&>svg]:w-full [&>svg]:h-full'
|
|
59
|
+
}
|
|
57
60
|
)
|
|
58
61
|
} %}
|
|
59
62
|
{% endblock %}
|
package/Button/StyledButton.twig
CHANGED
|
@@ -4,30 +4,46 @@
|
|
|
4
4
|
* Styled button.
|
|
5
5
|
*
|
|
6
6
|
* @param 'primary'|'secondary'|'tertiary' $theme
|
|
7
|
+
* @param boolean $icon_only
|
|
8
|
+
* @param 's'|'m'|'l' $size
|
|
7
9
|
*/
|
|
8
10
|
#}
|
|
9
11
|
|
|
10
12
|
{% extends '@ui/Button/Button.twig' %}
|
|
11
13
|
|
|
12
|
-
{% set
|
|
14
|
+
{% set icon_position = icon_position ?? 'start' %}
|
|
15
|
+
{% set icon_only = icon_only ?? false %}
|
|
13
16
|
|
|
14
17
|
{% set theme = theme|default('primary') %}
|
|
15
18
|
|
|
19
|
+
{% set size = size ?? 'm' %}
|
|
20
|
+
{% if size not in ['s', 'm', 'l'] %}
|
|
21
|
+
{% set size = 'm' %}
|
|
22
|
+
{% endif %}
|
|
23
|
+
|
|
16
24
|
{% set theme_shared = [
|
|
17
25
|
'rounded cursor-pointer transition',
|
|
18
26
|
'disabled:cursor-not-allowed',
|
|
19
27
|
{
|
|
20
28
|
'inline-block': icon is not defined,
|
|
21
29
|
'inline-flex items-center': icon is defined,
|
|
22
|
-
'px-6 py-4': not icon_only,
|
|
23
|
-
'
|
|
30
|
+
'px-6 py-4': size == 'l' and not icon_only,
|
|
31
|
+
'px-3 py-2': size == 'm' and not icon_only,
|
|
32
|
+
'px-2.5 py-1.5': size == 's' and not icon_only,
|
|
33
|
+
'p-4': size == 'l' and icon_only,
|
|
34
|
+
'p-3': size == 'm' and icon_only,
|
|
35
|
+
'p-2': size == 's' and icon_only,
|
|
36
|
+
'text-sm': size == 's'
|
|
24
37
|
}
|
|
25
38
|
] %}
|
|
26
39
|
|
|
27
|
-
{% set theme_primary = [
|
|
40
|
+
{% set theme_primary = [
|
|
41
|
+
'text-white bg-black dark:text-black dark:bg-white',
|
|
42
|
+
'hover:bg-opacity-75 disabled:bg-opacity-50'
|
|
43
|
+
] %}
|
|
28
44
|
|
|
29
45
|
{% set theme_secondary = [
|
|
30
|
-
'ring ring-inset ring-2 ring-black ring-opacity-25',
|
|
46
|
+
'ring ring-inset ring-2 ring-black dark:ring-white ring-opacity-25 dark:ring-opacity-25',
|
|
31
47
|
{
|
|
32
48
|
'hover:ring-opacity-100': (attr is defined and attr.disabled is not defined)
|
|
33
49
|
or attr is not defined
|
|
@@ -47,3 +63,22 @@
|
|
|
47
63
|
}
|
|
48
64
|
)
|
|
49
65
|
%}
|
|
66
|
+
|
|
67
|
+
{% set icon_attr =
|
|
68
|
+
merge_html_attributes(
|
|
69
|
+
icon_attr ?? null,
|
|
70
|
+
{
|
|
71
|
+
class: 'h-[0.75lh]'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
class: {
|
|
75
|
+
'mr-3': size == 'l' and not icon_only and icon_position == 'start',
|
|
76
|
+
'ml-3': size == 'l' and not icon_only and icon_position == 'end',
|
|
77
|
+
'mr-2': size == 'm' and not icon_only and icon_position == 'start',
|
|
78
|
+
'ml-2': size == 'm' and not icon_only and icon_position == 'end',
|
|
79
|
+
'mr-1': size == 's' and not icon_only and icon_position == 'start',
|
|
80
|
+
'ml-1': size == 's' and not icon_only and icon_position == 'end'
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
%}
|
|
@@ -8,58 +8,28 @@
|
|
|
8
8
|
*/
|
|
9
9
|
#}
|
|
10
10
|
|
|
11
|
-
{% extends '@ui/Button/
|
|
11
|
+
{% extends '@ui/Button/StyledButton.twig' %}
|
|
12
12
|
|
|
13
|
-
{% set icon_only = icon_only
|
|
14
|
-
|
|
15
|
-
{% set theme = theme|default('primary') %}
|
|
16
|
-
|
|
17
|
-
{% set theme_shared = [
|
|
18
|
-
'rounded-full cursor-pointer transition',
|
|
19
|
-
'disabled:cursor-not-allowed leading-6',
|
|
20
|
-
{
|
|
21
|
-
'inline-block': icon is not defined,
|
|
22
|
-
'inline-flex items-center': icon is defined,
|
|
23
|
-
'px-6 py-4': not icon_only,
|
|
24
|
-
'w-14 relative p-4': icon_only
|
|
25
|
-
}
|
|
26
|
-
] %}
|
|
27
|
-
|
|
28
|
-
{% set theme_primary = ['text-white bg-black', 'hover:bg-opacity-75 disabled:bg-opacity-50'] %}
|
|
29
|
-
|
|
30
|
-
{% set theme_secondary = [
|
|
31
|
-
'ring ring-inset ring-2 ring-black ring-opacity-25',
|
|
32
|
-
{
|
|
33
|
-
'hover:ring-opacity-100': (attr is defined and attr.disabled is not defined)
|
|
34
|
-
or attr is not defined
|
|
35
|
-
}
|
|
36
|
-
] %}
|
|
13
|
+
{% set icon_only = icon_only ?? null %}
|
|
37
14
|
|
|
38
15
|
{% set attr =
|
|
39
16
|
merge_html_attributes(
|
|
40
17
|
attr ?? null,
|
|
41
18
|
null,
|
|
42
19
|
{
|
|
43
|
-
class: [
|
|
44
|
-
theme_shared,
|
|
45
|
-
theme == 'primary' ? theme_primary : '',
|
|
46
|
-
theme == 'secondary' ? theme_secondary : ''
|
|
47
|
-
]
|
|
20
|
+
class: ['rounded-full']
|
|
48
21
|
}
|
|
49
22
|
)
|
|
50
23
|
%}
|
|
51
|
-
|
|
24
|
+
|
|
52
25
|
{% if icon_only %}
|
|
53
|
-
{% set
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
26
|
+
{% set icon_attr =
|
|
27
|
+
merge_html_attributes(
|
|
28
|
+
icon_attr ?? null,
|
|
29
|
+
{
|
|
30
|
+
class: 'h-[0.75lh] aspect-square'
|
|
31
|
+
},
|
|
32
|
+
null
|
|
33
|
+
)
|
|
57
34
|
%}
|
|
58
35
|
{% endif %}
|
|
59
|
-
|
|
60
|
-
{% block icon %}
|
|
61
|
-
{{ parent() }}
|
|
62
|
-
{% if icon_only %}
|
|
63
|
-
|
|
64
|
-
{% endif %}
|
|
65
|
-
{% endblock %}
|
package/Data/DataBind.js
CHANGED
|
@@ -31,7 +31,7 @@ class DataBind extends Base {
|
|
|
31
31
|
return this.$options.prop;
|
|
32
32
|
}
|
|
33
33
|
const { target } = this;
|
|
34
|
-
if (target instanceof HTMLInputElement) {
|
|
34
|
+
if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) {
|
|
35
35
|
return "value";
|
|
36
36
|
}
|
|
37
37
|
return "textContent";
|
package/Data/DataBind.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/ui/Data/DataBind.ts"],
|
|
4
|
-
"sourcesContent": ["import { Base } from '@studiometa/js-toolkit';\nimport type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { isArray } from '@studiometa/js-toolkit/utils';\nimport { isInput, isCheckbox, isSelect } from './utils.js';\n\nconst groups = new Map<string, Set<DataBind>>();\n\nexport interface DataBindProps extends BaseProps {\n $options: {\n prop: string;\n group: string;\n };\n}\n\nexport class DataBind<T extends BaseProps = BaseProps> extends Base<DataBindProps & T> {\n static config: BaseConfig = {\n name: 'DataBind',\n options: {\n prop: String,\n group: String,\n },\n };\n\n get relatedInstances() {\n const { group } = this.$options;\n\n const instances = groups.get(group) ?? groups.set(group, new Set()).get(group);\n\n for (const instance of instances) {\n if (!instance.$el.isConnected) {\n instances.delete(instance);\n }\n }\n\n return instances;\n }\n\n get multiple() {\n return this.$options.group.endsWith('[]');\n }\n\n get target() {\n return this.$el;\n }\n\n get prop() {\n if (this.$options.prop) {\n return this.$options.prop;\n }\n\n const { target } = this;\n if (target instanceof HTMLInputElement) {\n return 'value';\n }\n\n return 'textContent';\n }\n\n get value() {\n return this.get();\n }\n\n set value(value) {\n this.set(value);\n }\n\n get() {\n const { target, multiple } = this;\n\n if (isSelect(target)) {\n if (multiple) {\n const values = [];\n // @ts-ignore\n for (const option of target.options) {\n if (option.selected) {\n values.push(option.value);\n }\n }\n\n return values;\n }\n\n const option = target.options.item(target.selectedIndex);\n return option.value;\n }\n\n if (isCheckbox(target)) {\n if (multiple) {\n const values = new Set();\n for (const instance of this.relatedInstances) {\n if (isCheckbox(instance.target) && instance.target.checked) {\n values.add(instance.target.value);\n }\n }\n return Array.from(values);\n } else {\n return target.checked;\n }\n }\n\n return target[this.prop];\n }\n\n set(value: boolean | string | string[], dispatch = true) {\n const { target, multiple, relatedInstances } = this;\n\n if (dispatch) {\n for (const instance of relatedInstances) {\n if (instance !== this && instance.value !== value) {\n instance.set(value, false);\n }\n }\n }\n\n if (isSelect(target)) {\n // @ts-ignore\n for (const option of target.options) {\n option.selected =\n multiple && isArray(value) ? value.includes(option.value) : option.value === value;\n }\n return;\n }\n\n if (isInput(target)) {\n switch (target.type) {\n case 'radio':\n target.checked = target.value === value;\n return;\n case 'checkbox':\n target.checked =\n multiple && isArray(value) ? value.includes(target.value) : Boolean(value);\n return;\n }\n }\n\n target[this.prop] = value;\n }\n\n mounted() {\n this.relatedInstances.add(this);\n }\n\n destroyed() {\n this.relatedInstances.delete(this);\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,YAAY;AAErB,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY,gBAAgB;AAE9C,MAAM,SAAS,oBAAI,IAA2B;AASvC,MAAM,iBAAkD,KAAwB;AAAA,EACrF,OAAO,SAAqB;AAAA,IAC1B,MAAM;AAAA,IACN,SAAS;AAAA,MACP,MAAM;AAAA,MACN,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,IAAI,mBAAmB;AACrB,UAAM,EAAE,MAAM,IAAI,KAAK;AAEvB,UAAM,YAAY,OAAO,IAAI,KAAK,KAAK,OAAO,IAAI,OAAO,oBAAI,IAAI,CAAC,EAAE,IAAI,KAAK;AAE7E,eAAW,YAAY,WAAW;AAChC,UAAI,CAAC,SAAS,IAAI,aAAa;AAC7B,kBAAU,OAAO,QAAQ;AAAA,MAC3B;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,IAAI,WAAW;AACb,WAAO,KAAK,SAAS,MAAM,SAAS,IAAI;AAAA,EAC1C;AAAA,EAEA,IAAI,SAAS;AACX,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,OAAO;AACT,QAAI,KAAK,SAAS,MAAM;AACtB,aAAO,KAAK,SAAS;AAAA,IACvB;AAEA,UAAM,EAAE,OAAO,IAAI;AACnB,QAAI,kBAAkB,kBAAkB;
|
|
4
|
+
"sourcesContent": ["import { Base } from '@studiometa/js-toolkit';\nimport type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { isArray } from '@studiometa/js-toolkit/utils';\nimport { isInput, isCheckbox, isSelect } from './utils.js';\n\nconst groups = new Map<string, Set<DataBind>>();\n\nexport interface DataBindProps extends BaseProps {\n $options: {\n prop: string;\n group: string;\n };\n}\n\nexport class DataBind<T extends BaseProps = BaseProps> extends Base<DataBindProps & T> {\n static config: BaseConfig = {\n name: 'DataBind',\n options: {\n prop: String,\n group: String,\n },\n };\n\n get relatedInstances() {\n const { group } = this.$options;\n\n const instances = groups.get(group) ?? groups.set(group, new Set()).get(group);\n\n for (const instance of instances) {\n if (!instance.$el.isConnected) {\n instances.delete(instance);\n }\n }\n\n return instances;\n }\n\n get multiple() {\n return this.$options.group.endsWith('[]');\n }\n\n get target() {\n return this.$el;\n }\n\n get prop() {\n if (this.$options.prop) {\n return this.$options.prop;\n }\n\n const { target } = this;\n if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) {\n return 'value';\n }\n\n return 'textContent';\n }\n\n get value() {\n return this.get();\n }\n\n set value(value) {\n this.set(value);\n }\n\n get() {\n const { target, multiple } = this;\n\n if (isSelect(target)) {\n if (multiple) {\n const values = [];\n // @ts-ignore\n for (const option of target.options) {\n if (option.selected) {\n values.push(option.value);\n }\n }\n\n return values;\n }\n\n const option = target.options.item(target.selectedIndex);\n return option.value;\n }\n\n if (isCheckbox(target)) {\n if (multiple) {\n const values = new Set();\n for (const instance of this.relatedInstances) {\n if (isCheckbox(instance.target) && instance.target.checked) {\n values.add(instance.target.value);\n }\n }\n return Array.from(values);\n } else {\n return target.checked;\n }\n }\n\n return target[this.prop];\n }\n\n set(value: boolean | string | string[], dispatch = true) {\n const { target, multiple, relatedInstances } = this;\n\n if (dispatch) {\n for (const instance of relatedInstances) {\n if (instance !== this && instance.value !== value) {\n instance.set(value, false);\n }\n }\n }\n\n if (isSelect(target)) {\n // @ts-ignore\n for (const option of target.options) {\n option.selected =\n multiple && isArray(value) ? value.includes(option.value) : option.value === value;\n }\n return;\n }\n\n if (isInput(target)) {\n switch (target.type) {\n case 'radio':\n target.checked = target.value === value;\n return;\n case 'checkbox':\n target.checked =\n multiple && isArray(value) ? value.includes(target.value) : Boolean(value);\n return;\n }\n }\n\n target[this.prop] = value;\n }\n\n mounted() {\n this.relatedInstances.add(this);\n }\n\n destroyed() {\n this.relatedInstances.delete(this);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY;AAErB,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY,gBAAgB;AAE9C,MAAM,SAAS,oBAAI,IAA2B;AASvC,MAAM,iBAAkD,KAAwB;AAAA,EACrF,OAAO,SAAqB;AAAA,IAC1B,MAAM;AAAA,IACN,SAAS;AAAA,MACP,MAAM;AAAA,MACN,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,IAAI,mBAAmB;AACrB,UAAM,EAAE,MAAM,IAAI,KAAK;AAEvB,UAAM,YAAY,OAAO,IAAI,KAAK,KAAK,OAAO,IAAI,OAAO,oBAAI,IAAI,CAAC,EAAE,IAAI,KAAK;AAE7E,eAAW,YAAY,WAAW;AAChC,UAAI,CAAC,SAAS,IAAI,aAAa;AAC7B,kBAAU,OAAO,QAAQ;AAAA,MAC3B;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,IAAI,WAAW;AACb,WAAO,KAAK,SAAS,MAAM,SAAS,IAAI;AAAA,EAC1C;A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AI,aAAa,QAAQ,SAAS,UAAU,OAAO;AACjD,mBAAS,IAAI,OAAO,KAAK;AAAA,QAC3B;AAAA,MACF;AAAA,IACF;AAEA,QAAI,SAAS,MAAM,GAAG;AAEpB,iBAAW,UAAU,OAAO,SAAS;AACnC,eAAO,WACL,YAAY,QAAQ,KAAK,IAAI,MAAM,SAAS,OAAO,KAAK,IAAI,OAAO,UAAU;AAAA,MACjF;AACA;AAAA,IACF;AAEA,QAAI,QAAQ,MAAM,GAAG;AACnB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK;AACH,iBAAO,UAAU,OAAO,UAAU;AAClC;AAAA,QACF,KAAK;AACH,iBAAO,UACL,YAAY,QAAQ,KAAK,IAAI,MAAM,SAAS,OAAO,KAAK,IAAI,QAAQ,KAAK;AAC3E;AAAA,MACJ;AAAA,IACF;AAEA,WAAO,KAAK,IAAI,IAAI;AAAA,EACtB;AAAA,EAEA,UAAU;AACR,SAAK,iBAAiB,IAAI,IAAI;AAAA,EAChC;AAAA,EAEA,YAAY;AACV,SAAK,iBAAiB,OAAO,IAAI;AAAA,EACnC;AACF;",
|
|
6
6
|
"names": ["option"]
|
|
7
7
|
}
|
package/Draggable/Draggable.d.ts
CHANGED
|
@@ -1,33 +1,63 @@
|
|
|
1
1
|
import { Base } from '@studiometa/js-toolkit';
|
|
2
2
|
import type { BaseProps, BaseConfig, DragServiceProps } from '@studiometa/js-toolkit';
|
|
3
|
+
export interface DraggableProps extends BaseProps {
|
|
4
|
+
$refs: {
|
|
5
|
+
target: HTMLElement;
|
|
6
|
+
};
|
|
7
|
+
$options: {
|
|
8
|
+
x: boolean;
|
|
9
|
+
y: boolean;
|
|
10
|
+
fitBounds: boolean;
|
|
11
|
+
sensitivity: number;
|
|
12
|
+
dropSensitivity: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
3
15
|
declare const Draggable_base: import("@studiometa/js-toolkit").BaseDecorator<import("@studiometa/js-toolkit").BaseInterface, Base<BaseProps>>;
|
|
4
16
|
/**
|
|
5
17
|
* Draggable class.
|
|
6
18
|
*/
|
|
7
|
-
export declare class Draggable<T extends BaseProps = BaseProps> extends Draggable_base<T> {
|
|
19
|
+
export declare class Draggable<T extends BaseProps = BaseProps> extends Draggable_base<T & DraggableProps> {
|
|
8
20
|
/**
|
|
9
21
|
* Config.
|
|
10
22
|
*/
|
|
11
23
|
static config: BaseConfig;
|
|
12
24
|
/**
|
|
13
|
-
*
|
|
25
|
+
* Props for the target position.
|
|
26
|
+
*/
|
|
27
|
+
props: {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
originX: number;
|
|
31
|
+
originY: number;
|
|
32
|
+
dampedX: number;
|
|
33
|
+
dampedY: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Smooth factor.
|
|
14
37
|
*/
|
|
15
|
-
|
|
38
|
+
dampFactor: number;
|
|
16
39
|
/**
|
|
17
|
-
*
|
|
40
|
+
* The draggable element, defaults to `this.$refs.target`.
|
|
18
41
|
*/
|
|
19
|
-
|
|
42
|
+
get target(): HTMLElement;
|
|
20
43
|
/**
|
|
21
|
-
*
|
|
44
|
+
* The bouding element, defaults to `this.$el`.
|
|
22
45
|
*/
|
|
23
|
-
|
|
46
|
+
get parent(): HTMLElement;
|
|
24
47
|
/**
|
|
25
|
-
*
|
|
48
|
+
* The bounds values.
|
|
26
49
|
*/
|
|
27
|
-
|
|
50
|
+
get bounds(): {
|
|
51
|
+
yMin: number;
|
|
52
|
+
yMax: number;
|
|
53
|
+
xMin: number;
|
|
54
|
+
xMax: number;
|
|
55
|
+
};
|
|
28
56
|
/**
|
|
29
57
|
* Drag service hook.
|
|
30
58
|
*/
|
|
31
59
|
dragged(props: DragServiceProps): void;
|
|
60
|
+
ticked(): void;
|
|
61
|
+
render(): void;
|
|
32
62
|
}
|
|
33
63
|
export {};
|
package/Draggable/Draggable.js
CHANGED
|
@@ -1,40 +1,124 @@
|
|
|
1
1
|
import { Base, withDrag } from "@studiometa/js-toolkit";
|
|
2
|
-
import {
|
|
3
|
-
class Draggable extends withDrag(Base
|
|
2
|
+
import { domScheduler, transform, damp, clamp, getOffsetSizes } from "@studiometa/js-toolkit/utils";
|
|
3
|
+
class Draggable extends withDrag(Base, {
|
|
4
|
+
// @ts-expect-error draggable is instance of Draggable.
|
|
5
|
+
target: (draggable) => draggable.target
|
|
6
|
+
}) {
|
|
4
7
|
/**
|
|
5
8
|
* Config.
|
|
6
9
|
*/
|
|
7
10
|
static config = {
|
|
8
|
-
name: "DraggableElement"
|
|
11
|
+
name: "DraggableElement",
|
|
12
|
+
refs: ["target"],
|
|
13
|
+
emits: ["drag-start", "drag-drag", "drag-drop", "drag-inertia", "drag-stop", "drag-fit"],
|
|
14
|
+
options: {
|
|
15
|
+
x: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: true
|
|
18
|
+
},
|
|
19
|
+
y: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: true
|
|
22
|
+
},
|
|
23
|
+
fitBounds: Boolean,
|
|
24
|
+
sensitivity: { type: Number, default: 0.5 },
|
|
25
|
+
dropSensitivity: { type: Number, default: 0.1 }
|
|
26
|
+
}
|
|
9
27
|
};
|
|
10
28
|
/**
|
|
11
|
-
*
|
|
29
|
+
* Props for the target position.
|
|
12
30
|
*/
|
|
13
|
-
|
|
31
|
+
props = {
|
|
32
|
+
x: 0,
|
|
33
|
+
y: 0,
|
|
34
|
+
originX: 0,
|
|
35
|
+
originY: 0,
|
|
36
|
+
dampedX: 0,
|
|
37
|
+
dampedY: 0
|
|
38
|
+
};
|
|
14
39
|
/**
|
|
15
|
-
*
|
|
40
|
+
* Smooth factor.
|
|
16
41
|
*/
|
|
17
|
-
|
|
42
|
+
dampFactor = 0.5;
|
|
43
|
+
/**
|
|
44
|
+
* The draggable element, defaults to `this.$refs.target`.
|
|
45
|
+
*/
|
|
46
|
+
get target() {
|
|
47
|
+
return this.$refs.target;
|
|
48
|
+
}
|
|
18
49
|
/**
|
|
19
|
-
*
|
|
50
|
+
* The bouding element, defaults to `this.$el`.
|
|
20
51
|
*/
|
|
21
|
-
|
|
52
|
+
get parent() {
|
|
53
|
+
return this.$el;
|
|
54
|
+
}
|
|
22
55
|
/**
|
|
23
|
-
*
|
|
56
|
+
* The bounds values.
|
|
24
57
|
*/
|
|
25
|
-
|
|
58
|
+
get bounds() {
|
|
59
|
+
const targetSizes = getOffsetSizes(this.target);
|
|
60
|
+
const parentSizes = getOffsetSizes(this.parent);
|
|
61
|
+
const xMin = targetSizes.x - parentSizes.x;
|
|
62
|
+
const yMin = targetSizes.y - parentSizes.y;
|
|
63
|
+
const xMax = xMin + targetSizes.width - parentSizes.width;
|
|
64
|
+
const yMax = yMin + targetSizes.height - parentSizes.height;
|
|
65
|
+
return {
|
|
66
|
+
yMin: yMin * -1,
|
|
67
|
+
yMax: yMax * -1,
|
|
68
|
+
xMin: xMin * -1,
|
|
69
|
+
xMax: xMax * -1
|
|
70
|
+
};
|
|
71
|
+
}
|
|
26
72
|
/**
|
|
27
73
|
* Drag service hook.
|
|
28
74
|
*/
|
|
29
75
|
dragged(props) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
|
|
76
|
+
this.$emit(`drag-${props.mode}`, this.props);
|
|
77
|
+
if (props.mode === props.MODES.START) {
|
|
78
|
+
this.props.originX = this.props.x;
|
|
79
|
+
this.props.originY = this.props.y;
|
|
80
|
+
this.dampFactor = this.$options.sensitivity;
|
|
81
|
+
this.render();
|
|
82
|
+
} else if (props.mode === props.MODES.DRAG || props.mode === props.MODES.INERTIA && !this.$options.fitBounds) {
|
|
83
|
+
this.props.x = this.props.originX + props.x - props.origin.x;
|
|
84
|
+
this.props.y = this.props.originY + props.y - props.origin.y;
|
|
85
|
+
this.render();
|
|
86
|
+
} else if (props.mode === props.MODES.DROP && this.$options.fitBounds) {
|
|
87
|
+
const { bounds } = this;
|
|
88
|
+
this.props.x = clamp(
|
|
89
|
+
this.props.originX + props.final.x - props.origin.x,
|
|
90
|
+
bounds.xMin,
|
|
91
|
+
bounds.xMax
|
|
92
|
+
);
|
|
93
|
+
this.props.y = clamp(
|
|
94
|
+
this.props.originY + props.final.y - props.origin.y,
|
|
95
|
+
bounds.yMin,
|
|
96
|
+
bounds.yMax
|
|
97
|
+
);
|
|
98
|
+
this.dampFactor = this.$options.dropSensitivity;
|
|
99
|
+
this.$services.enable("ticked");
|
|
34
100
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.$
|
|
101
|
+
}
|
|
102
|
+
ticked() {
|
|
103
|
+
this.$emit(`drag-inertia`, this.props);
|
|
104
|
+
this.render();
|
|
105
|
+
if (this.props.dampedX === this.props.x && this.props.dampedY === this.props.y) {
|
|
106
|
+
this.$services.disable("ticked");
|
|
107
|
+
this.$emit("drag-fit", this.props);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
render() {
|
|
111
|
+
this.props.dampedX = damp(this.props.x, this.props.dampedX, this.dampFactor);
|
|
112
|
+
this.props.dampedY = damp(this.props.y, this.props.dampedY, this.dampFactor);
|
|
113
|
+
domScheduler.read(() => {
|
|
114
|
+
const { x, y } = this.$options;
|
|
115
|
+
domScheduler.write(() => {
|
|
116
|
+
transform(this.target, {
|
|
117
|
+
x: x ? this.props.dampedX : 0,
|
|
118
|
+
y: y ? this.props.dampedY : 0
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
38
122
|
}
|
|
39
123
|
}
|
|
40
124
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/ui/Draggable/Draggable.ts"],
|
|
4
|
-
"sourcesContent": ["import { Base, withDrag } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig, DragServiceProps } from '@studiometa/js-toolkit';\nimport {
|
|
5
|
-
"mappings": "AAAA,SAAS,MAAM,gBAAgB;AAE/B,SAAS,cAAc;
|
|
4
|
+
"sourcesContent": ["import { Base, withDrag } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig, DragServiceProps } from '@studiometa/js-toolkit';\nimport { domScheduler, transform, damp, clamp, getOffsetSizes } from '@studiometa/js-toolkit/utils';\n\nexport interface DraggableProps extends BaseProps {\n $refs: {\n target: HTMLElement;\n };\n $options: {\n x: boolean;\n y: boolean;\n fitBounds: boolean;\n sensitivity: number;\n dropSensitivity: number;\n };\n}\n\n/**\n * Draggable class.\n */\nexport class Draggable<T extends BaseProps = BaseProps> extends withDrag(Base, {\n // @ts-expect-error draggable is instance of Draggable.\n target: (draggable) => draggable.target,\n})<T & DraggableProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'DraggableElement',\n refs: ['target'],\n emits: ['drag-start', 'drag-drag', 'drag-drop', 'drag-inertia', 'drag-stop', 'drag-fit'],\n options: {\n x: {\n type: Boolean,\n default: true,\n },\n y: {\n type: Boolean,\n default: true,\n },\n fitBounds: Boolean,\n sensitivity: { type: Number, default: 0.5 },\n dropSensitivity: { type: Number, default: 0.1 },\n },\n };\n\n /**\n * Props for the target position.\n */\n props = {\n x: 0,\n y: 0,\n originX: 0,\n originY: 0,\n dampedX: 0,\n dampedY: 0,\n };\n\n /**\n * Smooth factor.\n */\n dampFactor = 0.5;\n\n /**\n * The draggable element, defaults to `this.$refs.target`.\n */\n get target(): HTMLElement {\n return this.$refs.target;\n }\n\n /**\n * The bouding element, defaults to `this.$el`.\n */\n get parent(): HTMLElement {\n return this.$el;\n }\n\n /**\n * The bounds values.\n */\n get bounds() {\n const targetSizes = getOffsetSizes(this.target);\n const parentSizes = getOffsetSizes(this.parent);\n const xMin = targetSizes.x - parentSizes.x;\n const yMin = targetSizes.y - parentSizes.y;\n const xMax = xMin + targetSizes.width - parentSizes.width;\n const yMax = yMin + targetSizes.height - parentSizes.height;\n\n return {\n yMin: yMin * -1,\n yMax: yMax * -1,\n xMin: xMin * -1,\n xMax: xMax * -1,\n };\n }\n\n /**\n * Drag service hook.\n */\n dragged(props: DragServiceProps) {\n this.$emit(`drag-${props.mode}`, this.props);\n\n if (props.mode === props.MODES.START) {\n this.props.originX = this.props.x;\n this.props.originY = this.props.y;\n this.dampFactor = this.$options.sensitivity;\n this.render();\n } else if (\n props.mode === props.MODES.DRAG ||\n (props.mode === props.MODES.INERTIA && !this.$options.fitBounds)\n ) {\n this.props.x = this.props.originX + props.x - props.origin.x;\n this.props.y = this.props.originY + props.y - props.origin.y;\n this.render();\n } else if (props.mode === props.MODES.DROP && this.$options.fitBounds) {\n const { bounds } = this;\n this.props.x = clamp(\n this.props.originX + props.final.x - props.origin.x,\n bounds.xMin,\n bounds.xMax,\n );\n this.props.y = clamp(\n this.props.originY + props.final.y - props.origin.y,\n bounds.yMin,\n bounds.yMax,\n );\n this.dampFactor = this.$options.dropSensitivity;\n this.$services.enable('ticked');\n }\n }\n\n ticked() {\n this.$emit(`drag-inertia`, this.props);\n this.render();\n if (this.props.dampedX === this.props.x && this.props.dampedY === this.props.y) {\n this.$services.disable('ticked');\n this.$emit('drag-fit', this.props);\n }\n }\n\n render() {\n this.props.dampedX = damp(this.props.x, this.props.dampedX, this.dampFactor);\n this.props.dampedY = damp(this.props.y, this.props.dampedY, this.dampFactor);\n\n domScheduler.read(() => {\n const { x, y } = this.$options;\n domScheduler.write(() => {\n transform(this.target, {\n x: x ? this.props.dampedX : 0,\n y: y ? this.props.dampedY : 0,\n });\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,MAAM,gBAAgB;AAE/B,SAAS,cAAc,WAAW,MAAM,OAAO,sBAAsB;AAkB9D,MAAM,kBAAmD,SAAS,MAAM;AAAA;AAAA,EAE7E,QAAQ,CAAC,cAAc,UAAU;AACnC,CAAC,EAAsB;AAAA;AAAA;AAAA;AAAA,EAIrB,OAAO,SAAqB;AAAA,IAC1B,MAAM;AAAA,IACN,MAAM,CAAC,QAAQ;AAAA,IACf,OAAO,CAAC,cAAc,aAAa,aAAa,gBAAgB,aAAa,UAAU;A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ACtB,mBAAa,MAAM,MAAM;AACvB,kBAAU,KAAK,QAAQ;AAAA,UACrB,GAAG,IAAI,KAAK,MAAM,UAAU;AAAA,UAC5B,GAAG,IAAI,KAAK,MAAM,UAAU;AAAA,QAC9B,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/Figure/Figure.d.ts
CHANGED
package/Figure/Figure.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/ui/Figure/Figure.ts"],
|
|
4
|
-
"sourcesContent": ["import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { AbstractFigure } from './AbstractFigure.js';\nimport type { AbstractFigureProps } from './AbstractFigure.js';\n\nexport interface FigureProps extends AbstractFigureProps {}\n\n/**\n * Figure class.\n */\nexport class Figure<T extends BaseProps = BaseProps> extends AbstractFigure<T> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...AbstractFigure.config,\n name: 'Figure',\n };\n\n /**\n * Terminate the component on load.\n */\n onLoad() {\n this.$terminate();\n }\n}\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,sBAAsB;
|
|
4
|
+
"sourcesContent": ["import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { AbstractFigure } from './AbstractFigure.js';\nimport type { AbstractFigureProps } from './AbstractFigure.js';\n\nexport interface FigureProps extends AbstractFigureProps {}\n\n/**\n * Figure class.\n * @see https://ui.studiometa.dev/-/components/Figure/\n */\nexport class Figure<T extends BaseProps = BaseProps> extends AbstractFigure<T> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...AbstractFigure.config,\n name: 'Figure',\n };\n\n /**\n * Terminate the component on load.\n */\n onLoad() {\n this.$terminate();\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,sBAAsB;AASxB,MAAM,eAAgD,eAAkB;AAAA;AAAA;AAAA;AAAA,EAI7E,OAAO,SAAqB;AAAA,IAC1B,GAAG,eAAe;AAAA,IAClB,MAAM;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,SAAS;AACP,SAAK,WAAW;AAAA,EAClB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Base } from '@studiometa/js-toolkit';
|
|
2
|
+
import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';
|
|
3
|
+
import type { FrameRequestInit } from './types.js';
|
|
4
|
+
import { FrameTriggerLoader } from './FrameTriggerLoader.js';
|
|
5
|
+
export interface AbstractFrameTriggerProps extends BaseProps {
|
|
6
|
+
$el: HTMLFormElement | HTMLAnchorElement;
|
|
7
|
+
$options: {
|
|
8
|
+
requestInit: RequestInit;
|
|
9
|
+
headers: Record<string, string>;
|
|
10
|
+
};
|
|
11
|
+
$children: {
|
|
12
|
+
FrameTriggerLoader: FrameTriggerLoader[];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* AbstractFrameTrigger class.
|
|
17
|
+
*/
|
|
18
|
+
export declare class AbstractFrameTrigger<T extends BaseProps = BaseProps> extends Base<T & AbstractFrameTriggerProps> {
|
|
19
|
+
/**
|
|
20
|
+
* Config.
|
|
21
|
+
*/
|
|
22
|
+
static config: BaseConfig;
|
|
23
|
+
/**
|
|
24
|
+
* The URL to use for the request.
|
|
25
|
+
*/
|
|
26
|
+
get url(): URL;
|
|
27
|
+
/**
|
|
28
|
+
* Option for the fetch request.
|
|
29
|
+
*/
|
|
30
|
+
get requestInit(): FrameRequestInit;
|
|
31
|
+
/**
|
|
32
|
+
* Trigger FrameLoaders enter.
|
|
33
|
+
*/
|
|
34
|
+
onFrameFetchBefore(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Trigger FrameLoaders leave.
|
|
37
|
+
*/
|
|
38
|
+
onFrameFetchAfter(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Trigger request.
|
|
41
|
+
*/
|
|
42
|
+
trigger(): Promise<void>;
|
|
43
|
+
}
|