intelliwaketssveltekitv25 0.1.166 → 0.1.168
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.
- package/dist/Cookie.d.ts +1 -1
- package/dist/Cookie.js +1 -1
- package/dist/Paginator.svelte +46 -6
- package/dist/Paginator.svelte.d.ts +1 -0
- package/package.json +1 -1
package/dist/Cookie.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function CookieCreate(name: string, value: string | null, days
|
|
1
|
+
export declare function CookieCreate(name: string, value: string | null, days?: number): void;
|
|
2
2
|
export declare function CookieReadOld(name: string, defaultValue?: string | null): string | null;
|
|
3
3
|
export declare function CookieRead(name: string, defaultValue?: string | null): string | null;
|
|
4
4
|
export declare function CookieErase(name: string): void;
|
package/dist/Cookie.js
CHANGED
|
@@ -6,7 +6,7 @@ import { IsOn } from "@solidbasisventures/intelliwaketsfoundation";
|
|
|
6
6
|
export function CookieCreate(name, value, days) {
|
|
7
7
|
name = name.replace(/=/g, '');
|
|
8
8
|
let expires = '';
|
|
9
|
-
if (days) {
|
|
9
|
+
if (days !== undefined) {
|
|
10
10
|
const date = new Date();
|
|
11
11
|
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
12
12
|
expires = '; expires=' + date.toUTCString();
|
package/dist/Paginator.svelte
CHANGED
|
@@ -10,21 +10,23 @@
|
|
|
10
10
|
ToArray,
|
|
11
11
|
ToDigits
|
|
12
12
|
} from '@solidbasisventures/intelliwaketsfoundation'
|
|
13
|
-
import { DropDown, type IDDAction, PageAdvanceSize } from './index'
|
|
13
|
+
import { CookieCreate, CookieErase, CookieRead, DropDown, type IDDAction, PageAdvanceSize } from './index'
|
|
14
14
|
import { page as pageState } from '$app/state'
|
|
15
|
-
import { goto } from '$app/navigation'
|
|
15
|
+
import { goto, invalidate as doInvalidate, invalidateAll } from '$app/navigation'
|
|
16
16
|
|
|
17
17
|
let {
|
|
18
18
|
page = $bindable(),
|
|
19
19
|
pageCount,
|
|
20
20
|
verbose = false,
|
|
21
21
|
updateQueryParams = false,
|
|
22
|
+
cookieParms = false,
|
|
22
23
|
invalidate = 'All',
|
|
23
24
|
class: clazz = ''
|
|
24
25
|
}: (Pick<IPaginatorResponse, 'page' | 'pageCount'> &
|
|
25
26
|
{
|
|
26
27
|
verbose?: boolean
|
|
27
28
|
updateQueryParams?: boolean | string
|
|
29
|
+
cookieParms?: boolean | string
|
|
28
30
|
invalidate?: string | string[] | (string | URL | ((url: URL) => boolean)) | (string | URL | ((url: URL) => boolean))[] | null
|
|
29
31
|
class?: string
|
|
30
32
|
}) = $props()
|
|
@@ -95,10 +97,23 @@
|
|
|
95
97
|
let display = $derived(createDisplay(page, pageCount, clientWidth))
|
|
96
98
|
|
|
97
99
|
let queryParamName = $derived(!updateQueryParams ? null : updateQueryParams === true ? 'page' : updateQueryParams)
|
|
100
|
+
let cookieName = $derived(!cookieParms ? null : cookieParms === true ? 'page' : cookieParms)
|
|
101
|
+
|
|
102
|
+
function performInvalidate() {
|
|
103
|
+
for (const inv of ToArray(invalidate)) {
|
|
104
|
+
if (inv) {
|
|
105
|
+
if (inv === 'All') {
|
|
106
|
+
invalidateAll()
|
|
107
|
+
} else {
|
|
108
|
+
doInvalidate(inv)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
98
113
|
|
|
99
114
|
$effect(() => {
|
|
100
|
-
if (queryParamName) {
|
|
101
|
-
const currentValue = CleanNumberNull(pageState.url.searchParams.get(queryParamName))
|
|
115
|
+
if (queryParamName || cookieName) {
|
|
116
|
+
const currentValue = CleanNumberNull(cookieName ? CookieRead(cookieName) : queryParamName ? pageState.url.searchParams.get(queryParamName) : null)
|
|
102
117
|
const gotoSettings: {
|
|
103
118
|
replaceState?: boolean | undefined;
|
|
104
119
|
invalidateAll?: boolean | undefined;
|
|
@@ -108,10 +123,35 @@
|
|
|
108
123
|
if (ToArray(invalidate).some(inv => inv === 'All')) gotoSettings.invalidateAll = true
|
|
109
124
|
else gotoSettings.invalidate = ToArray(invalidate)
|
|
110
125
|
}
|
|
111
|
-
if (display.page
|
|
112
|
-
|
|
126
|
+
if (display.page === 1) {
|
|
127
|
+
if (currentValue) {
|
|
128
|
+
if (queryParamName) {
|
|
129
|
+
pageState.url.searchParams.delete(queryParamName)
|
|
130
|
+
goto(pageState.url, gotoSettings)
|
|
131
|
+
} else if (cookieName) {
|
|
132
|
+
CookieErase(cookieName)
|
|
133
|
+
if (invalidate) {
|
|
134
|
+
performInvalidate()
|
|
135
|
+
} else {
|
|
136
|
+
window.location.reload()
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
} else if (display.page !== currentValue) {
|
|
141
|
+
if (queryParamName) {
|
|
142
|
+
pageState.url.searchParams.set(queryParamName, display.page.toString())
|
|
113
143
|
goto(pageState.url, gotoSettings)
|
|
144
|
+
} else if (cookieName) {
|
|
145
|
+
CookieCreate(cookieName, display.page.toString())
|
|
146
|
+
if (invalidate) {
|
|
147
|
+
performInvalidate()
|
|
148
|
+
} else {
|
|
149
|
+
window.location.reload()
|
|
150
|
+
}
|
|
151
|
+
}
|
|
114
152
|
}
|
|
153
|
+
} else if (invalidate) {
|
|
154
|
+
performInvalidate()
|
|
115
155
|
}
|
|
116
156
|
})
|
|
117
157
|
</script>
|
|
@@ -2,6 +2,7 @@ import { type IPaginatorResponse } from '@solidbasisventures/intelliwaketsfounda
|
|
|
2
2
|
type $$ComponentProps = (Pick<IPaginatorResponse, 'page' | 'pageCount'> & {
|
|
3
3
|
verbose?: boolean;
|
|
4
4
|
updateQueryParams?: boolean | string;
|
|
5
|
+
cookieParms?: boolean | string;
|
|
5
6
|
invalidate?: string | string[] | (string | URL | ((url: URL) => boolean)) | (string | URL | ((url: URL) => boolean))[] | null;
|
|
6
7
|
class?: string;
|
|
7
8
|
});
|