@kws3/ui 1.6.7 → 1.7.1

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 (50) hide show
  1. package/CHANGELOG.mdx +99 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1 -1
  4. package/buttons/SubmitButton.svelte +8 -8
  5. package/controls/Checkbox.svelte +5 -5
  6. package/controls/FileUpload.svelte +4 -4
  7. package/controls/NumberInput.svelte +2 -2
  8. package/controls/ToggleButtons.svelte +1 -1
  9. package/datagrid/DataSearch/DataSearch.svelte +7 -6
  10. package/datagrid/DataSearch/SearchFilter.svelte +25 -10
  11. package/datagrid/GridView/GridCell.svelte +1 -0
  12. package/datagrid/GridView/GridRow.svelte +1 -1
  13. package/datagrid/Pagination/Pagination.svelte +107 -47
  14. package/datagrid/TileView/TileViewItem.svelte +1 -0
  15. package/forms/MaskedInput.svelte +1 -1
  16. package/forms/PasswordValidator/validatePassword.js +2 -2
  17. package/forms/actions.js +2 -1
  18. package/forms/colorpicker/Colorpicker.js +18 -13
  19. package/forms/colorpicker/Colorpicker.svelte +2 -2
  20. package/forms/select/MultiSelect.svelte +11 -13
  21. package/helpers/Dialog/Dialog.svelte +13 -14
  22. package/helpers/Divider.svelte +55 -0
  23. package/helpers/FloatingUI/Floatie.svelte +11 -5
  24. package/helpers/FloatingUI/index.js +2 -2
  25. package/helpers/Icon.svelte +1 -1
  26. package/helpers/Loader.svelte +4 -4
  27. package/helpers/Message.svelte +4 -1
  28. package/helpers/Modal.svelte +10 -2
  29. package/helpers/Nl2br.svelte +1 -1
  30. package/helpers/Notification.svelte +1 -1
  31. package/helpers/Panel.svelte +3 -1
  32. package/helpers/Popover.svelte +5 -5
  33. package/helpers/Skeleton.svelte +66 -0
  34. package/helpers/Timeline/Timeline.svelte +28 -0
  35. package/helpers/Timeline/TimelineHeader.svelte +21 -0
  36. package/helpers/Timeline/TimelineItem.svelte +70 -0
  37. package/index.js +5 -0
  38. package/package.json +2 -2
  39. package/sliding-panes/SlidingPane.svelte +2 -2
  40. package/sliding-panes/SlidingPaneSet.svelte +12 -15
  41. package/styles/DataSort.scss +5 -0
  42. package/styles/Divider.scss +102 -0
  43. package/styles/Grid.scss +1 -0
  44. package/styles/Loader.scss +35 -34
  45. package/styles/Pagination.scss +1 -1
  46. package/styles/RangeSlider.scss +2 -1
  47. package/styles/Skeleton.scss +52 -0
  48. package/styles/Timeline.scss +165 -0
  49. package/utils/index.js +1 -1
  50. package/utils/keyboard-events.js +3 -3
package/CHANGELOG.mdx ADDED
@@ -0,0 +1,99 @@
1
+ ## 1.7.1
2
+ - `Skeleton` component: Illustrate in example the use of empty string for `color` prop.
3
+ - `Pagination` component: Deprecate `meta` prop. And use separate props for `offset`, `limit`, `count` and `total` instead.
4
+ - `Pagination` component: Add methods `prev()`, `next()`, `first()`, `last()` and `goto(page)`.
5
+ - New `Divider` component.
6
+ - `Modal` component can now be opened and closed programatically via `open()` and `close()` methods.
7
+ - Added linting rules for ESLint. And corrected all resulting issues.
8
+
9
+
10
+ ## 1.7.0
11
+ - Ensure uniform usage of $kws-theme-colors across all components, this means $kws-theme-colors can be independent of the global $colors SCSS variable.
12
+ - `DataSearch` component: Expand filters to fill area when main search input is not present.
13
+ - `DataSort` component: Increase click area for activating dropdown, and provide visual segementation between label and dropdown.
14
+ - New `Skeleton` component.
15
+
16
+ ## 1.6.9
17
+ - New `Timeline`, `TimelineItem` and `TimelineHeader` components.
18
+
19
+ ## 1.6.8
20
+ - Vertically align `is-icon` cells in `Grid`
21
+
22
+ ## 1.6.7
23
+ - Added granular events `showing`, `shown`, `hiding` and `hidden` for `Popover`.
24
+ - Added `is-checked` class on `Grid` when a row is checked using the multiselect checkboxes.
25
+ - New colors for `is-checked` class on `Grid`
26
+
27
+ ## 1.6.6
28
+ - Enhance `Popover` with native `show` `hide` `enable` `disable` methods
29
+
30
+ ## 1.6.5
31
+ - Filter fix on `DataSearch`
32
+
33
+ ## 1.6.4
34
+ - Add support for `dropdown_portal` prop in `SearchableSelect`
35
+
36
+ ## 1.6.3
37
+ - Prevent submit call on `MultiSelect` when `Enter` key is pressed while searching
38
+ - Fix filter items going blank after search is initiated in `DataSearch`
39
+
40
+ ## 1.6.2
41
+ - Add `dropdown_portal` prop on `MultiSelect` to allow rendering dropdown in alternative locations
42
+
43
+ ## 1.6.1
44
+ - New `Portal` component
45
+ - Use `Portal` for `MultiSelect` and `SearchableSelect` components
46
+
47
+ ## 1.6.0
48
+ - Fix `DataSearch` responsiveness for mobile
49
+ - Fix `Pagination` CSS for mobile
50
+ - Fix `DataSort` responsiveness for mobile
51
+ - Fix functionality of `DataSearch`
52
+
53
+ ## 1.5.9
54
+ - Fix `z-index` issue with `SearchableSelect`
55
+
56
+ ## 1.5.8
57
+ - Showing `undefined` on total in `Pagination`
58
+
59
+ ## 1.5.7
60
+ - Width calculation on `DataSearch`
61
+ - More `text` validation `Nl2br`
62
+
63
+ ## 1.5.6
64
+ - Fix attribute of `MultiSelect`
65
+ - Fix `text` checking on `Nl2br`
66
+
67
+ ## 1.5.5
68
+ - Added `BarChart`
69
+ - Added `LineChart`
70
+ - Added `AreaChart`
71
+ - Added `RadialChart`
72
+ - Support `sparklines` in `Charts`
73
+ - Add `yAxisOptions` and `horizontal` bar for `Charts`
74
+ - Fix attribute of `ConfirmButton`
75
+ - Fix error Handling in `MixedChart`
76
+
77
+ ## 1.5.1
78
+ - Chart bugfixes
79
+ - Fix attribute of `NumberInput` for UI testing
80
+
81
+ ## 1.5.0
82
+ - Added `DonutChart`
83
+ - Added `MixedChart`
84
+ - Added `PieChart`
85
+
86
+ ## 1.4.7
87
+ - Fix value mismatch on `NumberInput`
88
+
89
+ ## 1.4.6
90
+ - Fix Typing bug on `NumberInput`
91
+
92
+ ## 1.4.5
93
+ - Fix **on:change** event on `NumberInput`
94
+
95
+ ## 1.4.4
96
+ - import `Floatie`, `FloatingUIOutput`, `FloatiesStore` from `@kws3/ui` for `FloatingUIOutput`
97
+
98
+ ## 1.4.3
99
+ - Rename `completion_timeout` to `error_timeout` in `Buttons`
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 KWS3 Media Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  UI components for use with Svelte v3 applications.
2
2
 
3
- Docs: [https://ui.kws3.media](https://ui.kws3.media)
3
+ [Demo and Documentation](https://ui.kws3.media)
@@ -15,9 +15,9 @@
15
15
  @param {number} [completion_timeout=600] - How long to wait before `saved` event is fired, and the UI state reverts back to normal, Default: `600`
16
16
  @param {number} [error_timeout=3000] - How long to wait before `error` event is fired, and the UI state reverts back to normal, Default: `3000`
17
17
  @param {string} [class=""] - CSS classes for Button container, Default: `""`
18
- @param {function} [saving()] - call this function on form saving state
19
- @param {function} [saved(callback, timeout)] - call this function after form saved
20
- @param {function} [error(callback, timeout)] - call this function on form error state
18
+ @method `saving()` - call this method on form saving state
19
+ @method `saved(callback, timeout)` - call this method after form saved
20
+ @method `error(callback, timeout)` - call this method on form error state
21
21
 
22
22
  ### Events
23
23
  - `saved` - Fired on successful submission
@@ -115,7 +115,7 @@
115
115
  export { klass as class };
116
116
 
117
117
  /**
118
- * call this function on form saving state
118
+ * call this method on form saving state
119
119
  */
120
120
  export function saving() {
121
121
  tracker = {
@@ -126,7 +126,7 @@
126
126
  }
127
127
 
128
128
  /**
129
- * call this function after form saved
129
+ * call this method after form saved
130
130
  */
131
131
  export function saved(callback, timeout = completion_timeout) {
132
132
  tracker = {
@@ -150,7 +150,7 @@
150
150
  }
151
151
 
152
152
  /**
153
- * call this function on form error state
153
+ * call this method on form error state
154
154
  */
155
155
  export function error(callback, timeout = error_timeout) {
156
156
  tracker = {
@@ -173,6 +173,6 @@
173
173
  }, timeout);
174
174
  }
175
175
 
176
- $: err_text = error_text == "" ? text : error_text;
177
- $: icon_size = size == "large" ? "" : "small";
176
+ $: err_text = error_text === "" ? text : error_text;
177
+ $: icon_size = size === "large" ? "" : "small";
178
178
  </script>
@@ -15,9 +15,9 @@ Checked\Not Checked, Default: `false`
15
15
  @param {string} [label_style=""] - Inline CSS for the Checkbox label, Default: `""`
16
16
  @param {''|'fa'|'lar'|'las'|'gg'|'unicons'} [icon_family="null"] - Icon family to be used
17
17
 
18
- Defaults to global family set via `Icon.setDefaultIconType()`
18
+ Defaults to global family set via `Icon.setDefaultIconType()`
19
19
 
20
- Ultimately defaults to `fa`, if family is not set anywhere, Default: `"null"`
20
+ Ultimately defaults to `fa`, if family is not set anywhere, Default: `"null"`
21
21
  @param {string} [class=""] - CSS classes of the Checkbox, Default: `""`
22
22
 
23
23
  ### Events
@@ -96,9 +96,9 @@ Ultimately defaults to `fa`, if family is not set anywhere, Default: `"null"`
96
96
  /**
97
97
  * Icon family to be used
98
98
  *
99
- * Defaults to global family set via `Icon.setDefaultIconType()`
99
+ * Defaults to global family set via `Icon.setDefaultIconType()`
100
100
  *
101
- * Ultimately defaults to `fa`, if family is not set anywhere
101
+ * Ultimately defaults to `fa`, if family is not set anywhere
102
102
  *
103
103
  * @type {''|'fa'|'lar'|'las'|'gg'|'unicons'}
104
104
  */
@@ -111,5 +111,5 @@ Ultimately defaults to `fa`, if family is not set anywhere, Default: `"null"`
111
111
  let klass = "";
112
112
  export { klass as class };
113
113
 
114
- $: has_icon = icon && icon != "";
114
+ $: has_icon = icon && icon !== "";
115
115
  </script>
@@ -170,7 +170,7 @@ The following functions are returned in `event.detail`:
170
170
 
171
171
  $: {
172
172
  fileTypes =
173
- allowed != "*" && Array.isArray(allowed) && allowed.length
173
+ allowed !== "*" && Array.isArray(allowed) && allowed.length
174
174
  ? allowed.join(", ")
175
175
  : "";
176
176
  _progress = Math.floor((_uploaded / _total) * 100);
@@ -256,18 +256,18 @@ The following functions are returned in `event.detail`:
256
256
  } else {
257
257
  size = 0;
258
258
  }
259
- val = val.split(/[\/\\]+/);
259
+ val = val.split(/[/\\]+/);
260
260
  val = val[val.length - 1];
261
261
  ext = val.split(/\./);
262
262
  ext = ext[ext.length - 1];
263
263
  ext = ext.toLowerCase();
264
- if (size == 0) {
264
+ if (size === 0) {
265
265
  valid = false;
266
266
  val = "No file selected";
267
267
  }
268
268
 
269
269
  //check if file extension is allowed
270
- if (allowed != "*") {
270
+ if (allowed !== "*") {
271
271
  if (typeof allowed.length != "undefined") {
272
272
  if (allowed.indexOf(ext) === -1) {
273
273
  valid = false;
@@ -183,7 +183,7 @@ This will be overridden if `min` is higher, or `max` is lower, Default: `0`
183
183
  const count = (i) => () => {
184
184
  if (typeof value == "undefined" || value === null) value = min;
185
185
  value = Number(value) + i * step;
186
- if (step % 1 != 0) value = value.toFixed(1);
186
+ if (step % 1 !== 0) value = value.toFixed(1);
187
187
  };
188
188
 
189
189
  function validateInput() {
@@ -194,7 +194,7 @@ This will be overridden if `min` is higher, or `max` is lower, Default: `0`
194
194
  if (value < min) value = min;
195
195
  if (value > max) value = max;
196
196
 
197
- if (_old_value != value) {
197
+ if (_old_value !== value) {
198
198
  _old_value = value;
199
199
  /**
200
200
  * Triggered when value changes
@@ -34,7 +34,7 @@ This property can be bound to, to fetch the current value, Default: `null`
34
34
  type="button"
35
35
  {disabled}
36
36
  on:click={setValue(option.value)}
37
- class="button is-{size} {fullwidth ? 'is-fullwidth' : ''} {value ==
37
+ class="button is-{size} {fullwidth ? 'is-fullwidth' : ''} {value ===
38
38
  option.value
39
39
  ? 'is-active ' +
40
40
  (option.active_class ? option.active_class : active_class)
@@ -23,7 +23,7 @@
23
23
  {#if hasSearch}
24
24
  <div class="control is-expanded main-search">
25
25
  <input
26
- class="input {query != '' && query != undefined
26
+ class="input {query !== '' && query !== undefined
27
27
  ? filter_in_use_class
28
28
  : filter_not_in_use_class}"
29
29
  type="text"
@@ -32,14 +32,14 @@
32
32
  </div>
33
33
  {/if}
34
34
  {#if hasFilters}
35
- {#each _filters as filter, i}
35
+ {#each _filters as filter}
36
36
  <svelte:component
37
37
  this={usedFilterComponent}
38
38
  {filterVals}
39
39
  {filter}
40
40
  {filterWidthStyle}
41
- hilightClass={filterVals[filter.name] != "" &&
42
- filterVals[filter.name] != undefined
41
+ hilightClass={filterVals[filter.name] !== "" &&
42
+ filterVals[filter.name] !== undefined
43
43
  ? filter_in_use_class
44
44
  : filter_not_in_use_class}
45
45
  {filter_label_map} />
@@ -117,7 +117,7 @@
117
117
  filterWidthStyle = "";
118
118
 
119
119
  $: usedFilterComponent = filterComponent ? filterComponent : SearchFilter;
120
- $: changed = q && q.trim() != "";
120
+ $: changed = q && q.trim() !== "";
121
121
  $: q, qHasChanged();
122
122
  $: filters, filtersHaveChanged();
123
123
 
@@ -152,7 +152,7 @@
152
152
  }
153
153
 
154
154
  function qHasChanged() {
155
- if (q == "") {
155
+ if (q === "") {
156
156
  //bail out early and reset all filters
157
157
  //this happens when using back/forward browser buttons
158
158
  return doresetSearch();
@@ -183,6 +183,7 @@
183
183
  filterVals[i] = "";
184
184
  }
185
185
  query = "";
186
+ // eslint-disable-next-line no-self-assign
186
187
  filterVals = filterVals;
187
188
 
188
189
  /**
@@ -10,8 +10,11 @@
10
10
 
11
11
  -->
12
12
 
13
- {#if filter.type == "multiselect"}
14
- <div class="control search-control" style={filterWidthStyle}>
13
+ {#if filter.type === "multiselect"}
14
+ <div
15
+ class="control search-control"
16
+ class:is-expanded={shouldExpandToFill}
17
+ style={filterWidthStyle}>
15
18
  <MultiSelect
16
19
  options={sanitizedOptions}
17
20
  placeholder={`Any ${name}`}
@@ -22,15 +25,21 @@
22
25
  summary_mode
23
26
  class={hilightClass} />
24
27
  </div>
25
- {:else if filter.type == "date"}
26
- <div class="control search-control" style={filterWidthStyle}>
28
+ {:else if filter.type === "date"}
29
+ <div
30
+ class="control search-control"
31
+ class:is-expanded={shouldExpandToFill}
32
+ style={filterWidthStyle}>
27
33
  <Datepicker
28
34
  class={hilightClass}
29
35
  bind:value={filterVals[filter.name]}
30
36
  placeholder="{capitaliseFirstLetter(name)} Date" />
31
37
  </div>
32
- {:else if filter.type == "daterange"}
33
- <div class="control search-control" style={filterWidthStyle}>
38
+ {:else if filter.type === "daterange"}
39
+ <div
40
+ class="control search-control"
41
+ class:is-expanded={shouldExpandToFill}
42
+ style={filterWidthStyle}>
34
43
  <Datepicker
35
44
  class={hilightClass}
36
45
  bind:value={filterVals[filter.name]}
@@ -38,7 +47,10 @@
38
47
  placeholder="{capitaliseFirstLetter(name)} Date Range" />
39
48
  </div>
40
49
  {:else if filter.options.length > 10}
41
- <div class="control search-control" style={filterWidthStyle}>
50
+ <div
51
+ class="control search-control"
52
+ class:is-expanded={shouldExpandToFill}
53
+ style={filterWidthStyle}>
42
54
  <SearchableSelect
43
55
  options={sanitizedOptions}
44
56
  placeholder={`Any ${name}`}
@@ -50,12 +62,13 @@
50
62
  {:else}
51
63
  <div
52
64
  class="select control search-control {hilightClass}"
65
+ class:is-expanded={shouldExpandToFill}
53
66
  style={filterWidthStyle}
54
67
  data-cy="select-container">
55
68
  <select
56
69
  bind:value={filterVals[filter.name]}
57
70
  class="is-radiusless {hilightClass}"
58
- style="max-width:100%"
71
+ style="max-width:100%;width:100%;"
59
72
  data-cy={cy}>
60
73
  {#each sanitizedOptions as option}
61
74
  {#if option}
@@ -103,6 +116,8 @@
103
116
 
104
117
  $: filterVals, filter, convertToValuesArray();
105
118
 
119
+ $: shouldExpandToFill = !filterWidthStyle || filterWidthStyle.trim() === "";
120
+
106
121
  function convertValuesToString() {
107
122
  tick().then(() => {
108
123
  filterVals[filter.name] = multiSelectValue
@@ -111,7 +126,7 @@
111
126
  });
112
127
  }
113
128
  function convertToValuesArray() {
114
- if (filter && filter.type == "multiselect") {
129
+ if (filter && filter.type === "multiselect") {
115
130
  multiSelectValue = filterVals[filter.name]
116
131
  ? filterVals[filter.name].split("|")
117
132
  : [];
@@ -122,7 +137,7 @@
122
137
  let options = filter.options || [];
123
138
  if (options.length) {
124
139
  options =
125
- filter.type == "multiselect"
140
+ filter.type === "multiselect"
126
141
  ? options
127
142
  : [{ id: "", name: `Any ${name}` }, ...options];
128
143
  options = options.map((el) => {
@@ -11,6 +11,7 @@
11
11
  -->
12
12
 
13
13
  <td class={classNames(column, row)} style={styles(column, row)}>
14
+ <!-- eslint-disable-next-line @ota-meshi/svelte/no-at-html-tags -->
14
15
  {@html transforms(column, row)}
15
16
  </td>
16
17
 
@@ -164,7 +164,7 @@
164
164
 
165
165
  function setCheckedValue() {
166
166
  checked = false;
167
- if (selectedIds.indexOf(row.id) != -1) {
167
+ if (selectedIds.indexOf(row.id) !== -1) {
168
168
  checked = true;
169
169
  }
170
170
  }