masua 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 (4) hide show
  1. package/LICENSE.md +21 -0
  2. package/index.ts +3 -1
  3. package/package.json +19 -15
  4. package/react.tsx +10 -14
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Matthias Giger, 2017 Spope
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/index.ts CHANGED
@@ -180,7 +180,9 @@ function layout(state: State) {
180
180
  child.style.transform = `translate3d(${Math.round(x)}px,${Math.round(y)}px,0)`
181
181
  child.style.position = 'absolute'
182
182
 
183
- state.columns[nextColumn] += (state.sizes[index] ?? 0) + (state.count > 1 ? state.gutterY : state.singleColumnGutter) // margin-bottom
183
+ if (state.columns[nextColumn]) {
184
+ state.columns[nextColumn] += (state.sizes[index] ?? 0) + (state.count > 1 ? state.gutterY : state.singleColumnGutter) // margin-bottom
185
+ }
184
186
  }
185
187
 
186
188
  state.container.style.height = `${(state.columns[getLongest(state)] ?? 0) - state.currentGutterY}px`
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.5",
4
+ "version": "0.11.6",
5
5
  "repository": "github:tobua/masua",
6
6
  "homepage": "https://tobua.github.io/masua",
7
7
  "license": "MIT",
@@ -10,16 +10,15 @@
10
10
  "Spope (minimasonry)"
11
11
  ],
12
12
  "scripts": {
13
- "format": "bun biome format . --write",
14
- "lint": "bun biome lint .",
13
+ "check": "biome check --write .",
15
14
  "types": "tsc"
16
15
  },
17
16
  "devDependencies": {
18
- "@biomejs/biome": "^1.7.1",
19
- "@types/bun": "^1.1.1",
20
- "@types/react": "^18.3.1",
21
- "typescript": "^5.4.5",
22
- "zero-configuration": "^0.6.0"
17
+ "@biomejs/biome": "^1.8.3",
18
+ "@types/bun": "^1.1.6",
19
+ "@types/react": "^18.3.3",
20
+ "typescript": "^5.5.3",
21
+ "zero-configuration": "^0.17.0"
23
22
  },
24
23
  "peerDependencies": {
25
24
  "react": ">= 18",
@@ -66,6 +65,18 @@
66
65
  "configuration": {
67
66
  "gitignore": "bundle",
68
67
  "vscode": "biome",
68
+ "license": {
69
+ "extends": "MIT",
70
+ "authors": [
71
+ {
72
+ "name": "Matthias Giger"
73
+ },
74
+ {
75
+ "name": "Spope",
76
+ "year": "2017"
77
+ }
78
+ ]
79
+ },
69
80
  "typescript": {
70
81
  "extends": "plugin",
71
82
  "compilerOptions": {
@@ -78,13 +89,6 @@
78
89
  },
79
90
  "biome": {
80
91
  "extends": "recommended",
81
- "linter": {
82
- "rules": {
83
- "nursery": {
84
- "all": true
85
- }
86
- }
87
- },
88
92
  "files": {
89
93
  "ignore": [
90
94
  "demo"
package/react.tsx CHANGED
@@ -1,6 +1,5 @@
1
- // biome-ignore lint/nursery/noUndeclaredDependencies: This is a reference to the local package.
2
1
  import { type Configuration, grid } from 'masua'
3
- import { type JSX, useEffect, useMemo, useRef } from 'react'
2
+ import { type JSX, useEffect, useRef } from 'react'
4
3
 
5
4
  interface ReactConfiguration extends Configuration {
6
5
  disabled: boolean
@@ -21,18 +20,15 @@ const configurationProperties = [
21
20
  export function Grid({ disabled = false, children, ...props }: JSX.IntrinsicElements['div'] & Partial<ReactConfiguration>) {
22
21
  const gridRef = useRef(null)
23
22
  const instance = useRef<ReturnType<typeof grid> | null>(null)
24
- const configurationProps = useMemo(
25
- () =>
26
- Object.entries(props).reduce((result: { [key: string]: string }, [key, value]) => {
27
- if (configurationProperties.includes(key)) {
28
- result[key] = value
29
- // @ts-ignore
30
- delete props[key]
31
- }
32
- return result
33
- }, {}),
34
- [props],
35
- )
23
+ // TODO props changes on every render, cannot be memoized, should do deep compare.
24
+ const configurationProps = Object.entries(props).reduce((result: { [key: string]: string }, [key, value]) => {
25
+ if (configurationProperties.includes(key)) {
26
+ result[key] = value
27
+ // @ts-ignore
28
+ delete props[key]
29
+ }
30
+ return result
31
+ }, {})
36
32
 
37
33
  useEffect(() => {
38
34
  if (disabled) {