@studiometa/ui 0.2.3 → 0.2.6

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 (163) hide show
  1. package/atoms/AnchorScrollTo/AnchorScrollTo.cjs +8 -13
  2. package/atoms/AnchorScrollTo/AnchorScrollTo.js +1 -26
  3. package/atoms/Button/Button.twig +68 -0
  4. package/atoms/Button/StyledButton.twig +47 -0
  5. package/atoms/Cursor/Cursor.cjs +14 -22
  6. package/atoms/Cursor/Cursor.d.ts +2 -2
  7. package/atoms/Cursor/Cursor.js +1 -103
  8. package/atoms/Cursor/Cursor.twig +28 -0
  9. package/atoms/Figure/Figure.cjs +20 -16
  10. package/atoms/Figure/Figure.d.ts +19 -1
  11. package/atoms/Figure/Figure.js +1 -27
  12. package/atoms/Figure/Figure.twig +120 -0
  13. package/atoms/Figure/FigureTwicPics.cjs +72 -0
  14. package/atoms/Figure/FigureTwicPics.d.ts +48 -0
  15. package/atoms/Figure/FigureTwicPics.js +1 -0
  16. package/atoms/Figure/index.cjs +31 -0
  17. package/atoms/Figure/index.d.ts +2 -0
  18. package/atoms/Figure/index.js +1 -0
  19. package/atoms/Icon/Icon.twig +13 -0
  20. package/atoms/LargeText/LargeText.cjs +15 -23
  21. package/atoms/LargeText/LargeText.d.ts +3 -3
  22. package/atoms/LargeText/LargeText.js +1 -64
  23. package/atoms/LargeText/LargeText.twig +49 -0
  24. package/atoms/LazyInclude/LazyInclude.cjs +8 -13
  25. package/atoms/LazyInclude/LazyInclude.d.ts +4 -4
  26. package/atoms/LazyInclude/LazyInclude.js +1 -46
  27. package/atoms/Prefetch/AbstractPrefetch.cjs +8 -13
  28. package/atoms/Prefetch/AbstractPrefetch.d.ts +1 -1
  29. package/atoms/Prefetch/AbstractPrefetch.js +1 -58
  30. package/atoms/Prefetch/PrefetchWhenOver.cjs +12 -34
  31. package/atoms/Prefetch/PrefetchWhenOver.d.ts +1 -1
  32. package/atoms/Prefetch/PrefetchWhenOver.js +1 -35
  33. package/atoms/Prefetch/PrefetchWhenVisible.cjs +12 -34
  34. package/atoms/Prefetch/PrefetchWhenVisible.d.ts +1 -1
  35. package/atoms/Prefetch/PrefetchWhenVisible.js +1 -36
  36. package/atoms/Prefetch/index.cjs +9 -16
  37. package/atoms/Prefetch/index.js +1 -8
  38. package/atoms/ScrollAnimation/AbstractScrollAnimation.cjs +126 -0
  39. package/atoms/ScrollAnimation/AbstractScrollAnimation.d.ts +133 -0
  40. package/atoms/ScrollAnimation/AbstractScrollAnimation.js +1 -0
  41. package/atoms/ScrollAnimation/ScrollAnimation.cjs +51 -0
  42. package/atoms/ScrollAnimation/ScrollAnimation.d.ts +55 -0
  43. package/atoms/ScrollAnimation/ScrollAnimation.js +1 -0
  44. package/atoms/ScrollAnimation/ScrollAnimationChild.cjs +51 -0
  45. package/atoms/ScrollAnimation/ScrollAnimationChild.d.ts +13 -0
  46. package/atoms/ScrollAnimation/ScrollAnimationChild.js +1 -0
  47. package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.cjs +41 -0
  48. package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.d.ts +6 -0
  49. package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.js +1 -0
  50. package/atoms/ScrollAnimation/ScrollAnimationParent.cjs +48 -0
  51. package/atoms/ScrollAnimation/ScrollAnimationParent.d.ts +35 -0
  52. package/atoms/ScrollAnimation/ScrollAnimationParent.js +1 -0
  53. package/atoms/ScrollAnimation/ScrollAnimationWithEase.cjs +41 -0
  54. package/atoms/ScrollAnimation/ScrollAnimationWithEase.d.ts +6 -0
  55. package/atoms/ScrollAnimation/ScrollAnimationWithEase.js +1 -0
  56. package/atoms/ScrollAnimation/animationScrollWithEase.cjs +70 -0
  57. package/atoms/ScrollAnimation/animationScrollWithEase.d.ts +11 -0
  58. package/atoms/ScrollAnimation/animationScrollWithEase.js +1 -0
  59. package/atoms/ScrollAnimation/index.cjs +41 -0
  60. package/atoms/ScrollAnimation/index.d.ts +7 -0
  61. package/atoms/ScrollAnimation/index.js +1 -0
  62. package/atoms/index.cjs +13 -19
  63. package/atoms/index.d.ts +2 -1
  64. package/atoms/index.js +1 -13
  65. package/index.cjs +12 -15
  66. package/index.d.ts +1 -0
  67. package/index.js +1 -3
  68. package/molecules/Accordion/Accordion.cjs +12 -34
  69. package/molecules/Accordion/Accordion.js +1 -35
  70. package/molecules/Accordion/Accordion.twig +54 -0
  71. package/molecules/Accordion/AccordionCore.cjs +8 -13
  72. package/molecules/Accordion/AccordionCore.d.ts +2 -2
  73. package/molecules/Accordion/AccordionCore.js +1 -34
  74. package/molecules/Accordion/AccordionItem.cjs +70 -114
  75. package/molecules/Accordion/AccordionItem.d.ts +7 -6
  76. package/molecules/Accordion/AccordionItem.js +1 -178
  77. package/molecules/Menu/Menu.cjs +148 -0
  78. package/molecules/Menu/Menu.d.ts +140 -0
  79. package/molecules/Menu/Menu.js +1 -0
  80. package/molecules/Menu/MenuBtn.cjs +53 -0
  81. package/molecules/Menu/MenuBtn.d.ts +39 -0
  82. package/molecules/Menu/MenuBtn.js +1 -0
  83. package/molecules/Menu/MenuList.cjs +134 -0
  84. package/molecules/Menu/MenuList.d.ts +101 -0
  85. package/molecules/Menu/MenuList.js +1 -0
  86. package/molecules/Menu/index.cjs +33 -0
  87. package/molecules/Menu/index.d.ts +3 -0
  88. package/molecules/Menu/index.js +1 -0
  89. package/molecules/Modal/Modal.cjs +42 -71
  90. package/molecules/Modal/Modal.d.ts +5 -5
  91. package/molecules/Modal/Modal.js +1 -150
  92. package/molecules/Modal/Modal.twig +108 -0
  93. package/molecules/Modal/ModalWithTransition.cjs +13 -43
  94. package/molecules/Modal/ModalWithTransition.js +1 -69
  95. package/molecules/Modal/StyledModal.twig +39 -0
  96. package/molecules/Panel/Panel.cjs +42 -76
  97. package/molecules/Panel/Panel.js +1 -117
  98. package/molecules/Panel/Panel.twig +73 -0
  99. package/molecules/Panel/StyledPanel.twig +28 -0
  100. package/molecules/Slider/AbstractSliderChild.cjs +10 -20
  101. package/molecules/Slider/AbstractSliderChild.d.ts +6 -2
  102. package/molecules/Slider/AbstractSliderChild.js +1 -43
  103. package/molecules/Slider/Slider.cjs +14 -24
  104. package/molecules/Slider/Slider.d.ts +6 -6
  105. package/molecules/Slider/Slider.js +1 -209
  106. package/molecules/Slider/SliderBtn.cjs +9 -16
  107. package/molecules/Slider/SliderBtn.d.ts +1 -1
  108. package/molecules/Slider/SliderBtn.js +1 -34
  109. package/molecules/Slider/SliderCount.cjs +9 -16
  110. package/molecules/Slider/SliderCount.js +1 -19
  111. package/molecules/Slider/SliderDots.cjs +9 -16
  112. package/molecules/Slider/SliderDots.js +1 -24
  113. package/molecules/Slider/SliderDrag.cjs +8 -13
  114. package/molecules/Slider/SliderDrag.js +1 -19
  115. package/molecules/Slider/SliderItem.cjs +14 -37
  116. package/molecules/Slider/SliderItem.js +1 -105
  117. package/molecules/Slider/SliderProgress.cjs +9 -16
  118. package/molecules/Slider/SliderProgress.js +1 -23
  119. package/molecules/Slider/index.cjs +9 -16
  120. package/molecules/Slider/index.js +1 -18
  121. package/molecules/Sticky/Sticky.cjs +11 -19
  122. package/molecules/Sticky/Sticky.d.ts +8 -8
  123. package/molecules/Sticky/Sticky.js +1 -107
  124. package/molecules/Sticky/Sticky.twig +31 -0
  125. package/molecules/TableOfContent/TableOfContent.cjs +9 -16
  126. package/molecules/TableOfContent/TableOfContent.d.ts +1 -1
  127. package/molecules/TableOfContent/TableOfContent.js +1 -42
  128. package/molecules/TableOfContent/TableOfContentAnchor.cjs +8 -13
  129. package/molecules/TableOfContent/TableOfContentAnchor.js +1 -39
  130. package/molecules/TableOfContent/index.cjs +9 -16
  131. package/molecules/TableOfContent/index.js +1 -6
  132. package/molecules/Tabs/Tabs.cjs +54 -82
  133. package/molecules/Tabs/Tabs.d.ts +5 -4
  134. package/molecules/Tabs/Tabs.js +1 -126
  135. package/molecules/Tabs/Tabs.twig +20 -0
  136. package/molecules/index.cjs +13 -18
  137. package/molecules/index.d.ts +1 -0
  138. package/molecules/index.js +1 -18
  139. package/organisms/Frame/Frame.cjs +107 -99
  140. package/organisms/Frame/Frame.d.ts +37 -4
  141. package/organisms/Frame/Frame.js +1 -171
  142. package/organisms/Frame/FrameAnchor.cjs +8 -13
  143. package/organisms/Frame/FrameAnchor.js +1 -22
  144. package/organisms/Frame/FrameForm.cjs +8 -13
  145. package/organisms/Frame/FrameForm.js +1 -22
  146. package/organisms/Frame/FrameTarget.cjs +31 -73
  147. package/organisms/Frame/FrameTarget.js +1 -109
  148. package/organisms/Frame/index.cjs +9 -16
  149. package/organisms/Frame/index.js +1 -10
  150. package/organisms/ImageGrid/ImageGrid.twig +42 -0
  151. package/organisms/index.cjs +9 -13
  152. package/organisms/index.js +1 -1
  153. package/package.json +3 -4
  154. package/primitives/Draggable/Draggable.cjs +15 -28
  155. package/primitives/Draggable/Draggable.d.ts +0 -5
  156. package/primitives/Draggable/Draggable.js +1 -38
  157. package/primitives/Sentinel/Sentinel.cjs +8 -13
  158. package/primitives/Sentinel/Sentinel.js +1 -15
  159. package/primitives/Transition/Transition.cjs +12 -17
  160. package/primitives/Transition/Transition.d.ts +2 -4
  161. package/primitives/Transition/Transition.js +1 -45
  162. package/primitives/index.cjs +9 -16
  163. package/primitives/index.js +1 -8
@@ -3,24 +3,19 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
7
6
  var __export = (target, all) => {
8
7
  for (var name in all)
9
8
  __defProp(target, name, { get: all[name], enumerable: true });
10
9
  };
11
- var __reExport = (target, module2, copyDefault, desc) => {
12
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
13
- for (let key of __getOwnPropNames(module2))
14
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
15
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
15
  }
17
- return target;
16
+ return to;
18
17
  };
19
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
20
- return (module2, temp) => {
21
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
22
- };
23
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
19
  var __publicField = (obj, key, value) => {
25
20
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
26
21
  return value;
@@ -31,6 +26,7 @@ var AnchorScrollTo_exports = {};
31
26
  __export(AnchorScrollTo_exports, {
32
27
  default: () => AnchorScrollTo
33
28
  });
29
+ module.exports = __toCommonJS(AnchorScrollTo_exports);
34
30
  var import_js_toolkit = require("@studiometa/js-toolkit");
35
31
  var import_utils = require("@studiometa/js-toolkit/utils");
36
32
  var AnchorScrollTo = class extends import_js_toolkit.Base {
@@ -48,5 +44,4 @@ var AnchorScrollTo = class extends import_js_toolkit.Base {
48
44
  __publicField(AnchorScrollTo, "config", {
49
45
  name: "AnchorScrollTo"
50
46
  });
51
- module.exports = __toCommonJS(AnchorScrollTo_exports);
52
47
  if (module.exports.default) module.exports = module.exports.default;
@@ -1,26 +1 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import { Base } from "@studiometa/js-toolkit";
8
- import { scrollTo } from "@studiometa/js-toolkit/utils";
9
- class AnchorScrollTo extends Base {
10
- get targetSelector() {
11
- return this.$el.hash;
12
- }
13
- onClick(event) {
14
- try {
15
- scrollTo(this.targetSelector);
16
- event.preventDefault();
17
- } catch (err) {
18
- }
19
- }
20
- }
21
- __publicField(AnchorScrollTo, "config", {
22
- name: "AnchorScrollTo"
23
- });
24
- export {
25
- AnchorScrollTo as default
26
- };
1
+ import{Base as r}from"@studiometa/js-toolkit";import{scrollTo as e}from"@studiometa/js-toolkit/utils";class o extends r{static config={name:"AnchorScrollTo"};get targetSelector(){return this.$el.hash}onClick(t){try{e(this.targetSelector),t.preventDefault()}catch{}}}export{o as default};
@@ -0,0 +1,68 @@
1
+ {#
2
+ /**
3
+ * @file
4
+ * Button component.
5
+ *
6
+ * @param string $label
7
+ * @param string $tag
8
+ * @param string $href
9
+ * @param array $attr
10
+ * @param string $icon
11
+ * @param array|string $icon_classes
12
+ * @param 'start'|'end' $icon_position
13
+ * @param boolean $icon_only
14
+ */
15
+ #}
16
+
17
+ {# Customizable tag with a default value. #}
18
+ {% set tag =
19
+ tag|default(href is defined or (attr is defined and attr.href is defined) ? 'a' : 'button')
20
+ %}
21
+
22
+ {# Default icon values #}
23
+ {% set icon_position = icon_position|default('start') %}
24
+ {% set icon_only = icon_only|default(false) %}
25
+
26
+ {# Final attributes are a merge of the defaults, the given and then the required #}
27
+ {% set attributes =
28
+ merge_html_attributes(
29
+ attr ?? null,
30
+ {
31
+ title: label,
32
+ type: tag == 'button' ? 'button' : false,
33
+ href: tag == 'a' and href is defined ? href : false,
34
+ aria_label: icon_only ? label : false
35
+ },
36
+ { class: ['btn'] }
37
+ )
38
+ %}
39
+
40
+ {% set rendered_icon %}
41
+ {% block icon %}
42
+ {% include '@ui/atoms/Icon/Icon.twig' with {
43
+ name: icon ?? '',
44
+ classes: icon_classes ?? {
45
+ 'mr-3': not icon_only and icon_position == 'start',
46
+ 'ml-3': not icon_only and icon_position == 'end',
47
+ }
48
+ } %}
49
+ {% endblock %}
50
+ {% endset %}
51
+
52
+ {% html_element tag with attributes %}
53
+ {% block content %}
54
+ {% if icon is defined and icon_position == 'start' %}
55
+ {{ rendered_icon }}
56
+ {% endif %}
57
+ {% block label %}
58
+ {% if icon_only %}
59
+ <span class="sr-only">{{ label }}</span>
60
+ {% else %}
61
+ {{ label }}
62
+ {% endif %}
63
+ {% endblock %}
64
+ {% if icon is defined and icon_position == 'end' %}
65
+ {{ rendered_icon }}
66
+ {% endif %}
67
+ {% endblock %}
68
+ {% end_html_element %}
@@ -0,0 +1,47 @@
1
+ {#
2
+ /**
3
+ * @file
4
+ * Styled button.
5
+ *
6
+ * @param 'primary'|'secondary'|'tertiary' $theme
7
+ */
8
+ #}
9
+
10
+ {% extends '@ui/atoms/Button/Button.twig' %}
11
+
12
+ {% set icon_only = icon_only|default(false) %}
13
+
14
+ {% set theme = theme|default('primary') %}
15
+
16
+ {% set theme_shared = [
17
+ 'rounded cursor-pointer transition',
18
+ 'disabled:cursor-not-allowed',
19
+ {
20
+ 'inline-block': icon is not defined,
21
+ 'inline-flex items-center': icon is defined,
22
+ 'px-6 py-4': not icon_only,
23
+ 'p-4': icon_only
24
+ }
25
+ ] %}
26
+
27
+ {% set theme_primary = ['text-white bg-black', 'hover:bg-opacity-75 disabled:bg-opacity-50'] %}
28
+
29
+ {% set theme_secondary = [
30
+ 'ring ring-inset ring-2 ring-black ring-opacity-25',
31
+ {
32
+ 'hover:ring-opacity-100': (attr is defined and attr.disabled is not defined)
33
+ or attr is not defined
34
+ }
35
+ ] %}
36
+
37
+ {% set attr =
38
+ attr
39
+ |default({})
40
+ |merge({
41
+ class: [
42
+ theme_shared,
43
+ theme == 'primary' ? theme_primary : '',
44
+ theme == 'secondary' ? theme_secondary : ''
45
+ ]
46
+ })
47
+ %}
@@ -3,24 +3,19 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
7
6
  var __export = (target, all) => {
8
7
  for (var name in all)
9
8
  __defProp(target, name, { get: all[name], enumerable: true });
10
9
  };
11
- var __reExport = (target, module2, copyDefault, desc) => {
12
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
13
- for (let key of __getOwnPropNames(module2))
14
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
15
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
15
  }
17
- return target;
16
+ return to;
18
17
  };
19
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
20
- return (module2, temp) => {
21
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
22
- };
23
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
19
  var __publicField = (obj, key, value) => {
25
20
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
26
21
  return value;
@@ -31,18 +26,16 @@ var Cursor_exports = {};
31
26
  __export(Cursor_exports, {
32
27
  default: () => Cursor
33
28
  });
29
+ module.exports = __toCommonJS(Cursor_exports);
34
30
  var import_js_toolkit = require("@studiometa/js-toolkit");
35
31
  var import_utils = require("@studiometa/js-toolkit/utils");
36
32
  var Cursor = class extends import_js_toolkit.Base {
37
- constructor() {
38
- super(...arguments);
39
- __publicField(this, "x", 0);
40
- __publicField(this, "y", 0);
41
- __publicField(this, "scale", 0);
42
- __publicField(this, "pointerX", 0);
43
- __publicField(this, "pointerY", 0);
44
- __publicField(this, "pointerScale", 0);
45
- }
33
+ x = 0;
34
+ y = 0;
35
+ scale = 0;
36
+ pointerX = 0;
37
+ pointerY = 0;
38
+ pointerScale = 0;
46
39
  mounted() {
47
40
  this.x = 0;
48
41
  this.y = 0;
@@ -125,5 +118,4 @@ __publicField(Cursor, "config", {
125
118
  }
126
119
  }
127
120
  });
128
- module.exports = __toCommonJS(Cursor_exports);
129
121
  if (module.exports.default) module.exports = module.exports.default;
@@ -96,7 +96,7 @@ export default class Cursor extends Base {
96
96
  * @param {PointerServiceProps} options
97
97
  * @return {void}
98
98
  */
99
- moved({ event, x, y, isDown }: PointerServiceProps): void;
99
+ moved(this: CursorInterface, { event, x, y, isDown }: PointerServiceProps): void;
100
100
  /**
101
101
  * RequestAnimationFrame hook.
102
102
  *
@@ -104,7 +104,7 @@ export default class Cursor extends Base {
104
104
  *
105
105
  * @return {void}
106
106
  */
107
- ticked(): void;
107
+ ticked(this: CursorInterface): void;
108
108
  /**
109
109
  * Render the cursor.
110
110
  *
@@ -1,103 +1 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import { Base } from "@studiometa/js-toolkit";
8
- import { damp, matrix } from "@studiometa/js-toolkit/utils";
9
- class Cursor extends Base {
10
- constructor() {
11
- super(...arguments);
12
- __publicField(this, "x", 0);
13
- __publicField(this, "y", 0);
14
- __publicField(this, "scale", 0);
15
- __publicField(this, "pointerX", 0);
16
- __publicField(this, "pointerY", 0);
17
- __publicField(this, "pointerScale", 0);
18
- }
19
- mounted() {
20
- this.x = 0;
21
- this.y = 0;
22
- this.scale = 0;
23
- this.pointerX = 0;
24
- this.pointerY = 0;
25
- this.pointerScale = 0;
26
- this.render({ x: this.x, y: this.y, scale: this.scale });
27
- }
28
- moved({ event, x, y, isDown }) {
29
- if (!this.$services.has("ticked")) {
30
- this.$services.enable("ticked");
31
- }
32
- this.pointerX = x;
33
- this.pointerY = y;
34
- let scale = 1;
35
- if (!event) {
36
- this.pointerScale = scale;
37
- return;
38
- }
39
- const shouldGrow = event.target instanceof Element && event.target.matches(this.$options.growSelectors) || false;
40
- const shouldReduce = isDown || event.target instanceof Element && event.target.matches(this.$options.shrinkSelectors) || false;
41
- if (shouldGrow) {
42
- scale = this.$options.growTo;
43
- }
44
- if (shouldReduce) {
45
- scale = this.$options.shrinkTo;
46
- }
47
- this.pointerScale = scale;
48
- }
49
- ticked() {
50
- this.x = damp(this.pointerX, this.x, this.$options.translateDampFactor);
51
- this.y = damp(this.pointerY, this.y, this.$options.translateDampFactor);
52
- this.scale = damp(this.pointerScale, this.scale, this.pointerScale < this.scale ? this.$options.shrinkDampFactor : this.$options.growDampFactor);
53
- this.render({ x: this.x, y: this.y, scale: this.scale });
54
- if (this.x === this.pointerX && this.y === this.pointerY && this.scale === this.pointerScale) {
55
- this.$services.disable("ticked");
56
- }
57
- }
58
- render({ x, y, scale }) {
59
- const transform = matrix({
60
- translateX: x,
61
- translateY: y,
62
- scaleX: scale,
63
- scaleY: scale
64
- });
65
- this.$el.style.transform = `translateZ(0) ${transform}`;
66
- }
67
- }
68
- __publicField(Cursor, "config", {
69
- name: "Cursor",
70
- options: {
71
- growSelectors: {
72
- type: String,
73
- default: "a, a *, button, button *, [data-cursor-grow], [data-cursor-grow] *"
74
- },
75
- shrinkSelectors: {
76
- type: String,
77
- default: "[data-cursor-shrink], [data-cursor-shrink] *"
78
- },
79
- growTo: {
80
- type: Number,
81
- default: 2
82
- },
83
- shrinkTo: {
84
- type: Number,
85
- default: 0.5
86
- },
87
- translateDampFactor: {
88
- type: Number,
89
- default: 0.25
90
- },
91
- growDampFactor: {
92
- type: Number,
93
- default: 0.25
94
- },
95
- shrinkDampFactor: {
96
- type: Number,
97
- default: 0.25
98
- }
99
- }
100
- });
101
- export {
102
- Cursor as default
103
- };
1
+ import{Base as n}from"@studiometa/js-toolkit";import{damp as a,matrix as c}from"@studiometa/js-toolkit/utils";class l extends n{static config={name:"Cursor",options:{growSelectors:{type:String,default:"a, a *, button, button *, [data-cursor-grow], [data-cursor-grow] *"},shrinkSelectors:{type:String,default:"[data-cursor-shrink], [data-cursor-shrink] *"},growTo:{type:Number,default:2},shrinkTo:{type:Number,default:.5},translateDampFactor:{type:Number,default:.25},growDampFactor:{type:Number,default:.25},shrinkDampFactor:{type:Number,default:.25}}};x=0;y=0;scale=0;pointerX=0;pointerY=0;pointerScale=0;mounted(){this.x=0,this.y=0,this.scale=0,this.pointerX=0,this.pointerY=0,this.pointerScale=0,this.render({x:this.x,y:this.y,scale:this.scale})}moved({event:t,x:i,y:s,isDown:r}){this.$services.has("ticked")||this.$services.enable("ticked"),this.pointerX=i,this.pointerY=s;let e=1;if(!t){this.pointerScale=e;return}const o=t.target instanceof Element&&t.target.matches(this.$options.growSelectors)||!1,h=r||t.target instanceof Element&&t.target.matches(this.$options.shrinkSelectors)||!1;o&&(e=this.$options.growTo),h&&(e=this.$options.shrinkTo),this.pointerScale=e}ticked(){this.x=a(this.pointerX,this.x,this.$options.translateDampFactor),this.y=a(this.pointerY,this.y,this.$options.translateDampFactor),this.scale=a(this.pointerScale,this.scale,this.pointerScale<this.scale?this.$options.shrinkDampFactor:this.$options.growDampFactor),this.render({x:this.x,y:this.y,scale:this.scale}),this.x===this.pointerX&&this.y===this.pointerY&&this.scale===this.pointerScale&&this.$services.disable("ticked")}render({x:t,y:i,scale:s}){const r=c({translateX:t,translateY:i,scaleX:s,scaleY:s});this.$el.style.transform=`translateZ(0) ${r}`}}export{l as default};
@@ -0,0 +1,28 @@
1
+ {#
2
+ /**
3
+ * @file
4
+ * Cursor component.
5
+ *
6
+ * @param array $attr
7
+ * Custom attributes for the root element.
8
+ *
9
+ * @block $content
10
+ * Custom content for the root element, defaults to `''`.
11
+ */
12
+ #}
13
+
14
+ {% set attributes =
15
+ merge_html_attributes(
16
+ attr ?? null,
17
+ {
18
+ data_component: 'Cursor',
19
+ class: 'fixed top-0 left-0 w-12 h-12 -mt-6 -ml-6 rounded-full bg-black'
20
+ },
21
+ { class: 'pointer-events-none' }
22
+ )
23
+ %}
24
+
25
+ <div {{ html_attributes(attributes) }}>
26
+ {% block content %}
27
+ {% endblock %}
28
+ </div>
@@ -3,24 +3,19 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
7
6
  var __export = (target, all) => {
8
7
  for (var name in all)
9
8
  __defProp(target, name, { get: all[name], enumerable: true });
10
9
  };
11
- var __reExport = (target, module2, copyDefault, desc) => {
12
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
13
- for (let key of __getOwnPropNames(module2))
14
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
15
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
15
  }
17
- return target;
16
+ return to;
18
17
  };
19
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
20
- return (module2, temp) => {
21
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
22
- };
23
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
19
  var __publicField = (obj, key, value) => {
25
20
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
26
21
  return value;
@@ -31,8 +26,15 @@ var Figure_exports = {};
31
26
  __export(Figure_exports, {
32
27
  default: () => Figure
33
28
  });
29
+ module.exports = __toCommonJS(Figure_exports);
34
30
  var import_js_toolkit = require("@studiometa/js-toolkit");
35
31
  var Figure = class extends (0, import_js_toolkit.withMountWhenInView)(import_js_toolkit.Base, { threshold: [0, 1] }) {
32
+ get src() {
33
+ return this.$refs.img.src;
34
+ }
35
+ set src(value) {
36
+ this.$refs.img.src = value;
37
+ }
36
38
  mounted() {
37
39
  if (!this.$refs.img) {
38
40
  throw new Error("[Figure] The `img` ref is required.");
@@ -40,14 +42,16 @@ var Figure = class extends (0, import_js_toolkit.withMountWhenInView)(import_js_
40
42
  if (!(this.$refs.img instanceof HTMLImageElement)) {
41
43
  throw new Error("[Figure] The `img` ref must be an `<img>` element.");
42
44
  }
43
- if (this.$refs.img.hasAttribute("data-src")) {
44
- this.$refs.img.src = this.$refs.img.getAttribute("data-src");
45
+ if (this.$options.lazy && this.$refs.img.hasAttribute("data-src") && this.$refs.img.getAttribute("data-src") !== this.src) {
46
+ this.src = this.$refs.img.getAttribute("data-src");
45
47
  }
46
48
  }
47
49
  };
48
50
  __publicField(Figure, "config", {
49
51
  name: "Figure",
50
- refs: ["img"]
52
+ refs: ["img"],
53
+ options: {
54
+ lazy: Boolean
55
+ }
51
56
  });
52
- module.exports = __toCommonJS(Figure_exports);
53
57
  if (module.exports.default) module.exports = module.exports.default;
@@ -15,12 +15,30 @@ export default class Figure extends Base {
15
15
  static config: {
16
16
  name: string;
17
17
  refs: string[];
18
+ options: {
19
+ lazy: BooleanConstructor;
20
+ };
18
21
  };
22
+ /**
23
+ * Set the image source.
24
+ *
25
+ * @this {Figure & FigureInterface}
26
+ * @param {string} value
27
+ * @returns {void}
28
+ */
29
+ set src(arg: string);
30
+ /**
31
+ * Get the image source.
32
+ *
33
+ * @this {Figure & FigureInterface}
34
+ * @returns {string}
35
+ */
36
+ get src(): string;
19
37
  /**
20
38
  * Load on mount.
21
39
  * @this {Figure & FigureInterface}
22
40
  */
23
- mounted(): void;
41
+ mounted(this: Figure & FigureInterface): void;
24
42
  }
25
43
  export type FigureRefs = {
26
44
  img: HTMLImageElement;
@@ -1,27 +1 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import { Base, withMountWhenInView } from "@studiometa/js-toolkit";
8
- class Figure extends withMountWhenInView(Base, { threshold: [0, 1] }) {
9
- mounted() {
10
- if (!this.$refs.img) {
11
- throw new Error("[Figure] The `img` ref is required.");
12
- }
13
- if (!(this.$refs.img instanceof HTMLImageElement)) {
14
- throw new Error("[Figure] The `img` ref must be an `<img>` element.");
15
- }
16
- if (this.$refs.img.hasAttribute("data-src")) {
17
- this.$refs.img.src = this.$refs.img.getAttribute("data-src");
18
- }
19
- }
20
- }
21
- __publicField(Figure, "config", {
22
- name: "Figure",
23
- refs: ["img"]
24
- });
25
- export {
26
- Figure as default
27
- };
1
+ import{Base as t,withMountWhenInView as r}from"@studiometa/js-toolkit";class i extends r(t,{threshold:[0,1]}){static config={name:"Figure",refs:["img"],options:{lazy:Boolean}};get src(){return this.$refs.img.src}set src(e){this.$refs.img.src=e}mounted(){if(!this.$refs.img)throw new Error("[Figure] The `img` ref is required.");if(!(this.$refs.img instanceof HTMLImageElement))throw new Error("[Figure] The `img` ref must be an `<img>` element.");this.$options.lazy&&this.$refs.img.hasAttribute("data-src")&&this.$refs.img.getAttribute("data-src")!==this.src&&(this.src=this.$refs.img.getAttribute("data-src"))}}export{i as default};
@@ -0,0 +1,120 @@
1
+ {#
2
+ /**
3
+ * @file
4
+ * Figure component.
5
+ *
6
+ * @param string $src
7
+ * @param string $srcset
8
+ * @param string $sizes
9
+ * @param number $width
10
+ * @param number $height
11
+ * @param string $alt
12
+ * @param string $caption
13
+ * @param boolean $lazy
14
+ * @param 'cover'|'contain'|'fill'|'none' $fit
15
+ * Define how the image will fit.
16
+ * @param boolean $absolute
17
+ * Use absolute position on the image holder instead of relative.
18
+ * @param boolean $inline
19
+ * Wether to enable the display of the figure inline or not. When `inline`, the root element
20
+ * will have a max-width set corresponding to the `width` given. Use with caution.
21
+ * @param array $attr
22
+ * Custom attributes for the root element.
23
+ * @param array $inner_attr
24
+ * Custom attributes for the inner element.
25
+ * @param array $img_attr
26
+ * Custom attributes for the image element.
27
+ * @param array $caption_attr
28
+ * Custom attributes for the caption element.
29
+ *
30
+ * @block $caption
31
+ * Use this block to customize the image's caption.
32
+ *
33
+ * @todo
34
+ * - twicpics: use TwicPics to serve image at the right size
35
+ * - loading: display a loader while loading, the fallback image if there was an error
36
+ * - mode: img | background → is it really necessary with `object-fit-...`?
37
+ */
38
+ #}
39
+
40
+ {% set absolute = absolute|default(false) %}
41
+ {% set inline = inline|default(false) %}
42
+ {% set fit = fit ?? null %}
43
+ {% set height = height|default(100) %}
44
+ {% set width = width|default(100) %}
45
+ {% set lazy = lazy ?? true %}
46
+
47
+ {%- set placeholder_markup -%}
48
+ <svg xmlns="http://www.w3.org/2000/svg"
49
+ viewbox="0 0 {{ width }} {{ height }}"
50
+ width="{{ width }}"
51
+ height="{{ height }}">
52
+ <rect x="0" y="0" width="{{ width }}" height="{{ height }}" fill="#eee" />
53
+ </svg>
54
+ {%- endset -%}
55
+ {% set generic_placeholder = 'data:image/svg+xml,%s'|format(placeholder_markup|url_encode) %}
56
+
57
+ {% set attributes =
58
+ merge_html_attributes(
59
+ attr ?? null,
60
+ { data_component: 'Figure', class: ['figure', 'w-full'] },
61
+ {
62
+ style: { height: absolute ? '100%' : '', maxWidth: inline ? width ~ 'px' : '' },
63
+ data_option_lazy: lazy
64
+ }
65
+ )
66
+ %}
67
+
68
+ {% set img_attributes =
69
+ merge_html_attributes(
70
+ img_attr ?? null,
71
+ { class: 'figure__img' },
72
+ {
73
+ class: [
74
+ 'absolute inset-0 w-full max-w-none h-full',
75
+ {
76
+ 'object-cover': fit == 'cover',
77
+ 'object-contain': fit == 'contain',
78
+ 'object-fill': fit == 'fill',
79
+ 'object-none': fit == 'none'
80
+ }
81
+ ],
82
+ src: lazy ? placeholder|default(generic_placeholder) : src,
83
+ data_src: lazy ? src|default(generic_placeholder) : src,
84
+ alt: alt|default(''),
85
+ width: width|default(false),
86
+ height: height|default(false),
87
+ srcset: srcset|default(false),
88
+ sizes: sizes|default(false),
89
+ data_ref: 'img'
90
+ }
91
+ )
92
+ %}
93
+
94
+ {% set inner_attributes =
95
+ merge_html_attributes(
96
+ inner_attr ?? null,
97
+ { class: ['figure__inner'] },
98
+ {
99
+ class: absolute ? ['absolute', 'inset-0'] : ['relative', 'w-full', 'h-0'],
100
+ style: { paddingTop: absolute ? '' : height * 100 / width ~ '%' }
101
+ }
102
+ )
103
+ %}
104
+
105
+ {% set caption_attributes =
106
+ merge_html_attributes(caption_attr ?? null, { class: 'figure__caption' })
107
+ %}
108
+
109
+ <figure {{ html_attributes(attributes) }}>
110
+ <div {{ html_attributes(inner_attributes) }}>
111
+ <img {{ html_attributes(img_attributes) }} />
112
+ </div>
113
+ {% if caption is defined %}
114
+ {% block caption %}
115
+ <figcaption {{ html_attributes(caption_attributes) }}>
116
+ {{ caption }}
117
+ </figcaption>
118
+ {% endblock %}
119
+ {% endif %}
120
+ </figure>