@niche-works/css-layouts 0.1.0
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/LICENSE +21 -0
- package/README.md +3 -0
- package/_constants.cjs +94 -0
- package/_constants.d.cts +83 -0
- package/_constants.d.mts +83 -0
- package/_constants.mjs +86 -0
- package/_helpers/applyChildCount.cjs +26 -0
- package/_helpers/applyChildCount.d.cts +12 -0
- package/_helpers/applyChildCount.d.mts +13 -0
- package/_helpers/applyChildCount.mjs +24 -0
- package/_helpers/applyChildSize.cjs +27 -0
- package/_helpers/applyChildSize.d.cts +12 -0
- package/_helpers/applyChildSize.d.mts +13 -0
- package/_helpers/applyChildSize.mjs +25 -0
- package/_helpers/applySpacing.cjs +30 -0
- package/_helpers/applySpacing.d.cts +13 -0
- package/_helpers/applySpacing.d.mts +14 -0
- package/_helpers/applySpacing.mjs +28 -0
- package/_helpers/hasValue.cjs +15 -0
- package/_helpers/hasValue.d.cts +8 -0
- package/_helpers/hasValue.d.mts +9 -0
- package/_helpers/hasValue.mjs +14 -0
- package/_helpers/mergeLayoutResults.cjs +18 -0
- package/_helpers/mergeLayoutResults.d.cts +5 -0
- package/_helpers/mergeLayoutResults.d.mts +6 -0
- package/_helpers/mergeLayoutResults.mjs +16 -0
- package/_helpers/unit.cjs +16 -0
- package/_helpers/unit.d.cts +10 -0
- package/_helpers/unit.d.mts +11 -0
- package/_helpers/unit.mjs +15 -0
- package/_types.cjs +0 -0
- package/_types.d.cts +118 -0
- package/_types.d.mts +118 -0
- package/_types.mjs +1 -0
- package/_virtual/_rolldown/runtime.cjs +29 -0
- package/balance/balance.cjs +34 -0
- package/balance/balance.d.cts +11 -0
- package/balance/balance.d.mts +12 -0
- package/balance/balance.mjs +31 -0
- package/balance/index.cjs +3 -0
- package/balance/index.d.cts +3 -0
- package/balance/index.d.mts +3 -0
- package/balance/index.mjs +3 -0
- package/balance/styles.css +109 -0
- package/balance/types.cjs +0 -0
- package/balance/types.d.cts +6 -0
- package/balance/types.d.mts +6 -0
- package/balance/types.mjs +1 -0
- package/constants.cjs +341 -0
- package/constants.d.cts +299 -0
- package/constants.d.mts +299 -0
- package/constants.mjs +288 -0
- package/flow/flow.cjs +70 -0
- package/flow/flow.d.cts +12 -0
- package/flow/flow.d.mts +13 -0
- package/flow/flow.mjs +67 -0
- package/flow/index.cjs +3 -0
- package/flow/index.d.cts +3 -0
- package/flow/index.d.mts +3 -0
- package/flow/index.mjs +3 -0
- package/flow/styles.css +162 -0
- package/flow/types.cjs +0 -0
- package/flow/types.d.cts +21 -0
- package/flow/types.d.mts +21 -0
- package/flow/types.mjs +1 -0
- package/index.cjs +23 -0
- package/index.d.cts +16 -0
- package/index.d.mts +16 -0
- package/index.mjs +16 -0
- package/matrix/index.cjs +3 -0
- package/matrix/index.d.cts +3 -0
- package/matrix/index.d.mts +3 -0
- package/matrix/index.mjs +3 -0
- package/matrix/matrix.cjs +109 -0
- package/matrix/matrix.d.cts +11 -0
- package/matrix/matrix.d.mts +12 -0
- package/matrix/matrix.mjs +106 -0
- package/matrix/styles.css +59 -0
- package/matrix/types.cjs +0 -0
- package/matrix/types.d.cts +46 -0
- package/matrix/types.d.mts +46 -0
- package/matrix/types.mjs +1 -0
- package/pack/index.cjs +3 -0
- package/pack/index.d.cts +3 -0
- package/pack/index.d.mts +3 -0
- package/pack/index.mjs +3 -0
- package/pack/pack.cjs +28 -0
- package/pack/pack.d.cts +11 -0
- package/pack/pack.d.mts +12 -0
- package/pack/pack.mjs +25 -0
- package/pack/styles.css +27 -0
- package/pack/types.cjs +0 -0
- package/pack/types.d.cts +6 -0
- package/pack/types.d.mts +6 -0
- package/pack/types.mjs +1 -0
- package/package.json +45 -0
- package/pin/index.cjs +3 -0
- package/pin/index.d.cts +3 -0
- package/pin/index.d.mts +3 -0
- package/pin/index.mjs +3 -0
- package/pin/pin.cjs +22 -0
- package/pin/pin.d.cts +11 -0
- package/pin/pin.d.mts +12 -0
- package/pin/pin.mjs +22 -0
- package/pin/styles.css +15 -0
- package/pin/types.cjs +0 -0
- package/pin/types.d.cts +6 -0
- package/pin/types.d.mts +6 -0
- package/pin/types.mjs +1 -0
- package/stack/index.cjs +3 -0
- package/stack/index.d.cts +3 -0
- package/stack/index.d.mts +3 -0
- package/stack/index.mjs +3 -0
- package/stack/stack.cjs +98 -0
- package/stack/stack.d.cts +11 -0
- package/stack/stack.d.mts +12 -0
- package/stack/stack.mjs +95 -0
- package/stack/styles.css +171 -0
- package/stack/types.cjs +0 -0
- package/stack/types.d.cts +21 -0
- package/stack/types.d.mts +21 -0
- package/stack/types.mjs +1 -0
- package/tile/index.cjs +3 -0
- package/tile/index.d.cts +3 -0
- package/tile/index.d.mts +3 -0
- package/tile/index.mjs +3 -0
- package/tile/styles.css +104 -0
- package/tile/tile.cjs +85 -0
- package/tile/tile.d.cts +12 -0
- package/tile/tile.d.mts +13 -0
- package/tile/tile.mjs +82 -0
- package/tile/types.cjs +0 -0
- package/tile/types.d.cts +9 -0
- package/tile/types.d.mts +9 -0
- package/tile/types.mjs +1 -0
- package/types.cjs +0 -0
- package/types.d.cts +23 -0
- package/types.d.mts +23 -0
- package/types.mjs +1 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
let clsx = require("clsx");
|
|
3
|
+
clsx = require_runtime.__toESM(clsx, 1);
|
|
4
|
+
|
|
5
|
+
//#region src/_helpers/mergeLayoutResults.ts
|
|
6
|
+
function mergeLayoutResults(results) {
|
|
7
|
+
return results.reduce((layoutResult, result) => {
|
|
8
|
+
if (result.className) layoutResult.className = (0, clsx.default)(layoutResult.className, result.className);
|
|
9
|
+
if (result.style) layoutResult.style = {
|
|
10
|
+
...layoutResult.style,
|
|
11
|
+
...result.style
|
|
12
|
+
};
|
|
13
|
+
return layoutResult;
|
|
14
|
+
}, {});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
module.exports = mergeLayoutResults;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
|
|
3
|
+
//#region src/_helpers/mergeLayoutResults.ts
|
|
4
|
+
function mergeLayoutResults(results) {
|
|
5
|
+
return results.reduce((layoutResult, result) => {
|
|
6
|
+
if (result.className) layoutResult.className = clsx(layoutResult.className, result.className);
|
|
7
|
+
if (result.style) layoutResult.style = {
|
|
8
|
+
...layoutResult.style,
|
|
9
|
+
...result.style
|
|
10
|
+
};
|
|
11
|
+
return layoutResult;
|
|
12
|
+
}, {});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { mergeLayoutResults as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/_helpers/unit.ts
|
|
3
|
+
/**
|
|
4
|
+
* valueが数値の場合、単位を付与して文字列に変換する
|
|
5
|
+
* それ以外はそのまま返す
|
|
6
|
+
* @param value
|
|
7
|
+
* @param unit
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
function unit(value, unit = "px") {
|
|
11
|
+
if (typeof value === "number") return `${value}${unit}`;
|
|
12
|
+
else return value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
module.exports = unit;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/_helpers/unit.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* valueが数値の場合、単位を付与して文字列に変換する
|
|
4
|
+
* それ以外はそのまま返す
|
|
5
|
+
* @param value
|
|
6
|
+
* @param unit
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
declare function unit(value: string | number | null | undefined, unit?: string): string;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { unit as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/_helpers/unit.ts
|
|
2
|
+
/**
|
|
3
|
+
* valueが数値の場合、単位を付与して文字列に変換する
|
|
4
|
+
* それ以外はそのまま返す
|
|
5
|
+
* @param value
|
|
6
|
+
* @param unit
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
function unit(value, unit = "px") {
|
|
10
|
+
if (typeof value === "number") return `${value}${unit}`;
|
|
11
|
+
else return value;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { unit as default };
|
package/_types.cjs
ADDED
|
File without changes
|
package/_types.d.cts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Adjust, AlignX, AlignY, Direction } from "./constants.cjs";
|
|
2
|
+
import CSS from "csstype";
|
|
3
|
+
|
|
4
|
+
//#region src/_types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* CSS変数を許容するCSSProperties
|
|
7
|
+
*/
|
|
8
|
+
type CSSPropertiesWithVars = CSSProperties & {
|
|
9
|
+
[key: `--${string}`]: string | number | undefined;
|
|
10
|
+
};
|
|
11
|
+
type CSSProperties = CSS.Properties<string | number>;
|
|
12
|
+
/**
|
|
13
|
+
* 子要素を並べる方向
|
|
14
|
+
*/
|
|
15
|
+
type DirectionOptions<D extends Direction = Direction> = {
|
|
16
|
+
/**
|
|
17
|
+
* 並べる方向
|
|
18
|
+
*/
|
|
19
|
+
direction?: D;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 子要素の位置
|
|
23
|
+
*/
|
|
24
|
+
type AlignOptions = {
|
|
25
|
+
/**
|
|
26
|
+
* 子要素の横位置
|
|
27
|
+
*/
|
|
28
|
+
alignX?: AlignX;
|
|
29
|
+
/**
|
|
30
|
+
* 子要素の縦位置
|
|
31
|
+
*/
|
|
32
|
+
alignY?: AlignY;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 子要素のサイズ調整
|
|
36
|
+
*/
|
|
37
|
+
type AdjustOptions = {
|
|
38
|
+
/**
|
|
39
|
+
* 子要素の幅の調整
|
|
40
|
+
* childSizeXを指定した場合に有効
|
|
41
|
+
* デフォルトは`none`
|
|
42
|
+
*/
|
|
43
|
+
adjustX?: Adjust;
|
|
44
|
+
/**
|
|
45
|
+
* 子要素の高さの調整
|
|
46
|
+
* childSizeYを指定した場合に有効
|
|
47
|
+
* デフォルトは`none`
|
|
48
|
+
*/
|
|
49
|
+
adjustY?: Adjust;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* 要素間の余白
|
|
53
|
+
*/
|
|
54
|
+
type SpacingOptions = {
|
|
55
|
+
/**
|
|
56
|
+
* 余白
|
|
57
|
+
*/
|
|
58
|
+
spacing?: ChildSpacing;
|
|
59
|
+
/**
|
|
60
|
+
* 横方向の余白
|
|
61
|
+
*/
|
|
62
|
+
spacingX?: ChildSpacing;
|
|
63
|
+
/**
|
|
64
|
+
* 縦方向の余白
|
|
65
|
+
*/
|
|
66
|
+
spacingY?: ChildSpacing;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* 子要素のサイズ
|
|
70
|
+
*/
|
|
71
|
+
type ChildSizeOptions = {
|
|
72
|
+
/**
|
|
73
|
+
* 子要素の幅
|
|
74
|
+
*/
|
|
75
|
+
childSizeX?: ChildSize;
|
|
76
|
+
/**
|
|
77
|
+
* 子要素の高さ
|
|
78
|
+
*/
|
|
79
|
+
childSizeY?: ChildSize;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* 子要素の数
|
|
83
|
+
*/
|
|
84
|
+
type ChildCountOptions = {
|
|
85
|
+
/**
|
|
86
|
+
* 横方向の要素数
|
|
87
|
+
*/
|
|
88
|
+
childCountX?: number;
|
|
89
|
+
/**
|
|
90
|
+
* 縦方向の要素数
|
|
91
|
+
*/
|
|
92
|
+
childCountY?: number;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* childのテンプレート
|
|
96
|
+
*/
|
|
97
|
+
type ChildOptions = {
|
|
98
|
+
/**
|
|
99
|
+
* 横方向の設定
|
|
100
|
+
* このプロパティが設定されている場合、childCountX,childSizeXは無効
|
|
101
|
+
*/
|
|
102
|
+
childX?: (string | number)[];
|
|
103
|
+
/**
|
|
104
|
+
* 縦方向の設定
|
|
105
|
+
* このプロパティが設定されている場合、childCountY,childSizeYは無効
|
|
106
|
+
*/
|
|
107
|
+
childY?: (string | number)[];
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* 子要素の高さ or 幅
|
|
111
|
+
*/
|
|
112
|
+
type ChildSize = CSSProperties['flexBasis'];
|
|
113
|
+
/**
|
|
114
|
+
* 余白
|
|
115
|
+
*/
|
|
116
|
+
type ChildSpacing = CSSProperties['gap'];
|
|
117
|
+
//#endregion
|
|
118
|
+
export { AdjustOptions, AlignOptions, CSSProperties, CSSPropertiesWithVars, ChildCountOptions, ChildOptions, ChildSize, ChildSizeOptions, ChildSpacing, DirectionOptions, SpacingOptions };
|
package/_types.d.mts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Adjust, AlignX, AlignY, Direction } from "./constants.mjs";
|
|
2
|
+
import CSS from "csstype";
|
|
3
|
+
|
|
4
|
+
//#region src/_types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* CSS変数を許容するCSSProperties
|
|
7
|
+
*/
|
|
8
|
+
type CSSPropertiesWithVars = CSSProperties & {
|
|
9
|
+
[key: `--${string}`]: string | number | undefined;
|
|
10
|
+
};
|
|
11
|
+
type CSSProperties = CSS.Properties<string | number>;
|
|
12
|
+
/**
|
|
13
|
+
* 子要素を並べる方向
|
|
14
|
+
*/
|
|
15
|
+
type DirectionOptions<D extends Direction = Direction> = {
|
|
16
|
+
/**
|
|
17
|
+
* 並べる方向
|
|
18
|
+
*/
|
|
19
|
+
direction?: D;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 子要素の位置
|
|
23
|
+
*/
|
|
24
|
+
type AlignOptions = {
|
|
25
|
+
/**
|
|
26
|
+
* 子要素の横位置
|
|
27
|
+
*/
|
|
28
|
+
alignX?: AlignX;
|
|
29
|
+
/**
|
|
30
|
+
* 子要素の縦位置
|
|
31
|
+
*/
|
|
32
|
+
alignY?: AlignY;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 子要素のサイズ調整
|
|
36
|
+
*/
|
|
37
|
+
type AdjustOptions = {
|
|
38
|
+
/**
|
|
39
|
+
* 子要素の幅の調整
|
|
40
|
+
* childSizeXを指定した場合に有効
|
|
41
|
+
* デフォルトは`none`
|
|
42
|
+
*/
|
|
43
|
+
adjustX?: Adjust;
|
|
44
|
+
/**
|
|
45
|
+
* 子要素の高さの調整
|
|
46
|
+
* childSizeYを指定した場合に有効
|
|
47
|
+
* デフォルトは`none`
|
|
48
|
+
*/
|
|
49
|
+
adjustY?: Adjust;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* 要素間の余白
|
|
53
|
+
*/
|
|
54
|
+
type SpacingOptions = {
|
|
55
|
+
/**
|
|
56
|
+
* 余白
|
|
57
|
+
*/
|
|
58
|
+
spacing?: ChildSpacing;
|
|
59
|
+
/**
|
|
60
|
+
* 横方向の余白
|
|
61
|
+
*/
|
|
62
|
+
spacingX?: ChildSpacing;
|
|
63
|
+
/**
|
|
64
|
+
* 縦方向の余白
|
|
65
|
+
*/
|
|
66
|
+
spacingY?: ChildSpacing;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* 子要素のサイズ
|
|
70
|
+
*/
|
|
71
|
+
type ChildSizeOptions = {
|
|
72
|
+
/**
|
|
73
|
+
* 子要素の幅
|
|
74
|
+
*/
|
|
75
|
+
childSizeX?: ChildSize;
|
|
76
|
+
/**
|
|
77
|
+
* 子要素の高さ
|
|
78
|
+
*/
|
|
79
|
+
childSizeY?: ChildSize;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* 子要素の数
|
|
83
|
+
*/
|
|
84
|
+
type ChildCountOptions = {
|
|
85
|
+
/**
|
|
86
|
+
* 横方向の要素数
|
|
87
|
+
*/
|
|
88
|
+
childCountX?: number;
|
|
89
|
+
/**
|
|
90
|
+
* 縦方向の要素数
|
|
91
|
+
*/
|
|
92
|
+
childCountY?: number;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* childのテンプレート
|
|
96
|
+
*/
|
|
97
|
+
type ChildOptions = {
|
|
98
|
+
/**
|
|
99
|
+
* 横方向の設定
|
|
100
|
+
* このプロパティが設定されている場合、childCountX,childSizeXは無効
|
|
101
|
+
*/
|
|
102
|
+
childX?: (string | number)[];
|
|
103
|
+
/**
|
|
104
|
+
* 縦方向の設定
|
|
105
|
+
* このプロパティが設定されている場合、childCountY,childSizeYは無効
|
|
106
|
+
*/
|
|
107
|
+
childY?: (string | number)[];
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* 子要素の高さ or 幅
|
|
111
|
+
*/
|
|
112
|
+
type ChildSize = CSSProperties['flexBasis'];
|
|
113
|
+
/**
|
|
114
|
+
* 余白
|
|
115
|
+
*/
|
|
116
|
+
type ChildSpacing = CSSProperties['gap'];
|
|
117
|
+
//#endregion
|
|
118
|
+
export { AdjustOptions, AlignOptions, CSSProperties, CSSPropertiesWithVars, ChildCountOptions, ChildOptions, ChildSize, ChildSizeOptions, ChildSpacing, DirectionOptions, SpacingOptions };
|
package/_types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_constants = require('../constants.cjs');
|
|
3
|
+
const require__constants = require('../_constants.cjs');
|
|
4
|
+
const require__helpers_applyChildSize = require('../_helpers/applyChildSize.cjs');
|
|
5
|
+
const require__helpers_applySpacing = require('../_helpers/applySpacing.cjs');
|
|
6
|
+
require('./styles.cjs');
|
|
7
|
+
let _niche_works_utils_object_maybeDefault = require("@niche-works/utils/object/maybeDefault");
|
|
8
|
+
_niche_works_utils_object_maybeDefault = require_runtime.__toESM(_niche_works_utils_object_maybeDefault, 1);
|
|
9
|
+
let clsx = require("clsx");
|
|
10
|
+
clsx = require_runtime.__toESM(clsx, 1);
|
|
11
|
+
|
|
12
|
+
//#region src/balance/balance.ts
|
|
13
|
+
/**
|
|
14
|
+
* balanceレイアウト
|
|
15
|
+
*
|
|
16
|
+
* - 子要素を均等に配置する
|
|
17
|
+
*/
|
|
18
|
+
const balance = (options = {}) => {
|
|
19
|
+
const { direction, alignX, alignY, adjustX, adjustY, spacing, spacingX, spacingY, childSizeX, childSizeY } = (0, _niche_works_utils_object_maybeDefault.default)(options, {
|
|
20
|
+
direction: "x",
|
|
21
|
+
alignX: "left",
|
|
22
|
+
alignY: "top"
|
|
23
|
+
}, { overwriteNull: true });
|
|
24
|
+
const result = {
|
|
25
|
+
className: (0, clsx.default)(require_constants.clsLayoutBalance, require__constants.clsLayoutDirection[direction], require__constants.clsLayoutAlign.x[alignX], require__constants.clsLayoutAlign.y[alignY], require__constants.clsLayoutAdjust.x[adjustX], require__constants.clsLayoutAdjust.y[adjustY]),
|
|
26
|
+
style: {}
|
|
27
|
+
};
|
|
28
|
+
require__helpers_applySpacing(result, spacing, spacingX, spacingY);
|
|
29
|
+
require__helpers_applyChildSize(result, childSizeX, childSizeY);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
module.exports = balance;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CreateLayout } from "../types.cjs";
|
|
2
|
+
import { BalanceLayoutOptions } from "./types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/balance/balance.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* balanceレイアウト
|
|
7
|
+
*
|
|
8
|
+
* - 子要素を均等に配置する
|
|
9
|
+
*/
|
|
10
|
+
declare const balance: CreateLayout<BalanceLayoutOptions>;
|
|
11
|
+
export = balance;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CreateLayout } from "../types.mjs";
|
|
2
|
+
import { BalanceLayoutOptions } from "./types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/balance/balance.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* balanceレイアウト
|
|
7
|
+
*
|
|
8
|
+
* - 子要素を均等に配置する
|
|
9
|
+
*/
|
|
10
|
+
declare const balance: CreateLayout<BalanceLayoutOptions>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { balance as default };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { clsLayoutBalance } from "../constants.mjs";
|
|
2
|
+
import { clsLayoutAdjust, clsLayoutAlign, clsLayoutDirection } from "../_constants.mjs";
|
|
3
|
+
import applyChildSize from "../_helpers/applyChildSize.mjs";
|
|
4
|
+
import applySpacing from "../_helpers/applySpacing.mjs";
|
|
5
|
+
import "./styles.css";
|
|
6
|
+
import maybeDefault from "@niche-works/utils/object/maybeDefault";
|
|
7
|
+
import clsx from "clsx";
|
|
8
|
+
|
|
9
|
+
//#region src/balance/balance.ts
|
|
10
|
+
/**
|
|
11
|
+
* balanceレイアウト
|
|
12
|
+
*
|
|
13
|
+
* - 子要素を均等に配置する
|
|
14
|
+
*/
|
|
15
|
+
const balance = (options = {}) => {
|
|
16
|
+
const { direction, alignX, alignY, adjustX, adjustY, spacing, spacingX, spacingY, childSizeX, childSizeY } = maybeDefault(options, {
|
|
17
|
+
direction: "x",
|
|
18
|
+
alignX: "left",
|
|
19
|
+
alignY: "top"
|
|
20
|
+
}, { overwriteNull: true });
|
|
21
|
+
const result = {
|
|
22
|
+
className: clsx(clsLayoutBalance, clsLayoutDirection[direction], clsLayoutAlign.x[alignX], clsLayoutAlign.y[alignY], clsLayoutAdjust.x[adjustX], clsLayoutAdjust.y[adjustY]),
|
|
23
|
+
style: {}
|
|
24
|
+
};
|
|
25
|
+
applySpacing(result, spacing, spacingX, spacingY);
|
|
26
|
+
applyChildSize(result, childSizeX, childSizeY);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { balance as default };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
.nws-layout-balance {
|
|
2
|
+
--nws-layout-spacingX: 0px;
|
|
3
|
+
--nws-layout-spacingY: 0px;
|
|
4
|
+
--nws-layout-childSizeX: auto;
|
|
5
|
+
--nws-layout-childSizeY: auto;
|
|
6
|
+
display: grid;
|
|
7
|
+
}
|
|
8
|
+
.nws-layout-balance.nws-layout-spacingX {
|
|
9
|
+
column-gap: var(--nws-layout-spacingX);
|
|
10
|
+
}
|
|
11
|
+
.nws-layout-balance.nws-layout-spacingY {
|
|
12
|
+
row-gap: var(--nws-layout-spacingY);
|
|
13
|
+
}
|
|
14
|
+
.nws-layout-balance.nws-layout-direction-x {
|
|
15
|
+
grid-auto-flow: column;
|
|
16
|
+
}
|
|
17
|
+
.nws-layout-balance.nws-layout-direction-y {
|
|
18
|
+
grid-auto-flow: row;
|
|
19
|
+
}
|
|
20
|
+
.nws-layout-balance.nws-layout-alignX-left {
|
|
21
|
+
justify-items: flex-start;
|
|
22
|
+
}
|
|
23
|
+
.nws-layout-balance.nws-layout-alignX-center {
|
|
24
|
+
justify-items: center;
|
|
25
|
+
}
|
|
26
|
+
.nws-layout-balance.nws-layout-alignX-right {
|
|
27
|
+
justify-items: flex-end;
|
|
28
|
+
}
|
|
29
|
+
.nws-layout-balance.nws-layout-alignX-spaceBetween {
|
|
30
|
+
justify-items: space-between;
|
|
31
|
+
}
|
|
32
|
+
.nws-layout-balance.nws-layout-alignX-spaceAround {
|
|
33
|
+
justify-items: space-around;
|
|
34
|
+
}
|
|
35
|
+
.nws-layout-balance.nws-layout-alignX-spaceEvenly {
|
|
36
|
+
justify-items: space-evenly;
|
|
37
|
+
}
|
|
38
|
+
.nws-layout-balance.nws-layout-alignY-top {
|
|
39
|
+
align-items: flex-start;
|
|
40
|
+
}
|
|
41
|
+
.nws-layout-balance.nws-layout-alignY-middle {
|
|
42
|
+
align-items: center;
|
|
43
|
+
}
|
|
44
|
+
.nws-layout-balance.nws-layout-alignY-bottom {
|
|
45
|
+
align-items: flex-end;
|
|
46
|
+
}
|
|
47
|
+
.nws-layout-balance.nws-layout-alignY-spaceBetween {
|
|
48
|
+
align-items: space-between;
|
|
49
|
+
}
|
|
50
|
+
.nws-layout-balance.nws-layout-alignY-spaceAround {
|
|
51
|
+
align-items: space-around;
|
|
52
|
+
}
|
|
53
|
+
.nws-layout-balance.nws-layout-alignY-spaceEvenly {
|
|
54
|
+
align-items: space-evenly;
|
|
55
|
+
}
|
|
56
|
+
.nws-layout-balance > * {
|
|
57
|
+
min-width: 0;
|
|
58
|
+
}
|
|
59
|
+
.nws-layout-balance.nws-layout-childSizeX > * {
|
|
60
|
+
width: var(--nws-layout-childSizeX);
|
|
61
|
+
}
|
|
62
|
+
.nws-layout-balance.nws-layout-adjustX-fit {
|
|
63
|
+
justify-items: stretch;
|
|
64
|
+
}
|
|
65
|
+
.nws-layout-balance.nws-layout-adjustX-fit > * {
|
|
66
|
+
width: auto;
|
|
67
|
+
}
|
|
68
|
+
.nws-layout-balance.nws-layout-adjustX-fit.nws-layout-childSizeX > * {
|
|
69
|
+
width: auto;
|
|
70
|
+
}
|
|
71
|
+
.nws-layout-balance.nws-layout-adjustX-grow > * {
|
|
72
|
+
width: 100%;
|
|
73
|
+
}
|
|
74
|
+
.nws-layout-balance.nws-layout-adjustX-grow.nws-layout-childSizeX > * {
|
|
75
|
+
min-width: var(--nws-layout-childSizeX);
|
|
76
|
+
}
|
|
77
|
+
.nws-layout-balance.nws-layout-adjustX-shrink > * {
|
|
78
|
+
width: 100%;
|
|
79
|
+
}
|
|
80
|
+
.nws-layout-balance.nws-layout-adjustX-shrink.nws-layout-childSizeX > * {
|
|
81
|
+
max-width: var(--nws-layout-childSizeX);
|
|
82
|
+
}
|
|
83
|
+
.nws-layout-balance > * {
|
|
84
|
+
min-height: 0;
|
|
85
|
+
}
|
|
86
|
+
.nws-layout-balance.nws-layout-childSizeY > * {
|
|
87
|
+
height: var(--nws-layout-childSizeY);
|
|
88
|
+
}
|
|
89
|
+
.nws-layout-balance.nws-layout-adjustY-fit {
|
|
90
|
+
align-items: stretch;
|
|
91
|
+
}
|
|
92
|
+
.nws-layout-balance.nws-layout-adjustY-fit > * {
|
|
93
|
+
height: auto;
|
|
94
|
+
}
|
|
95
|
+
.nws-layout-balance.nws-layout-adjustY-fit.nws-layout-childSizeY > * {
|
|
96
|
+
height: auto;
|
|
97
|
+
}
|
|
98
|
+
.nws-layout-balance.nws-layout-adjustY-grow > * {
|
|
99
|
+
height: 100%;
|
|
100
|
+
}
|
|
101
|
+
.nws-layout-balance.nws-layout-adjustY-grow.nws-layout-childSizeY > * {
|
|
102
|
+
min-height: var(--nws-layout-childSizeY);
|
|
103
|
+
}
|
|
104
|
+
.nws-layout-balance.nws-layout-adjustY-shrink > * {
|
|
105
|
+
height: 100%;
|
|
106
|
+
}
|
|
107
|
+
.nws-layout-balance.nws-layout-adjustY-shrink.nws-layout-childSizeY > * {
|
|
108
|
+
max-height: var(--nws-layout-childSizeY);
|
|
109
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AdjustOptions, AlignOptions, ChildSizeOptions, DirectionOptions, SpacingOptions } from "../_types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/balance/types.d.ts
|
|
4
|
+
type BalanceLayoutOptions = AdjustOptions & AlignOptions & ChildSizeOptions & DirectionOptions & SpacingOptions;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { BalanceLayoutOptions };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AdjustOptions, AlignOptions, ChildSizeOptions, DirectionOptions, SpacingOptions } from "../_types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/balance/types.d.ts
|
|
4
|
+
type BalanceLayoutOptions = AdjustOptions & AlignOptions & ChildSizeOptions & DirectionOptions & SpacingOptions;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { BalanceLayoutOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|