@weing-dev/ui-kit-primitive 0.0.2 → 0.0.4

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 (81) hide show
  1. package/dist/components/Editor/Editor.context.d.ts +21 -3
  2. package/dist/components/Editor/Editor.d.ts +8 -6
  3. package/dist/components/Editor/constants/editor.constants.d.ts +24 -0
  4. package/dist/components/Editor/modules/ImageResize.d.ts +19 -0
  5. package/dist/components/Editor/modules/MediaResize.d.ts +19 -0
  6. package/dist/components/Editor/modules/index.d.ts +7 -0
  7. package/dist/components/Icons/AddOutlined.d.ts +3 -0
  8. package/dist/components/Icons/ArrowDown.d.ts +3 -0
  9. package/dist/components/Icons/ArrowDropDown.d.ts +3 -0
  10. package/dist/components/Icons/ArrowUp.d.ts +3 -0
  11. package/dist/components/Icons/ArticleOutlined.d.ts +3 -0
  12. package/dist/components/Icons/CalendarMonth.d.ts +3 -0
  13. package/dist/components/Icons/CalendarToday.d.ts +3 -0
  14. package/dist/components/Icons/Category.d.ts +3 -0
  15. package/dist/components/Icons/CategoryOutlined.d.ts +3 -0
  16. package/dist/components/Icons/Celebration.d.ts +3 -0
  17. package/dist/components/Icons/CheckBadge.d.ts +3 -0
  18. package/dist/components/Icons/CheckList.d.ts +3 -0
  19. package/dist/components/Icons/ChevronLeft.d.ts +3 -0
  20. package/dist/components/Icons/ChromeReaderMode.d.ts +3 -0
  21. package/dist/components/Icons/CreditCard.d.ts +3 -0
  22. package/dist/components/Icons/CropOriginal.d.ts +3 -0
  23. package/dist/components/Icons/DoubleArrowDown.d.ts +3 -0
  24. package/dist/components/Icons/DoubleArrowUp.d.ts +3 -0
  25. package/dist/components/Icons/EditNoteOutlined.d.ts +3 -0
  26. package/dist/components/Icons/HandshakeRound.d.ts +3 -0
  27. package/dist/components/Icons/Home.d.ts +3 -0
  28. package/dist/components/Icons/ImportExport.d.ts +3 -0
  29. package/dist/components/Icons/InfoFilled.d.ts +3 -0
  30. package/dist/components/Icons/LocalActivityOutlined.d.ts +3 -0
  31. package/dist/components/Icons/LocalHospital.d.ts +3 -0
  32. package/dist/components/Icons/MinusOutlined.d.ts +3 -0
  33. package/dist/components/Icons/Notification.d.ts +3 -0
  34. package/dist/components/Icons/Payment.d.ts +3 -0
  35. package/dist/components/Icons/PersonAddAlt.d.ts +3 -0
  36. package/dist/components/Icons/PersonFilled.d.ts +3 -0
  37. package/dist/components/Icons/PersonOutline.d.ts +3 -0
  38. package/dist/components/Icons/Search2.d.ts +3 -0
  39. package/dist/components/Icons/SettingFilled.d.ts +3 -0
  40. package/dist/components/Icons/TrashOutlined.d.ts +3 -0
  41. package/dist/components/Icons/index.d.ts +34 -0
  42. package/dist/index-BL3MWQXq.js +255 -0
  43. package/dist/index.css +3 -3
  44. package/dist/index.d.ts +2 -2
  45. package/dist/index.js +15885 -50093
  46. package/dist/index.umd.cjs +22 -156
  47. package/dist/static/icon/ArrowDown.svg +5 -0
  48. package/dist/static/icon/ArrowUp.svg +5 -0
  49. package/dist/static/icon/CalendarMonth.svg +5 -0
  50. package/dist/static/icon/CalendarToday.svg +5 -0
  51. package/dist/static/icon/Category.svg +9 -0
  52. package/dist/static/icon/Celebration.svg +11 -0
  53. package/dist/static/icon/CheckList.svg +5 -0
  54. package/dist/static/icon/ChromeReaderMode.svg +5 -0
  55. package/dist/static/icon/CreditCard.svg +5 -0
  56. package/dist/static/icon/CropOriginal.svg +5 -0
  57. package/dist/static/icon/Home.svg +5 -0
  58. package/dist/static/icon/Notification.svg +3 -0
  59. package/dist/static/icon/Payment.svg +5 -0
  60. package/dist/static/icon/PersonAddAlt.svg +5 -0
  61. package/dist/static/icon/PersonOutline.svg +5 -0
  62. package/dist/static/icon/addOutlined.svg +3 -0
  63. package/dist/static/icon/arrow_drop_down.svg +5 -0
  64. package/dist/static/icon/articleOutlined.svg +4 -0
  65. package/dist/static/icon/categoryOutlined.svg +3 -0
  66. package/dist/static/icon/checkBadge.svg +3 -0
  67. package/dist/static/icon/chevron_left.svg +3 -0
  68. package/dist/static/icon/doubleArrowDown.svg +4 -0
  69. package/dist/static/icon/doubleArrowUp.svg +4 -0
  70. package/dist/static/icon/edit_note_outlined.svg +3 -0
  71. package/dist/static/icon/handshake_Round.svg +3 -0
  72. package/dist/static/icon/import_export.svg +5 -0
  73. package/dist/static/icon/infoFilled.svg +3 -0
  74. package/dist/static/icon/localActivityOutlined.svg +3 -0
  75. package/dist/static/icon/localHospital.svg +3 -0
  76. package/dist/static/icon/minusOutlined.svg +3 -0
  77. package/dist/static/icon/personFilled.svg +3 -0
  78. package/dist/static/icon/search2.svg +3 -0
  79. package/dist/static/icon/settingFilled.svg +3 -0
  80. package/dist/static/icon/trashOutlined.svg +3 -0
  81. package/package.json +47 -24
@@ -0,0 +1,255 @@
1
+ var h = Object.defineProperty;
2
+ var l = (r, e, t) => e in r ? h(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var n = (r, e, t) => l(r, typeof e != "symbol" ? e + "" : e, t);
4
+ import a from "quill";
5
+ const u = 50, c = 50, m = 1e3, f = 1e3;
6
+ class p {
7
+ constructor(e) {
8
+ n(this, "quill");
9
+ n(this, "img", null);
10
+ n(this, "box", null);
11
+ n(this, "startPos", { x: 0, y: 0 });
12
+ n(this, "startSize", {
13
+ width: 0,
14
+ height: 0
15
+ });
16
+ n(this, "currentHandle", null);
17
+ n(this, "aspectRatio", 1);
18
+ n(this, "onClick", (e) => {
19
+ if (typeof document > "u") return;
20
+ const t = e.target;
21
+ t && t.tagName === "IMG" && (e.stopPropagation(), this.img = t, this.showResizeBox());
22
+ });
23
+ n(this, "onDocClick", (e) => {
24
+ typeof document > "u" || this.box && !this.box.contains(e.target) && this.removeBox();
25
+ });
26
+ n(this, "initResize", (e) => {
27
+ if (typeof document > "u" || (e.preventDefault(), !this.img || !this.box)) return;
28
+ const t = e.target;
29
+ this.currentHandle = t.dataset.corner || "se", this.startPos = { x: e.clientX, y: e.clientY }, this.startSize = {
30
+ width: this.img.width,
31
+ height: this.img.height
32
+ }, document.addEventListener("mousemove", this.performResize), document.addEventListener("mouseup", this.stopResize);
33
+ });
34
+ n(this, "performResize", (e) => {
35
+ if (typeof document > "u" || !this.img) return;
36
+ const t = e.clientX - this.startPos.x, s = e.clientY - this.startPos.y;
37
+ let i = this.startSize.width, o = this.startSize.height;
38
+ const d = e.shiftKey;
39
+ switch (this.currentHandle) {
40
+ case "se":
41
+ i += t, o += s;
42
+ break;
43
+ case "sw":
44
+ i -= t, o += s;
45
+ break;
46
+ case "ne":
47
+ i += t, o -= s;
48
+ break;
49
+ case "nw":
50
+ i -= t, o -= s;
51
+ break;
52
+ }
53
+ d && (Math.abs(t) > Math.abs(s) ? o = i / this.aspectRatio : i = o * this.aspectRatio), i = Math.max(u, Math.min(m, i)), o = Math.max(c, Math.min(f, o)), this.img.style.width = `${i}px`, this.img.style.height = `${o}px`, this.showResizeBox();
54
+ });
55
+ n(this, "stopResize", () => {
56
+ typeof document > "u" || (document.removeEventListener("mousemove", this.performResize), document.removeEventListener("mouseup", this.stopResize), this.saveToDelta());
57
+ });
58
+ n(this, "removeBox", () => {
59
+ typeof document > "u" || this.box && (this.box.remove(), this.box = null);
60
+ });
61
+ this.quill = e, typeof document < "u" && (this.quill.root.addEventListener("click", this.onClick), document.addEventListener("click", this.onDocClick), this.quill.root.addEventListener("scroll", this.removeBox));
62
+ }
63
+ showResizeBox() {
64
+ if (typeof document > "u" || typeof window > "u" || (this.removeBox(), !this.img)) return;
65
+ const e = this.img.getBoundingClientRect();
66
+ this.aspectRatio = this.img.naturalWidth / this.img.naturalHeight;
67
+ const t = document.createElement("div");
68
+ t.style.position = "absolute", t.style.left = `${e.left + window.scrollX}px`, t.style.top = `${e.top + window.scrollY}px`, t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.style.border = "2px solid #09f", t.style.zIndex = "1000", t.style.boxSizing = "border-box", ["nw", "ne", "sw", "se"].forEach((s) => {
69
+ const i = document.createElement("div");
70
+ i.dataset.corner = s, Object.assign(i.style, {
71
+ position: "absolute",
72
+ width: "10px",
73
+ height: "10px",
74
+ background: "#09f",
75
+ borderRadius: "50%",
76
+ cursor: `${s}-resize`
77
+ }), s.includes("n") && (i.style.top = "-5px"), s.includes("s") && (i.style.bottom = "-5px"), s.includes("w") && (i.style.left = "-5px"), s.includes("e") && (i.style.right = "-5px"), i.addEventListener("mousedown", this.initResize), t.appendChild(i);
78
+ }), document.body.appendChild(t), this.box = t;
79
+ }
80
+ saveToDelta() {
81
+ if (typeof document > "u" || !this.img) return;
82
+ const e = a.find(this.img);
83
+ if (e && e.parent && e.domNode) {
84
+ if (e === this.quill) {
85
+ console.error(
86
+ "Quill.find returned the Quill instance itself, not a Blot for image",
87
+ this.img
88
+ );
89
+ return;
90
+ }
91
+ try {
92
+ const t = this.quill.getIndex(e);
93
+ this.quill.deleteText(t, 1), this.quill.insertEmbed(
94
+ t,
95
+ "image",
96
+ this.img.getAttribute("src") || "",
97
+ "user"
98
+ );
99
+ const s = {
100
+ width: this.img.style.width,
101
+ height: this.img.style.height
102
+ };
103
+ this.quill.formatText(t, 1, s, "user");
104
+ } catch (t) {
105
+ console.error("Error processing blot in saveToDelta:", t, e);
106
+ }
107
+ } else
108
+ console.error(
109
+ "Could not find a valid blot for image (missing parent or domNode)",
110
+ this.img,
111
+ e
112
+ );
113
+ }
114
+ }
115
+ const g = 50, x = 50, b = 1200, y = 1200;
116
+ class w {
117
+ constructor(e) {
118
+ n(this, "quill");
119
+ n(this, "media", null);
120
+ n(this, "box", null);
121
+ n(this, "startPos", { x: 0, y: 0 });
122
+ n(this, "startSize", { width: 0, height: 0 });
123
+ n(this, "currentHandle", null);
124
+ n(this, "aspectRatio", 1);
125
+ n(this, "initResize", (e) => {
126
+ if (typeof document > "u" || (e.preventDefault(), !this.media || !this.box)) return;
127
+ const t = e.target;
128
+ this.currentHandle = t.dataset.corner || "se", this.startPos = { x: e.clientX, y: e.clientY }, this.startSize = {
129
+ width: this.media.clientWidth,
130
+ height: this.media.clientHeight
131
+ }, document.addEventListener("mousemove", this.performResize), document.addEventListener("mouseup", this.stopResize);
132
+ });
133
+ n(this, "performResize", (e) => {
134
+ if (typeof document > "u" || !this.media) return;
135
+ const t = e.clientX - this.startPos.x, s = e.clientY - this.startPos.y;
136
+ let i = this.startSize.width, o = this.startSize.height;
137
+ const d = e.shiftKey;
138
+ switch (this.currentHandle) {
139
+ case "se":
140
+ i += t, o += s;
141
+ break;
142
+ case "sw":
143
+ i -= t, o += s;
144
+ break;
145
+ case "ne":
146
+ i += t, o -= s;
147
+ break;
148
+ case "nw":
149
+ i -= t, o -= s;
150
+ break;
151
+ }
152
+ d && (Math.abs(t) > Math.abs(s) ? o = i / this.aspectRatio : i = o * this.aspectRatio), i = Math.max(g, Math.min(b, i)), o = Math.max(x, Math.min(y, o)), this.media.style.width = `${i}px`, this.media.style.height = `${o}px`, this.showResizeBox();
153
+ });
154
+ n(this, "stopResize", () => {
155
+ typeof document > "u" || (document.removeEventListener("mousemove", this.performResize), document.removeEventListener("mouseup", this.stopResize), this.saveToDelta());
156
+ });
157
+ n(this, "removeBox", () => {
158
+ typeof document > "u" || this.box && (this.box.remove(), this.box = null);
159
+ });
160
+ this.quill = e, typeof document < "u" && this.observeHover();
161
+ }
162
+ getMedia(e) {
163
+ return ["IMG", "VIDEO", "IFRAME"].includes(e.tagName) ? e : null;
164
+ }
165
+ observeHover() {
166
+ const e = this.quill.root;
167
+ e.addEventListener("mouseover", (t) => {
168
+ if (typeof document > "u") return;
169
+ const s = t.target, i = this.getMedia(s);
170
+ i && (this.media = i, this.showResizeBox());
171
+ }), e.addEventListener("mouseout", (t) => {
172
+ this.box && t.relatedTarget && this.box.contains(t.relatedTarget) || this.removeBox();
173
+ });
174
+ }
175
+ showResizeBox() {
176
+ if (this.removeBox(), !this.media || typeof document > "u" || typeof window > "u")
177
+ return;
178
+ const e = this.media.getBoundingClientRect();
179
+ this.aspectRatio = e.width / e.height;
180
+ const t = document.createElement("div");
181
+ Object.assign(t.style, {
182
+ position: "absolute",
183
+ left: `${e.left + window.scrollX}px`,
184
+ top: `${e.top + window.scrollY}px`,
185
+ width: `${e.width}px`,
186
+ height: `${e.height}px`,
187
+ border: "2px solid #09f",
188
+ zIndex: "1000",
189
+ boxSizing: "border-box",
190
+ pointerEvents: "none"
191
+ });
192
+ const s = document.createElement("div");
193
+ Object.assign(s.style, {
194
+ position: "absolute",
195
+ top: "0",
196
+ left: "0",
197
+ width: "100%",
198
+ height: "100%",
199
+ background: "transparent",
200
+ zIndex: "1001",
201
+ pointerEvents: "none"
202
+ }), s.addEventListener("mousedown", (i) => i.stopPropagation()), t.appendChild(s), ["nw", "ne", "sw", "se"].forEach((i) => {
203
+ const o = document.createElement("div");
204
+ o.dataset.corner = i, Object.assign(o.style, {
205
+ position: "absolute",
206
+ width: "12px",
207
+ height: "12px",
208
+ background: "#09f",
209
+ borderRadius: "50%",
210
+ cursor: `${i}-resize`,
211
+ zIndex: "1002",
212
+ pointerEvents: "auto"
213
+ }), i.includes("n") && (o.style.top = "-6px"), i.includes("s") && (o.style.bottom = "-6px"), i.includes("w") && (o.style.left = "-6px"), i.includes("e") && (o.style.right = "-6px"), o.addEventListener("mousedown", this.initResize), t.appendChild(o);
214
+ }), document.body.appendChild(t), this.box = t;
215
+ }
216
+ saveToDelta() {
217
+ if (typeof document > "u" || !this.media) return;
218
+ const e = a.find(this.media);
219
+ if (e && e.parent && e.domNode) {
220
+ if (e === this.quill) {
221
+ console.error(
222
+ "Quill.find returned the Quill instance itself, not a Blot for media",
223
+ this.media
224
+ );
225
+ return;
226
+ }
227
+ try {
228
+ const t = this.quill.getIndex(e), s = this.media.getAttribute("src") || "", i = this.media.tagName.toLowerCase();
229
+ this.quill.deleteText(t, 1), i === "img" ? this.quill.insertEmbed(t, "image", s, "user") : (i === "video" || i === "iframe") && this.quill.insertEmbed(t, "video", s, "user"), this.quill.formatText(
230
+ t,
231
+ 1,
232
+ {
233
+ width: this.media.style.width,
234
+ height: this.media.style.height
235
+ },
236
+ "user"
237
+ );
238
+ } catch (t) {
239
+ console.error("Error processing blot in saveToDelta:", t, e);
240
+ }
241
+ } else
242
+ console.error(
243
+ "Could not find a valid blot for media (missing parent or domNode)",
244
+ this.media,
245
+ e
246
+ );
247
+ }
248
+ }
249
+ const R = {
250
+ ImageResize: p,
251
+ MediaResize: w
252
+ };
253
+ export {
254
+ R as default
255
+ };