@vuu-ui/vuu-utils 0.13.90 → 0.13.92
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/cjs/packages/vuu-utils/src/cookie-utils.js +12 -0
- package/cjs/packages/vuu-utils/src/cookie-utils.js.map +1 -1
- package/cjs/packages/vuu-utils/src/index.js +2 -0
- package/cjs/packages/vuu-utils/src/index.js.map +1 -1
- package/cjs/packages/vuu-utils/src/local-storage-utils.js +20 -5
- package/cjs/packages/vuu-utils/src/local-storage-utils.js.map +1 -1
- package/esm/packages/vuu-utils/src/cookie-utils.js +12 -1
- package/esm/packages/vuu-utils/src/cookie-utils.js.map +1 -1
- package/esm/packages/vuu-utils/src/index.js +2 -2
- package/esm/packages/vuu-utils/src/local-storage-utils.js +20 -6
- package/esm/packages/vuu-utils/src/local-storage-utils.js.map +1 -1
- package/package.json +8 -8
- package/types/cookie-utils.d.ts +8 -0
- package/types/local-storage-utils.d.ts +3 -2
|
@@ -5,6 +5,18 @@ const getCookieValue = (name) => {
|
|
|
5
5
|
return globalThis.document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
|
+
function setCookieValue(name, value, days) {
|
|
9
|
+
let expires = "";
|
|
10
|
+
if (typeof days === "number") {
|
|
11
|
+
const date = /* @__PURE__ */ new Date();
|
|
12
|
+
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
13
|
+
expires = "; expires=" + date.toUTCString();
|
|
14
|
+
}
|
|
15
|
+
const encodedName = encodeURIComponent(name);
|
|
16
|
+
const encodedValue = encodeURIComponent(value);
|
|
17
|
+
document.cookie = `${encodedName}=${encodedValue}${expires};`;
|
|
18
|
+
}
|
|
8
19
|
|
|
9
20
|
exports.getCookieValue = getCookieValue;
|
|
21
|
+
exports.setCookieValue = setCookieValue;
|
|
10
22
|
//# sourceMappingURL=cookie-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-utils.js","sources":["../../../../../../packages/vuu-utils/src/cookie-utils.ts"],"sourcesContent":["export const getCookieValue = (name: string): string | number | undefined => {\n if (globalThis.document?.cookie !== undefined) {\n return globalThis.document.cookie\n .split(\"; \")\n .find((row) => row.startsWith(`${name}=`))\n ?.split(\"=\")[1];\n }\n};\n"],"names":[],"mappings":";;AAAa,MAAA,cAAA,GAAiB,CAAC,IAA8C,KAAA;AAC3E,EAAI,IAAA,UAAA,CAAW,QAAU,EAAA,MAAA,KAAW,KAAW,CAAA,EAAA;AAC7C,IAAA,OAAO,WAAW,QAAS,CAAA,MAAA,CACxB,MAAM,IAAI,CAAA,CACV,KAAK,CAAC,GAAA,KAAQ,IAAI,UAAW,CAAA,CAAA,EAAG,IAAI,CAAG,CAAA,CAAA,CAAC,GACvC,KAAM,CAAA,GAAG,EAAE,CAAC,CAAA;AAAA;AAEpB
|
|
1
|
+
{"version":3,"file":"cookie-utils.js","sources":["../../../../../../packages/vuu-utils/src/cookie-utils.ts"],"sourcesContent":["export const getCookieValue = (name: string): string | number | undefined => {\n if (globalThis.document?.cookie !== undefined) {\n return globalThis.document.cookie\n .split(\"; \")\n .find((row) => row.startsWith(`${name}=`))\n ?.split(\"=\")[1];\n }\n};\n\n/**\n * Sets a cookie value.\n *\n * @param {string} name - Cookie name\n * @param {string} value - Cookie value\n * @param {number} [days] - Optional: number of days until the cookie expires\n */\nexport function setCookieValue(name: string, value: string, days?: number) {\n let expires = \"\";\n\n if (typeof days === \"number\") {\n const date = new Date();\n // days -> milliseconds\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = \"; expires=\" + date.toUTCString();\n }\n\n const encodedName = encodeURIComponent(name);\n const encodedValue = encodeURIComponent(value);\n\n document.cookie = `${encodedName}=${encodedValue}${expires};`;\n}\n"],"names":[],"mappings":";;AAAa,MAAA,cAAA,GAAiB,CAAC,IAA8C,KAAA;AAC3E,EAAI,IAAA,UAAA,CAAW,QAAU,EAAA,MAAA,KAAW,KAAW,CAAA,EAAA;AAC7C,IAAA,OAAO,WAAW,QAAS,CAAA,MAAA,CACxB,MAAM,IAAI,CAAA,CACV,KAAK,CAAC,GAAA,KAAQ,IAAI,UAAW,CAAA,CAAA,EAAG,IAAI,CAAG,CAAA,CAAA,CAAC,GACvC,KAAM,CAAA,GAAG,EAAE,CAAC,CAAA;AAAA;AAEpB;AASgB,SAAA,cAAA,CAAe,IAAc,EAAA,KAAA,EAAe,IAAe,EAAA;AACzE,EAAA,IAAI,OAAU,GAAA,EAAA;AAEd,EAAI,IAAA,OAAO,SAAS,QAAU,EAAA;AAC5B,IAAM,MAAA,IAAA,uBAAW,IAAK,EAAA;AAEtB,IAAK,IAAA,CAAA,OAAA,CAAQ,KAAK,OAAQ,EAAA,GAAI,OAAO,EAAK,GAAA,EAAA,GAAK,KAAK,GAAI,CAAA;AACxD,IAAU,OAAA,GAAA,YAAA,GAAe,KAAK,WAAY,EAAA;AAAA;AAG5C,EAAM,MAAA,WAAA,GAAc,mBAAmB,IAAI,CAAA;AAC3C,EAAM,MAAA,YAAA,GAAe,mBAAmB,KAAK,CAAA;AAE7C,EAAA,QAAA,CAAS,SAAS,CAAG,EAAA,WAAW,CAAI,CAAA,EAAA,YAAY,GAAG,OAAO,CAAA,CAAA,CAAA;AAC5D;;;;;"}
|
|
@@ -172,6 +172,7 @@ exports.updateColumnRenderProps = columnUtils.updateColumnRenderProps;
|
|
|
172
172
|
exports.updateColumnType = columnUtils.updateColumnType;
|
|
173
173
|
exports.visibleColumnAtIndex = columnUtils.visibleColumnAtIndex;
|
|
174
174
|
exports.getCookieValue = cookieUtils.getCookieValue;
|
|
175
|
+
exports.setCookieValue = cookieUtils.setCookieValue;
|
|
175
176
|
exports.getCellConfigPanelRenderer = componentRegistry.getCellConfigPanelRenderer;
|
|
176
177
|
exports.getCellRenderer = componentRegistry.getCellRenderer;
|
|
177
178
|
exports.getCellRendererOptions = componentRegistry.getCellRendererOptions;
|
|
@@ -340,6 +341,7 @@ exports.Tab = keyboardUtils.Tab;
|
|
|
340
341
|
exports.isArrowKey = keyboardUtils.isArrowKey;
|
|
341
342
|
exports.KeySet = keyset.KeySet;
|
|
342
343
|
exports.getSelectedOption = listUtils.getSelectedOption;
|
|
344
|
+
exports.clearLocalEntity = localStorageUtils.clearLocalEntity;
|
|
343
345
|
exports.getAllLocalEntity = localStorageUtils.getAllLocalEntity;
|
|
344
346
|
exports.getLocalEntity = localStorageUtils.getLocalEntity;
|
|
345
347
|
exports.saveLocalEntity = localStorageUtils.saveLocalEntity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const getLocalEntity = (
|
|
4
|
-
const data = localStorage.getItem(
|
|
5
|
-
|
|
3
|
+
const getLocalEntity = (key, deleteOnRead = false) => {
|
|
4
|
+
const data = localStorage.getItem(key);
|
|
5
|
+
if (data) {
|
|
6
|
+
if (deleteOnRead) {
|
|
7
|
+
localStorage.removeItem(key);
|
|
8
|
+
}
|
|
9
|
+
return JSON.parse(data);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const clearLocalEntity = (key) => {
|
|
13
|
+
const doomedItem = localStorage.getItem(key);
|
|
14
|
+
if (doomedItem) {
|
|
15
|
+
localStorage.removeItem(key);
|
|
16
|
+
return true;
|
|
17
|
+
} else {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
6
20
|
};
|
|
7
21
|
const getAllLocalEntity = (url) => Object.entries(localStorage).filter(([key]) => key.includes(url)).map(([, value]) => JSON.parse(value));
|
|
8
|
-
const saveLocalEntity = (
|
|
22
|
+
const saveLocalEntity = (key, data) => {
|
|
9
23
|
try {
|
|
10
|
-
localStorage.setItem(
|
|
24
|
+
localStorage.setItem(key, JSON.stringify(data));
|
|
11
25
|
return data;
|
|
12
26
|
} catch {
|
|
13
27
|
return void 0;
|
|
14
28
|
}
|
|
15
29
|
};
|
|
16
30
|
|
|
31
|
+
exports.clearLocalEntity = clearLocalEntity;
|
|
17
32
|
exports.getAllLocalEntity = getAllLocalEntity;
|
|
18
33
|
exports.getLocalEntity = getLocalEntity;
|
|
19
34
|
exports.saveLocalEntity = saveLocalEntity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-storage-utils.js","sources":["../../../../../../packages/vuu-utils/src/local-storage-utils.ts"],"sourcesContent":["export const getLocalEntity = <T>(
|
|
1
|
+
{"version":3,"file":"local-storage-utils.js","sources":["../../../../../../packages/vuu-utils/src/local-storage-utils.ts"],"sourcesContent":["export const getLocalEntity = <T>(\n key: string,\n deleteOnRead = false,\n): T | undefined => {\n const data = localStorage.getItem(key);\n if (data) {\n if (deleteOnRead) {\n localStorage.removeItem(key);\n }\n return JSON.parse(data);\n }\n};\n\nexport const clearLocalEntity = (key: string) => {\n const doomedItem = localStorage.getItem(key);\n if (doomedItem) {\n localStorage.removeItem(key);\n return true;\n } else {\n return false;\n }\n};\n\nexport const getAllLocalEntity = <T>(url: string): T[] =>\n Object.entries(localStorage)\n .filter(([key]) => key.includes(url))\n .map(([, value]) => JSON.parse(value) as T);\n\nexport const saveLocalEntity = <T>(key: string, data: T): T | undefined => {\n try {\n localStorage.setItem(key, JSON.stringify(data));\n return data;\n } catch {\n return undefined;\n }\n};\n"],"names":[],"mappings":";;AAAO,MAAM,cAAiB,GAAA,CAC5B,GACA,EAAA,YAAA,GAAe,KACG,KAAA;AAClB,EAAM,MAAA,IAAA,GAAO,YAAa,CAAA,OAAA,CAAQ,GAAG,CAAA;AACrC,EAAA,IAAI,IAAM,EAAA;AACR,IAAA,IAAI,YAAc,EAAA;AAChB,MAAA,YAAA,CAAa,WAAW,GAAG,CAAA;AAAA;AAE7B,IAAO,OAAA,IAAA,CAAK,MAAM,IAAI,CAAA;AAAA;AAE1B;AAEa,MAAA,gBAAA,GAAmB,CAAC,GAAgB,KAAA;AAC/C,EAAM,MAAA,UAAA,GAAa,YAAa,CAAA,OAAA,CAAQ,GAAG,CAAA;AAC3C,EAAA,IAAI,UAAY,EAAA;AACd,IAAA,YAAA,CAAa,WAAW,GAAG,CAAA;AAC3B,IAAO,OAAA,IAAA;AAAA,GACF,MAAA;AACL,IAAO,OAAA,KAAA;AAAA;AAEX;AAEa,MAAA,iBAAA,GAAoB,CAAI,GAAA,KACnC,MAAO,CAAA,OAAA,CAAQ,YAAY,CAAA,CACxB,MAAO,CAAA,CAAC,CAAC,GAAG,CAAM,KAAA,GAAA,CAAI,SAAS,GAAG,CAAC,CACnC,CAAA,GAAA,CAAI,CAAC,GAAG,KAAK,CAAM,KAAA,IAAA,CAAK,KAAM,CAAA,KAAK,CAAM;AAEjC,MAAA,eAAA,GAAkB,CAAI,GAAA,EAAa,IAA2B,KAAA;AACzE,EAAI,IAAA;AACF,IAAA,YAAA,CAAa,OAAQ,CAAA,GAAA,EAAK,IAAK,CAAA,SAAA,CAAU,IAAI,CAAC,CAAA;AAC9C,IAAO,OAAA,IAAA;AAAA,GACD,CAAA,MAAA;AACN,IAAO,OAAA,KAAA,CAAA;AAAA;AAEX;;;;;;;"}
|
|
@@ -3,6 +3,17 @@ const getCookieValue = (name) => {
|
|
|
3
3
|
return globalThis.document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
|
|
4
4
|
}
|
|
5
5
|
};
|
|
6
|
+
function setCookieValue(name, value, days) {
|
|
7
|
+
let expires = "";
|
|
8
|
+
if (typeof days === "number") {
|
|
9
|
+
const date = /* @__PURE__ */ new Date();
|
|
10
|
+
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
11
|
+
expires = "; expires=" + date.toUTCString();
|
|
12
|
+
}
|
|
13
|
+
const encodedName = encodeURIComponent(name);
|
|
14
|
+
const encodedValue = encodeURIComponent(value);
|
|
15
|
+
document.cookie = `${encodedName}=${encodedValue}${expires};`;
|
|
16
|
+
}
|
|
6
17
|
|
|
7
|
-
export { getCookieValue };
|
|
18
|
+
export { getCookieValue, setCookieValue };
|
|
8
19
|
//# sourceMappingURL=cookie-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-utils.js","sources":["../../../../../../packages/vuu-utils/src/cookie-utils.ts"],"sourcesContent":["export const getCookieValue = (name: string): string | number | undefined => {\n if (globalThis.document?.cookie !== undefined) {\n return globalThis.document.cookie\n .split(\"; \")\n .find((row) => row.startsWith(`${name}=`))\n ?.split(\"=\")[1];\n }\n};\n"],"names":[],"mappings":"AAAa,MAAA,cAAA,GAAiB,CAAC,IAA8C,KAAA;AAC3E,EAAI,IAAA,UAAA,CAAW,QAAU,EAAA,MAAA,KAAW,KAAW,CAAA,EAAA;AAC7C,IAAA,OAAO,WAAW,QAAS,CAAA,MAAA,CACxB,MAAM,IAAI,CAAA,CACV,KAAK,CAAC,GAAA,KAAQ,IAAI,UAAW,CAAA,CAAA,EAAG,IAAI,CAAG,CAAA,CAAA,CAAC,GACvC,KAAM,CAAA,GAAG,EAAE,CAAC,CAAA;AAAA;AAEpB;;;;"}
|
|
1
|
+
{"version":3,"file":"cookie-utils.js","sources":["../../../../../../packages/vuu-utils/src/cookie-utils.ts"],"sourcesContent":["export const getCookieValue = (name: string): string | number | undefined => {\n if (globalThis.document?.cookie !== undefined) {\n return globalThis.document.cookie\n .split(\"; \")\n .find((row) => row.startsWith(`${name}=`))\n ?.split(\"=\")[1];\n }\n};\n\n/**\n * Sets a cookie value.\n *\n * @param {string} name - Cookie name\n * @param {string} value - Cookie value\n * @param {number} [days] - Optional: number of days until the cookie expires\n */\nexport function setCookieValue(name: string, value: string, days?: number) {\n let expires = \"\";\n\n if (typeof days === \"number\") {\n const date = new Date();\n // days -> milliseconds\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = \"; expires=\" + date.toUTCString();\n }\n\n const encodedName = encodeURIComponent(name);\n const encodedValue = encodeURIComponent(value);\n\n document.cookie = `${encodedName}=${encodedValue}${expires};`;\n}\n"],"names":[],"mappings":"AAAa,MAAA,cAAA,GAAiB,CAAC,IAA8C,KAAA;AAC3E,EAAI,IAAA,UAAA,CAAW,QAAU,EAAA,MAAA,KAAW,KAAW,CAAA,EAAA;AAC7C,IAAA,OAAO,WAAW,QAAS,CAAA,MAAA,CACxB,MAAM,IAAI,CAAA,CACV,KAAK,CAAC,GAAA,KAAQ,IAAI,UAAW,CAAA,CAAA,EAAG,IAAI,CAAG,CAAA,CAAA,CAAC,GACvC,KAAM,CAAA,GAAG,EAAE,CAAC,CAAA;AAAA;AAEpB;AASgB,SAAA,cAAA,CAAe,IAAc,EAAA,KAAA,EAAe,IAAe,EAAA;AACzE,EAAA,IAAI,OAAU,GAAA,EAAA;AAEd,EAAI,IAAA,OAAO,SAAS,QAAU,EAAA;AAC5B,IAAM,MAAA,IAAA,uBAAW,IAAK,EAAA;AAEtB,IAAK,IAAA,CAAA,OAAA,CAAQ,KAAK,OAAQ,EAAA,GAAI,OAAO,EAAK,GAAA,EAAA,GAAK,KAAK,GAAI,CAAA;AACxD,IAAU,OAAA,GAAA,YAAA,GAAe,KAAK,WAAY,EAAA;AAAA;AAG5C,EAAM,MAAA,WAAA,GAAc,mBAAmB,IAAI,CAAA;AAC3C,EAAM,MAAA,YAAA,GAAe,mBAAmB,KAAK,CAAA;AAE7C,EAAA,QAAA,CAAS,SAAS,CAAG,EAAA,WAAW,CAAI,CAAA,EAAA,YAAY,GAAG,OAAO,CAAA,CAAA,CAAA;AAC5D;;;;"}
|
|
@@ -5,7 +5,7 @@ export { RestrictToHorizontalAxis } from '../../../node_modules/@dnd-kit/abstrac
|
|
|
5
5
|
export { getAddedItems, getMissingItems, itemsChanged, itemsOrOrderChanged, moveItem, moveItemDeprecated, partition } from './array-utils.js';
|
|
6
6
|
export { boxContainsPoint, getCenteredBox, getPositionWithinBox, isGridLayoutSplitDirection, pointPositionWithinRect } from './box-utils.js';
|
|
7
7
|
export { AggregationType, addColumnToSubscribedColumns, applyDefaultColumnConfig, applyGroupByToColumns, applyRuntimeColumnWidthsToConfig, applySortToColumns, applyWidthToColumns, assertAllColumnsAreIncludedInSubscription, buildColumnMap, checkConfirmationPending, columnByAriaIndex, dataAndColumnUnchanged, dataColumnAndKeyUnchanged, dataSourceRowToDataRowDto, existingSort, extractGroupColumn, findColumn, flattenColumnGroup, fromServerDataType, getCalculatedColumnDetails, getColumnLabel, getColumnName, getColumnStyle, getColumnsInViewport, getDefaultAlignment, getDefaultColumnType, getGroupIcon, getGroupValue, getRuntimeColumnWidth, getTableHeadings, getTypeFormattingFromColumn, hasCustomRenderer, hasHeadings, hasValidationRules, isCalculatedColumn, isColumnTypeRenderer, isDataLoading, isDateTimeDataType, isDateTimeDataValue, isGroupColumn, isJsonAttribute, isJsonColumn, isJsonGroup, isLookupRenderer, isMappedValueTypeRenderer, isNotHidden, isNumericColumn, isPinned, isResizing, isStringColumn, isTextColumn, isTimeDataValue, isTimestampColumn, isTypeDescriptor, isValidColumnAlignment, isValidPinLocation, isValueListRenderer, isVuuColumnDataType, mapSortCriteria, measurePinnedColumns, metadataKeys, moveColumnTo, projectUpdates, removeSort, reorderColumnItems, replaceColumn, setAggregations, setCalculatedColumnExpression, setCalculatedColumnName, setCalculatedColumnType, sortPinnedColumns, subscribedOnly, toColumnDescriptor, toColumnName, toDataSourceColumns, updateColumn, updateColumnFormatting, updateColumnRenderProps, updateColumnType, visibleColumnAtIndex } from './column-utils.js';
|
|
8
|
-
export { getCookieValue } from './cookie-utils.js';
|
|
8
|
+
export { getCookieValue, setCookieValue } from './cookie-utils.js';
|
|
9
9
|
export { getCellConfigPanelRenderer, getCellRenderer, getCellRendererOptions, getColumnHeaderContentRenderer, getColumnHeaderLabelRenderer, getConfigurationEditor, getEditRuleValidator, getLayoutComponent, getRegisteredCellRenderers, getRowClassNameGenerator, isContainer, isLayoutComponent, isView, registerComponent, registerConfigurationEditor } from './component-registry.js';
|
|
10
10
|
export { DataWindow } from './DataWindow.js';
|
|
11
11
|
export { Clock } from './Clock.js';
|
|
@@ -37,7 +37,7 @@ export { jsonToDataSourceRows } from './json-utils.js';
|
|
|
37
37
|
export { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, End, Enter, Escape, Home, PageDown, PageUp, Space, Tab, isArrowKey } from './keyboard-utils.js';
|
|
38
38
|
export { KeySet } from './keyset.js';
|
|
39
39
|
export { getSelectedOption } from './list-utils.js';
|
|
40
|
-
export { getAllLocalEntity, getLocalEntity, saveLocalEntity } from './local-storage-utils.js';
|
|
40
|
+
export { clearLocalEntity, getAllLocalEntity, getLocalEntity, saveLocalEntity } from './local-storage-utils.js';
|
|
41
41
|
export { getLoggingConfigForWorker, logUnhandledMessage, logger } from './logging-utils.js';
|
|
42
42
|
export { isModule } from './module-utils.js';
|
|
43
43
|
export { uuid } from './nanoid/index.js';
|
|
@@ -1,16 +1,30 @@
|
|
|
1
|
-
const getLocalEntity = (
|
|
2
|
-
const data = localStorage.getItem(
|
|
3
|
-
|
|
1
|
+
const getLocalEntity = (key, deleteOnRead = false) => {
|
|
2
|
+
const data = localStorage.getItem(key);
|
|
3
|
+
if (data) {
|
|
4
|
+
if (deleteOnRead) {
|
|
5
|
+
localStorage.removeItem(key);
|
|
6
|
+
}
|
|
7
|
+
return JSON.parse(data);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const clearLocalEntity = (key) => {
|
|
11
|
+
const doomedItem = localStorage.getItem(key);
|
|
12
|
+
if (doomedItem) {
|
|
13
|
+
localStorage.removeItem(key);
|
|
14
|
+
return true;
|
|
15
|
+
} else {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
4
18
|
};
|
|
5
19
|
const getAllLocalEntity = (url) => Object.entries(localStorage).filter(([key]) => key.includes(url)).map(([, value]) => JSON.parse(value));
|
|
6
|
-
const saveLocalEntity = (
|
|
20
|
+
const saveLocalEntity = (key, data) => {
|
|
7
21
|
try {
|
|
8
|
-
localStorage.setItem(
|
|
22
|
+
localStorage.setItem(key, JSON.stringify(data));
|
|
9
23
|
return data;
|
|
10
24
|
} catch {
|
|
11
25
|
return void 0;
|
|
12
26
|
}
|
|
13
27
|
};
|
|
14
28
|
|
|
15
|
-
export { getAllLocalEntity, getLocalEntity, saveLocalEntity };
|
|
29
|
+
export { clearLocalEntity, getAllLocalEntity, getLocalEntity, saveLocalEntity };
|
|
16
30
|
//# sourceMappingURL=local-storage-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-storage-utils.js","sources":["../../../../../../packages/vuu-utils/src/local-storage-utils.ts"],"sourcesContent":["export const getLocalEntity = <T>(
|
|
1
|
+
{"version":3,"file":"local-storage-utils.js","sources":["../../../../../../packages/vuu-utils/src/local-storage-utils.ts"],"sourcesContent":["export const getLocalEntity = <T>(\n key: string,\n deleteOnRead = false,\n): T | undefined => {\n const data = localStorage.getItem(key);\n if (data) {\n if (deleteOnRead) {\n localStorage.removeItem(key);\n }\n return JSON.parse(data);\n }\n};\n\nexport const clearLocalEntity = (key: string) => {\n const doomedItem = localStorage.getItem(key);\n if (doomedItem) {\n localStorage.removeItem(key);\n return true;\n } else {\n return false;\n }\n};\n\nexport const getAllLocalEntity = <T>(url: string): T[] =>\n Object.entries(localStorage)\n .filter(([key]) => key.includes(url))\n .map(([, value]) => JSON.parse(value) as T);\n\nexport const saveLocalEntity = <T>(key: string, data: T): T | undefined => {\n try {\n localStorage.setItem(key, JSON.stringify(data));\n return data;\n } catch {\n return undefined;\n }\n};\n"],"names":[],"mappings":"AAAO,MAAM,cAAiB,GAAA,CAC5B,GACA,EAAA,YAAA,GAAe,KACG,KAAA;AAClB,EAAM,MAAA,IAAA,GAAO,YAAa,CAAA,OAAA,CAAQ,GAAG,CAAA;AACrC,EAAA,IAAI,IAAM,EAAA;AACR,IAAA,IAAI,YAAc,EAAA;AAChB,MAAA,YAAA,CAAa,WAAW,GAAG,CAAA;AAAA;AAE7B,IAAO,OAAA,IAAA,CAAK,MAAM,IAAI,CAAA;AAAA;AAE1B;AAEa,MAAA,gBAAA,GAAmB,CAAC,GAAgB,KAAA;AAC/C,EAAM,MAAA,UAAA,GAAa,YAAa,CAAA,OAAA,CAAQ,GAAG,CAAA;AAC3C,EAAA,IAAI,UAAY,EAAA;AACd,IAAA,YAAA,CAAa,WAAW,GAAG,CAAA;AAC3B,IAAO,OAAA,IAAA;AAAA,GACF,MAAA;AACL,IAAO,OAAA,KAAA;AAAA;AAEX;AAEa,MAAA,iBAAA,GAAoB,CAAI,GAAA,KACnC,MAAO,CAAA,OAAA,CAAQ,YAAY,CAAA,CACxB,MAAO,CAAA,CAAC,CAAC,GAAG,CAAM,KAAA,GAAA,CAAI,SAAS,GAAG,CAAC,CACnC,CAAA,GAAA,CAAI,CAAC,GAAG,KAAK,CAAM,KAAA,IAAA,CAAK,KAAM,CAAA,KAAK,CAAM;AAEjC,MAAA,eAAA,GAAkB,CAAI,GAAA,EAAa,IAA2B,KAAA;AACzE,EAAI,IAAA;AACF,IAAA,YAAA,CAAa,OAAQ,CAAA,GAAA,EAAK,IAAK,CAAA,SAAA,CAAU,IAAI,CAAC,CAAA;AAC9C,IAAO,OAAA,IAAA;AAAA,GACD,CAAA,MAAA;AACN,IAAO,OAAA,KAAA,CAAA;AAAA;AAEX;;;;"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.13.
|
|
2
|
+
"version": "0.13.92",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@vuu-ui/vuu-data-types": "0.13.
|
|
8
|
-
"@vuu-ui/vuu-table-types": "0.13.
|
|
9
|
-
"@vuu-ui/vuu-filter-types": "0.13.
|
|
10
|
-
"@vuu-ui/vuu-protocol-types": "0.13.
|
|
7
|
+
"@vuu-ui/vuu-data-types": "0.13.92",
|
|
8
|
+
"@vuu-ui/vuu-table-types": "0.13.92",
|
|
9
|
+
"@vuu-ui/vuu-filter-types": "0.13.92",
|
|
10
|
+
"@vuu-ui/vuu-protocol-types": "0.13.92"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"@internationalized/date": "^3.0.0",
|
|
14
|
-
"@vuu-ui/vuu-filter-parser": "0.13.
|
|
14
|
+
"@vuu-ui/vuu-filter-parser": "0.13.92",
|
|
15
15
|
"clsx": "^2.0.0",
|
|
16
|
-
"react": "^19.2.
|
|
17
|
-
"react-dom": "^19.2.
|
|
16
|
+
"react": "^19.2.3",
|
|
17
|
+
"react-dom": "^19.2.3"
|
|
18
18
|
},
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"files": [
|
package/types/cookie-utils.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
1
|
export declare const getCookieValue: (name: string) => string | number | undefined;
|
|
2
|
+
/**
|
|
3
|
+
* Sets a cookie value.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} name - Cookie name
|
|
6
|
+
* @param {string} value - Cookie value
|
|
7
|
+
* @param {number} [days] - Optional: number of days until the cookie expires
|
|
8
|
+
*/
|
|
9
|
+
export declare function setCookieValue(name: string, value: string, days?: number): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export declare const getLocalEntity: <T>(
|
|
1
|
+
export declare const getLocalEntity: <T>(key: string, deleteOnRead?: boolean) => T | undefined;
|
|
2
|
+
export declare const clearLocalEntity: (key: string) => boolean;
|
|
2
3
|
export declare const getAllLocalEntity: <T>(url: string) => T[];
|
|
3
|
-
export declare const saveLocalEntity: <T>(
|
|
4
|
+
export declare const saveLocalEntity: <T>(key: string, data: T) => T | undefined;
|