@onsvisual/svelte-components 0.0.33 → 0.0.35

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.
@@ -13,6 +13,7 @@ export default class Select extends SvelteComponentTyped<{
13
13
  multiple?: boolean;
14
14
  maxSelected?: number;
15
15
  clearable?: boolean;
16
+ autoClear?: boolean;
16
17
  idKey?: string;
17
18
  labelKey?: string;
18
19
  colors?: any[];
@@ -21,10 +22,10 @@ export default class Select extends SvelteComponentTyped<{
21
22
  floatingConfig?: any;
22
23
  }, {
23
24
  input: CustomEvent<any>;
24
- change: CustomEvent<any>;
25
25
  focus: CustomEvent<any>;
26
26
  blur: CustomEvent<any>;
27
27
  clear: CustomEvent<any>;
28
+ change: CustomEvent<any>;
28
29
  } & {
29
30
  [evt: string]: CustomEvent<any>;
30
31
  }, {}> {
@@ -46,6 +47,7 @@ declare const __propDef: {
46
47
  multiple?: boolean;
47
48
  maxSelected?: number;
48
49
  clearable?: boolean;
50
+ autoClear?: boolean;
49
51
  idKey?: string;
50
52
  labelKey?: string;
51
53
  colors?: any[];
@@ -55,10 +57,10 @@ declare const __propDef: {
55
57
  };
56
58
  events: {
57
59
  input: CustomEvent<any>;
58
- change: CustomEvent<any>;
59
60
  focus: CustomEvent<any>;
60
61
  blur: CustomEvent<any>;
61
62
  clear: CustomEvent<any>;
63
+ change: CustomEvent<any>;
62
64
  } & {
63
65
  [evt: string]: CustomEvent<any>;
64
66
  };
@@ -8,3 +8,4 @@ export function formatDate(str: any, locale?: string, opts?: {
8
8
  export function commas(num: any): string;
9
9
  export function ascending(a: any, b: any): number;
10
10
  export function descending(a: any, b: any): number;
11
+ export function sleep(ms?: number): Promise<any>;
@@ -6,6 +6,7 @@ export default class AnalyticsBanner extends SvelteComponentTyped<{
6
6
  width?: "wide" | "wider";
7
7
  analyticsId?: string;
8
8
  analyticsProps?: any;
9
+ hideBanner?: boolean;
9
10
  usageCookies?: boolean;
10
11
  }, {
11
12
  [evt: string]: CustomEvent<any>;
@@ -20,6 +21,7 @@ declare const __propDef: {
20
21
  width?: "wide" | "wider";
21
22
  analyticsId?: string;
22
23
  analyticsProps?: object;
24
+ hideBanner?: boolean;
23
25
  usageCookies?: boolean;
24
26
  };
25
27
  events: {
@@ -1,5 +1,7 @@
1
1
  <script>
2
+ import { createEventDispatcher } from "svelte";
2
3
  import SelectInner from "svelte-select";
4
+ import { sleep } from "../../js/utils";
3
5
 
4
6
  /**
5
7
  * Unique id for the element
@@ -26,6 +28,11 @@
26
28
  * @type {boolean}
27
29
  */
28
30
  export let clearable = true;
31
+ /**
32
+ * Clear value on selection (default for "search" mode)
33
+ * @type {boolean}
34
+ */
35
+ export let autoClear = mode === "search";
29
36
  /**
30
37
  * A label to describe the element (expected for accessibility)
31
38
  * @type {string}
@@ -110,6 +117,16 @@
110
117
  : "No options available";
111
118
 
112
119
  let filterText = "";
120
+
121
+ const dispatch = createEventDispatcher();
122
+
123
+ async function handleChange(e) {
124
+ dispatch("change", e.detail);
125
+ if (autoClear) {
126
+ await sleep(100);
127
+ value = null;
128
+ }
129
+ }
113
130
  </script>
114
131
 
115
132
  <div class="ons-field" style="{style}">
@@ -131,8 +148,8 @@
131
148
  showChevron="{!value}"
132
149
  multiple="{multiple}"
133
150
  clearable="{clearable}"
151
+ on:change="{handleChange}"
134
152
  on:input
135
- on:change
136
153
  on:focus
137
154
  on:blur
138
155
  on:clear
package/dist/js/utils.js CHANGED
@@ -44,3 +44,5 @@ export const ascending = (a, b) =>
44
44
 
45
45
  export const descending = (a, b) =>
46
46
  a == null || b == null ? NaN : b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
47
+
48
+ export const sleep = (ms = 1000) => new Promise((resolve) => setTimeout(resolve, ms));
@@ -19,6 +19,11 @@
19
19
  * @type {object}
20
20
  */
21
21
  export let analyticsProps = {};
22
+ /**
23
+ * Use this to hide the banner (only initialises analytics if cookies already accepted)
24
+ * @type {boolean}
25
+ */
26
+ export let hideBanner = false;
22
27
  /**
23
28
  * Bind to this value if you need to know if cookies have been accepted
24
29
  * @type {boolean}
@@ -147,7 +152,7 @@
147
152
  const i18n = (text) => (lang == "cy" && texts[text] ? texts[text] : text);
148
153
  </script>
149
154
 
150
- {#if showBanner}
155
+ {#if showBanner && !hideBanner}
151
156
  <div
152
157
  class="ons-cookies-banner"
153
158
  role="region"
@@ -147,4 +147,5 @@
147
147
  <style>
148
148
  svg {
149
149
  overflow: visible;
150
+ width: auto;
150
151
  }</style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://onsvisual.github.io/svelte-components",