@kws3/ui 1.6.3 → 1.6.7

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.
@@ -166,6 +166,15 @@
166
166
  qfilters[qqp[0]] = qqp[1];
167
167
  }
168
168
 
169
+ if (hasFilters) {
170
+ for (let i in _filters) {
171
+ let filter = _filters[i];
172
+ if (typeof qfilters[filter.name] == "undefined") {
173
+ qfilters[filter.name] = "";
174
+ }
175
+ }
176
+ }
177
+
169
178
  filterVals = qfilters;
170
179
  }
171
180
 
@@ -186,7 +195,7 @@
186
195
  let ret = [];
187
196
  ret.push(query);
188
197
  for (var i in filterVals) {
189
- ret.push(i + ":" + filterVals[i]);
198
+ filterVals[i] && ret.push(i + ":" + filterVals[i]);
190
199
  }
191
200
  /**
192
201
  * Event triggered on search
@@ -29,7 +29,8 @@
29
29
  <tr
30
30
  in:fly={{ x: 20, delay: 25 * row_index }}
31
31
  on:click|stopPropagation={rowClick}
32
- class:is-selected={rowActive}>
32
+ class:is-selected={rowActive}
33
+ class:is-checked={checked}>
33
34
  {#if bulk_actions}
34
35
  <td style="vertical-align:middle;">
35
36
  <Checkbox
@@ -55,7 +56,10 @@
55
56
  {/each}
56
57
  </tr>
57
58
  {:else}
58
- <tr on:click|stopPropagation={rowClick} class:is-selected={rowActive}>
59
+ <tr
60
+ on:click|stopPropagation={rowClick}
61
+ class:is-selected={rowActive}
62
+ class:is-checked={checked}>
59
63
  {#if bulk_actions}
60
64
  <td style="vertical-align:middle;">
61
65
  <Checkbox
@@ -242,7 +242,6 @@ Default value: `<span>{option[search_key] || option}</span>`
242
242
  * Tooltip text for the Clear All button
243
243
  */
244
244
  export let remove_all_tip = "Remove all";
245
-
246
245
  /**
247
246
  * Where to render the dropdown list.
248
247
  * Can be a DOM element or a `string` with the CSS selector of the element.
@@ -20,6 +20,10 @@ this property of each object will be returned as the value, Default: `"id"`
20
20
  @param {string} [selected_icon="check"] - Icon used to mark selected items in dropdown list, Default: `"check"`
21
21
  @param {string} [no_options_msg="No matching options"] - Message to display when no matching options are found, Default: `"No matching options"`
22
22
  @param {string} [remove_all_tip="Clear Selection"] - Tooltip text for the Clear selection button, Default: `"Clear Selection"`
23
+ @param {HTMLElement|string} [dropdown_portal=undefined] - Where to render the dropdown list.
24
+ Can be a DOM element or a `string` with the CSS selector of the element.
25
+
26
+ By default it renders in a custom container appended to `document.body`., Default: `undefined`
23
27
  @param {string} [class=""] - CSS classes for input container, Default: `""`
24
28
 
25
29
  ### Events
@@ -48,6 +52,7 @@ Default value: `<span>{option[search_key] || option}</span>`
48
52
  {selected_icon}
49
53
  {remove_all_tip}
50
54
  {no_options_msg}
55
+ {dropdown_portal}
51
56
  on:change={change}
52
57
  on:blur={blur}
53
58
  let:option
@@ -67,6 +72,8 @@ Default value: `<span>{option[search_key] || option}</span>`
67
72
 
68
73
  const fire = createEventDispatcher();
69
74
 
75
+ const rootContainerId = "kws-overlay-root";
76
+
70
77
  /**
71
78
  * Value of the Input
72
79
  *
@@ -127,6 +134,15 @@ Default value: `<span>{option[search_key] || option}</span>`
127
134
  * Tooltip text for the Clear selection button
128
135
  */
129
136
  export let remove_all_tip = "Clear Selection";
137
+ /**
138
+ * Where to render the dropdown list.
139
+ * Can be a DOM element or a `string` with the CSS selector of the element.
140
+ *
141
+ * By default it renders in a custom container appended to `document.body`.
142
+ *
143
+ * @type { HTMLElement|string}
144
+ */
145
+ export let dropdown_portal = "#" + rootContainerId;
130
146
 
131
147
  /**
132
148
  * CSS classes for input container
@@ -7,11 +7,14 @@
7
7
  @param {''|'small'|'medium'|'large'} [icon_size="small"] - Size of the trigger icon displayed when default slot has no content, Default: `"small"`
8
8
  @param {string} [trigger="click"] - Determines the events that cause the Popover to show. Multiple event names are separated by spaces.
9
9
 
10
- **Examples:** `click`, `mouseenter`, `mouseenter focus`, Default: `"click"`
10
+ **Examples:** `click`, `mouseenter`, `mouseenter focus`
11
+
12
+ If you would like to trigger the popover programatically only, you can use `manual`., Default: `"click"`
11
13
  @param {string} [placement="auto"] - Preferred placement of the Popover
12
14
 
13
15
  Available options: <a target="_blank" href="https://atomiks.github.io/tippyjs/v6/all-props/#placement">https://atomiks.github.io/tippyjs/v6/all-props/#placement</a>, Default: `"auto"`
14
16
  @param {boolean} [interactive=false] - Allows you to interact with the Popover content, when turned on, Default: `false`
17
+ @param {boolean} [hide_on_click=true] - Whether the popover should hide on clicking outside of it, Default: `true`
15
18
  @param {object} [external_target=null] - Specify a target node reference to use as the Popover content
16
19
 
17
20
  When set to `null`, it will use the content of the `popover` slot, Default: `null`
@@ -20,6 +23,18 @@ When set to `null`, it will use the content of the `popover` slot, Default: `nul
20
23
  It can be any CSS value associated with `max-width` property, including `"none"`, Default: `"none"`
21
24
  @param {string} [style=""] - Inline CSS for Popover trigger, Default: `""`
22
25
  @param {string} [class=""] - CSS classes for Popover trigger, Default: `""`
26
+ @param {function} [open()] - Open function
27
+ @param {function} [close()] - Close function
28
+ @param {function} [enable()] - Enable function
29
+ @param {function} [disable()] - Disable function
30
+ @param {function} [setProps(props)] - SetProps function
31
+
32
+ ### Events
33
+ - `opening` - Triggered when popover is opening
34
+ - `open` - Triggered when popover is opened
35
+ - `closing` - Triggered when popover is closing
36
+ - `close` - Triggered when popover is closed
37
+ - `trigger` - Triggered when popover is triggered either programatically or by user interaction
23
38
 
24
39
  ### Slots
25
40
  - `<slot name="default" />` - Content of the Popover Trigger, by default it displays an Icon
@@ -28,11 +43,18 @@ It can be any CSS value associated with `max-width` property, including `"none"`
28
43
  -->
29
44
  <span
30
45
  use:popover={{ content: targetNode }}
46
+ bind:this={popoverParent}
47
+ on:showing={popoverShowing}
48
+ on:shown={popoverShown}
49
+ on:hiding={popoverHiding}
50
+ on:hidden={popoverHidden}
51
+ on:triggered={popoverTriggered}
31
52
  data-tippy-trigger={trigger}
32
53
  data-tippy-placement={placement}
33
54
  data-tippy-offset="[0, 10]"
34
55
  data-tippy-interactive={interactive ? "true" : "false"}
35
56
  data-tippy-maxWidth={max_width}
57
+ data-tippy-hideOnClick={hide_on_click ? "true" : "false"}
36
58
  style={_style}
37
59
  class={klass}>
38
60
  <!--Content of the Popover Trigger, by default it displays an Icon--><slot
@@ -51,8 +73,12 @@ It can be any CSS value associated with `max-width` property, including `"none"`
51
73
  </style>
52
74
 
53
75
  <script>
76
+ import { createEventDispatcher } from "svelte";
54
77
  import { popover } from "./Tooltip";
55
78
  import { Icon } from "@kws3/ui";
79
+
80
+ const fire = createEventDispatcher();
81
+
56
82
  /**
57
83
  * Icon used when default slot has no content
58
84
  */
@@ -71,6 +97,8 @@ It can be any CSS value associated with `max-width` property, including `"none"`
71
97
  * Determines the events that cause the Popover to show. Multiple event names are separated by spaces.
72
98
  *
73
99
  * **Examples:** `click`, `mouseenter`, `mouseenter focus`
100
+ *
101
+ * If you would like to trigger the popover programatically only, you can use `manual`.
74
102
  */
75
103
  export let trigger = "click";
76
104
  /**
@@ -83,6 +111,10 @@ It can be any CSS value associated with `max-width` property, including `"none"`
83
111
  * Allows you to interact with the Popover content, when turned on
84
112
  */
85
113
  export let interactive = false;
114
+ /**
115
+ * Whether the popover should hide on clicking outside of it
116
+ */
117
+ export let hide_on_click = true;
86
118
  /**
87
119
  * Specify a target node reference to use as the Popover content
88
120
  *
@@ -106,7 +138,66 @@ It can be any CSS value associated with `max-width` property, including `"none"`
106
138
  let klass = "";
107
139
  export { klass as class };
108
140
 
109
- let popoverNode;
141
+ let popoverNode, popoverParent;
142
+
143
+ const getInstance = () => {
144
+ return popoverParent._tippy;
145
+ };
146
+
147
+ export function open() {
148
+ getInstance().show();
149
+ }
150
+
151
+ export function close() {
152
+ getInstance().hide();
153
+ }
154
+
155
+ export function enable() {
156
+ getInstance().enable();
157
+ }
158
+
159
+ export function disable() {
160
+ getInstance().disable();
161
+ }
162
+
163
+ export function setProps(props) {
164
+ getInstance().setProps(props);
165
+ }
166
+
167
+ const popoverShowing = ({ detail }) => {
168
+ /**
169
+ * Triggered when popover is opening
170
+ */
171
+ fire("opening", detail);
172
+ };
173
+
174
+ const popoverShown = ({ detail }) => {
175
+ /**
176
+ * Triggered when popover is opened
177
+ */
178
+ fire("open", detail);
179
+ };
180
+
181
+ const popoverHiding = ({ detail }) => {
182
+ /**
183
+ * Triggered when popover is closing
184
+ */
185
+ fire("closing", detail);
186
+ };
187
+
188
+ const popoverHidden = ({ detail }) => {
189
+ /**
190
+ * Triggered when popover is closed
191
+ */
192
+ fire("close", detail);
193
+ };
194
+
195
+ const popoverTriggered = ({ detail }) => {
196
+ /**
197
+ * Triggered when popover is triggered either programatically or by user interaction
198
+ */
199
+ fire("trigger", detail);
200
+ };
110
201
 
111
202
  $: _style = `cursor:pointer;${style}`;
112
203
  $: targetNode = external_target ? external_target : popoverNode;
@@ -29,7 +29,23 @@ function createTippyAction(defaultOpts) {
29
29
  let instance;
30
30
 
31
31
  function makeOptions() {
32
- return Object.assign({}, defaultOpts, opts);
32
+ return Object.assign({}, defaultOpts, opts, {
33
+ onShow(instance) {
34
+ dispatch("showing", { instance });
35
+ },
36
+ onShown(instance) {
37
+ dispatch("shown", { instance });
38
+ },
39
+ onHide(instance) {
40
+ dispatch("hiding", { instance });
41
+ },
42
+ onHidden(instance) {
43
+ dispatch("hidden", { instance });
44
+ },
45
+ onTrigger(instance) {
46
+ dispatch("triggered", { instance });
47
+ },
48
+ });
33
49
  }
34
50
 
35
51
  function remakeInstance() {
@@ -51,6 +67,11 @@ function createTippyAction(defaultOpts) {
51
67
 
52
68
  makeInstance();
53
69
 
70
+ function dispatch(type, detail) {
71
+ const e = new CustomEvent(type, { bubbles: false, detail });
72
+ node.dispatchEvent(e);
73
+ }
74
+
54
75
  return {
55
76
  update(_opts) {
56
77
  opts = _opts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kws3/ui",
3
- "version": "1.6.3",
3
+ "version": "1.6.7",
4
4
  "description": "UI components for use with Svelte v3 applications.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -29,5 +29,5 @@
29
29
  "text-mask-core": "^5.1.2",
30
30
  "tippy.js": "^6.3.1"
31
31
  },
32
- "gitHead": "a84e962f160c41cdcc6c2b7827b815d1f1b63e05"
32
+ "gitHead": "12e85eba3be37c2d133c8ac047e4dbf651378c18"
33
33
  }
package/styles/Grid.scss CHANGED
@@ -4,12 +4,14 @@ $kws-gridview-th-background: $table-background-color !default;
4
4
  $kws-gridview-th-color: $text !default;
5
5
  $kws-gridview-tag-margin: 0 0.125rem 0.125rem 0 !default;
6
6
  $kws-gridview-icon-size: 1.5em !default;
7
+ $kws-gridview-checked-row-background: $primary-light !default;
7
8
 
8
9
  .data-table .table {
9
10
  box-shadow: $kws-gridview-box-shadow;
10
11
  th {
11
12
  background: $kws-gridview-th-background;
12
13
  color: $kws-gridview-th-color;
14
+ vertical-align: middle;
13
15
  }
14
16
  &.is-bordered {
15
17
  tr {
@@ -43,4 +45,11 @@ $kws-gridview-icon-size: 1.5em !default;
43
45
  cursor: pointer;
44
46
  }
45
47
  }
48
+
49
+ tr.is-checked {
50
+ background-color: $kws-gridview-checked-row-background !important;
51
+ td {
52
+ background-color: $kws-gridview-checked-row-background !important;
53
+ }
54
+ }
46
55
  }