masua 0.11.4 → 0.11.5

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 (3) hide show
  1. package/README.md +1 -1
  2. package/index.ts +10 -8
  3. package/package.json +3 -6
package/README.md CHANGED
@@ -43,7 +43,7 @@ grid(document.querySelector('#my-custom-grid'), {
43
43
  import { Grid } from 'masua/react'
44
44
 
45
45
  const MyGrid = () => (
46
- <Grid disabled={window.innerWidth < 501}>
46
+ <Grid disabled={window.innerWidth < 501} gutter={50}>
47
47
  <Box />
48
48
  <Box size={3} />
49
49
  <Box size={2} />
package/index.ts CHANGED
@@ -21,7 +21,7 @@ interface State {
21
21
  }
22
22
 
23
23
  export interface Configuration {
24
- baseWidth: number
24
+ baseWidth: number | string
25
25
  gutter: number | string
26
26
  gutterX: number | string
27
27
  gutterY: number | string
@@ -33,6 +33,7 @@ export interface Configuration {
33
33
  }
34
34
 
35
35
  interface NumberConfiguration extends Configuration {
36
+ baseWidth: number
36
37
  gutter: number
37
38
  gutterX: number
38
39
  gutterY: number
@@ -52,7 +53,7 @@ function getCount(state: State) {
52
53
  function getLongest(state: State) {
53
54
  let longest = 0
54
55
  for (let index = 0; index < state.count; index += 1) {
55
- if (state.columns[index] > state.columns[longest]) {
56
+ if ((state.columns[index] ?? 0) > (state.columns[longest] ?? 1)) {
56
57
  longest = index
57
58
  }
58
59
  }
@@ -66,7 +67,7 @@ function getNextColumn(index: number, state: State) {
66
67
  function getShortest(state: State) {
67
68
  let shortest = 0
68
69
  for (let index = 0; index < state.count; index += 1) {
69
- if (state.columns[index] < state.columns[shortest]) {
70
+ if ((state.columns[index] ?? 1) < (state.columns[shortest] ?? 0)) {
70
71
  shortest = index
71
72
  }
72
73
  }
@@ -174,15 +175,15 @@ function layout(state: State) {
174
175
  } else {
175
176
  x = startX - (colWidth + childrenGutter) * nextColumn - colWidth
176
177
  }
177
- const y = state.columns[nextColumn]
178
+ const y = state.columns[nextColumn] ?? 0
178
179
  const child = children[index] as HTMLElement
179
180
  child.style.transform = `translate3d(${Math.round(x)}px,${Math.round(y)}px,0)`
180
181
  child.style.position = 'absolute'
181
182
 
182
- state.columns[nextColumn] += state.sizes[index] + (state.count > 1 ? state.gutterY : state.singleColumnGutter) // margin-bottom
183
+ state.columns[nextColumn] += (state.sizes[index] ?? 0) + (state.count > 1 ? state.gutterY : state.singleColumnGutter) // margin-bottom
183
184
  }
184
185
 
185
- state.container.style.height = `${state.columns[getLongest(state)] - state.currentGutterY}px`
186
+ state.container.style.height = `${(state.columns[getLongest(state)] ?? 0) - state.currentGutterY}px`
186
187
  }
187
188
 
188
189
  function resizeThrottler(state: State) {
@@ -257,13 +258,14 @@ function getSizeInPixels(size: string) {
257
258
  return pixels
258
259
  }
259
260
 
260
- const sizeValues: (keyof Configuration)[] = ['gutter', 'gutterX', 'gutterY', 'singleColumnGutter']
261
+ const sizeValues: (keyof Configuration)[] = ['baseWidth', 'gutter', 'gutterX', 'gutterY', 'singleColumnGutter']
261
262
 
262
263
  function convertStringSizesToPixels(configuration: Partial<Configuration>): Partial<NumberConfiguration> {
263
264
  for (const property of sizeValues) {
264
265
  const value = configuration[property]
265
266
  if (typeof value === 'string') {
266
- configuration.gutter = getSizeInPixels(value)
267
+ // @ts-ignore No idea what's the issue here.
268
+ configuration[property] = getSizeInPixels(value)
267
269
  }
268
270
  }
269
271
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "masua",
3
3
  "description": "Simple masonry layout library in TypeScript.",
4
- "version": "0.11.4",
4
+ "version": "0.11.5",
5
5
  "repository": "github:tobua/masua",
6
6
  "homepage": "https://tobua.github.io/masua",
7
7
  "license": "MIT",
@@ -16,10 +16,10 @@
16
16
  },
17
17
  "devDependencies": {
18
18
  "@biomejs/biome": "^1.7.1",
19
- "@types/bun": "^1.1.0",
19
+ "@types/bun": "^1.1.1",
20
20
  "@types/react": "^18.3.1",
21
21
  "typescript": "^5.4.5",
22
- "zero-configuration": "^0.5.5"
22
+ "zero-configuration": "^0.6.0"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": ">= 18",
@@ -63,9 +63,6 @@
63
63
  "publishConfig": {
64
64
  "provenance": true
65
65
  },
66
- "engines": {
67
- "node": ">= 18"
68
- },
69
66
  "configuration": {
70
67
  "gitignore": "bundle",
71
68
  "vscode": "biome",