@frollo/frollo-web-ui 9.0.1 → 9.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/cjs/index.js +10733 -3060
  2. package/esm/{_rollupPluginBabelHelpers-DODWUb5N.js → _rollupPluginBabelHelpers-BKlDnZ7n.js} +1 -1
  3. package/esm/fw-accordion.js +15 -18
  4. package/esm/fw-alert.js +32 -25
  5. package/esm/fw-bar-chart.js +265 -93
  6. package/esm/fw-button-DZTHZLjk.js +318 -0
  7. package/esm/fw-button.js +2 -2
  8. package/esm/{fw-card-D45R4kN-.js → fw-card-XGtsK2bM.js} +7 -10
  9. package/esm/fw-card.js +2 -2
  10. package/esm/fw-checkbox.js +8 -11
  11. package/esm/fw-date-picker.js +85 -49
  12. package/esm/fw-drawer.js +8 -8
  13. package/esm/{fw-dropdown-58wyuzsW.js → fw-dropdown-CSmYTm5O.js} +11 -14
  14. package/esm/fw-dropdown.js +7 -6
  15. package/esm/fw-form.js +1 -1
  16. package/esm/fw-icons.js +11 -12
  17. package/esm/fw-image-A2lXYs0u.js +325 -0
  18. package/esm/fw-image.js +5 -4
  19. package/esm/{fw-input-C2-cZ-BY.js → fw-input-BiPWWfK3.js} +12 -19
  20. package/esm/fw-input.js +3 -3
  21. package/esm/fw-loading-bar-3x4tkF1B.js +37 -0
  22. package/esm/fw-loading.js +89 -40
  23. package/esm/fw-media-picker.js +10 -653
  24. package/esm/fw-modal.js +11 -10
  25. package/esm/fw-navigation-menu.js +36 -41
  26. package/esm/fw-popover-BZ-zqUme.js +330 -0
  27. package/esm/fw-popover.js +2 -3
  28. package/esm/fw-progress-bar.js +1 -1
  29. package/esm/fw-provider-list.js +109 -87
  30. package/esm/fw-sidebar-menu.js +58 -51
  31. package/esm/fw-slider.js +64 -61
  32. package/esm/fw-switch.js +76 -49
  33. package/esm/fw-table-row-D6FdCJMs.js +447 -0
  34. package/esm/fw-table.js +5 -6
  35. package/esm/fw-tabs.js +87 -35
  36. package/esm/fw-tag-BRxPc4zc.js +199 -0
  37. package/esm/fw-tag.js +4 -4
  38. package/esm/fw-toast.js +58 -76
  39. package/esm/fw-transactions-card.js +20 -20
  40. package/esm/{get-root-colours-DCjlYelc.js → get-root-colours-DCCAnRF4.js} +3 -1
  41. package/esm/index-C8z11jcJ.js +7583 -0
  42. package/esm/index-DHyRsKsZ.js +843 -0
  43. package/esm/index-eP2GMSdQ.js +755 -0
  44. package/esm/index.js +54 -61
  45. package/esm/{uniqueId-DZdGzBh8.js → uniqueId-DK6xzFd8.js} +1 -1
  46. package/esm/{vee-validate.esm-3ptvCDR1.js → vee-validate-0dtT5GSQ.js} +182 -305
  47. package/frollo-web-ui.esm.js +10790 -3115
  48. package/icons/circle-check.svg +4 -0
  49. package/index.d.ts +1522 -586
  50. package/package.json +11 -11
  51. package/types/components/fw-accordion/fw-accordion.vue.d.ts +9 -7
  52. package/types/components/fw-alert/fw-alert.vue.d.ts +11 -6
  53. package/types/components/fw-bar-chart/fw-bar-chart.vue.d.ts +15 -64
  54. package/types/components/fw-button/fw-button.vue.d.ts +11 -7
  55. package/types/components/fw-card/fw-card.vue.d.ts +6 -6
  56. package/types/components/fw-checkbox/fw-checkbox.vue.d.ts +365 -5
  57. package/types/components/fw-date-picker/fw-date-picker.vue.d.ts +3 -242
  58. package/types/components/fw-drawer/fw-drawer.vue.d.ts +11 -8
  59. package/types/components/fw-dropdown/fw-dropdown.vue.d.ts +20 -12
  60. package/types/components/fw-icons/fw-success-animation.vue.d.ts +1 -1
  61. package/types/components/fw-image/fw-image.vue.d.ts +33 -7
  62. package/types/components/fw-input/fw-input.vue.d.ts +368 -10
  63. package/types/components/fw-loading/fw-loading-bar.vue.d.ts +7 -5
  64. package/types/components/fw-loading/fw-loading-card.vue.d.ts +3 -1
  65. package/types/components/fw-loading/fw-loading-dots.vue.d.ts +8 -1
  66. package/types/components/fw-loading/fw-loading-table.vue.d.ts +11 -6
  67. package/types/components/fw-media-picker/fw-media-picker.vue.d.ts +27 -18
  68. package/types/components/fw-modal/fw-modal.vue.d.ts +11 -7
  69. package/types/components/fw-navigation-menu/fw-navigation-menu.vue.d.ts +12 -8
  70. package/types/components/fw-popover/fw-popover.vue.d.ts +16 -21
  71. package/types/components/fw-progress-bar/fw-progress-bar.vue.d.ts +6 -4
  72. package/types/components/fw-provider-list/fw-provider-list.vue.d.ts +20 -45
  73. package/types/components/fw-sidebar-menu/fw-sidebar-menu.vue.d.ts +13 -7
  74. package/types/components/fw-slider/fw-slider.vue.d.ts +11 -8
  75. package/types/components/fw-switch/fw-switch.vue.d.ts +383 -9
  76. package/types/components/fw-switch/index.types.d.ts +1 -0
  77. package/types/components/fw-table/fw-table-head.vue.d.ts +1 -1
  78. package/types/components/fw-table/fw-table-row.vue.d.ts +1 -1
  79. package/types/components/fw-table/fw-table.vue.d.ts +40 -19
  80. package/types/components/fw-table/index.types.d.ts +36 -2
  81. package/types/components/fw-tabs/fw-tab.vue.d.ts +4 -8
  82. package/types/components/fw-tabs/fw-tabs.vue.d.ts +11 -8
  83. package/types/components/fw-tabs/index.types.d.ts +14 -4
  84. package/types/components/fw-tag/fw-tag.vue.d.ts +14 -8
  85. package/types/components/fw-toast/fw-toast.vue.d.ts +17 -22
  86. package/types/components/fw-transactions-card/fw-transactions-card.vue.d.ts +6 -3
  87. package/types/directives/lazy-loader.d.ts +11 -2
  88. package/types/helpers/get-root-colours.d.ts +1 -0
  89. package/web-components/index.js +16793 -7700
  90. package/esm/fw-button-YMoW4x4c.js +0 -296
  91. package/esm/fw-image-D-OHafdw.js +0 -217
  92. package/esm/fw-loading-bar-DecYSBC_.js +0 -45
  93. package/esm/fw-popover-B4bsfuxm.js +0 -620
  94. package/esm/fw-table-row-Cgi8871h.js +0 -389
  95. package/esm/fw-tag-fDo50Nw7.js +0 -177
  96. package/esm/index-BsEH8YYr.js +0 -979
@@ -0,0 +1,755 @@
1
+ import { c as _asyncToGenerator, d as _regeneratorRuntime, a as _slicedToArray, b as _toConsumableArray } from './_rollupPluginBabelHelpers-BKlDnZ7n.js';
2
+ import { h, render as render$1, defineComponent, ref, shallowRef, onBeforeUnmount, computed, watch, nextTick, resolveComponent, createElementBlock, openBlock, Fragment, createElementVNode, createVNode, toDisplayString, withCtx, withModifiers, normalizeClass, createCommentVNode, createTextVNode } from 'vue';
3
+ import { e as render$2, f as render$3, g as render$4, h as render$5, i as render$6, j as render$7 } from './index-DHyRsKsZ.js';
4
+ import { FwModal as __default__ } from './fw-modal.js';
5
+ import './fw-button.js';
6
+ import { u as useColours } from './get-root-colours-DCCAnRF4.js';
7
+ import { s as script$1 } from './fw-button-DZTHZLjk.js';
8
+ import { s as styleInject } from './style-inject.es-tgCJW-Cu.js';
9
+
10
+ var getVueComponentHtml = function getVueComponentHtml(component, props) {
11
+ var myVNode = h(component, props);
12
+ var tempElement = document.createElement('div'); // Create a temporary DOM element
13
+ render$1(myVNode, tempElement); // Render the VNode into the temporary element
14
+ var componentHtmlString = tempElement.innerHTML; // Get the HTML string
15
+ return componentHtmlString;
16
+ };
17
+
18
+ var script = defineComponent({
19
+ name: 'MediaPicker',
20
+ components: {
21
+ FwModal: __default__,
22
+ FwButton: script$1,
23
+ ArrowRotateSvg: render$7,
24
+ CloudArrowUpSvg: render$6,
25
+ GuideSvg: render$5,
26
+ LoadingSvg: render$4,
27
+ PenSvg: render$3,
28
+ PlusSvg: render$2
29
+ },
30
+ emits: [/** Fired when media is selected */
31
+ 'selected'],
32
+ props: {
33
+ /**
34
+ * The accepted file types for the media picker
35
+ */
36
+ acceptedFileTypes: {
37
+ type: String,
38
+ "default": 'image/png, image/jpeg'
39
+ },
40
+ /**
41
+ * The maximum file size in bytes. Default 8 MB
42
+ */
43
+ maxFileSize: {
44
+ type: Number,
45
+ "default": 8 * 1024 * 1024
46
+ },
47
+ /**
48
+ * The title of the picker tile
49
+ */
50
+ title: {
51
+ type: String
52
+ },
53
+ /**
54
+ * The image URL to display in the media picker
55
+ */
56
+ imageUrl: {
57
+ type: String
58
+ },
59
+ /**
60
+ * The header text for the upload modal
61
+ */
62
+ uploadHeaderText: {
63
+ type: String,
64
+ "default": 'Upload Image'
65
+ },
66
+ /**
67
+ * The header text for the edit modal
68
+ */
69
+ editHeaderText: {
70
+ type: String,
71
+ "default": 'Edit Image'
72
+ }
73
+ },
74
+ setup: function setup(props, _ref) {
75
+ var emit = _ref.emit;
76
+ // State
77
+ var isSelectMediaModalOpen = ref(false);
78
+ var isEditMediaModalOpen = ref(false);
79
+ var fileInput = ref(null);
80
+ var editorCanvas = ref(null);
81
+ var selectedFile = shallowRef(null);
82
+ var bitmap = shallowRef(null);
83
+ var dragging = ref(false);
84
+ var loading = ref(false);
85
+ var _useColours = useColours(),
86
+ colorSuccessNew = _useColours.colorSuccessNew;
87
+ // preview URL w/ cleanup
88
+ var previewUrl = ref(null);
89
+ onBeforeUnmount(function () {
90
+ var _bitmap$value, _bitmap$value$close;
91
+ if (previewUrl.value) URL.revokeObjectURL(previewUrl.value);
92
+ (_bitmap$value = bitmap.value) === null || _bitmap$value === void 0 || (_bitmap$value$close = _bitmap$value.close) === null || _bitmap$value$close === void 0 || _bitmap$value$close.call(_bitmap$value);
93
+ });
94
+ // File validation / display helpers
95
+ var acceptedTypes = computed(function () {
96
+ return props.acceptedFileTypes.split(',').map(function (t) {
97
+ return t.trim();
98
+ });
99
+ });
100
+ var isInvalidFile = computed(function () {
101
+ var f = selectedFile.value;
102
+ if (!f) return false;
103
+ return f.size > props.maxFileSize || !acceptedTypes.value.includes(f.type);
104
+ });
105
+ var previewImageUrl = computed(function () {
106
+ var _previewUrl$value;
107
+ return (_previewUrl$value = previewUrl.value) !== null && _previewUrl$value !== void 0 ? _previewUrl$value : undefined;
108
+ });
109
+ var acceptedFileTypesText = computed(function () {
110
+ return props.acceptedFileTypes.split(',').map(function (type) {
111
+ return type.replace('image/', '').toUpperCase().trim();
112
+ }).join(', ');
113
+ });
114
+ var maxFileSizeText = computed(function () {
115
+ var sizeInMB = Math.floor(props.maxFileSize / (1024 * 1024));
116
+ return "".concat(sizeInMB, "MB");
117
+ });
118
+ // File selection / drag drop
119
+ var openFilePicker = function openFilePicker() {
120
+ var _fileInput$value;
121
+ return (_fileInput$value = fileInput.value) === null || _fileInput$value === void 0 ? void 0 : _fileInput$value.click();
122
+ };
123
+ var setFile = function setFile(file) {
124
+ selectedFile.value = file;
125
+ // Revoke old preview URL, create new
126
+ if (previewUrl.value) URL.revokeObjectURL(previewUrl.value);
127
+ previewUrl.value = file ? URL.createObjectURL(file) : null;
128
+ };
129
+ var fileSelected = function fileSelected(event) {
130
+ var _target$files$, _target$files;
131
+ var target = event.target;
132
+ var file = (_target$files$ = (_target$files = target.files) === null || _target$files === void 0 ? void 0 : _target$files[0]) !== null && _target$files$ !== void 0 ? _target$files$ : null;
133
+ setFile(file);
134
+ if (file && !isInvalidFile.value) showEditor();
135
+ };
136
+ var dragDropFile = function dragDropFile(event) {
137
+ var _event$dataTransfer$f, _event$dataTransfer;
138
+ var file = (_event$dataTransfer$f = (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 || (_event$dataTransfer = _event$dataTransfer.files) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer[0]) !== null && _event$dataTransfer$f !== void 0 ? _event$dataTransfer$f : null;
139
+ setFile(file);
140
+ dragging.value = false;
141
+ if (file && !isInvalidFile.value) showEditor();
142
+ };
143
+ // Sync from imageUrl prop (watch the prop directly)
144
+ var fetchToken = 0;
145
+ watch(function () {
146
+ return props.imageUrl;
147
+ }, /*#__PURE__*/function () {
148
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
149
+ var _bitmap$value2, _bitmap$value2$close, myToken, res, blob, mimeType, file;
150
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
151
+ while (1) switch (_context.prev = _context.next) {
152
+ case 0:
153
+ if (url) {
154
+ _context.next = 5;
155
+ break;
156
+ }
157
+ setFile(null);
158
+ (_bitmap$value2 = bitmap.value) === null || _bitmap$value2 === void 0 || (_bitmap$value2$close = _bitmap$value2.close) === null || _bitmap$value2$close === void 0 || _bitmap$value2$close.call(_bitmap$value2);
159
+ bitmap.value = null;
160
+ return _context.abrupt("return");
161
+ case 5:
162
+ myToken = ++fetchToken;
163
+ loading.value = true;
164
+ _context.prev = 7;
165
+ _context.next = 10;
166
+ return fetch(url);
167
+ case 10:
168
+ res = _context.sent;
169
+ _context.next = 13;
170
+ return res.blob();
171
+ case 13:
172
+ blob = _context.sent;
173
+ mimeType = res.headers.get('Content-Type') || blob.type;
174
+ file = new File([blob], 'image', {
175
+ type: mimeType
176
+ });
177
+ if (!(myToken !== fetchToken)) {
178
+ _context.next = 18;
179
+ break;
180
+ }
181
+ return _context.abrupt("return");
182
+ case 18:
183
+ // stale fetch
184
+ setFile(file);
185
+ _context.next = 24;
186
+ break;
187
+ case 21:
188
+ _context.prev = 21;
189
+ _context.t0 = _context["catch"](7);
190
+ console.error('Error fetching image:', _context.t0);
191
+ case 24:
192
+ _context.prev = 24;
193
+ if (myToken === fetchToken) loading.value = false;
194
+ return _context.finish(24);
195
+ case 27:
196
+ case "end":
197
+ return _context.stop();
198
+ }
199
+ }, _callee, null, [[7, 21, 24, 27]]);
200
+ }));
201
+ return function (_x) {
202
+ return _ref2.apply(this, arguments);
203
+ };
204
+ }(), {
205
+ immediate: true
206
+ });
207
+ // Decode bitmap once per file
208
+ var decodeToken = 0;
209
+ watch(selectedFile, /*#__PURE__*/function () {
210
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(file) {
211
+ var _bitmap$value3, _bitmap$value3$close;
212
+ var myToken, bm, _bm$close;
213
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
214
+ while (1) switch (_context2.prev = _context2.next) {
215
+ case 0:
216
+ (_bitmap$value3 = bitmap.value) === null || _bitmap$value3 === void 0 || (_bitmap$value3$close = _bitmap$value3.close) === null || _bitmap$value3$close === void 0 || _bitmap$value3$close.call(_bitmap$value3);
217
+ bitmap.value = null;
218
+ if (file) {
219
+ _context2.next = 4;
220
+ break;
221
+ }
222
+ return _context2.abrupt("return");
223
+ case 4:
224
+ myToken = ++decodeToken;
225
+ _context2.prev = 5;
226
+ _context2.next = 8;
227
+ return createImageBitmap(file);
228
+ case 8:
229
+ bm = _context2.sent;
230
+ if (!(myToken !== decodeToken)) {
231
+ _context2.next = 12;
232
+ break;
233
+ }
234
+ (_bm$close = bm.close) === null || _bm$close === void 0 || _bm$close.call(bm);
235
+ return _context2.abrupt("return");
236
+ case 12:
237
+ bitmap.value = bm;
238
+ if (isEditMediaModalOpen.value) scheduleDraw();
239
+ _context2.next = 19;
240
+ break;
241
+ case 16:
242
+ _context2.prev = 16;
243
+ _context2.t0 = _context2["catch"](5);
244
+ console.error('Error decoding bitmap:', _context2.t0);
245
+ case 19:
246
+ case "end":
247
+ return _context2.stop();
248
+ }
249
+ }, _callee2, null, [[5, 16]]);
250
+ }));
251
+ return function (_x2) {
252
+ return _ref3.apply(this, arguments);
253
+ };
254
+ }(), {
255
+ immediate: true
256
+ });
257
+ // Canvas editing logic
258
+ var imageX = ref(0);
259
+ var imageY = ref(0);
260
+ var scaledWidth = ref(0);
261
+ var scaledHeight = ref(0);
262
+ var interaction = ref({
263
+ type: null,
264
+ startX: 0,
265
+ startY: 0,
266
+ startImgX: 0,
267
+ startImgY: 0,
268
+ startW: 0,
269
+ startH: 0,
270
+ offsetX: 0,
271
+ offsetY: 0
272
+ });
273
+ var isEditingImage = ref(false);
274
+ var pointerType = {
275
+ 'top-left': 'nwse-resize',
276
+ 'top-right': 'nesw-resize',
277
+ 'bottom-left': 'nesw-resize',
278
+ 'bottom-right': 'nwse-resize',
279
+ inside: 'move'
280
+ };
281
+ var detectHandle = function detectHandle(px, py) {
282
+ var squareSize = 5;
283
+ var x = imageX.value;
284
+ var y = imageY.value;
285
+ var w = scaledWidth.value;
286
+ var h = scaledHeight.value;
287
+ if (px < x || px > x + w || py < y || py > y + h) return null;
288
+ if (px <= x + squareSize && py <= y + squareSize) return 'top-left';
289
+ if (px >= x + w - squareSize && py <= y + squareSize) return 'top-right';
290
+ if (px <= x + squareSize && py >= y + h - squareSize) return 'bottom-left';
291
+ if (px >= x + w - squareSize && py >= y + h - squareSize) return 'bottom-right';
292
+ return 'inside';
293
+ };
294
+ // RAF batching for pointermove redraws
295
+ var rafId = null;
296
+ var scheduleDraw = function scheduleDraw() {
297
+ var save = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
298
+ if (rafId != null) return;
299
+ rafId = requestAnimationFrame(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
300
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
301
+ while (1) switch (_context3.prev = _context3.next) {
302
+ case 0:
303
+ rafId = null;
304
+ _context3.next = 3;
305
+ return drawImageOnCanvas(save);
306
+ case 3:
307
+ case "end":
308
+ return _context3.stop();
309
+ }
310
+ }, _callee3);
311
+ })));
312
+ };
313
+ var drawImageOnCanvas = /*#__PURE__*/function () {
314
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
315
+ var save,
316
+ canvas,
317
+ bm,
318
+ ctx,
319
+ imgW,
320
+ imgH,
321
+ cW,
322
+ cH,
323
+ scale,
324
+ squareSize,
325
+ half,
326
+ corners,
327
+ _i,
328
+ _corners,
329
+ _corners$_i,
330
+ cx,
331
+ cy,
332
+ _args4 = arguments;
333
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
334
+ while (1) switch (_context4.prev = _context4.next) {
335
+ case 0:
336
+ save = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : false;
337
+ canvas = editorCanvas.value;
338
+ bm = bitmap.value;
339
+ if (!(!canvas || !bm)) {
340
+ _context4.next = 5;
341
+ break;
342
+ }
343
+ return _context4.abrupt("return");
344
+ case 5:
345
+ ctx = canvas.getContext('2d');
346
+ if (ctx) {
347
+ _context4.next = 8;
348
+ break;
349
+ }
350
+ return _context4.abrupt("return");
351
+ case 8:
352
+ imgW = bm.width, imgH = bm.height;
353
+ cW = canvas.width, cH = canvas.height;
354
+ ctx.clearRect(0, 0, cW, cH);
355
+ // initialize position/scale on first draw
356
+ if (imageX.value === 0 && imageY.value === 0 && scaledWidth.value === 0 && scaledHeight.value === 0) {
357
+ scale = Math.min(cW / imgW, cH / imgH);
358
+ scaledWidth.value = imgW * scale;
359
+ scaledHeight.value = imgH * scale;
360
+ imageX.value = cW / 2 - scaledWidth.value / 2;
361
+ imageY.value = cH / 2 - scaledHeight.value / 2;
362
+ }
363
+ ctx.drawImage(bm, imageX.value, imageY.value, scaledWidth.value, scaledHeight.value);
364
+ if (!save) {
365
+ ctx.strokeStyle = colorSuccessNew;
366
+ ctx.lineWidth = 2;
367
+ ctx.strokeRect(imageX.value, imageY.value, scaledWidth.value, scaledHeight.value);
368
+ squareSize = 5;
369
+ half = squareSize / 2;
370
+ corners = [[imageX.value - half, imageY.value - half], [imageX.value + scaledWidth.value - half, imageY.value - half], [imageX.value - half, imageY.value + scaledHeight.value - half], [imageX.value + scaledWidth.value - half, imageY.value + scaledHeight.value - half]];
371
+ ctx.fillStyle = colorSuccessNew;
372
+ for (_i = 0, _corners = corners; _i < _corners.length; _i++) {
373
+ _corners$_i = _slicedToArray(_corners[_i], 2), cx = _corners$_i[0], cy = _corners$_i[1];
374
+ ctx.fillRect(cx, cy, squareSize, squareSize);
375
+ }
376
+ }
377
+ case 14:
378
+ case "end":
379
+ return _context4.stop();
380
+ }
381
+ }, _callee4);
382
+ }));
383
+ return function drawImageOnCanvas() {
384
+ return _ref5.apply(this, arguments);
385
+ };
386
+ }();
387
+ var showEditor = function showEditor() {
388
+ isSelectMediaModalOpen.value = false;
389
+ isEditMediaModalOpen.value = true;
390
+ nextTick(function () {
391
+ return scheduleDraw();
392
+ });
393
+ };
394
+ var startEditImage = function startEditImage(e) {
395
+ if (e.button !== 0) return;
396
+ var canvas = editorCanvas.value;
397
+ if (!canvas) return;
398
+ var type = detectHandle(e.offsetX, e.offsetY);
399
+ if (!type) return;
400
+ isEditingImage.value = true;
401
+ interaction.value.type = type;
402
+ interaction.value.startX = e.offsetX;
403
+ interaction.value.startY = e.offsetY;
404
+ interaction.value.startImgX = imageX.value;
405
+ interaction.value.startImgY = imageY.value;
406
+ interaction.value.startW = scaledWidth.value;
407
+ interaction.value.startH = scaledHeight.value;
408
+ if (type === 'inside') {
409
+ interaction.value.offsetX = e.offsetX - imageX.value;
410
+ interaction.value.offsetY = e.offsetY - imageY.value;
411
+ }
412
+ canvas.setPointerCapture(e.pointerId);
413
+ };
414
+ var stopEditImage = function stopEditImage(e) {
415
+ var _editorCanvas$value;
416
+ isEditingImage.value = false;
417
+ interaction.value.type = null;
418
+ (_editorCanvas$value = editorCanvas.value) === null || _editorCanvas$value === void 0 || _editorCanvas$value.releasePointerCapture(e.pointerId);
419
+ if (editorCanvas.value) editorCanvas.value.style.cursor = 'default';
420
+ };
421
+ var editImage = function editImage(e) {
422
+ var canvas = editorCanvas.value;
423
+ if (!canvas) return;
424
+ if (!isEditingImage.value) {
425
+ var _type = detectHandle(e.offsetX, e.offsetY);
426
+ canvas.style.cursor = _type ? pointerType[_type] : 'default';
427
+ return;
428
+ }
429
+ var type = interaction.value.type;
430
+ if (!type) return;
431
+ if (type === 'inside') {
432
+ imageX.value = e.offsetX - interaction.value.offsetX;
433
+ imageY.value = e.offsetY - interaction.value.offsetY;
434
+ } else {
435
+ var dx = e.offsetX - interaction.value.startX;
436
+ var dy = e.offsetY - interaction.value.startY;
437
+ switch (type) {
438
+ case 'top-left':
439
+ imageX.value = interaction.value.startImgX + dx;
440
+ imageY.value = interaction.value.startImgY + dy;
441
+ scaledWidth.value = interaction.value.startW - dx;
442
+ scaledHeight.value = interaction.value.startH - dy;
443
+ break;
444
+ case 'top-right':
445
+ imageY.value = interaction.value.startImgY + dy;
446
+ scaledWidth.value = interaction.value.startW + dx;
447
+ scaledHeight.value = interaction.value.startH - dy;
448
+ break;
449
+ case 'bottom-left':
450
+ imageX.value = interaction.value.startImgX + dx;
451
+ scaledWidth.value = interaction.value.startW - dx;
452
+ scaledHeight.value = interaction.value.startH + dy;
453
+ break;
454
+ case 'bottom-right':
455
+ scaledWidth.value = interaction.value.startW + dx;
456
+ scaledHeight.value = interaction.value.startH + dy;
457
+ break;
458
+ }
459
+ var MIN_SIZE = 10;
460
+ scaledWidth.value = Math.max(scaledWidth.value, MIN_SIZE);
461
+ scaledHeight.value = Math.max(scaledHeight.value, MIN_SIZE);
462
+ }
463
+ scheduleDraw();
464
+ };
465
+ // Actions
466
+ var clearEdits = function clearEdits() {
467
+ imageX.value = 0;
468
+ imageY.value = 0;
469
+ scaledWidth.value = 0;
470
+ scaledHeight.value = 0;
471
+ };
472
+ var change = function change() {
473
+ clearEdits();
474
+ setFile(null);
475
+ isSelectMediaModalOpen.value = true;
476
+ isEditMediaModalOpen.value = false;
477
+ };
478
+ var reset = function reset() {
479
+ clearEdits();
480
+ scheduleDraw();
481
+ };
482
+ var save = /*#__PURE__*/function () {
483
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
484
+ var canvas;
485
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
486
+ while (1) switch (_context5.prev = _context5.next) {
487
+ case 0:
488
+ canvas = editorCanvas.value;
489
+ if (canvas) {
490
+ _context5.next = 3;
491
+ break;
492
+ }
493
+ return _context5.abrupt("return");
494
+ case 3:
495
+ _context5.next = 5;
496
+ return drawImageOnCanvas(true);
497
+ case 5:
498
+ canvas.toBlob(function (blob) {
499
+ if (!blob) return;
500
+ var file = new File([blob], 'edited-image.png', {
501
+ type: 'image/png'
502
+ });
503
+ setFile(file);
504
+ emit('selected', file);
505
+ isEditMediaModalOpen.value = false;
506
+ clearEdits();
507
+ }, 'image/png');
508
+ case 6:
509
+ case "end":
510
+ return _context5.stop();
511
+ }
512
+ }, _callee5);
513
+ }));
514
+ return function save() {
515
+ return _ref6.apply(this, arguments);
516
+ };
517
+ }();
518
+ return {
519
+ previewImageUrl: previewImageUrl,
520
+ fileInput: fileInput,
521
+ editorCanvas: editorCanvas,
522
+ isSelectMediaModalOpen: isSelectMediaModalOpen,
523
+ isEditMediaModalOpen: isEditMediaModalOpen,
524
+ acceptedFileTypesText: acceptedFileTypesText,
525
+ maxFileSizeText: maxFileSizeText,
526
+ openFilePicker: openFilePicker,
527
+ fileSelected: fileSelected,
528
+ dragging: dragging,
529
+ loading: loading,
530
+ dragDropFile: dragDropFile,
531
+ isInvalidFile: isInvalidFile,
532
+ showEditor: showEditor,
533
+ change: change,
534
+ reset: reset,
535
+ save: save,
536
+ startEditImage: startEditImage,
537
+ stopEditImage: stopEditImage,
538
+ editImage: editImage
539
+ };
540
+ }
541
+ });
542
+
543
+ var _hoisted_1 = ["accept"];
544
+ var _hoisted_2 = {
545
+ "class": "cursor-pointer w-[160px] h-[160px] bg-white"
546
+ };
547
+ var _hoisted_3 = ["src"];
548
+ var _hoisted_4 = {
549
+ key: 1,
550
+ "class": "flex flex-col w-full h-full items-center justify-center gap-2 border border-grey-100 rounded"
551
+ };
552
+ var _hoisted_5 = {
553
+ "class": "text-brand-text3 group-hover:text-brand-text2"
554
+ };
555
+ var _hoisted_6 = {
556
+ "class": "pt-[23px] px-4 pb-2 mb-0 text-left"
557
+ };
558
+ var _hoisted_7 = {
559
+ "class": "h-[360px] px-10 pb-10"
560
+ };
561
+ var _hoisted_8 = {
562
+ key: 0,
563
+ "class": "text-error"
564
+ };
565
+ var _hoisted_9 = {
566
+ "class": "pt-[23px] px-4 pb-2 mb-0 text-left"
567
+ };
568
+ var _hoisted_10 = {
569
+ "class": "flex flex-col items-center justify-center p-10 bg-black gap-1"
570
+ };
571
+ var _hoisted_11 = {
572
+ "class": "w-[300px] h-[300px] rounded bg-white relative"
573
+ };
574
+ var _hoisted_12 = {
575
+ "class": "flex px-6 py-4 gap-2 w-full justify-between flex-col sm:flex-row"
576
+ };
577
+ var _hoisted_13 = {
578
+ "class": "flex justify-start gap-2 flex-col sm:flex-row"
579
+ };
580
+ var _hoisted_14 = {
581
+ "class": "flex flex-row items-center gap-2"
582
+ };
583
+ var _hoisted_15 = {
584
+ "class": "flex justify-end flex-col sm:flex-row"
585
+ };
586
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
587
+ var _component_PenSvg = resolveComponent("PenSvg");
588
+ var _component_LoadingSvg = resolveComponent("LoadingSvg");
589
+ var _component_PlusSvg = resolveComponent("PlusSvg");
590
+ var _component_CloudArrowUpSvg = resolveComponent("CloudArrowUpSvg");
591
+ var _component_FwButton = resolveComponent("FwButton");
592
+ var _component_FwModal = resolveComponent("FwModal");
593
+ var _component_GuideSvg = resolveComponent("GuideSvg");
594
+ var _component_ArrowRotateSvg = resolveComponent("ArrowRotateSvg");
595
+ return openBlock(), createElementBlock(Fragment, null, [createElementVNode("input", {
596
+ ref: "fileInput",
597
+ type: "file",
598
+ accept: _ctx.acceptedFileTypes,
599
+ "class": "hidden",
600
+ onChange: _cache[0] || (_cache[0] = function () {
601
+ return _ctx.fileSelected && _ctx.fileSelected.apply(_ctx, arguments);
602
+ })
603
+ }, null, 40, _hoisted_1), createElementVNode("div", _hoisted_2, [_ctx.previewImageUrl ? (openBlock(), createElementBlock("div", {
604
+ key: 0,
605
+ "class": "w-full h-full relative",
606
+ onClick: _cache[1] || (_cache[1] = function () {
607
+ return _ctx.showEditor && _ctx.showEditor.apply(_ctx, arguments);
608
+ })
609
+ }, [createVNode(_component_PenSvg, {
610
+ name: "pen",
611
+ "class": "absolute bottom-[-8px] right-[-8px] w-8 h-8 p-2 text-white bg-primary rounded-full"
612
+ }), createElementVNode("img", {
613
+ src: _ctx.previewImageUrl,
614
+ "class": "object-cover rounded w-full h-full"
615
+ }, null, 8, _hoisted_3)])) : _ctx.loading ? (openBlock(), createElementBlock("div", _hoisted_4, [createVNode(_component_LoadingSvg, {
616
+ name: "loading",
617
+ "class": "w-8 h-8 text-brand-text2 animate-spin"
618
+ })])) : (openBlock(), createElementBlock("div", {
619
+ key: 2,
620
+ "class": "fw-media-picker--empty group",
621
+ onClick: _cache[2] || (_cache[2] = function ($event) {
622
+ return _ctx.isSelectMediaModalOpen = true;
623
+ })
624
+ }, [createVNode(_component_PlusSvg, {
625
+ name: "plus",
626
+ "class": "w-8 h-8 p-1 text-brand-text3 rounded-full border border-brand-text3 group-hover:border-brand-text2 group-hover:text-brand-text2"
627
+ }), createElementVNode("p", _hoisted_5, toDisplayString(_ctx.title), 1)]))]), createVNode(_component_FwModal, {
628
+ modelValue: _ctx.isSelectMediaModalOpen,
629
+ "onUpdate:modelValue": _cache[7] || (_cache[7] = function ($event) {
630
+ return _ctx.isSelectMediaModalOpen = $event;
631
+ }),
632
+ "show-confirm": false,
633
+ "show-cancel": false,
634
+ "show-close-button": true,
635
+ padding: false,
636
+ "footer-class": "px-4 pb-8",
637
+ onCancel: _cache[8] || (_cache[8] = function ($event) {
638
+ return _ctx.isSelectMediaModalOpen = false;
639
+ })
640
+ }, {
641
+ header: withCtx(function () {
642
+ return [createElementVNode("h4", _hoisted_6, toDisplayString(_ctx.uploadHeaderText), 1)];
643
+ }),
644
+ body: withCtx(function () {
645
+ return [createElementVNode("div", _hoisted_7, [createElementVNode("div", {
646
+ "class": normalizeClass(["flex flex-col border border-1 border-dashed border-grey-40 rounded h-full items-center justify-center gap-1 bg-white", {
647
+ 'border-primary !bg-grey-40/60': _ctx.dragging,
648
+ '!border-error': _ctx.isInvalidFile
649
+ }]),
650
+ onDragenter: _cache[3] || (_cache[3] = withModifiers(function ($event) {
651
+ return _ctx.dragging = true;
652
+ }, ["prevent"])),
653
+ onDragover: _cache[4] || (_cache[4] = withModifiers(function ($event) {
654
+ return _ctx.dragging = true;
655
+ }, ["prevent"])),
656
+ onDragleave: _cache[5] || (_cache[5] = withModifiers(function ($event) {
657
+ return _ctx.dragging = false;
658
+ }, ["prevent"])),
659
+ onDrop: _cache[6] || (_cache[6] = withModifiers(function () {
660
+ return _ctx.dragDropFile && _ctx.dragDropFile.apply(_ctx, arguments);
661
+ }, ["prevent"]))
662
+ }, [createVNode(_component_CloudArrowUpSvg, {
663
+ name: "cloud-arrow-up",
664
+ "class": "w-12 h-12 p-1 text-grey-80"
665
+ }), createElementVNode("p", null, [_cache[15] || (_cache[15] = createTextVNode(" Select file to ", -1)), createVNode(_component_FwButton, {
666
+ variant: "link",
667
+ onClick: withModifiers(_ctx.openFilePicker, ["prevent"])
668
+ }, {
669
+ "default": withCtx(function () {
670
+ return _toConsumableArray(_cache[14] || (_cache[14] = [createTextVNode("upload", -1)]));
671
+ }),
672
+ _: 1
673
+ }, 8, ["onClick"]), _cache[16] || (_cache[16] = createTextVNode(" or drag-and-drop a file. ", -1)), _cache[17] || (_cache[17] = createElementVNode("br", null, null, -1)), createElementVNode("span", null, toDisplayString(_ctx.acceptedFileTypesText) + " files only", 1), _cache[18] || (_cache[18] = createTextVNode(". ", -1)), _cache[19] || (_cache[19] = createElementVNode("br", null, null, -1)), createTextVNode(" Recommended 300 x 300 or larger. Max " + toDisplayString(_ctx.maxFileSizeText) + ". ", 1)]), _ctx.isInvalidFile ? (openBlock(), createElementBlock("p", _hoisted_8, "Please upload a valid file")) : createCommentVNode("", true)], 34)])];
674
+ }),
675
+ _: 1
676
+ }, 8, ["modelValue"]), createVNode(_component_FwModal, {
677
+ modelValue: _ctx.isEditMediaModalOpen,
678
+ "onUpdate:modelValue": _cache[12] || (_cache[12] = function ($event) {
679
+ return _ctx.isEditMediaModalOpen = $event;
680
+ }),
681
+ "show-confirm": false,
682
+ "show-cancel": false,
683
+ "show-close-button": true,
684
+ padding: false,
685
+ "container-class": "!bg-[#F7F7F7] w-full",
686
+ "footer-class": "px-4 pb-8",
687
+ onCancel: _cache[13] || (_cache[13] = function ($event) {
688
+ return _ctx.isEditMediaModalOpen = false;
689
+ })
690
+ }, {
691
+ header: withCtx(function () {
692
+ return [createElementVNode("h4", _hoisted_9, toDisplayString(_ctx.editHeaderText), 1)];
693
+ }),
694
+ body: withCtx(function () {
695
+ return [createElementVNode("div", _hoisted_10, [createElementVNode("div", _hoisted_11, [createVNode(_component_GuideSvg, {
696
+ name: "guide",
697
+ "class": "absolute pointer-events-none"
698
+ }), createElementVNode("canvas", {
699
+ ref: "editorCanvas",
700
+ width: "300",
701
+ height: "300",
702
+ onPointerdown: _cache[9] || (_cache[9] = function () {
703
+ return _ctx.startEditImage && _ctx.startEditImage.apply(_ctx, arguments);
704
+ }),
705
+ onPointerup: _cache[10] || (_cache[10] = function () {
706
+ return _ctx.stopEditImage && _ctx.stopEditImage.apply(_ctx, arguments);
707
+ }),
708
+ onPointermove: _cache[11] || (_cache[11] = function () {
709
+ return _ctx.editImage && _ctx.editImage.apply(_ctx, arguments);
710
+ })
711
+ }, null, 544)]), _cache[20] || (_cache[20] = createElementVNode("p", {
712
+ "class": "text-white text-sm"
713
+ }, "Drag to reposition or resize", -1))]), createElementVNode("div", _hoisted_12, [createElementVNode("div", _hoisted_13, [createVNode(_component_FwButton, {
714
+ variant: "tertiary",
715
+ size: "md",
716
+ onClick: _ctx.change
717
+ }, {
718
+ "default": withCtx(function () {
719
+ return _toConsumableArray(_cache[21] || (_cache[21] = [createTextVNode("Change", -1)]));
720
+ }),
721
+ _: 1
722
+ }, 8, ["onClick"]), createVNode(_component_FwButton, {
723
+ variant: "tertiary",
724
+ size: "md",
725
+ onClick: _ctx.reset
726
+ }, {
727
+ "default": withCtx(function () {
728
+ return [createElementVNode("div", _hoisted_14, [_cache[22] || (_cache[22] = createTextVNode(" Reset ", -1)), createVNode(_component_ArrowRotateSvg, {
729
+ name: "arrow-rotate",
730
+ "class": "inline-block ml-1 w-4 h-4"
731
+ })])];
732
+ }),
733
+ _: 1
734
+ }, 8, ["onClick"])]), createElementVNode("div", _hoisted_15, [createVNode(_component_FwButton, {
735
+ variant: "primary",
736
+ size: "md",
737
+ onClick: _ctx.save
738
+ }, {
739
+ "default": withCtx(function () {
740
+ return _toConsumableArray(_cache[23] || (_cache[23] = [createTextVNode("Save", -1)]));
741
+ }),
742
+ _: 1
743
+ }, 8, ["onClick"])])])];
744
+ }),
745
+ _: 1
746
+ }, 8, ["modelValue"])], 64);
747
+ }
748
+
749
+ var css_248z = ".fw-media-picker--empty{-webkit-box-orient:vertical;-webkit-box-direction:normal;-moz-box-orient:vertical;-moz-box-direction:normal;-webkit-box-align:center;-moz-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-moz-box-pack:center;-ms-flex-pack:center;--tw-border-opacity:1;-webkit-align-items:center;align-items:center;border-color:rgb(200 203 208/var(--tw-border-opacity));border-radius:.25rem;border-width:1px;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;gap:.5rem;height:100%;-webkit-justify-content:center;justify-content:center;text-align:center;width:100%}.fw-media-picker--empty:hover{border-color:var(--colorText2);color:var(--colorText2)}";
750
+ var stylesheet = ".fw-media-picker--empty{-webkit-box-orient:vertical;-webkit-box-direction:normal;-moz-box-orient:vertical;-moz-box-direction:normal;-webkit-box-align:center;-moz-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-moz-box-pack:center;-ms-flex-pack:center;--tw-border-opacity:1;-webkit-align-items:center;align-items:center;border-color:rgb(200 203 208/var(--tw-border-opacity));border-radius:.25rem;border-width:1px;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;gap:.5rem;height:100%;-webkit-justify-content:center;justify-content:center;text-align:center;width:100%}.fw-media-picker--empty:hover{border-color:var(--colorText2);color:var(--colorText2)}";
751
+ styleInject(css_248z);
752
+
753
+ script.render = render;
754
+
755
+ export { getVueComponentHtml as g, script as s };