@pyreon/coolgrid 0.24.0 → 0.24.2

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/lib/index.js CHANGED
@@ -43,14 +43,13 @@ var RowContext_default = createContext({});
43
43
 
44
44
  //#endregion
45
45
  //#region src/useContext.tsx
46
- const pickThemeProps = (props, keywords) => pick(props, keywords);
47
46
  const getGridContext = (props = {}, theme = {}) => ({
48
- columns: get(props, "columns") || get(theme, "grid.columns") || get(theme, "coolgrid.columns"),
49
- containerWidth: get(props, "width") || get(theme, "grid.container") || get(theme, "coolgrid.container")
47
+ columns: props.columns || get(theme, "grid.columns") || get(theme, "coolgrid.columns"),
48
+ containerWidth: props.width || get(theme, "grid.container") || get(theme, "coolgrid.container")
50
49
  });
51
50
  const useGridContext = (props) => {
52
51
  const { theme } = useContext(context)();
53
- const ctxProps = pickThemeProps(props, CONTEXT_KEYS);
52
+ const ctxProps = pick(props, CONTEXT_KEYS);
54
53
  return {
55
54
  ...getGridContext(ctxProps, theme),
56
55
  ...ctxProps
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyreon/coolgrid",
3
- "version": "0.24.0",
3
+ "version": "0.24.2",
4
4
  "description": "Responsive grid system for Pyreon",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,8 +43,8 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@pyreon/test-utils": "^0.13.11",
46
- "@pyreon/typescript": "^0.24.0",
47
- "@pyreon/ui-core": "^0.24.0",
46
+ "@pyreon/typescript": "^0.24.2",
47
+ "@pyreon/ui-core": "^0.24.2",
48
48
  "@vitest/browser-playwright": "^4.1.4",
49
49
  "@vitus-labs/tools-rolldown": "^2.4.0"
50
50
  },
@@ -52,10 +52,10 @@
52
52
  "node": ">= 22"
53
53
  },
54
54
  "dependencies": {
55
- "@pyreon/core": "^0.24.0",
56
- "@pyreon/reactivity": "^0.24.0",
57
- "@pyreon/styler": "^0.24.0",
58
- "@pyreon/ui-core": "^0.24.0",
59
- "@pyreon/unistyle": "^0.24.0"
55
+ "@pyreon/core": "^0.24.2",
56
+ "@pyreon/reactivity": "^0.24.2",
57
+ "@pyreon/styler": "^0.24.2",
58
+ "@pyreon/ui-core": "^0.24.2",
59
+ "@pyreon/unistyle": "^0.24.2"
60
60
  }
61
61
  }
@@ -4,16 +4,6 @@ import { context } from '@pyreon/unistyle'
4
4
  import { CONTEXT_KEYS } from './constants'
5
5
  import type { Context, Obj, ValueType } from './types'
6
6
 
7
- /**
8
- * Picks only the recognized grid configuration keys from a props object,
9
- * filtering out any non-grid props before they enter context resolution.
10
- */
11
- export type PickThemeProps = <T extends Record<string, unknown>>(
12
- props: T,
13
- keywords: Array<keyof T>,
14
- ) => ReturnType<typeof pick>
15
- const pickThemeProps: PickThemeProps = (props, keywords) => pick(props, keywords)
16
-
17
7
  /**
18
8
  * Resolves grid columns and container width using a three-layer fallback:
19
9
  * 1. Explicit component props (e.g. `columns={6}`)
@@ -29,10 +19,15 @@ type GetGridContext = (
29
19
  }
30
20
 
31
21
  export const getGridContext: GetGridContext = (props = {}, theme = {}) => ({
32
- columns: (get(props, 'columns') ||
22
+ // `props` is always a plain object (callers pass a `pick()` result or a
23
+ // user-supplied object literal), so direct property access is safe and
24
+ // skips `get`'s path-parsing for these single-key lookups. Ported from
25
+ // vitus-labs `55402572`. Two `get` calls per `getGridContext` invocation
26
+ // saved; fires once per Container/Row/Col render.
27
+ columns: ((props as Obj).columns ||
33
28
  get(theme, 'grid.columns') ||
34
29
  get(theme, 'coolgrid.columns')) as ValueType,
35
- containerWidth: (get(props, 'width') ||
30
+ containerWidth: ((props as Obj).width ||
36
31
  get(theme, 'grid.container') ||
37
32
  get(theme, 'coolgrid.container')) as Record<string, number>,
38
33
  })
@@ -46,7 +41,9 @@ type UseGridContext = (props: Obj) => Context
46
41
  const useGridContext: UseGridContext = (props) => {
47
42
  const getCtx = useContext(context)
48
43
  const { theme } = getCtx()
49
- const ctxProps = pickThemeProps(props, CONTEXT_KEYS)
44
+ // Direct `pick` (vs the `pickThemeProps` one-liner wrapper that was
45
+ // removed in vitus-labs `55402572`) saves one function call per render.
46
+ const ctxProps = pick(props, CONTEXT_KEYS as Array<keyof typeof props>)
50
47
  const gridContext = getGridContext(ctxProps, theme as Record<string, unknown>)
51
48
 
52
49
  return { ...gridContext, ...ctxProps }