@pyreon/rocketstyle 0.11.5 → 0.11.7

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 (51) hide show
  1. package/README.md +32 -32
  2. package/lib/index.d.ts +25 -6
  3. package/lib/index.js +122 -97
  4. package/package.json +25 -24
  5. package/src/__tests__/attrs.test.ts +49 -49
  6. package/src/__tests__/chaining.test.ts +27 -27
  7. package/src/__tests__/collection.test.ts +12 -12
  8. package/src/__tests__/compose.test.ts +10 -10
  9. package/src/__tests__/context.test.ts +65 -65
  10. package/src/__tests__/createLocalProvider.test.ts +53 -53
  11. package/src/__tests__/dimensions.test.ts +54 -54
  12. package/src/__tests__/e2e-styler.test.ts +142 -136
  13. package/src/__tests__/hooks.test.ts +41 -70
  14. package/src/__tests__/isRocketComponent.test.ts +11 -11
  15. package/src/__tests__/misc.test.ts +91 -91
  16. package/src/__tests__/providerConsumer.test.ts +54 -126
  17. package/src/__tests__/rocketstyleIntegration.test.ts +182 -255
  18. package/src/__tests__/themeUtils.test.ts +173 -173
  19. package/src/cache/index.ts +1 -1
  20. package/src/constants/booleanTags.ts +25 -25
  21. package/src/constants/defaultDimensions.ts +5 -5
  22. package/src/constants/index.ts +16 -16
  23. package/src/context/context.ts +13 -10
  24. package/src/context/createLocalProvider.ts +26 -13
  25. package/src/context/localContext.ts +2 -2
  26. package/src/hoc/index.ts +1 -1
  27. package/src/hoc/rocketstyleAttrsHoc.ts +26 -29
  28. package/src/hooks/index.ts +2 -2
  29. package/src/hooks/usePseudoState.ts +3 -3
  30. package/src/hooks/useTheme.ts +14 -17
  31. package/src/index.ts +32 -15
  32. package/src/init.ts +12 -12
  33. package/src/isRocketComponent.ts +2 -2
  34. package/src/rocketstyle.ts +125 -112
  35. package/src/types/attrs.ts +2 -2
  36. package/src/types/config.ts +4 -4
  37. package/src/types/configuration.ts +5 -5
  38. package/src/types/dimensions.ts +5 -5
  39. package/src/types/hoc.ts +1 -1
  40. package/src/types/rocketComponent.ts +4 -4
  41. package/src/types/rocketstyle.ts +10 -10
  42. package/src/types/styles.ts +9 -4
  43. package/src/types/theme.ts +4 -4
  44. package/src/types/utils.ts +1 -1
  45. package/src/utils/attrs.ts +2 -2
  46. package/src/utils/chaining.ts +2 -2
  47. package/src/utils/compose.ts +1 -1
  48. package/src/utils/dimensions.ts +6 -6
  49. package/src/utils/statics.ts +2 -2
  50. package/src/utils/styles.ts +2 -2
  51. package/src/utils/theme.ts +10 -10
@@ -1,21 +1,21 @@
1
- import { compose, config, hoistNonReactStatics, omit, pick, render } from "@pyreon/ui-core"
2
- import { LocalThemeManager } from "./cache"
3
- import { CONFIG_KEYS, PSEUDO_KEYS, PSEUDO_META_KEYS, STYLING_KEYS } from "./constants"
4
- import createLocalProvider from "./context/createLocalProvider"
5
- import { useLocalContext } from "./context/localContext"
6
- import { rocketstyleAttrsHoc } from "./hoc"
7
- import { useTheme } from "./hooks"
8
- import type { Configuration, ExtendedConfiguration } from "./types/configuration"
9
- import type { RocketComponent } from "./types/rocketComponent"
10
- import type { InnerComponentProps, RocketStyleComponent } from "./types/rocketstyle"
11
- import type { ComponentFn } from "./types/utils"
12
- import { calculateChainOptions, calculateStylingAttrs, pickStyledAttrs } from "./utils/attrs"
13
- import { chainOptions, chainOrOptions, chainReservedKeyOptions } from "./utils/chaining"
14
- import { calculateHocsFuncs } from "./utils/compose"
15
- import { getDimensionsMap } from "./utils/dimensions"
16
- import { createStaticsChainingEnhancers, createStaticsEnhancers } from "./utils/statics"
17
- import { calculateStyles } from "./utils/styles"
18
- import { getDimensionThemes, getTheme, getThemeByMode, getThemeFromChain } from "./utils/theme"
1
+ import { compose, config, hoistNonReactStatics, omit, pick, render } from '@pyreon/ui-core'
2
+ import { LocalThemeManager } from './cache'
3
+ import { CONFIG_KEYS, PSEUDO_KEYS, PSEUDO_META_KEYS, STYLING_KEYS } from './constants'
4
+ import createLocalProvider from './context/createLocalProvider'
5
+ import { useLocalContext } from './context/localContext'
6
+ import { rocketstyleAttrsHoc } from './hoc'
7
+ import { useTheme } from './hooks'
8
+ import type { Configuration, ExtendedConfiguration } from './types/configuration'
9
+ import type { RocketComponent } from './types/rocketComponent'
10
+ import type { InnerComponentProps, RocketStyleComponent } from './types/rocketstyle'
11
+ import type { ComponentFn } from './types/utils'
12
+ import { calculateChainOptions, calculateStylingAttrs, pickStyledAttrs } from './utils/attrs'
13
+ import { chainOptions, chainOrOptions, chainReservedKeyOptions } from './utils/chaining'
14
+ import { calculateHocsFuncs } from './utils/compose'
15
+ import { getDimensionsMap } from './utils/dimensions'
16
+ import { createStaticsChainingEnhancers, createStaticsEnhancers } from './utils/statics'
17
+ import { calculateStyles } from './utils/styles'
18
+ import { getDimensionThemes, getTheme, getThemeByMode, getThemeFromChain } from './utils/theme'
19
19
 
20
20
  /**
21
21
  * Core rocketstyle component factory. Creates a fully-featured Pyreon component
@@ -110,132 +110,145 @@ const rocketComponent: RocketComponent = (options) => {
110
110
  const themeAttrs = useTheme(options)
111
111
 
112
112
  // --------------------------------------------------
113
- // Static setupruns once at component mount
113
+ // Theme structurecached by theme object identity.
114
+ // Theme object itself doesn't change (enrichTheme produces a stable ref),
115
+ // only mode switches change which mode-variant is resolved.
114
116
  // --------------------------------------------------
115
- const { pseudo, ...mergeProps } = {
116
- ...localCtx,
117
- ...props,
117
+ const theme = themeAttrs.theme
118
+
119
+ const baseThemeHelper = ThemeManager.baseTheme
120
+ if (!baseThemeHelper.has(theme)) {
121
+ baseThemeHelper.set(theme, getThemeFromChain(options.theme, theme))
118
122
  }
123
+ const baseTheme = baseThemeHelper.get(theme)
119
124
 
120
- const pseudoRocketstate = {
121
- ...pseudo,
122
- ...pick(props, [...PSEUDO_KEYS, ...PSEUDO_META_KEYS]),
125
+ const dimHelper = ThemeManager.dimensionsThemes
126
+ if (!dimHelper.has(theme)) {
127
+ dimHelper.set(theme, getDimensionThemes(theme, options))
123
128
  }
129
+ const themes = dimHelper.get(theme)
130
+
131
+ const { keysMap: dimensions, keywords: reservedPropNames } = getDimensionsMap({
132
+ themes,
133
+ useBooleans: options.useBooleans,
134
+ })
135
+
136
+ const RESERVED_STYLING_PROPS_KEYS = Object.keys(reservedPropNames)
124
137
 
125
138
  // --------------------------------------------------
126
- // Reactive accessor re-evaluates when mode changes.
127
- // When mounted, the runtime wraps this in an effect so
128
- // reading themeAttrs.mode creates a reactive dependency.
129
- // Mode switches are infrequent (user-initiated), so full
130
- // re-render of the styled subtree is acceptable.
139
+ // $rocketstyle as a FUNCTION ACCESSOR fully reactive.
140
+ // Re-evaluates when mode OR dimension props change.
141
+ // Props are resolved fresh each call so reactive prop accessors
142
+ // (signals, getters) produce updated dimension values.
131
143
  // --------------------------------------------------
132
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: theme resolution is inherently multi-step
133
- return (() => {
134
- // Read theme and mode lazily via getters tracked by the effect
135
- const theme = themeAttrs.theme
136
- const mode = themeAttrs.mode
137
-
138
- // --------------------------------------------------
139
- // calculate themes for all defined styling dimensions
140
- // --------------------------------------------------
141
-
142
- // BASE / DEFAULT THEME Object (cached by theme identity)
143
- const baseThemeHelper = ThemeManager.baseTheme
144
- if (!baseThemeHelper.has(theme)) {
145
- baseThemeHelper.set(theme, getThemeFromChain(options.theme, theme))
144
+ const $rocketstyleAccessor = () => {
145
+ // Merge props fresh — if parent passes reactive accessors,
146
+ // spreading them here evaluates them in this reactive scope.
147
+ const { pseudo, ...mergeProps } = {
148
+ ...localCtx,
149
+ ...props,
146
150
  }
147
- const baseTheme = baseThemeHelper.get(theme)
148
151
 
149
- // DIMENSION(S) THEMES Object (cached by theme identity)
150
- const dimHelper = ThemeManager.dimensionsThemes
151
- if (!dimHelper.has(theme)) {
152
- dimHelper.set(theme, getDimensionThemes(theme, options))
153
- }
154
- const themes = dimHelper.get(theme)
152
+ const mode = themeAttrs.mode // reactive: tracks mode signal
153
+
154
+ // Resolve active dimensions from current prop values
155
+ const rocketstate = _calculateStylingAttrs({
156
+ props: pickStyledAttrs(mergeProps, reservedPropNames),
157
+ dimensions,
158
+ })
155
159
 
156
- // BASE / DEFAULT MODE THEME Object (cached by mode + baseTheme)
160
+ // Resolve mode-specific theme
157
161
  const modeBaseHelper = ThemeManager.modeBaseTheme[mode]
158
162
  if (!modeBaseHelper.has(baseTheme)) {
159
163
  modeBaseHelper.set(baseTheme, getThemeByMode(baseTheme, mode))
160
164
  }
161
165
  const currentModeBaseTheme = modeBaseHelper.get(baseTheme)
162
166
 
163
- // DIMENSION(S) MODE THEMES Object (cached by mode + themes)
164
167
  const modeDimHelper = ThemeManager.modeDimensionTheme[mode]
165
168
  if (!modeDimHelper.has(themes)) {
166
169
  modeDimHelper.set(themes, getThemeByMode(themes, mode))
167
170
  }
168
171
  const currentModeThemes = modeDimHelper.get(themes)
169
172
 
170
- // --------------------------------------------------
171
- // dimension map & reserved prop names
172
- // --------------------------------------------------
173
- const { keysMap: dimensions, keywords: reservedPropNames } = getDimensionsMap({
174
- themes,
175
- useBooleans: options.useBooleans,
173
+ return getTheme({
174
+ rocketstate,
175
+ themes: currentModeThemes,
176
+ baseTheme: currentModeBaseTheme,
177
+ transformKeys: options.transformKeys,
178
+ appTheme: theme,
176
179
  })
180
+ }
177
181
 
178
- const RESERVED_STYLING_PROPS_KEYS = Object.keys(reservedPropNames)
182
+ // --------------------------------------------------
183
+ // $rocketstate as a FUNCTION ACCESSOR — reactive on prop changes.
184
+ // Re-evaluates active dimensions + pseudo state from current props.
185
+ // --------------------------------------------------
186
+ const $rocketstateAccessor = () => {
187
+ const { pseudo, ...mergeProps } = {
188
+ ...localCtx,
189
+ ...props,
190
+ }
191
+
192
+ const pseudoRocketstate = {
193
+ ...pseudo,
194
+ ...pick(props, [...PSEUDO_KEYS, ...PSEUDO_META_KEYS]),
195
+ }
179
196
 
180
- // --------------------------------------------------
181
- // rocketstate — active dimension values
182
- // --------------------------------------------------
183
197
  const rocketstate = _calculateStylingAttrs({
184
198
  props: pickStyledAttrs(mergeProps, reservedPropNames),
185
199
  dimensions,
186
200
  })
187
201
 
188
- const finalRocketstate = { ...rocketstate, pseudo: pseudoRocketstate }
202
+ return { ...rocketstate, pseudo: pseudoRocketstate }
203
+ }
189
204
 
190
- // --------------------------------------------------
191
- // rocketstyle computed theme based on active dimensions
192
- // --------------------------------------------------
193
- const computedRocketstyle = getTheme({
194
- rocketstate,
195
- themes: currentModeThemes,
196
- baseTheme: currentModeBaseTheme,
197
- transformKeys: options.transformKeys,
198
- appTheme: theme,
199
- })
205
+ // --------------------------------------------------
206
+ // Static mergeProps for final prop filtering (non-dimension props)
207
+ // --------------------------------------------------
208
+ const { pseudo: _pseudo, ...mergeProps } = {
209
+ ...localCtx,
210
+ ...props,
211
+ }
200
212
 
201
- // --------------------------------------------------
202
- // final props passed to WrappedComponent
203
- // --------------------------------------------------
204
- const finalProps: Record<string, any> = {
205
- ...omit(mergeProps, [
206
- ...RESERVED_STYLING_PROPS_KEYS,
207
- ...PSEUDO_KEYS,
208
- ...options.filterAttrs,
209
- ]),
210
- ...(options.passProps ? pick(mergeProps, options.passProps) : {}),
211
- // ref flows as a normal prop in Pyreon
212
- ref: props.ref,
213
- $rocketstyle: computedRocketstyle,
214
- $rocketstate: finalRocketstate,
215
- }
213
+ // --------------------------------------------------
214
+ // final props passed to WrappedComponent
215
+ // --------------------------------------------------
216
+ const finalProps: Record<string, any> = {
217
+ ...omit(mergeProps, [
218
+ ...RESERVED_STYLING_PROPS_KEYS,
219
+ ...PSEUDO_KEYS,
220
+ ...options.filterAttrs,
221
+ ]),
222
+ ...(options.passProps ? pick(mergeProps, options.passProps) : {}),
223
+ ref: props.ref,
224
+ // FUNCTION accessors — styled component resolves them reactively
225
+ $rocketstyle: $rocketstyleAccessor,
226
+ $rocketstate: $rocketstateAccessor,
227
+ }
216
228
 
217
- // development debugging
218
- if (process.env.NODE_ENV !== "production") {
219
- finalProps["data-rocketstyle"] = componentName
220
-
221
- if (options.DEBUG) {
222
- const debugPayload = {
223
- component: componentName,
224
- rocketstate: finalRocketstate,
225
- rocketstyle: computedRocketstyle,
226
- dimensions,
227
- mode,
228
- reservedPropNames: RESERVED_STYLING_PROPS_KEYS,
229
- filteredAttrs: options.filterAttrs,
230
- }
231
-
232
- // biome-ignore lint/suspicious/noConsole: debug logging controlled by DEBUG option
233
- console.debug(`[rocketstyle] ${componentName} render:`, debugPayload)
229
+ // development debugging
230
+ if (process.env.NODE_ENV !== 'production') {
231
+ finalProps['data-rocketstyle'] = componentName
232
+
233
+ if (options.DEBUG) {
234
+ const debugPayload = {
235
+ component: componentName,
236
+ rocketstate: $rocketstateAccessor(),
237
+ rocketstyle: $rocketstyleAccessor(),
238
+ dimensions,
239
+ mode: themeAttrs.mode,
240
+ reservedPropNames: RESERVED_STYLING_PROPS_KEYS,
241
+ filteredAttrs: options.filterAttrs,
234
242
  }
243
+
244
+ // eslint-disable-next-line no-console
245
+ console.debug(`[rocketstyle] ${componentName} render:`, debugPayload)
235
246
  }
247
+ }
236
248
 
237
- return RenderComponent(finalProps)
238
- }) as unknown as ReturnType<ComponentFn<InnerComponentProps>>
249
+ // STATIC VNode — created once, never remounted on mode change.
250
+ // The styled component handles reactive class swaps internally.
251
+ return RenderComponent(finalProps)
239
252
  }
240
253
 
241
254
  // ------------------------------------------------------
@@ -285,12 +298,12 @@ const rocketComponent: RocketComponent = (options) => {
285
298
  }
286
299
 
287
300
  if (priority) {
288
- result.priorityAttrs = attrs as ExtendedConfiguration["priorityAttrs"]
301
+ result.priorityAttrs = attrs as ExtendedConfiguration['priorityAttrs']
289
302
 
290
303
  return cloneAndEnhance(options, result)
291
304
  }
292
305
 
293
- result.attrs = attrs as ExtendedConfiguration["attrs"]
306
+ result.attrs = attrs as ExtendedConfiguration['attrs']
294
307
 
295
308
  return cloneAndEnhance(options, result)
296
309
  },
@@ -326,8 +339,8 @@ const rocketComponent: RocketComponent = (options) => {
326
339
  {
327
340
  render,
328
341
  mode,
329
- isDark: mode === "light",
330
- isLight: mode === "dark",
342
+ isDark: mode === 'light',
343
+ isLight: mode === 'dark',
331
344
  },
332
345
  ]),
333
346
  })
@@ -1,5 +1,5 @@
1
- import type { render } from "@pyreon/ui-core"
2
- import type { ThemeModeKeys } from "./theme"
1
+ import type { render } from '@pyreon/ui-core'
2
+ import type { ThemeModeKeys } from './theme'
3
3
 
4
4
  export type AttrsCb<A, T> = (
5
5
  props: Partial<A>,
@@ -1,6 +1,6 @@
1
- import type { DimensionBooleanAttrs, Dimensions, ExtractDimensions, TDKP } from "./dimensions"
2
- import type { PseudoState } from "./pseudo"
3
- import type { ElementType, TObj } from "./utils"
1
+ import type { DimensionBooleanAttrs, Dimensions, ExtractDimensions, TDKP } from './dimensions'
2
+ import type { PseudoState } from './pseudo'
3
+ import type { ElementType, TObj } from './utils'
4
4
 
5
5
  // --------------------------------------------------------
6
6
  // CONFIG
@@ -11,7 +11,7 @@ export type RocketComponentType = ElementType & {
11
11
  }
12
12
 
13
13
  export type RocketProviderState<T extends RocketComponentType | TObj | unknown = unknown> =
14
- T extends RocketComponentType ? Partial<T["$$rocketstyle"]> & { pseudo: PseudoState } : T
14
+ T extends RocketComponentType ? Partial<T['$$rocketstyle']> & { pseudo: PseudoState } : T
15
15
 
16
16
  export type ConsumerCtxCBValue<
17
17
  T extends RocketComponentType,
@@ -1,8 +1,8 @@
1
- import type { ConsumerCb } from "./config"
2
- import type { Dimensions, MultiKeys } from "./dimensions"
3
- import type { PseudoProps } from "./pseudo"
4
- import type { StylesCbArray } from "./styles"
5
- import type { ArrayOfKeys, ArrayOfValues, ElementType, TFn } from "./utils"
1
+ import type { ConsumerCb } from './config'
2
+ import type { Dimensions, MultiKeys } from './dimensions'
3
+ import type { PseudoProps } from './pseudo'
4
+ import type { StylesCbArray } from './styles'
5
+ import type { ArrayOfKeys, ArrayOfValues, ElementType, TFn } from './utils'
6
6
 
7
7
  export type __ROCKETSTYLE__ = {
8
8
  dimensions: Record<string, string>
@@ -1,7 +1,7 @@
1
- import type { DefaultDimensions } from "../constants/defaultDimensions"
2
- import type { Css } from "./styles"
3
- import type { ThemeModeCallback } from "./theme"
4
- import type { CallBackParam, NullableKeys, ReturnCbParam, Spread, TObj, ValueOf } from "./utils"
1
+ import type { DefaultDimensions } from '../constants/defaultDimensions'
2
+ import type { Css } from './styles'
3
+ import type { ThemeModeCallback } from './theme'
4
+ import type { CallBackParam, NullableKeys, ReturnCbParam, Spread, TObj, ValueOf } from './utils'
5
5
 
6
6
  export type { DefaultDimensions }
7
7
 
@@ -10,7 +10,7 @@ export type ExtractNullableDimensionKeys<T> = {
10
10
  }
11
11
 
12
12
  export type ExtractDimensionKey<T extends DimensionValue> = T extends DimensionValueObj
13
- ? T["propName"]
13
+ ? T['propName']
14
14
  : T
15
15
 
16
16
  export type ExtractDimensionMulti<T extends DimensionValue> = T extends DimensionValueObj
package/src/types/hoc.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ElementType } from "./utils"
1
+ import type { ElementType } from './utils'
2
2
 
3
3
  export type GenericHoc = (component: ElementType) => ElementType
4
4
 
@@ -1,7 +1,7 @@
1
- import type { Configuration } from "./configuration"
2
- import type { DefaultDimensions, Dimensions } from "./dimensions"
3
- import type { RocketStyleComponent } from "./rocketstyle"
4
- import type { ElementType, ExtractProps, TObj } from "./utils"
1
+ import type { Configuration } from './configuration'
2
+ import type { DefaultDimensions, Dimensions } from './dimensions'
3
+ import type { RocketStyleComponent } from './rocketstyle'
4
+ import type { ElementType, ExtractProps, TObj } from './utils'
5
5
 
6
6
  export type RocketComponent<
7
7
  C extends ElementType = ElementType,
@@ -1,7 +1,7 @@
1
- import type { VNodeChild } from "@pyreon/core"
2
- import type { AttrsCb } from "./attrs"
3
- import type { ConfigAttrs } from "./config"
4
- import type { DefaultProps } from "./configuration"
1
+ import type { VNodeChild } from '@pyreon/core'
2
+ import type { AttrsCb } from './attrs'
3
+ import type { ConfigAttrs } from './config'
4
+ import type { DefaultProps } from './configuration'
5
5
  import type {
6
6
  DimensionCallbackParam,
7
7
  DimensionProps,
@@ -11,14 +11,14 @@ import type {
11
11
  ExtractDimensions,
12
12
  MultiKeys,
13
13
  TDKP,
14
- } from "./dimensions"
15
- import type { ComposeParam } from "./hoc"
16
- import type { Styles, StylesCb } from "./styles"
17
- import type { Theme, ThemeCb, ThemeModeKeys } from "./theme"
18
- import type { ElementType, ExtractProps, MergeTypes, TObj } from "./utils"
14
+ } from './dimensions'
15
+ import type { ComposeParam } from './hoc'
16
+ import type { Styles, StylesCb } from './styles'
17
+ import type { Theme, ThemeCb, ThemeModeKeys } from './theme'
18
+ import type { ElementType, ExtractProps, MergeTypes, TObj } from './utils'
19
19
 
20
20
  export type InnerComponentProps = {
21
- "data-rocketstyle"?: string | undefined
21
+ 'data-rocketstyle'?: string | undefined
22
22
  } & Record<string, any>
23
23
 
24
24
  export type RocketStyleComponent<
@@ -1,6 +1,6 @@
1
- import type { config } from "@pyreon/ui-core"
2
- import type { PseudoState } from "./pseudo"
3
- import type { TObj } from "./utils"
1
+ import type { config } from '@pyreon/ui-core'
2
+ import type { PseudoState } from './pseudo'
3
+ import type { TObj } from './utils'
4
4
 
5
5
  // biome-ignore lint/suspicious/noEmptyInterface: this is an interface to be extended in consuming projects
6
6
  export interface StylesDefault {}
@@ -15,8 +15,13 @@ export type OptionStyles = ((css: Css) => ReturnType<Css>)[]
15
15
  /**
16
16
  * Props available inside `.styles()` interpolation functions.
17
17
  *
18
- * - `$rocketstyle` — computed theme (inferred from `.theme()` chain)
18
+ * - `$rocketstyle` — resolved theme object (the styled() runtime resolves
19
+ * the reactive accessor before calling interpolation functions)
19
20
  * - `$rocketstate` — active dimension values + pseudo state
21
+ *
22
+ * Note: internally, rocketstyle passes $rocketstyle as a `() => CSS` accessor
23
+ * to DynamicStyled for reactive class swapping. But by the time interpolation
24
+ * functions run, it's always been resolved to a plain CSS object.
20
25
  */
21
26
  export type RocketStyleInterpolationProps<CSS extends TObj = TObj> = {
22
27
  $rocketstyle: CSS
@@ -1,6 +1,6 @@
1
- import type { THEME_MODES } from "../constants"
2
- import type { Css } from "./styles"
3
- import type { MergeTypes } from "./utils"
1
+ import type { THEME_MODES } from '../constants'
2
+ import type { Css } from './styles'
3
+ import type { MergeTypes } from './utils'
4
4
 
5
5
  // biome-ignore lint/suspicious/noEmptyInterface: this is an interface to be extended in consuming projects
6
6
  export interface ThemeDefault {}
@@ -12,7 +12,7 @@ export type ThemeModeKeys = keyof typeof THEME_MODES
12
12
  export type ThemeModeCallback = <A = any, B = any>(
13
13
  light: A,
14
14
  dark: B,
15
- ) => (mode: "light" | "dark") => A | B
15
+ ) => (mode: 'light' | 'dark') => A | B
16
16
 
17
17
  export type ThemeMode = <A = any, B = any>(light: A, dark: B) => A | B
18
18
 
@@ -1,4 +1,4 @@
1
- import type { VNodeChild } from "@pyreon/core"
1
+ import type { VNodeChild } from '@pyreon/core'
2
2
 
3
3
  export type TObj = Record<string, unknown>
4
4
  export type TFn = (...args: any) => any
@@ -1,4 +1,4 @@
1
- import type { MultiKeys } from "../types/dimensions"
1
+ import type { MultiKeys } from '../types/dimensions'
2
2
 
3
3
  // --------------------------------------------------------
4
4
  // remove undefined props
@@ -91,7 +91,7 @@ export const calculateStylingAttrs: CalculateStylingAttrs =
91
91
  }
92
92
  // assign when it's only a string or number otherwise it's considered
93
93
  // as invalid param
94
- else if (t === "string" || t === "number") {
94
+ else if (t === 'string' || t === 'number') {
95
95
  result[item] = pickedProp
96
96
  } else {
97
97
  result[item] = undefined
@@ -13,8 +13,8 @@ type ChainOptions = (opts: Obj | Func | undefined, defaultOpts: Func[]) => Func[
13
13
  export const chainOptions: ChainOptions = (opts, defaultOpts = []) => {
14
14
  const result = [...defaultOpts]
15
15
 
16
- if (typeof opts === "function") result.push(opts)
17
- else if (typeof opts === "object") result.push(() => opts)
16
+ if (typeof opts === 'function') result.push(opts)
17
+ else if (typeof opts === 'object') result.push(() => opts)
18
18
 
19
19
  return result
20
20
  }
@@ -7,5 +7,5 @@ type CalculateHocsFuncs = (options: Record<string, any>) => ((arg: any) => any)[
7
7
 
8
8
  export const calculateHocsFuncs: CalculateHocsFuncs = (options = {}) =>
9
9
  Object.values(options)
10
- .filter((item) => typeof item === "function")
10
+ .filter((item) => typeof item === 'function')
11
11
  .reverse()
@@ -1,5 +1,5 @@
1
- import { get, isEmpty, set } from "@pyreon/ui-core"
2
- import type { Dimensions, DimensionValue, MultiKeys } from "../types/dimensions"
1
+ import { get, isEmpty, set } from '@pyreon/ui-core'
2
+ import type { Dimensions, DimensionValue, MultiKeys } from '../types/dimensions'
3
3
 
4
4
  // --------------------------------------------------------
5
5
  // Is value a valid key
@@ -15,7 +15,7 @@ export const isValidKey: IsValidKey = (value) =>
15
15
  /** Determines if a dimension value is a multi-key config object, returning [isMulti, propName]. */
16
16
  type IsMultiKey = (value: string | Record<string, unknown>) => [boolean, string]
17
17
  export const isMultiKey: IsMultiKey = (value) => {
18
- if (typeof value === "object" && value !== null) return [true, get(value, "propName") as string]
18
+ if (typeof value === 'object' && value !== null) return [true, get(value, 'propName') as string]
19
19
  return [false, value]
20
20
  }
21
21
 
@@ -81,7 +81,7 @@ type GetDimensionsValues = <T extends Dimensions, K extends keyof T>(obj: T) =>
81
81
 
82
82
  export const getDimensionsValues = (<T extends Dimensions>(obj: T) =>
83
83
  getValues(obj).map((item: DimensionValue) => {
84
- if (typeof item === "object") {
84
+ if (typeof item === 'object') {
85
85
  return item.propName as string
86
86
  }
87
87
 
@@ -97,7 +97,7 @@ type GetMultipleDimensions = <T extends Dimensions>(obj: T) => MultiKeys<T>
97
97
  export const getMultipleDimensions: GetMultipleDimensions = (obj) =>
98
98
  getValues(obj).reduce(
99
99
  (accumulator, value: DimensionValue) => {
100
- if (typeof value === "object") {
100
+ if (typeof value === 'object') {
101
101
  if (value.multi === true) accumulator[value.propName] = true
102
102
  }
103
103
 
@@ -116,7 +116,7 @@ type GetTransformDimensions = <T extends Dimensions>(obj: T) => TransformKeys
116
116
  export const getTransformDimensions: GetTransformDimensions = (obj) =>
117
117
  getValues(obj).reduce(
118
118
  (accumulator, value: DimensionValue) => {
119
- if (typeof value === "object") {
119
+ if (typeof value === 'object') {
120
120
  if (value.transform === true) accumulator[value.propName] = true
121
121
  }
122
122
 
@@ -1,5 +1,5 @@
1
- import { isEmpty } from "@pyreon/ui-core"
2
- import { STATIC_KEYS } from "../constants"
1
+ import { isEmpty } from '@pyreon/ui-core'
2
+ import { STATIC_KEYS } from '../constants'
3
3
 
4
4
  // --------------------------------------------------------
5
5
  // helpers for create statics chaining methods on component
@@ -1,5 +1,5 @@
1
- import { config } from "@pyreon/ui-core"
2
- import type { StylesCbArray } from "../types/styles"
1
+ import { config } from '@pyreon/ui-core'
2
+ import type { StylesCbArray } from '../types/styles'
3
3
 
4
4
  // --------------------------------------------------------
5
5
  // Calculate styles
@@ -1,17 +1,17 @@
1
- import { config, isEmpty, merge } from "@pyreon/ui-core"
2
- import type { ThemeModeCallback } from "../types/theme"
3
- import { removeNullableValues } from "./collection"
4
- import { isMultiKey } from "./dimensions"
1
+ import { config, isEmpty, merge } from '@pyreon/ui-core'
2
+ import type { ThemeModeCallback } from '../types/theme'
3
+ import { removeNullableValues } from './collection'
4
+ import { isMultiKey } from './dimensions'
5
5
 
6
6
  // --------------------------------------------------------
7
7
  // Theme Mode Callback
8
8
  // --------------------------------------------------------
9
- const MODE_CALLBACK_BRAND = Symbol.for("pyreon.themeModeCallback")
9
+ const MODE_CALLBACK_BRAND = Symbol.for('pyreon.themeModeCallback')
10
10
 
11
11
  /** Creates a mode-switching function that returns the light or dark value based on the active mode. */
12
12
  export const themeModeCallback: ThemeModeCallback = (light, dark) => {
13
13
  const fn = (mode: string) => {
14
- if (!mode || mode === "light") return light
14
+ if (!mode || mode === 'light') return light
15
15
  return dark
16
16
  }
17
17
  ;(fn as unknown as Record<string, unknown>).__brand = MODE_CALLBACK_BRAND
@@ -24,7 +24,7 @@ export const themeModeCallback: ThemeModeCallback = (light, dark) => {
24
24
  /** Detects whether a value is a `themeModeCallback` function via Symbol brand. */
25
25
  type IsModeCallback = (value: unknown) => boolean
26
26
  const isModeCallback: IsModeCallback = (value: unknown) =>
27
- typeof value === "function" &&
27
+ typeof value === 'function' &&
28
28
  (value as unknown as Record<string, unknown>).__brand === MODE_CALLBACK_BRAND
29
29
 
30
30
  // --------------------------------------------------------
@@ -136,7 +136,7 @@ export const getTheme: GetTheme = ({ rocketstate, themes, baseTheme, transformKe
136
136
 
137
137
  const mergeValue = (item: string) => {
138
138
  const val = keyTheme[item]
139
- if (isTransform && typeof val === "function") {
139
+ if (isTransform && typeof val === 'function') {
140
140
  deferredTransforms.push(val)
141
141
  } else {
142
142
  finalTheme = merge({}, finalTheme, val)
@@ -171,7 +171,7 @@ export const getTheme: GetTheme = ({ rocketstate, themes, baseTheme, transformKe
171
171
  */
172
172
  export type GetThemeByMode = (
173
173
  object: Record<string, any>,
174
- mode: "light" | "dark",
174
+ mode: 'light' | 'dark',
175
175
  ) => Partial<{
176
176
  baseTheme: Record<string, unknown>
177
177
  themes: Record<string, unknown>
@@ -182,7 +182,7 @@ export const getThemeByMode: GetThemeByMode = (object, mode) =>
182
182
  (acc, key) => {
183
183
  const value = object[key]
184
184
 
185
- if (typeof value === "object" && value !== null) {
185
+ if (typeof value === 'object' && value !== null) {
186
186
  acc[key] = getThemeByMode(value, mode)
187
187
  } else if (isModeCallback(value)) {
188
188
  acc[key] = value(mode)