@niche-works/style-layouts 0.2.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.ja.md +320 -0
- package/README.md +320 -0
- package/_virtual/_rolldown/runtime.cjs +29 -0
- package/balance/index.cjs +4 -0
- package/balance/index.d.cts +3 -0
- package/balance/index.d.mts +3 -0
- package/balance/index.mjs +4 -0
- package/center/index.cjs +4 -0
- package/center/index.d.cts +3 -0
- package/center/index.d.mts +3 -0
- package/center/index.mjs +4 -0
- package/constants.cjs +59 -0
- package/constants.d.cts +2 -0
- package/constants.d.mts +2 -0
- package/constants.mjs +3 -0
- package/core/_constants.cjs +94 -0
- package/core/_constants.d.cts +83 -0
- package/core/_constants.d.mts +83 -0
- package/core/_constants.mjs +86 -0
- package/core/_internal/applyChildCount.cjs +26 -0
- package/core/_internal/applyChildCount.d.cts +11 -0
- package/core/_internal/applyChildCount.d.mts +12 -0
- package/core/_internal/applyChildCount.mjs +24 -0
- package/core/_internal/applyChildRatio.cjs +22 -0
- package/core/_internal/applyChildRatio.d.cts +11 -0
- package/core/_internal/applyChildRatio.d.mts +12 -0
- package/core/_internal/applyChildRatio.mjs +20 -0
- package/core/_internal/applyChildSize.cjs +27 -0
- package/core/_internal/applyChildSize.d.cts +11 -0
- package/core/_internal/applyChildSize.d.mts +12 -0
- package/core/_internal/applyChildSize.mjs +25 -0
- package/core/_internal/applyGap.cjs +30 -0
- package/core/_internal/applyGap.d.cts +12 -0
- package/core/_internal/applyGap.d.mts +13 -0
- package/core/_internal/applyGap.mjs +28 -0
- package/core/_internal/hasValue.cjs +15 -0
- package/core/_internal/hasValue.d.cts +8 -0
- package/core/_internal/hasValue.d.mts +9 -0
- package/core/_internal/hasValue.mjs +14 -0
- package/core/_internal/mergeLayoutResults.cjs +18 -0
- package/core/_internal/mergeLayoutResults.d.cts +5 -0
- package/core/_internal/mergeLayoutResults.d.mts +6 -0
- package/core/_internal/mergeLayoutResults.mjs +16 -0
- package/core/_internal/unit.cjs +16 -0
- package/core/_internal/unit.d.cts +10 -0
- package/core/_internal/unit.d.mts +11 -0
- package/core/_internal/unit.mjs +15 -0
- package/core/_internal/warnIfUnsupported.cjs +15 -0
- package/core/_internal/warnIfUnsupported.d.cts +3 -0
- package/core/_internal/warnIfUnsupported.d.mts +4 -0
- package/core/_internal/warnIfUnsupported.mjs +14 -0
- package/core/_styles.scss.cjs +1 -0
- package/core/_styles.scss.d.cts +1 -0
- package/core/_styles.scss.d.mts +1 -0
- package/core/_styles.scss.mjs +3 -0
- package/core/_types.cjs +0 -0
- package/core/_types.d.cts +123 -0
- package/core/_types.d.mts +123 -0
- package/core/_types.mjs +1 -0
- package/core/balance/balance.cjs +35 -0
- package/core/balance/balance.d.cts +11 -0
- package/core/balance/balance.d.mts +12 -0
- package/core/balance/balance.mjs +32 -0
- package/core/balance/index.cjs +3 -0
- package/core/balance/index.d.cts +3 -0
- package/core/balance/index.d.mts +3 -0
- package/core/balance/index.mjs +3 -0
- package/core/balance/styles.css +113 -0
- package/core/balance/types.cjs +0 -0
- package/core/balance/types.d.cts +21 -0
- package/core/balance/types.d.mts +21 -0
- package/core/balance/types.mjs +1 -0
- package/core/center/center.cjs +31 -0
- package/core/center/center.d.cts +11 -0
- package/core/center/center.d.mts +12 -0
- package/core/center/center.mjs +28 -0
- package/core/center/index.cjs +3 -0
- package/core/center/index.d.cts +3 -0
- package/core/center/index.d.mts +3 -0
- package/core/center/index.mjs +3 -0
- package/core/center/styles.css +166 -0
- package/core/center/types.cjs +0 -0
- package/core/center/types.d.cts +9 -0
- package/core/center/types.d.mts +9 -0
- package/core/center/types.mjs +1 -0
- package/core/constants.cjs +362 -0
- package/core/constants.d.cts +316 -0
- package/core/constants.d.mts +316 -0
- package/core/constants.mjs +305 -0
- package/core/flow/flow.cjs +71 -0
- package/core/flow/flow.d.cts +12 -0
- package/core/flow/flow.d.mts +13 -0
- package/core/flow/flow.mjs +68 -0
- package/core/flow/index.cjs +3 -0
- package/core/flow/index.d.cts +3 -0
- package/core/flow/index.d.mts +3 -0
- package/core/flow/index.mjs +3 -0
- package/core/flow/styles.css +166 -0
- package/core/flow/types.cjs +0 -0
- package/core/flow/types.d.cts +21 -0
- package/core/flow/types.d.mts +21 -0
- package/core/flow/types.mjs +1 -0
- package/core/index.cjs +20 -0
- package/core/index.d.cts +20 -0
- package/core/index.d.mts +20 -0
- package/core/index.mjs +11 -0
- package/core/layer/index.cjs +3 -0
- package/core/layer/index.d.cts +3 -0
- package/core/layer/index.d.mts +3 -0
- package/core/layer/index.mjs +3 -0
- package/core/layer/layer.cjs +34 -0
- package/core/layer/layer.d.cts +13 -0
- package/core/layer/layer.d.mts +14 -0
- package/core/layer/layer.mjs +31 -0
- package/core/layer/styles.css +64 -0
- package/core/layer/types.cjs +0 -0
- package/core/layer/types.d.cts +13 -0
- package/core/layer/types.d.mts +13 -0
- package/core/layer/types.mjs +1 -0
- package/core/matrix/index.cjs +3 -0
- package/core/matrix/index.d.cts +3 -0
- package/core/matrix/index.d.mts +3 -0
- package/core/matrix/index.mjs +3 -0
- package/core/matrix/matrix.cjs +110 -0
- package/core/matrix/matrix.d.cts +11 -0
- package/core/matrix/matrix.d.mts +12 -0
- package/core/matrix/matrix.mjs +107 -0
- package/core/matrix/styles.css +63 -0
- package/core/matrix/types.cjs +0 -0
- package/core/matrix/types.d.cts +46 -0
- package/core/matrix/types.d.mts +46 -0
- package/core/matrix/types.mjs +1 -0
- package/core/pack/index.cjs +3 -0
- package/core/pack/index.d.cts +3 -0
- package/core/pack/index.d.mts +3 -0
- package/core/pack/index.mjs +3 -0
- package/core/pack/pack.cjs +27 -0
- package/core/pack/pack.d.cts +11 -0
- package/core/pack/pack.d.mts +12 -0
- package/core/pack/pack.mjs +24 -0
- package/core/pack/styles.css +36 -0
- package/core/pack/types.cjs +0 -0
- package/core/pack/types.d.cts +6 -0
- package/core/pack/types.d.mts +6 -0
- package/core/pack/types.mjs +1 -0
- package/core/pin/index.cjs +3 -0
- package/core/pin/index.d.cts +3 -0
- package/core/pin/index.d.mts +3 -0
- package/core/pin/index.mjs +3 -0
- package/core/pin/pin.cjs +23 -0
- package/core/pin/pin.d.cts +11 -0
- package/core/pin/pin.d.mts +12 -0
- package/core/pin/pin.mjs +23 -0
- package/core/pin/styles.css +18 -0
- package/core/pin/types.cjs +0 -0
- package/core/pin/types.d.cts +6 -0
- package/core/pin/types.d.mts +6 -0
- package/core/pin/types.mjs +1 -0
- package/core/stack/index.cjs +3 -0
- package/core/stack/index.d.cts +3 -0
- package/core/stack/index.d.mts +3 -0
- package/core/stack/index.mjs +3 -0
- package/core/stack/stack.cjs +99 -0
- package/core/stack/stack.d.cts +11 -0
- package/core/stack/stack.d.mts +12 -0
- package/core/stack/stack.mjs +96 -0
- package/core/stack/styles.css +175 -0
- package/core/stack/types.cjs +0 -0
- package/core/stack/types.d.cts +21 -0
- package/core/stack/types.d.mts +21 -0
- package/core/stack/types.mjs +1 -0
- package/core/styles.css +917 -0
- package/core/tile/index.cjs +3 -0
- package/core/tile/index.d.cts +3 -0
- package/core/tile/index.d.mts +3 -0
- package/core/tile/index.mjs +3 -0
- package/core/tile/styles.css +108 -0
- package/core/tile/tile.cjs +86 -0
- package/core/tile/tile.d.cts +12 -0
- package/core/tile/tile.d.mts +13 -0
- package/core/tile/tile.mjs +83 -0
- package/core/tile/types.cjs +0 -0
- package/core/tile/types.d.cts +9 -0
- package/core/tile/types.d.mts +9 -0
- package/core/tile/types.mjs +1 -0
- package/core/types.cjs +0 -0
- package/core/types.d.cts +23 -0
- package/core/types.d.mts +23 -0
- package/core/types.mjs +1 -0
- package/flow/index.cjs +4 -0
- package/flow/index.d.cts +3 -0
- package/flow/index.d.mts +3 -0
- package/flow/index.mjs +4 -0
- package/index.cjs +20 -0
- package/index.d.cts +20 -0
- package/index.d.mts +20 -0
- package/index.mjs +11 -0
- package/layer/index.cjs +4 -0
- package/layer/index.d.cts +3 -0
- package/layer/index.d.mts +3 -0
- package/layer/index.mjs +4 -0
- package/matrix/index.cjs +4 -0
- package/matrix/index.d.cts +3 -0
- package/matrix/index.d.mts +3 -0
- package/matrix/index.mjs +4 -0
- package/pack/index.cjs +4 -0
- package/pack/index.d.cts +3 -0
- package/pack/index.d.mts +3 -0
- package/pack/index.mjs +4 -0
- package/package.json +51 -0
- package/pin/index.cjs +4 -0
- package/pin/index.d.cts +3 -0
- package/pin/index.d.mts +3 -0
- package/pin/index.mjs +4 -0
- package/stack/index.cjs +4 -0
- package/stack/index.d.cts +3 -0
- package/stack/index.d.mts +3 -0
- package/stack/index.mjs +4 -0
- package/tile/index.cjs +4 -0
- package/tile/index.d.cts +3 -0
- package/tile/index.d.mts +3 -0
- package/tile/index.mjs +4 -0
- package/types.cjs +0 -0
- package/types.d.cts +2 -0
- package/types.d.mts +2 -0
- package/types.mjs +1 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StyleLayoutResult } from "../types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/_internal/applyChildSize.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* 子要素のサイズに関する設定の適用
|
|
6
|
+
* @param result
|
|
7
|
+
* @param childSizeX
|
|
8
|
+
* @param childSizeY
|
|
9
|
+
*/
|
|
10
|
+
declare function applyChildSize(result: StyleLayoutResult, childSizeX: number | null | undefined, childSizeY: number | null | undefined): void;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { applyChildSize as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { clsLayoutChildSizeX, clsLayoutChildSizeY, varLayoutChildSizeX, varLayoutChildSizeY } from "../constants.mjs";
|
|
2
|
+
import hasValue from "./hasValue.mjs";
|
|
3
|
+
import unit from "./unit.mjs";
|
|
4
|
+
import clsx from "clsx";
|
|
5
|
+
|
|
6
|
+
//#region src/core/_internal/applyChildSize.ts
|
|
7
|
+
/**
|
|
8
|
+
* 子要素のサイズに関する設定の適用
|
|
9
|
+
* @param result
|
|
10
|
+
* @param childSizeX
|
|
11
|
+
* @param childSizeY
|
|
12
|
+
*/
|
|
13
|
+
function applyChildSize(result, childSizeX, childSizeY) {
|
|
14
|
+
if (hasValue(childSizeX)) {
|
|
15
|
+
result.className = clsx(result.className, clsLayoutChildSizeX);
|
|
16
|
+
result.style[varLayoutChildSizeX] = unit(childSizeX);
|
|
17
|
+
}
|
|
18
|
+
if (hasValue(childSizeY)) {
|
|
19
|
+
result.className = clsx(result.className, clsLayoutChildSizeY);
|
|
20
|
+
result.style[varLayoutChildSizeY] = unit(childSizeY);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { applyChildSize as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_core_constants = require('../constants.cjs');
|
|
3
|
+
const require_core__internal_hasValue = require('./hasValue.cjs');
|
|
4
|
+
const require_core__internal_unit = require('./unit.cjs');
|
|
5
|
+
let clsx = require("clsx");
|
|
6
|
+
clsx = require_runtime.__toESM(clsx, 1);
|
|
7
|
+
|
|
8
|
+
//#region src/core/_internal/applyGap.ts
|
|
9
|
+
/**
|
|
10
|
+
* スペーシングに関する設定の適用
|
|
11
|
+
* @param result
|
|
12
|
+
* @param gap
|
|
13
|
+
* @param gapX
|
|
14
|
+
* @param gapY
|
|
15
|
+
*/
|
|
16
|
+
function applyGap(result, gap, gapX, gapY) {
|
|
17
|
+
gapX = gapX ?? gap;
|
|
18
|
+
if (require_core__internal_hasValue(gapX)) {
|
|
19
|
+
result.className = (0, clsx.default)(result.className, require_core_constants.clsLayoutGapX);
|
|
20
|
+
result.style[require_core_constants.varLayoutGapX] = require_core__internal_unit(gapX);
|
|
21
|
+
}
|
|
22
|
+
gapY = gapY ?? gap;
|
|
23
|
+
if (require_core__internal_hasValue(gapY)) {
|
|
24
|
+
result.className = (0, clsx.default)(result.className, require_core_constants.clsLayoutGapY);
|
|
25
|
+
result.style[require_core_constants.varLayoutGapY] = require_core__internal_unit(gapY);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
module.exports = applyGap;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StyleLayoutResult } from "../types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/_internal/applyGap.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* スペーシングに関する設定の適用
|
|
6
|
+
* @param result
|
|
7
|
+
* @param gap
|
|
8
|
+
* @param gapX
|
|
9
|
+
* @param gapY
|
|
10
|
+
*/
|
|
11
|
+
declare function applyGap(result: StyleLayoutResult, gap: number | null | undefined, gapX: number | null | undefined, gapY: number | null | undefined): void;
|
|
12
|
+
export = applyGap;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StyleLayoutResult } from "../types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/_internal/applyGap.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* スペーシングに関する設定の適用
|
|
6
|
+
* @param result
|
|
7
|
+
* @param gap
|
|
8
|
+
* @param gapX
|
|
9
|
+
* @param gapY
|
|
10
|
+
*/
|
|
11
|
+
declare function applyGap(result: StyleLayoutResult, gap: number | null | undefined, gapX: number | null | undefined, gapY: number | null | undefined): void;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { applyGap as default };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { clsLayoutGapX, clsLayoutGapY, varLayoutGapX, varLayoutGapY } from "../constants.mjs";
|
|
2
|
+
import hasValue from "./hasValue.mjs";
|
|
3
|
+
import unit from "./unit.mjs";
|
|
4
|
+
import clsx from "clsx";
|
|
5
|
+
|
|
6
|
+
//#region src/core/_internal/applyGap.ts
|
|
7
|
+
/**
|
|
8
|
+
* スペーシングに関する設定の適用
|
|
9
|
+
* @param result
|
|
10
|
+
* @param gap
|
|
11
|
+
* @param gapX
|
|
12
|
+
* @param gapY
|
|
13
|
+
*/
|
|
14
|
+
function applyGap(result, gap, gapX, gapY) {
|
|
15
|
+
gapX = gapX ?? gap;
|
|
16
|
+
if (hasValue(gapX)) {
|
|
17
|
+
result.className = clsx(result.className, clsLayoutGapX);
|
|
18
|
+
result.style[varLayoutGapX] = unit(gapX);
|
|
19
|
+
}
|
|
20
|
+
gapY = gapY ?? gap;
|
|
21
|
+
if (hasValue(gapY)) {
|
|
22
|
+
result.className = clsx(result.className, clsLayoutGapY);
|
|
23
|
+
result.style[varLayoutGapY] = unit(gapY);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { applyGap as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/core/_internal/hasValue.ts
|
|
3
|
+
/**
|
|
4
|
+
* 有効な値か
|
|
5
|
+
* @param value
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
function hasValue(value) {
|
|
9
|
+
if (typeof value === "number") return true;
|
|
10
|
+
else if (typeof value === "boolean") return true;
|
|
11
|
+
else return value !== null && value !== void 0 && value !== "";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
module.exports = hasValue;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/core/_internal/hasValue.ts
|
|
2
|
+
/**
|
|
3
|
+
* 有効な値か
|
|
4
|
+
* @param value
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
function hasValue(value) {
|
|
8
|
+
if (typeof value === "number") return true;
|
|
9
|
+
else if (typeof value === "boolean") return true;
|
|
10
|
+
else return value !== null && value !== void 0 && value !== "";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { hasValue as default };
|
|
@@ -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/core/_internal/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/core/_internal/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/core/_internal/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/core/_internal/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/core/_internal/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 };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/core/_internal/warnIfUnsupported.ts
|
|
3
|
+
const _checkCSSSupport = (property, value) => {
|
|
4
|
+
if (typeof CSS === "undefined" || !CSS.supports) return true;
|
|
5
|
+
return CSS.supports(property, value);
|
|
6
|
+
};
|
|
7
|
+
function warnIfUnsupported(layout, checks) {
|
|
8
|
+
if (process.env.NODE_ENV === "production") return;
|
|
9
|
+
checks.forEach(([property, value]) => {
|
|
10
|
+
if (!_checkCSSSupport(property, value)) console.warn(`[@niche-works/style-layouts] "${property}: ${value}" is not supported in this browser. The "${layout}" layout may not work as expected.`);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
module.exports = warnIfUnsupported;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/core/_internal/warnIfUnsupported.ts
|
|
2
|
+
const _checkCSSSupport = (property, value) => {
|
|
3
|
+
if (typeof CSS === "undefined" || !CSS.supports) return true;
|
|
4
|
+
return CSS.supports(property, value);
|
|
5
|
+
};
|
|
6
|
+
function warnIfUnsupported(layout, checks) {
|
|
7
|
+
if (process.env.NODE_ENV === "production") return;
|
|
8
|
+
checks.forEach(([property, value]) => {
|
|
9
|
+
if (!_checkCSSSupport(property, value)) console.warn(`[@niche-works/style-layouts] "${property}: ${value}" is not supported in this browser. The "${layout}" layout may not work as expected.`);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { warnIfUnsupported as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('./styles.css');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/core/_types.cjs
ADDED
|
File without changes
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Adjust, AlignX, AlignY, Direction } from "./constants.cjs";
|
|
2
|
+
import CSS from "csstype";
|
|
3
|
+
|
|
4
|
+
//#region src/core/_types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* CSSカスタムプロパティ(変数)
|
|
7
|
+
*/
|
|
8
|
+
type CSSCustomProperties = {
|
|
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 | null;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 子要素の位置
|
|
23
|
+
*/
|
|
24
|
+
type AlignOptions = {
|
|
25
|
+
/**
|
|
26
|
+
* 子要素の横位置
|
|
27
|
+
*/
|
|
28
|
+
alignX?: AlignX | null;
|
|
29
|
+
/**
|
|
30
|
+
* 子要素の縦位置
|
|
31
|
+
*/
|
|
32
|
+
alignY?: AlignY | null;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 子要素のサイズ調整
|
|
36
|
+
*/
|
|
37
|
+
type AdjustOptions = {
|
|
38
|
+
/**
|
|
39
|
+
* 子要素の幅の調整
|
|
40
|
+
* childSizeXを指定した場合に有効
|
|
41
|
+
* デフォルトは`none`
|
|
42
|
+
*/
|
|
43
|
+
adjustX?: Adjust | null;
|
|
44
|
+
/**
|
|
45
|
+
* 子要素の高さの調整
|
|
46
|
+
* childSizeYを指定した場合に有効
|
|
47
|
+
* デフォルトは`none`
|
|
48
|
+
*/
|
|
49
|
+
adjustY?: Adjust | null;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* 要素間の余白
|
|
53
|
+
*/
|
|
54
|
+
type GapOptions = {
|
|
55
|
+
/**
|
|
56
|
+
* 余白
|
|
57
|
+
*/
|
|
58
|
+
gap?: number | null;
|
|
59
|
+
/**
|
|
60
|
+
* 横方向の余白
|
|
61
|
+
*/
|
|
62
|
+
gapX?: number | null;
|
|
63
|
+
/**
|
|
64
|
+
* 縦方向の余白
|
|
65
|
+
*/
|
|
66
|
+
gapY?: number | null;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* 子要素のサイズ
|
|
70
|
+
*/
|
|
71
|
+
type ChildSizeOptions = {
|
|
72
|
+
/**
|
|
73
|
+
* 子要素の幅
|
|
74
|
+
*/
|
|
75
|
+
childSizeX?: number | null;
|
|
76
|
+
/**
|
|
77
|
+
* 子要素の高さ
|
|
78
|
+
*/
|
|
79
|
+
childSizeY?: number | null;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* 子要素のサイズの縦横比
|
|
83
|
+
*/
|
|
84
|
+
type ChildRatioOptions = {
|
|
85
|
+
/**
|
|
86
|
+
* 子要素の縦横比(横)
|
|
87
|
+
*/
|
|
88
|
+
childRatioX?: number;
|
|
89
|
+
/**
|
|
90
|
+
* 子要素の縦横比(縦)
|
|
91
|
+
*/
|
|
92
|
+
childRatioY?: number;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* 子要素の数
|
|
96
|
+
*/
|
|
97
|
+
type ChildCountOptions = {
|
|
98
|
+
/**
|
|
99
|
+
* 横方向の要素数
|
|
100
|
+
*/
|
|
101
|
+
childCountX?: number | null;
|
|
102
|
+
/**
|
|
103
|
+
* 縦方向の要素数
|
|
104
|
+
*/
|
|
105
|
+
childCountY?: number | null;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* 子要素のサイズと数
|
|
109
|
+
*/
|
|
110
|
+
type TracksOptions = {
|
|
111
|
+
/**
|
|
112
|
+
* 横方向の設定
|
|
113
|
+
* このプロパティが設定されている場合、childCountX,childSizeXは無効
|
|
114
|
+
*/
|
|
115
|
+
tracksX?: (string | number)[] | null;
|
|
116
|
+
/**
|
|
117
|
+
* 縦方向の設定
|
|
118
|
+
* このプロパティが設定されている場合、childCountY,childSizeYは無効
|
|
119
|
+
*/
|
|
120
|
+
tracksY?: (string | number)[] | null;
|
|
121
|
+
};
|
|
122
|
+
//#endregion
|
|
123
|
+
export { AdjustOptions, AlignOptions, CSSCustomProperties, CSSProperties, ChildCountOptions, ChildRatioOptions, ChildSizeOptions, DirectionOptions, GapOptions, TracksOptions };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Adjust, AlignX, AlignY, Direction } from "./constants.mjs";
|
|
2
|
+
import CSS from "csstype";
|
|
3
|
+
|
|
4
|
+
//#region src/core/_types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* CSSカスタムプロパティ(変数)
|
|
7
|
+
*/
|
|
8
|
+
type CSSCustomProperties = {
|
|
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 | null;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 子要素の位置
|
|
23
|
+
*/
|
|
24
|
+
type AlignOptions = {
|
|
25
|
+
/**
|
|
26
|
+
* 子要素の横位置
|
|
27
|
+
*/
|
|
28
|
+
alignX?: AlignX | null;
|
|
29
|
+
/**
|
|
30
|
+
* 子要素の縦位置
|
|
31
|
+
*/
|
|
32
|
+
alignY?: AlignY | null;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 子要素のサイズ調整
|
|
36
|
+
*/
|
|
37
|
+
type AdjustOptions = {
|
|
38
|
+
/**
|
|
39
|
+
* 子要素の幅の調整
|
|
40
|
+
* childSizeXを指定した場合に有効
|
|
41
|
+
* デフォルトは`none`
|
|
42
|
+
*/
|
|
43
|
+
adjustX?: Adjust | null;
|
|
44
|
+
/**
|
|
45
|
+
* 子要素の高さの調整
|
|
46
|
+
* childSizeYを指定した場合に有効
|
|
47
|
+
* デフォルトは`none`
|
|
48
|
+
*/
|
|
49
|
+
adjustY?: Adjust | null;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* 要素間の余白
|
|
53
|
+
*/
|
|
54
|
+
type GapOptions = {
|
|
55
|
+
/**
|
|
56
|
+
* 余白
|
|
57
|
+
*/
|
|
58
|
+
gap?: number | null;
|
|
59
|
+
/**
|
|
60
|
+
* 横方向の余白
|
|
61
|
+
*/
|
|
62
|
+
gapX?: number | null;
|
|
63
|
+
/**
|
|
64
|
+
* 縦方向の余白
|
|
65
|
+
*/
|
|
66
|
+
gapY?: number | null;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* 子要素のサイズ
|
|
70
|
+
*/
|
|
71
|
+
type ChildSizeOptions = {
|
|
72
|
+
/**
|
|
73
|
+
* 子要素の幅
|
|
74
|
+
*/
|
|
75
|
+
childSizeX?: number | null;
|
|
76
|
+
/**
|
|
77
|
+
* 子要素の高さ
|
|
78
|
+
*/
|
|
79
|
+
childSizeY?: number | null;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* 子要素のサイズの縦横比
|
|
83
|
+
*/
|
|
84
|
+
type ChildRatioOptions = {
|
|
85
|
+
/**
|
|
86
|
+
* 子要素の縦横比(横)
|
|
87
|
+
*/
|
|
88
|
+
childRatioX?: number;
|
|
89
|
+
/**
|
|
90
|
+
* 子要素の縦横比(縦)
|
|
91
|
+
*/
|
|
92
|
+
childRatioY?: number;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* 子要素の数
|
|
96
|
+
*/
|
|
97
|
+
type ChildCountOptions = {
|
|
98
|
+
/**
|
|
99
|
+
* 横方向の要素数
|
|
100
|
+
*/
|
|
101
|
+
childCountX?: number | null;
|
|
102
|
+
/**
|
|
103
|
+
* 縦方向の要素数
|
|
104
|
+
*/
|
|
105
|
+
childCountY?: number | null;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* 子要素のサイズと数
|
|
109
|
+
*/
|
|
110
|
+
type TracksOptions = {
|
|
111
|
+
/**
|
|
112
|
+
* 横方向の設定
|
|
113
|
+
* このプロパティが設定されている場合、childCountX,childSizeXは無効
|
|
114
|
+
*/
|
|
115
|
+
tracksX?: (string | number)[] | null;
|
|
116
|
+
/**
|
|
117
|
+
* 縦方向の設定
|
|
118
|
+
* このプロパティが設定されている場合、childCountY,childSizeYは無効
|
|
119
|
+
*/
|
|
120
|
+
tracksY?: (string | number)[] | null;
|
|
121
|
+
};
|
|
122
|
+
//#endregion
|
|
123
|
+
export { AdjustOptions, AlignOptions, CSSCustomProperties, CSSProperties, ChildCountOptions, ChildRatioOptions, ChildSizeOptions, DirectionOptions, GapOptions, TracksOptions };
|
package/core/_types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_core_constants = require('../constants.cjs');
|
|
3
|
+
const require_core__constants = require('../_constants.cjs');
|
|
4
|
+
const require_core__internal_applyChildRatio = require('../_internal/applyChildRatio.cjs');
|
|
5
|
+
const require_core__internal_applyChildSize = require('../_internal/applyChildSize.cjs');
|
|
6
|
+
const require_core__internal_applyGap = require('../_internal/applyGap.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/core/balance/balance.ts
|
|
13
|
+
/**
|
|
14
|
+
* balanceレイアウト
|
|
15
|
+
*
|
|
16
|
+
* - 子要素を均等に配置する
|
|
17
|
+
*/
|
|
18
|
+
const balance = (options = {}) => {
|
|
19
|
+
const { direction, alignX, alignY, adjustX, adjustY, gap, gapX, gapY, childSizeX, childSizeY, childRatioX, childRatioY } = (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_core_constants.clsLayoutBalance, require_core__constants.clsLayoutDirection[direction], require_core__constants.clsLayoutAlign.x[alignX], require_core__constants.clsLayoutAlign.y[alignY], require_core__constants.clsLayoutAdjust.x[adjustX], require_core__constants.clsLayoutAdjust.y[adjustY]),
|
|
26
|
+
style: {}
|
|
27
|
+
};
|
|
28
|
+
require_core__internal_applyGap(result, gap, gapX, gapY);
|
|
29
|
+
require_core__internal_applyChildSize(result, childSizeX, childSizeY);
|
|
30
|
+
require_core__internal_applyChildRatio(result, childRatioX, childRatioY);
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
module.exports = balance;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StyleLayout } from "../types.cjs";
|
|
2
|
+
import { BalanceLayoutOptions } from "./types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/core/balance/balance.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* balanceレイアウト
|
|
7
|
+
*
|
|
8
|
+
* - 子要素を均等に配置する
|
|
9
|
+
*/
|
|
10
|
+
declare const balance: StyleLayout<BalanceLayoutOptions>;
|
|
11
|
+
export = balance;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StyleLayout } from "../types.mjs";
|
|
2
|
+
import { BalanceLayoutOptions } from "./types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/core/balance/balance.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* balanceレイアウト
|
|
7
|
+
*
|
|
8
|
+
* - 子要素を均等に配置する
|
|
9
|
+
*/
|
|
10
|
+
declare const balance: StyleLayout<BalanceLayoutOptions>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { balance as default };
|