@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.
Files changed (108) hide show
  1. package/CHANGELOG.mdx +13 -1
  2. package/buttons/ConfirmButton.svelte +7 -6
  3. package/buttons/DeleteButton.svelte +14 -8
  4. package/buttons/ProcessButton.svelte +15 -9
  5. package/buttons/SubmitButton.svelte +11 -8
  6. package/canvas/Canvas.svelte +263 -0
  7. package/canvas/ESignature.svelte +101 -0
  8. package/canvas/PenControls.svelte +234 -0
  9. package/canvas/PenInput.svelte +152 -0
  10. package/charts/AreaChart.svelte +2 -2
  11. package/charts/BarChart.svelte +2 -2
  12. package/charts/Chart.svelte +16 -12
  13. package/charts/DonutChart.svelte +2 -2
  14. package/charts/LineChart.svelte +2 -2
  15. package/charts/MixedChart.svelte +2 -2
  16. package/charts/PieChart.svelte +2 -2
  17. package/charts/RadialChart.svelte +2 -2
  18. package/charts/utils.d.ts +553 -0
  19. package/charts/utils.d.ts.map +1 -0
  20. package/charts/utils.js +27 -4
  21. package/controls/Checkbox.svelte +7 -6
  22. package/controls/FileUpload.svelte +5 -4
  23. package/controls/NumberInput.svelte +5 -5
  24. package/controls/Radio.svelte +2 -2
  25. package/controls/RangeSlider.svelte +4 -2
  26. package/controls/Toggle.svelte +2 -2
  27. package/controls/ToggleButtons.svelte +1 -1
  28. package/datagrid/GridView/GridRow.svelte +4 -4
  29. package/datagrid/GridView/GridView.svelte +7 -4
  30. package/datagrid/Pagination/Pagination.svelte +12 -11
  31. package/form/index.d.ts +15 -0
  32. package/form/index.d.ts.map +1 -0
  33. package/forms/AutoComplete.svelte +12 -6
  34. package/forms/Datepicker.svelte +4 -3
  35. package/forms/PasswordInput.svelte +224 -0
  36. package/forms/PasswordValidator/validatePassword.d.ts +5 -0
  37. package/forms/PasswordValidator/validatePassword.d.ts.map +1 -0
  38. package/forms/SearchInput.svelte +18 -7
  39. package/forms/Timepicker.svelte +9 -6
  40. package/forms/actions.d.ts +9 -0
  41. package/forms/actions.d.ts.map +1 -0
  42. package/forms/actions.js +6 -0
  43. package/forms/colorpicker/Colorpicker.d.ts +3 -0
  44. package/forms/colorpicker/Colorpicker.d.ts.map +1 -0
  45. package/forms/colorpicker/Colorpicker.js +12 -2
  46. package/forms/colorpicker/Colorpicker.svelte +10 -3
  47. package/forms/select/MultiSelect.svelte +14 -9
  48. package/forms/select/SearchableSelect.svelte +10 -5
  49. package/helpers/CardModal.svelte +7 -2
  50. package/helpers/ClipboardCopier.svelte +3 -3
  51. package/helpers/Dialog/Dialog.svelte +9 -7
  52. package/helpers/Dialog/index.d.ts +42 -0
  53. package/helpers/Dialog/index.d.ts.map +1 -0
  54. package/helpers/Dialog/index.js +58 -19
  55. package/helpers/Divider.svelte +10 -4
  56. package/helpers/FloatingUI/Floatie.svelte +1 -1
  57. package/helpers/FloatingUI/index.d.ts +51 -0
  58. package/helpers/FloatingUI/index.d.ts.map +1 -0
  59. package/helpers/FloatingUI/index.js +13 -0
  60. package/helpers/Icon.svelte +14 -7
  61. package/helpers/Loader.svelte +5 -5
  62. package/helpers/Message.svelte +11 -6
  63. package/helpers/Modal.svelte +7 -2
  64. package/helpers/Notification.svelte +6 -2
  65. package/helpers/Popover.svelte +13 -6
  66. package/helpers/Skeleton.svelte +3 -3
  67. package/helpers/Timeline/Timeline.svelte +1 -1
  68. package/helpers/Timeline/TimelineItem.svelte +8 -4
  69. package/helpers/Tooltip.d.ts +19 -0
  70. package/helpers/Tooltip.d.ts.map +1 -0
  71. package/helpers/Tooltip.js +14 -1
  72. package/index.d.ts +69 -0
  73. package/index.d.ts.map +1 -0
  74. package/index.js +7 -0
  75. package/internal/DrawingPad.d.ts +86 -0
  76. package/internal/DrawingPad.d.ts.map +1 -0
  77. package/internal/DrawingPad.js +306 -0
  78. package/internal/UndoManager.d.ts +17 -0
  79. package/internal/UndoManager.d.ts.map +1 -0
  80. package/internal/UndoManager.js +84 -0
  81. package/internal/fuzzy.d.ts +24 -0
  82. package/internal/fuzzy.d.ts.map +1 -0
  83. package/internal/index.d.ts +16 -0
  84. package/internal/index.d.ts.map +1 -0
  85. package/internal/index.js +5 -1
  86. package/internal/scrollIntoActiveElement.d.ts +2 -0
  87. package/internal/scrollIntoActiveElement.d.ts.map +1 -0
  88. package/keyboard/index.d.ts +30 -0
  89. package/keyboard/index.d.ts.map +1 -0
  90. package/keyboard/index.js +1 -1
  91. package/package.json +6 -3
  92. package/resizeObserver/index.d.ts +8 -0
  93. package/resizeObserver/index.d.ts.map +1 -0
  94. package/search/index.d.ts +17 -0
  95. package/search/index.d.ts.map +1 -0
  96. package/settings.d.ts +22 -0
  97. package/settings.d.ts.map +1 -0
  98. package/settings.js +6 -1
  99. package/styles/Canvas.scss +100 -0
  100. package/styles/RangeSlider.scss +12 -0
  101. package/transitions/components/getEasing.d.ts +2 -0
  102. package/transitions/components/getEasing.d.ts.map +1 -0
  103. package/tsconfig.json +33 -0
  104. package/types/index.d.ts +103 -9
  105. package/types/type-defs/index.d.ts +64 -0
  106. package/utils/index.d.ts +77 -0
  107. package/utils/index.d.ts.map +1 -0
  108. package/types/type-defs/index.ts +0 -14
@@ -0,0 +1,100 @@
1
+ :root {
2
+ --kws-peninput-height: 350px;
3
+ --kws-peninput-width: 250px;
4
+ --kws-peninput-border: 1px dotted #ccc;
5
+ --kws-peninput-controls-height: 2.4rem;
6
+ }
7
+ .kws-canvas-wrapper {
8
+ display: flex;
9
+ flex-direction: column;
10
+ margin: 0 auto;
11
+ height: var(--kws-peninput-height);
12
+ width: var(--kws-peninput-width);
13
+ transform: translate3d(0, 0, 0);
14
+ transition: transform 0.3s $easeOutCustom;
15
+ transform-origin: center center;
16
+ will-change: transform;
17
+ backface-visibility: hidden;
18
+ transform-style: preserve-3d;
19
+ position: relative;
20
+ .kws-pen-controls {
21
+ position: absolute;
22
+ width: 100%;
23
+ min-height: var(--kws-peninput-controls-height);
24
+ background: transparentize($grey-light, 0.5);
25
+ padding: 0.25rem;
26
+ margin: 0 auto;
27
+ .control {
28
+ .button {
29
+ &.is-always-rounded {
30
+ border-radius: 1rem !important;
31
+ padding-left: 1em;
32
+ padding-right: 1em;
33
+ }
34
+ }
35
+ }
36
+ &.is-placement-bottom {
37
+ top: var(--kws-peninput-height);
38
+ }
39
+ &.is-placement-top {
40
+ top: 0;
41
+ }
42
+
43
+ input[type="color"] {
44
+ -webkit-appearance: none;
45
+ border: none;
46
+ width: 32px;
47
+ height: 32px;
48
+ padding: 3px;
49
+ background-color: $white-ter;
50
+ }
51
+ input[type="color"]::-webkit-color-swatch-wrapper {
52
+ padding: 0;
53
+ }
54
+ input[type="color"]::-webkit-color-swatch {
55
+ border: none;
56
+ }
57
+ &.expanded {
58
+ z-index: 999;
59
+ position: relative;
60
+ box-shadow: $card-shadow;
61
+ .kws-pen-controls {
62
+ background: $grey-lighter;
63
+ }
64
+ }
65
+ }
66
+
67
+ .kws-pen-input {
68
+ position: relative;
69
+ margin: auto auto;
70
+ overflow: hidden;
71
+ img {
72
+ display: block;
73
+ background-repeat: no-repeat;
74
+ background-size: contain;
75
+ background-position: center center;
76
+ border: 1px dotted #ccc;
77
+ }
78
+ canvas {
79
+ display: block;
80
+ cursor: crosshair;
81
+ box-sizing: border-box;
82
+ background-color: #fdfdfd;
83
+ background-repeat: no-repeat;
84
+ background-size: contain;
85
+ background-position: center center;
86
+ border: 1px solid #000000;
87
+ }
88
+ &.is-readonly {
89
+ canvas {
90
+ cursor: default;
91
+ }
92
+ }
93
+ }
94
+
95
+ &.has-toolbar-top {
96
+ .kws-pen-input {
97
+ top: var(--kws-peninput-controls-height);
98
+ }
99
+ }
100
+ }
@@ -253,6 +253,18 @@ $kws-slider-output-radius: $radius !default;
253
253
  }
254
254
  }
255
255
  }
256
+
257
+ &.is-thumb-#{$name} {
258
+ &::-webkit-slider-thumb {
259
+ background: $color !important;
260
+ }
261
+ &::-moz-range-thumb {
262
+ background: $color !important;
263
+ }
264
+ &::-ms-thumb {
265
+ background: $color !important;
266
+ }
267
+ }
256
268
  }
257
269
  }
258
270
  }
@@ -0,0 +1,2 @@
1
+ export default function getEasing(easing: any): any;
2
+ //# sourceMappingURL=getEasing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getEasing.d.ts","sourceRoot":"","sources":["getEasing.js"],"names":[],"mappings":"AAUA,oDAWC"}
package/tsconfig.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ // Change this to match your project
3
+ "include": ["./**/*.js", "./**/*.svelte"],
4
+ "compilerOptions": {
5
+ "lib": ["es2020", "DOM"],
6
+ "skipLibCheck": true,
7
+ "checkJs": true,
8
+ // Tells TypeScript to read JS files, as
9
+ // normally they are ignored as source files
10
+ "allowJs": true,
11
+ // Generate d.ts files
12
+ "declaration": true,
13
+ // This compiler run should
14
+ // only output d.ts files
15
+ "emitDeclarationOnly": true,
16
+ // Types should go into this directory.
17
+ // Removing this would place the .d.ts files
18
+ // next to the .js files
19
+ //"declarationDir": "./generatedTypes",
20
+ //"outDir": "./generatedTypes",
21
+ // go to js file when using IDE functions like
22
+ // "Go to Definition" in VSCode
23
+ "declarationMap": true,
24
+ "baseUrl": ".",
25
+ "paths": {
26
+ "@kws3/ui": ["./"],
27
+ "@kws3/ui/*": ["./*"],
28
+ "@kws3/ui/types": ["./types"]
29
+ },
30
+ "types": ["svelte"]
31
+ },
32
+ "exclude": ["node_modules"]
33
+ }
package/types/index.d.ts CHANGED
@@ -1,4 +1,44 @@
1
- import { Colors, BGColors, SpinnerColors, Sizes } from "./type-defs.ts";
1
+ import type {
2
+ Colors,
3
+ BGColors,
4
+ ExtendedColors,
5
+ Sizes,
6
+ Positions,
7
+ FontFamilies,
8
+ FloatiePositions,
9
+ TippyPositions,
10
+ } from "./type-defs";
11
+
12
+ export type ColorOptions = (typeof Colors)[number];
13
+ export type SizeOptions = (typeof Sizes)[number];
14
+ export type ExtendedColorOptions = (typeof ExtendedColors)[number];
15
+ export type BGColorOptions = (typeof BGColors)[number];
16
+ export type FontFamilies = (typeof FontFamilies)[number];
17
+ export type Positions = (typeof Positions)[number];
18
+ export type TippyPositions = (typeof TippyPositions)[number];
19
+ export type FloatiePositions = (typeof FloatiePositions)[number];
20
+
21
+ export type FloatieType = {
22
+ create: (opts: object) => { props: object; destroy: () => void };
23
+ remove: (props: object) => void;
24
+ };
25
+
26
+ export type DialogProps = {
27
+ title?: string;
28
+ help_text?: string;
29
+ size?: SizeOptions;
30
+ input_value?: string;
31
+ icon?: string;
32
+ icon_color?: ColorOptions;
33
+ icon_size?: SizeOptions;
34
+ ok_button_text?: string;
35
+ ok_button_color?: ColorOptions;
36
+ ok_button_icon?: string;
37
+ cancel_button_text?: string;
38
+ cancel_button_color?: ColorOptions;
39
+ cancel_button_icon?: string;
40
+ };
41
+
2
42
  export type SearchOptions = {
3
43
  search_key: Array<string> | string;
4
44
  scoreThreshold: number;
@@ -12,7 +52,10 @@ export type SearchOptions = {
12
52
  };
13
53
  };
14
54
 
15
- export type SearchHelper = (needle: string, haystack: array) => array;
55
+ export type SearchHelper = (
56
+ needle: string,
57
+ haystack: Array<string>
58
+ ) => Array<any>;
16
59
 
17
60
  export type ValidatePasswordOptions = {
18
61
  name: string;
@@ -25,6 +68,64 @@ export type ValidatePasswordOptions = {
25
68
  negate?: boolean;
26
69
  };
27
70
 
71
+ export type SettingOptions = {
72
+ defaultIconFamily?: FontFamilies;
73
+ defaultToastPlacement?: TippyPositions;
74
+ defaultSnackbarPlacement?: TippyPositions;
75
+ defaultNotificationPlacement?: TippyPositions;
76
+ hasTransitions?: boolean;
77
+ defaultChartColors?: Array<string>;
78
+ };
79
+
80
+ type DrawingTool = {
81
+ name: string;
82
+ icon: string;
83
+ draw: (pad: DrawingPad) => void;
84
+ };
85
+
86
+ export type DrawingTools = {
87
+ [key: string]: DrawingTool;
88
+ };
89
+
90
+ export type DrawingPadOptions = {
91
+ initialScale: number;
92
+ penColor: string;
93
+ penWidth: number;
94
+ eraserWidth: number;
95
+ readonly?: boolean;
96
+ image?: string;
97
+ tools: DrawingTools;
98
+ expanded?: boolean;
99
+ expand?: number;
100
+ };
101
+
102
+ export type DrawingPadEvents = {
103
+ change: {
104
+ canUndo: boolean;
105
+ canRedo: boolean;
106
+ canvasImage: string;
107
+ };
108
+ };
109
+
110
+ export type ButtonEvent = {
111
+ doing: () => void;
112
+ done: (callback?: Function, timeout?: number) => void;
113
+ error: (callback?: Function, timeout?: number) => void;
114
+ context: any;
115
+ };
116
+
117
+ export type SubmitButtonEvent = {
118
+ saving: () => void;
119
+ saved: (callback?: Function, timeout?: number) => void;
120
+ error: (callback?: Function, timeout?: number) => void;
121
+ };
122
+
123
+ export type ButtonTracker = {
124
+ saving: boolean;
125
+ saved: boolean;
126
+ error: boolean;
127
+ };
128
+
28
129
  declare global {
29
130
  interface Navigator {
30
131
  readonly userAgentData: {
@@ -37,10 +138,3 @@ declare global {
37
138
  readonly navigator: Navigator;
38
139
  }
39
140
  }
40
-
41
- export type Options<T> = T;
42
-
43
- export type ColorOptions = Options<Colors>;
44
- export type SizeOptions = Options<Sizes>;
45
- export type SpinnerColorOptions = Options<Colors | SpinnerColors>;
46
- export type BGColorOptions = Options<Colors | BGColors>;
@@ -0,0 +1,64 @@
1
+ export const Colors = [
2
+ "",
3
+ "primary",
4
+ "success",
5
+ "warning",
6
+ "info",
7
+ "danger",
8
+ "dark",
9
+ "light",
10
+ "link",
11
+ ] as const;
12
+
13
+ export const ExtendedColors = [...Colors, "grey"] as const;
14
+ export const BGColors = [...Colors, "transparent"] as const;
15
+
16
+ export const Sizes = ["", "small", "medium", "large"] as const;
17
+
18
+ export const Positions = [
19
+ "top",
20
+ "bottom",
21
+ "left",
22
+ "right",
23
+ "start",
24
+ "center",
25
+ "end",
26
+ ] as const;
27
+
28
+ export const FontFamilies = [
29
+ "",
30
+ "fa",
31
+ "lar",
32
+ "las",
33
+ "gg",
34
+ "unicons",
35
+ "material",
36
+ ] as const;
37
+
38
+ export const FloatiePositions = [
39
+ "",
40
+ "top",
41
+ "bottom",
42
+ "top-left",
43
+ "top-right",
44
+ "bottom-left",
45
+ "bottom-right",
46
+ ] as const;
47
+
48
+ export const TippyPositions = [
49
+ "top",
50
+ "top-start",
51
+ "top-end",
52
+ "right",
53
+ "right-start",
54
+ "right-end",
55
+ "bottom",
56
+ "bottom-start",
57
+ "bottom-end",
58
+ "left",
59
+ "left-start",
60
+ "left-end",
61
+ "auto",
62
+ "auto-start",
63
+ "auto-end",
64
+ ] as const;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Truncate a string.
3
+ * @param {string} [str=""] - String to truncate, Default: `""`
4
+ * @param {number} [len=0] - The number of characters to extract, Default: `""`
5
+ */
6
+ export function truncate(str?: string, len?: number): string;
7
+ /**
8
+ * Insert line breaks where newlines (\n) occur in the string.
9
+ * @param {string} [input=""] - String to be checked, Default: `""`
10
+ */
11
+ export function nl2br(input?: string): string;
12
+ /**
13
+ * Clone an Object.
14
+ * @param {object} [obj={}] - Object to be cloned, Default: `{}`
15
+ */
16
+ export function cloneObject(obj?: object): any;
17
+ /**
18
+ * Returns a function, that, as long as it continues to be invoked, will not
19
+ * be triggered. The function will be called after it stops being called for
20
+ * `threshold` milliseconds.
21
+ * @param {function} [fn=function(){}] - The function that you want to execute after the debounce time
22
+ * @param {number} [threshold=100] - The amount of time to wait, Default: `100`
23
+ * @param {boolean} [isAsap=false] - flag to debounce early, Default: `false`
24
+ *
25
+ */
26
+ export function debounce(fn?: Function, threshold?: number, isAsap?: boolean): {
27
+ (...args: any[]): any;
28
+ cancel(): void;
29
+ };
30
+ /**
31
+ * Capitalise First letter of string.
32
+ * @param {string} [string=""] - A string whose first letter is to be capitalised, Default: `""`
33
+ */
34
+ export function capitaliseFirstLetter(string?: string): string;
35
+ /**
36
+ * Returns Date Object.
37
+ * Makes mysql dates work in safari
38
+ * @param {string} [strDate=""] - Date String., Default: `""`
39
+ */
40
+ export function createDate(strDate?: string): Date;
41
+ /**
42
+ * Returns currency format.
43
+ * @param {number} [n=''] - Number., Default: `""`
44
+ */
45
+ export function currency(n?: number): string;
46
+ /**
47
+ * Converts date to ordinal.
48
+ * @param {number} [n=''] - Number., Default: `""`
49
+ */
50
+ export function dateToOrdinal(n?: number): string;
51
+ /**
52
+ * Returns a random integer between min (inclusive) and max (inclusive).
53
+ * The value is no lower than min (or the next integer greater than min
54
+ * if min isn't an integer) and no greater than max (or the next integer
55
+ * lower than max if max isn't an integer).
56
+ * @param {number} [min] - Minimum Number.
57
+ * @param {number} [max] - Maximum Number.
58
+ */
59
+ export function randomIntegerFromInterval(min?: number, max?: number): number;
60
+ /**
61
+ * Returns random percentage.
62
+ * @param {number} [min=1] - Minimum Number, Default: `1`
63
+ * @param {number} [max=100] - Maximum Number, Default: `100`
64
+ */
65
+ export function randomPercent(min?: number, max?: number): string;
66
+ /**
67
+ * Downloads file.
68
+ * @param {Object} [data={}] - File data.
69
+ * @param {string} [fileName=''] - File Name.
70
+ */
71
+ export function fileDownloader(data?: any, fileName?: string): void;
72
+ /**
73
+ * Request an animation before the next repaint.
74
+ * @param {function} [callback=function(){}] - callback function
75
+ */
76
+ export const rAF: any;
77
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,+BAHW,MAAM,QACN,MAAM,UAIhB;AAED;;;GAGG;AACH,8BAFW,MAAM,UAQhB;AAED;;;GAGG;AACH,kCAFW,MAAM,OAIhB;AAsBD;;;;;;;;GAQG;AACH,oDAJW,MAAM,WACN,OAAO;;;EA2BjB;AAED;;;GAGG;AACH,+CAFW,MAAM,UAIhB;AAED;;;;GAIG;AACH,qCAFW,MAAM,QAKhB;AAED;;;GAGG;AACH,6BAFW,MAAM,UAKhB;AAED;;;GAGG;AACH,kCAFW,MAAM,UAUhB;AAED;;;;;;;GAOG;AACH,gDAHW,MAAM,QACN,MAAM,UAMhB;AAED;;;;GAIG;AACH,oCAHW,MAAM,QACN,MAAM,UAIhB;AAED;;;;GAIG;AACH,sDAFW,MAAM,QAYhB;AAtID;;;GAGG;AACH,sBAce"}
@@ -1,14 +0,0 @@
1
- export type Colors =
2
- | ""
3
- | "primary"
4
- | "success"
5
- | "warning"
6
- | "info"
7
- | "danger"
8
- | "dark"
9
- | "light";
10
-
11
- export type BGColors = "" | "transparent" | "link";
12
- export type SpinnerColors = "" | "grey";
13
-
14
- export type Sizes = "" | "small" | "medium" | "large";