@mirohq/design-system-use-local-storage
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -19,3 +19,3 @@ 'use strict'; | ||
console.error( | ||
`[useLocalStorage] Error reading localStorage key \u201C${key}\u201D:`, | ||
"[useLocalStorage] Error reading localStorage key \u201C".concat(key, "\u201D:"), | ||
e | ||
@@ -34,3 +34,3 @@ ); | ||
console.error( | ||
`[useLocalStorage] Error setting localStorage key \u201C${key}\u201D:`, | ||
"[useLocalStorage] Error setting localStorage key \u201C".concat(key, "\u201D:"), | ||
e | ||
@@ -48,3 +48,3 @@ ); | ||
console.error( | ||
`[useLocalStorage] Error removing localStorage key \u201C${key}\u201D:`, | ||
"[useLocalStorage] Error removing localStorage key \u201C".concat(key, "\u201D:"), | ||
e | ||
@@ -54,5 +54,9 @@ ); | ||
} | ||
const configUseLocalStorage = ({ prefix }) => { | ||
if (prefix !== void 0) | ||
KEY_PREFIX = prefix; | ||
}; | ||
function useLocalStorage(key, defaultValue, { prefix } = {}) { | ||
const prefixedKey = react.useMemo( | ||
() => `${prefix != null ? prefix : KEY_PREFIX}_${key}`, | ||
() => "".concat(prefix != null ? prefix : KEY_PREFIX, "_").concat(key), | ||
[prefix, key] | ||
@@ -89,3 +93,4 @@ ); | ||
exports.configUseLocalStorage = configUseLocalStorage; | ||
exports.useLocalStorage = useLocalStorage; | ||
//# sourceMappingURL=main.js.map |
@@ -15,3 +15,3 @@ import { useEventListener } from '@mirohq/design-system-use-event-listener'; | ||
console.error( | ||
`[useLocalStorage] Error reading localStorage key \u201C${key}\u201D:`, | ||
"[useLocalStorage] Error reading localStorage key \u201C".concat(key, "\u201D:"), | ||
e | ||
@@ -30,3 +30,3 @@ ); | ||
console.error( | ||
`[useLocalStorage] Error setting localStorage key \u201C${key}\u201D:`, | ||
"[useLocalStorage] Error setting localStorage key \u201C".concat(key, "\u201D:"), | ||
e | ||
@@ -44,3 +44,3 @@ ); | ||
console.error( | ||
`[useLocalStorage] Error removing localStorage key \u201C${key}\u201D:`, | ||
"[useLocalStorage] Error removing localStorage key \u201C".concat(key, "\u201D:"), | ||
e | ||
@@ -50,5 +50,9 @@ ); | ||
} | ||
const configUseLocalStorage = ({ prefix }) => { | ||
if (prefix !== void 0) | ||
KEY_PREFIX = prefix; | ||
}; | ||
function useLocalStorage(key, defaultValue, { prefix } = {}) { | ||
const prefixedKey = useMemo( | ||
() => `${prefix != null ? prefix : KEY_PREFIX}_${key}`, | ||
() => "".concat(prefix != null ? prefix : KEY_PREFIX, "_").concat(key), | ||
[prefix, key] | ||
@@ -85,3 +89,3 @@ ); | ||
export { useLocalStorage }; | ||
export { configUseLocalStorage, useLocalStorage }; | ||
//# sourceMappingURL=module.js.map |
interface Config { | ||
prefix?: string; | ||
} | ||
declare const configUseLocalStorage: ({ prefix }: Config) => void; | ||
declare function useLocalStorage<Value, InitValue extends (oldValue: Value) => Value = (oldValue: Value) => Value>(key: string, defaultValue: Value, { prefix }?: Config): [Value, (newValue: Value | InitValue) => void, () => void]; | ||
export { useLocalStorage }; | ||
export { configUseLocalStorage, useLocalStorage }; |
{ | ||
"name": "@mirohq/design-system-use-local-storage", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "", | ||
@@ -29,4 +29,4 @@ "author": "Miro", | ||
"@mirohq/design-system-types": "^0.6.0", | ||
"@mirohq/design-system-use-event": "^0.2.0", | ||
"@mirohq/design-system-use-event-listener": "^0.3.0" | ||
"@mirohq/design-system-use-event-listener": "^0.3.0", | ||
"@mirohq/design-system-use-event": "^0.2.0" | ||
}, | ||
@@ -33,0 +33,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18155
177