@kws3/ui 2.0.4 → 2.1.0
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.
- package/CHANGELOG.mdx +13 -1
- package/buttons/ConfirmButton.svelte +7 -6
- package/buttons/DeleteButton.svelte +14 -8
- package/buttons/ProcessButton.svelte +15 -9
- package/buttons/SubmitButton.svelte +11 -8
- package/canvas/Canvas.svelte +263 -0
- package/canvas/ESignature.svelte +101 -0
- package/canvas/PenControls.svelte +234 -0
- package/canvas/PenInput.svelte +152 -0
- package/charts/AreaChart.svelte +2 -2
- package/charts/BarChart.svelte +2 -2
- package/charts/Chart.svelte +16 -12
- package/charts/DonutChart.svelte +2 -2
- package/charts/LineChart.svelte +2 -2
- package/charts/MixedChart.svelte +2 -2
- package/charts/PieChart.svelte +2 -2
- package/charts/RadialChart.svelte +2 -2
- package/charts/utils.d.ts +553 -0
- package/charts/utils.d.ts.map +1 -0
- package/charts/utils.js +27 -4
- package/controls/Checkbox.svelte +7 -6
- package/controls/FileUpload.svelte +5 -4
- package/controls/NumberInput.svelte +5 -5
- package/controls/Radio.svelte +2 -2
- package/controls/RangeSlider.svelte +4 -2
- package/controls/Toggle.svelte +2 -2
- package/controls/ToggleButtons.svelte +1 -1
- package/datagrid/GridView/GridRow.svelte +4 -4
- package/datagrid/GridView/GridView.svelte +7 -4
- package/datagrid/Pagination/Pagination.svelte +12 -11
- package/form/index.d.ts +15 -0
- package/form/index.d.ts.map +1 -0
- package/forms/AutoComplete.svelte +12 -6
- package/forms/Datepicker.svelte +4 -3
- package/forms/PasswordInput.svelte +224 -0
- package/forms/PasswordValidator/validatePassword.d.ts +5 -0
- package/forms/PasswordValidator/validatePassword.d.ts.map +1 -0
- package/forms/SearchInput.svelte +18 -7
- package/forms/Timepicker.svelte +9 -6
- package/forms/actions.d.ts +9 -0
- package/forms/actions.d.ts.map +1 -0
- package/forms/actions.js +6 -0
- package/forms/colorpicker/Colorpicker.d.ts +3 -0
- package/forms/colorpicker/Colorpicker.d.ts.map +1 -0
- package/forms/colorpicker/Colorpicker.js +12 -2
- package/forms/colorpicker/Colorpicker.svelte +10 -3
- package/forms/select/MultiSelect.svelte +14 -9
- package/forms/select/SearchableSelect.svelte +10 -5
- package/helpers/CardModal.svelte +7 -2
- package/helpers/ClipboardCopier.svelte +3 -3
- package/helpers/Dialog/Dialog.svelte +9 -7
- package/helpers/Dialog/index.d.ts +42 -0
- package/helpers/Dialog/index.d.ts.map +1 -0
- package/helpers/Dialog/index.js +58 -19
- package/helpers/Divider.svelte +10 -4
- package/helpers/FloatingUI/Floatie.svelte +1 -1
- package/helpers/FloatingUI/index.d.ts +51 -0
- package/helpers/FloatingUI/index.d.ts.map +1 -0
- package/helpers/FloatingUI/index.js +13 -0
- package/helpers/Icon.svelte +14 -7
- package/helpers/Loader.svelte +5 -5
- package/helpers/Message.svelte +11 -6
- package/helpers/Modal.svelte +7 -2
- package/helpers/Notification.svelte +6 -2
- package/helpers/Popover.svelte +13 -6
- package/helpers/Skeleton.svelte +3 -3
- package/helpers/Timeline/Timeline.svelte +1 -1
- package/helpers/Timeline/TimelineItem.svelte +8 -4
- package/helpers/Tooltip.d.ts +19 -0
- package/helpers/Tooltip.d.ts.map +1 -0
- package/helpers/Tooltip.js +14 -1
- package/index.d.ts +69 -0
- package/index.d.ts.map +1 -0
- package/index.js +7 -0
- package/internal/DrawingPad.d.ts +86 -0
- package/internal/DrawingPad.d.ts.map +1 -0
- package/internal/DrawingPad.js +306 -0
- package/internal/UndoManager.d.ts +17 -0
- package/internal/UndoManager.d.ts.map +1 -0
- package/internal/UndoManager.js +84 -0
- package/internal/fuzzy.d.ts +24 -0
- package/internal/fuzzy.d.ts.map +1 -0
- package/internal/index.d.ts +16 -0
- package/internal/index.d.ts.map +1 -0
- package/internal/index.js +5 -1
- package/internal/scrollIntoActiveElement.d.ts +2 -0
- package/internal/scrollIntoActiveElement.d.ts.map +1 -0
- package/keyboard/index.d.ts +30 -0
- package/keyboard/index.d.ts.map +1 -0
- package/keyboard/index.js +1 -1
- package/package.json +6 -3
- package/resizeObserver/index.d.ts +8 -0
- package/resizeObserver/index.d.ts.map +1 -0
- package/search/index.d.ts +17 -0
- package/search/index.d.ts.map +1 -0
- package/settings.d.ts +22 -0
- package/settings.d.ts.map +1 -0
- package/settings.js +6 -1
- package/styles/Canvas.scss +100 -0
- package/styles/RangeSlider.scss +12 -0
- package/transitions/components/getEasing.d.ts +2 -0
- package/transitions/components/getEasing.d.ts.map +1 -0
- package/tsconfig.json +33 -0
- package/types/index.d.ts +103 -9
- package/types/type-defs/index.d.ts +64 -0
- package/utils/index.d.ts +77 -0
- package/utils/index.d.ts.map +1 -0
- package/types/type-defs/index.ts +0 -14
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import UndoManager from "./UndoManager";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import('@kws3/ui/types').DrawingPadOptions} DrawingPadOptions
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var passiveSupported = false;
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
let options = Object.defineProperty({}, "passive", {
|
|
11
|
+
get: () => (passiveSupported = !0),
|
|
12
|
+
});
|
|
13
|
+
typeof window !== "undefined" &&
|
|
14
|
+
window.addEventListener("test", null, options);
|
|
15
|
+
} catch (err) {
|
|
16
|
+
console.log(err);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var eventOpts = passiveSupported ? { passive: false, capture: false } : false;
|
|
20
|
+
|
|
21
|
+
export class DrawingPad {
|
|
22
|
+
/**
|
|
23
|
+
* DrawingPad constructor
|
|
24
|
+
* @param {{CANVAS:HTMLCanvasElement, fire:(string, object)=>void}} app
|
|
25
|
+
* @param {DrawingPadOptions} opts - Parameter description.
|
|
26
|
+
*/
|
|
27
|
+
constructor(app, opts) {
|
|
28
|
+
this.app = app;
|
|
29
|
+
this.canvas = this.app.CANVAS;
|
|
30
|
+
this.context = this.canvas.getContext("2d");
|
|
31
|
+
this.drawing = false;
|
|
32
|
+
this.currentPos = { x: 0, y: 0 };
|
|
33
|
+
this.lastPos = this.currentPos;
|
|
34
|
+
this.scaleFactor = opts.initialScale;
|
|
35
|
+
this.drawingType = "Pen";
|
|
36
|
+
|
|
37
|
+
this.penColor = opts.penColor;
|
|
38
|
+
this.penWidth = opts.penWidth;
|
|
39
|
+
this.eraserWidth = opts.eraserWidth;
|
|
40
|
+
this.readonly = opts.readonly;
|
|
41
|
+
this.image = opts.image;
|
|
42
|
+
this.tools = opts.tools;
|
|
43
|
+
|
|
44
|
+
if (opts.expanded) {
|
|
45
|
+
this.scaleFactor = opts.expand;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.undoManager = new UndoManager();
|
|
49
|
+
this.prevState = null;
|
|
50
|
+
|
|
51
|
+
this.START = this.start.bind(this);
|
|
52
|
+
this.MOVE = this.move.bind(this);
|
|
53
|
+
this.END = this.end.bind(this);
|
|
54
|
+
this.RENDER = this.render.bind(this);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
prevent(e) {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
e.stopPropagation();
|
|
60
|
+
e.stopImmediatePropagation();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getPosition(e) {
|
|
64
|
+
let x, y;
|
|
65
|
+
let rect = this.canvas.getBoundingClientRect();
|
|
66
|
+
|
|
67
|
+
if (e.type.indexOf("touch") !== -1) {
|
|
68
|
+
// Touch event
|
|
69
|
+
x = e.touches[0].clientX - rect.left;
|
|
70
|
+
y = e.touches[0].clientY - rect.top;
|
|
71
|
+
} else {
|
|
72
|
+
// Mouse event
|
|
73
|
+
x = e.clientX - rect.left;
|
|
74
|
+
y = e.clientY - rect.top;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return { x: x / this.scaleFactor, y: y / this.scaleFactor };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
render() {
|
|
81
|
+
this.draw();
|
|
82
|
+
if (this.drawing) {
|
|
83
|
+
typeof window !== "undefined" &&
|
|
84
|
+
window.setTimeout(() => this.render(), 1000 / 60);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
draw() {
|
|
89
|
+
if (this.drawing) {
|
|
90
|
+
this.context.strokeStyle = this.penColor;
|
|
91
|
+
this.context.lineWidth = this.penWidth;
|
|
92
|
+
if (this.drawingType === "Eraser") {
|
|
93
|
+
this.context.lineWidth = this.eraserWidth;
|
|
94
|
+
}
|
|
95
|
+
this.tools[this.drawingType].draw(this);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
move(e) {
|
|
100
|
+
this.prevent(e);
|
|
101
|
+
this.currentPos = this.getPosition(e);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
end(e) {
|
|
105
|
+
this.prevent(e);
|
|
106
|
+
this.drawing = false;
|
|
107
|
+
|
|
108
|
+
this.addHistory();
|
|
109
|
+
|
|
110
|
+
document.removeEventListener("touchmove", this.MOVE);
|
|
111
|
+
document.removeEventListener("mousemove", this.MOVE);
|
|
112
|
+
document.removeEventListener("touchend", this.END);
|
|
113
|
+
document.removeEventListener("mouseup", this.END);
|
|
114
|
+
|
|
115
|
+
this.fire("change");
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
start(e) {
|
|
119
|
+
this.prevent(e);
|
|
120
|
+
this.drawing = true;
|
|
121
|
+
this.currentPos = this.getPosition(e);
|
|
122
|
+
this.lastPos = this.currentPos;
|
|
123
|
+
|
|
124
|
+
document.addEventListener("touchmove", this.MOVE, eventOpts);
|
|
125
|
+
document.addEventListener("mousemove", this.MOVE, eventOpts);
|
|
126
|
+
document.addEventListener("touchend", this.END, eventOpts);
|
|
127
|
+
document.addEventListener("mouseup", this.END, eventOpts);
|
|
128
|
+
|
|
129
|
+
this.prevState = this.getImageData();
|
|
130
|
+
|
|
131
|
+
this.render();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
addHistory() {
|
|
135
|
+
let nextStack = this.getImageData();
|
|
136
|
+
let prevStack = this.prevState;
|
|
137
|
+
this.undoManager.add({
|
|
138
|
+
undo: () => {
|
|
139
|
+
this.setImageData(prevStack.data);
|
|
140
|
+
},
|
|
141
|
+
redo: () => {
|
|
142
|
+
this.setImageData(nextStack.data);
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
resetHistory() {
|
|
148
|
+
this.undoManager.clear();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
getImageData() {
|
|
152
|
+
return this.context.getImageData(
|
|
153
|
+
0,
|
|
154
|
+
0,
|
|
155
|
+
this.canvas.width,
|
|
156
|
+
this.canvas.height
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
setImageData(data) {
|
|
161
|
+
let imageData = this.getImageData();
|
|
162
|
+
for (let i = 0; i < imageData.data.length; i++) {
|
|
163
|
+
imageData.data[i] = data[i];
|
|
164
|
+
}
|
|
165
|
+
this.context.putImageData(imageData, 0, 0);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
setImage(imgSrc, callBackFn) {
|
|
169
|
+
if (imgSrc) {
|
|
170
|
+
let img = new Image();
|
|
171
|
+
img.src = imgSrc;
|
|
172
|
+
img.onload = () => {
|
|
173
|
+
this.context.drawImage(
|
|
174
|
+
img,
|
|
175
|
+
0,
|
|
176
|
+
0,
|
|
177
|
+
img.width,
|
|
178
|
+
img.height,
|
|
179
|
+
0,
|
|
180
|
+
0,
|
|
181
|
+
this.canvas.width,
|
|
182
|
+
this.canvas.height
|
|
183
|
+
);
|
|
184
|
+
if (callBackFn) {
|
|
185
|
+
callBackFn();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
this.fire("change");
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
fire(type) {
|
|
194
|
+
switch (type) {
|
|
195
|
+
case "change":
|
|
196
|
+
this.app.fire("change", {
|
|
197
|
+
canUndo: this.canUndo(),
|
|
198
|
+
canRedo: this.canRedo(),
|
|
199
|
+
canvasImage: this.canvas.toDataURL(),
|
|
200
|
+
});
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
canUndo() {
|
|
206
|
+
return this.undoManager.hasUndo();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
canRedo() {
|
|
210
|
+
return this.undoManager.hasRedo();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
init() {
|
|
214
|
+
this.is_readonly = this.readonly || false;
|
|
215
|
+
this.imageDataUrl = this.image || "";
|
|
216
|
+
|
|
217
|
+
this.resetHistory();
|
|
218
|
+
|
|
219
|
+
this.setImage(this.imageDataUrl);
|
|
220
|
+
|
|
221
|
+
this.addEvent();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
syncImage(imgData) {
|
|
225
|
+
let curUrl = this.canvas.toDataURL();
|
|
226
|
+
if (curUrl !== imgData) {
|
|
227
|
+
this.prevState = this.getImageData();
|
|
228
|
+
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
229
|
+
this.setImage(imgData, () => {
|
|
230
|
+
this.addHistory();
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
addEvent() {
|
|
236
|
+
if (!this.is_readonly) {
|
|
237
|
+
this.canvas.addEventListener("touchstart", this.START, false);
|
|
238
|
+
this.canvas.addEventListener("mousedown", this.START, false);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
removeEvent() {
|
|
243
|
+
this.canvas.removeEventListener("touchstart", this.START);
|
|
244
|
+
this.canvas.removeEventListener("mousedown", this.START);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
undo() {
|
|
248
|
+
if (this.canUndo()) {
|
|
249
|
+
this.undoManager.undo();
|
|
250
|
+
this.fire("change");
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
redo() {
|
|
255
|
+
if (this.canRedo()) {
|
|
256
|
+
this.undoManager.redo();
|
|
257
|
+
this.fire("change");
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
reset() {
|
|
262
|
+
this.prevState = this.getImageData();
|
|
263
|
+
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
264
|
+
this.addHistory();
|
|
265
|
+
this.fire("change");
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
setScaleFactor(f) {
|
|
269
|
+
this.scaleFactor = f;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
setTool(toolType) {
|
|
273
|
+
this.drawingType = toolType;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
setColor(color) {
|
|
277
|
+
this.penColor = color;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export let Pen = {
|
|
282
|
+
name: "Pen",
|
|
283
|
+
icon: "pencil",
|
|
284
|
+
draw: (instance) => {
|
|
285
|
+
instance.context.beginPath();
|
|
286
|
+
instance.context.moveTo(instance.lastPos.x, instance.lastPos.y);
|
|
287
|
+
instance.context.lineCap = "round";
|
|
288
|
+
instance.context.lineTo(instance.currentPos.x, instance.currentPos.y);
|
|
289
|
+
instance.context.stroke();
|
|
290
|
+
instance.context.globalCompositeOperation = "source-over";
|
|
291
|
+
instance.lastPos = instance.currentPos;
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
export let Eraser = {
|
|
296
|
+
name: "Eraser",
|
|
297
|
+
icon: "eraser",
|
|
298
|
+
draw: (instance) => {
|
|
299
|
+
instance.context.beginPath();
|
|
300
|
+
instance.context.moveTo(instance.lastPos.x, instance.lastPos.y);
|
|
301
|
+
instance.context.lineTo(instance.currentPos.x, instance.currentPos.y);
|
|
302
|
+
instance.context.stroke();
|
|
303
|
+
instance.context.globalCompositeOperation = "destination-out";
|
|
304
|
+
instance.lastPos = instance.currentPos;
|
|
305
|
+
},
|
|
306
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default UndoManager;
|
|
2
|
+
declare class UndoManager {
|
|
3
|
+
commands: any[];
|
|
4
|
+
index: number;
|
|
5
|
+
isExecuting: boolean;
|
|
6
|
+
callback: any;
|
|
7
|
+
execute(command: any, action: any): UndoManager;
|
|
8
|
+
add(command: any): UndoManager;
|
|
9
|
+
setCallback(callbackFunc: any): void;
|
|
10
|
+
undo(): UndoManager;
|
|
11
|
+
redo(): UndoManager;
|
|
12
|
+
clear(): void;
|
|
13
|
+
hasUndo(): boolean;
|
|
14
|
+
hasRedo(): boolean;
|
|
15
|
+
getCommands(): any[];
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=UndoManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UndoManager.d.ts","sourceRoot":"","sources":["UndoManager.js"],"names":[],"mappings":";AAAA;IAEI,gBAAkB;IAClB,cAAe;IACf,qBAAwB;IACxB,cAAoB;IAGtB,gDAQC;IAED,+BAcC;IAED,qCAEC;IAED,oBAWC;IAED,oBAWC;IAED,cAOC;IACD,mBAEC;IACD,mBAEC;IACD,qBAEC;CACF"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
class UndoManager {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.commands = [];
|
|
4
|
+
this.index = -1;
|
|
5
|
+
this.isExecuting = false;
|
|
6
|
+
this.callback = null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
execute(command, action) {
|
|
10
|
+
if (!command || typeof command[action] !== "function") {
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
this.isExecuting = true;
|
|
14
|
+
command[action]();
|
|
15
|
+
this.isExecuting = false;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
add(command) {
|
|
20
|
+
if (this.isExecuting) {
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// If we are here after having called undo, invalidate items higher on the stack.
|
|
25
|
+
this.commands.splice(this.index + 1, this.commands.length - this.index);
|
|
26
|
+
this.commands.push(command);
|
|
27
|
+
// Set the current index to the end.
|
|
28
|
+
this.index = this.commands.length - 1;
|
|
29
|
+
if (this.callback) {
|
|
30
|
+
this.callback();
|
|
31
|
+
}
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
setCallback(callbackFunc) {
|
|
36
|
+
this.callback = callbackFunc;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
undo() {
|
|
40
|
+
const command = this.commands[this.index];
|
|
41
|
+
if (!command) {
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
this.execute(command, "undo");
|
|
45
|
+
this.index -= 1;
|
|
46
|
+
if (this.callback) {
|
|
47
|
+
this.callback();
|
|
48
|
+
}
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
redo() {
|
|
53
|
+
const command = this.commands[this.index + 1];
|
|
54
|
+
if (!command) {
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
this.execute(command, "redo");
|
|
58
|
+
this.index += 1;
|
|
59
|
+
if (this.callback) {
|
|
60
|
+
this.callback();
|
|
61
|
+
}
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
clear() {
|
|
66
|
+
const prev_size = this.commands.length;
|
|
67
|
+
this.commands = [];
|
|
68
|
+
this.index = -1;
|
|
69
|
+
if (this.callback && prev_size > 0) {
|
|
70
|
+
this.callback();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
hasUndo() {
|
|
74
|
+
return this.index !== -1;
|
|
75
|
+
}
|
|
76
|
+
hasRedo() {
|
|
77
|
+
return this.index < this.commands.length - 1;
|
|
78
|
+
}
|
|
79
|
+
getCommands() {
|
|
80
|
+
return this.commands;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default UndoManager;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fuzzy.js v0.1.0
|
|
3
|
+
* (c) 2016 Ben Ripkens
|
|
4
|
+
* @license: MIT
|
|
5
|
+
* @params
|
|
6
|
+
* term : haystack
|
|
7
|
+
* query : needle
|
|
8
|
+
* opts: {
|
|
9
|
+
* analyzeSubTerms,
|
|
10
|
+
* analyzeSubTermDepth
|
|
11
|
+
* highlighting
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* Adapted from fuzzy.js for @kws3/ui to work with vite prebundling
|
|
17
|
+
*/
|
|
18
|
+
export function fuzzy(term: any, query: any, opts?: {}): {
|
|
19
|
+
score: number;
|
|
20
|
+
term: any;
|
|
21
|
+
query: any;
|
|
22
|
+
highlightedTerm: string;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=fuzzy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fuzzy.d.ts","sourceRoot":"","sources":["fuzzy.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH;;;GAGG;AAsBH;;;;;EA+BC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect whether a user has pressed Enter.
|
|
3
|
+
* @param {object} [e=[]] - Event object., Default: `[]`
|
|
4
|
+
*/
|
|
5
|
+
export function isEnterKey(e?: object): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Detect whether a user has pressed Escape key.
|
|
8
|
+
* @param {object} [e=[]] - Event object., Default: `[]`
|
|
9
|
+
*/
|
|
10
|
+
export function isEscKey(e?: object): boolean;
|
|
11
|
+
export { scrollIntoActiveElement } from "./scrollIntoActiveElement";
|
|
12
|
+
export { fuzzy } from "./fuzzy.js";
|
|
13
|
+
export { default as UndoManager } from "./UndoManager";
|
|
14
|
+
export const IS_MAC: boolean;
|
|
15
|
+
export { DrawingPad, Pen, Eraser } from "./DrawingPad";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH,+BAFW,MAAM,WAIhB;AAED;;;GAGG;AACH,6BAFW,MAAM,WAIhB;;;;AAED,6BAWY"}
|
package/internal/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { scrollIntoActiveElement } from "./scrollIntoActiveElement";
|
|
2
2
|
export { fuzzy } from "./fuzzy.js";
|
|
3
|
+
export { default as UndoManager } from "./UndoManager";
|
|
4
|
+
export { DrawingPad, Pen, Eraser } from "./DrawingPad";
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Detect whether a user has pressed Enter.
|
|
@@ -21,8 +23,10 @@ export const IS_MAC =
|
|
|
21
23
|
typeof window !== "undefined"
|
|
22
24
|
? "navigator" in window
|
|
23
25
|
? /mac/i.test(
|
|
26
|
+
//@ts-ignore
|
|
24
27
|
window.navigator.userAgentData
|
|
25
|
-
?
|
|
28
|
+
? //@ts-ignore
|
|
29
|
+
window.navigator.userAgentData.platform
|
|
26
30
|
: window.navigator.platform
|
|
27
31
|
)
|
|
28
32
|
: false
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollIntoActiveElement.d.ts","sourceRoot":"","sources":["scrollIntoActiveElement.js"],"names":[],"mappings":"AAAA,sFAqBC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {string | number} definition - can be a string like 'Enter', 'Tab' or number as keyCode, also allow combination key like 'ctrl+d', 'ctrl+alt+x'
|
|
3
|
+
* @param {boolean} CommandKey - if true, in mac 'ctrl' key binding will be shift on 'command' key.
|
|
4
|
+
* @returns {import("svelte/action").Action} .
|
|
5
|
+
*/
|
|
6
|
+
export function makeKeyDefinition(definition: string | number, CommandKey?: boolean): import("svelte/action").Action;
|
|
7
|
+
export let enter: import("svelte/action").Action<HTMLElement, any, any>;
|
|
8
|
+
export let tab: import("svelte/action").Action<HTMLElement, any, any>;
|
|
9
|
+
export let escape: import("svelte/action").Action<HTMLElement, any, any>;
|
|
10
|
+
export let space: import("svelte/action").Action<HTMLElement, any, any>;
|
|
11
|
+
export let leftarrow: import("svelte/action").Action<HTMLElement, any, any>;
|
|
12
|
+
export let rightarrow: import("svelte/action").Action<HTMLElement, any, any>;
|
|
13
|
+
export let downarrow: import("svelte/action").Action<HTMLElement, any, any>;
|
|
14
|
+
export let uparrow: import("svelte/action").Action<HTMLElement, any, any>;
|
|
15
|
+
export let backspace: import("svelte/action").Action<HTMLElement, any, any>;
|
|
16
|
+
export let del: import("svelte/action").Action<HTMLElement, any, any>;
|
|
17
|
+
declare namespace _default {
|
|
18
|
+
export { enter };
|
|
19
|
+
export { tab };
|
|
20
|
+
export { escape };
|
|
21
|
+
export { space };
|
|
22
|
+
export { leftarrow };
|
|
23
|
+
export { rightarrow };
|
|
24
|
+
export { downarrow };
|
|
25
|
+
export { uparrow };
|
|
26
|
+
export { backspace };
|
|
27
|
+
export { del };
|
|
28
|
+
}
|
|
29
|
+
export default _default;
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAQA;;;;GAIG;AAEH,8CALW,MAAM,GAAG,MAAM,eACf,OAAO,GACL,OAAO,eAAe,EAAE,MAAM,CA0D1C;AAED,wEAA8C;AAC9C,sEAA0C;AAC1C,yEAAgD;AAChD,wEAA0C;AAC1C,4EAAsD;AACtD,6EAAwD;AACxD,4EAAsD;AACtD,0EAAkD;AAClD,4EAAsD;AACtD,sEAA6C"}
|
package/keyboard/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const ctrlKeys = {
|
|
|
9
9
|
/**
|
|
10
10
|
* @param {string | number} definition - can be a string like 'Enter', 'Tab' or number as keyCode, also allow combination key like 'ctrl+d', 'ctrl+alt+x'
|
|
11
11
|
* @param {boolean} CommandKey - if true, in mac 'ctrl' key binding will be shift on 'command' key.
|
|
12
|
-
* @returns {
|
|
12
|
+
* @returns {import("svelte/action").Action} .
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
export function makeKeyDefinition(definition, CommandKey = false) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kws3/ui",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "UI components for use with Svelte v3 applications.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"svelte": "index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
|
-
"types": "
|
|
27
|
+
"types": "./index.d.ts",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"apexcharts": "3.33.2",
|
|
30
30
|
"flatpickr": "^4.5.2",
|
|
@@ -32,5 +32,8 @@
|
|
|
32
32
|
"text-mask-core": "^5.1.2",
|
|
33
33
|
"tippy.js": "^6.3.1"
|
|
34
34
|
},
|
|
35
|
-
"
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"typescript": "^5.0.4"
|
|
37
|
+
},
|
|
38
|
+
"gitHead": "1df9160ff743e55eb266d3e0b4a8c23287b7a23d"
|
|
36
39
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,qCAHW,WAAW,OAmBrB;AA1BD,wCAGY"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('@kws3/ui/types').SearchOptions} SearchOptions - contains search options and fuzzy lib options
|
|
3
|
+
* @typedef {import('@kws3/ui/types').SearchHelper} SearchHelper - returned search helper function which take unction take params `needle` and `haystack`.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @param {SearchOptions} opts
|
|
7
|
+
*/
|
|
8
|
+
export function makeSearchEngine(opts: SearchOptions): (needle: string, haystack: any[]) => any[];
|
|
9
|
+
/**
|
|
10
|
+
* - contains search options and fuzzy lib options
|
|
11
|
+
*/
|
|
12
|
+
export type SearchOptions = import('@kws3/ui/types').SearchOptions;
|
|
13
|
+
/**
|
|
14
|
+
* - returned search helper function which take unction take params `needle` and `haystack`.
|
|
15
|
+
*/
|
|
16
|
+
export type SearchHelper = import('@kws3/ui/types').SearchHelper;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAEA;;;GAGG;AAEH;;GAEG;AACH,uCAFW,aAAa,YAQX,MAAM,4BAmClB;;;;4BAhDY,OAAO,gBAAgB,EAAE,aAAa;;;;2BACtC,OAAO,gBAAgB,EAAE,YAAY"}
|
package/settings.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* - `defaultIconFamily`: `"fa"` - default icon family
|
|
3
|
+
* - `defaultToastPlacement`: `"bottom"` - default placement of toast notifications
|
|
4
|
+
* - `defaultSnackbarPlacement`: `"bottom-right"` - default placement of snackbar notifications
|
|
5
|
+
* - `defaultNotificationPlacement`: `"top-right"` - default placement of floating notifications
|
|
6
|
+
* - `hasTransitions`: `true` - Transitions are applied
|
|
7
|
+
* - `defaultChartColors`: `["#284BED", "#ED6134", "#1DAFEC", "#EDB405", "#11EDB7", "#77ED11"]` - default colors for charts
|
|
8
|
+
* @param {SettingOptions} obj
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export function applySettings(obj: SettingOptions): void;
|
|
12
|
+
export type SettingOptions = import('@kws3/ui/types').SettingOptions;
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {import('@kws3/ui/types').SettingOptions} SettingOptions
|
|
15
|
+
*/
|
|
16
|
+
export const defaultIconFamily: import("svelte/store").Writable<string>;
|
|
17
|
+
export const defaultToastPlacement: import("svelte/store").Writable<string>;
|
|
18
|
+
export const defaultSnackbarPlacement: import("svelte/store").Writable<string>;
|
|
19
|
+
export const defaultNotificationPlacement: import("svelte/store").Writable<string>;
|
|
20
|
+
export const hasTransitions: import("svelte/store").Writable<boolean>;
|
|
21
|
+
export const defaultChartColors: import("svelte/store").Writable<string[]>;
|
|
22
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["settings.js"],"names":[],"mappings":"AAsCA;;;;;;;;;GASG;AAEH,mCAJW,cAAc,QAQxB;6BAlDY,OAAO,gBAAgB,EAAE,cAAc;AADpD;;GAEG;AAEH,wEAAyC;AACzC,4EAAiD;AACjD,+EAA0D;AAC1D,mFAA2D;AAC3D,sEAAsC;AACtC,2EAOG"}
|
package/settings.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { writable } from "svelte/store";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import('@kws3/ui/types').SettingOptions} SettingOptions
|
|
5
|
+
*/
|
|
6
|
+
|
|
3
7
|
const defaultIconFamily = writable("fa");
|
|
4
8
|
const defaultToastPlacement = writable("bottom");
|
|
5
9
|
const defaultSnackbarPlacement = writable("bottom-right");
|
|
@@ -39,9 +43,10 @@ export {
|
|
|
39
43
|
* - `defaultNotificationPlacement`: `"top-right"` - default placement of floating notifications
|
|
40
44
|
* - `hasTransitions`: `true` - Transitions are applied
|
|
41
45
|
* - `defaultChartColors`: `["#284BED", "#ED6134", "#1DAFEC", "#EDB405", "#11EDB7", "#77ED11"]` - default colors for charts
|
|
46
|
+
* @param {SettingOptions} obj
|
|
42
47
|
*
|
|
43
|
-
* @param {*} obj containing all settings
|
|
44
48
|
*/
|
|
49
|
+
|
|
45
50
|
export function applySettings(obj) {
|
|
46
51
|
Object.entries(obj).forEach(([k, v]) => {
|
|
47
52
|
SETTINGS[k] && SETTINGS[k].set(v);
|