@studiometa/js-toolkit 2.0.0-alpha.1 → 2.0.0-alpha.10

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 (201) hide show
  1. package/Base/index.d.ts +29 -47
  2. package/Base/index.js +144 -171
  3. package/Base/managers/ChildrenManager.d.ts +6 -6
  4. package/Base/managers/ChildrenManager.js +95 -119
  5. package/Base/managers/EventsManager.d.ts +9 -9
  6. package/Base/managers/EventsManager.js +128 -161
  7. package/Base/managers/OptionsManager.d.ts +50 -5
  8. package/Base/managers/OptionsManager.js +115 -116
  9. package/Base/managers/RefsManager.js +62 -73
  10. package/Base/managers/ServicesManager.d.ts +14 -3
  11. package/Base/managers/ServicesManager.js +78 -77
  12. package/Base/utils.js +5 -8
  13. package/README.md +12 -70
  14. package/decorators/index.js +1 -2
  15. package/decorators/withBreakpointManager.d.ts +4 -4
  16. package/decorators/withBreakpointManager.js +37 -75
  17. package/decorators/withBreakpointObserver.d.ts +2 -2
  18. package/decorators/withBreakpointObserver.js +54 -77
  19. package/decorators/withDrag.d.ts +3 -3
  20. package/decorators/withDrag.js +17 -41
  21. package/decorators/withExtraConfig.d.ts +3 -3
  22. package/decorators/withExtraConfig.js +2 -24
  23. package/decorators/withIntersectionObserver.d.ts +2 -2
  24. package/decorators/withIntersectionObserver.js +17 -56
  25. package/decorators/withMountWhenInView.d.ts +3 -3
  26. package/decorators/withMountWhenInView.js +23 -51
  27. package/helpers/createApp.d.ts +3 -3
  28. package/helpers/createApp.js +10 -12
  29. package/helpers/importOnInteraction.d.ts +3 -3
  30. package/helpers/importOnInteraction.js +7 -8
  31. package/helpers/importWhenIdle.d.ts +3 -3
  32. package/helpers/importWhenIdle.js +7 -8
  33. package/helpers/importWhenVisible.d.ts +3 -3
  34. package/helpers/importWhenVisible.js +9 -16
  35. package/helpers/index.d.ts +1 -3
  36. package/helpers/index.js +1 -4
  37. package/helpers/utils.js +1 -2
  38. package/index.d.ts +14 -4
  39. package/index.js +4 -4
  40. package/index.modern.js +1 -2
  41. package/index.umd.js +1 -2
  42. package/package.json +4 -6
  43. package/services/Service.js +48 -67
  44. package/services/drag.js +143 -179
  45. package/services/index.js +1 -2
  46. package/services/key.js +55 -97
  47. package/services/load.d.ts +1 -1
  48. package/services/load.js +21 -50
  49. package/services/pointer.js +117 -156
  50. package/services/raf.js +36 -64
  51. package/services/resize.js +47 -86
  52. package/services/scroll.js +81 -120
  53. package/utils/collide/boundingRectToCircle.js +7 -6
  54. package/utils/collide/collideCircleCircle.js +1 -2
  55. package/utils/collide/collideCircleRect.js +1 -2
  56. package/utils/collide/collidePointCircle.js +1 -2
  57. package/utils/collide/collidePointRect.js +1 -2
  58. package/utils/collide/collideRectRect.js +1 -2
  59. package/utils/collide/index.js +1 -2
  60. package/utils/css/classes.js +2 -3
  61. package/utils/css/index.js +1 -2
  62. package/utils/css/matrix.js +1 -2
  63. package/utils/css/styles.js +3 -8
  64. package/utils/css/transition.js +67 -140
  65. package/utils/debounce.js +3 -4
  66. package/utils/focusTrap.js +4 -5
  67. package/utils/history.js +13 -20
  68. package/utils/index.d.ts +2 -1
  69. package/utils/index.js +2 -2
  70. package/utils/keyCodes.js +1 -2
  71. package/utils/math/clamp.js +1 -2
  72. package/utils/math/clamp01.js +1 -2
  73. package/utils/math/damp.js +1 -2
  74. package/utils/math/index.js +1 -2
  75. package/utils/math/inertiaFinalValue.js +1 -2
  76. package/utils/math/lerp.js +1 -2
  77. package/utils/math/map.js +1 -2
  78. package/utils/math/round.js +1 -2
  79. package/utils/memoize.d.ts +30 -0
  80. package/utils/memoize.js +30 -0
  81. package/utils/nextFrame.js +4 -9
  82. package/utils/object/autoBind.js +11 -19
  83. package/utils/object/getAllProperties.js +3 -11
  84. package/utils/object/index.js +1 -2
  85. package/utils/object/isObject.js +2 -4
  86. package/utils/string/index.js +1 -2
  87. package/utils/string/withLeadingCharacters.js +1 -2
  88. package/utils/string/withLeadingSlash.js +1 -2
  89. package/utils/string/withTrailingCharacters.js +1 -2
  90. package/utils/string/withTrailingSlash.js +1 -2
  91. package/utils/string/withoutLeadingCharacters.js +1 -2
  92. package/utils/string/withoutLeadingCharactersRecursive.js +1 -2
  93. package/utils/string/withoutLeadingSlash.js +1 -2
  94. package/utils/string/withoutTrailingCharacters.js +1 -2
  95. package/utils/string/withoutTrailingCharactersRecursive.js +1 -2
  96. package/utils/string/withoutTrailingSlash.js +1 -2
  97. package/utils/throttle.js +2 -3
  98. package/Base/index.js.map +0 -1
  99. package/Base/managers/ChildrenManager.js.map +0 -1
  100. package/Base/managers/EventsManager.js.map +0 -1
  101. package/Base/managers/OptionsManager.js.map +0 -1
  102. package/Base/managers/RefsManager.js.map +0 -1
  103. package/Base/managers/ServicesManager.js.map +0 -1
  104. package/Base/utils.js.map +0 -1
  105. package/components/Accordion/Accordion.d.ts +0 -83
  106. package/components/Accordion/Accordion.js +0 -121
  107. package/components/Accordion/Accordion.js.map +0 -1
  108. package/components/Accordion/AccordionItem.d.ts +0 -122
  109. package/components/Accordion/AccordionItem.js +0 -327
  110. package/components/Accordion/AccordionItem.js.map +0 -1
  111. package/components/Accordion/index.d.ts +0 -27
  112. package/components/Accordion/index.js +0 -39
  113. package/components/Accordion/index.js.map +0 -1
  114. package/components/Cursor.d.ts +0 -138
  115. package/components/Cursor.js +0 -167
  116. package/components/Cursor.js.map +0 -1
  117. package/components/Draggable.d.ts +0 -49
  118. package/components/Draggable.js +0 -77
  119. package/components/Draggable.js.map +0 -1
  120. package/components/Modal.d.ts +0 -158
  121. package/components/Modal.js +0 -270
  122. package/components/Modal.js.map +0 -1
  123. package/components/Tabs.d.ts +0 -108
  124. package/components/Tabs.js +0 -195
  125. package/components/Tabs.js.map +0 -1
  126. package/components/index.d.ts +0 -6
  127. package/components/index.js +0 -7
  128. package/components/index.js.map +0 -1
  129. package/decorators/index.js.map +0 -1
  130. package/decorators/withBreakpointManager.js.map +0 -1
  131. package/decorators/withBreakpointObserver.js.map +0 -1
  132. package/decorators/withDrag.js.map +0 -1
  133. package/decorators/withExtraConfig.js.map +0 -1
  134. package/decorators/withIntersectionObserver.js.map +0 -1
  135. package/decorators/withMountWhenInView.js.map +0 -1
  136. package/helpers/createApp.js.map +0 -1
  137. package/helpers/createBase.d.ts +0 -7
  138. package/helpers/createBase.js +0 -7
  139. package/helpers/createBase.js.map +0 -1
  140. package/helpers/defineComponent.d.ts +0 -11
  141. package/helpers/defineComponent.js +0 -68
  142. package/helpers/defineComponent.js.map +0 -1
  143. package/helpers/importOnInteraction.js.map +0 -1
  144. package/helpers/importWhenIdle.js.map +0 -1
  145. package/helpers/importWhenVisible.js.map +0 -1
  146. package/helpers/index.js.map +0 -1
  147. package/helpers/utils.js.map +0 -1
  148. package/index.js.map +0 -1
  149. package/index.modern.js.map +0 -1
  150. package/index.umd.js.map +0 -1
  151. package/services/Service.js.map +0 -1
  152. package/services/drag.js.map +0 -1
  153. package/services/index.js.map +0 -1
  154. package/services/key.js.map +0 -1
  155. package/services/load.js.map +0 -1
  156. package/services/pointer.js.map +0 -1
  157. package/services/raf.js.map +0 -1
  158. package/services/resize.js.map +0 -1
  159. package/services/scroll.js.map +0 -1
  160. package/utils/collide/boundingRectToCircle.js.map +0 -1
  161. package/utils/collide/collideCircleCircle.js.map +0 -1
  162. package/utils/collide/collideCircleRect.js.map +0 -1
  163. package/utils/collide/collidePointCircle.js.map +0 -1
  164. package/utils/collide/collidePointRect.js.map +0 -1
  165. package/utils/collide/collideRectRect.js.map +0 -1
  166. package/utils/collide/index.js.map +0 -1
  167. package/utils/css/classes.js.map +0 -1
  168. package/utils/css/index.js.map +0 -1
  169. package/utils/css/matrix.js.map +0 -1
  170. package/utils/css/styles.js.map +0 -1
  171. package/utils/css/transition.js.map +0 -1
  172. package/utils/debounce.js.map +0 -1
  173. package/utils/focusTrap.js.map +0 -1
  174. package/utils/history.js.map +0 -1
  175. package/utils/index.js.map +0 -1
  176. package/utils/keyCodes.js.map +0 -1
  177. package/utils/math/clamp.js.map +0 -1
  178. package/utils/math/clamp01.js.map +0 -1
  179. package/utils/math/damp.js.map +0 -1
  180. package/utils/math/index.js.map +0 -1
  181. package/utils/math/inertiaFinalValue.js.map +0 -1
  182. package/utils/math/lerp.js.map +0 -1
  183. package/utils/math/map.js.map +0 -1
  184. package/utils/math/round.js.map +0 -1
  185. package/utils/nextFrame.js.map +0 -1
  186. package/utils/object/autoBind.js.map +0 -1
  187. package/utils/object/getAllProperties.js.map +0 -1
  188. package/utils/object/index.js.map +0 -1
  189. package/utils/object/isObject.js.map +0 -1
  190. package/utils/string/index.js.map +0 -1
  191. package/utils/string/withLeadingCharacters.js.map +0 -1
  192. package/utils/string/withLeadingSlash.js.map +0 -1
  193. package/utils/string/withTrailingCharacters.js.map +0 -1
  194. package/utils/string/withTrailingSlash.js.map +0 -1
  195. package/utils/string/withoutLeadingCharacters.js.map +0 -1
  196. package/utils/string/withoutLeadingCharactersRecursive.js.map +0 -1
  197. package/utils/string/withoutLeadingSlash.js.map +0 -1
  198. package/utils/string/withoutTrailingCharacters.js.map +0 -1
  199. package/utils/string/withoutTrailingCharactersRecursive.js.map +0 -1
  200. package/utils/string/withoutTrailingSlash.js.map +0 -1
  201. package/utils/throttle.js.map +0 -1
@@ -1,167 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
-
9
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
-
11
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
-
13
- import Base from '../Base/index.js';
14
- import damp from '../utils/math/damp.js';
15
- import matrix from '../utils/css/matrix.js';
16
-
17
- var Cursor = function (_Base) {
18
- _inherits(Cursor, _Base);
19
-
20
- var _super = _createSuper(Cursor);
21
-
22
- function Cursor() {
23
- var _this;
24
-
25
- _classCallCheck(this, Cursor);
26
-
27
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
28
- args[_key] = arguments[_key];
29
- }
30
-
31
- _this = _super.call.apply(_super, [this].concat(args));
32
-
33
- _defineProperty(_assertThisInitialized(_this), "x", 0);
34
-
35
- _defineProperty(_assertThisInitialized(_this), "y", 0);
36
-
37
- _defineProperty(_assertThisInitialized(_this), "scale", 0);
38
-
39
- _defineProperty(_assertThisInitialized(_this), "pointerX", 0);
40
-
41
- _defineProperty(_assertThisInitialized(_this), "pointerY", 0);
42
-
43
- _defineProperty(_assertThisInitialized(_this), "pointerScale", 0);
44
-
45
- return _this;
46
- }
47
-
48
- _createClass(Cursor, [{
49
- key: "mounted",
50
- value: function mounted() {
51
- this.x = 0;
52
- this.y = 0;
53
- this.scale = 0;
54
- this.pointerX = 0;
55
- this.pointerY = 0;
56
- this.pointerScale = 0;
57
- this.render({
58
- x: this.x,
59
- y: this.y,
60
- scale: this.scale
61
- });
62
- }
63
- }, {
64
- key: "moved",
65
- value: function moved(_ref) {
66
- var event = _ref.event,
67
- x = _ref.x,
68
- y = _ref.y,
69
- isDown = _ref.isDown;
70
-
71
- if (!this.$services.has('ticked')) {
72
- this.$services.enable('ticked');
73
- }
74
-
75
- this.pointerX = x;
76
- this.pointerY = y;
77
- var scale = 1;
78
-
79
- if (!event) {
80
- this.pointerScale = scale;
81
- return;
82
- }
83
-
84
- var shouldGrow = event.target instanceof Element && event.target.matches(this.$options.growSelectors) || false;
85
- var shouldReduce = isDown || event.target instanceof Element && event.target.matches(this.$options.shrinkSelectors) || false;
86
-
87
- if (shouldGrow) {
88
- scale = this.$options.growTo;
89
- }
90
-
91
- if (shouldReduce) {
92
- scale = this.$options.shrinkTo;
93
- }
94
-
95
- this.pointerScale = scale;
96
- }
97
- }, {
98
- key: "ticked",
99
- value: function ticked() {
100
- this.x = damp(this.pointerX, this.x, this.$options.translateDampFactor);
101
- this.y = damp(this.pointerY, this.y, this.$options.translateDampFactor);
102
- this.scale = damp(this.pointerScale, this.scale, this.pointerScale < this.scale ? this.$options.shrinkDampFactor : this.$options.growDampFactor);
103
- this.render({
104
- x: this.x,
105
- y: this.y,
106
- scale: this.scale
107
- });
108
-
109
- if (this.x === this.pointerX && this.y === this.pointerY && this.scale === this.pointerScale) {
110
- this.$services.disable('ticked');
111
- }
112
- }
113
- }, {
114
- key: "render",
115
- value: function render(_ref2) {
116
- var x = _ref2.x,
117
- y = _ref2.y,
118
- scale = _ref2.scale;
119
- var transform = matrix({
120
- translateX: x,
121
- translateY: y,
122
- scaleX: scale,
123
- scaleY: scale
124
- });
125
- this.$el.style.transform = "translateZ(0) ".concat(transform);
126
- }
127
- }]);
128
-
129
- return Cursor;
130
- }(Base);
131
-
132
- _defineProperty(Cursor, "config", {
133
- name: 'Cursor',
134
- options: {
135
- growSelectors: {
136
- type: String,
137
- default: 'a, a *, button, button *, [data-cursor-grow], [data-cursor-grow] *'
138
- },
139
- shrinkSelectors: {
140
- type: String,
141
- default: '[data-cursor-shrink], [data-cursor-shrink] *'
142
- },
143
- growTo: {
144
- type: Number,
145
- default: 2
146
- },
147
- shrinkTo: {
148
- type: Number,
149
- default: 0.5
150
- },
151
- translateDampFactor: {
152
- type: Number,
153
- default: 0.25
154
- },
155
- growDampFactor: {
156
- type: Number,
157
- default: 0.25
158
- },
159
- shrinkDampFactor: {
160
- type: Number,
161
- default: 0.25
162
- }
163
- }
164
- });
165
-
166
- export { Cursor as default };
167
- //# sourceMappingURL=Cursor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../packages/js-toolkit/components/Cursor.js"],"names":["Base","damp","matrix","Cursor","x","y","scale","pointerX","pointerY","pointerScale","render","event","isDown","$services","has","enable","shouldGrow","target","Element","matches","$options","growSelectors","shouldReduce","shrinkSelectors","growTo","shrinkTo","translateDampFactor","shrinkDampFactor","growDampFactor","disable","transform","translateX","translateY","scaleX","scaleY","$el","style","name","options","type","String","default","Number"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,IAAP,MAAiB,kBAAjB;AACA,OAAOC,IAAP,MAAiB,uBAAjB;AACA,OAAOC,MAAP,MAAmB,wBAAnB;;IA8BqBC,M;;;;;;;;;;;;;;;;wDAyCf,C;;wDAKA,C;;4DAKI,C;;+DAKG,C;;+DAKA,C;;mEAKI,C;;;;;;;WAMf,mBAAU;AACR,WAAKC,CAAL,GAAS,CAAT;AACA,WAAKC,CAAL,GAAS,CAAT;AACA,WAAKC,KAAL,GAAa,CAAb;AACA,WAAKC,QAAL,GAAgB,CAAhB;AACA,WAAKC,QAAL,GAAgB,CAAhB;AACA,WAAKC,YAAL,GAAoB,CAApB;AACA,WAAKC,MAAL,CAAY;AAAEN,QAAAA,CAAC,EAAE,KAAKA,CAAV;AAAaC,QAAAA,CAAC,EAAE,KAAKA,CAArB;AAAwBC,QAAAA,KAAK,EAAE,KAAKA;AAApC,OAAZ;AACD;;;WAUD,qBAA+B;AAAA,UAAvBK,KAAuB,QAAvBA,KAAuB;AAAA,UAAhBP,CAAgB,QAAhBA,CAAgB;AAAA,UAAbC,CAAa,QAAbA,CAAa;AAAA,UAAVO,MAAU,QAAVA,MAAU;;AAC7B,UAAI,CAAC,KAAKC,SAAL,CAAeC,GAAf,CAAmB,QAAnB,CAAL,EAAmC;AACjC,aAAKD,SAAL,CAAeE,MAAf,CAAsB,QAAtB;AACD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AAc,EAAE;AACdW,MAAAA,IAAI,EAAEG,MADQ;AAEdD,MAAAA,OAAO,EAAE;AAFK,KArBT;AAyBPd,IAAAA,gBAAgB,EAAE;AAChBY,MAAAA,IAAI,EAAEG,MADU;AAEhBD,MAAAA,OAAO,EAAE;AAFO;AAzBX;AAFK,C;;SAJGtC,M","sourcesContent":["import Base from '../Base/index.js';\nimport damp from '../utils/math/damp.js';\nimport matrix from '../utils/css/matrix.js';\n\n/**\n * @typedef {import('../services/pointer').PointerServiceProps} PointerServiceProps\n * @typedef {import('../Base').BaseOptions} BaseOptions\n */\n\n/**\n * @typedef {Object} CursorOptions\n * @property {string} growSelectors\n * @property {string} shrinkSelectors\n * @property {number} growTo\n * @property {number} shrinkTo\n * @property {number} translateDampFactor\n * @property {number} growDampFactor\n * @property {number} shrinkDampFactor\n */\n\n/**\n * @typedef {Object} CursorPrivateInterface\n * @property {BaseOptions & CursorOptions} $options\n */\n\n/**\n * @typedef {Cursor & CursorPrivateInterface} CursorInterface\n */\n\n/**\n * Custom cursor component.\n */\nexport default class Cursor extends Base {\n /**\n * Class config.\n */\n static config = {\n name: 'Cursor',\n options: {\n growSelectors: {\n type: String,\n default: 'a, a *, button, button *, [data-cursor-grow], [data-cursor-grow] *',\n },\n shrinkSelectors: {\n type: String,\n default: '[data-cursor-shrink], [data-cursor-shrink] *',\n },\n growTo: {\n type: Number,\n default: 2,\n },\n shrinkTo: {\n type: Number,\n default: 0.5,\n },\n translateDampFactor: {\n type: Number,\n default: 0.25,\n },\n growDampFactor: {\n type: Number,\n default: 0.25,\n },\n shrinkDampFactor: {\n type: Number,\n default: 0.25,\n },\n },\n };\n\n /**\n * @type {Number}\n */\n x = 0;\n\n /**\n * @type {Number}\n */\n y = 0;\n\n /**\n * @type {Number}\n */\n scale = 0;\n\n /**\n * @type {Number}\n */\n pointerX = 0;\n\n /**\n * @type {Number}\n */\n pointerY = 0;\n\n /**\n * @type {Number}\n */\n pointerScale = 0;\n\n /**\n * Mounted hook.\n * @return {void}\n */\n mounted() {\n this.x = 0;\n this.y = 0;\n this.scale = 0;\n this.pointerX = 0;\n this.pointerY = 0;\n this.pointerScale = 0;\n this.render({ x: this.x, y: this.y, scale: this.scale });\n }\n\n /**\n * Moved hook.\n *\n * @this {CursorInterface}\n *\n * @param {PointerServiceProps} options\n * @return {void}\n */\n moved({ event, x, y, isDown }) {\n if (!this.$services.has('ticked')) {\n this.$services.enable('ticked');\n }\n\n this.pointerX = x;\n this.pointerY = y;\n\n let scale = 1;\n\n if (!event) {\n this.pointerScale = scale;\n return;\n }\n\n const shouldGrow =\n (event.target instanceof Element && event.target.matches(this.$options.growSelectors)) ||\n false;\n const shouldReduce =\n isDown ||\n (event.target instanceof Element && event.target.matches(this.$options.shrinkSelectors)) ||\n false;\n\n if (shouldGrow) {\n scale = this.$options.growTo;\n }\n\n if (shouldReduce) {\n scale = this.$options.shrinkTo;\n }\n\n this.pointerScale = scale;\n }\n\n /**\n * RequestAnimationFrame hook.\n *\n * @this {CursorInterface}\n *\n * @return {void}\n */\n ticked() {\n this.x = damp(this.pointerX, this.x, this.$options.translateDampFactor);\n this.y = damp(this.pointerY, this.y, this.$options.translateDampFactor);\n this.scale = damp(\n this.pointerScale,\n this.scale,\n this.pointerScale < this.scale ? this.$options.shrinkDampFactor : this.$options.growDampFactor\n );\n\n this.render({ x: this.x, y: this.y, scale: this.scale });\n\n if (this.x === this.pointerX && this.y === this.pointerY && this.scale === this.pointerScale) {\n this.$services.disable('ticked');\n }\n }\n\n /**\n * Render the cursor.\n *\n * @param {Object} options\n * @param {Number} options.x\n * @param {Number} options.y\n * @param {Number} options.scale\n * @return {void}\n */\n render({ x, y, scale }) {\n const transform = matrix({\n translateX: x,\n translateY: y,\n scaleX: scale,\n scaleY: scale,\n });\n this.$el.style.transform = `translateZ(0) ${transform}`;\n }\n}\n"],"file":"Cursor.js"}
@@ -1,49 +0,0 @@
1
- /**
2
- * @typedef {import('stylefire').Styler} Styler
3
- * @typedef {import('../services/drag.js').DragServiceProps} DragServiceProps
4
- */
5
- /**
6
- * @typedef {Draggable} DraggableInterface
7
- */
8
- /**
9
- * Draggable class.
10
- *
11
- * @link https://jsfiddle.net/soulwire/znj683b9/
12
- */
13
- export default class Draggable extends Base {
14
- static config: {
15
- name: string;
16
- };
17
- /**
18
- * The origin of the element.
19
- * @type {{ x: number, y: number }}
20
- */
21
- elementOrigin: {
22
- x: number;
23
- y: number;
24
- };
25
- /**
26
- * The element styler for performant style update.
27
- * @type {Styler}
28
- */
29
- styler: Styler;
30
- /**
31
- * Mounted hook.
32
- * @return {void}
33
- */
34
- mounted(): void;
35
- /**
36
- * Destroyed hook.
37
- * @return {void}
38
- */
39
- destroyed(): void;
40
- /**
41
- * Drag service hook.
42
- * @param {DragServiceProps} props
43
- */
44
- dragged(props: DragServiceProps): void;
45
- }
46
- export type Styler = import('stylefire').Styler;
47
- export type DragServiceProps = import('../services/drag.js').DragServiceProps;
48
- export type DraggableInterface = Draggable;
49
- import Base from "../Base/index.js";
@@ -1,77 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
-
9
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
-
11
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
-
13
- import styler from 'stylefire';
14
- import Base from '../Base/index.js';
15
- import withDrag from '../decorators/withDrag.js';
16
-
17
- var Draggable = function (_withDrag) {
18
- _inherits(Draggable, _withDrag);
19
-
20
- var _super = _createSuper(Draggable);
21
-
22
- function Draggable() {
23
- var _this;
24
-
25
- _classCallCheck(this, Draggable);
26
-
27
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
28
- args[_key] = arguments[_key];
29
- }
30
-
31
- _this = _super.call.apply(_super, [this].concat(args));
32
-
33
- _defineProperty(_assertThisInitialized(_this), "elementOrigin", {
34
- x: 0,
35
- y: 0
36
- });
37
-
38
- _defineProperty(_assertThisInitialized(_this), "styler", void 0);
39
-
40
- return _this;
41
- }
42
-
43
- _createClass(Draggable, [{
44
- key: "mounted",
45
- value: function mounted() {
46
- this.styler = styler(this.$el);
47
- }
48
- }, {
49
- key: "destroyed",
50
- value: function destroyed() {
51
- this.styler = undefined;
52
- }
53
- }, {
54
- key: "dragged",
55
- value: function dragged(props) {
56
- if (props.mode === 'start') {
57
- this.elementOrigin.x = this.styler.get('x');
58
- this.elementOrigin.y = this.styler.get('y');
59
- return;
60
- }
61
-
62
- this.styler.set({
63
- x: this.elementOrigin.x + props.x - props.origin.x,
64
- y: this.elementOrigin.y + props.y - props.origin.y
65
- });
66
- }
67
- }]);
68
-
69
- return Draggable;
70
- }(withDrag(Base));
71
-
72
- _defineProperty(Draggable, "config", {
73
- name: 'DraggableElement'
74
- });
75
-
76
- export { Draggable as default };
77
- //# sourceMappingURL=Draggable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../packages/js-toolkit/components/Draggable.js"],"names":["styler","Base","withDrag","Draggable","x","y","$el","undefined","props","mode","elementOrigin","get","set","origin","name"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,MAAP,MAAmB,WAAnB;AACA,OAAOC,IAAP,MAAiB,kBAAjB;AACA,OAAOC,QAAP,MAAqB,2BAArB;;IAgBqBC,S;;;;;;;;;;;;;;;;oEASH;AACdC,MAAAA,CAAC,EAAE,CADW;AAEdC,MAAAA,CAAC,EAAE;AAFW,K;;;;;;;;;WAehB,mBAAU;AACR,WAAKL,MAAL,GAAcA,MAAM,CAAC,KAAKM,GAAN,CAApB;AACD;;;WAMD,qBAAY;AACV,WAAKN,MAAL,GAAcO,SAAd;AACD;;;WAMD,iBAAQC,KAAR,EAAe;AACb,UAAIA,KAAK,CAACC,IAAN,KAAe,OAAnB,EAA4B;AAC1B,aAAKC,aAAL,CAAmBN,CAAnB,GAAuB,KAAKJ,MAAL,CAAYW,GAAZ,CAAgB,GAAhB,CAAvB;AACA,aAAKD,aAAL,CAAmBL,CAAnB,GAAuB,KAAKL,MAAL,CAAYW,GAAZ,CAAgB,GAAhB,CAAvB;AACA;AACD;;AAED,WAAKX,MAAL,CAAYY,GAAZ,CAAgB;AACdR,QAAAA,CAAC,EAAE,KAAKM,aAAL,CAAmBN,CAAnB,GAAuBI,KAAK,CAACJ,CAA7B,GAAiCI,KAAK,CAACK,MAAN,CAAaT,CADnC;AAEdC,QAAAA,CAAC,EAAE,KAAKK,aAAL,CAAmBL,CAAnB,GAAuBG,KAAK,CAACH,CAA7B,GAAiCG,KAAK,CAACK,MAAN,CAAaR;AAFnC,OAAhB;AAID;;;;EAnDoCH,QAAQ,CAACD,IAAD,C;;gBAA1BE,S,YACH;AACdW,EAAAA,IAAI,EAAE;AADQ,C;;SADGX,S","sourcesContent":["import styler from 'stylefire';\nimport Base from '../Base/index.js';\nimport withDrag from '../decorators/withDrag.js';\n\n/**\n * @typedef {import('stylefire').Styler} Styler\n * @typedef {import('../services/drag.js').DragServiceProps} DragServiceProps\n */\n\n/**\n * @typedef {Draggable} DraggableInterface\n */\n\n/**\n * Draggable class.\n *\n * @link https://jsfiddle.net/soulwire/znj683b9/\n */\nexport default class Draggable extends withDrag(Base) {\n static config = {\n name: 'DraggableElement',\n };\n\n /**\n * The origin of the element.\n * @type {{ x: number, y: number }}\n */\n elementOrigin = {\n x: 0,\n y: 0,\n };\n\n /**\n * The element styler for performant style update.\n * @type {Styler}\n */\n styler;\n\n /**\n * Mounted hook.\n * @return {void}\n */\n mounted() {\n this.styler = styler(this.$el);\n }\n\n /**\n * Destroyed hook.\n * @return {void}\n */\n destroyed() {\n this.styler = undefined;\n }\n\n /**\n * Drag service hook.\n * @param {DragServiceProps} props\n */\n dragged(props) {\n if (props.mode === 'start') {\n this.elementOrigin.x = this.styler.get('x');\n this.elementOrigin.y = this.styler.get('y');\n return;\n }\n\n this.styler.set({\n x: this.elementOrigin.x + props.x - props.origin.x,\n y: this.elementOrigin.y + props.y - props.origin.y,\n });\n }\n}\n"],"file":"Draggable.js"}
@@ -1,158 +0,0 @@
1
- /**
2
- * @typedef {Object} ModalRefs
3
- * @property {HTMLElement} close
4
- * @property {HTMLElement} container
5
- * @property {HTMLElement} content
6
- * @property {HTMLElement} modal
7
- * @property {HTMLElement} open
8
- * @property {HTMLElement} overlay
9
- */
10
- /**
11
- * @typedef {import('../utils/css/styles.js').CssStyleObject} CssStyleObject
12
- * @typedef {Partial<Record<'open'|'active'|'closed', string|CssStyleObject>>} ModalStates
13
- * @typedef {Partial<Record<keyof ModalRefs, ModalStates>>} ModalStylesOption
14
- */
15
- /**
16
- * @typedef {Object} ModalOptions
17
- * @property {String} move A selector where to move the modal to.
18
- * @property {String} autofocus A selector for the element to set the focus to when the modal opens.
19
- * @property {ModalStylesOption} styles The styles for the different state of the modal.
20
- */
21
- /**
22
- * @typedef {Object} ModalPrivateInterface
23
- * @property {ModalRefs} $refs
24
- * @property {ModalOptions} $options
25
- * @property {Boolean} isOpen
26
- * @property {Comment} refModalPlaceholder
27
- * @property {HTMLElement} refModalParentBackup
28
- * @property {Function} refModalUnbindGetRefFilter
29
- */
30
- /**
31
- * @typedef {Modal & ModalPrivateInterface} ModalInterface
32
- */
33
- /**
34
- * Modal class.
35
- */
36
- export default class Modal extends Base {
37
- /**
38
- * Modal options.
39
- */
40
- static config: {
41
- name: string;
42
- refs: string[];
43
- options: {
44
- move: StringConstructor;
45
- autofocus: {
46
- type: StringConstructor;
47
- default: string;
48
- };
49
- styles: {
50
- type: ObjectConstructor;
51
- /**
52
- * @return {ModalStylesOption}
53
- */
54
- default: () => ModalStylesOption;
55
- };
56
- };
57
- };
58
- /**
59
- * Open the modal on click on the `open` ref.
60
- *
61
- * @return {Function} The component's `open` method.
62
- */
63
- get onOpenClick(): Function;
64
- /**
65
- * Close the modal on click on the `close` ref.
66
- *
67
- * @return {Function} The component's `close` method.
68
- */
69
- get onCloseClick(): Function;
70
- /**
71
- * Close the modal on click on the `overlay` ref.
72
- *
73
- * @return {Function} The component's `close` method.
74
- */
75
- get onOverlayClick(): Function;
76
- /**
77
- * Initialize the component's behaviours.
78
- *
79
- * @this {ModalInterface}
80
- */
81
- mounted(): ModalInterface;
82
- isOpen: boolean;
83
- refModalPlaceholder: Comment;
84
- refModalParentBackup: any;
85
- refModalUnbindGetRefFilter: any;
86
- /**
87
- * Unbind all events on destroy.
88
- *
89
- * @this {ModalInterface}
90
- * @return {Modal} The Modal instance.
91
- */
92
- destroyed(): Modal;
93
- /**
94
- * Close the modal on `ESC` and trap the tabulation.
95
- *
96
- * @this {ModalInterface}
97
- * @param {Object} options
98
- * @param {KeyboardEvent} options.event The original keyboard event
99
- * @param {Boolean} options.isUp Is it a keyup event?
100
- * @param {Boolean} options.isDown Is it a keydown event?
101
- * @param {Boolean} options.ESC Is it the ESC key?
102
- */
103
- keyed({ event, isUp, isDown, ESC }: {
104
- event: KeyboardEvent;
105
- isUp: boolean;
106
- isDown: boolean;
107
- ESC: boolean;
108
- }): void;
109
- /**
110
- * Open the modal.
111
- *
112
- * @this {ModalInterface}
113
- * @return {Promise<ModalInterface>} The Modal instance.
114
- */
115
- open(): Promise<ModalInterface>;
116
- /**
117
- * Close the modal.
118
- *
119
- * @this {ModalInterface}
120
- * @return {Promise<ModalInterface>} The Modal instance.
121
- */
122
- close(): Promise<ModalInterface>;
123
- }
124
- export type ModalRefs = {
125
- close: HTMLElement;
126
- container: HTMLElement;
127
- content: HTMLElement;
128
- modal: HTMLElement;
129
- open: HTMLElement;
130
- overlay: HTMLElement;
131
- };
132
- export type CssStyleObject = import('../utils/css/styles.js').CssStyleObject;
133
- export type ModalStates = Partial<Record<'open' | 'active' | 'closed', string | CssStyleObject>>;
134
- export type ModalStylesOption = Partial<Record<keyof ModalRefs, ModalStates>>;
135
- export type ModalOptions = {
136
- /**
137
- * A selector where to move the modal to.
138
- */
139
- move: string;
140
- /**
141
- * A selector for the element to set the focus to when the modal opens.
142
- */
143
- autofocus: string;
144
- /**
145
- * The styles for the different state of the modal.
146
- */
147
- styles: ModalStylesOption;
148
- };
149
- export type ModalPrivateInterface = {
150
- $refs: ModalRefs;
151
- $options: ModalOptions;
152
- isOpen: boolean;
153
- refModalPlaceholder: Comment;
154
- refModalParentBackup: HTMLElement;
155
- refModalUnbindGetRefFilter: Function;
156
- };
157
- export type ModalInterface = Modal & ModalPrivateInterface;
158
- import Base from "../Base/index.js";