@kws3/ui 1.5.7 → 1.6.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.
@@ -18,10 +18,10 @@
18
18
 
19
19
  -->
20
20
 
21
- <form on:submit|preventDefault={dosearch}>
22
- <div class="field has-addons">
21
+ <form class="kws-grid-search" on:submit|preventDefault={dosearch}>
22
+ <div class="field has-addons outer-level-field">
23
23
  {#if hasSearch}
24
- <p class="control is-expanded">
24
+ <div class="control is-expanded main-search">
25
25
  <input
26
26
  class="input {query != '' && query != undefined
27
27
  ? filter_in_use_class
@@ -29,7 +29,7 @@
29
29
  type="text"
30
30
  {placeholder}
31
31
  bind:value={query} />
32
- </p>
32
+ </div>
33
33
  {/if}
34
34
  {#if hasFilters}
35
35
  {#each _filters as filter, i}
@@ -45,18 +45,25 @@
45
45
  {filter_label_map} />
46
46
  {/each}
47
47
  {/if}
48
- {#if changed}
49
- <p class="control">
50
- <button class="button is-danger" type="button" on:click={doresetSearch}>
51
- <Icon icon="close" size="small" />
48
+
49
+ <div class="field has-addons action-buttons-field">
50
+ {#if changed}
51
+ <div class="control is-expanded clear-search">
52
+ <button
53
+ class="button is-danger"
54
+ type="button"
55
+ on:click={doresetSearch}>
56
+ <Icon icon="close" size="small" />
57
+ <span class="is-hidden-desktop is-hidden-tablet">Clear</span>
58
+ </button>
59
+ </div>
60
+ {/if}
61
+ <div class="control is-expanded search-submit">
62
+ <button class="button is-primary" type="submit">
63
+ <Icon icon="search" size="small" /> <span>Search</span>
52
64
  </button>
53
- </p>
54
- {/if}
55
- <p class="control">
56
- <button class="button is-primary" type="submit">
57
- <Icon icon="search" size="small" /> <span>Search</span>
58
- </button>
59
- </p>
65
+ </div>
66
+ </div>
60
67
  </div>
61
68
  </form>
62
69
 
@@ -11,7 +11,7 @@
11
11
  -->
12
12
 
13
13
  {#if filter.type == "multiselect"}
14
- <div class="control" style={filterWidthStyle}>
14
+ <div class="control search-control" style={filterWidthStyle}>
15
15
  <MultiSelect
16
16
  options={sanitizedOptions}
17
17
  placeholder={`Any ${name}`}
@@ -23,14 +23,14 @@
23
23
  class={hilightClass} />
24
24
  </div>
25
25
  {:else if filter.type == "date"}
26
- <div class="control" style={filterWidthStyle}>
26
+ <div class="control search-control" style={filterWidthStyle}>
27
27
  <Datepicker
28
28
  class={hilightClass}
29
29
  bind:value={filterVals[filter.name]}
30
30
  placeholder="{capitaliseFirstLetter(name)} Date" />
31
31
  </div>
32
32
  {:else if filter.type == "daterange"}
33
- <div class="control" style={filterWidthStyle}>
33
+ <div class="control search-control" style={filterWidthStyle}>
34
34
  <Datepicker
35
35
  class={hilightClass}
36
36
  bind:value={filterVals[filter.name]}
@@ -38,7 +38,7 @@
38
38
  placeholder="{capitaliseFirstLetter(name)} Date Range" />
39
39
  </div>
40
40
  {:else if filter.options.length > 10}
41
- <div class="control" style={filterWidthStyle}>
41
+ <div class="control search-control" style={filterWidthStyle}>
42
42
  <SearchableSelect
43
43
  options={sanitizedOptions}
44
44
  placeholder={`Any ${name}`}
@@ -49,7 +49,7 @@
49
49
  </div>
50
50
  {:else}
51
51
  <div
52
- class="select {hilightClass}"
52
+ class="select control search-control {hilightClass}"
53
53
  style={filterWidthStyle}
54
54
  data-cy="select-container">
55
55
  <select
@@ -47,7 +47,7 @@
47
47
  {:else}
48
48
  <div class="level-item">
49
49
  {#if showTotal}
50
- <strong>Total {meta.total} {entityName}</strong>
50
+ <strong>Total {totalItems} {entityName}</strong>
51
51
  {:else if showCurrent}
52
52
  {#if meta.total > 0}Showing {meta.offset * 1 + 1} to {meta.offset *
53
53
  1 +
@@ -72,12 +72,12 @@
72
72
  {/if}
73
73
  {/if}
74
74
  {#if showTotal}
75
- <strong>{meta.total} {entityName}</strong>
75
+ <strong>{totalItems} {entityName}</strong>
76
76
  {/if}
77
77
  </div>
78
78
  {:else if showPerPage && showTotal && !showCurrent}
79
79
  <div class="level-item pagination-showing">
80
- <strong>Total {meta.total} {entityName}</strong>
80
+ <strong>Total {totalItems} {entityName}</strong>
81
81
  </div>
82
82
  {/if}
83
83
 
@@ -204,6 +204,7 @@
204
204
  _perPageOptions = ret;
205
205
  }
206
206
 
207
+ $: totalItems = meta && meta.total ? meta.total : 0;
207
208
  $: currentPage = Math.floor(meta.offset / meta.limit);
208
209
  $: totalPages = Math.ceil(meta.total / (meta.limit || 1));
209
210
  $: totalPages, currentPage, breakThreshold, calculatePages();
@@ -105,38 +105,41 @@ Default value: `<span>{option[search_key] || option}</span>`
105
105
  on:click|stopPropagation={removeAll}
106
106
  style={shouldShowClearAll ? "" : "display: none;"} />
107
107
  {/if}
108
-
109
- <ul
110
- bind:this={dropdown}
111
- class="options {single ? 'is-single' : 'is-multi'}"
112
- class:hidden={!showOptions}>
113
- {#each filteredOptions as option}
114
- <li
115
- on:mousedown|preventDefault|stopPropagation={() =>
116
- handleOptionMouseDown(option)}
117
- on:mouseenter|preventDefault|stopPropagation={() => {
118
- activeOption = option;
119
- }}
120
- class:selected={isSelected(option)}
121
- class:active={activeOption === option}>
122
- <span class="kws-selected-icon"
123
- ><Icon icon={selected_icon} size="small" /></span
124
- ><!--
125
- Slot containing text for each selectable item
126
-
127
- Default value: `<span>{option[search_key] || option}</span>`
128
- --><slot
129
- search_key={used_search_key}
130
- {option}>{option[used_search_key] || option}</slot>
131
- </li>
132
- {:else}
133
- <li class="no-options">{no_options_msg}</li>
134
- {/each}
135
- </ul>
108
+ {#if rootContainer}
109
+ <div class="kws-searchableselect" use:portal={"#" + rootContainerId}>
110
+ <ul
111
+ bind:this={dropdown}
112
+ class="options {single ? 'is-single' : 'is-multi'}"
113
+ class:hidden={!showOptions}>
114
+ {#each filteredOptions as option}
115
+ <li
116
+ on:mousedown|preventDefault|stopPropagation={() =>
117
+ handleOptionMouseDown(option)}
118
+ on:mouseenter|preventDefault|stopPropagation={() => {
119
+ activeOption = option;
120
+ }}
121
+ class:selected={isSelected(option)}
122
+ class:active={activeOption === option}>
123
+ <span class="kws-selected-icon"
124
+ ><Icon icon={selected_icon} size="small" /></span
125
+ ><!--
126
+ Slot containing text for each selectable item
127
+
128
+ Default value: `<span>{option[search_key] || option}</span>`
129
+ --><slot
130
+ search_key={used_search_key}
131
+ {option}>{option[used_search_key] || option}</slot>
132
+ </li>
133
+ {:else}
134
+ <li class="no-options">{no_options_msg}</li>
135
+ {/each}
136
+ </ul>
137
+ </div>
138
+ {/if}
136
139
  </div>
137
140
 
138
141
  <script>
139
- import { Icon } from "@kws3/ui";
142
+ import { Icon, portal } from "@kws3/ui";
140
143
  import { createEventDispatcher, onMount } from "svelte";
141
144
  import { createPopper } from "@popperjs/core";
142
145
 
@@ -247,7 +250,7 @@ Default value: `<span>{option[search_key] || option}</span>`
247
250
  }
248
251
 
249
252
  //ensure we have a root container for all our hoisitng related stuff
250
- let rootContainerId = "kws-overlay-root";
253
+ const rootContainerId = "kws-overlay-root";
251
254
  let rootContainer = document.getElementById(rootContainerId);
252
255
  if (!rootContainer) {
253
256
  rootContainer = document.createElement("div");
@@ -255,9 +258,6 @@ Default value: `<span>{option[search_key] || option}</span>`
255
258
  document.body.appendChild(rootContainer);
256
259
  }
257
260
 
258
- //this is the container that will hold the dropdown
259
- let container;
260
-
261
261
  const fire = createEventDispatcher();
262
262
 
263
263
  let el, //whole wrapping element
@@ -386,22 +386,7 @@ Default value: `<span>{option[search_key] || option}</span>`
386
386
  POPPER && POPPER.update();
387
387
  }
388
388
 
389
- /**
390
- * Moves dropdown to rootContainer, so that
391
- * overflows etc do not mess with it
392
- */
393
- function hoistDropdown() {
394
- if (!container) {
395
- container = document.createElement("div");
396
- container.className = "kws-searchableselect";
397
- rootContainer.appendChild(container);
398
- container.appendChild(dropdown);
399
- }
400
- }
401
-
402
389
  onMount(() => {
403
- hoistDropdown();
404
-
405
390
  POPPER = createPopper(el, dropdown, {
406
391
  strategy: "fixed",
407
392
  placement: "bottom-start",
@@ -416,10 +401,6 @@ Default value: `<span>{option[search_key] || option}</span>`
416
401
 
417
402
  return () => {
418
403
  POPPER.destroy();
419
- //remove hoisted items
420
- container &&
421
- container.parentNode &&
422
- container.parentNode.removeChild(container);
423
404
  };
424
405
  });
425
406
 
package/index.js CHANGED
@@ -21,6 +21,8 @@ export {
21
21
  } from "./helpers/FloatingUI";
22
22
  export { default as FloatingUIOutput } from "./helpers/FloatingUI/FloatingUIOutput.svelte";
23
23
  export { default as Floatie } from "./helpers/FloatingUI/Floatie.svelte";
24
+ export { portal } from "svelte-portal";
25
+ export { default as Portal } from "svelte-portal";
24
26
 
25
27
  export { default as ConfirmButton } from "./buttons/ConfirmButton.svelte";
26
28
  export { default as DeleteButton } from "./buttons/DeleteButton.svelte";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kws3/ui",
3
- "version": "1.5.7",
3
+ "version": "1.6.1",
4
4
  "description": "UI components for use with Svelte v3 applications.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -25,8 +25,9 @@
25
25
  "dependencies": {
26
26
  "apexcharts": "^3.32.0",
27
27
  "flatpickr": "^4.5.2",
28
+ "svelte-portal": "^2.1.2",
28
29
  "text-mask-core": "^5.1.2",
29
30
  "tippy.js": "^6.3.1"
30
31
  },
31
- "gitHead": "68ac0e4a0c88268dac739f25bcc16fab2b6ea941"
32
+ "gitHead": "ea18e1e71037d787675491be9c0260b901bf9e7a"
32
33
  }
@@ -0,0 +1,60 @@
1
+ .kws-grid-search {
2
+ .is-not-in-use {
3
+ }
4
+ .is-in-use {
5
+ border-color: transparentize($success, 0.5);
6
+ box-shadow: 0 0 3px rgba(0, 0, 0, 0.23) !important;
7
+ z-index: 2;
8
+ }
9
+
10
+ .clear-search {
11
+ .button {
12
+ .icon {
13
+ margin-right: calc(-0.5em - 1px);
14
+ }
15
+ }
16
+ }
17
+ }
18
+
19
+ @include mobile {
20
+ .kws-grid-search {
21
+ .field.outer-level-field {
22
+ flex-wrap: wrap;
23
+ .control {
24
+ margin-bottom: 0.5rem;
25
+ }
26
+ .main-search {
27
+ width: 100%;
28
+ .input {
29
+ border-bottom-right-radius: $radius !important;
30
+ border-top-right-radius: $radius !important;
31
+ }
32
+ }
33
+ .search-control {
34
+ max-width: 100% !important;
35
+ width: auto !important;
36
+ flex-grow: 1;
37
+ flex-shrink: 1;
38
+ select {
39
+ width: 100%;
40
+ }
41
+ }
42
+ }
43
+ .field.action-buttons-field {
44
+ width: 100%;
45
+ .clear-search,
46
+ .search-submit {
47
+ .button {
48
+ width: 100%;
49
+ }
50
+ }
51
+ .clear-search {
52
+ .button {
53
+ .icon {
54
+ margin-right: 0.25em;
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
@@ -7,7 +7,7 @@
7
7
  margin: 0 !important;
8
8
  padding: 0.2rem 0;
9
9
  &:first-child {
10
- padding-left: calc(0.625em - 1px);
10
+ padding-left: calc(0.625rem - 1px);
11
11
  border-radius: 0 0 0 $radius-large;
12
12
  }
13
13
  &:last-child {
@@ -17,8 +17,8 @@
17
17
  .select {
18
18
  height: auto;
19
19
  select {
20
- padding-top: 0.2em;
21
- padding-bottom: 0.2em;
20
+ padding-top: 0.2rem;
21
+ padding-bottom: 0.2rem;
22
22
  border: none;
23
23
  background: transparent;
24
24
  color: $primary;
@@ -35,3 +35,25 @@
35
35
  }
36
36
  }
37
37
  }
38
+
39
+ @include mobile {
40
+ .sorting-filters {
41
+ margin-top: 0rem;
42
+ .field {
43
+ justify-content: center;
44
+ }
45
+ .control {
46
+ &:first-child {
47
+ border-radius: $radius-large 0 0 $radius-large;
48
+ }
49
+ &:last-child {
50
+ border-radius: 0 $radius-large $radius-large 0;
51
+ flex-grow: 1;
52
+ flex-shrink: 1;
53
+ .select {
54
+ width: 100%;
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
@@ -8,57 +8,90 @@ $kws-pagination-item-disabled-color: $grey !default;
8
8
  $kws-pagination-item-ellipsis-background: $white-bis !default;
9
9
  $kws-pagination-item-ellipsis-border-color: $grey-lighter !default;
10
10
  $kws-pagination-item-active-background: $success !default;
11
- $kws-pagination-item-active-color: findColorInvert($kws-pagination-item-active-background) !default;
11
+ $kws-pagination-item-active-color: findColorInvert(
12
+ $kws-pagination-item-active-background
13
+ ) !default;
12
14
 
13
- $kws-pagination-frame-box-shadow: 0 0.125rem 0.1875rem rgba(0, 0, 0, 0.1), 0 0 0 0.0625rem rgba(0, 0, 0, 0.1) !default;
15
+ $kws-pagination-frame-box-shadow: 0 0.125rem 0.1875rem rgba(0, 0, 0, 0.1),
16
+ 0 0 0 0.0625rem rgba(0, 0, 0, 0.1) !default;
14
17
  $kws-pagination-frame-background: linear-gradient(#fff, #fafafa);
15
18
 
16
-
17
- .pagination{
18
- &.is-small{
19
- .pagination-previous, .pagination-next, .pagination-link, .pagination-ellipsis{
20
- min-height:1.8rem;
19
+ .pagination {
20
+ &.is-small {
21
+ .pagination-previous,
22
+ .pagination-next,
23
+ .pagination-link,
24
+ .pagination-ellipsis {
25
+ min-height: 1.8rem;
21
26
  }
22
27
  }
23
- .pagination-previous, .pagination-next{
24
- padding-left:0;
25
- padding-right:0;
28
+ .pagination-previous,
29
+ .pagination-next {
30
+ padding-left: 0;
31
+ padding-right: 0;
26
32
  }
27
- .pagination-previous, .pagination-next, .pagination-link, .pagination-ellipsis{
28
- background:$kws-pagination-item-background;
33
+ .pagination-previous,
34
+ .pagination-next,
35
+ .pagination-link,
36
+ .pagination-ellipsis {
37
+ background: $kws-pagination-item-background;
29
38
  color: $kws-pagination-item-color;
30
39
  border: $kws-pagination-item-border;
31
- margin:0;
32
- border-radius:0;
33
- min-height:100%;
34
- margin-left:-1px;
35
- &.is-disabled{
36
- background:$kws-pagination-item-disabled-background;
37
- color:$kws-pagination-item-disabled-color;
40
+ margin: 0;
41
+ border-radius: 0;
42
+ min-height: 100%;
43
+ margin-left: -1px;
44
+ &.is-disabled {
45
+ background: $kws-pagination-item-disabled-background;
46
+ color: $kws-pagination-item-disabled-color;
38
47
  }
39
- &:hover{
40
- border:$kws-pagination-item-hover-border;
41
- color:$kws-pagination-item-hover-color;
48
+ &:hover {
49
+ border: $kws-pagination-item-hover-border;
50
+ color: $kws-pagination-item-hover-color;
42
51
  }
43
52
  }
44
- .pagination-ellipsis{
45
- background:$kws-pagination-item-ellipsis-background;
46
- border-color:$kws-pagination-item-ellipsis-border-color;
53
+ .pagination-ellipsis {
54
+ background: $kws-pagination-item-ellipsis-background;
55
+ border-color: $kws-pagination-item-ellipsis-border-color;
47
56
  }
48
- .pagination-link.is-current{
49
- text-shadow:none;
57
+ .pagination-link.is-current {
58
+ text-shadow: none;
50
59
  color: $kws-pagination-item-active-color;
51
60
  background: $kws-pagination-item-active-background;
52
61
  border-color: $kws-pagination-item-active-background;
53
62
  }
54
- .pagination-list{
55
- &.pagination-limit-chooser{
56
- order:inherit;
63
+ .pagination-list {
64
+ &.pagination-limit-chooser {
65
+ order: inherit;
57
66
  }
58
67
  }
59
68
  }
60
- .pagination_frame.has-frame{
61
- padding:0.625rem;
69
+ .pagination_frame.has-frame {
70
+ padding: 0.625rem;
62
71
  box-shadow: $kws-pagination-frame-box-shadow;
63
72
  background: $kws-pagination-frame-background;
64
- }
73
+ }
74
+
75
+ @include mobile {
76
+ .pagination_frame {
77
+ .level {
78
+ display: flex;
79
+ flex-wrap: wrap;
80
+ .level-right {
81
+ margin-top: 0.75rem;
82
+ flex-basis: 100%;
83
+ }
84
+ }
85
+ .pagination-showing {
86
+ margin-bottom: 0;
87
+ }
88
+ .pagination {
89
+ .pagination-previous,
90
+ .pagination-next,
91
+ .pagination-link,
92
+ .pagination-ellipsis {
93
+ margin: 0.25rem;
94
+ }
95
+ }
96
+ }
97
+ }
@@ -11,6 +11,13 @@ $kws-select-selecting-background: $primary !default;
11
11
  $kws-select-selected-color: $primary-dark !default;
12
12
  $kws-select-selected-background: $primary-light !default;
13
13
 
14
+ $__modal-z: 41 !default;
15
+ @if $modal-z {
16
+ $__modal-z: $modal-z;
17
+ }
18
+
19
+ $kws-select-options-z-index: $__modal-z + 1 !default;
20
+
14
21
  .kws-searchableselect {
15
22
  position: relative;
16
23
  align-items: center;
@@ -205,5 +212,6 @@ $kws-select-selected-background: $primary-light !default;
205
212
  #kws-overlay-root {
206
213
  .kws-searchableselect {
207
214
  position: absolute;
215
+ z-index: $kws-select-options-z-index;
208
216
  }
209
217
  }