intelliwaketssveltekitv25 0.1.167 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- export declare function CookieCreate(name: string, value: string | null, days: number): void;
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();
@@ -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;
@@ -110,13 +125,33 @@
110
125
  }
111
126
  if (display.page === 1) {
112
127
  if (currentValue) {
113
- pageState.url.searchParams.delete(queryParamName)
114
- goto(pageState.url, gotoSettings)
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
+ }
115
139
  }
116
140
  } else if (display.page !== currentValue) {
117
- pageState.url.searchParams.set(queryParamName, display.page.toString())
141
+ if (queryParamName) {
142
+ pageState.url.searchParams.set(queryParamName, display.page.toString())
118
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
+ }
119
152
  }
153
+ } else if (invalidate) {
154
+ performInvalidate()
120
155
  }
121
156
  })
122
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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intelliwaketssveltekitv25",
3
- "version": "0.1.167",
3
+ "version": "0.1.168",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",