@softwareone/spi-sv5-library 1.11.4 → 1.11.6

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'}
@@ -199,7 +199,7 @@
199
199
 
200
200
  <style>
201
201
  .container {
202
- --color-red: #b30825;
202
+ --color-red: #dc2626;
203
203
  --color-gray-outer: #434952;
204
204
  --color-gray-auro: #6b7180;
205
205
  --color-gray: #e0e5e8;
@@ -238,9 +238,7 @@
238
238
 
239
239
  .text-error {
240
240
  color: var(--color-red);
241
- margin: 4px;
242
241
  font-size: 12px;
243
- line-height: 16px;
244
242
  }
245
243
 
246
244
  .drop-area {
@@ -7,7 +7,7 @@
7
7
  showModal?: boolean;
8
8
  ondelete: () => Promise<boolean> | boolean;
9
9
  onclose?: VoidFunction;
10
- ondeleteSuccess?: VoidFunction;
10
+ ondeleteSuccess?: () => Promise<void> | void;
11
11
  }
12
12
 
13
13
  let {
@@ -28,15 +28,17 @@
28
28
 
29
29
  const handleDelete = async () => {
30
30
  isLoading = true;
31
+
31
32
  const isSuccessful = await ondelete();
32
- isLoading = false;
33
33
 
34
34
  if (isSuccessful) {
35
+ await ondeleteSuccess?.();
35
36
  showModal = false;
36
- ondeleteSuccess?.();
37
37
  } else {
38
38
  addToast({ message: 'There was an unexpected error.', type: 'danger' });
39
39
  }
40
+
41
+ isLoading = false;
40
42
  };
41
43
  </script>
42
44
 
@@ -59,7 +61,13 @@
59
61
  </div>
60
62
 
61
63
  {#snippet footer()}
62
- <Button variant="primary" variantColor="danger" disabled={!enableButton} onclick={handleDelete}>
64
+ <Button
65
+ type="button"
66
+ variant="primary"
67
+ variantColor="danger"
68
+ disabled={!enableButton}
69
+ onclick={handleDelete}
70
+ >
63
71
  Delete
64
72
  </Button>
65
73
  {/snippet}
@@ -72,7 +80,7 @@
72
80
  gap: 16px;
73
81
  width: 100%;
74
82
  }
75
-
83
+
76
84
  p {
77
85
  margin: 0;
78
86
  user-select: none;
@@ -4,7 +4,7 @@ interface DeleteConfirmationProps {
4
4
  showModal?: boolean;
5
5
  ondelete: () => Promise<boolean> | boolean;
6
6
  onclose?: VoidFunction;
7
- ondeleteSuccess?: VoidFunction;
7
+ ondeleteSuccess?: () => Promise<void> | void;
8
8
  }
9
9
  declare const DeleteConfirmation: import("svelte").Component<DeleteConfirmationProps, {}, "showModal">;
10
10
  type DeleteConfirmation = ReturnType<typeof DeleteConfirmation>;
@@ -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
  >
@@ -87,11 +87,23 @@
87
87
  const tableManualPagination = manualPagination ? setPaginationTableContext() : undefined;
88
88
  const hasData = $derived(data.length > 0);
89
89
 
90
+ const tableColumns = $derived.by(() => {
91
+ if (!enableChecked) return columns;
92
+
93
+ const checkedColumnExists = columns.some((column) => column.id === 'checked');
94
+ if (checkedColumnExists) return columns;
95
+
96
+ const checkedColumn = createCheckedColumn<T>();
97
+ return [checkedColumn, ...columns];
98
+ });
99
+
90
100
  const table = createSvelteTable({
91
101
  get data() {
92
102
  return tableData;
93
103
  },
94
- columns,
104
+ get columns() {
105
+ return tableColumns;
106
+ },
95
107
  state: {
96
108
  get sorting() {
97
109
  return sorting;
@@ -222,16 +234,6 @@
222
234
  $tableManualPagination = { ...pagination };
223
235
  }
224
236
  });
225
-
226
- $effect.pre(() => {
227
- if (enableChecked && columns.length) {
228
- const checkedColumnExists = columns.some((column) => column.id === 'checked');
229
- if (!checkedColumnExists) {
230
- const checkedColumn = createCheckedColumn<T>();
231
- columns.unshift(checkedColumn);
232
- }
233
- }
234
- });
235
237
  </script>
236
238
 
237
239
  <section class="table-container">
@@ -266,8 +268,10 @@
266
268
  />
267
269
  {/if}
268
270
  {#if enableExportExcel}
269
- <Button variant="secondary" onclick={() => exportExcel(table, excelSetting)}
270
- >Export</Button
271
+ <Button
272
+ type="button"
273
+ variant="secondary"
274
+ onclick={() => exportExcel(table, excelSetting)}>Export</Button
271
275
  >
272
276
  {/if}
273
277
  {@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.6",
4
4
  "description": "Svelte components",
5
5
  "keywords": [
6
6
  "svelte",