@kws3/ui 1.7.0 → 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.
package/CHANGELOG.mdx CHANGED
@@ -1,5 +1,14 @@
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
+
1
10
  ## 1.7.0
2
- - Ensure uniform usage of $kws-theme-colors across all components, this means $kws-theme-colors can be indepnedent of the global $colors SCSS variable.
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.
3
12
  - `DataSearch` component: Expand filters to fill area when main search input is not present.
4
13
  - `DataSort` component: Increase click area for activating dropdown, and provide visual segementation between label and dropdown.
5
14
  - New `Skeleton` component.
@@ -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,7 +10,7 @@
10
10
 
11
11
  -->
12
12
 
13
- {#if filter.type == "multiselect"}
13
+ {#if filter.type === "multiselect"}
14
14
  <div
15
15
  class="control search-control"
16
16
  class:is-expanded={shouldExpandToFill}
@@ -25,7 +25,7 @@
25
25
  summary_mode
26
26
  class={hilightClass} />
27
27
  </div>
28
- {:else if filter.type == "date"}
28
+ {:else if filter.type === "date"}
29
29
  <div
30
30
  class="control search-control"
31
31
  class:is-expanded={shouldExpandToFill}
@@ -35,7 +35,7 @@
35
35
  bind:value={filterVals[filter.name]}
36
36
  placeholder="{capitaliseFirstLetter(name)} Date" />
37
37
  </div>
38
- {:else if filter.type == "daterange"}
38
+ {:else if filter.type === "daterange"}
39
39
  <div
40
40
  class="control search-control"
41
41
  class:is-expanded={shouldExpandToFill}
@@ -116,7 +116,7 @@
116
116
 
117
117
  $: filterVals, filter, convertToValuesArray();
118
118
 
119
- $: shouldExpandToFill = !filterWidthStyle || filterWidthStyle.trim() == "";
119
+ $: shouldExpandToFill = !filterWidthStyle || filterWidthStyle.trim() === "";
120
120
 
121
121
  function convertValuesToString() {
122
122
  tick().then(() => {
@@ -126,7 +126,7 @@
126
126
  });
127
127
  }
128
128
  function convertToValuesArray() {
129
- if (filter && filter.type == "multiselect") {
129
+ if (filter && filter.type === "multiselect") {
130
130
  multiSelectValue = filterVals[filter.name]
131
131
  ? filterVals[filter.name].split("|")
132
132
  : [];
@@ -137,7 +137,7 @@
137
137
  let options = filter.options || [];
138
138
  if (options.length) {
139
139
  options =
140
- filter.type == "multiselect"
140
+ filter.type === "multiselect"
141
141
  ? options
142
142
  : [{ id: "", name: `Any ${name}` }, ...options];
143
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
  }
@@ -2,21 +2,36 @@
2
2
  @component
3
3
 
4
4
 
5
- @param {object} [meta={}] - Contains the total, count, limit, offset values, Default: `{}`
5
+ @param {object} [meta={}] - Object containing `total`, `count`, `limit` and `offset` values
6
+
7
+ **DEPRECATED**: Use `total`, `count`, `limit` and `offset` props instead, Default: `{}`
8
+ @param {number} [limit=0] - How many items are meant to be per page, Default: `0`
9
+ @param {number} [count=0] - How many items are actually in this page, Default: `0`
10
+ @param {number} [total=0] - Total number of items available, Default: `0`
11
+ @param {number} [offset=0] - Offset of the first item in this page, Default: `0`
6
12
  @param {boolean} [showTotal=true] - Determines whether to show total or not, Default: `true`
7
13
  @param {boolean} [showCurrent=true] - Determines whether to show current page details, Default: `true`
8
14
  @param {boolean} [showPerPage=true] - Determines whether to show per page options, Default: `true`
9
15
  @param {number} [breakThreshold=10] - Limit the number of visible pages in pagination, Default: `10`
10
16
  @param {string} [entityName="entries"] - String to display total entries, Default: `"entries"`
11
- @param {string} [size="small"] - Size of the pagination, Default: `"small"`
17
+ @param {''|'small'|'medium'|'large'} [size="small"] - Size of the pagination elements, Default: `"small"`
12
18
  @param {boolean} [frame=false] - Determines whether to show pagination frame or not, Default: `false`
13
19
  @param {string} [iconRight="chevron-right"] - Right navigation icon, Default: `"chevron-right"`
14
20
  @param {string} [iconLeft="chevron-left"] - Left navigation icon, Default: `"chevron-left"`
15
- @param {array} [perPageOptions=[]] - Determines the number of rows displayed in a page., Default: `[]`
21
+ @param {array} [perPageOptions=[]] - Displays the options for how many items to show per page, Default: `[]`
22
+ @method `goto(targetPage)` - Go to an arbitrary page number
23
+ @method `prev()` - Go to the previous page
24
+ @method `next()` - Go to the next page
25
+ @method `first()` - Go to the first page
26
+ @method `last()` - Go to the last page
16
27
 
17
28
  ### Events
18
- - `setLimit` - Event used to set limit of pagination
19
- - `paginate` - Event triggered on paginate
29
+ - `setLimit` - Event used to set a new `limit`.
30
+
31
+ *Event Data:* `{currentPage, newLimit}`
32
+ - `paginate` - Event triggered on pagination change with new `offset` and current `limit` values.
33
+
34
+ *Event Data:* `{offset, limit}`
20
35
 
21
36
  -->
22
37
  <div
@@ -34,9 +49,7 @@
34
49
  <li>
35
50
  <button
36
51
  type="button"
37
- class="pagination-link {meta.limit == v
38
- ? 'is-current'
39
- : ''}"
52
+ class="pagination-link {_limit === v ? 'is-current' : ''}"
40
53
  on:click={() => setLimit(v)}>{k}</button>
41
54
  </li>
42
55
  {/each}
@@ -49,9 +62,8 @@
49
62
  {#if showTotal}
50
63
  <strong>Total {totalItems} {entityName}</strong>
51
64
  {:else if showCurrent}
52
- {#if meta.total > 0}Showing {meta.offset * 1 + 1} to {meta.offset *
53
- 1 +
54
- meta.count * 1}{/if}
65
+ {#if _total > 0}Showing {_offset * 1 + 1} to {_offset * 1 +
66
+ _count * 1}{/if}
55
67
  {/if}
56
68
  </div>
57
69
  {/if}
@@ -59,14 +71,14 @@
59
71
 
60
72
  {#if showCurrent && showTotal && !showPerPage}
61
73
  <div class="level-item pagination-showing">
62
- {#if meta.total > 0}
63
- Showing {meta.offset * 1 + 1} to {meta.offset * 1 + meta.count * 1}
74
+ {#if _total > 0}
75
+ Showing {_offset * 1 + 1} to {_offset * 1 + _count * 1}
64
76
  {/if}
65
77
  </div>
66
78
  {:else if showPerPage && showCurrent}
67
79
  <div class="level-item pagination-showing">
68
- {#if meta.total > 0}
69
- Showing {meta.offset * 1 + 1} to {meta.offset * 1 + meta.count * 1}
80
+ {#if _total > 0}
81
+ Showing {_offset * 1 + 1} to {_offset * 1 + _count * 1}
70
82
  {#if showTotal}
71
83
  |&nbsp;
72
84
  {/if}
@@ -82,25 +94,25 @@
82
94
  {/if}
83
95
 
84
96
  <div class="level-right">
85
- {#if meta.total > 0}
97
+ {#if _total > 0}
86
98
  <nav class="pagination is-centered {size ? 'is-' + size : ''}">
87
99
  <button
88
100
  type="button"
89
101
  on:click={prev}
90
- class="pagination-previous {meta.offset == 0 ? 'is-disabled' : ''}">
91
- <Icon {size} icon={iconLeft} />
102
+ class="pagination-previous {_offset === 0 ? 'is-disabled' : ''}">
103
+ <Icon icon={iconLeft} />
92
104
  </button>
93
105
  <button
94
106
  type="button"
95
107
  on:click={next}
96
- class="pagination-next {currentPage + 1 == totalPages
108
+ class="pagination-next {currentPage + 1 === totalPages
97
109
  ? 'is-disabled'
98
110
  : ''}">
99
- <Icon {size} icon={iconRight} />
111
+ <Icon icon={iconRight} />
100
112
  </button>
101
113
  <ul class="pagination-list" data-cy="pagination-list">
102
114
  {#each pages as page}
103
- {#if page.p == "sep"}
115
+ {#if page.p === "sep"}
104
116
  <li>
105
117
  <span class="pagination-ellipsis">&hellip;</span>
106
118
  </li>
@@ -108,7 +120,7 @@
108
120
  <li>
109
121
  <button
110
122
  type="button"
111
- class="pagination-link {page.p == currentPage
123
+ class="pagination-link {page.p === currentPage
112
124
  ? 'is-current'
113
125
  : ''}"
114
126
  on:click={() => goto(page.p + 1)}>{page.p + 1}</button>
@@ -129,15 +141,32 @@
129
141
  const fire = createEventDispatcher();
130
142
 
131
143
  /**
132
- * Contains the total, count, limit, offset values
144
+ * Object containing `total`, `count`, `limit` and `offset` values
145
+ *
146
+ * **DEPRECATED**: Use `total`, `count`, `limit` and `offset` props instead
133
147
  */
134
148
  export let meta = {
135
149
  limit: 0,
136
150
  total: 0,
137
151
  count: 0,
138
152
  offset: 0,
139
- status: "",
140
153
  },
154
+ /**
155
+ * How many items are meant to be per page
156
+ */
157
+ limit = 0,
158
+ /**
159
+ * How many items are actually in this page
160
+ */
161
+ count = 0,
162
+ /**
163
+ * Total number of items available
164
+ */
165
+ total = 0,
166
+ /**
167
+ * Offset of the first item in this page
168
+ */
169
+ offset = 0,
141
170
  /**
142
171
  * Determines whether to show total or not
143
172
  */
@@ -159,7 +188,8 @@
159
188
  */
160
189
  entityName = "entries",
161
190
  /**
162
- * Size of the pagination
191
+ * Size of the pagination elements
192
+ * @type {''|'small'|'medium'|'large'}
163
193
  */
164
194
  size = "small",
165
195
  /**
@@ -175,15 +205,20 @@
175
205
  */
176
206
  iconLeft = "chevron-left",
177
207
  /**
178
- * Determines the number of rows displayed in a page.
208
+ * Displays the options for how many items to show per page
179
209
  */
180
210
  perPageOptions = [20, 50, 100, 150, 200, 250];
181
211
 
182
212
  let pages = [],
183
213
  _perPageOptions = 0;
184
214
 
215
+ $: _total = total || meta.total || 0;
216
+ $: _count = count || meta.count || 0;
217
+ $: _offset = offset || meta.offset || 0;
218
+ $: _limit = limit || meta.limit || 0;
219
+
185
220
  $: {
186
- let max = meta.total,
221
+ let max = _total,
187
222
  ppo = perPageOptions || [],
188
223
  ppmax = Math.max(...ppo),
189
224
  ret = {};
@@ -204,9 +239,9 @@
204
239
  _perPageOptions = ret;
205
240
  }
206
241
 
207
- $: totalItems = meta && meta.total ? meta.total : 0;
208
- $: currentPage = Math.floor(meta.offset / meta.limit);
209
- $: totalPages = Math.ceil(meta.total / (meta.limit || 1));
242
+ $: totalItems = meta && _total ? _total : 0;
243
+ $: currentPage = Math.floor(_offset / _limit);
244
+ $: totalPages = Math.ceil(_total / (_limit || 1));
210
245
  $: totalPages, currentPage, breakThreshold, calculatePages();
211
246
 
212
247
  function calculatePages() {
@@ -221,12 +256,12 @@
221
256
  ret.push({ p: i });
222
257
  } else if (i > total - 4) {
223
258
  ret.push({ p: i });
224
- } else if (i == Math.floor(total / 2)) {
259
+ } else if (i === Math.floor(total / 2)) {
225
260
  ret.push({ p: i });
226
261
  } else if (
227
- i == currentPage ||
228
- i == currentPage - 1 ||
229
- i == currentPage + 1
262
+ i === currentPage ||
263
+ i === currentPage - 1 ||
264
+ i === currentPage + 1
230
265
  ) {
231
266
  ret.push({ p: i });
232
267
  }
@@ -240,7 +275,7 @@
240
275
  if (total > breakThreshold) {
241
276
  for (var j = 0; j < ret.length; j++) {
242
277
  var page = ret[j].p;
243
- if (page != _prev + 1 && page != 0) {
278
+ if (page !== _prev + 1 && page !== 0) {
244
279
  items.push({ p: "sep" });
245
280
  }
246
281
  items.push(ret[j]);
@@ -255,31 +290,56 @@
255
290
 
256
291
  function setLimit(limit) {
257
292
  /**
258
- * Event used to set limit of pagination
293
+ * Event used to set a new `limit`.
294
+ *
295
+ * *Event Data:* `{currentPage, newLimit}`
259
296
  */
260
297
  fire("setLimit", { currentPage, newLimit: limit });
261
298
  }
262
- function goto(pagenum) {
263
- let limit = meta.limit,
264
- i = pagenum - 1,
265
- offset = limit * i;
266
- if (offset >= 0 && offset != meta.offset && offset < meta.total) {
299
+
300
+ /**
301
+ * Go to an arbitrary page number
302
+ * @param {int} targetPage
303
+ */
304
+ export function goto(targetPage) {
305
+ let limit = _limit,
306
+ i = targetPage - 1,
307
+ __offset = limit * i;
308
+ if (__offset >= 0 && __offset !== _offset && __offset < _total) {
267
309
  /**
268
- * Event triggered on paginate
310
+ * Event triggered on pagination change with new `offset` and current `limit` values.
311
+ *
312
+ * *Event Data:* `{offset, limit}`
269
313
  */
270
- fire("paginate", { offset, limit });
314
+ fire("paginate", { offset: __offset, limit });
271
315
  }
272
316
  }
273
- function prev() {
317
+
318
+ /**
319
+ * Go to the previous page
320
+ */
321
+ export function prev() {
274
322
  goto(currentPage);
275
323
  }
276
- function next() {
324
+
325
+ /**
326
+ * Go to the next page
327
+ */
328
+ export function next() {
277
329
  goto(currentPage + 2);
278
330
  }
279
- function first() {
331
+
332
+ /**
333
+ * Go to the first page
334
+ */
335
+ export function first() {
280
336
  goto(1);
281
337
  }
282
- function last() {
338
+
339
+ /**
340
+ * Go to the last page
341
+ */
342
+ export function last() {
283
343
  goto(totalPages);
284
344
  }
285
345
  </script>
@@ -22,6 +22,7 @@
22
22
  {#each column_keys as column}
23
23
  {#if isVisible(column)}
24
24
  <div class={classNames(column, row)} style={styles(column, row)}>
25
+ <!-- eslint-disable-next-line @ota-meshi/svelte/no-at-html-tags -->
25
26
  {@html transforms(column, row)}
26
27
  </div>
27
28
  {/if}
@@ -32,7 +32,7 @@ Requires `guide` to be `true`, Default: `false`
32
32
  bind:this={inputElement} />
33
33
 
34
34
  <script>
35
- import { onMount, tick } from "svelte";
35
+ import { onMount } from "svelte";
36
36
  import {
37
37
  createTextMaskInputElement,
38
38
  conformToMask,
@@ -7,7 +7,7 @@ export default function (password, options) {
7
7
  result.items = (options || []).slice().map((_opt) => {
8
8
  const opt = Object.assign({}, _opt);
9
9
  if (opt && opt.active) {
10
- if (opt.name == "kws_pv_min_length") {
10
+ if (opt.name === "kws_pv_min_length") {
11
11
  if (password && password.length >= opt.value) {
12
12
  opt.passed = true;
13
13
  }
@@ -24,7 +24,7 @@ export default function (password, options) {
24
24
  });
25
25
 
26
26
  result.overall =
27
- result.items.filter((el) => el.passed).length == result.items.length;
27
+ result.items.filter((el) => el.passed).length === result.items.length;
28
28
 
29
29
  return result;
30
30
  }
package/forms/actions.js CHANGED
@@ -3,6 +3,7 @@ import flatpickr from "flatpickr";
3
3
  function createFlatpickrAction(defaultOpts, hooks) {
4
4
  return function (
5
5
  node,
6
+ // eslint-disable-next-line no-unused-vars
6
7
  { opts, value, placeholder, klass, style, disabled, color }
7
8
  ) {
8
9
  const _opts = {};
@@ -50,7 +51,7 @@ function createFlatpickrAction(defaultOpts, hooks) {
50
51
  function applyColorClass(instance, color) {
51
52
  let contains = false;
52
53
  instance.calendarContainer.classList.forEach((c) => {
53
- if (c.charAt(3).toLowerCase() == "is-") {
54
+ if (c.charAt(3).toLowerCase() === "is-") {
54
55
  contains = c;
55
56
  }
56
57
  });
@@ -255,7 +255,9 @@ export default (function (win, doc) {
255
255
 
256
256
  // get mouse/finger coordinate
257
257
  function point(el, e) {
258
+ // eslint-disable-next-line no-extra-boolean-cast
258
259
  var x = !!e.touches ? e.touches[0].pageX : e.pageX,
260
+ // eslint-disable-next-line no-extra-boolean-cast
259
261
  y = !!e.touches ? e.touches[0].pageY : e.pageY,
260
262
  left = offset(el).l,
261
263
  top = offset(el).t;
@@ -396,18 +398,21 @@ export default (function (win, doc) {
396
398
  H_point_H = size(H_point).h,
397
399
  SV_point_W = SV_point_size.w,
398
400
  SV_point_H = SV_point_size.h;
401
+
402
+ function click(e) {
403
+ var t = e.target,
404
+ is_target = t === target || closest(t, target) === target;
405
+ if (is_target) {
406
+ create();
407
+ } else {
408
+ $.exit();
409
+ }
410
+ trigger(is_target ? "enter" : "exit", [$]);
411
+ }
412
+
399
413
  if (first) {
400
414
  picker.style.left = picker.style.top = "-9999px";
401
- function click(e) {
402
- var t = e.target,
403
- is_target = t === target || closest(t, target) === target;
404
- if (is_target) {
405
- create();
406
- } else {
407
- $.exit();
408
- }
409
- trigger(is_target ? "enter" : "exit", [$]);
410
- }
415
+
411
416
  if (events !== false) {
412
417
  on(events, target, click);
413
418
  }
@@ -430,7 +435,7 @@ export default (function (win, doc) {
430
435
  SV_point.style.right = SV_W - SV_point_W / 2 - SV_W * +HSV[1] + "px";
431
436
  SV_point.style.top = SV_H - SV_point_H / 2 - SV_H * +HSV[2] + "px";
432
437
  };
433
- $.exit = function (e) {
438
+ $.exit = function () {
434
439
  if (visible()) {
435
440
  visible().removeChild(picker);
436
441
  $.visible = false;
@@ -443,8 +448,8 @@ export default (function (win, doc) {
443
448
  return $;
444
449
  };
445
450
  function color(e) {
446
- var a = HSV2RGB(HSV),
447
- b = HSV2RGB([HSV[0], 1, 1]);
451
+ //var a = HSV2RGB(HSV),
452
+ var b = HSV2RGB([HSV[0], 1, 1]);
448
453
  SV.style.backgroundColor = "rgb(" + b.join(",") + ")";
449
454
  set_data(HSV);
450
455
  prevent(e);