@studiometa/ui 0.2.6 → 0.2.9

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.
Files changed (56) hide show
  1. package/atoms/Cursor/Cursor.cjs +5 -1
  2. package/atoms/Cursor/Cursor.d.ts +6 -0
  3. package/atoms/Cursor/Cursor.js +1 -1
  4. package/atoms/LargeText/LargeText.cjs +14 -14
  5. package/atoms/LargeText/LargeText.d.ts +3 -4
  6. package/atoms/LargeText/LargeText.js +1 -1
  7. package/atoms/LargeText/LargeText.twig +1 -1
  8. package/atoms/ScrollAnimation/AbstractScrollAnimation.cjs +18 -59
  9. package/atoms/ScrollAnimation/AbstractScrollAnimation.d.ts +28 -55
  10. package/atoms/ScrollAnimation/AbstractScrollAnimation.js +1 -1
  11. package/atoms/ScrollAnimation/ScrollAnimation.d.ts +9 -4
  12. package/atoms/ScrollAnimation/animationScrollWithEase.cjs +3 -24
  13. package/atoms/ScrollAnimation/animationScrollWithEase.js +1 -1
  14. package/molecules/Menu/Menu.cjs +7 -16
  15. package/molecules/Menu/Menu.d.ts +12 -12
  16. package/molecules/Menu/Menu.js +1 -1
  17. package/molecules/Menu/MenuBtn.cjs +1 -5
  18. package/molecules/Menu/MenuBtn.d.ts +0 -1
  19. package/molecules/Menu/MenuBtn.js +1 -1
  20. package/molecules/Menu/MenuList.cjs +1 -2
  21. package/molecules/Menu/MenuList.d.ts +1 -2
  22. package/molecules/Menu/MenuList.js +1 -1
  23. package/molecules/Modal/Modal.cjs +11 -3
  24. package/molecules/Modal/Modal.d.ts +17 -5
  25. package/molecules/Modal/Modal.js +1 -1
  26. package/molecules/Modal/Modal.twig +5 -2
  27. package/molecules/Modal/StyledModal.twig +5 -2
  28. package/molecules/Panel/StyledPanel.twig +8 -3
  29. package/molecules/Slider/AbstractSliderChild.cjs +8 -1
  30. package/molecules/Slider/AbstractSliderChild.d.ts +2 -2
  31. package/molecules/Slider/AbstractSliderChild.js +1 -1
  32. package/molecules/Slider/Slider.cjs +12 -4
  33. package/molecules/Slider/Slider.d.ts +11 -0
  34. package/molecules/Slider/Slider.js +1 -1
  35. package/molecules/Slider/SliderBtn.d.ts +8 -0
  36. package/molecules/Slider/SliderCount.d.ts +8 -0
  37. package/molecules/Slider/SliderDots.d.ts +8 -0
  38. package/molecules/Slider/SliderDrag.cjs +5 -1
  39. package/molecules/Slider/SliderDrag.d.ts +7 -0
  40. package/molecules/Slider/SliderDrag.js +1 -1
  41. package/molecules/Slider/SliderItem.cjs +7 -6
  42. package/molecules/Slider/SliderItem.d.ts +9 -0
  43. package/molecules/Slider/SliderItem.js +1 -1
  44. package/molecules/Slider/SliderProgress.cjs +7 -3
  45. package/molecules/Slider/SliderProgress.d.ts +8 -0
  46. package/molecules/Slider/SliderProgress.js +1 -1
  47. package/organisms/Frame/Frame.cjs +12 -16
  48. package/organisms/Frame/Frame.d.ts +4 -14
  49. package/organisms/Frame/Frame.js +1 -1
  50. package/organisms/Frame/FrameAnchor.cjs +1 -5
  51. package/organisms/Frame/FrameAnchor.d.ts +0 -8
  52. package/organisms/Frame/FrameAnchor.js +1 -1
  53. package/organisms/Frame/FrameForm.cjs +1 -5
  54. package/organisms/Frame/FrameForm.d.ts +0 -8
  55. package/organisms/Frame/FrameForm.js +1 -1
  56. package/package.json +2 -2
@@ -54,10 +54,9 @@ export default class MenuList extends Transition {
54
54
  /**
55
55
  * Unset hover state.
56
56
  *
57
- * @param {MouseEvent} event
58
57
  * @returns {void}
59
58
  */
60
- onMouseleave(event: MouseEvent): void;
59
+ onMouseleave(): void;
61
60
  /**
62
61
  * Display the menu items.
63
62
  *
@@ -1 +1 @@
1
- import n from"../../primitives/Transition/Transition.js";const o=["a[href]:not([inert])","area[href]:not([inert])","input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])","iframe:not([inert])","audio:not([inert])","video:not([inert])","[contenteditable]:not([inert])","[tabindex]:not([inert])"].join(",");class s extends n{static config={...n.config,name:"MenuList",emits:["items-open","items-close","items-mouseleave"],components:{MenuList:s}};isOpen=!1;isHover=!1;get $options(){const e=super.$options;return e.leaveKeep=!0,e.enterKeep=!0,e}mounted(){this.__updateTabIndexes("close")}onMouseenter(){this.isHover=!0}onMouseleave(e){this.isHover=!1,this.$emit("items-mouseleave",e)}open(){if(this.isOpen)return;const e=t=>{this.$el.contains(t.target)||(document.removeEventListener("click",e),this.close())};document.addEventListener("click",e),this.__updateTabIndexes("open"),this.$el.setAttribute("aria-hidden","false"),this.isOpen=!0,this.enter(),this.$emit("items-open")}close(){!this.isOpen||(this.$children.MenuList.forEach(e=>{e.close()}),document.activeElement instanceof HTMLElement&&this.$el.contains(document.activeElement)&&document.activeElement.blur(),this.$el.setAttribute("aria-hidden","true"),this.__updateTabIndexes("close"),this.isOpen=!1,this.leave(),this.$emit("items-close"))}toggle(){console.log(this.$id,"toggle",this.isOpen),this.isOpen?this.close():this.open()}__updateTabIndexes(e="open"){Array.from(this.$el.querySelectorAll(o)).filter(i=>this.__filterFocusableItems(i)).forEach(i=>{e==="close"?i.setAttribute("tabindex","-1"):i.removeAttribute("tabindex")})}__filterFocusableItems(e){let t=e.parentElement;for(;t&&(!t.__base__||!t.__base__.has(this.constructor));)t=t.parentElement;return t===null||t===this.$el}}export{s as default};
1
+ import n from"../../primitives/Transition/Transition.js";const o=["a[href]:not([inert])","area[href]:not([inert])","input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])","iframe:not([inert])","audio:not([inert])","video:not([inert])","[contenteditable]:not([inert])","[tabindex]:not([inert])"].join(",");class s extends n{static config={...n.config,name:"MenuList",emits:["items-open","items-close","items-mouseleave"],components:{MenuList:s}};isOpen=!1;isHover=!1;get $options(){const e=super.$options;return e.leaveKeep=!0,e.enterKeep=!0,e}mounted(){this.__updateTabIndexes("close")}onMouseenter(){this.isHover=!0}onMouseleave(){this.isHover=!1}open(){if(this.isOpen)return;const e=t=>{this.$el.contains(t.target)||(document.removeEventListener("click",e),this.close())};document.addEventListener("click",e),this.__updateTabIndexes("open"),this.$el.setAttribute("aria-hidden","false"),this.isOpen=!0,this.enter(),this.$emit("items-open")}close(){!this.isOpen||(this.$children.MenuList.forEach(e=>{e.close()}),document.activeElement instanceof HTMLElement&&this.$el.contains(document.activeElement)&&document.activeElement.blur(),this.$el.setAttribute("aria-hidden","true"),this.__updateTabIndexes("close"),this.isOpen=!1,this.leave(),this.$emit("items-close"))}toggle(){console.log(this.$id,"toggle",this.isOpen),this.isOpen?this.close():this.open()}__updateTabIndexes(e="open"){Array.from(this.$el.querySelectorAll(o)).filter(i=>this.__filterFocusableItems(i)).forEach(i=>{e==="close"?i.setAttribute("tabindex","-1"):i.removeAttribute("tabindex")})}__filterFocusableItems(e){let t=e.parentElement;for(;t&&(!t.__base__||!t.__base__.has(this.constructor));)t=t.parentElement;return t===null||t===this.$el}}export{s as default};
@@ -89,7 +89,9 @@ var Modal = class extends import_js_toolkit.Base {
89
89
  return Promise.resolve();
90
90
  }
91
91
  this.$refs.modal.setAttribute("aria-hidden", "false");
92
- document.documentElement.style.overflow = "hidden";
92
+ if (this.$options.scrollLock) {
93
+ document.documentElement.style.overflow = "hidden";
94
+ }
93
95
  this.isOpen = true;
94
96
  this.$emit("open");
95
97
  const refs = this.$refs;
@@ -111,7 +113,9 @@ var Modal = class extends import_js_toolkit.Base {
111
113
  return Promise.resolve();
112
114
  }
113
115
  this.$refs.modal.setAttribute("aria-hidden", "true");
114
- document.documentElement.style.overflow = "";
116
+ if (this.$options.scrollLock) {
117
+ document.documentElement.style.overflow = "";
118
+ }
115
119
  this.isOpen = false;
116
120
  untrap();
117
121
  this.$emit("close");
@@ -125,7 +129,7 @@ var Modal = class extends import_js_toolkit.Base {
125
129
  };
126
130
  __publicField(Modal, "config", {
127
131
  name: "Modal",
128
- refs: ["close", "container", "content", "modal", "open", "overlay"],
132
+ refs: ["close[]", "container", "content", "modal", "open[]", "overlay"],
129
133
  emits: ["open", "close"],
130
134
  options: {
131
135
  move: String,
@@ -141,6 +145,10 @@ __publicField(Modal, "config", {
141
145
  }
142
146
  }
143
147
  })
148
+ },
149
+ scrollLock: {
150
+ type: Boolean,
151
+ default: true
144
152
  }
145
153
  }
146
154
  });
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @typedef {Object} ModalRefs
3
- * @property {HTMLElement} close
3
+ * @property {HTMLElement} close[]
4
4
  * @property {HTMLElement} container
5
5
  * @property {HTMLElement} content
6
6
  * @property {HTMLElement} modal
7
- * @property {HTMLElement} open
7
+ * @property {HTMLElement} open[]
8
8
  * @property {HTMLElement} overlay
9
9
  */
10
10
  /**
@@ -13,9 +13,10 @@
13
13
  */
14
14
  /**
15
15
  * @typedef {Object} ModalOptions
16
- * @property {String} move A selector where to move the modal to.
17
- * @property {String} autofocus A selector for the element to set the focus to when the modal opens.
18
- * @property {ModalStylesOption} styles The styles for the different state of the modal.
16
+ * @property {String} move A selector where to move the modal to.
17
+ * @property {String} autofocus A selector for the element to set the focus to when the modal opens.
18
+ * @property {Boolean} scrollLock Lock or allow scroll in the documentElement.
19
+ * @property {ModalStylesOption} styles The styles for the different state of the modal.
19
20
  */
20
21
  /**
21
22
  * @typedef {Object} ModalPrivateInterface
@@ -54,6 +55,13 @@ export default class Modal extends Base {
54
55
  */
55
56
  default: () => ModalStylesOption;
56
57
  };
58
+ /**
59
+ * @return {ModalScrollLockOption}
60
+ */
61
+ scrollLock: {
62
+ type: BooleanConstructor;
63
+ default: boolean;
64
+ };
57
65
  };
58
66
  };
59
67
  /**
@@ -141,6 +149,10 @@ export type ModalOptions = {
141
149
  * A selector for the element to set the focus to when the modal opens.
142
150
  */
143
151
  autofocus: string;
152
+ /**
153
+ * Lock or allow scroll in the documentElement.
154
+ */
155
+ scrollLock: boolean;
144
156
  /**
145
157
  * The styles for the different state of the modal.
146
158
  */
@@ -1 +1 @@
1
- import{Base as n}from"@studiometa/js-toolkit";import{transition as r,focusTrap as l}from"@studiometa/js-toolkit/utils";const{trap:a,untrap:c,saveActiveElement:f}=l();class h extends n{static config={name:"Modal",refs:["close","container","content","modal","open","overlay"],emits:["open","close"],options:{move:String,autofocus:{type:String,default:"[autofocus]"},styles:{type:Object,default:()=>({modal:{closed:{opacity:"0",pointerEvents:"none",visibility:"hidden"}}})}}};get onOpenClick(){return this.open}get onCloseClick(){return this.close}get onOverlayClick(){return this.close}mounted(){if(this.isOpen=!1,this.close(),this.$options.move){const e=document.querySelector(this.$options.move)||document.body;this.__refsBackup=this.$refs,this.__refModalPlaceholder=document.createComment(""),this.__refModalParentBackup=this.$refs.modal.parentElement||this.$el,this.__refModalParentBackup.insertBefore(this.__refModalPlaceholder,this.$refs.modal),e.appendChild(this.$refs.modal)}}get $refs(){const e=super.$refs;return this.$options.move&&this.__refsBackup&&Object.entries(this.__refsBackup).forEach(([t,s])=>{e[t]||(e[t]=s)}),e}destroyed(){return this.close(),this.$options.move&&this.__refModalParentBackup&&(this.__refModalParentBackup.insertBefore(this.$refs.modal,this.__refModalPlaceholder),this.__refModalPlaceholder.remove(),delete this.__refModalPlaceholder,delete this.__refModalParentBackup),this}keyed({event:e,isUp:t,isDown:s,ESC:o}){!this.isOpen||(s&&a(this.$refs.modal,e),o&&t&&this.close())}async open(){if(this.isOpen)return Promise.resolve();this.$refs.modal.setAttribute("aria-hidden","false"),document.documentElement.style.overflow="hidden",this.isOpen=!0,this.$emit("open");const e=this.$refs;return Promise.all(Object.entries(this.$options.styles).map(([t,{open:s,active:o,closed:i}={open:"",active:"",closed:""}])=>r(e[t],{from:i,active:o,to:s},"keep"))).then(()=>(this.$options.autofocus&&this.$refs.modal.querySelector(this.$options.autofocus)&&(f(),this.$refs.modal.querySelector(this.$options.autofocus).focus()),Promise.resolve()))}async close(){if(!this.isOpen)return Promise.resolve();this.$refs.modal.setAttribute("aria-hidden","true"),document.documentElement.style.overflow="",this.isOpen=!1,c(),this.$emit("close");const e=this.$refs;return Promise.all(Object.entries(this.$options.styles).map(([t,{open:s,active:o,closed:i}={open:"",active:"",closed:""}])=>r(e[t],{from:s,active:o,to:i},"keep"))).then(()=>Promise.resolve())}}export{h as default};
1
+ import{Base as n}from"@studiometa/js-toolkit";import{transition as r,focusTrap as l}from"@studiometa/js-toolkit/utils";const{trap:a,untrap:c,saveActiveElement:f}=l();class h extends n{static config={name:"Modal",refs:["close[]","container","content","modal","open[]","overlay"],emits:["open","close"],options:{move:String,autofocus:{type:String,default:"[autofocus]"},styles:{type:Object,default:()=>({modal:{closed:{opacity:"0",pointerEvents:"none",visibility:"hidden"}}})},scrollLock:{type:Boolean,default:!0}}};get onOpenClick(){return this.open}get onCloseClick(){return this.close}get onOverlayClick(){return this.close}mounted(){if(this.isOpen=!1,this.close(),this.$options.move){const e=document.querySelector(this.$options.move)||document.body;this.__refsBackup=this.$refs,this.__refModalPlaceholder=document.createComment(""),this.__refModalParentBackup=this.$refs.modal.parentElement||this.$el,this.__refModalParentBackup.insertBefore(this.__refModalPlaceholder,this.$refs.modal),e.appendChild(this.$refs.modal)}}get $refs(){const e=super.$refs;return this.$options.move&&this.__refsBackup&&Object.entries(this.__refsBackup).forEach(([t,s])=>{e[t]||(e[t]=s)}),e}destroyed(){return this.close(),this.$options.move&&this.__refModalParentBackup&&(this.__refModalParentBackup.insertBefore(this.$refs.modal,this.__refModalPlaceholder),this.__refModalPlaceholder.remove(),delete this.__refModalPlaceholder,delete this.__refModalParentBackup),this}keyed({event:e,isUp:t,isDown:s,ESC:o}){!this.isOpen||(s&&a(this.$refs.modal,e),o&&t&&this.close())}async open(){if(this.isOpen)return Promise.resolve();this.$refs.modal.setAttribute("aria-hidden","false"),this.$options.scrollLock&&(document.documentElement.style.overflow="hidden"),this.isOpen=!0,this.$emit("open");const e=this.$refs;return Promise.all(Object.entries(this.$options.styles).map(([t,{open:s,active:o,closed:i}={open:"",active:"",closed:""}])=>r(e[t],{from:i,active:o,to:s},"keep"))).then(()=>(this.$options.autofocus&&this.$refs.modal.querySelector(this.$options.autofocus)&&(f(),this.$refs.modal.querySelector(this.$options.autofocus).focus()),Promise.resolve()))}async close(){if(!this.isOpen)return Promise.resolve();this.$refs.modal.setAttribute("aria-hidden","true"),this.$options.scrollLock&&(document.documentElement.style.overflow=""),this.isOpen=!1,c(),this.$emit("close");const e=this.$refs;return Promise.all(Object.entries(this.$options.styles).map(([t,{open:s,active:o,closed:i}={open:"",active:"",closed:""}])=>r(e[t],{from:s,active:o,to:i},"keep"))).then(()=>Promise.resolve())}}export{h as default};
@@ -83,7 +83,10 @@
83
83
 
84
84
  <div {{ html_attributes(attributes) }}>
85
85
  {% block open %}
86
- {% include '@ui/atoms/Button/Button.twig' with { label: 'Open', attr: { data_ref: 'open' } } %}
86
+ {% include '@ui/atoms/Button/Button.twig' with {
87
+ label: 'Open',
88
+ attr: { data_ref: 'open[]' }
89
+ } %}
87
90
  {% endblock %}
88
91
  <div {{ html_attributes(modal_attributes) }}>
89
92
  <div {{ html_attributes(overlay_attributes) }}></div>
@@ -93,7 +96,7 @@
93
96
  <div class="absolute top-0 right-0 m-2">
94
97
  {% include '@ui/atoms/Button/Button.twig' with {
95
98
  label: 'Close',
96
- attr: { data_ref: 'close' }
99
+ attr: { data_ref: 'close[]' }
97
100
  } %}
98
101
  </div>
99
102
  {% endblock %}
@@ -26,14 +26,17 @@
26
26
  {% extends '@ui/molecules/Modal/Modal.twig' %}
27
27
 
28
28
  {% block open %}
29
- {% include '@ui/atoms/Button/StyledButton.twig' with { label: 'Open', attr: { data_ref: 'open' } } %}
29
+ {% include '@ui/atoms/Button/StyledButton.twig' with {
30
+ label: 'Open',
31
+ attr: { data_ref: 'open[]' }
32
+ } %}
30
33
  {% endblock %}
31
34
 
32
35
  {% block close %}
33
36
  <div class="absolute top-0 right-0 m-2">
34
37
  {% include '@ui/atoms/Button/StyledButton.twig' with {
35
38
  label: 'Close',
36
- attr: { data_ref: 'close' }
39
+ attr: { data_ref: 'close[]' }
37
40
  } %}
38
41
  </div>
39
42
  {% endblock %}
@@ -12,17 +12,22 @@
12
12
 
13
13
  {% extends '@ui/molecules/Panel/Panel.twig' %}
14
14
 
15
- {% set container_attr = merge_html_attributes(container_attr ?? null, required={ class: 'bg-white' }) %}
15
+ {% set container_attr =
16
+ merge_html_attributes(container_attr ?? null, required = { class: 'bg-white' })
17
+ %}
16
18
 
17
19
  {% block open %}
18
- {% include '@ui/atoms/Button/StyledButton.twig' with { label: 'Open', attr: { data_ref: 'open' } } %}
20
+ {% include '@ui/atoms/Button/StyledButton.twig' with {
21
+ label: 'Open',
22
+ attr: { data_ref: 'open[]' }
23
+ } %}
19
24
  {% endblock %}
20
25
 
21
26
  {% block close %}
22
27
  <div class="absolute top-0 right-0 m-2">
23
28
  {% include '@ui/atoms/Button/StyledButton.twig' with {
24
29
  label: 'Close',
25
- attr: { data_ref: 'close' }
30
+ attr: { data_ref: 'close[]' }
26
31
  } %}
27
32
  </div>
28
33
  {% endblock %}
@@ -51,7 +51,14 @@ var AbstractSliderChild = class extends import_js_toolkit.Base {
51
51
  }
52
52
  handleEvent(event) {
53
53
  if (event.type === "index") {
54
- this.update(event.detail[0]);
54
+ import_utils.domScheduler.read(() => {
55
+ const callback = this.update(event.detail[0]);
56
+ if ((0, import_utils.isFunction)(callback)) {
57
+ import_utils.domScheduler.write(() => {
58
+ callback();
59
+ });
60
+ }
61
+ });
55
62
  }
56
63
  }
57
64
  update(index) {
@@ -45,9 +45,9 @@ export default class AbstractSliderChild extends Base {
45
45
  *
46
46
  * @this {AbstractSliderChildInterface}
47
47
  * @param {number} index The new active index.
48
- * @returns {void}
48
+ * @returns {void|(()=>void)}
49
49
  */
50
- update(this: AbstractSliderChildInterface, index: number): void;
50
+ update(this: AbstractSliderChildInterface, index: number): void | (() => void);
51
51
  }
52
52
  export type AbstractSliderChildInterface = AbstractSliderChild & {
53
53
  $parent: Slider;
@@ -1 +1 @@
1
- import{Base as t}from"@studiometa/js-toolkit";import{nextFrame as i}from"@studiometa/js-toolkit/utils";import r from"./Slider.js";class d extends t{static config={name:"AbstractSliderChild"};$parent;mounted(){if(!(this.$parent instanceof r))throw new Error(`The \`${this.$options.name}\` component must be a direct child of a \`Slider\` component.`);this.$parent.$on("index",this)}resized(){i(()=>{this.update(this.$parent.currentIndex)})}destroyed(){this.$parent.$off("index",this)}handleEvent(e){e.type==="index"&&this.update(e.detail[0])}update(e){throw new Error(`The \`AbstractSliderChild.update(${e})\` method must be implemented.`)}}export{d as default};
1
+ import{Base as r}from"@studiometa/js-toolkit";import{nextFrame as d,domScheduler as i,isFunction as n}from"@studiometa/js-toolkit/utils";import o from"./Slider.js";class a extends r{static config={name:"AbstractSliderChild"};$parent;mounted(){if(!(this.$parent instanceof o))throw new Error(`The \`${this.$options.name}\` component must be a direct child of a \`Slider\` component.`);this.$parent.$on("index",this)}resized(){d(()=>{this.update(this.$parent.currentIndex)})}destroyed(){this.$parent.$off("index",this)}handleEvent(e){e.type==="index"&&i.read(()=>{const t=this.update(e.detail[0]);n(t)&&i.write(()=>{t()})})}update(e){throw new Error(`The \`AbstractSliderChild.update(${e})\` method must be implemented.`)}}export{a as default};
@@ -48,6 +48,11 @@ var Slider = class extends import_js_toolkit.Base {
48
48
  this.currentSliderItem.activate();
49
49
  }
50
50
  states = [];
51
+ origins = {
52
+ left: 0,
53
+ center: 0,
54
+ right: 0
55
+ };
51
56
  get currentState() {
52
57
  return this.states[this.currentIndex];
53
58
  }
@@ -72,7 +77,7 @@ var Slider = class extends import_js_toolkit.Base {
72
77
  getStates() {
73
78
  const { wrapper } = this.$refs;
74
79
  const originRect = wrapper.getBoundingClientRect();
75
- const origins = {
80
+ this.origins = {
76
81
  left: originRect.left,
77
82
  center: originRect.x + originRect.width / 2,
78
83
  right: originRect.x + originRect.width
@@ -80,13 +85,16 @@ var Slider = class extends import_js_toolkit.Base {
80
85
  return this.$children.SliderItem.map((item) => {
81
86
  return {
82
87
  x: {
83
- left: (item.rect.x - origins.left) * -1,
84
- center: (item.rect.x + item.rect.width / 2 - origins.center) * -1,
85
- right: (item.rect.x + item.rect.width - origins.right) * -1
88
+ left: (item.rect.x - this.origins.left) * -1,
89
+ center: (item.rect.x + item.rect.width / 2 - this.origins.center) * -1,
90
+ right: (item.rect.x + item.rect.width - this.origins.right) * -1
86
91
  }
87
92
  };
88
93
  });
89
94
  }
95
+ getOriginByMode(mode) {
96
+ return this.origins[mode ?? this.$options.mode];
97
+ }
90
98
  getStateValueByMode(state, mode) {
91
99
  return state[mode ?? this.$options.mode];
92
100
  }
@@ -75,6 +75,11 @@ export default class Slider extends Base {
75
75
  * @type {SliderState[]}
76
76
  */
77
77
  states: SliderState[];
78
+ /**
79
+ * Origins for the different modes.
80
+ * @type {Record<SliderModes, number>}
81
+ */
82
+ origins: Record<SliderModes, number>;
78
83
  /**
79
84
  * Get the current state.
80
85
  * @returns {SliderState}
@@ -127,6 +132,12 @@ export default class Slider extends Base {
127
132
  right: number;
128
133
  };
129
134
  }[];
135
+ /**
136
+ * Get an origin by mode.
137
+ * @param {SliderOptions['mode']} [mode]
138
+ * @returns {number}
139
+ */
140
+ getOriginByMode(mode?: SliderOptions['mode']): number;
130
141
  /**
131
142
  * Get a state value according to the given mode.
132
143
  *
@@ -1 +1 @@
1
- import{Base as o}from"@studiometa/js-toolkit";import{clamp as d,inertiaFinalValue as c,nextFrame as h}from"@studiometa/js-toolkit/utils";import u from"./SliderDrag.js";import x from"./SliderItem.js";class I extends o{static config={name:"Slider",refs:["wrapper"],emits:["goto","index"],components:{SliderItem:x,SliderDrag:u},options:{mode:{type:String,default:"left"},fitBounds:Boolean,contain:Boolean,sensitivity:{type:Number,default:1}}};__distanceX=0;__initialX=0;__currentIndex=0;get currentIndex(){return this.__currentIndex}set currentIndex(e){this.currentSliderItem.disactivate(),this.$emit("index",e),this.__currentIndex=e,this.currentSliderItem.activate()}states=[];get currentState(){return this.states[this.currentIndex]}get firstState(){return this.states[0]}get lastState(){return this.states[this.states.length-1]}get containMinState(){return this.getStateValueByMode(this.firstState.x,"left")}get containMaxState(){return this.getStateValueByMode(this.lastState.x,"right")}get indexMax(){return this.$children.SliderItem.length-1}get currentSliderItem(){return this.$children.SliderItem[this.currentIndex]}getStates(){const{wrapper:e}=this.$refs,t=e.getBoundingClientRect(),s={left:t.left,center:t.x+t.width/2,right:t.x+t.width};return this.$children.SliderItem.map(i=>({x:{left:(i.rect.x-s.left)*-1,center:(i.rect.x+i.rect.width/2-s.center)*-1,right:(i.rect.x+i.rect.width-s.right)*-1}}))}getStateValueByMode(e,t){return e[t??this.$options.mode]}mounted(){this.states=this.getStates(),this.prepareInvisibleItems(),this.goTo(this.currentIndex)}resized(){h(()=>{this.states=this.getStates(),h(()=>{this.prepareInvisibleItems(),this.goTo(this.currentIndex)})})}goNext(){this.currentIndex+1>this.indexMax||this.goTo(this.currentIndex+1)}goPrev(){this.currentIndex-1<0||this.goTo(this.currentIndex-1)}goTo(e){if(e<0||e>this.indexMax)throw new Error("Index out of bound.");let t=this.getStateValueByMode(this.states[e].x);this.$options.contain&&(this.$children.SliderItem[this.indexMax].willBeFullyVisible(t)?t=this.getStateValueByMode(this.lastState.x,"right"):this.$children.SliderItem[0].willBeFullyVisible(t)&&(t=this.getStateValueByMode(this.firstState.x,"left")));const s=this.getVisibleItems(t);e<this.currentIndex&&s.reverse(),s.forEach(i=>{h(()=>i.move(t))}),this.currentIndex=e,this.$emit("goto",e)}onSliderDragStart(){this.__initialX=this.currentSliderItem?this.currentSliderItem.x:0}onSliderDragDrag(e){Math.abs(e.delta.y)>Math.abs(e.delta.x)||(this.__distanceX=this.__initialX+e.distance.x*this.$options.sensitivity,this.getVisibleItems(this.__distanceX).forEach(t=>{t.moveInstantly(this.__distanceX)}))}onSliderDragDrop(e){if(Math.abs(e.delta.y)>Math.abs(e.delta.x))return;let t=d(c(this.__distanceX,e.delta.x*this.$options.sensitivity),0,this.getStateValueByMode(this.lastState.x));const s=this.states.map(n=>Math.abs(t-this.getStateValueByMode(n.x))),i=Math.min(...s),r=s.findIndex(n=>n===i);this.$options.fitBounds?this.goTo(r):(this.$options.contain&&(t=Math.min(this.containMinState,t),t=Math.max(this.containMaxState,t)),this.$children.SliderItem.forEach(n=>{n.move(t)}),this.currentIndex=r)}prepareInvisibleItems(){const e=this.states[this.currentIndex],t=[],s=[];this.getInvisibleItems(this.getStateValueByMode(e.x)).forEach((i,r)=>{if(r>this.currentIndex){t.push(i);return}r<this.currentIndex&&s.push(i)}),t.forEach(i=>{const r=this.getStateWhereItemWillBeInvisible(i);r&&i.moveInstantly(this.getStateValueByMode(r.x))}),s.forEach(i=>{const r=this.getStateWhereItemWillBeInvisible(i,{reversed:!0});r&&i.moveInstantly(this.getStateValueByMode(r.x))})}getStateWhereItemWillBeInvisible(e,{reversed:t=!1}={}){const s=this.states.filter(a=>e.willBeVisible(this.getStateValueByMode(a.x))),i=s[0],r=s[s.length-1],n=this.states.findIndex(a=>this.getStateValueByMode(a.x)===this.getStateValueByMode(i.x)),l=this.states.findIndex(a=>a.x===r.x);return t?this.states[l+1]:this.states[n-1]}getVisibleItems(e){return this.$children.SliderItem.filter(t=>t.isVisible||t.willBeVisible(e))}getInvisibleItems(e){return this.$children.SliderItem.filter(t=>!t.isVisible&&!t.willBeVisible(e))}}export{I as default};
1
+ import{Base as o}from"@studiometa/js-toolkit";import{clamp as d,inertiaFinalValue as c,nextFrame as h}from"@studiometa/js-toolkit/utils";import u from"./SliderDrag.js";import g from"./SliderItem.js";class x extends o{static config={name:"Slider",refs:["wrapper"],emits:["goto","index"],components:{SliderItem:g,SliderDrag:u},options:{mode:{type:String,default:"left"},fitBounds:Boolean,contain:Boolean,sensitivity:{type:Number,default:1}}};__distanceX=0;__initialX=0;__currentIndex=0;get currentIndex(){return this.__currentIndex}set currentIndex(e){this.currentSliderItem.disactivate(),this.$emit("index",e),this.__currentIndex=e,this.currentSliderItem.activate()}states=[];origins={left:0,center:0,right:0};get currentState(){return this.states[this.currentIndex]}get firstState(){return this.states[0]}get lastState(){return this.states[this.states.length-1]}get containMinState(){return this.getStateValueByMode(this.firstState.x,"left")}get containMaxState(){return this.getStateValueByMode(this.lastState.x,"right")}get indexMax(){return this.$children.SliderItem.length-1}get currentSliderItem(){return this.$children.SliderItem[this.currentIndex]}getStates(){const{wrapper:e}=this.$refs,t=e.getBoundingClientRect();return this.origins={left:t.left,center:t.x+t.width/2,right:t.x+t.width},this.$children.SliderItem.map(i=>({x:{left:(i.rect.x-this.origins.left)*-1,center:(i.rect.x+i.rect.width/2-this.origins.center)*-1,right:(i.rect.x+i.rect.width-this.origins.right)*-1}}))}getOriginByMode(e){return this.origins[e??this.$options.mode]}getStateValueByMode(e,t){return e[t??this.$options.mode]}mounted(){this.states=this.getStates(),this.prepareInvisibleItems(),this.goTo(this.currentIndex)}resized(){h(()=>{this.states=this.getStates(),h(()=>{this.prepareInvisibleItems(),this.goTo(this.currentIndex)})})}goNext(){this.currentIndex+1>this.indexMax||this.goTo(this.currentIndex+1)}goPrev(){this.currentIndex-1<0||this.goTo(this.currentIndex-1)}goTo(e){if(e<0||e>this.indexMax)throw new Error("Index out of bound.");let t=this.getStateValueByMode(this.states[e].x);this.$options.contain&&(this.$children.SliderItem[this.indexMax].willBeFullyVisible(t)?t=this.getStateValueByMode(this.lastState.x,"right"):this.$children.SliderItem[0].willBeFullyVisible(t)&&(t=this.getStateValueByMode(this.firstState.x,"left")));const i=this.getVisibleItems(t);e<this.currentIndex&&i.reverse(),i.forEach(s=>{h(()=>s.move(t))}),this.currentIndex=e,this.$emit("goto",e)}onSliderDragStart(){this.__initialX=this.currentSliderItem?this.currentSliderItem.x:0}onSliderDragDrag(e){Math.abs(e.delta.y)>Math.abs(e.delta.x)||(this.__distanceX=this.__initialX+e.distance.x*this.$options.sensitivity,this.getVisibleItems(this.__distanceX).forEach(t=>{t.moveInstantly(this.__distanceX)}))}onSliderDragDrop(e){if(Math.abs(e.delta.y)>Math.abs(e.delta.x))return;let t=d(c(this.__distanceX,e.delta.x*this.$options.sensitivity),0,this.getStateValueByMode(this.lastState.x));const i=this.states.map(n=>Math.abs(t-this.getStateValueByMode(n.x))),s=Math.min(...i),r=i.findIndex(n=>n===s);this.$options.fitBounds?this.goTo(r):(this.$options.contain&&(t=Math.min(this.containMinState,t),t=Math.max(this.containMaxState,t)),this.$children.SliderItem.forEach(n=>{n.move(t)}),this.currentIndex=r)}prepareInvisibleItems(){const e=this.states[this.currentIndex],t=[],i=[];this.getInvisibleItems(this.getStateValueByMode(e.x)).forEach((s,r)=>{if(r>this.currentIndex){t.push(s);return}r<this.currentIndex&&i.push(s)}),t.forEach(s=>{const r=this.getStateWhereItemWillBeInvisible(s);r&&s.moveInstantly(this.getStateValueByMode(r.x))}),i.forEach(s=>{const r=this.getStateWhereItemWillBeInvisible(s,{reversed:!0});r&&s.moveInstantly(this.getStateValueByMode(r.x))})}getStateWhereItemWillBeInvisible(e,{reversed:t=!1}={}){const i=this.states.filter(a=>e.willBeVisible(this.getStateValueByMode(a.x))),s=i[0],r=i[i.length-1],n=this.states.findIndex(a=>this.getStateValueByMode(a.x)===this.getStateValueByMode(s.x)),l=this.states.findIndex(a=>a.x===r.x);return t?this.states[l+1]:this.states[n-1]}getVisibleItems(e){return this.$children.SliderItem.filter(t=>t.isVisible||t.willBeVisible(e))}getInvisibleItems(e){return this.$children.SliderItem.filter(t=>!t.isVisible&&!t.willBeVisible(e))}}export{x as default};
@@ -17,6 +17,14 @@ export default class SliderBtn extends AbstractSliderChild {
17
17
  next: BooleanConstructor;
18
18
  };
19
19
  };
20
+ /**
21
+ * Update attributes.
22
+ *
23
+ * @this {SliderBtnInterface}
24
+ * @param {number} index
25
+ * @returns {void}
26
+ */
27
+ update(this: SliderBtnInterface, index: number): void;
20
28
  /**
21
29
  * Go prev or next on click.
22
30
  *
@@ -12,6 +12,14 @@ export default class SliderCount extends AbstractSliderChild {
12
12
  name: string;
13
13
  refs: string[];
14
14
  };
15
+ /**
16
+ * Update the current counter indicator.
17
+ *
18
+ * @this {SliderCountInterface}
19
+ * @param {number} index The new active index.
20
+ * @returns {void}
21
+ */
22
+ update(this: SliderCountInterface, index: number): void;
15
23
  }
16
24
  export type SliderCountInterface = SliderCount & {
17
25
  $refs: {
@@ -16,6 +16,14 @@ export default class SliderDots extends AbstractSliderChild {
16
16
  name: string;
17
17
  refs: string[];
18
18
  };
19
+ /**
20
+ * Update dots classes according to the new index.
21
+ *
22
+ * @this {SliderDotsInterface}
23
+ * @param {number} index
24
+ * @returns {void}
25
+ */
26
+ update(this: SliderDotsInterface, index: number): void;
19
27
  /**
20
28
  * Go to the given index on dot click.
21
29
  *
@@ -35,6 +35,10 @@ var SliderDrag = class extends (0, import_js_toolkit.withDrag)(import_js_toolkit
35
35
  };
36
36
  __publicField(SliderDrag, "config", {
37
37
  name: "SliderDrag",
38
- emits: ["start", "drag", "drop", "inertia", "stop"]
38
+ emits: ["start", "drag", "drop", "inertia", "stop"],
39
+ sensitivity: {
40
+ type: Number,
41
+ default: 1
42
+ }
39
43
  });
40
44
  if (module.exports.default) module.exports = module.exports.default;
@@ -2,9 +2,16 @@
2
2
  * SliderDrag class.
3
3
  */
4
4
  export default class SliderDrag extends Base {
5
+ /**
6
+ * Config.
7
+ */
5
8
  static config: {
6
9
  name: string;
7
10
  emits: string[];
11
+ sensitivity: {
12
+ type: NumberConstructor;
13
+ default: number;
14
+ };
8
15
  };
9
16
  /**
10
17
  * Emit drag events.
@@ -1 +1 @@
1
- import{Base as e,withDrag as a}from"@studiometa/js-toolkit";class r extends a(e){static config={name:"SliderDrag",emits:["start","drag","drop","inertia","stop"]};dragged(t){this.$emit(t.mode,t)}}export{r as default};
1
+ import{Base as e,withDrag as i}from"@studiometa/js-toolkit";class a extends i(e){static config={name:"SliderDrag",emits:["start","drag","drop","inertia","stop"],sensitivity:{type:Number,default:1}};dragged(t){this.$emit(t.mode,t)}}export{a as default};
@@ -57,9 +57,7 @@ var SliderItem = class extends (0, import_js_toolkit.withIntersectionObserver)(i
57
57
  }
58
58
  ticked() {
59
59
  this.dampedX = (0, import_utils.damp)(this.x, this.dampedX, 0.2, 1e-5);
60
- this.$el.style.transform = `${(0, import_utils.matrix)({
61
- translateX: this.dampedX
62
- })} translateZ(0px)`;
60
+ this.render();
63
61
  if (this.dampedX === this.x) {
64
62
  this.$services.disable("ticked");
65
63
  }
@@ -79,9 +77,12 @@ var SliderItem = class extends (0, import_js_toolkit.withIntersectionObserver)(i
79
77
  moveInstantly(targetPosition) {
80
78
  this.x = targetPosition;
81
79
  this.dampedX = targetPosition;
82
- this.$el.style.transform = `${(0, import_utils.matrix)({
83
- translateX: targetPosition
84
- })} translateZ(0px)`;
80
+ this.render();
81
+ }
82
+ render() {
83
+ import_utils.domScheduler.write(() => {
84
+ (0, import_utils.transform)(this.$el, { x: this.dampedX });
85
+ });
85
86
  }
86
87
  willBeVisible(targetPosition) {
87
88
  return this.rect.x + targetPosition < window.innerWidth * 1.5 && this.rect.x + targetPosition + this.rect.width > window.innerWidth * -0.5;
@@ -52,6 +52,9 @@ export default class SliderItem extends Base {
52
52
  /**
53
53
  * Ticked hook.
54
54
  *
55
+ * @todo create AbstractSliderItem with `render` method
56
+ * @todo add state to SliderItem
57
+ * @todo add origin to SliderItem
55
58
  * @returns {void}
56
59
  */
57
60
  ticked(): void;
@@ -81,6 +84,12 @@ export default class SliderItem extends Base {
81
84
  * @returns {void}
82
85
  */
83
86
  moveInstantly(targetPosition: number): void;
87
+ /**
88
+ * Render the component.
89
+ *
90
+ * @returns {void}
91
+ */
92
+ render(): void;
84
93
  /**
85
94
  * Check if SliderItem is partially visible for the given target position.
86
95
  *
@@ -1 +1 @@
1
- import{Base as s,withIntersectionObserver as d}from"@studiometa/js-toolkit";import{matrix as i,damp as h}from"@studiometa/js-toolkit/utils";class l extends d(s,{threshold:[0,1]}){static config={name:"SliderItem",emits:["is-fully-visible","is-partially-visible","is-hidden"]};isVisible=!1;x=0;dampedX=0;mounted(){this.updateRectAdjustedWithX()}resized(){this.updateRectAdjustedWithX()}destroyed(){this.moveInstantly(0)}intersected([{intersectionRatio:t,isIntersecting:e}]){t>=1?(this.$emit("is-fully-visible"),this.$el.setAttribute("aria-hidden","false")):t>0?(this.$emit("is-partially-visible"),this.$el.setAttribute("aria-hidden","true")):(this.$emit("is-hidden"),this.$el.setAttribute("aria-hidden","true")),this.isVisible=e}ticked(){this.dampedX=h(this.x,this.dampedX,.2,1e-5),this.$el.style.transform=`${i({translateX:this.dampedX})} translateZ(0px)`,this.dampedX===this.x&&this.$services.disable("ticked")}activate(){this.$el.classList.add("is-active")}disactivate(){this.$el.classList.remove("is-active")}move(t){this.x=t,this.$services.has("ticked")||this.$services.enable("ticked")}moveInstantly(t){this.x=t,this.dampedX=t,this.$el.style.transform=`${i({translateX:t})} translateZ(0px)`}willBeVisible(t){return this.rect.x+t<window.innerWidth*1.5&&this.rect.x+t+this.rect.width>window.innerWidth*-.5}willBeFullyVisible(t){return this.rect.x+t<window.innerWidth&&this.rect.x+t>0&&this.rect.x+t+this.rect.width<window.innerWidth&&this.rect.x+t+this.rect.width>0}updateRectAdjustedWithX(){const t=this.x*-1,e=this.$el.getBoundingClientRect().toJSON();this.rect={...e,left:e.left+t,right:e.left+t+e.width,x:e.left+t}}}export{l as default};
1
+ import{Base as t,withIntersectionObserver as s}from"@studiometa/js-toolkit";import{damp as d,domScheduler as h,transform as r}from"@studiometa/js-toolkit/utils";class l extends s(t,{threshold:[0,1]}){static config={name:"SliderItem",emits:["is-fully-visible","is-partially-visible","is-hidden"]};isVisible=!1;x=0;dampedX=0;mounted(){this.updateRectAdjustedWithX()}resized(){this.updateRectAdjustedWithX()}destroyed(){this.moveInstantly(0)}intersected([{intersectionRatio:e,isIntersecting:i}]){e>=1?(this.$emit("is-fully-visible"),this.$el.setAttribute("aria-hidden","false")):e>0?(this.$emit("is-partially-visible"),this.$el.setAttribute("aria-hidden","true")):(this.$emit("is-hidden"),this.$el.setAttribute("aria-hidden","true")),this.isVisible=i}ticked(){this.dampedX=d(this.x,this.dampedX,.2,1e-5),this.render(),this.dampedX===this.x&&this.$services.disable("ticked")}activate(){this.$el.classList.add("is-active")}disactivate(){this.$el.classList.remove("is-active")}move(e){this.x=e,this.$services.has("ticked")||this.$services.enable("ticked")}moveInstantly(e){this.x=e,this.dampedX=e,this.render()}render(){h.write(()=>{r(this.$el,{x:this.dampedX})})}willBeVisible(e){return this.rect.x+e<window.innerWidth*1.5&&this.rect.x+e+this.rect.width>window.innerWidth*-.5}willBeFullyVisible(e){return this.rect.x+e<window.innerWidth&&this.rect.x+e>0&&this.rect.x+e+this.rect.width<window.innerWidth&&this.rect.x+e+this.rect.width>0}updateRectAdjustedWithX(){const e=this.x*-1,i=this.$el.getBoundingClientRect().toJSON();this.rect={...i,left:i.left+e,right:i.left+e+i.width,x:i.left+e}}}export{l as default};
@@ -34,9 +34,13 @@ var import_utils = require("@studiometa/js-toolkit/utils");
34
34
  var import_AbstractSliderChild = __toESM(require("./AbstractSliderChild.cjs"), 1);
35
35
  var SliderProgress = class extends import_AbstractSliderChild.default {
36
36
  update(index) {
37
- const unit = this.$refs.progress.clientWidth / this.$parent.indexMax;
38
- this.$refs.progress.style.transform = (0, import_utils.matrix)({
39
- translateX: (0, import_utils.map)(index, 0, this.$parent.indexMax, (this.$refs.progress.clientWidth - unit) * -1, 0)
37
+ import_utils.domScheduler.read(() => {
38
+ const unit = this.$refs.progress.clientWidth / (this.$parent.indexMax + 1);
39
+ import_utils.domScheduler.write(() => {
40
+ this.$refs.progress.style.transform = (0, import_utils.matrix)({
41
+ translateX: (0, import_utils.map)(index, 0, this.$parent.indexMax, (this.$refs.progress.clientWidth - unit) * -1, 0)
42
+ });
43
+ });
40
44
  });
41
45
  }
42
46
  };
@@ -17,6 +17,14 @@ export default class SliderProgress extends AbstractSliderChild {
17
17
  name: string;
18
18
  refs: string[];
19
19
  };
20
+ /**
21
+ * Update the progress indicator.
22
+ *
23
+ * @this {SliderProgressInterface}
24
+ * @param {number} index The new active index.
25
+ * @returns {void}
26
+ */
27
+ update(this: SliderProgressInterface, index: number): void;
20
28
  }
21
29
  export type SliderProgressInterface = SliderProgress & {
22
30
  $refs: {
@@ -1 +1 @@
1
- import{matrix as t,map as e}from"@studiometa/js-toolkit/utils";import i from"./AbstractSliderChild.js";class a extends i{static config={name:"SliderProgress",refs:["progress"]};update(r){const s=this.$refs.progress.clientWidth/this.$parent.indexMax;this.$refs.progress.style.transform=t({translateX:e(r,0,this.$parent.indexMax,(this.$refs.progress.clientWidth-s)*-1,0)})}}export{a as default};
1
+ import{matrix as t,map as i,domScheduler as r}from"@studiometa/js-toolkit/utils";import a from"./AbstractSliderChild.js";class o extends a{static config={name:"SliderProgress",refs:["progress"]};update(e){r.read(()=>{const s=this.$refs.progress.clientWidth/(this.$parent.indexMax+1);r.write(()=>{this.$refs.progress.style.transform=t({translateX:i(e,0,this.$parent.indexMax,(this.$refs.progress.clientWidth-s)*-1,0)})})})}}export{o as default};
@@ -55,14 +55,8 @@ var _Frame = class extends import_js_toolkit.Base {
55
55
  }
56
56
  return this.$children[name].filter((child) => this.$children.Frame.every((frame) => frame.$children[name] ? !frame.$children[name].includes(child) : true));
57
57
  }
58
- get directChildFrameAnchor() {
59
- return this.getDirectChild("FrameAnchor");
60
- }
61
- get directChildFrameForm() {
62
- return this.getDirectChild("form");
63
- }
64
- get directChildFrameTarget() {
65
- return this.getDirectChild("FrameTarget");
58
+ get directChildrenFrameTarget() {
59
+ return (0, import_js_toolkit.getDirectChildren)(this, "Frame", "FrameTarget");
66
60
  }
67
61
  mounted() {
68
62
  if (this.$options.history) {
@@ -93,8 +87,8 @@ var _Frame = class extends import_js_toolkit.Base {
93
87
  onWindowPopstate(event) {
94
88
  this.goTo(window.location.href, event.state);
95
89
  }
96
- onFrameAnchorFrameClick(event, index) {
97
- if (!this.directChildFrameAnchor.includes(this.$children.FrameAnchor[index])) {
90
+ onFrameAnchorClick(event, index) {
91
+ if (!(0, import_js_toolkit.isDirectChild)(this, "Frame", "FrameAnchor", this.$children.FrameAnchor[index])) {
98
92
  return;
99
93
  }
100
94
  this.$log("onAFrameClick", event, index);
@@ -105,14 +99,16 @@ var _Frame = class extends import_js_toolkit.Base {
105
99
  }
106
100
  this.goTo(anchor.href);
107
101
  }
108
- onFrameFormFrameSubmit(event, index) {
109
- if (!this.directChildFrameForm.includes(this.$children.FrameForm[index])) {
102
+ onFrameFormSubmit(event, index) {
103
+ if (!(0, import_js_toolkit.isDirectChild)(this, "Frame", "FrameForm", this.$children.FrameForm[index])) {
110
104
  return;
111
105
  }
112
106
  this.$log("onFrameFormFrameSubmit", event);
113
107
  event.preventDefault();
114
108
  const form = this.$children.FrameForm[index];
115
- this.goTo(form.action);
109
+ const url = new URL(form.action);
110
+ url.search = new URLSearchParams(new FormData(form.$el)).toString();
111
+ this.goTo(url.toString());
116
112
  }
117
113
  parseHTML(string = "") {
118
114
  return new DOMParser().parseFromString(string, "text/html");
@@ -131,10 +127,10 @@ var _Frame = class extends import_js_toolkit.Base {
131
127
  newFrame.$children.registerAll();
132
128
  this.$emit("after-fetch", url, content);
133
129
  this.$emit("before-leave");
134
- await Promise.all(this.directChildFrameTarget.map((target) => target.leave()));
130
+ await Promise.all(this.directChildrenFrameTarget.map((target) => target.leave()));
135
131
  this.$emit("after-leave");
136
132
  this.$emit("before-content");
137
- this.directChildFrameTarget.map((target, index) => target.updateContent(newFrame.directChildFrameTarget[index]));
133
+ this.directChildrenFrameTarget.map((target, index) => target.updateContent(newFrame.directChildrenFrameTarget[index]));
138
134
  if (this.$options.history) {
139
135
  document.title = doc.title;
140
136
  (0, import_utils.historyPush)({ path: parsedUrl.pathname, search: parsedUrl.searchParams });
@@ -148,7 +144,7 @@ var _Frame = class extends import_js_toolkit.Base {
148
144
  await (0, import_utils.nextFrame)();
149
145
  this.$emit("after-content");
150
146
  this.$emit("before-enter");
151
- await Promise.all(this.directChildFrameTarget.map((target) => target.enter()));
147
+ await Promise.all(this.directChildrenFrameTarget.map((target) => target.enter()));
152
148
  this.$emit("after-enter");
153
149
  }
154
150
  async fetch(url) {
@@ -48,21 +48,11 @@ export default class Frame extends Base {
48
48
  * @returns {any[]}
49
49
  */
50
50
  getDirectChild(this: FrameInterface, name: string): any[];
51
- /**
52
- * Get direct `FrameAnchor` children.
53
- * @returns {FrameAnchor[]}
54
- */
55
- get directChildFrameAnchor(): FrameAnchor[];
56
- /**
57
- * Get direct `FrameForm` children.
58
- * @returns {FrameForm[]}
59
- */
60
- get directChildFrameForm(): FrameForm[];
61
51
  /**
62
52
  * Get direct `FrameTarget` children.
63
53
  * @returns {FrameTarget[]}
64
54
  */
65
- get directChildFrameTarget(): FrameTarget[];
55
+ get directChildrenFrameTarget(): FrameTarget[];
66
56
  /**
67
57
  * Mounted hook.
68
58
  * @returns {void}
@@ -100,7 +90,7 @@ export default class Frame extends Base {
100
90
  * @param {number} index
101
91
  * @returns {void}
102
92
  */
103
- onFrameAnchorFrameClick(this: FrameInterface, event: MouseEvent, index: number): void;
93
+ onFrameAnchorClick(this: FrameInterface, event: MouseEvent, index: number): void;
104
94
  /**
105
95
  * Prevent submit on forms.
106
96
  *
@@ -109,7 +99,7 @@ export default class Frame extends Base {
109
99
  * @param {number} index
110
100
  * @returns {void}
111
101
  */
112
- onFrameFormFrameSubmit(this: FrameInterface, event: SubmitEvent, index: number): void;
102
+ onFrameFormSubmit(this: FrameInterface, event: SubmitEvent, index: number): void;
113
103
  /**
114
104
  * Parge an HTML string into a DOM object.
115
105
  * @param {string} string
@@ -147,6 +137,6 @@ export type FrameInterface = Frame & {
147
137
  };
148
138
  };
149
139
  import { Base } from "@studiometa/js-toolkit";
140
+ import FrameTarget from "./FrameTarget.js";
150
141
  import FrameAnchor from "./FrameAnchor.js";
151
142
  import FrameForm from "./FrameForm.js";
152
- import FrameTarget from "./FrameTarget.js";