@pyreon/coolgrid 0.12.0 → 0.12.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index2.d.ts","names":[],"sources":["../../src/types.ts","../../src/Col/component.tsx","../../src/Container/component.tsx","../../src/Row/component.tsx","../../src/theme.ts"],"mappings":";;;;;KAWK,eAAA,MAAqB,CAAA,GAAI,CAAA,KAAM,OAAA,CAAQ,MAAA,CAAO,cAAA,EAAgB,CAAA;AAAA,KAGvD,KAAA;AAAA,KACA,GAAA,GAAM,UAAA,QAAkB,SAAA;AAAA,KACxB,WAAA,GAAc,eAAA,CAAgB,GAAA;AAAA,KAI9B,SAAA,GAAY,eAAA;AAAA,KACZ,cAAA,GAAiB,eAAA,CAAgB,KAAA;AAAA,KAEjC,aAAA;AAAA,KAQA,kBAAA,GAAqB,OAAA;EAC/B,IAAA,EAAM,SAAA;EACN,OAAA,EAAS,SAAA;EACT,GAAA,EAAK,SAAA;EACL,MAAA,EAAQ,SAAA;EACR,OAAA,EAAS,SAAA;EACT,MAAA,EAAQ,WAAA;EACR,MAAA,EAAQ,WAAA;EACR,YAAA,EAAc,WAAA;EACd,YAAA,EAAc,WAAA;EACd,aAAA,EAAe,aAAA;EACf,cAAA,EAAgB,cAAA;EAChB,KAAA,EAAO,cAAA,KAAmB,MAAA,EAAQ,MAAA,kBAAwB,cAAA;AAAA;AAAA,KAGhD,cAAA,GAAiB,kBAAA,GAC3B,OAAA;EACE,SAAA,EAAW,WAAA;EACX,GAAA,EAAK,WAAA;AAAA;AAAA,KAcG,WAAA,uBAAkC,WAAA,CAC5C,IAAA,CAAK,cAAA,EAAgB,CAAA,YAAa,MAAA;EAA4B,QAAA,GAAW,UAAA;AAAA;EAEzE,WAAA;EACA,OAAA;EACA,iBAAA;AAAA;;;cCnDI,SAAA,EAAW,WAAA;;;cCCX,WAAA,EAAW,WAAA;;;cCAX,WAAA,EAAW,WAAA"}
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ALIGN_CONTENT_MAP_X, Provider, context, extendCss, makeItResponsive, value } from "@pyreon/unistyle";
2
- import { createContext, provide, useContext } from "@pyreon/core";
2
+ import { createContext, provide, splitProps, useContext } from "@pyreon/core";
3
3
  import { config, get, omit, pick } from "@pyreon/ui-core";
4
4
  import { jsx } from "@pyreon/core/jsx-runtime";
5
5
 
@@ -151,24 +151,29 @@ var styled_default$2 = styled$2(component$2)`
151
151
  * of the total columns. Supports responsive size, padding, and visibility.
152
152
  */
153
153
  const DEV_PROPS$2 = process.env.NODE_ENV !== "production" ? { "data-coolgrid": "col" } : {};
154
- const Component$2 = ({ children, component, css, ...props }) => {
154
+ const Component$2 = (props) => {
155
+ const [own, rest] = splitProps(props, [
156
+ "children",
157
+ "component",
158
+ "css"
159
+ ]);
155
160
  const { colCss, colComponent, columns, gap, size, padding } = useGridContext({
156
161
  ...useContext(RowContext_default),
157
- ...props
162
+ ...rest
158
163
  });
159
164
  const finalProps = { $coolgrid: {
160
165
  columns,
161
166
  gap,
162
167
  size,
163
168
  padding,
164
- extraStyles: css ?? colCss
169
+ extraStyles: own.css ?? colCss
165
170
  } };
166
171
  return /* @__PURE__ */ jsx(styled_default$2, {
167
- ...omitCtxKeys(props),
168
- as: component ?? colComponent,
172
+ ...omitCtxKeys(rest),
173
+ as: own.component ?? colComponent,
169
174
  ...finalProps,
170
175
  ...DEV_PROPS$2,
171
- children
176
+ children: own.children
172
177
  });
173
178
  };
174
179
  const name$2 = `${PKG_NAME}/Col`;
@@ -217,8 +222,14 @@ var styled_default$1 = styled$1(component$1)`
217
222
  * responsive max-width.
218
223
  */
219
224
  const DEV_PROPS$1 = process.env.NODE_ENV !== "production" ? { "data-coolgrid": "container" } : {};
220
- const Component$1 = ({ children, component, css, width, ...props }) => {
221
- const { containerWidth, columns, size, gap, padding, gutter, colCss, colComponent, rowCss, rowComponent, contentAlignX } = useGridContext(props);
225
+ const Component$1 = (props) => {
226
+ const [own, rest] = splitProps(props, [
227
+ "children",
228
+ "component",
229
+ "css",
230
+ "width"
231
+ ]);
232
+ const { containerWidth, columns, size, gap, padding, gutter, colCss, colComponent, rowCss, rowComponent, contentAlignX } = useGridContext(rest);
222
233
  const context = {
223
234
  columns,
224
235
  size,
@@ -233,19 +244,19 @@ const Component$1 = ({ children, component, css, width, ...props }) => {
233
244
  };
234
245
  const finalProps = { $coolgrid: {
235
246
  width: (() => {
236
- if (!width) return containerWidth;
237
- if (typeof width === "function") return width(containerWidth);
238
- return width;
247
+ if (!own.width) return containerWidth;
248
+ if (typeof own.width === "function") return own.width(containerWidth);
249
+ return own.width;
239
250
  })(),
240
- extraStyles: css
251
+ extraStyles: own.css
241
252
  } };
242
253
  provide(ContainerContext_default, context);
243
254
  return /* @__PURE__ */ jsx(styled_default$1, {
244
- ...omitCtxKeys(props),
245
- as: component,
255
+ ...omitCtxKeys(rest),
256
+ as: own.component,
246
257
  ...finalProps,
247
258
  ...DEV_PROPS$1,
248
- children
259
+ children: own.children
249
260
  });
250
261
  };
251
262
  const name$1 = `${PKG_NAME}/Container`;
@@ -313,10 +324,16 @@ var styled_default = styled(component)`
313
324
  * with negative margins to offset column gutters.
314
325
  */
315
326
  const DEV_PROPS = process.env.NODE_ENV !== "production" ? { "data-coolgrid": "row" } : {};
316
- const Component = ({ children, component, css, contentAlignX: rowAlignX, ...props }) => {
327
+ const Component = (props) => {
328
+ const [own, rest] = splitProps(props, [
329
+ "children",
330
+ "component",
331
+ "css",
332
+ "contentAlignX"
333
+ ]);
317
334
  const { columns, gap, gutter, rowComponent, rowCss, contentAlignX, containerWidth, size, padding, colCss, colComponent } = useGridContext({
318
335
  ...useContext(ContainerContext_default),
319
- ...props
336
+ ...rest
320
337
  });
321
338
  const context = {
322
339
  containerWidth,
@@ -329,19 +346,19 @@ const Component = ({ children, component, css, contentAlignX: rowAlignX, ...prop
329
346
  gutter
330
347
  };
331
348
  const finalProps = { $coolgrid: {
332
- contentAlignX: rowAlignX || contentAlignX,
349
+ contentAlignX: own.contentAlignX || contentAlignX,
333
350
  columns,
334
351
  gap,
335
352
  gutter,
336
- extraStyles: css || rowCss
353
+ extraStyles: own.css || rowCss
337
354
  } };
338
355
  provide(RowContext_default, context);
339
356
  return /* @__PURE__ */ jsx(styled_default, {
340
- ...omitCtxKeys(props),
341
- as: component || rowComponent,
357
+ ...omitCtxKeys(rest),
358
+ as: own.component || rowComponent,
342
359
  ...finalProps,
343
360
  ...DEV_PROPS,
344
- children
361
+ children: own.children
345
362
  });
346
363
  };
347
364
  const name = `${PKG_NAME}/Row`;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["spacingStyles","styles","component","DEV_PROPS","Component","RowContext","Styled","name","component","styles","component","DEV_PROPS","Component","ContainerContext","Styled","name","component","ContainerContext","RowContext","Styled","component"],"sources":["../src/constants.ts","../src/context/ContainerContext.ts","../src/context/RowContext.ts","../src/useContext.tsx","../src/utils.ts","../src/Col/styled.ts","../src/Col/component.tsx","../src/Col/index.ts","../src/Container/styled.ts","../src/Container/component.tsx","../src/Container/index.ts","../src/Row/styled.ts","../src/Row/component.tsx","../src/Row/index.ts","../src/theme.ts"],"sourcesContent":["export const PKG_NAME = '@pyreon/coolgrid'\n\n/**\n * Grid configuration keys that are passed through context\n * from Container to Row and from Row to Col components.\n */\nexport const CONTEXT_KEYS = [\n // 'breakpoints',\n // 'rootSize',\n 'columns',\n 'size',\n 'gap',\n 'padding',\n 'gutter',\n 'colCss',\n 'colComponent',\n 'rowCss',\n 'rowComponent',\n 'contentAlignX',\n]\n","import { createContext } from '@pyreon/core'\nimport type { Context as ContextType } from '../types'\n\n/**\n * Context for container-level grid configuration.\n * Provided by the Container component and consumed by Row children\n * to inherit columns, gap, gutter, and other grid settings.\n */\nexport default createContext<ContextType>({})\n","import { createContext } from '@pyreon/core'\nimport type { Context as ContextType } from '../types'\n\n/**\n * Context for row-level grid configuration.\n * Provided by the Row component and consumed by Col children\n * to inherit columns, gap, gutter, and sizing for width calculations.\n */\nexport default createContext<ContextType>({})\n","import { useContext } from '@pyreon/core'\nimport { get, pick } from '@pyreon/ui-core'\nimport { context } from '@pyreon/unistyle'\nimport { CONTEXT_KEYS } from './constants'\nimport type { Context, Obj, ValueType } from './types'\n\n/**\n * Picks only the recognized grid configuration keys from a props object,\n * filtering out any non-grid props before they enter context resolution.\n */\nexport type PickThemeProps = <T extends Record<string, unknown>>(\n props: T,\n keywords: Array<keyof T>,\n) => ReturnType<typeof pick>\nconst pickThemeProps: PickThemeProps = (props, keywords) => pick(props, keywords)\n\n/**\n * Resolves grid columns and container width using a three-layer fallback:\n * 1. Explicit component props (e.g. `columns={6}`)\n * 2. `theme.grid.columns` / `theme.grid.container`\n * 3. `theme.coolgrid.columns` / `theme.coolgrid.container`\n */\ntype GetGridContext = (\n props: Obj,\n theme: Obj,\n) => {\n columns?: ValueType\n containerWidth?: Record<string, number>\n}\n\nexport const getGridContext: GetGridContext = (props = {}, theme = {}) => ({\n columns: (get(props, 'columns') ||\n get(theme, 'grid.columns') ||\n get(theme, 'coolgrid.columns')) as ValueType,\n containerWidth: (get(props, 'width') ||\n get(theme, 'grid.container') ||\n get(theme, 'coolgrid.container')) as Record<string, number>,\n})\n\n/**\n * Hook that reads the unistyle theme context and merges it with the\n * component's own props to produce the final grid configuration.\n * Applies the three-layer resolution (props -> grid.* -> coolgrid.*).\n */\ntype UseGridContext = (props: Obj) => Context\nconst useGridContext: UseGridContext = (props) => {\n const getCtx = useContext(context)\n const { theme } = getCtx()\n const ctxProps = pickThemeProps(props, CONTEXT_KEYS)\n const gridContext = getGridContext(ctxProps, theme as Record<string, unknown>)\n\n return { ...gridContext, ...ctxProps }\n}\n\nexport default useGridContext\n","import { omit } from '@pyreon/ui-core'\nimport { CONTEXT_KEYS } from './constants'\n\n/** Checks whether a value is a finite number. */\nexport const isNumber = (value: unknown): value is number => Number.isFinite(value)\n\n/** Checks whether a value is a finite number greater than zero. */\nexport const hasValue = (value: unknown): boolean => isNumber(value) && value > 0\n\n/**\n * Determines if a column should be visible. A column is visible when its\n * size is undefined (auto) or a non-zero number. Size 0 hides the column.\n */\nexport const isVisible = (value: unknown): boolean =>\n (isNumber(value) && value !== 0) || value === undefined\n\n/** Returns true when both size and columns are positive numbers, indicating an explicit width can be calculated. */\ntype HasWidth = (size: unknown, columns: unknown) => boolean\nexport const hasWidth: HasWidth = (size, columns) => !!(hasValue(size) && hasValue(columns))\n\n/** Strips grid context keys from a props object so they are not forwarded to the DOM element. */\ntype OmitCtxKeys = (props?: Record<string, any>) => ReturnType<typeof omit>\nexport const omitCtxKeys: OmitCtxKeys = (props) => omit(props, CONTEXT_KEYS)\n","import { config } from '@pyreon/ui-core'\nimport type { MakeItResponsiveStyles } from '@pyreon/unistyle'\nimport { extendCss, makeItResponsive, value } from '@pyreon/unistyle'\nimport type { CssOutput, StyledTypes } from '../types'\nimport { hasValue, isNumber, isVisible } from '../utils'\n\nconst { styled, css, component } = config\n\ntype HasWidth = (size?: number, columns?: number) => boolean\n\n/** Returns true when both size and columns are valid, enabling explicit width calculation. */\nconst hasWidth: HasWidth = (size, columns) => hasValue(size) && hasValue(columns)\n\ntype WidthStyles = (\n props: Pick<StyledTypes, 'size' | 'columns' | 'gap'>,\n defaults: { rootSize?: number | undefined },\n) => CssOutput\n\n/**\n * Calculates column width as a percentage of total columns, subtracting\n * the gap when present. Uses `calc(%)` for web.\n */\nconst widthStyles: WidthStyles = ({ size, columns, gap }, { rootSize }) => {\n if (!hasWidth(size, columns)) {\n return ''\n }\n\n const s = size as number\n const c = columns as number\n const g = gap as number\n\n // calculate % of width\n const width = (s / c) * 100\n\n const hasGap = hasValue(gap)\n\n const val = hasGap ? `calc(${width}% - ${g}px)` : `${width}%`\n\n const v = value(val, rootSize)\n\n return css`\n flex-grow: 0;\n flex-shrink: 0;\n max-width: ${v};\n flex-basis: ${v};\n `\n}\n\ntype SpacingStyles = (type: 'margin' | 'padding', param?: number, rootSize?: number) => CssOutput\n/** Applies half of the given value as either margin or padding (used for gap and padding distribution). */\nconst spacingStyles: SpacingStyles = (type, param, rootSize) => {\n if (!isNumber(param)) {\n return ''\n }\n\n const finalStyle = `${type}: ${value((param as number) / 2, rootSize)}`\n\n return css`\n ${finalStyle};\n `\n}\n\n/**\n * Main responsive style block for Col. When the column is visible, applies\n * width, padding, margin, and extra CSS. When hidden (size === 0), moves\n * the element off-screen with fixed positioning.\n */\nconst styles: MakeItResponsiveStyles<StyledTypes> = ({ theme, css: cssFn, rootSize }) => {\n const { size, columns, gap, padding, extraStyles } = theme\n const renderStyles = isVisible(size)\n\n if (renderStyles) {\n return cssFn`\n left: initial;\n position: relative;\n ${widthStyles({ size, columns, gap }, { rootSize })};\n ${spacingStyles('padding', padding, rootSize)};\n ${spacingStyles('margin', gap, rootSize)};\n ${extendCss(extraStyles)};\n `\n }\n\n return cssFn`\n left: -9999px;\n position: fixed;\n margin: 0;\n padding: 0;\n `\n}\n\nexport default styled(component)`\n box-sizing: border-box;\n justify-content: stretch;\n\n position: relative;\n display: flex;\n flex-basis: 0;\n flex-grow: 1;\n flex-direction: column;\n\n ${makeItResponsive({\n key: '$coolgrid',\n styles,\n css,\n normalize: true,\n })};\n`\n","import { splitProps, useContext } from '@pyreon/core'\nimport { PKG_NAME } from '../constants'\nimport { RowContext } from '../context'\nimport type { ElementType } from '../types'\nimport useGridContext from '../useContext'\nimport { omitCtxKeys } from '../utils'\nimport Styled from './styled'\n\n/**\n * Col (column) component that reads grid settings from RowContext\n * (columns, gap, gutter) and calculates its own width as a fraction\n * of the total columns. Supports responsive size, padding, and visibility.\n */\n\nconst DEV_PROPS: Record<string, string> =\n process.env.NODE_ENV !== 'production' ? { 'data-coolgrid': 'col' } : {}\n\nconst Component: ElementType<\n [\n 'containerWidth',\n 'width',\n 'rowComponent',\n 'rowCss',\n 'colCss',\n 'colComponent',\n 'columns',\n 'gap',\n 'gutter',\n 'contentAlignX',\n ]\n> = (props) => {\n const [own, rest] = splitProps(props, ['children', 'component', 'css'])\n const parentCtx = useContext(RowContext)\n const { colCss, colComponent, columns, gap, size, padding } = useGridContext({\n ...parentCtx,\n ...rest,\n })\n\n const finalProps = {\n $coolgrid: {\n columns,\n gap,\n size,\n padding,\n extraStyles: own.css ?? colCss,\n },\n }\n\n return (\n <Styled {...omitCtxKeys(rest)} as={own.component ?? colComponent} {...finalProps} {...DEV_PROPS}>\n {own.children}\n </Styled>\n )\n}\n\nconst name = `${PKG_NAME}/Col`\n\nComponent.displayName = name\nComponent.pkgName = PKG_NAME\nComponent.PYREON__COMPONENT = name\n\nexport default Component\n","import component from './component'\n\nexport default component\n","import { config } from '@pyreon/ui-core'\nimport type { MakeItResponsiveStyles } from '@pyreon/unistyle'\nimport { extendCss, makeItResponsive, value } from '@pyreon/unistyle'\nimport type { StyledTypes } from '../types'\n\nconst { styled, css, component } = config\n\n/** Responsive styles that apply the container's max-width and any extra CSS at each breakpoint. */\nconst styles: MakeItResponsiveStyles<Pick<StyledTypes, 'width' | 'extraStyles'>> = ({\n theme: t,\n css: cssFn,\n rootSize,\n}) => {\n const w = t.width != null && typeof t.width !== 'object' ? t.width : null\n\n return cssFn`\n ${w != null ? `max-width: ${value(w, rootSize)};` : ''};\n ${extendCss(t.extraStyles)};\n `\n}\n\n/** Styled Container element. Centered via auto margins with responsive max-width. */\nexport default styled(component)`\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n width: 100%;\n margin-right: auto;\n margin-left: auto;\n\n ${makeItResponsive({\n key: '$coolgrid',\n styles,\n css,\n normalize: true,\n })};\n`\n","import { provide, splitProps } from '@pyreon/core'\nimport { PKG_NAME } from '../constants'\nimport ContainerContext from '../context/ContainerContext'\nimport type { ElementType } from '../types'\nimport useGridContext from '../useContext'\nimport { omitCtxKeys } from '../utils'\nimport Styled from './styled'\n\n/**\n * Container component that establishes the outermost grid boundary.\n * Resolves grid config from the theme, provides it to descendant Row/Col\n * components via ContainerContext, and renders a styled wrapper with\n * responsive max-width.\n */\n\nconst DEV_PROPS: Record<string, string> =\n process.env.NODE_ENV !== 'production' ? { 'data-coolgrid': 'container' } : {}\n\nconst Component: ElementType<['containerWidth']> = (props) => {\n const [own, rest] = splitProps(props, ['children', 'component', 'css', 'width'])\n const {\n containerWidth,\n columns,\n size,\n gap,\n padding,\n gutter,\n colCss,\n colComponent,\n rowCss,\n rowComponent,\n contentAlignX,\n } = useGridContext(rest)\n\n const context = {\n columns,\n size,\n gap,\n padding,\n gutter,\n colCss,\n colComponent,\n rowCss,\n rowComponent,\n contentAlignX,\n }\n\n const finalWidth = (() => {\n if (!own.width) return containerWidth\n if (typeof own.width === 'function') return own.width(containerWidth as Record<string, any>)\n return own.width\n })()\n\n const finalProps = {\n $coolgrid: {\n width: finalWidth,\n extraStyles: own.css,\n },\n }\n\n // Provide container context to descendant Row/Col components\n provide(ContainerContext, context)\n\n return (\n <Styled {...omitCtxKeys(rest)} as={own.component} {...finalProps} {...DEV_PROPS}>\n {own.children}\n </Styled>\n )\n}\n\nconst name = `${PKG_NAME}/Container`\n\nComponent.displayName = name\nComponent.pkgName = PKG_NAME\nComponent.PYREON__COMPONENT = name\n\nexport default Component\n","import component from './component'\n\nexport default component\n","import { config } from '@pyreon/ui-core'\nimport type { MakeItResponsiveStyles } from '@pyreon/unistyle'\nimport { ALIGN_CONTENT_MAP_X, extendCss, makeItResponsive, value } from '@pyreon/unistyle'\nimport type { CssOutput, StyledTypes } from '../types'\nimport { isNumber } from '../utils'\n\nconst { styled, css, component } = config\n\n/**\n * Computes negative horizontal margins to compensate for column gap,\n * and vertical margins that account for gutter (inter-row spacing).\n * This creates the classic grid pattern where column gaps cancel out\n * at the row edges.\n */\ntype SpacingStyles = (\n props: Pick<StyledTypes, 'gap' | 'gutter'>,\n { rootSize }: { rootSize?: number | undefined },\n) => CssOutput\n\nconst spacingStyles: SpacingStyles = ({ gap, gutter }, { rootSize }) => {\n if (!isNumber(gap)) return ''\n\n const g = gap as number\n const getValue = (param: string | number | null | undefined) => value(param, rootSize)\n\n const spacingX = (g / 2) * -1\n const spacingY = isNumber(gutter) ? (gutter as number) - g / 2 : g / 2\n\n return css`\n margin: ${getValue(spacingY)} ${getValue(spacingX)};\n `\n}\n\n/** Maps the contentAlignX prop to a CSS justify-content value. */\nconst contentAlign = (align?: StyledTypes['contentAlignX']) => {\n if (!align) return ''\n\n return css`\n justify-content: ${ALIGN_CONTENT_MAP_X[align]};\n `\n}\n\n/** Composes spacing, alignment, and extra CSS into a single responsive style block for the Row. */\nconst styles: MakeItResponsiveStyles<\n Pick<StyledTypes, 'gap' | 'gutter' | 'contentAlignX' | 'extraStyles'>\n> = ({ theme, css: cssFn, rootSize }) => {\n const { gap, gutter, contentAlignX, extraStyles } = theme\n\n return cssFn`\n ${spacingStyles({ gap, gutter }, { rootSize })};\n ${contentAlign(contentAlignX)};\n ${extendCss(extraStyles)};\n `\n}\n\nexport default styled(component)`\n box-sizing: border-box;\n\n display: flex;\n flex-wrap: wrap;\n align-self: stretch;\n flex-direction: row;\n\n ${makeItResponsive({\n key: '$coolgrid',\n styles,\n css,\n normalize: true,\n })};\n`\n","import { provide, splitProps, useContext } from '@pyreon/core'\nimport { PKG_NAME } from '../constants'\nimport { ContainerContext, RowContext } from '../context'\nimport type { ElementType } from '../types'\nimport useGridContext from '../useContext'\nimport { omitCtxKeys } from '../utils'\nimport Styled from './styled'\n\n/**\n * Row component that reads inherited config from ContainerContext, merges\n * it with its own props, and provides the resolved grid settings (columns,\n * gap, gutter) to Col children via RowContext. Renders a flex-wrap container\n * with negative margins to offset column gutters.\n */\n\nconst DEV_PROPS: Record<string, string> =\n process.env.NODE_ENV !== 'production' ? { 'data-coolgrid': 'row' } : {}\n\nconst Component: ElementType<['containerWidth', 'width', 'rowComponent', 'rowCss']> = (props) => {\n const [own, rest] = splitProps(props, ['children', 'component', 'css', 'contentAlignX'])\n const parentCtx = useContext(ContainerContext)\n\n const {\n columns,\n gap,\n gutter,\n rowComponent,\n rowCss,\n contentAlignX,\n containerWidth,\n size,\n padding,\n colCss,\n colComponent,\n } = useGridContext({ ...parentCtx, ...rest })\n\n const context = {\n containerWidth,\n size,\n padding,\n colCss,\n colComponent,\n columns,\n gap,\n gutter,\n }\n\n const finalProps = {\n $coolgrid: {\n contentAlignX: own.contentAlignX || contentAlignX,\n columns,\n gap,\n gutter,\n extraStyles: own.css || rowCss,\n },\n }\n\n // Provide row context to Col children\n provide(RowContext, context)\n\n return (\n <Styled {...omitCtxKeys(rest)} as={own.component || rowComponent} {...finalProps} {...DEV_PROPS}>\n {own.children}\n </Styled>\n )\n}\n\nconst name = `${PKG_NAME}/Row`\n\nComponent.displayName = name\nComponent.pkgName = PKG_NAME\nComponent.PYREON__COMPONENT = name\n\nexport default Component\n","import component from './component'\n\nexport default component\n","/**\n * Default Bootstrap-like grid configuration. Provides 5 breakpoints (xs-xl),\n * a 12-column grid, and responsive container max-widths matching Bootstrap 4.\n */\nexport default {\n rootSize: 16,\n breakpoints: {\n xs: 0,\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200,\n },\n grid: {\n columns: 12,\n container: {\n xs: '100%',\n sm: 540,\n md: 720,\n lg: 960,\n xl: 1140,\n },\n },\n} as const\n\nexport const defaultBreakpoints: Record<string, number> = {\n xs: 0,\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200,\n}\n\nexport const defaultContainerWidths: Record<string, string | number> = {\n xs: '100%',\n sm: 540,\n md: 720,\n lg: 960,\n xl: 1140,\n}\n"],"mappings":";;;;;;AAAA,MAAa,WAAW;;;;;AAMxB,MAAa,eAAe;CAG1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;;ACXD,+BAAe,cAA2B,EAAE,CAAC;;;;;;;;;ACA7C,yBAAe,cAA2B,EAAE,CAAC;;;;ACM7C,MAAM,kBAAkC,OAAO,aAAa,KAAK,OAAO,SAAS;AAgBjF,MAAa,kBAAkC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM;CACzE,SAAU,IAAI,OAAO,UAAU,IAC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;;ACEf,oBAAe;CACb,UAAU;CACV,aAAa;EACX,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACL;CACD,MAAM;EACJ,SAAS;EACT,WAAW;GACT,IAAI;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;GACL;EACF;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyreon/coolgrid",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "Responsive grid system for Pyreon",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -10,7 +10,6 @@
10
10
  },
11
11
  "files": [
12
12
  "lib",
13
- "!lib/**/*.map",
14
13
  "!lib/analysis",
15
14
  "README.md",
16
15
  "LICENSE",
@@ -41,15 +40,15 @@
41
40
  "typecheck": "tsc --noEmit"
42
41
  },
43
42
  "devDependencies": {
44
- "@pyreon/typescript": "^0.12.0",
43
+ "@pyreon/typescript": "^0.12.2",
45
44
  "@vitus-labs/tools-rolldown": "^1.15.3"
46
45
  },
47
46
  "peerDependencies": {
48
- "@pyreon/core": "^0.12.0",
49
- "@pyreon/reactivity": "^0.12.0",
50
- "@pyreon/styler": "^0.12.0",
51
- "@pyreon/ui-core": "^0.12.0",
52
- "@pyreon/unistyle": "^0.12.0"
47
+ "@pyreon/core": "^0.12.2",
48
+ "@pyreon/reactivity": "^0.12.2",
49
+ "@pyreon/styler": "^0.12.2",
50
+ "@pyreon/ui-core": "^0.12.2",
51
+ "@pyreon/unistyle": "^0.12.2"
53
52
  },
54
53
  "engines": {
55
54
  "node": ">= 22"
@@ -1,4 +1,4 @@
1
- import { useContext } from '@pyreon/core'
1
+ import { splitProps, useContext } from '@pyreon/core'
2
2
  import { PKG_NAME } from '../constants'
3
3
  import { RowContext } from '../context'
4
4
  import type { ElementType } from '../types'
@@ -28,11 +28,12 @@ const Component: ElementType<
28
28
  'gutter',
29
29
  'contentAlignX',
30
30
  ]
31
- > = ({ children, component, css, ...props }) => {
31
+ > = (props) => {
32
+ const [own, rest] = splitProps(props, ['children', 'component', 'css'])
32
33
  const parentCtx = useContext(RowContext)
33
34
  const { colCss, colComponent, columns, gap, size, padding } = useGridContext({
34
35
  ...parentCtx,
35
- ...props,
36
+ ...rest,
36
37
  })
37
38
 
38
39
  const finalProps = {
@@ -41,13 +42,13 @@ const Component: ElementType<
41
42
  gap,
42
43
  size,
43
44
  padding,
44
- extraStyles: css ?? colCss,
45
+ extraStyles: own.css ?? colCss,
45
46
  },
46
47
  }
47
48
 
48
49
  return (
49
- <Styled {...omitCtxKeys(props)} as={component ?? colComponent} {...finalProps} {...DEV_PROPS}>
50
- {children}
50
+ <Styled {...omitCtxKeys(rest)} as={own.component ?? colComponent} {...finalProps} {...DEV_PROPS}>
51
+ {own.children}
51
52
  </Styled>
52
53
  )
53
54
  }
@@ -1,4 +1,4 @@
1
- import { provide } from '@pyreon/core'
1
+ import { provide, splitProps } from '@pyreon/core'
2
2
  import { PKG_NAME } from '../constants'
3
3
  import ContainerContext from '../context/ContainerContext'
4
4
  import type { ElementType } from '../types'
@@ -16,13 +16,8 @@ import Styled from './styled'
16
16
  const DEV_PROPS: Record<string, string> =
17
17
  process.env.NODE_ENV !== 'production' ? { 'data-coolgrid': 'container' } : {}
18
18
 
19
- const Component: ElementType<['containerWidth']> = ({
20
- children,
21
- component,
22
- css,
23
- width,
24
- ...props
25
- }) => {
19
+ const Component: ElementType<['containerWidth']> = (props) => {
20
+ const [own, rest] = splitProps(props, ['children', 'component', 'css', 'width'])
26
21
  const {
27
22
  containerWidth,
28
23
  columns,
@@ -35,7 +30,7 @@ const Component: ElementType<['containerWidth']> = ({
35
30
  rowCss,
36
31
  rowComponent,
37
32
  contentAlignX,
38
- } = useGridContext(props)
33
+ } = useGridContext(rest)
39
34
 
40
35
  const context = {
41
36
  columns,
@@ -51,15 +46,15 @@ const Component: ElementType<['containerWidth']> = ({
51
46
  }
52
47
 
53
48
  const finalWidth = (() => {
54
- if (!width) return containerWidth
55
- if (typeof width === 'function') return width(containerWidth as Record<string, any>)
56
- return width
49
+ if (!own.width) return containerWidth
50
+ if (typeof own.width === 'function') return own.width(containerWidth as Record<string, any>)
51
+ return own.width
57
52
  })()
58
53
 
59
54
  const finalProps = {
60
55
  $coolgrid: {
61
56
  width: finalWidth,
62
- extraStyles: css,
57
+ extraStyles: own.css,
63
58
  },
64
59
  }
65
60
 
@@ -67,8 +62,8 @@ const Component: ElementType<['containerWidth']> = ({
67
62
  provide(ContainerContext, context)
68
63
 
69
64
  return (
70
- <Styled {...omitCtxKeys(props)} as={component} {...finalProps} {...DEV_PROPS}>
71
- {children}
65
+ <Styled {...omitCtxKeys(rest)} as={own.component} {...finalProps} {...DEV_PROPS}>
66
+ {own.children}
72
67
  </Styled>
73
68
  )
74
69
  }
@@ -1,4 +1,4 @@
1
- import { provide, useContext } from '@pyreon/core'
1
+ import { provide, splitProps, useContext } from '@pyreon/core'
2
2
  import { PKG_NAME } from '../constants'
3
3
  import { ContainerContext, RowContext } from '../context'
4
4
  import type { ElementType } from '../types'
@@ -16,13 +16,8 @@ import Styled from './styled'
16
16
  const DEV_PROPS: Record<string, string> =
17
17
  process.env.NODE_ENV !== 'production' ? { 'data-coolgrid': 'row' } : {}
18
18
 
19
- const Component: ElementType<['containerWidth', 'width', 'rowComponent', 'rowCss']> = ({
20
- children,
21
- component,
22
- css,
23
- contentAlignX: rowAlignX,
24
- ...props
25
- }) => {
19
+ const Component: ElementType<['containerWidth', 'width', 'rowComponent', 'rowCss']> = (props) => {
20
+ const [own, rest] = splitProps(props, ['children', 'component', 'css', 'contentAlignX'])
26
21
  const parentCtx = useContext(ContainerContext)
27
22
 
28
23
  const {
@@ -37,7 +32,7 @@ const Component: ElementType<['containerWidth', 'width', 'rowComponent', 'rowCss
37
32
  padding,
38
33
  colCss,
39
34
  colComponent,
40
- } = useGridContext({ ...parentCtx, ...props })
35
+ } = useGridContext({ ...parentCtx, ...rest })
41
36
 
42
37
  const context = {
43
38
  containerWidth,
@@ -52,11 +47,11 @@ const Component: ElementType<['containerWidth', 'width', 'rowComponent', 'rowCss
52
47
 
53
48
  const finalProps = {
54
49
  $coolgrid: {
55
- contentAlignX: rowAlignX || contentAlignX,
50
+ contentAlignX: own.contentAlignX || contentAlignX,
56
51
  columns,
57
52
  gap,
58
53
  gutter,
59
- extraStyles: css || rowCss,
54
+ extraStyles: own.css || rowCss,
60
55
  },
61
56
  }
62
57
 
@@ -64,8 +59,8 @@ const Component: ElementType<['containerWidth', 'width', 'rowComponent', 'rowCss
64
59
  provide(RowContext, context)
65
60
 
66
61
  return (
67
- <Styled {...omitCtxKeys(props)} as={component || rowComponent} {...finalProps} {...DEV_PROPS}>
68
- {children}
62
+ <Styled {...omitCtxKeys(rest)} as={own.component || rowComponent} {...finalProps} {...DEV_PROPS}>
63
+ {own.children}
69
64
  </Styled>
70
65
  )
71
66
  }