@pyreon/rocketstyle 0.11.5 → 0.11.6

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 +99 -88
  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 +78 -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 +180 -253
  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 +22 -12
  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 +103 -109
  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
@@ -123,119 +123,113 @@ const rocketComponent: RocketComponent = (options) => {
123
123
  }
124
124
 
125
125
  // --------------------------------------------------
126
- // Reactive accessorre-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.
126
+ // Static theme structure computed once at mount, doesn't change with mode.
127
+ // Only the mode-dependent resolution is reactive (via $rocketstyle accessor).
131
128
  // --------------------------------------------------
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))
146
- }
147
- const baseTheme = baseThemeHelper.get(theme)
129
+ const theme = themeAttrs.theme
148
130
 
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)
131
+ // BASE / DEFAULT THEME Object (cached by theme identity)
132
+ const baseThemeHelper = ThemeManager.baseTheme
133
+ if (!baseThemeHelper.has(theme)) {
134
+ baseThemeHelper.set(theme, getThemeFromChain(options.theme, theme))
135
+ }
136
+ const baseTheme = baseThemeHelper.get(theme)
137
+
138
+ // DIMENSION(S) THEMES Object (cached by theme identity)
139
+ const dimHelper = ThemeManager.dimensionsThemes
140
+ if (!dimHelper.has(theme)) {
141
+ dimHelper.set(theme, getDimensionThemes(theme, options))
142
+ }
143
+ const themes = dimHelper.get(theme)
144
+
145
+ // --------------------------------------------------
146
+ // dimension map & reserved prop names
147
+ // --------------------------------------------------
148
+ const { keysMap: dimensions, keywords: reservedPropNames } = getDimensionsMap({
149
+ themes,
150
+ useBooleans: options.useBooleans,
151
+ })
152
+
153
+ const RESERVED_STYLING_PROPS_KEYS = Object.keys(reservedPropNames)
154
+
155
+ // --------------------------------------------------
156
+ // rocketstate — active dimension values
157
+ // --------------------------------------------------
158
+ const rocketstate = _calculateStylingAttrs({
159
+ props: pickStyledAttrs(mergeProps, reservedPropNames),
160
+ dimensions,
161
+ })
162
+
163
+ const finalRocketstate = { ...rocketstate, pseudo: pseudoRocketstate }
164
+
165
+ // --------------------------------------------------
166
+ // $rocketstyle as a FUNCTION ACCESSOR — reactive on mode changes.
167
+ // The styled component calls this inside its own effect() to track
168
+ // the mode dependency. Only the CSS class swaps — no VNode remount.
169
+ // --------------------------------------------------
170
+ const $rocketstyleAccessor = () => {
171
+ const mode = themeAttrs.mode // reactive read via getter
155
172
 
156
- // BASE / DEFAULT MODE THEME Object (cached by mode + baseTheme)
157
173
  const modeBaseHelper = ThemeManager.modeBaseTheme[mode]
158
174
  if (!modeBaseHelper.has(baseTheme)) {
159
175
  modeBaseHelper.set(baseTheme, getThemeByMode(baseTheme, mode))
160
176
  }
161
177
  const currentModeBaseTheme = modeBaseHelper.get(baseTheme)
162
178
 
163
- // DIMENSION(S) MODE THEMES Object (cached by mode + themes)
164
179
  const modeDimHelper = ThemeManager.modeDimensionTheme[mode]
165
180
  if (!modeDimHelper.has(themes)) {
166
181
  modeDimHelper.set(themes, getThemeByMode(themes, mode))
167
182
  }
168
183
  const currentModeThemes = modeDimHelper.get(themes)
169
184
 
170
- // --------------------------------------------------
171
- // dimension map & reserved prop names
172
- // --------------------------------------------------
173
- const { keysMap: dimensions, keywords: reservedPropNames } = getDimensionsMap({
174
- themes,
175
- useBooleans: options.useBooleans,
176
- })
177
-
178
- const RESERVED_STYLING_PROPS_KEYS = Object.keys(reservedPropNames)
179
-
180
- // --------------------------------------------------
181
- // rocketstate — active dimension values
182
- // --------------------------------------------------
183
- const rocketstate = _calculateStylingAttrs({
184
- props: pickStyledAttrs(mergeProps, reservedPropNames),
185
- dimensions,
186
- })
187
-
188
- const finalRocketstate = { ...rocketstate, pseudo: pseudoRocketstate }
189
-
190
- // --------------------------------------------------
191
- // rocketstyle — computed theme based on active dimensions
192
- // --------------------------------------------------
193
- const computedRocketstyle = getTheme({
185
+ return getTheme({
194
186
  rocketstate,
195
187
  themes: currentModeThemes,
196
188
  baseTheme: currentModeBaseTheme,
197
189
  transformKeys: options.transformKeys,
198
190
  appTheme: theme,
199
191
  })
192
+ }
200
193
 
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
- }
194
+ // --------------------------------------------------
195
+ // final props passed to WrappedComponent
196
+ // --------------------------------------------------
197
+ const finalProps: Record<string, any> = {
198
+ ...omit(mergeProps, [
199
+ ...RESERVED_STYLING_PROPS_KEYS,
200
+ ...PSEUDO_KEYS,
201
+ ...options.filterAttrs,
202
+ ]),
203
+ ...(options.passProps ? pick(mergeProps, options.passProps) : {}),
204
+ ref: props.ref,
205
+ // FUNCTION accessor — styled component resolves it reactively
206
+ $rocketstyle: $rocketstyleAccessor,
207
+ $rocketstate: finalRocketstate,
208
+ }
216
209
 
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)
210
+ // development debugging
211
+ if (process.env.NODE_ENV !== 'production') {
212
+ finalProps['data-rocketstyle'] = componentName
213
+
214
+ if (options.DEBUG) {
215
+ const debugPayload = {
216
+ component: componentName,
217
+ rocketstate: finalRocketstate,
218
+ rocketstyle: $rocketstyleAccessor(),
219
+ dimensions,
220
+ mode: themeAttrs.mode,
221
+ reservedPropNames: RESERVED_STYLING_PROPS_KEYS,
222
+ filteredAttrs: options.filterAttrs,
234
223
  }
224
+
225
+ // eslint-disable-next-line no-console
226
+ console.debug(`[rocketstyle] ${componentName} render:`, debugPayload)
235
227
  }
228
+ }
236
229
 
237
- return RenderComponent(finalProps)
238
- }) as unknown as ReturnType<ComponentFn<InnerComponentProps>>
230
+ // STATIC VNode — created once, never remounted on mode change.
231
+ // The styled component handles reactive class swaps internally.
232
+ return RenderComponent(finalProps)
239
233
  }
240
234
 
241
235
  // ------------------------------------------------------
@@ -285,12 +279,12 @@ const rocketComponent: RocketComponent = (options) => {
285
279
  }
286
280
 
287
281
  if (priority) {
288
- result.priorityAttrs = attrs as ExtendedConfiguration["priorityAttrs"]
282
+ result.priorityAttrs = attrs as ExtendedConfiguration['priorityAttrs']
289
283
 
290
284
  return cloneAndEnhance(options, result)
291
285
  }
292
286
 
293
- result.attrs = attrs as ExtendedConfiguration["attrs"]
287
+ result.attrs = attrs as ExtendedConfiguration['attrs']
294
288
 
295
289
  return cloneAndEnhance(options, result)
296
290
  },
@@ -326,8 +320,8 @@ const rocketComponent: RocketComponent = (options) => {
326
320
  {
327
321
  render,
328
322
  mode,
329
- isDark: mode === "light",
330
- isLight: mode === "dark",
323
+ isDark: mode === 'light',
324
+ isLight: mode === 'dark',
331
325
  },
332
326
  ]),
333
327
  })
@@ -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)