@kws3/ui 2.0.5 → 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 +7 -0
- 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 +3 -3
- 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 +5 -5
- 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 +10 -5
- 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 +8 -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/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,234 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@param {any} [EXPANDED_BUTTON=undefined] - EXPANDED_BUTTON property, Default: `undefined`
|
|
6
|
+
@param {string} [canvas_controls_styles=""] - Inline CSS for the control, Default: `""`
|
|
7
|
+
@param {boolean} [disabled=false] - Determines whether canvas is disabled or not, Default: `false`
|
|
8
|
+
@param {boolean} [readonly=false] - Determines whether canvas is readonly or not, Default: `false`
|
|
9
|
+
@param {object} [tools={}] - List of tools available, Default: `{}`
|
|
10
|
+
@param {array} [actions=[]] - List of actions toolbar, Default: `[]`
|
|
11
|
+
@param {string} [active_tool="Pen"] - Determines which tool is select, Default: `"Pen"`
|
|
12
|
+
@param {Extract<Positions, 'bottom'|'top'>} [toolbar_placement=bottom] - Determines where the action tools are placed, Default: `bottom`
|
|
13
|
+
@param {string} [default_color=""] - colorpicker's default color, Default: `""`
|
|
14
|
+
@param {Extract<Positions, 'start'|'center'|'end'>} [control_position=center] - Default position of controls, Default: `center`
|
|
15
|
+
@param {boolean} [can_undo=false] - Whether allowed to undo drawing changes or not, Default: `false`
|
|
16
|
+
@param {boolean} [can_redo=false] - Whether allowed to redo drawing changes or not, Default: `false`
|
|
17
|
+
@param {boolean} [show_tools=false] - Whether allowed to show tools or not, Default: `false`
|
|
18
|
+
|
|
19
|
+
### Events
|
|
20
|
+
- `toggleExpand`
|
|
21
|
+
- `setTool`
|
|
22
|
+
- `undo`
|
|
23
|
+
- `redo`
|
|
24
|
+
- `reset`
|
|
25
|
+
- `changeColor`
|
|
26
|
+
|
|
27
|
+
-->
|
|
28
|
+
<div
|
|
29
|
+
class="kws-pen-controls is-placement-{toolbar_placement}"
|
|
30
|
+
style={canvas_controls_styles}>
|
|
31
|
+
{#if initialized && !readonly && !disabled}
|
|
32
|
+
<div
|
|
33
|
+
class="columns m-0 is-flex is-justify-content-{control_position}"
|
|
34
|
+
style="gap: 0.5rem;">
|
|
35
|
+
{#each actions as action}
|
|
36
|
+
{#if action === "controls"}
|
|
37
|
+
<div class="control">
|
|
38
|
+
<div class="dropdown is-{show_tools ? 'active' : ''} is-up">
|
|
39
|
+
<div class="dropdown-trigger">
|
|
40
|
+
<button
|
|
41
|
+
type="button"
|
|
42
|
+
use:tooltip
|
|
43
|
+
class="button is-info is-small"
|
|
44
|
+
data-tooltip="Tools"
|
|
45
|
+
aria-controls="tools-dropdown"
|
|
46
|
+
on:click={() => (show_tools = !show_tools)}>
|
|
47
|
+
<Icon icon={toolMap[active_tool].icon} size="small" />
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<div
|
|
52
|
+
class="dropdown-menu"
|
|
53
|
+
id="tools-dropdown"
|
|
54
|
+
role="menu"
|
|
55
|
+
style="min-width:auto;">
|
|
56
|
+
<div class="dropdown-content has-text-left">
|
|
57
|
+
{#each Object.values(tools) as { name, icon }}
|
|
58
|
+
<a
|
|
59
|
+
href="/#"
|
|
60
|
+
class="dropdown-item {toolMap[active_tool].icon === icon
|
|
61
|
+
? 'has-text-weight-bold'
|
|
62
|
+
: ''}"
|
|
63
|
+
on:click|preventDefault={() => {
|
|
64
|
+
active_tool = name;
|
|
65
|
+
fire("setTool", { tool: name });
|
|
66
|
+
}}
|
|
67
|
+
style="padding-right:1rem;">
|
|
68
|
+
<Icon {icon} size="small" />
|
|
69
|
+
<span>{name}</span>
|
|
70
|
+
</a>
|
|
71
|
+
{/each}
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
{:else if action === "undo"}
|
|
77
|
+
<div class="control">
|
|
78
|
+
<button
|
|
79
|
+
use:tooltip
|
|
80
|
+
type="button"
|
|
81
|
+
class="button is-small is-warning"
|
|
82
|
+
data-tooltip="Undo"
|
|
83
|
+
on:click={() => fire("undo")}
|
|
84
|
+
disabled={!can_undo}>
|
|
85
|
+
<Icon icon="undo" size="small" />
|
|
86
|
+
</button>
|
|
87
|
+
</div>
|
|
88
|
+
{:else if action === "redo"}
|
|
89
|
+
<div class="control">
|
|
90
|
+
<button
|
|
91
|
+
use:tooltip
|
|
92
|
+
type="button"
|
|
93
|
+
class="button is-small is-warning"
|
|
94
|
+
data-tooltip="Redo"
|
|
95
|
+
on:click={() => fire("redo")}
|
|
96
|
+
disabled={!can_redo}>
|
|
97
|
+
<Icon icon="repeat" size="small" />
|
|
98
|
+
</button>
|
|
99
|
+
</div>
|
|
100
|
+
{:else if action === "reset"}
|
|
101
|
+
<div class="control">
|
|
102
|
+
<button
|
|
103
|
+
use:tooltip
|
|
104
|
+
type="button"
|
|
105
|
+
class="button is-small is-danger"
|
|
106
|
+
data-tooltip="Reset"
|
|
107
|
+
on:click={() => fire("reset")}>
|
|
108
|
+
<Icon icon="refresh" size="small" />
|
|
109
|
+
</button>
|
|
110
|
+
</div>
|
|
111
|
+
{:else if action === "expand"}
|
|
112
|
+
<div class="control">
|
|
113
|
+
<button
|
|
114
|
+
use:tooltip
|
|
115
|
+
bind:this={EXPANDED_BUTTON}
|
|
116
|
+
type="button"
|
|
117
|
+
class="button is-small is-dark"
|
|
118
|
+
data-tooltip={expanded ? "Contract" : "Expand"}
|
|
119
|
+
on:click={() => expandContract()}>
|
|
120
|
+
<Icon icon={expanded ? "compress" : "expand"} size="small" />
|
|
121
|
+
</button>
|
|
122
|
+
</div>
|
|
123
|
+
{:else if action === "colorpicker"}
|
|
124
|
+
<div class="control">
|
|
125
|
+
<input
|
|
126
|
+
use:tooltip
|
|
127
|
+
type="color"
|
|
128
|
+
bind:value={color}
|
|
129
|
+
class="button is-small"
|
|
130
|
+
on:input={() => {
|
|
131
|
+
fire("changeColor", { color });
|
|
132
|
+
}}
|
|
133
|
+
data-tooltip="Pick Color" />
|
|
134
|
+
</div>
|
|
135
|
+
{/if}
|
|
136
|
+
{/each}
|
|
137
|
+
</div>
|
|
138
|
+
{/if}
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
<script>
|
|
142
|
+
import { Icon, tooltip } from "@kws3/ui";
|
|
143
|
+
import { createEventDispatcher, onMount } from "svelte";
|
|
144
|
+
|
|
145
|
+
const fire = createEventDispatcher();
|
|
146
|
+
export let EXPANDED_BUTTON;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @typedef {import('@kws3/ui/types').Positions} Positions
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Inline CSS for the control
|
|
154
|
+
*/
|
|
155
|
+
export let canvas_controls_styles = "";
|
|
156
|
+
/**
|
|
157
|
+
* Determines whether canvas is disabled or not
|
|
158
|
+
*/
|
|
159
|
+
export let disabled = false;
|
|
160
|
+
/**
|
|
161
|
+
* Determines whether canvas is readonly or not
|
|
162
|
+
*/
|
|
163
|
+
export let readonly = false;
|
|
164
|
+
/**
|
|
165
|
+
* List of tools available
|
|
166
|
+
*/
|
|
167
|
+
export let tools = {};
|
|
168
|
+
/**
|
|
169
|
+
* List of actions toolbar
|
|
170
|
+
*/
|
|
171
|
+
export let actions = ["controls", "undo", "redo", "reset", "expand"];
|
|
172
|
+
/**
|
|
173
|
+
* Determines which tool is select
|
|
174
|
+
*/
|
|
175
|
+
export let active_tool = "Pen";
|
|
176
|
+
/**
|
|
177
|
+
* Determines where the action tools are placed
|
|
178
|
+
* @type {Extract<Positions, 'bottom'|'top'>}
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
export let toolbar_placement = "bottom";
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* colorpicker's default color
|
|
185
|
+
*/
|
|
186
|
+
export let default_color = "";
|
|
187
|
+
/**
|
|
188
|
+
* Default position of controls
|
|
189
|
+
* @type {Extract<Positions, 'start'|'center'|'end'>}
|
|
190
|
+
*/
|
|
191
|
+
export let control_position = "center";
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Whether allowed to undo drawing changes or not
|
|
195
|
+
*/
|
|
196
|
+
export let can_undo = false;
|
|
197
|
+
/**
|
|
198
|
+
* Whether allowed to redo drawing changes or not
|
|
199
|
+
*/
|
|
200
|
+
export let can_redo = false;
|
|
201
|
+
/**
|
|
202
|
+
* Whether allowed to show tools or not
|
|
203
|
+
*/
|
|
204
|
+
export let show_tools = false;
|
|
205
|
+
|
|
206
|
+
let expanded = false;
|
|
207
|
+
let color = "";
|
|
208
|
+
let toolMap = {};
|
|
209
|
+
let initialized = false;
|
|
210
|
+
|
|
211
|
+
onMount(() => {
|
|
212
|
+
if (actions.includes("colorpicker") && default_color !== "") {
|
|
213
|
+
color = default_color;
|
|
214
|
+
}
|
|
215
|
+
setToolMap();
|
|
216
|
+
initialized = true;
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
function setToolMap() {
|
|
220
|
+
Object.values(tools).forEach((v) => {
|
|
221
|
+
toolMap[v.name] = v;
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function expandContract() {
|
|
226
|
+
expanded = !expanded;
|
|
227
|
+
if (EXPANDED_BUTTON) {
|
|
228
|
+
EXPANDED_BUTTON._tippy.setContent(
|
|
229
|
+
EXPANDED_BUTTON.getAttribute("data-tooltip")
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
fire("toggleExpand");
|
|
233
|
+
}
|
|
234
|
+
</script>
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@param {string} [width="250px"] - Canvas width, Default: `"250px"`
|
|
6
|
+
@param {string} [height="250px"] - Canvas height, Default: `"250px"`
|
|
7
|
+
@param {number} [pen_width=2] - pen width, Default: `2`
|
|
8
|
+
@param {number} [eraser_width=6] - Eraser width, Default: `6`
|
|
9
|
+
@param {string} [pen_color="#000000"] - line color, Default: `"#000000"`
|
|
10
|
+
@param {string} [background_image=""] - Background image for the canvas, Default: `""`
|
|
11
|
+
@param {boolean} [readonly=false] - Determines whether canvas is readonly or not, Default: `false`
|
|
12
|
+
@param {boolean} [disabled=false] - Determines whether canvas is disabled or not, Default: `false`
|
|
13
|
+
@param {string} [image=""] - The Data created in the canvas by the user, Default: `""`
|
|
14
|
+
@param {number} [initial_scale=1] - Initial transform scale for the canvas before expansion, Default: `1`
|
|
15
|
+
@param {number} [expand_scale=50] - Transform scale of the canvas on expansion, Default: `50`
|
|
16
|
+
@param {DrawingTools} [tools=undefined] - List of tools available for user to select from, Default: `undefined`
|
|
17
|
+
@param {DrawingPad} [DRAWING_PAD=undefined] - DRAWING_PAD property, Default: `undefined`
|
|
18
|
+
|
|
19
|
+
-->
|
|
20
|
+
<div
|
|
21
|
+
class="kws-pen-input {readonly || disabled ? 'is-readonly' : ''}"
|
|
22
|
+
style:width
|
|
23
|
+
style:height>
|
|
24
|
+
{#if disabled || readonly}
|
|
25
|
+
<img
|
|
26
|
+
alt="canvasimage"
|
|
27
|
+
src={image || emptyImage}
|
|
28
|
+
style:width
|
|
29
|
+
style:height
|
|
30
|
+
style:background-image="url({background_image})" />
|
|
31
|
+
{/if}
|
|
32
|
+
<canvas
|
|
33
|
+
bind:this={CANVAS}
|
|
34
|
+
style:width
|
|
35
|
+
style:height
|
|
36
|
+
style:background-image="url({background_image})"
|
|
37
|
+
style:background-color={readonly ? "transparent" : ""} />
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<script>
|
|
41
|
+
import { DrawingPad } from "../internal";
|
|
42
|
+
|
|
43
|
+
import { onMount, createEventDispatcher } from "svelte";
|
|
44
|
+
/**
|
|
45
|
+
* @typedef {import('@kws3/ui/internal/DrawingPad').DrawingPad} DrawingPad
|
|
46
|
+
* @typedef {import('@kws3/ui/types').DrawingTools} DrawingTools
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
const fire = createEventDispatcher();
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Canvas width
|
|
53
|
+
*/
|
|
54
|
+
export let width = "250px";
|
|
55
|
+
/**
|
|
56
|
+
* Canvas height
|
|
57
|
+
*/
|
|
58
|
+
export let height = "250px";
|
|
59
|
+
/**
|
|
60
|
+
*pen width
|
|
61
|
+
*/
|
|
62
|
+
export let pen_width = 2;
|
|
63
|
+
/**
|
|
64
|
+
* Eraser width
|
|
65
|
+
*/
|
|
66
|
+
export let eraser_width = 6;
|
|
67
|
+
/**
|
|
68
|
+
* line color
|
|
69
|
+
*/
|
|
70
|
+
export let pen_color = "#000000";
|
|
71
|
+
/**
|
|
72
|
+
/**
|
|
73
|
+
* Background image for the canvas
|
|
74
|
+
*/
|
|
75
|
+
export let background_image = "";
|
|
76
|
+
/**
|
|
77
|
+
* Determines whether canvas is readonly or not
|
|
78
|
+
*/
|
|
79
|
+
export let readonly = false;
|
|
80
|
+
/**
|
|
81
|
+
* Determines whether canvas is disabled or not
|
|
82
|
+
*/
|
|
83
|
+
export let disabled = false;
|
|
84
|
+
/**
|
|
85
|
+
* The Data created in the canvas by the user
|
|
86
|
+
*/
|
|
87
|
+
export let image = "";
|
|
88
|
+
/**
|
|
89
|
+
* Initial transform scale for the canvas before expansion
|
|
90
|
+
*/
|
|
91
|
+
export let initial_scale = 1;
|
|
92
|
+
/**
|
|
93
|
+
* Transform scale of the canvas on expansion
|
|
94
|
+
*/
|
|
95
|
+
export let expand_scale = 50;
|
|
96
|
+
/**
|
|
97
|
+
* List of tools available for user to select from
|
|
98
|
+
* @type {DrawingTools}
|
|
99
|
+
*/
|
|
100
|
+
export let tools = {};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @type {DrawingPad}
|
|
104
|
+
*/
|
|
105
|
+
export let DRAWING_PAD;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @type {HTMLCanvasElement}
|
|
109
|
+
*/
|
|
110
|
+
let CANVAS,
|
|
111
|
+
is_ready = false,
|
|
112
|
+
emptyImage =
|
|
113
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
|
|
114
|
+
|
|
115
|
+
$: readonly, setEvents();
|
|
116
|
+
|
|
117
|
+
onMount(() => {
|
|
118
|
+
CANVAS && CANVAS.setAttribute("width", width.replace("px", ""));
|
|
119
|
+
CANVAS && CANVAS.setAttribute("height", height.replace("px", ""));
|
|
120
|
+
|
|
121
|
+
DRAWING_PAD = new DrawingPad(
|
|
122
|
+
{ CANVAS, fire },
|
|
123
|
+
{
|
|
124
|
+
penWidth: pen_width,
|
|
125
|
+
penColor: pen_color,
|
|
126
|
+
eraserWidth: eraser_width,
|
|
127
|
+
initialScale: initial_scale,
|
|
128
|
+
image: image || emptyImage,
|
|
129
|
+
readonly,
|
|
130
|
+
expand: expand_scale,
|
|
131
|
+
tools: tools,
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
DRAWING_PAD && DRAWING_PAD.init();
|
|
136
|
+
is_ready = true;
|
|
137
|
+
|
|
138
|
+
return () => {
|
|
139
|
+
CANVAS && DRAWING_PAD.removeEvent();
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
function setEvents() {
|
|
144
|
+
if (is_ready) {
|
|
145
|
+
if (readonly) {
|
|
146
|
+
DRAWING_PAD && DRAWING_PAD.removeEvent();
|
|
147
|
+
} else {
|
|
148
|
+
DRAWING_PAD && DRAWING_PAD.addEvent();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
</script>
|
package/charts/AreaChart.svelte
CHANGED
|
@@ -12,9 +12,9 @@ squeezed into small spaces, Default: `false`
|
|
|
12
12
|
@param {object} [y_axis_options={}] - Y Axis options, see ApexCharts options for Y Axis, Default: `{}`
|
|
13
13
|
@param {string} [width="100%"] - Chart width, supports CSS size strings, Default: `"100%"`
|
|
14
14
|
@param {string} [height="auto"] - Chart height, supports CSS size strings, Default: `"auto"`
|
|
15
|
-
@param {array} [colors=
|
|
15
|
+
@param {array} [colors=[]] - Chart colors, can be modified globally in framework settings
|
|
16
16
|
|
|
17
|
-
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `
|
|
17
|
+
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `[]`
|
|
18
18
|
@param {array} [captured_events=[]] - String array of event names that will be captured and fired as svelte events.
|
|
19
19
|
This is to prevent unnecessary event subscriptions., Default: `[]`
|
|
20
20
|
@param {string} [class=""] - CSS classes for container, Default: `""`
|
package/charts/BarChart.svelte
CHANGED
|
@@ -16,9 +16,9 @@ squeezed into small spaces, Default: `false`
|
|
|
16
16
|
@param {object} [y_axis_options={}] - Y Axis options, see ApexCharts options for Y Axis, Default: `{}`
|
|
17
17
|
@param {string} [width="100%"] - Chart width, supports CSS size strings, Default: `"100%"`
|
|
18
18
|
@param {string} [height="auto"] - Chart height, supports CSS size strings, Default: `"auto"`
|
|
19
|
-
@param {array} [colors=
|
|
19
|
+
@param {array} [colors=[]] - Chart colors, can be modified globally in framework settings
|
|
20
20
|
|
|
21
|
-
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `
|
|
21
|
+
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `[]`
|
|
22
22
|
@param {array} [captured_events=[]] - String array of event names that will be captured and fired as svelte events.
|
|
23
23
|
This is to prevent unnecessary event subscriptions., Default: `[]`
|
|
24
24
|
@param {string} [class=""] - CSS classes for container, Default: `""`
|
package/charts/Chart.svelte
CHANGED
|
@@ -16,21 +16,14 @@ This is to prevent unnecessary event subscriptions., Default: `[]`
|
|
|
16
16
|
<div class="kws-chart {klass}" bind:this={canvas} />
|
|
17
17
|
|
|
18
18
|
<script>
|
|
19
|
-
import {
|
|
20
|
-
import ApexCharts from "apexcharts/dist/apexcharts.esm";
|
|
19
|
+
import { createEventDispatcher, onMount } from "svelte";
|
|
21
20
|
import { merge } from "./utils";
|
|
22
21
|
|
|
23
|
-
//some functions such as brush charts
|
|
24
|
-
//require ApexCharts to be globally available
|
|
25
|
-
if (window) {
|
|
26
|
-
if (!window.ApexCharts) {
|
|
27
|
-
window.ApexCharts = ApexCharts;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
22
|
const fire = createEventDispatcher();
|
|
32
23
|
let canvas, chart;
|
|
33
24
|
|
|
25
|
+
let ApexCharts;
|
|
26
|
+
|
|
34
27
|
/**
|
|
35
28
|
* Chart options
|
|
36
29
|
*/
|
|
@@ -91,8 +84,13 @@ This is to prevent unnecessary event subscriptions., Default: `[]`
|
|
|
91
84
|
"brushScrolled",
|
|
92
85
|
];
|
|
93
86
|
|
|
94
|
-
onMount(() => {
|
|
87
|
+
onMount(async () => {
|
|
88
|
+
const module = await import("apexcharts/dist/apexcharts.esm");
|
|
89
|
+
ApexCharts = module.default;
|
|
90
|
+
window.ApexCharts = ApexCharts;
|
|
91
|
+
|
|
95
92
|
init();
|
|
93
|
+
|
|
96
94
|
return () => {
|
|
97
95
|
chart && chart.destroy();
|
|
98
96
|
};
|
|
@@ -120,6 +118,12 @@ This is to prevent unnecessary event subscriptions., Default: `[]`
|
|
|
120
118
|
const init = () => {
|
|
121
119
|
chart && chart.destroy();
|
|
122
120
|
|
|
121
|
+
if (typeof window !== "undefined") {
|
|
122
|
+
if (!window.ApexCharts) {
|
|
123
|
+
window.ApexCharts = ApexCharts;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
123
127
|
const newOptions = {
|
|
124
128
|
chart: {
|
|
125
129
|
type,
|
|
@@ -156,7 +160,7 @@ This is to prevent unnecessary event subscriptions., Default: `[]`
|
|
|
156
160
|
|
|
157
161
|
const optionsChanged = () => {
|
|
158
162
|
if (chart) {
|
|
159
|
-
if (typeof options.chart.events
|
|
163
|
+
if (typeof options.chart.events !== "undefined") {
|
|
160
164
|
options.chart.events = Events;
|
|
161
165
|
}
|
|
162
166
|
chart.updateOptions(options, true);
|
package/charts/DonutChart.svelte
CHANGED
|
@@ -10,9 +10,9 @@ These are charts with minimal UI and can be
|
|
|
10
10
|
squeezed into small spaces, Default: `false`
|
|
11
11
|
@param {string} [width="100%"] - Chart width, supports CSS size strings, Default: `"100%"`
|
|
12
12
|
@param {string} [height="auto"] - Chart height, supports CSS size strings, Default: `"auto"`
|
|
13
|
-
@param {array} [colors=
|
|
13
|
+
@param {array} [colors=[]] - Chart colors, can be modified globally in framework settings
|
|
14
14
|
|
|
15
|
-
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `
|
|
15
|
+
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `[]`
|
|
16
16
|
@param {array} [captured_events=[]] - String array of event names that will be captured and fired as svelte events.
|
|
17
17
|
This is to prevent unnecessary event subscriptions., Default: `[]`
|
|
18
18
|
@param {string} [class=""] - CSS classes for container, Default: `""`
|
package/charts/LineChart.svelte
CHANGED
|
@@ -12,9 +12,9 @@ squeezed into small spaces, Default: `false`
|
|
|
12
12
|
@param {object} [y_axis_options={}] - Y Axis options, see ApexCharts options for Y Axis, Default: `{}`
|
|
13
13
|
@param {string} [width="100%"] - Chart width, supports CSS size strings, Default: `"100%"`
|
|
14
14
|
@param {string} [height="auto"] - Chart height, supports CSS size strings, Default: `"auto"`
|
|
15
|
-
@param {array} [colors=
|
|
15
|
+
@param {array} [colors=[]] - Chart colors, can be modified globally in framework settings
|
|
16
16
|
|
|
17
|
-
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `
|
|
17
|
+
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `[]`
|
|
18
18
|
@param {array} [captured_events=[]] - String array of event names that will be captured and fired as svelte events.
|
|
19
19
|
This is to prevent unnecessary event subscriptions., Default: `[]`
|
|
20
20
|
@param {string} [class=""] - CSS classes for container, Default: `""`
|
package/charts/MixedChart.svelte
CHANGED
|
@@ -13,9 +13,9 @@ squeezed into small spaces, Default: `false`
|
|
|
13
13
|
@param {object} [y_axis_options={}] - Y Axis options, see ApexCharts options for Y Axis, Default: `{}`
|
|
14
14
|
@param {string} [width="100%"] - Chart width, supports CSS size strings, Default: `"100%"`
|
|
15
15
|
@param {string} [height="auto"] - Chart height, supports CSS size strings, Default: `"auto"`
|
|
16
|
-
@param {array} [colors=
|
|
16
|
+
@param {array} [colors=[]] - Chart colors, can be modified globally in framework settings
|
|
17
17
|
|
|
18
|
-
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `
|
|
18
|
+
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `[]`
|
|
19
19
|
@param {array} [captured_events=[]] - String array of event names that will be captured and fired as svelte events.
|
|
20
20
|
This is to prevent unnecessary event subscriptions., Default: `[]`
|
|
21
21
|
@param {string} [class=""] - CSS classes for container, Default: `""`
|
package/charts/PieChart.svelte
CHANGED
|
@@ -10,9 +10,9 @@ These are charts with minimal UI and can be
|
|
|
10
10
|
squeezed into small spaces, Default: `false`
|
|
11
11
|
@param {string} [width="100%"] - Chart width, supports CSS size strings, Default: `"100%"`
|
|
12
12
|
@param {string} [height="auto"] - Chart height, supports CSS size strings, Default: `"auto"`
|
|
13
|
-
@param {array} [colors=
|
|
13
|
+
@param {array} [colors=[]] - Chart colors, can be modified globally in framework settings
|
|
14
14
|
|
|
15
|
-
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `
|
|
15
|
+
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `[]`
|
|
16
16
|
@param {array} [captured_events=[]] - String array of event names that will be captured and fired as svelte events.
|
|
17
17
|
This is to prevent unnecessary event subscriptions., Default: `[]`
|
|
18
18
|
@param {string} [class=""] - CSS classes for container, Default: `""`
|
|
@@ -12,9 +12,9 @@ These are charts with minimal UI and can be
|
|
|
12
12
|
squeezed into small spaces, Default: `false`
|
|
13
13
|
@param {string} [width="100%"] - Chart width, supports CSS size strings, Default: `"100%"`
|
|
14
14
|
@param {string} [height="auto"] - Chart height, supports CSS size strings, Default: `"auto"`
|
|
15
|
-
@param {array} [colors=
|
|
15
|
+
@param {array} [colors=[]] - Chart colors, can be modified globally in framework settings
|
|
16
16
|
|
|
17
|
-
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `
|
|
17
|
+
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `[]`
|
|
18
18
|
@param {array} [captured_events=[]] - String array of event names that will be captured and fired as svelte events.
|
|
19
19
|
This is to prevent unnecessary event subscriptions., Default: `[]`
|
|
20
20
|
@param {string} [class=""] - CSS classes for container, Default: `""`
|