@helpwave/hightide 0.1.37 → 0.1.39

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.
Files changed (144) hide show
  1. package/dist/components/date/DatePicker.js.map +1 -1
  2. package/dist/components/date/DatePicker.mjs.map +1 -1
  3. package/dist/components/date/DayPicker.js.map +1 -1
  4. package/dist/components/date/DayPicker.mjs.map +1 -1
  5. package/dist/components/date/TimeDisplay.js.map +1 -1
  6. package/dist/components/date/TimeDisplay.mjs.map +1 -1
  7. package/dist/components/date/YearMonthPicker.js.map +1 -1
  8. package/dist/components/date/YearMonthPicker.mjs.map +1 -1
  9. package/dist/components/date/index.js.map +1 -1
  10. package/dist/components/date/index.mjs.map +1 -1
  11. package/dist/components/dialog/ConfirmDialog.js +15 -9
  12. package/dist/components/dialog/ConfirmDialog.js.map +1 -1
  13. package/dist/components/dialog/ConfirmDialog.mjs +16 -10
  14. package/dist/components/dialog/ConfirmDialog.mjs.map +1 -1
  15. package/dist/components/dialog/Dialog.d.mts +4 -5
  16. package/dist/components/dialog/Dialog.d.ts +4 -5
  17. package/dist/components/dialog/Dialog.js +15 -9
  18. package/dist/components/dialog/Dialog.js.map +1 -1
  19. package/dist/components/dialog/Dialog.mjs +16 -10
  20. package/dist/components/dialog/Dialog.mjs.map +1 -1
  21. package/dist/components/dialog/DiscardChangesDialog.js +15 -9
  22. package/dist/components/dialog/DiscardChangesDialog.js.map +1 -1
  23. package/dist/components/dialog/DiscardChangesDialog.mjs +16 -10
  24. package/dist/components/dialog/DiscardChangesDialog.mjs.map +1 -1
  25. package/dist/components/dialog/InputDialog.js +15 -9
  26. package/dist/components/dialog/InputDialog.js.map +1 -1
  27. package/dist/components/dialog/InputDialog.mjs +16 -10
  28. package/dist/components/dialog/InputDialog.mjs.map +1 -1
  29. package/dist/components/dialog/LanguageDialog.js +188 -154
  30. package/dist/components/dialog/LanguageDialog.js.map +1 -1
  31. package/dist/components/dialog/LanguageDialog.mjs +151 -116
  32. package/dist/components/dialog/LanguageDialog.mjs.map +1 -1
  33. package/dist/components/dialog/ThemeDialog.js +191 -157
  34. package/dist/components/dialog/ThemeDialog.js.map +1 -1
  35. package/dist/components/dialog/ThemeDialog.mjs +151 -116
  36. package/dist/components/dialog/ThemeDialog.mjs.map +1 -1
  37. package/dist/components/dialog/index.js +205 -171
  38. package/dist/components/dialog/index.js.map +1 -1
  39. package/dist/components/dialog/index.mjs +152 -117
  40. package/dist/components/dialog/index.mjs.map +1 -1
  41. package/dist/components/index.js +337 -299
  42. package/dist/components/index.js.map +1 -1
  43. package/dist/components/index.mjs +198 -159
  44. package/dist/components/index.mjs.map +1 -1
  45. package/dist/components/layout/Carousel.d.mts +2 -1
  46. package/dist/components/layout/Carousel.d.ts +2 -1
  47. package/dist/components/layout/Carousel.js +4 -0
  48. package/dist/components/layout/Carousel.js.map +1 -1
  49. package/dist/components/layout/Carousel.mjs +4 -0
  50. package/dist/components/layout/Carousel.mjs.map +1 -1
  51. package/dist/components/layout/TextImage.js.map +1 -1
  52. package/dist/components/layout/TextImage.mjs.map +1 -1
  53. package/dist/components/layout/index.js +4 -0
  54. package/dist/components/layout/index.js.map +1 -1
  55. package/dist/components/layout/index.mjs +4 -0
  56. package/dist/components/layout/index.mjs.map +1 -1
  57. package/dist/components/loading-states/ErrorComponent.js.map +1 -1
  58. package/dist/components/loading-states/ErrorComponent.mjs.map +1 -1
  59. package/dist/components/loading-states/LoadingAnimation.js.map +1 -1
  60. package/dist/components/loading-states/LoadingAnimation.mjs.map +1 -1
  61. package/dist/components/loading-states/index.js.map +1 -1
  62. package/dist/components/loading-states/index.mjs.map +1 -1
  63. package/dist/components/navigation/Pagination.js.map +1 -1
  64. package/dist/components/navigation/Pagination.mjs.map +1 -1
  65. package/dist/components/navigation/StepperBar.js.map +1 -1
  66. package/dist/components/navigation/StepperBar.mjs.map +1 -1
  67. package/dist/components/navigation/index.js.map +1 -1
  68. package/dist/components/navigation/index.mjs.map +1 -1
  69. package/dist/components/properties/CheckboxProperty.js.map +1 -1
  70. package/dist/components/properties/CheckboxProperty.mjs.map +1 -1
  71. package/dist/components/properties/DateProperty.js.map +1 -1
  72. package/dist/components/properties/DateProperty.mjs.map +1 -1
  73. package/dist/components/properties/MultiSelectProperty.js +129 -101
  74. package/dist/components/properties/MultiSelectProperty.js.map +1 -1
  75. package/dist/components/properties/MultiSelectProperty.mjs +131 -102
  76. package/dist/components/properties/MultiSelectProperty.mjs.map +1 -1
  77. package/dist/components/properties/NumberProperty.js.map +1 -1
  78. package/dist/components/properties/NumberProperty.mjs.map +1 -1
  79. package/dist/components/properties/PropertyBase.js.map +1 -1
  80. package/dist/components/properties/PropertyBase.mjs.map +1 -1
  81. package/dist/components/properties/SelectProperty.js +129 -101
  82. package/dist/components/properties/SelectProperty.js.map +1 -1
  83. package/dist/components/properties/SelectProperty.mjs +131 -102
  84. package/dist/components/properties/SelectProperty.mjs.map +1 -1
  85. package/dist/components/properties/TextProperty.js.map +1 -1
  86. package/dist/components/properties/TextProperty.mjs.map +1 -1
  87. package/dist/components/properties/index.js +129 -101
  88. package/dist/components/properties/index.js.map +1 -1
  89. package/dist/components/properties/index.mjs +131 -102
  90. package/dist/components/properties/index.mjs.map +1 -1
  91. package/dist/components/table/Table.js.map +1 -1
  92. package/dist/components/table/Table.mjs.map +1 -1
  93. package/dist/components/table/TableFilterButton.js.map +1 -1
  94. package/dist/components/table/TableFilterButton.mjs.map +1 -1
  95. package/dist/components/table/index.js.map +1 -1
  96. package/dist/components/table/index.mjs.map +1 -1
  97. package/dist/components/user-action/CopyToClipboardWrapper.js.map +1 -1
  98. package/dist/components/user-action/CopyToClipboardWrapper.mjs.map +1 -1
  99. package/dist/components/user-action/DateAndTimePicker.js.map +1 -1
  100. package/dist/components/user-action/DateAndTimePicker.mjs.map +1 -1
  101. package/dist/components/user-action/SearchBar.js.map +1 -1
  102. package/dist/components/user-action/SearchBar.mjs.map +1 -1
  103. package/dist/components/user-action/index.js +129 -101
  104. package/dist/components/user-action/index.js.map +1 -1
  105. package/dist/components/user-action/index.mjs +131 -102
  106. package/dist/components/user-action/index.mjs.map +1 -1
  107. package/dist/components/user-action/select/Select.d.mts +2 -0
  108. package/dist/components/user-action/select/Select.d.ts +2 -0
  109. package/dist/components/user-action/select/Select.js +129 -101
  110. package/dist/components/user-action/select/Select.js.map +1 -1
  111. package/dist/components/user-action/select/Select.mjs +131 -102
  112. package/dist/components/user-action/select/Select.mjs.map +1 -1
  113. package/dist/components/user-action/select/index.js +129 -101
  114. package/dist/components/user-action/select/index.js.map +1 -1
  115. package/dist/components/user-action/select/index.mjs +131 -102
  116. package/dist/components/user-action/select/index.mjs.map +1 -1
  117. package/dist/hooks/index.js.map +1 -1
  118. package/dist/hooks/index.mjs.map +1 -1
  119. package/dist/hooks/useValidators.js.map +1 -1
  120. package/dist/hooks/useValidators.mjs.map +1 -1
  121. package/dist/index.js +362 -324
  122. package/dist/index.js.map +1 -1
  123. package/dist/index.mjs +206 -167
  124. package/dist/index.mjs.map +1 -1
  125. package/dist/localization/LanguageProvider.js +1 -1
  126. package/dist/localization/LanguageProvider.js.map +1 -1
  127. package/dist/localization/LanguageProvider.mjs +1 -1
  128. package/dist/localization/LanguageProvider.mjs.map +1 -1
  129. package/dist/localization/index.js +1 -1
  130. package/dist/localization/index.js.map +1 -1
  131. package/dist/localization/index.mjs +1 -1
  132. package/dist/localization/index.mjs.map +1 -1
  133. package/dist/localization/useTranslation.js.map +1 -1
  134. package/dist/localization/useTranslation.mjs.map +1 -1
  135. package/dist/style/globals.css +0 -3
  136. package/dist/theming/index.js +1 -1
  137. package/dist/theming/index.js.map +1 -1
  138. package/dist/theming/index.mjs +1 -1
  139. package/dist/theming/index.mjs.map +1 -1
  140. package/dist/theming/useTheme.js +1 -1
  141. package/dist/theming/useTheme.js.map +1 -1
  142. package/dist/theming/useTheme.mjs +1 -1
  143. package/dist/theming/useTheme.mjs.map +1 -1
  144. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theming/index.ts","../../src/theming/useTheme.tsx","../../src/hooks/useLocalStorage.ts","../../src/utils/storage.ts","../../src/utils/resolveSetState.ts"],"sourcesContent":["export * from './useTheme'\n","import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'\nimport type { Translation, TranslationPlural } from '../localization/useTranslation'\nimport { useLocalStorage } from '../hooks/useLocalStorage'\n\nconst themes = ['light', 'dark', 'system'] as const\n\nexport type ThemeType = typeof themes[number]\nexport type ResolvedTheme = Exclude<ThemeType, 'system'>\n\nexport type ThemeTypeTranslation = Record<ThemeType, string> & {\n theme: TranslationPlural,\n}\n\nconst defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {\n en: {\n dark: 'Dark',\n light: 'Light',\n system: 'System',\n theme: {\n one: 'Theme',\n other: 'Themes'\n }\n },\n de: {\n dark: 'Dunkel',\n light: 'Hell',\n system: 'System',\n theme: {\n one: 'Farbschema',\n other: 'Farbschemas'\n }\n }\n}\n\nexport const ThemeUtil = {\n themes,\n translation: defaultThemeTypeTranslation,\n}\n\ntype ThemeContextType = {\n theme: ThemeType,\n resolvedTheme: ResolvedTheme,\n setTheme: Dispatch<SetStateAction<ThemeType>>,\n}\n\nexport const ThemeContext = createContext<ThemeContextType | null>(null)\n\ntype ThemeProviderProps = {\n /**\n * Only set this if you want to control the theme yourself\n */\n theme?: ThemeType,\n}\n\nexport const ThemeProvider = ({ children, theme }: PropsWithChildren<ThemeProviderProps>) => {\n const {\n value: storedTheme,\n setValue: setStoredTheme,\n deleteValue: deleteStoredTheme\n } = useLocalStorage<ThemeType>('theme', 'system')\n const [themePreference, setThemePreference] = useState<ThemeType>('system')\n\n const resolvedTheme = useMemo((): ResolvedTheme => {\n if (theme && theme !== 'system') {\n return theme\n }\n if (storedTheme && storedTheme !== 'system') {\n return storedTheme\n }\n if (themePreference !== 'system') {\n return themePreference\n }\n return 'light'\n }, [storedTheme, theme, themePreference])\n\n useEffect(() => {\n if(!theme) return\n if (theme === 'system') {\n deleteStoredTheme()\n } else {\n setStoredTheme(theme)\n }\n }, [theme]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n document.documentElement.setAttribute('data-theme', resolvedTheme)\n }, [resolvedTheme])\n\n const getPreference = useCallback(() => {\n const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n const prefersLight = window.matchMedia('(prefers-color-scheme: light)').matches\n setThemePreference(prefersDark ? 'dark' : (prefersLight ? 'light' : 'system'))\n }, [])\n\n useEffect(() => {\n getPreference()\n }, [getPreference])\n\n useEffect(() => {\n const darkQuery = window.matchMedia('(prefers-color-scheme: dark)')\n const lightQuery = window.matchMedia('(prefers-color-scheme: light)')\n const noPrefQuery = window.matchMedia('(prefers-color-scheme: no-preference)')\n darkQuery.addEventListener('change', getPreference)\n lightQuery.addEventListener('change', getPreference)\n noPrefQuery.addEventListener('change', getPreference)\n return () => {\n darkQuery.removeEventListener('change', getPreference)\n lightQuery.removeEventListener('change', getPreference)\n noPrefQuery.removeEventListener('change', getPreference)\n }\n }, [getPreference])\n\n return (\n <ThemeContext.Provider\n value={{\n theme: storedTheme,\n resolvedTheme,\n setTheme: (newTheme) => {\n if (theme) {\n console.warn('ThemeProvider: Attempting to change the ' +\n \"theme while setting a fixed theme won't have any effect. \" +\n 'Change the theme provided to the ThemeProvider instead.')\n }\n setStoredTheme(newTheme)\n }\n }}\n >\n {children}\n </ThemeContext.Provider>\n )\n}\n\nexport const useTheme = () => {\n const context = useContext(ThemeContext)\n if (!context) {\n throw new Error('useTheme must be used within ThemeContext. Try adding a ThemeProvider around your app.')\n }\n return context\n}\n","'use client'\n\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useState } from 'react'\nimport { LocalStorageService } from '@/src/utils/storage'\nimport { resolveSetState } from '@/src/utils/resolveSetState'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\n\ntype UseLocalStorageResult<T> = {\n value: T,\n setValue: SetValue<T>,\n deleteValue: () => void,\n}\n\n/**\n * @param key Key under which to save the data\n * @param backupValue Used if the storage is unavailable or no value is present\n *\n * The backup value will never be saved to the storage unless you explicitly\n */\nexport const useLocalStorage = <T>(key: string, backupValue: T): UseLocalStorageResult<T> => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return backupValue\n }\n const storageService = new LocalStorageService()\n try {\n const value = storageService.get<T>(key)\n return value || backupValue\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_) {\n console.warn('useLocalStorage: Error while reading the stored value. Make sure your typing is correct.')\n storageService.delete(key)\n console.info(`useLocalStorage: deleted erroneous value for key: ${key}`)\n return backupValue\n }\n }, [backupValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(action => {\n const newValue = resolveSetState(action, storedValue)\n const storageService = new LocalStorageService()\n storageService.set(key, newValue)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n const deleteValue = () => {\n const storageService = new LocalStorageService()\n storageService.delete(key)\n setStoredValue(backupValue)\n }\n\n return { value: storedValue, setValue, deleteValue }\n}","class StorageService {\n // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript\n\n constructor(private storage: Storage) {\n }\n\n public get<T>(key: string): T | null {\n const value = this.storage.getItem(key)\n if (value === null) {\n return null\n }\n return JSON.parse(value)\n }\n\n public set<T>(key: string, value: T) {\n this.storage.setItem(key, JSON.stringify(value))\n }\n\n public delete(key: string) {\n this.storage.removeItem(key)\n }\n\n public deleteAll() {\n this.storage.clear()\n }\n}\n\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(window.localStorage)\n }\n}\n\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(window.sessionStorage)\n }\n}\n","import type { SetStateAction } from 'react'\n\nexport function resolveSetState<T>(action: SetStateAction<T>, prev: T): T {\n return typeof action === 'function' ? (action as (prev: T) => T)(prev) : action\n}"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA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QAAM,cAAU,0BAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,wFAAwF;AAAA,EAC1G;AACA,SAAO;AACT;","names":["import_react"]}
1
+ {"version":3,"sources":["../../src/theming/index.ts","../../src/theming/useTheme.tsx","../../src/hooks/useLocalStorage.ts","../../src/utils/storage.ts","../../src/utils/resolveSetState.ts"],"sourcesContent":["export * from './useTheme'\n","import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'\nimport type { Translation, TranslationPlural } from '../localization/useTranslation'\nimport { useLocalStorage } from '../hooks/useLocalStorage'\n\nconst themes = ['light', 'dark', 'system'] as const\n\nexport type ThemeType = typeof themes[number]\nexport type ResolvedTheme = Exclude<ThemeType, 'system'>\n\nexport type ThemeTypeTranslation = Record<ThemeType, string> & {\n theme: TranslationPlural,\n}\n\nconst defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {\n en: {\n dark: 'Dark',\n light: 'Light',\n system: 'System',\n theme: {\n one: 'Theme',\n other: 'Themes'\n }\n },\n de: {\n dark: 'Dunkel',\n light: 'Hell',\n system: 'System',\n theme: {\n one: 'Farbschema',\n other: 'Farbschemas'\n }\n }\n}\n\nexport const ThemeUtil = {\n themes,\n translation: defaultThemeTypeTranslation,\n}\n\ntype ThemeContextType = {\n theme: ThemeType,\n resolvedTheme: ResolvedTheme,\n setTheme: Dispatch<SetStateAction<ThemeType>>,\n}\n\nexport const ThemeContext = createContext<ThemeContextType | null>(null)\n\ntype ThemeProviderProps = {\n /**\n * Only set this if you want to control the theme yourself\n */\n theme?: ThemeType,\n}\n\nexport const ThemeProvider = ({ children, theme }: PropsWithChildren<ThemeProviderProps>) => {\n const {\n value: storedTheme,\n setValue: setStoredTheme,\n deleteValue: deleteStoredTheme\n } = useLocalStorage<ThemeType>('theme', 'system')\n const [themePreference, setThemePreference] = useState<ThemeType>('system')\n\n const resolvedTheme = useMemo((): ResolvedTheme => {\n if (theme && theme !== 'system') {\n return theme\n }\n if (storedTheme && storedTheme !== 'system') {\n return storedTheme\n }\n if (themePreference !== 'system') {\n return themePreference\n }\n return 'light'\n }, [storedTheme, theme, themePreference])\n\n useEffect(() => {\n if(!theme) return\n if (theme === 'system') {\n deleteStoredTheme()\n } else {\n setStoredTheme(theme)\n }\n }, [theme]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n document.documentElement.setAttribute('data-theme', resolvedTheme)\n }, [resolvedTheme])\n\n const getPreference = useCallback(() => {\n const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n const prefersLight = window.matchMedia('(prefers-color-scheme: light)').matches\n setThemePreference(prefersDark ? 'dark' : (prefersLight ? 'light' : 'system'))\n }, [])\n\n useEffect(() => {\n getPreference()\n }, [getPreference])\n\n useEffect(() => {\n const darkQuery = window.matchMedia('(prefers-color-scheme: dark)')\n const lightQuery = window.matchMedia('(prefers-color-scheme: light)')\n const noPrefQuery = window.matchMedia('(prefers-color-scheme: no-preference)')\n darkQuery.addEventListener('change', getPreference)\n lightQuery.addEventListener('change', getPreference)\n noPrefQuery.addEventListener('change', getPreference)\n return () => {\n darkQuery.removeEventListener('change', getPreference)\n lightQuery.removeEventListener('change', getPreference)\n noPrefQuery.removeEventListener('change', getPreference)\n }\n }, [getPreference])\n\n return (\n <ThemeContext.Provider\n value={{\n theme: storedTheme,\n resolvedTheme,\n setTheme: (newTheme) => {\n if (theme && theme !== 'system') {\n console.warn('ThemeProvider: Attempting to change the ' +\n \"theme while setting a fixed theme won't have any effect. \" +\n 'Change the theme provided to the ThemeProvider instead.')\n }\n setStoredTheme(newTheme)\n }\n }}\n >\n {children}\n </ThemeContext.Provider>\n )\n}\n\nexport const useTheme = () => {\n const context = useContext(ThemeContext)\n if (!context) {\n throw new Error('useTheme must be used within ThemeContext. Try adding a ThemeProvider around your app.')\n }\n return context\n}\n","'use client'\n\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useState } from 'react'\nimport { LocalStorageService } from '@/src/utils/storage'\nimport { resolveSetState } from '@/src/utils/resolveSetState'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\n\ntype UseLocalStorageResult<T> = {\n value: T,\n setValue: SetValue<T>,\n deleteValue: () => void,\n}\n\n/**\n * @param key Key under which to save the data\n * @param backupValue Used if the storage is unavailable or no value is present\n *\n * The backup value will never be saved to the storage unless you explicitly\n */\nexport const useLocalStorage = <T>(key: string, backupValue: T): UseLocalStorageResult<T> => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return backupValue\n }\n const storageService = new LocalStorageService()\n try {\n const value = storageService.get<T>(key)\n return value || backupValue\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_) {\n console.warn('useLocalStorage: Error while reading the stored value. Make sure your typing is correct.')\n storageService.delete(key)\n console.info(`useLocalStorage: deleted erroneous value for key: ${key}`)\n return backupValue\n }\n }, [backupValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(action => {\n const newValue = resolveSetState(action, storedValue)\n const storageService = new LocalStorageService()\n storageService.set(key, newValue)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n const deleteValue = () => {\n const storageService = new LocalStorageService()\n storageService.delete(key)\n setStoredValue(backupValue)\n }\n\n return { value: storedValue, setValue, deleteValue }\n}","class StorageService {\n // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript\n\n constructor(private storage: Storage) {\n }\n\n public get<T>(key: string): T | null {\n const value = this.storage.getItem(key)\n if (value === null) {\n return null\n }\n return JSON.parse(value)\n }\n\n public set<T>(key: string, value: T) {\n this.storage.setItem(key, JSON.stringify(value))\n }\n\n public delete(key: string) {\n this.storage.removeItem(key)\n }\n\n public deleteAll() {\n this.storage.clear()\n }\n}\n\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(window.localStorage)\n }\n}\n\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(window.sessionStorage)\n }\n}\n","import type { SetStateAction } from 'react'\n\nexport function resolveSetState<T>(action: SetStateAction<T>, prev: T): T {\n return typeof action === 'function' ? (action as (prev: T) => T)(prev) : action\n}"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAAA,gBAAqF;;;ACErF,mBAAsC;;;ACHtC,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAGnB,YAAoB,SAAkB;AAAlB;AAAA,EACpB;AAAA,EAEO,IAAO,KAAuB;AACnC,UAAM,QAAQ,KAAK,QAAQ,QAAQ,GAAG;AACtC,QAAI,UAAU,MAAM;AAClB,aAAO;AAAA,IACT;AACA,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AAAA,EAEO,IAAO,KAAa,OAAU;AACnC,SAAK,QAAQ,QAAQ,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EACjD;AAAA,EAEO,OAAO,KAAa;AACzB,SAAK,QAAQ,WAAW,GAAG;AAAA,EAC7B;AAAA,EAEO,YAAY;AACjB,SAAK,QAAQ,MAAM;AAAA,EACrB;AACF;AAEO,IAAM,sBAAN,cAAkC,eAAe;AAAA,EACtD,cAAc;AACZ,UAAM,OAAO,YAAY;AAAA,EAC3B;AACF;;;AC7BO,SAAS,gBAAmB,QAA2B,MAAY;AACxE,SAAO,OAAO,WAAW,aAAc,OAA0B,IAAI,IAAI;AAC3E;;;AFiBO,IAAM,kBAAkB,CAAI,KAAa,gBAA6C;AAC3F,QAAM,UAAM,0BAAY,MAAS;AAC/B,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACT;AACA,UAAM,iBAAiB,IAAI,oBAAoB;AAC/C,QAAI;AACF,YAAM,QAAQ,eAAe,IAAO,GAAG;AACvC,aAAO,SAAS;AAAA,IAElB,SAAS,GAAG;AACV,cAAQ,KAAK,0FAA0F;AACvG,qBAAe,OAAO,GAAG;AACzB,cAAQ,KAAK,qDAAqD,GAAG,EAA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U,UAAU;AAC/B,oBAAQ,KAAK,0JAE8C;AAAA,UAC7D;AACA,yBAAe,QAAQ;AAAA,QACzB;AAAA,MACF;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEO,IAAM,WAAW,MAAM;AAC5B,QAAM,cAAU,0BAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,wFAAwF;AAAA,EAC1G;AACA,SAAO;AACT;","names":["import_react"]}
@@ -156,7 +156,7 @@ var ThemeProvider = ({ children, theme }) => {
156
156
  theme: storedTheme,
157
157
  resolvedTheme,
158
158
  setTheme: (newTheme) => {
159
- if (theme) {
159
+ if (theme && theme !== "system") {
160
160
  console.warn("ThemeProvider: Attempting to change the theme while setting a fixed theme won't have any effect. Change the theme provided to the ThemeProvider instead.");
161
161
  }
162
162
  setStoredTheme(newTheme);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theming/useTheme.tsx","../../src/hooks/useLocalStorage.ts","../../src/utils/storage.ts","../../src/utils/resolveSetState.ts"],"sourcesContent":["import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'\nimport type { Translation, TranslationPlural } from '../localization/useTranslation'\nimport { useLocalStorage } from '../hooks/useLocalStorage'\n\nconst themes = ['light', 'dark', 'system'] as const\n\nexport type ThemeType = typeof themes[number]\nexport type ResolvedTheme = Exclude<ThemeType, 'system'>\n\nexport type ThemeTypeTranslation = Record<ThemeType, string> & {\n theme: TranslationPlural,\n}\n\nconst defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {\n en: {\n dark: 'Dark',\n light: 'Light',\n system: 'System',\n theme: {\n one: 'Theme',\n other: 'Themes'\n }\n },\n de: {\n dark: 'Dunkel',\n light: 'Hell',\n system: 'System',\n theme: {\n one: 'Farbschema',\n other: 'Farbschemas'\n }\n }\n}\n\nexport const ThemeUtil = {\n themes,\n translation: defaultThemeTypeTranslation,\n}\n\ntype ThemeContextType = {\n theme: ThemeType,\n resolvedTheme: ResolvedTheme,\n setTheme: Dispatch<SetStateAction<ThemeType>>,\n}\n\nexport const ThemeContext = createContext<ThemeContextType | null>(null)\n\ntype ThemeProviderProps = {\n /**\n * Only set this if you want to control the theme yourself\n */\n theme?: ThemeType,\n}\n\nexport const ThemeProvider = ({ children, theme }: PropsWithChildren<ThemeProviderProps>) => {\n const {\n value: storedTheme,\n setValue: setStoredTheme,\n deleteValue: deleteStoredTheme\n } = useLocalStorage<ThemeType>('theme', 'system')\n const [themePreference, setThemePreference] = useState<ThemeType>('system')\n\n const resolvedTheme = useMemo((): ResolvedTheme => {\n if (theme && theme !== 'system') {\n return theme\n }\n if (storedTheme && storedTheme !== 'system') {\n return storedTheme\n }\n if (themePreference !== 'system') {\n return themePreference\n }\n return 'light'\n }, [storedTheme, theme, themePreference])\n\n useEffect(() => {\n if(!theme) return\n if (theme === 'system') {\n deleteStoredTheme()\n } else {\n setStoredTheme(theme)\n }\n }, [theme]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n document.documentElement.setAttribute('data-theme', resolvedTheme)\n }, [resolvedTheme])\n\n const getPreference = useCallback(() => {\n const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n const prefersLight = window.matchMedia('(prefers-color-scheme: light)').matches\n setThemePreference(prefersDark ? 'dark' : (prefersLight ? 'light' : 'system'))\n }, [])\n\n useEffect(() => {\n getPreference()\n }, [getPreference])\n\n useEffect(() => {\n const darkQuery = window.matchMedia('(prefers-color-scheme: dark)')\n const lightQuery = window.matchMedia('(prefers-color-scheme: light)')\n const noPrefQuery = window.matchMedia('(prefers-color-scheme: no-preference)')\n darkQuery.addEventListener('change', getPreference)\n lightQuery.addEventListener('change', getPreference)\n noPrefQuery.addEventListener('change', getPreference)\n return () => {\n darkQuery.removeEventListener('change', getPreference)\n lightQuery.removeEventListener('change', getPreference)\n noPrefQuery.removeEventListener('change', getPreference)\n }\n }, [getPreference])\n\n return (\n <ThemeContext.Provider\n value={{\n theme: storedTheme,\n resolvedTheme,\n setTheme: (newTheme) => {\n if (theme) {\n console.warn('ThemeProvider: Attempting to change the ' +\n \"theme while setting a fixed theme won't have any effect. \" +\n 'Change the theme provided to the ThemeProvider instead.')\n }\n setStoredTheme(newTheme)\n }\n }}\n >\n {children}\n </ThemeContext.Provider>\n )\n}\n\nexport const useTheme = () => {\n const context = useContext(ThemeContext)\n if (!context) {\n throw new Error('useTheme must be used within ThemeContext. Try adding a ThemeProvider around your app.')\n }\n return context\n}\n","'use client'\n\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useState } from 'react'\nimport { LocalStorageService } from '@/src/utils/storage'\nimport { resolveSetState } from '@/src/utils/resolveSetState'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\n\ntype UseLocalStorageResult<T> = {\n value: T,\n setValue: SetValue<T>,\n deleteValue: () => void,\n}\n\n/**\n * @param key Key under which to save the data\n * @param backupValue Used if the storage is unavailable or no value is present\n *\n * The backup value will never be saved to the storage unless you explicitly\n */\nexport const useLocalStorage = <T>(key: string, backupValue: T): UseLocalStorageResult<T> => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return backupValue\n }\n const storageService = new LocalStorageService()\n try {\n const value = storageService.get<T>(key)\n return value || backupValue\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_) {\n console.warn('useLocalStorage: Error while reading the stored value. Make sure your typing is correct.')\n storageService.delete(key)\n console.info(`useLocalStorage: deleted erroneous value for key: ${key}`)\n return backupValue\n }\n }, [backupValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(action => {\n const newValue = resolveSetState(action, storedValue)\n const storageService = new LocalStorageService()\n storageService.set(key, newValue)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n const deleteValue = () => {\n const storageService = new LocalStorageService()\n storageService.delete(key)\n setStoredValue(backupValue)\n }\n\n return { value: storedValue, setValue, deleteValue }\n}","class StorageService {\n // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript\n\n constructor(private storage: Storage) {\n }\n\n public get<T>(key: string): T | null {\n const value = this.storage.getItem(key)\n if (value === null) {\n return null\n }\n return JSON.parse(value)\n }\n\n public set<T>(key: string, value: T) {\n this.storage.setItem(key, JSON.stringify(value))\n }\n\n public delete(key: string) {\n this.storage.removeItem(key)\n }\n\n public deleteAll() {\n this.storage.clear()\n }\n}\n\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(window.localStorage)\n }\n}\n\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(window.sessionStorage)\n }\n}\n","import type { SetStateAction } from 'react'\n\nexport function resolveSetState<T>(action: SetStateAction<T>, prev: T): T {\n return typeof action === 'function' ? (action as (prev: T) => T)(prev) : action\n}"],"mappings":";AACA,SAAS,eAAe,eAAAA,cAAa,YAAY,WAAW,SAAS,YAAAC,iBAAgB;;;ACErF,SAAS,aAAa,gBAAgB;;;ACHtC,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAGnB,YAAoB,SAAkB;AAAlB;AAAA,EACpB;AAAA,EAEO,IAAO,KAAuB;AACnC,UAAM,QAAQ,KAAK,QAAQ,QAAQ,GAAG;AACtC,QAAI,UAAU,MAAM;AAClB,aAAO;AAAA,IACT;AACA,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AAAA,EAEO,IAAO,KAAa,OAAU;AACnC,SAAK,QAAQ,QAAQ,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EACjD;AAAA,EAEO,OAAO,KAAa;AACzB,SAAK,QAAQ,WAAW,GAAG;AAAA,EAC7B;AAAA,EAEO,YAAY;AACjB,SAAK,QAAQ,MAAM;AAAA,EACrB;AACF;AAEO,IAAM,sBAAN,cAAkC,eAAe;AAAA,EACtD,cAAc;AACZ,UAAM,OAAO,YAAY;AAAA,EAC3B;AACF;;;AC7BO,SAAS,gBAAmB,QAA2B,MAAY;AACxE,SAAO,OAAO,WAAW,aAAc,OAA0B,IA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iB,UAAU,aAAa;AACnD,gBAAY,iBAAiB,UAAU,aAAa;AACpD,WAAO,MAAM;AACX,gBAAU,oBAAoB,UAAU,aAAa;AACrD,iBAAW,oBAAoB,UAAU,aAAa;AACtD,kBAAY,oBAAoB,UAAU,aAAa;AAAA,IACzD;AAAA,EACF,GAAG,CAAC,aAAa,CAAC;AAElB,SACE;AAAA,IAAC,aAAa;AAAA,IAAb;AAAA,MACC,OAAO;AAAA,QACL,OAAO;AAAA,QACP;AAAA,QACA,UAAU,CAAC,aAAa;AACtB,cAAI,OAAO;AACT,oBAAQ,KAAK,0JAE8C;AAAA,UAC7D;AACA,yBAAe,QAAQ;AAAA,QACzB;AAAA,MACF;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEO,IAAM,WAAW,MAAM;AAC5B,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,wFAAwF;AAAA,EAC1G;AACA,SAAO;AACT;","names":["useCallback","useState","useState","useCallback"]}
1
+ {"version":3,"sources":["../../src/theming/useTheme.tsx","../../src/hooks/useLocalStorage.ts","../../src/utils/storage.ts","../../src/utils/resolveSetState.ts"],"sourcesContent":["import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'\nimport type { Translation, TranslationPlural } from '../localization/useTranslation'\nimport { useLocalStorage } from '../hooks/useLocalStorage'\n\nconst themes = ['light', 'dark', 'system'] as const\n\nexport type ThemeType = typeof themes[number]\nexport type ResolvedTheme = Exclude<ThemeType, 'system'>\n\nexport type ThemeTypeTranslation = Record<ThemeType, string> & {\n theme: TranslationPlural,\n}\n\nconst defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {\n en: {\n dark: 'Dark',\n light: 'Light',\n system: 'System',\n theme: {\n one: 'Theme',\n other: 'Themes'\n }\n },\n de: {\n dark: 'Dunkel',\n light: 'Hell',\n system: 'System',\n theme: {\n one: 'Farbschema',\n other: 'Farbschemas'\n }\n }\n}\n\nexport const ThemeUtil = {\n themes,\n translation: defaultThemeTypeTranslation,\n}\n\ntype ThemeContextType = {\n theme: ThemeType,\n resolvedTheme: ResolvedTheme,\n setTheme: Dispatch<SetStateAction<ThemeType>>,\n}\n\nexport const ThemeContext = createContext<ThemeContextType | null>(null)\n\ntype ThemeProviderProps = {\n /**\n * Only set this if you want to control the theme yourself\n */\n theme?: ThemeType,\n}\n\nexport const ThemeProvider = ({ children, theme }: PropsWithChildren<ThemeProviderProps>) => {\n const {\n value: storedTheme,\n setValue: setStoredTheme,\n deleteValue: deleteStoredTheme\n } = useLocalStorage<ThemeType>('theme', 'system')\n const [themePreference, setThemePreference] = useState<ThemeType>('system')\n\n const resolvedTheme = useMemo((): ResolvedTheme => {\n if (theme && theme !== 'system') {\n return theme\n }\n if (storedTheme && storedTheme !== 'system') {\n return storedTheme\n }\n if (themePreference !== 'system') {\n return themePreference\n }\n return 'light'\n }, [storedTheme, theme, themePreference])\n\n useEffect(() => {\n if(!theme) return\n if (theme === 'system') {\n deleteStoredTheme()\n } else {\n setStoredTheme(theme)\n }\n }, [theme]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n document.documentElement.setAttribute('data-theme', resolvedTheme)\n }, [resolvedTheme])\n\n const getPreference = useCallback(() => {\n const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n const prefersLight = window.matchMedia('(prefers-color-scheme: light)').matches\n setThemePreference(prefersDark ? 'dark' : (prefersLight ? 'light' : 'system'))\n }, [])\n\n useEffect(() => {\n getPreference()\n }, [getPreference])\n\n useEffect(() => {\n const darkQuery = window.matchMedia('(prefers-color-scheme: dark)')\n const lightQuery = window.matchMedia('(prefers-color-scheme: light)')\n const noPrefQuery = window.matchMedia('(prefers-color-scheme: no-preference)')\n darkQuery.addEventListener('change', getPreference)\n lightQuery.addEventListener('change', getPreference)\n noPrefQuery.addEventListener('change', getPreference)\n return () => {\n darkQuery.removeEventListener('change', getPreference)\n lightQuery.removeEventListener('change', getPreference)\n noPrefQuery.removeEventListener('change', getPreference)\n }\n }, [getPreference])\n\n return (\n <ThemeContext.Provider\n value={{\n theme: storedTheme,\n resolvedTheme,\n setTheme: (newTheme) => {\n if (theme && theme !== 'system') {\n console.warn('ThemeProvider: Attempting to change the ' +\n \"theme while setting a fixed theme won't have any effect. \" +\n 'Change the theme provided to the ThemeProvider instead.')\n }\n setStoredTheme(newTheme)\n }\n }}\n >\n {children}\n </ThemeContext.Provider>\n )\n}\n\nexport const useTheme = () => {\n const context = useContext(ThemeContext)\n if (!context) {\n throw new Error('useTheme must be used within ThemeContext. Try adding a ThemeProvider around your app.')\n }\n return context\n}\n","'use client'\n\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useState } from 'react'\nimport { LocalStorageService } from '@/src/utils/storage'\nimport { resolveSetState } from '@/src/utils/resolveSetState'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\n\ntype UseLocalStorageResult<T> = {\n value: T,\n setValue: SetValue<T>,\n deleteValue: () => void,\n}\n\n/**\n * @param key Key under which to save the data\n * @param backupValue Used if the storage is unavailable or no value is present\n *\n * The backup value will never be saved to the storage unless you explicitly\n */\nexport const useLocalStorage = <T>(key: string, backupValue: T): UseLocalStorageResult<T> => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return backupValue\n }\n const storageService = new LocalStorageService()\n try {\n const value = storageService.get<T>(key)\n return value || backupValue\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_) {\n console.warn('useLocalStorage: Error while reading the stored value. Make sure your typing is correct.')\n storageService.delete(key)\n console.info(`useLocalStorage: deleted erroneous value for key: ${key}`)\n return backupValue\n }\n }, [backupValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(action => {\n const newValue = resolveSetState(action, storedValue)\n const storageService = new LocalStorageService()\n storageService.set(key, newValue)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n const deleteValue = () => {\n const storageService = new LocalStorageService()\n storageService.delete(key)\n setStoredValue(backupValue)\n }\n\n return { value: storedValue, setValue, deleteValue }\n}","class StorageService {\n // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript\n\n constructor(private storage: Storage) {\n }\n\n public get<T>(key: string): T | null {\n const value = this.storage.getItem(key)\n if (value === null) {\n return null\n }\n return JSON.parse(value)\n }\n\n public set<T>(key: string, value: T) {\n this.storage.setItem(key, JSON.stringify(value))\n }\n\n public delete(key: string) {\n this.storage.removeItem(key)\n }\n\n public deleteAll() {\n this.storage.clear()\n }\n}\n\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(window.localStorage)\n }\n}\n\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(window.sessionStorage)\n }\n}\n","import type { SetStateAction } from 'react'\n\nexport function resolveSetState<T>(action: SetStateAction<T>, prev: T): T {\n return typeof action === 'function' ? (action as (prev: T) => T)(prev) : action\n}"],"mappings":";AACA,SAAS,eAAe,eAAAA,cAAa,YAAY,WAAW,SAAS,YAAAC,iBAAgB;;;ACErF,SAAS,aAAa,gBAAgB;;;ACHtC,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAGnB,YAAoB,SAAkB;AAAlB;AAAA,EACpB;AAAA,EAEO,IAAO,KAAuB;AACnC,UAAM,QAAQ,KAAK,QAAQ,QAAQ,GAAG;AACtC,QAAI,UAAU,MAAM;AAClB,aAAO;AAAA,IACT;AACA,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AAAA,EAEO,IAAO,KAAa,OAAU;AACnC,SAAK,QAAQ,QAAQ,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EACjD;AAAA,EAEO,OAAO,KAAa;AACzB,SAAK,QAAQ,WAAW,GAAG;AAAA,EAC7B;AAAA,EAEO,YAAY;AACjB,SAAK,QAAQ,MAAM;AAAA,EACrB;AACF;AAEO,IAAM,sBAAN,cAAkC,eAAe;AAAA,EACtD,cAAc;AACZ,UAAM,OAAO,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AW,+BAA+B;AACpE,UAAM,cAAc,OAAO,WAAW,uCAAuC;AAC7E,cAAU,iBAAiB,UAAU,aAAa;AAClD,eAAW,iBAAiB,UAAU,aAAa;AACnD,gBAAY,iBAAiB,UAAU,aAAa;AACpD,WAAO,MAAM;AACX,gBAAU,oBAAoB,UAAU,aAAa;AACrD,iBAAW,oBAAoB,UAAU,aAAa;AACtD,kBAAY,oBAAoB,UAAU,aAAa;AAAA,IACzD;AAAA,EACF,GAAG,CAAC,aAAa,CAAC;AAElB,SACE;AAAA,IAAC,aAAa;AAAA,IAAb;AAAA,MACC,OAAO;AAAA,QACL,OAAO;AAAA,QACP;AAAA,QACA,UAAU,CAAC,aAAa;AACtB,cAAI,SAAS,UAAU,UAAU;AAC/B,oBAAQ,KAAK,0JAE8C;AAAA,UAC7D;AACA,yBAAe,QAAQ;AAAA,QACzB;AAAA,MACF;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEO,IAAM,WAAW,MAAM;AAC5B,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,wFAAwF;AAAA,EAC1G;AACA,SAAO;AACT;","names":["useCallback","useState","useState","useCallback"]}
@@ -182,7 +182,7 @@ var ThemeProvider = ({ children, theme }) => {
182
182
  theme: storedTheme,
183
183
  resolvedTheme,
184
184
  setTheme: (newTheme) => {
185
- if (theme) {
185
+ if (theme && theme !== "system") {
186
186
  console.warn("ThemeProvider: Attempting to change the theme while setting a fixed theme won't have any effect. Change the theme provided to the ThemeProvider instead.");
187
187
  }
188
188
  setStoredTheme(newTheme);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theming/useTheme.tsx","../../src/hooks/useLocalStorage.ts","../../src/utils/storage.ts","../../src/utils/resolveSetState.ts"],"sourcesContent":["import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'\nimport type { Translation, TranslationPlural } from '../localization/useTranslation'\nimport { useLocalStorage } from '../hooks/useLocalStorage'\n\nconst themes = ['light', 'dark', 'system'] as const\n\nexport type ThemeType = typeof themes[number]\nexport type ResolvedTheme = Exclude<ThemeType, 'system'>\n\nexport type ThemeTypeTranslation = Record<ThemeType, string> & {\n theme: TranslationPlural,\n}\n\nconst defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {\n en: {\n dark: 'Dark',\n light: 'Light',\n system: 'System',\n theme: {\n one: 'Theme',\n other: 'Themes'\n }\n },\n de: {\n dark: 'Dunkel',\n light: 'Hell',\n system: 'System',\n theme: {\n one: 'Farbschema',\n other: 'Farbschemas'\n }\n }\n}\n\nexport const ThemeUtil = {\n themes,\n translation: defaultThemeTypeTranslation,\n}\n\ntype ThemeContextType = {\n theme: ThemeType,\n resolvedTheme: ResolvedTheme,\n setTheme: Dispatch<SetStateAction<ThemeType>>,\n}\n\nexport const ThemeContext = createContext<ThemeContextType | null>(null)\n\ntype ThemeProviderProps = {\n /**\n * Only set this if you want to control the theme yourself\n */\n theme?: ThemeType,\n}\n\nexport const ThemeProvider = ({ children, theme }: PropsWithChildren<ThemeProviderProps>) => {\n const {\n value: storedTheme,\n setValue: setStoredTheme,\n deleteValue: deleteStoredTheme\n } = useLocalStorage<ThemeType>('theme', 'system')\n const [themePreference, setThemePreference] = useState<ThemeType>('system')\n\n const resolvedTheme = useMemo((): ResolvedTheme => {\n if (theme && theme !== 'system') {\n return theme\n }\n if (storedTheme && storedTheme !== 'system') {\n return storedTheme\n }\n if (themePreference !== 'system') {\n return themePreference\n }\n return 'light'\n }, [storedTheme, theme, themePreference])\n\n useEffect(() => {\n if(!theme) return\n if (theme === 'system') {\n deleteStoredTheme()\n } else {\n setStoredTheme(theme)\n }\n }, [theme]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n document.documentElement.setAttribute('data-theme', resolvedTheme)\n }, [resolvedTheme])\n\n const getPreference = useCallback(() => {\n const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n const prefersLight = window.matchMedia('(prefers-color-scheme: light)').matches\n setThemePreference(prefersDark ? 'dark' : (prefersLight ? 'light' : 'system'))\n }, [])\n\n useEffect(() => {\n getPreference()\n }, [getPreference])\n\n useEffect(() => {\n const darkQuery = window.matchMedia('(prefers-color-scheme: dark)')\n const lightQuery = window.matchMedia('(prefers-color-scheme: light)')\n const noPrefQuery = window.matchMedia('(prefers-color-scheme: no-preference)')\n darkQuery.addEventListener('change', getPreference)\n lightQuery.addEventListener('change', getPreference)\n noPrefQuery.addEventListener('change', getPreference)\n return () => {\n darkQuery.removeEventListener('change', getPreference)\n lightQuery.removeEventListener('change', getPreference)\n noPrefQuery.removeEventListener('change', getPreference)\n }\n }, [getPreference])\n\n return (\n <ThemeContext.Provider\n value={{\n theme: storedTheme,\n resolvedTheme,\n setTheme: (newTheme) => {\n if (theme) {\n console.warn('ThemeProvider: Attempting to change the ' +\n \"theme while setting a fixed theme won't have any effect. \" +\n 'Change the theme provided to the ThemeProvider instead.')\n }\n setStoredTheme(newTheme)\n }\n }}\n >\n {children}\n </ThemeContext.Provider>\n )\n}\n\nexport const useTheme = () => {\n const context = useContext(ThemeContext)\n if (!context) {\n throw new Error('useTheme must be used within ThemeContext. Try adding a ThemeProvider around your app.')\n }\n return context\n}\n","'use client'\n\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useState } from 'react'\nimport { LocalStorageService } from '@/src/utils/storage'\nimport { resolveSetState } from '@/src/utils/resolveSetState'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\n\ntype UseLocalStorageResult<T> = {\n value: T,\n setValue: SetValue<T>,\n deleteValue: () => void,\n}\n\n/**\n * @param key Key under which to save the data\n * @param backupValue Used if the storage is unavailable or no value is present\n *\n * The backup value will never be saved to the storage unless you explicitly\n */\nexport const useLocalStorage = <T>(key: string, backupValue: T): UseLocalStorageResult<T> => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return backupValue\n }\n const storageService = new LocalStorageService()\n try {\n const value = storageService.get<T>(key)\n return value || backupValue\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_) {\n console.warn('useLocalStorage: Error while reading the stored value. Make sure your typing is correct.')\n storageService.delete(key)\n console.info(`useLocalStorage: deleted erroneous value for key: ${key}`)\n return backupValue\n }\n }, [backupValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(action => {\n const newValue = resolveSetState(action, storedValue)\n const storageService = new LocalStorageService()\n storageService.set(key, newValue)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n const deleteValue = () => {\n const storageService = new LocalStorageService()\n storageService.delete(key)\n setStoredValue(backupValue)\n }\n\n return { value: storedValue, setValue, deleteValue }\n}","class StorageService {\n // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript\n\n constructor(private storage: Storage) {\n }\n\n public get<T>(key: string): T | null {\n const value = this.storage.getItem(key)\n if (value === null) {\n return null\n }\n return JSON.parse(value)\n }\n\n public set<T>(key: string, value: T) {\n this.storage.setItem(key, JSON.stringify(value))\n }\n\n public delete(key: string) {\n this.storage.removeItem(key)\n }\n\n public deleteAll() {\n this.storage.clear()\n }\n}\n\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(window.localStorage)\n }\n}\n\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(window.sessionStorage)\n }\n}\n","import type { SetStateAction } from 'react'\n\nexport function resolveSetState<T>(action: SetStateAction<T>, prev: T): T {\n return typeof action === 'function' ? (action as (prev: T) => T)(prev) : action\n}"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,gBAAqF;;;ACErF,mBAAsC;;;ACHtC,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAGnB,YAAoB,SAAkB;AAAlB;AAAA,EACpB;AAAA,EAEO,IAAO,KAAuB;AACnC,UAAM,QAAQ,KAAK,QAAQ,QAAQ,GAAG;AACtC,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AAa;AAAA,EACnE,GAAG,CAAC,aAAa,CAAC;AAElB,QAAM,oBAAgB,2BAAY,MAAM;AACtC,UAAM,cAAc,OAAO,WAAW,8BAA8B,EAAE;AACtE,UAAM,eAAe,OAAO,WAAW,+BAA+B,EAAE;AACxE,uBAAmB,cAAc,SAAU,eAAe,UAAU,QAAS;AAAA,EAC/E,GAAG,CAAC,CAAC;AAEL,+BAAU,MAAM;AACd,kBAAc;AAAA,EAChB,GAAG,CAAC,aAAa,CAAC;AAElB,+BAAU,MAAM;AACd,UAAM,YAAY,OAAO,WAAW,8BAA8B;AAClE,UAAM,aAAa,OAAO,WAAW,+BAA+B;AACpE,UAAM,cAAc,OAAO,WAAW,uCAAuC;AAC7E,cAAU,iBAAiB,UAAU,aAAa;AAClD,eAAW,iBAAiB,UAAU,aAAa;AACnD,gBAAY,iBAAiB,UAAU,aAAa;AACpD,WAAO,MAAM;AACX,gBAAU,oBAAoB,UAAU,aAAa;AACrD,iBAAW,oBAAoB,UAAU,aAAa;AACtD,kBAAY,oBAAoB,UAAU,aAAa;AAAA,IACzD;AAAA,EACF,GAAG,CAAC,aAAa,CAAC;AAElB,SACE;AAAA,IAAC,aAAa;AAAA,IAAb;AAAA,MACC,OAAO;AAAA,QACL,OAAO;AAAA,QACP;AAAA,QACA,UAAU,CAAC,aAAa;AACtB,cAAI,OAAO;AACT,oBAAQ,KAAK,0JAE8C;AAAA,UAC7D;AACA,yBAAe,QAAQ;AAAA,QACzB;AAAA,MACF;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEO,IAAM,WAAW,MAAM;AAC5B,QAAM,cAAU,0BAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,wFAAwF;AAAA,EAC1G;AACA,SAAO;AACT;","names":["import_react"]}
1
+ {"version":3,"sources":["../../src/theming/useTheme.tsx","../../src/hooks/useLocalStorage.ts","../../src/utils/storage.ts","../../src/utils/resolveSetState.ts"],"sourcesContent":["import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'\nimport type { Translation, TranslationPlural } from '../localization/useTranslation'\nimport { useLocalStorage } from '../hooks/useLocalStorage'\n\nconst themes = ['light', 'dark', 'system'] as const\n\nexport type ThemeType = typeof themes[number]\nexport type ResolvedTheme = Exclude<ThemeType, 'system'>\n\nexport type ThemeTypeTranslation = Record<ThemeType, string> & {\n theme: TranslationPlural,\n}\n\nconst defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {\n en: {\n dark: 'Dark',\n light: 'Light',\n system: 'System',\n theme: {\n one: 'Theme',\n other: 'Themes'\n }\n },\n de: {\n dark: 'Dunkel',\n light: 'Hell',\n system: 'System',\n theme: {\n one: 'Farbschema',\n other: 'Farbschemas'\n }\n }\n}\n\nexport const ThemeUtil = {\n themes,\n translation: defaultThemeTypeTranslation,\n}\n\ntype ThemeContextType = {\n theme: ThemeType,\n resolvedTheme: ResolvedTheme,\n setTheme: Dispatch<SetStateAction<ThemeType>>,\n}\n\nexport const ThemeContext = createContext<ThemeContextType | null>(null)\n\ntype ThemeProviderProps = {\n /**\n * Only set this if you want to control the theme yourself\n */\n theme?: ThemeType,\n}\n\nexport const ThemeProvider = ({ children, theme }: PropsWithChildren<ThemeProviderProps>) => {\n const {\n value: storedTheme,\n setValue: setStoredTheme,\n deleteValue: deleteStoredTheme\n } = useLocalStorage<ThemeType>('theme', 'system')\n const [themePreference, setThemePreference] = useState<ThemeType>('system')\n\n const resolvedTheme = useMemo((): ResolvedTheme => {\n if (theme && theme !== 'system') {\n return theme\n }\n if (storedTheme && storedTheme !== 'system') {\n return storedTheme\n }\n if (themePreference !== 'system') {\n return themePreference\n }\n return 'light'\n }, [storedTheme, theme, themePreference])\n\n useEffect(() => {\n if(!theme) return\n if (theme === 'system') {\n deleteStoredTheme()\n } else {\n setStoredTheme(theme)\n }\n }, [theme]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n document.documentElement.setAttribute('data-theme', resolvedTheme)\n }, [resolvedTheme])\n\n const getPreference = useCallback(() => {\n const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n const prefersLight = window.matchMedia('(prefers-color-scheme: light)').matches\n setThemePreference(prefersDark ? 'dark' : (prefersLight ? 'light' : 'system'))\n }, [])\n\n useEffect(() => {\n getPreference()\n }, [getPreference])\n\n useEffect(() => {\n const darkQuery = window.matchMedia('(prefers-color-scheme: dark)')\n const lightQuery = window.matchMedia('(prefers-color-scheme: light)')\n const noPrefQuery = window.matchMedia('(prefers-color-scheme: no-preference)')\n darkQuery.addEventListener('change', getPreference)\n lightQuery.addEventListener('change', getPreference)\n noPrefQuery.addEventListener('change', getPreference)\n return () => {\n darkQuery.removeEventListener('change', getPreference)\n lightQuery.removeEventListener('change', getPreference)\n noPrefQuery.removeEventListener('change', getPreference)\n }\n }, [getPreference])\n\n return (\n <ThemeContext.Provider\n value={{\n theme: storedTheme,\n resolvedTheme,\n setTheme: (newTheme) => {\n if (theme && theme !== 'system') {\n console.warn('ThemeProvider: Attempting to change the ' +\n \"theme while setting a fixed theme won't have any effect. \" +\n 'Change the theme provided to the ThemeProvider instead.')\n }\n setStoredTheme(newTheme)\n }\n }}\n >\n {children}\n </ThemeContext.Provider>\n )\n}\n\nexport const useTheme = () => {\n const context = useContext(ThemeContext)\n if (!context) {\n throw new Error('useTheme must be used within ThemeContext. Try adding a ThemeProvider around your app.')\n }\n return context\n}\n","'use client'\n\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useState } from 'react'\nimport { LocalStorageService } from '@/src/utils/storage'\nimport { resolveSetState } from '@/src/utils/resolveSetState'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\n\ntype UseLocalStorageResult<T> = {\n value: T,\n setValue: SetValue<T>,\n deleteValue: () => void,\n}\n\n/**\n * @param key Key under which to save the data\n * @param backupValue Used if the storage is unavailable or no value is present\n *\n * The backup value will never be saved to the storage unless you explicitly\n */\nexport const useLocalStorage = <T>(key: string, backupValue: T): UseLocalStorageResult<T> => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return backupValue\n }\n const storageService = new LocalStorageService()\n try {\n const value = storageService.get<T>(key)\n return value || backupValue\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_) {\n console.warn('useLocalStorage: Error while reading the stored value. Make sure your typing is correct.')\n storageService.delete(key)\n console.info(`useLocalStorage: deleted erroneous value for key: ${key}`)\n return backupValue\n }\n }, [backupValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(action => {\n const newValue = resolveSetState(action, storedValue)\n const storageService = new LocalStorageService()\n storageService.set(key, newValue)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n const deleteValue = () => {\n const storageService = new LocalStorageService()\n storageService.delete(key)\n setStoredValue(backupValue)\n }\n\n return { value: storedValue, setValue, deleteValue }\n}","class StorageService {\n // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript\n\n constructor(private storage: Storage) {\n }\n\n public get<T>(key: string): T | null {\n const value = this.storage.getItem(key)\n if (value === null) {\n return null\n }\n return JSON.parse(value)\n }\n\n public set<T>(key: string, value: T) {\n this.storage.setItem(key, JSON.stringify(value))\n }\n\n public delete(key: string) {\n this.storage.removeItem(key)\n }\n\n public deleteAll() {\n this.storage.clear()\n }\n}\n\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(window.localStorage)\n }\n}\n\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(window.sessionStorage)\n }\n}\n","import type { SetStateAction } from 'react'\n\nexport function resolveSetState<T>(action: SetStateAction<T>, prev: T): T {\n return typeof action === 'function' ? (action as (prev: T) => T)(prev) : action\n}"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,gBAAqF;;;ACErF,mBAAsC;;;ACHtC,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAG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import_react"]}
@@ -156,7 +156,7 @@ var ThemeProvider = ({ children, theme }) => {
156
156
  theme: storedTheme,
157
157
  resolvedTheme,
158
158
  setTheme: (newTheme) => {
159
- if (theme) {
159
+ if (theme && theme !== "system") {
160
160
  console.warn("ThemeProvider: Attempting to change the theme while setting a fixed theme won't have any effect. Change the theme provided to the ThemeProvider instead.");
161
161
  }
162
162
  setStoredTheme(newTheme);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theming/useTheme.tsx","../../src/hooks/useLocalStorage.ts","../../src/utils/storage.ts","../../src/utils/resolveSetState.ts"],"sourcesContent":["import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'\nimport type { Translation, TranslationPlural } from '../localization/useTranslation'\nimport { useLocalStorage } from '../hooks/useLocalStorage'\n\nconst themes = ['light', 'dark', 'system'] as const\n\nexport type ThemeType = typeof themes[number]\nexport type ResolvedTheme = Exclude<ThemeType, 'system'>\n\nexport type ThemeTypeTranslation = Record<ThemeType, string> & {\n theme: TranslationPlural,\n}\n\nconst defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {\n en: {\n dark: 'Dark',\n light: 'Light',\n system: 'System',\n theme: {\n one: 'Theme',\n other: 'Themes'\n }\n },\n de: {\n dark: 'Dunkel',\n light: 'Hell',\n system: 'System',\n theme: {\n one: 'Farbschema',\n other: 'Farbschemas'\n }\n }\n}\n\nexport const ThemeUtil = {\n themes,\n translation: defaultThemeTypeTranslation,\n}\n\ntype ThemeContextType = {\n theme: ThemeType,\n resolvedTheme: ResolvedTheme,\n setTheme: Dispatch<SetStateAction<ThemeType>>,\n}\n\nexport const ThemeContext = createContext<ThemeContextType | null>(null)\n\ntype ThemeProviderProps = {\n /**\n * Only set this if you want to control the theme yourself\n */\n theme?: ThemeType,\n}\n\nexport const ThemeProvider = ({ children, theme }: PropsWithChildren<ThemeProviderProps>) => {\n const {\n value: storedTheme,\n setValue: setStoredTheme,\n deleteValue: deleteStoredTheme\n } = useLocalStorage<ThemeType>('theme', 'system')\n const [themePreference, setThemePreference] = useState<ThemeType>('system')\n\n const resolvedTheme = useMemo((): ResolvedTheme => {\n if (theme && theme !== 'system') {\n return theme\n }\n if (storedTheme && storedTheme !== 'system') {\n return storedTheme\n }\n if (themePreference !== 'system') {\n return themePreference\n }\n return 'light'\n }, [storedTheme, theme, themePreference])\n\n useEffect(() => {\n if(!theme) return\n if (theme === 'system') {\n deleteStoredTheme()\n } else {\n setStoredTheme(theme)\n }\n }, [theme]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n document.documentElement.setAttribute('data-theme', resolvedTheme)\n }, [resolvedTheme])\n\n const getPreference = useCallback(() => {\n const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n const prefersLight = window.matchMedia('(prefers-color-scheme: light)').matches\n setThemePreference(prefersDark ? 'dark' : (prefersLight ? 'light' : 'system'))\n }, [])\n\n useEffect(() => {\n getPreference()\n }, [getPreference])\n\n useEffect(() => {\n const darkQuery = window.matchMedia('(prefers-color-scheme: dark)')\n const lightQuery = window.matchMedia('(prefers-color-scheme: light)')\n const noPrefQuery = window.matchMedia('(prefers-color-scheme: no-preference)')\n darkQuery.addEventListener('change', getPreference)\n lightQuery.addEventListener('change', getPreference)\n noPrefQuery.addEventListener('change', getPreference)\n return () => {\n darkQuery.removeEventListener('change', getPreference)\n lightQuery.removeEventListener('change', getPreference)\n noPrefQuery.removeEventListener('change', getPreference)\n }\n }, [getPreference])\n\n return (\n <ThemeContext.Provider\n value={{\n theme: storedTheme,\n resolvedTheme,\n setTheme: (newTheme) => {\n if (theme) {\n console.warn('ThemeProvider: Attempting to change the ' +\n \"theme while setting a fixed theme won't have any effect. \" +\n 'Change the theme provided to the ThemeProvider instead.')\n }\n setStoredTheme(newTheme)\n }\n }}\n >\n {children}\n </ThemeContext.Provider>\n )\n}\n\nexport const useTheme = () => {\n const context = useContext(ThemeContext)\n if (!context) {\n throw new Error('useTheme must be used within ThemeContext. Try adding a ThemeProvider around your app.')\n }\n return context\n}\n","'use client'\n\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useState } from 'react'\nimport { LocalStorageService } from '@/src/utils/storage'\nimport { resolveSetState } from '@/src/utils/resolveSetState'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\n\ntype UseLocalStorageResult<T> = {\n value: T,\n setValue: SetValue<T>,\n deleteValue: () => void,\n}\n\n/**\n * @param key Key under which to save the data\n * @param backupValue Used if the storage is unavailable or no value is present\n *\n * The backup value will never be saved to the storage unless you explicitly\n */\nexport const useLocalStorage = <T>(key: string, backupValue: T): UseLocalStorageResult<T> => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return backupValue\n }\n const storageService = new LocalStorageService()\n try {\n const value = storageService.get<T>(key)\n return value || backupValue\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_) {\n console.warn('useLocalStorage: Error while reading the stored value. Make sure your typing is correct.')\n storageService.delete(key)\n console.info(`useLocalStorage: deleted erroneous value for key: ${key}`)\n return backupValue\n }\n }, [backupValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(action => {\n const newValue = resolveSetState(action, storedValue)\n const storageService = new LocalStorageService()\n storageService.set(key, newValue)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n const deleteValue = () => {\n const storageService = new LocalStorageService()\n storageService.delete(key)\n setStoredValue(backupValue)\n }\n\n return { value: storedValue, setValue, deleteValue }\n}","class StorageService {\n // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript\n\n constructor(private storage: Storage) {\n }\n\n public get<T>(key: string): T | null {\n const value = this.storage.getItem(key)\n if (value === null) {\n return null\n }\n return JSON.parse(value)\n }\n\n public set<T>(key: string, value: T) {\n this.storage.setItem(key, JSON.stringify(value))\n }\n\n public delete(key: string) {\n this.storage.removeItem(key)\n }\n\n public deleteAll() {\n this.storage.clear()\n }\n}\n\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(window.localStorage)\n }\n}\n\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(window.sessionStorage)\n }\n}\n","import type { SetStateAction } from 'react'\n\nexport function resolveSetState<T>(action: SetStateAction<T>, prev: T): T {\n return typeof action === 'function' ? (action as (prev: T) => T)(prev) : action\n}"],"mappings":";AACA,SAAS,eAAe,eAAAA,cAAa,YAAY,WAAW,SAAS,YAAAC,iBAAgB;;;ACErF,SAAS,aAAa,gBAAgB;;;ACHtC,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAGnB,YAAoB,SAAkB;AAAlB;AAAA,EACpB;AAAA,EAEO,IAAO,KAAuB;AACnC,UAAM,QAAQ,KAAK,QAAQ,QAAQ,GAAG;AACtC,QAAI,UAAU,MAAM;AAClB,aAAO;AAAA,IACT;AACA,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AAAA,EAEO,IAAO,KAAa,OAAU;AACnC,SAAK,QAAQ,QAAQ,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EACjD;AAAA,EAEO,OAAO,KAAa;AACzB,SAAK,QAAQ,WAAW,GAAG;AAAA,EAC7B;AAAA,EAEO,YAAY;AACjB,SAAK,QAAQ,MAAM;AAAA,EACrB;AACF;AAEO,IAAM,sBAAN,cAAkC,eAAe;AAAA,EACtD,cAAc;AACZ,UAAM,OAAO,YAAY;AAAA,EAC3B;AACF;;;AC7BO,SAAS,gBAAmB,QAA2B,MAAY;AACxE,SAAO,OAAO,WAAW,aAAc,OAA0B,IAAI,IAAI;AAC3E;;;AFiBO,IAAM,kBAAkB,CAAI,KAAa,gBAA6C;AAC3F,QAAM,MAAM,YAAY,MAAS;AAC/B,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACT;AACA,UAAM,iBAAiB,IAAI,oBAAoB;AAC/C,QAAI;AACF,YAAM,QAAQ,eAAe,IAAO,GAAG;AACvC,aAAO,SAAS;AAAA,IAElB,SAAS,GAAG;AACV,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,QACL,OAAO;AAAA,QACP;AAAA,QACA,UAAU,CAAC,aAAa;AACtB,cAAI,OAAO;AACT,oBAAQ,KAAK,0JAE8C;AAAA,UAC7D;AACA,yBAAe,QAAQ;AAAA,QACzB;AAAA,MACF;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEO,IAAM,WAAW,MAAM;AAC5B,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,wFAAwF;AAAA,EAC1G;AACA,SAAO;AACT;","names":["useCallback","useState","useState","useCallback"]}
1
+ {"version":3,"sources":["../../src/theming/useTheme.tsx","../../src/hooks/useLocalStorage.ts","../../src/utils/storage.ts","../../src/utils/resolveSetState.ts"],"sourcesContent":["import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'\nimport type { Translation, TranslationPlural } from '../localization/useTranslation'\nimport { useLocalStorage } from '../hooks/useLocalStorage'\n\nconst themes = ['light', 'dark', 'system'] as const\n\nexport type ThemeType = typeof themes[number]\nexport type ResolvedTheme = Exclude<ThemeType, 'system'>\n\nexport type ThemeTypeTranslation = Record<ThemeType, string> & {\n theme: TranslationPlural,\n}\n\nconst defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {\n en: {\n dark: 'Dark',\n light: 'Light',\n system: 'System',\n theme: {\n one: 'Theme',\n other: 'Themes'\n }\n },\n de: {\n dark: 'Dunkel',\n light: 'Hell',\n system: 'System',\n theme: {\n one: 'Farbschema',\n other: 'Farbschemas'\n }\n }\n}\n\nexport const ThemeUtil = {\n themes,\n translation: defaultThemeTypeTranslation,\n}\n\ntype ThemeContextType = {\n theme: ThemeType,\n resolvedTheme: ResolvedTheme,\n setTheme: Dispatch<SetStateAction<ThemeType>>,\n}\n\nexport const ThemeContext = createContext<ThemeContextType | null>(null)\n\ntype ThemeProviderProps = {\n /**\n * Only set this if you want to control the theme yourself\n */\n theme?: ThemeType,\n}\n\nexport const ThemeProvider = ({ children, theme }: PropsWithChildren<ThemeProviderProps>) => {\n const {\n value: storedTheme,\n setValue: setStoredTheme,\n deleteValue: deleteStoredTheme\n } = useLocalStorage<ThemeType>('theme', 'system')\n const [themePreference, setThemePreference] = useState<ThemeType>('system')\n\n const resolvedTheme = useMemo((): ResolvedTheme => {\n if (theme && theme !== 'system') {\n return theme\n }\n if (storedTheme && storedTheme !== 'system') {\n return storedTheme\n }\n if (themePreference !== 'system') {\n return themePreference\n }\n return 'light'\n }, [storedTheme, theme, themePreference])\n\n useEffect(() => {\n if(!theme) return\n if (theme === 'system') {\n deleteStoredTheme()\n } else {\n setStoredTheme(theme)\n }\n }, [theme]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n document.documentElement.setAttribute('data-theme', resolvedTheme)\n }, [resolvedTheme])\n\n const getPreference = useCallback(() => {\n const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n const prefersLight = window.matchMedia('(prefers-color-scheme: light)').matches\n setThemePreference(prefersDark ? 'dark' : (prefersLight ? 'light' : 'system'))\n }, [])\n\n useEffect(() => {\n getPreference()\n }, [getPreference])\n\n useEffect(() => {\n const darkQuery = window.matchMedia('(prefers-color-scheme: dark)')\n const lightQuery = window.matchMedia('(prefers-color-scheme: light)')\n const noPrefQuery = window.matchMedia('(prefers-color-scheme: no-preference)')\n darkQuery.addEventListener('change', getPreference)\n lightQuery.addEventListener('change', getPreference)\n noPrefQuery.addEventListener('change', getPreference)\n return () => {\n darkQuery.removeEventListener('change', getPreference)\n lightQuery.removeEventListener('change', getPreference)\n noPrefQuery.removeEventListener('change', getPreference)\n }\n }, [getPreference])\n\n return (\n <ThemeContext.Provider\n value={{\n theme: storedTheme,\n resolvedTheme,\n setTheme: (newTheme) => {\n if (theme && theme !== 'system') {\n console.warn('ThemeProvider: Attempting to change the ' +\n \"theme while setting a fixed theme won't have any effect. \" +\n 'Change the theme provided to the ThemeProvider instead.')\n }\n setStoredTheme(newTheme)\n }\n }}\n >\n {children}\n </ThemeContext.Provider>\n )\n}\n\nexport const useTheme = () => {\n const context = useContext(ThemeContext)\n if (!context) {\n throw new Error('useTheme must be used within ThemeContext. Try adding a ThemeProvider around your app.')\n }\n return context\n}\n","'use client'\n\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useState } from 'react'\nimport { LocalStorageService } from '@/src/utils/storage'\nimport { resolveSetState } from '@/src/utils/resolveSetState'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\n\ntype UseLocalStorageResult<T> = {\n value: T,\n setValue: SetValue<T>,\n deleteValue: () => void,\n}\n\n/**\n * @param key Key under which to save the data\n * @param backupValue Used if the storage is unavailable or no value is present\n *\n * The backup value will never be saved to the storage unless you explicitly\n */\nexport const useLocalStorage = <T>(key: string, backupValue: T): UseLocalStorageResult<T> => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return backupValue\n }\n const storageService = new LocalStorageService()\n try {\n const value = storageService.get<T>(key)\n return value || backupValue\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_) {\n console.warn('useLocalStorage: Error while reading the stored value. Make sure your typing is correct.')\n storageService.delete(key)\n console.info(`useLocalStorage: deleted erroneous value for key: ${key}`)\n return backupValue\n }\n }, [backupValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(action => {\n const newValue = resolveSetState(action, storedValue)\n const storageService = new LocalStorageService()\n storageService.set(key, newValue)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n const deleteValue = () => {\n const storageService = new LocalStorageService()\n storageService.delete(key)\n setStoredValue(backupValue)\n }\n\n return { value: storedValue, setValue, deleteValue }\n}","class StorageService {\n // this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript\n\n constructor(private storage: Storage) {\n }\n\n public get<T>(key: string): T | null {\n const value = this.storage.getItem(key)\n if (value === null) {\n return null\n }\n return JSON.parse(value)\n }\n\n public set<T>(key: string, value: T) {\n this.storage.setItem(key, JSON.stringify(value))\n }\n\n public delete(key: string) {\n this.storage.removeItem(key)\n }\n\n public deleteAll() {\n this.storage.clear()\n }\n}\n\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(window.localStorage)\n }\n}\n\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(window.sessionStorage)\n }\n}\n","import type { SetStateAction } from 'react'\n\nexport function resolveSetState<T>(action: SetStateAction<T>, prev: T): T {\n return typeof action === 'function' ? (action as (prev: T) => T)(prev) : action\n}"],"mappings":";AACA,SAAS,eAAe,eAAAA,cAAa,YAAY,WAAW,SAAS,YAAAC,iBAAgB;;;ACErF,SAAS,aAAa,gBAAgB;;;ACHtC,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAGnB,YAAoB,SAAkB;AAAlB;AAAA,EACpB;AAAA,EAEO,IAAO,KAAuB;AACnC,UAAM,QAAQ,KAAK,QAAQ,QAAQ,GAAG;AACtC,QAAI,UAAU,MAAM;AAClB,aAAO;AAAA,IACT;AACA,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AAAA,EAEO,IAAO,KAAa,OAAU;AACnC,SAAK,QAAQ,QAAQ,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EACjD;AAAA,EAEO,OAAO,KAAa;AACzB,SAAK,QAAQ,WAAW,GAAG;AAAA,EAC7B;AAAA,EAEO,YAAY;AACjB,SAAK,QAAQ,MAAM;AAAA,EACrB;AACF;AAEO,IAAM,sBAAN,cAAkC,eAAe;AAAA,EACtD,cAAc;AACZ,UAAM,OAAO,YAAY;AAAA,EAC3B;AACF;;;AC7BO,SAAS,gBAAmB,QAA2B,MAAY;AACxE,SAAO,OAAO,WAAW,aAAc,OAA0B,IAAI,IAAI;AAC3E;;;AFiBO,IAAM,kBAAkB,CAAI,KAAa,gBAA6C;AAC3F,QAAM,MAAM,YAAY,MAAS;AAC/B,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACT;AACA,UAAM,iBAAiB,IAAI,oBA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zD;AAAA,EACF,GAAG,CAAC,aAAa,CAAC;AAElB,SACE;AAAA,IAAC,aAAa;AAAA,IAAb;AAAA,MACC,OAAO;AAAA,QACL,OAAO;AAAA,QACP;AAAA,QACA,UAAU,CAAC,aAAa;AACtB,cAAI,SAAS,UAAU,UAAU;AAC/B,oBAAQ,KAAK,0JAE8C;AAAA,UAC7D;AACA,yBAAe,QAAQ;AAAA,QACzB;AAAA,MACF;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEO,IAAM,WAAW,MAAM;AAC5B,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,wFAAwF;AAAA,EAC1G;AACA,SAAO;AACT;","names":["useCallback","useState","useState","useCallback"]}
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "git+https://github.com/helpwave/hightide.git"
8
8
  },
9
9
  "license": "MPL-2.0",
10
- "version": "0.1.37",
10
+ "version": "0.1.39",
11
11
  "files": [
12
12
  "dist"
13
13
  ],