@kws3/ui 1.5.8 → 1.6.2

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
@@ -28,6 +28,10 @@ Instead of listing all the selected items inside the input., Default: `false`
28
28
  @param {string} [no_options_msg="No matching options"] - Message to display when no matching options are found, Default: `"No matching options"`
29
29
  @param {string} [remove_btn_tip="Remove"] - Tooltip text for Remove Item button. This `string` will precede the selected Item Name in the tooltip., Default: `"Remove"`
30
30
  @param {string} [remove_all_tip="Remove all"] - Tooltip text for the Clear All button, Default: `"Remove all"`
31
+ @param {HTMLElement|string} [dropdown_portal=undefined] - Where to render the dropdown list.
32
+ Can be a DOM element or a `string` with the CSS selector of the element.
33
+
34
+ By default it renders in a custom container appended to `document.body`., Default: `undefined`
31
35
  @param {string} [class=""] - CSS classes for input container, Default: `""`
32
36
 
33
37
  ### Events
@@ -105,38 +109,41 @@ Default value: `<span>{option[search_key] || option}</span>`
105
109
  on:click|stopPropagation={removeAll}
106
110
  style={shouldShowClearAll ? "" : "display: none;"} />
107
111
  {/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>
112
+ {#if rootContainer}
113
+ <div class="kws-searchableselect" use:portal={dropdown_portal}>
114
+ <ul
115
+ bind:this={dropdown}
116
+ class="options {single ? 'is-single' : 'is-multi'}"
117
+ class:hidden={!showOptions}>
118
+ {#each filteredOptions as option}
119
+ <li
120
+ on:mousedown|preventDefault|stopPropagation={() =>
121
+ handleOptionMouseDown(option)}
122
+ on:mouseenter|preventDefault|stopPropagation={() => {
123
+ activeOption = option;
124
+ }}
125
+ class:selected={isSelected(option)}
126
+ class:active={activeOption === option}>
127
+ <span class="kws-selected-icon"
128
+ ><Icon icon={selected_icon} size="small" /></span
129
+ ><!--
130
+ Slot containing text for each selectable item
131
+
132
+ Default value: `<span>{option[search_key] || option}</span>`
133
+ --><slot
134
+ search_key={used_search_key}
135
+ {option}>{option[used_search_key] || option}</slot>
136
+ </li>
137
+ {:else}
138
+ <li class="no-options">{no_options_msg}</li>
139
+ {/each}
140
+ </ul>
141
+ </div>
142
+ {/if}
136
143
  </div>
137
144
 
138
145
  <script>
139
- import { Icon } from "@kws3/ui";
146
+ import { Icon, portal } from "@kws3/ui";
140
147
  import { createEventDispatcher, onMount } from "svelte";
141
148
  import { createPopper } from "@popperjs/core";
142
149
 
@@ -156,6 +163,8 @@ Default value: `<span>{option[search_key] || option}</span>`
156
163
  },
157
164
  };
158
165
 
166
+ const rootContainerId = "kws-overlay-root";
167
+
159
168
  /**
160
169
  * Value of the Input
161
170
  *
@@ -234,6 +243,16 @@ Default value: `<span>{option[search_key] || option}</span>`
234
243
  */
235
244
  export let remove_all_tip = "Remove all";
236
245
 
246
+ /**
247
+ * Where to render the dropdown list.
248
+ * Can be a DOM element or a `string` with the CSS selector of the element.
249
+ *
250
+ * By default it renders in a custom container appended to `document.body`.
251
+ *
252
+ * @type { HTMLElement|string}
253
+ */
254
+ export let dropdown_portal = "#" + rootContainerId;
255
+
237
256
  /**
238
257
  * CSS classes for input container
239
258
  */
@@ -247,7 +266,7 @@ Default value: `<span>{option[search_key] || option}</span>`
247
266
  }
248
267
 
249
268
  //ensure we have a root container for all our hoisitng related stuff
250
- let rootContainerId = "kws-overlay-root";
269
+
251
270
  let rootContainer = document.getElementById(rootContainerId);
252
271
  if (!rootContainer) {
253
272
  rootContainer = document.createElement("div");
@@ -255,9 +274,6 @@ Default value: `<span>{option[search_key] || option}</span>`
255
274
  document.body.appendChild(rootContainer);
256
275
  }
257
276
 
258
- //this is the container that will hold the dropdown
259
- let container;
260
-
261
277
  const fire = createEventDispatcher();
262
278
 
263
279
  let el, //whole wrapping element
@@ -386,22 +402,7 @@ Default value: `<span>{option[search_key] || option}</span>`
386
402
  POPPER && POPPER.update();
387
403
  }
388
404
 
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
405
  onMount(() => {
403
- hoistDropdown();
404
-
405
406
  POPPER = createPopper(el, dropdown, {
406
407
  strategy: "fixed",
407
408
  placement: "bottom-start",
@@ -416,10 +417,6 @@ Default value: `<span>{option[search_key] || option}</span>`
416
417
 
417
418
  return () => {
418
419
  POPPER.destroy();
419
- //remove hoisted items
420
- container &&
421
- container.parentNode &&
422
- container.parentNode.removeChild(container);
423
420
  };
424
421
  });
425
422
 
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.8",
3
+ "version": "1.6.2",
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": "83046c7c9f3208ecace614fe22b152f00248bd06"
32
+ "gitHead": "7f64ac8547337d2835c5c6fb493f7d05c5451e1c"
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
  }