@softwareone/spi-sv5-library 1.11.4 → 1.11.5

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.
@@ -24,6 +24,7 @@
24
24
  <div class="accordion-content">
25
25
  <section class="header" class:is-open={isOpen}>
26
26
  <button
27
+ type="button"
27
28
  class="button"
28
29
  onclick={toggleAccordion}
29
30
  aria-label={isOpen ? 'Collapse accordion' : 'Expand accordion'}
@@ -59,7 +59,13 @@
59
59
  </div>
60
60
 
61
61
  {#snippet footer()}
62
- <Button variant="primary" variantColor="danger" disabled={!enableButton} onclick={handleDelete}>
62
+ <Button
63
+ type="button"
64
+ variant="primary"
65
+ variantColor="danger"
66
+ disabled={!enableButton}
67
+ onclick={handleDelete}
68
+ >
63
69
  Delete
64
70
  </Button>
65
71
  {/snippet}
@@ -72,7 +78,7 @@
72
78
  gap: 16px;
73
79
  width: 100%;
74
80
  }
75
-
81
+
76
82
  p {
77
83
  margin: 0;
78
84
  user-select: none;
@@ -39,8 +39,8 @@
39
39
  </p>
40
40
 
41
41
  <div class="feedback-footer">
42
- <Button variant="outline" onclick={() => window.history.back()}>Back</Button>
43
- <Button variant="primary" onclick={() => goto(page.url.origin)}>Go home</Button>
42
+ <Button type="button" variant="outline" onclick={() => window.history.back()}>Back</Button>
43
+ <Button type="button" variant="primary" onclick={() => goto(page.url.origin)}>Go home</Button>
44
44
  </div>
45
45
  </section>
46
46
 
@@ -27,6 +27,7 @@
27
27
  enctype?: FormEncodingType;
28
28
  invalidateAll?: boolean;
29
29
  spinnerFixed?: boolean;
30
+ contextName?: string;
30
31
  onsuccess: (data?: Record<string, unknown>) => void;
31
32
  onfailure?: (status: number | undefined, error: unknown) => void;
32
33
  children?: Snippet;
@@ -41,6 +42,7 @@
41
42
  enctype = 'application/x-www-form-urlencoded',
42
43
  invalidateAll = true,
43
44
  spinnerFixed = false,
45
+ contextName,
44
46
  onsuccess,
45
47
  onfailure = undefined,
46
48
  children
@@ -49,8 +51,7 @@
49
51
  let actionResult: ActionResult;
50
52
  let isLoading = $state(false);
51
53
 
52
- const { form, errors, isFormValid } = getFormContext<Schema>();
53
-
54
+ const { form, errors, isFormValid } = getFormContext<Schema>(contextName);
54
55
  $form = structuredClone($state.snapshot(initialData));
55
56
 
56
57
  const onUpdated = () => {
@@ -9,6 +9,7 @@ declare const Form: import("svelte").Component<{
9
9
  enctype?: "application/x-www-form-urlencoded" | "multipart/form-data";
10
10
  invalidateAll?: boolean;
11
11
  spinnerFixed?: boolean;
12
+ contextName?: string;
12
13
  onsuccess: (data?: Record<string, unknown>) => void;
13
14
  onfailure?: (status: number | undefined, error: unknown) => void;
14
15
  children?: Snippet;
@@ -1,3 +1,3 @@
1
1
  import type { FormContext } from './types.js';
2
- export declare const setFormContext: <T>() => FormContext<T>;
3
- export declare const getFormContext: <T>() => FormContext<T>;
2
+ export declare const setFormContext: <T>(name?: string) => FormContext<T>;
3
+ export declare const getFormContext: <T>(name?: string) => FormContext<T>;
@@ -1,15 +1,23 @@
1
1
  import { getContext, setContext } from 'svelte';
2
2
  import { writable } from 'svelte/store';
3
- const formContextKey = Symbol('formContext');
4
- export const setFormContext = () => {
3
+ const symbolCache = new Map();
4
+ const getFormContextKey = (name) => {
5
+ const DEFAULT_KEY = 'formContext';
6
+ const key = name ? `${DEFAULT_KEY}-${name}` : DEFAULT_KEY;
7
+ if (!symbolCache.has(key)) {
8
+ symbolCache.set(key, Symbol(key));
9
+ }
10
+ return symbolCache.get(key);
11
+ };
12
+ export const setFormContext = (name) => {
5
13
  const formContext = {
6
14
  form: writable({}),
7
15
  errors: writable({}),
8
16
  isFormValid: writable(false)
9
17
  };
10
- setContext(formContextKey, formContext);
18
+ setContext(getFormContextKey(name), formContext);
11
19
  return formContext;
12
20
  };
13
- export const getFormContext = () => {
14
- return getContext(formContextKey);
21
+ export const getFormContext = (name) => {
22
+ return getContext(getFormContextKey(name));
15
23
  };
@@ -41,7 +41,7 @@
41
41
  </div>
42
42
  </div>
43
43
  <div class="category-items">
44
- <button class="button" onclick={toggleSidebar}>
44
+ <button type="button" class="button" onclick={toggleSidebar}>
45
45
  <span class="material-icons-outlined icon-span">
46
46
  {isCollapsed ? 'menu' : 'menu_open'}
47
47
  </span>
@@ -7,7 +7,7 @@
7
7
 
8
8
  {#if footer}
9
9
  <footer class="modal-footer">
10
- <Button variant="outline-none" onclick={onclose}>Cancel</Button>
10
+ <Button type="button" variant="outline-none" onclick={onclose}>Cancel</Button>
11
11
  <div class="button-section">
12
12
  {@render footer()}
13
13
  </div>
@@ -38,7 +38,7 @@
38
38
  </div>
39
39
 
40
40
  {#if onclick}
41
- <Button {onclick}>{buttonText}</Button>
41
+ <Button type="button" {onclick}>{buttonText}</Button>
42
42
  {/if}
43
43
  </article>
44
44
 
@@ -114,19 +114,20 @@
114
114
  </article>
115
115
  </section>
116
116
  <section class="progress-wizard-footer">
117
- <Button variant="outline-none" onclick={oncancel}>Cancel</Button>
117
+ <Button type="button" variant="outline-none" onclick={oncancel}>Cancel</Button>
118
118
 
119
119
  <div class="actions">
120
120
  {#if !allStepsDisabled}
121
121
  {#if !readonly}
122
122
  <Button
123
+ type="button"
123
124
  variant="secondary"
124
125
  disabled={currentStep === firstActiveStep}
125
126
  onclick={onclickBack}>Back</Button
126
127
  >
127
128
 
128
129
  {#if currentStep < lastActiveStep}
129
- <Button variant="primary" onclick={onclickNext}>Next</Button>
130
+ <Button type="button" variant="primary" onclick={onclickNext}>Next</Button>
130
131
  {/if}
131
132
  {/if}
132
133
 
@@ -177,6 +177,7 @@
177
177
  {#if editingFilters.length}
178
178
  <div class="filter-footer">
179
179
  <Button
180
+ type="button"
180
181
  onclick={applyFilters}
181
182
  disabled={editingFilters.every((filter) => !filter.column || !filter.value.trim())}
182
183
  >
@@ -266,8 +266,10 @@
266
266
  />
267
267
  {/if}
268
268
  {#if enableExportExcel}
269
- <Button variant="secondary" onclick={() => exportExcel(table, excelSetting)}
270
- >Export</Button
269
+ <Button
270
+ type="button"
271
+ variant="secondary"
272
+ onclick={() => exportExcel(table, excelSetting)}>Export</Button
271
273
  >
272
274
  {/if}
273
275
  {@render header?.()}
@@ -8,7 +8,7 @@
8
8
  let { title, icon, onclickwaffleitems }: Props = $props();
9
9
  </script>
10
10
 
11
- <button onclick={onclickwaffleitems} class="waffle-item-button">
11
+ <button type="button" onclick={onclickwaffleitems} class="waffle-item-button">
12
12
  <figure class="waffle-icon-container" aria-hidden="true">
13
13
  {@html icon}
14
14
  </figure>
@@ -39,7 +39,8 @@
39
39
  background: #f4f6f8;
40
40
  }
41
41
 
42
- .waffle-item-button:focus, .waffle-item-button:focus-visible {
42
+ .waffle-item-button:focus,
43
+ .waffle-item-button:focus-visible {
43
44
  background: #eaecff;
44
45
  }
45
46
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwareone/spi-sv5-library",
3
- "version": "1.11.4",
3
+ "version": "1.11.5",
4
4
  "description": "Svelte components",
5
5
  "keywords": [
6
6
  "svelte",