@stacksjs/stx 0.2.146 → 0.2.147

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/stx.d.ts CHANGED
@@ -233,11 +233,38 @@ declare function useWebSocket(_url: string, _options?: {
233
233
  // Color mode
234
234
  // ============================================================================
235
235
 
236
- declare function useColorMode(): {
237
- mode: StxSignal<'light' | 'dark' | 'auto'>
238
- setMode: (mode: 'light' | 'dark' | 'auto') => void
236
+ interface StxColorModeOptions {
237
+ /** localStorage key holding the preference. @default 'stx-color-mode' */
238
+ storageKey?: string
239
+ /** Mode used when nothing valid is stored. @default 'auto' */
240
+ initialMode?: 'light' | 'dark' | 'auto'
241
+ /** Class applied to `<html>` when dark. @default 'dark' */
242
+ darkClass?: string
243
+ /** Attribute applied to `<html>` INSTEAD of the class, e.g. 'data-theme'. */
244
+ attribute?: string
245
+ /** Suppress CSS transitions across a mode switch. @default true */
246
+ disableTransitions?: boolean
247
+ }
248
+
249
+ /**
250
+ * Omitting the options picks up whatever `app.colorMode` in `stx.config.ts`
251
+ * published via the pre-paint boot script (stacksjs/stx#1794), so the storage
252
+ * key and attribute don't have to be repeated at the call site.
253
+ */
254
+ declare function useColorMode(_options?: StxColorModeOptions): {
255
+ /** Current resolved mode. */
256
+ readonly mode: 'light' | 'dark'
257
+ /** User preference, which may be 'auto'. */
258
+ readonly preference: 'light' | 'dark' | 'auto'
259
+ readonly isDark: boolean
260
+ set: (mode: 'light' | 'dark' | 'auto') => void
261
+ toggle: () => void
262
+ subscribe: (fn: (mode: 'light' | 'dark', preference: 'light' | 'dark' | 'auto') => void) => () => void
263
+ }
264
+ declare function useDark(_options?: StxColorModeOptions): StxSignal<boolean> & {
265
+ readonly isDark: boolean
266
+ toggle: () => void
239
267
  }
240
- declare function useDark(): StxSignal<boolean>
241
268
  declare function useMediaQuery(query: string): StxSignal<boolean> & {
242
269
  readonly matches: boolean
243
270
  readonly value: boolean
@@ -500,6 +527,7 @@ interface StxRuntimeRegistry {
500
527
  useFocus: typeof useFocus
501
528
  useAsync: typeof useAsync
502
529
  useLocalStorage: typeof useLocalStorage
530
+ useSessionStorage: typeof useSessionStorage
503
531
  useEventListener: typeof useEventListener
504
532
  useScrollLock: typeof useScrollLock
505
533
  useWebSocket: typeof useWebSocket
@@ -1,3 +1,4 @@
1
+ import type { ColorModeBootConfig } from '../color-mode-boot';
1
2
  import type { ComponentConfig, DocGeneratorConfig, WebComponentConfig } from './component-types';
2
3
  import type { CspConfig } from './csp-types';
3
4
  import type { CustomDirective, Middleware } from './directive-types';
@@ -250,6 +251,7 @@ export declare interface AppHeadConfig {
250
251
  export declare interface StxConfig {
251
252
  app?: {
252
253
  head?: AppHeadConfig
254
+ colorMode?: ColorModeBootConfig
253
255
  window?: {
254
256
  width?: number
255
257
  height?: number
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.146",
4
+ "version": "0.2.147",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -117,12 +117,12 @@
117
117
  "dependencies": {
118
118
  "@cwcss/crosswind": "^0.2.14",
119
119
  "@stacksjs/clapp": "^0.2.0",
120
- "@stacksjs/desktop": "0.2.146",
121
- "@stacksjs/sanitizer": "0.2.146",
120
+ "@stacksjs/desktop": "0.2.147",
121
+ "@stacksjs/sanitizer": "0.2.147",
122
122
  "@stacksjs/ts-i18n": "^0.1.11",
123
- "bun-plugin-stx": "0.2.146",
123
+ "bun-plugin-stx": "0.2.147",
124
124
  "bunfig": "^0.15.15",
125
- "stx-router": "0.2.146",
125
+ "stx-router": "0.2.147",
126
126
  "ts-broadcasting": "^0.0.9",
127
127
  "ts-images": "^0.1.9",
128
128
  "ts-syntax-highlighter": "^0.2.1"
package/stx.d.ts CHANGED
@@ -233,11 +233,38 @@ declare function useWebSocket(_url: string, _options?: {
233
233
  // Color mode
234
234
  // ============================================================================
235
235
 
236
- declare function useColorMode(): {
237
- mode: StxSignal<'light' | 'dark' | 'auto'>
238
- setMode: (mode: 'light' | 'dark' | 'auto') => void
236
+ interface StxColorModeOptions {
237
+ /** localStorage key holding the preference. @default 'stx-color-mode' */
238
+ storageKey?: string
239
+ /** Mode used when nothing valid is stored. @default 'auto' */
240
+ initialMode?: 'light' | 'dark' | 'auto'
241
+ /** Class applied to `<html>` when dark. @default 'dark' */
242
+ darkClass?: string
243
+ /** Attribute applied to `<html>` INSTEAD of the class, e.g. 'data-theme'. */
244
+ attribute?: string
245
+ /** Suppress CSS transitions across a mode switch. @default true */
246
+ disableTransitions?: boolean
247
+ }
248
+
249
+ /**
250
+ * Omitting the options picks up whatever `app.colorMode` in `stx.config.ts`
251
+ * published via the pre-paint boot script (stacksjs/stx#1794), so the storage
252
+ * key and attribute don't have to be repeated at the call site.
253
+ */
254
+ declare function useColorMode(_options?: StxColorModeOptions): {
255
+ /** Current resolved mode. */
256
+ readonly mode: 'light' | 'dark'
257
+ /** User preference, which may be 'auto'. */
258
+ readonly preference: 'light' | 'dark' | 'auto'
259
+ readonly isDark: boolean
260
+ set: (mode: 'light' | 'dark' | 'auto') => void
261
+ toggle: () => void
262
+ subscribe: (fn: (mode: 'light' | 'dark', preference: 'light' | 'dark' | 'auto') => void) => () => void
263
+ }
264
+ declare function useDark(_options?: StxColorModeOptions): StxSignal<boolean> & {
265
+ readonly isDark: boolean
266
+ toggle: () => void
239
267
  }
240
- declare function useDark(): StxSignal<boolean>
241
268
  declare function useMediaQuery(query: string): StxSignal<boolean> & {
242
269
  readonly matches: boolean
243
270
  readonly value: boolean
@@ -500,6 +527,7 @@ interface StxRuntimeRegistry {
500
527
  useFocus: typeof useFocus
501
528
  useAsync: typeof useAsync
502
529
  useLocalStorage: typeof useLocalStorage
530
+ useSessionStorage: typeof useSessionStorage
503
531
  useEventListener: typeof useEventListener
504
532
  useScrollLock: typeof useScrollLock
505
533
  useWebSocket: typeof useWebSocket