@react-fabric/draw 1.0.0-beta.9 → 1.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 (57) hide show
  1. package/dist/cjs/index.js +32 -0
  2. package/dist/esm/index.js +31 -0
  3. package/dist/types/index.d.ts +26 -1
  4. package/package.json +15 -17
  5. package/src/index.ts +21 -18
  6. package/dist/cjs/_virtual/_commonjsHelpers.js +0 -7
  7. package/dist/cjs/_virtual/dom-to-image.js +0 -5
  8. package/dist/cjs/node_modules/dom-to-image/src/dom-to-image.js +0 -777
  9. package/dist/cjs/packages/draw/src/canvas/DrawCanvas.js +0 -326
  10. package/dist/cjs/packages/draw/src/canvas/DrawContext.js +0 -22
  11. package/dist/cjs/packages/draw/src/canvas/shapes/avatar/AvatarShapeTool.js +0 -271
  12. package/dist/cjs/packages/draw/src/canvas/shapes/avatar/IdleState.js +0 -59
  13. package/dist/cjs/packages/draw/src/canvas/shapes/avatar/PointingState.js +0 -84
  14. package/dist/cjs/packages/draw/src/canvas/shapes/avatar/type.js +0 -36
  15. package/dist/cjs/packages/draw/src/canvas/shapes/custom/AudioShape.js +0 -152
  16. package/dist/cjs/packages/draw/src/canvas/shapes/custom/CardShape.js +0 -115
  17. package/dist/cjs/packages/draw/src/canvas/shapes/custom/FileShape.js +0 -128
  18. package/dist/cjs/packages/draw/src/canvas/shapes/custom/ImageShape.js +0 -137
  19. package/dist/cjs/packages/draw/src/canvas/shapes/custom/VideoShape.js +0 -160
  20. package/dist/cjs/packages/draw/src/index.js +0 -7
  21. package/dist/esm/_virtual/_commonjsHelpers.js +0 -7
  22. package/dist/esm/_virtual/dom-to-image.js +0 -5
  23. package/dist/esm/node_modules/dom-to-image/src/dom-to-image.js +0 -777
  24. package/dist/esm/packages/draw/src/canvas/DrawCanvas.js +0 -325
  25. package/dist/esm/packages/draw/src/canvas/DrawContext.js +0 -21
  26. package/dist/esm/packages/draw/src/canvas/shapes/avatar/AvatarShapeTool.js +0 -270
  27. package/dist/esm/packages/draw/src/canvas/shapes/avatar/IdleState.js +0 -59
  28. package/dist/esm/packages/draw/src/canvas/shapes/avatar/PointingState.js +0 -84
  29. package/dist/esm/packages/draw/src/canvas/shapes/avatar/type.js +0 -36
  30. package/dist/esm/packages/draw/src/canvas/shapes/custom/AudioShape.js +0 -152
  31. package/dist/esm/packages/draw/src/canvas/shapes/custom/CardShape.js +0 -115
  32. package/dist/esm/packages/draw/src/canvas/shapes/custom/FileShape.js +0 -128
  33. package/dist/esm/packages/draw/src/canvas/shapes/custom/ImageShape.js +0 -137
  34. package/dist/esm/packages/draw/src/canvas/shapes/custom/VideoShape.js +0 -160
  35. package/dist/esm/packages/draw/src/index.js +0 -3
  36. package/dist/types/canvas/DrawCanvas.d.ts +0 -13
  37. package/dist/types/canvas/DrawContext.d.ts +0 -6
  38. package/dist/types/canvas/shapes/avatar/AvatarShapeTool.d.ts +0 -37
  39. package/dist/types/canvas/shapes/avatar/IdleState.d.ts +0 -8
  40. package/dist/types/canvas/shapes/avatar/PointingState.d.ts +0 -13
  41. package/dist/types/canvas/shapes/avatar/type.d.ts +0 -9
  42. package/dist/types/canvas/shapes/custom/AudioShape.d.ts +0 -18
  43. package/dist/types/canvas/shapes/custom/CardShape.d.ts +0 -23
  44. package/dist/types/canvas/shapes/custom/FileShape.d.ts +0 -18
  45. package/dist/types/canvas/shapes/custom/ImageShape.d.ts +0 -29
  46. package/dist/types/canvas/shapes/custom/VideoShape.d.ts +0 -32
  47. package/src/canvas/DrawCanvas.tsx +0 -291
  48. package/src/canvas/DrawContext.tsx +0 -36
  49. package/src/canvas/shapes/avatar/AvatarShapeTool.tsx +0 -234
  50. package/src/canvas/shapes/avatar/IdleState.ts +0 -61
  51. package/src/canvas/shapes/avatar/PointingState.ts +0 -97
  52. package/src/canvas/shapes/avatar/type.ts +0 -41
  53. package/src/canvas/shapes/custom/AudioShape.tsx +0 -134
  54. package/src/canvas/shapes/custom/CardShape.tsx +0 -106
  55. package/src/canvas/shapes/custom/FileShape.tsx +0 -101
  56. package/src/canvas/shapes/custom/ImageShape.tsx +0 -138
  57. package/src/canvas/shapes/custom/VideoShape.tsx +0 -170
@@ -1,160 +0,0 @@
1
- 'use strict';
2
-
3
- var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
4
- var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
5
- var _createClass = require('@babel/runtime/helpers/createClass');
6
- var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
7
- var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
8
- var _inherits = require('@babel/runtime/helpers/inherits');
9
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
10
- var _regeneratorRuntime = require('@babel/runtime/regenerator');
11
- var utilities = require('@react-fabric/utilities');
12
- var tldraw = require('@tldraw/tldraw');
13
- var domToImage = require('../../../../../../node_modules/dom-to-image/src/dom-to-image.js');
14
- var react = require('react');
15
- var jsxRuntime = require('react/jsx-runtime');
16
-
17
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
18
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
19
- var VideoShapeUtil = /*#__PURE__*/function (_ShapeUtil) {
20
- function VideoShapeUtil() {
21
- _classCallCheck(this, VideoShapeUtil);
22
- return _callSuper(this, VideoShapeUtil, arguments);
23
- }
24
- _inherits(VideoShapeUtil, _ShapeUtil);
25
- return _createClass(VideoShapeUtil, [{
26
- key: "onResize",
27
- value: function onResize(shape, info) {
28
- return {
29
- props: {
30
- w: Math.max(Math.min(info.initialBounds.w * info.scaleX, 1024), 128),
31
- h: Math.max(Math.min(info.initialBounds.h * info.scaleY, 768), 128)
32
- }
33
- };
34
- }
35
- }, {
36
- key: "getDefaultProps",
37
- value: function getDefaultProps() {
38
- return {
39
- src: "",
40
- poster: "",
41
- fileName: "",
42
- fileSize: 0,
43
- w: 400,
44
- h: 300
45
- };
46
- }
47
- }, {
48
- key: "getGeometry",
49
- value: function getGeometry(shape) {
50
- return new tldraw.Rectangle2d({
51
- width: shape.props.w,
52
- height: shape.props.h,
53
- isFilled: true
54
- });
55
- }
56
- }, {
57
- key: "component",
58
- value: function component(shape) {
59
- var _shape$props$fileSize;
60
- var videoRef = react.useRef(null);
61
- react.useEffect(function () {
62
- var _videoRef$current2;
63
- var handler = function handler() {
64
- var _videoRef$current;
65
- (_videoRef$current = videoRef.current) === null || _videoRef$current === void 0 || (_videoRef$current = _videoRef$current.closest(".tl-container")) === null || _videoRef$current === void 0 || _videoRef$current.querySelectorAll("video,audio").forEach(function (el) {
66
- if (el !== videoRef.current) el.pause();
67
- });
68
- };
69
- (_videoRef$current2 = videoRef.current) === null || _videoRef$current2 === void 0 || _videoRef$current2.addEventListener("play", handler);
70
- }, []);
71
- return /*#__PURE__*/jsxRuntime.jsx(tldraw.HTMLContainer, {
72
- className: "relative grid",
73
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
74
- "data-shape-id": shape.id,
75
- className: "bg-zinc-900 relative p-1 flex flex-col overflow-hidden",
76
- children: [/*#__PURE__*/jsxRuntime.jsx("video", {
77
- controls: true,
78
- ref: videoRef,
79
- src: shape.props.src,
80
- poster: shape.props.poster,
81
- className: "object-contain flex-1 pointer-events-auto overflow-hidden"
82
- }), /*#__PURE__*/jsxRuntime.jsx("img", {
83
- src: shape.props.poster,
84
- alt: shape.props.fileName,
85
- className: "object-contain flex-1 pointer-events-auto overflow-hidden hidden"
86
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
87
- className: "bg-zinc-800/80 text-white items-center py-1 px-2 flex gap-1 text-sm",
88
- children: [/*#__PURE__*/jsxRuntime.jsx("svg", {
89
- xmlns: "http://www.w3.org/2000/svg",
90
- viewBox: "0 0 24 24",
91
- width: 16,
92
- height: 16,
93
- children: /*#__PURE__*/jsxRuntime.jsx("path", {
94
- d: "M17,10.5V7A1,1 0 0,0 16,6H4A1,1 0 0,0 3,7V17A1,1 0 0,0 4,18H16A1,1 0 0,0 17,17V13.5L21,17.5V6.5L17,10.5Z"
95
- })
96
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
97
- className: "truncate flex-1",
98
- children: shape.props.fileName
99
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
100
- children: utilities.Format.bytes((_shape$props$fileSize = shape.props.fileSize) !== null && _shape$props$fileSize !== void 0 ? _shape$props$fileSize : 0)
101
- })]
102
- })]
103
- })
104
- });
105
- }
106
- }, {
107
- key: "indicator",
108
- value: function indicator(shape) {
109
- return /*#__PURE__*/jsxRuntime.jsx("rect", {
110
- width: shape.props.w,
111
- height: shape.props.h
112
- });
113
- }
114
- }, {
115
- key: "toSvg",
116
- value: function () {
117
- var _toSvg = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(shape) {
118
- var el;
119
- return _regeneratorRuntime.wrap(function _callee$(_context) {
120
- while (1) switch (_context.prev = _context.next) {
121
- case 0:
122
- el = document.querySelector("div[data-shape-id=\"".concat(shape.id, "\"]"));
123
- if (el) {
124
- _context.next = 3;
125
- break;
126
- }
127
- return _context.abrupt("return", /*#__PURE__*/jsxRuntime.jsx("img", {
128
- src: "",
129
- alt: "svg"
130
- }));
131
- case 3:
132
- el.childNodes.item(0).style.display = "none";
133
- el.childNodes.item(1).style.display = "block";
134
- _context.next = 7;
135
- return domToImage.toPng(el).then(function (dataUrl) {
136
- el.childNodes.item(0).style.display = "block";
137
- el.childNodes.item(1).style.display = "none";
138
- return /*#__PURE__*/jsxRuntime.jsx("img", {
139
- src: dataUrl,
140
- alt: "svg"
141
- });
142
- });
143
- case 7:
144
- return _context.abrupt("return", _context.sent);
145
- case 8:
146
- case "end":
147
- return _context.stop();
148
- }
149
- }, _callee);
150
- }));
151
- function toSvg(_x) {
152
- return _toSvg.apply(this, arguments);
153
- }
154
- return toSvg;
155
- }()
156
- }]);
157
- }(tldraw.ShapeUtil);
158
- _defineProperty(VideoShapeUtil, "type", "video-card");
159
-
160
- exports.VideoShapeUtil = VideoShapeUtil;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- var DrawCanvas = require('./canvas/DrawCanvas.js');
4
-
5
-
6
-
7
- exports.DrawCanvas = DrawCanvas.DrawCanvas;
@@ -1,7 +0,0 @@
1
- 'use client';
2
-
3
- function getDefaultExportFromCjs (x) {
4
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
- }
6
-
7
- export { getDefaultExportFromCjs };
@@ -1,5 +0,0 @@
1
- 'use client';
2
-
3
- var domToImage = {exports: {}};
4
-
5
- export { domToImage as __module };