@niche-works/style-layouts 0.3.0 → 0.4.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/README.ja.md +8 -8
- package/README.md +8 -8
- package/balance/index.cjs +6 -2
- package/balance/index.mjs +6 -2
- package/center/index.cjs +6 -2
- package/center/index.mjs +6 -2
- package/constants.cjs +1 -50
- package/constants.d.cts +2 -2
- package/constants.d.mts +2 -2
- package/constants.mjs +2 -2
- package/core/_constants.cjs +287 -34
- package/core/_constants.d.cts +206 -1
- package/core/_constants.d.mts +206 -1
- package/core/_constants.mjs +206 -3
- package/core/_internal/applyChildCount.cjs +6 -8
- package/core/_internal/applyChildCount.mjs +6 -6
- package/core/_internal/applyChildRatio.cjs +4 -6
- package/core/_internal/applyChildRatio.mjs +3 -3
- package/core/_internal/applyChildSize.cjs +6 -8
- package/core/_internal/applyChildSize.mjs +4 -4
- package/core/_internal/applyGap.cjs +6 -8
- package/core/_internal/applyGap.mjs +4 -4
- package/core/_internal/mergeClassName.cjs +11 -0
- package/core/_internal/mergeClassName.d.cts +3 -0
- package/core/_internal/mergeClassName.d.mts +4 -0
- package/core/_internal/mergeClassName.mjs +10 -0
- package/core/_internal/mergeLayoutResults.cjs +2 -4
- package/core/_internal/mergeLayoutResults.mjs +2 -2
- package/core/_types.d.cts +1 -9
- package/core/_types.d.mts +1 -9
- package/core/balance/balance.cjs +4 -4
- package/core/balance/balance.d.cts +2 -0
- package/core/balance/balance.d.mts +2 -0
- package/core/balance/balance.mjs +5 -4
- package/core/balance/styles.css +38 -6
- package/core/center/center.cjs +3 -4
- package/core/center/center.d.cts +1 -0
- package/core/center/center.d.mts +1 -0
- package/core/center/center.mjs +4 -4
- package/core/center/styles.css +4 -26
- package/core/constants.cjs +4 -255
- package/core/constants.d.cts +4 -206
- package/core/constants.d.mts +4 -206
- package/core/constants.mjs +4 -206
- package/core/flow/flow.cjs +5 -7
- package/core/flow/flow.mjs +6 -7
- package/core/index.d.cts +2 -2
- package/core/index.d.mts +2 -2
- package/core/layer/layer.cjs +2 -4
- package/core/layer/layer.mjs +3 -4
- package/core/layer/styles.css +0 -4
- package/core/matrix/matrix.cjs +3 -4
- package/core/matrix/matrix.d.cts +1 -0
- package/core/matrix/matrix.d.mts +1 -0
- package/core/matrix/matrix.mjs +4 -4
- package/core/matrix/styles.css +0 -6
- package/core/pack/pack.cjs +2 -4
- package/core/pack/pack.mjs +3 -4
- package/core/pin/pin.cjs +2 -2
- package/core/pin/pin.mjs +1 -1
- package/core/stack/stack.cjs +12 -14
- package/core/stack/stack.d.cts +1 -1
- package/core/stack/stack.d.mts +1 -1
- package/core/stack/stack.mjs +13 -14
- package/core/stack/styles.css +0 -2
- package/core/styles.css +42 -44
- package/core/tile/tile.cjs +2 -4
- package/core/tile/tile.mjs +3 -4
- package/core/types.d.cts +7 -2
- package/core/types.d.mts +7 -2
- package/flow/index.cjs +6 -2
- package/flow/index.mjs +6 -2
- package/helpers/_internal/constants.cjs +25 -0
- package/helpers/_internal/constants.d.cts +13 -0
- package/helpers/_internal/constants.d.mts +13 -0
- package/helpers/_internal/constants.mjs +16 -0
- package/helpers/_internal/createExtractLayoutOptions.cjs +25 -0
- package/helpers/_internal/createExtractLayoutOptions.d.cts +8 -0
- package/helpers/_internal/createExtractLayoutOptions.d.mts +9 -0
- package/helpers/_internal/createExtractLayoutOptions.mjs +24 -0
- package/helpers/extractBalanceOptions.cjs +15 -0
- package/helpers/extractBalanceOptions.d.cts +5 -0
- package/helpers/extractBalanceOptions.d.mts +6 -0
- package/helpers/extractBalanceOptions.mjs +15 -0
- package/helpers/extractCenterOptions.cjs +14 -0
- package/helpers/extractCenterOptions.d.cts +6 -0
- package/helpers/extractCenterOptions.d.mts +7 -0
- package/helpers/extractCenterOptions.mjs +14 -0
- package/helpers/extractFlowOptions.cjs +15 -0
- package/helpers/extractFlowOptions.d.cts +6 -0
- package/helpers/extractFlowOptions.d.mts +7 -0
- package/helpers/extractFlowOptions.mjs +15 -0
- package/helpers/extractLayerOptions.cjs +13 -0
- package/helpers/extractLayerOptions.d.cts +6 -0
- package/helpers/extractLayerOptions.d.mts +7 -0
- package/helpers/extractLayerOptions.mjs +13 -0
- package/helpers/extractMatrixOptions.cjs +17 -0
- package/helpers/extractMatrixOptions.d.cts +5 -0
- package/helpers/extractMatrixOptions.d.mts +6 -0
- package/helpers/extractMatrixOptions.mjs +17 -0
- package/helpers/extractPackOptions.cjs +8 -0
- package/helpers/extractPackOptions.d.cts +6 -0
- package/helpers/extractPackOptions.d.mts +7 -0
- package/helpers/extractPackOptions.mjs +8 -0
- package/helpers/extractPinOptions.cjs +8 -0
- package/helpers/extractPinOptions.d.cts +6 -0
- package/helpers/extractPinOptions.d.mts +7 -0
- package/helpers/extractPinOptions.mjs +8 -0
- package/helpers/extractStackOptions.cjs +15 -0
- package/helpers/extractStackOptions.d.cts +6 -0
- package/helpers/extractStackOptions.d.mts +7 -0
- package/helpers/extractStackOptions.mjs +15 -0
- package/helpers/extractTileOptions.cjs +15 -0
- package/helpers/extractTileOptions.d.cts +6 -0
- package/helpers/extractTileOptions.d.mts +7 -0
- package/helpers/extractTileOptions.mjs +15 -0
- package/helpers/index.cjs +20 -0
- package/helpers/index.d.cts +10 -0
- package/helpers/index.d.mts +10 -0
- package/helpers/index.mjs +11 -0
- package/index.cjs +18 -18
- package/index.d.cts +2 -2
- package/index.d.mts +2 -2
- package/index.mjs +10 -10
- package/layer/index.cjs +6 -2
- package/layer/index.mjs +6 -2
- package/matrix/index.cjs +6 -2
- package/matrix/index.mjs +6 -2
- package/pack/index.cjs +6 -2
- package/pack/index.mjs +6 -2
- package/package.json +6 -4
- package/pin/index.cjs +6 -2
- package/pin/index.mjs +6 -2
- package/stack/index.cjs +6 -2
- package/stack/index.mjs +6 -2
- package/tile/index.cjs +6 -2
- package/tile/index.mjs +6 -2
- package/types.d.cts +2 -2
- package/types.d.mts +2 -2
- package/core/_internal/warnIfUnsupported.cjs +0 -15
- package/core/_internal/warnIfUnsupported.d.cts +0 -3
- package/core/_internal/warnIfUnsupported.d.mts +0 -4
- package/core/_internal/warnIfUnsupported.mjs +0 -14
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_core_constants = require('../constants.cjs');
|
|
1
|
+
const require_core__constants = require('../_constants.cjs');
|
|
3
2
|
const require_core__internal_hasValue = require('./hasValue.cjs');
|
|
4
|
-
|
|
5
|
-
clsx = require_runtime.__toESM(clsx, 1);
|
|
3
|
+
const require_core__internal_mergeClassName = require('./mergeClassName.cjs');
|
|
6
4
|
|
|
7
5
|
//#region src/core/_internal/applyChildRatio.ts
|
|
8
6
|
/**
|
|
@@ -13,8 +11,8 @@ clsx = require_runtime.__toESM(clsx, 1);
|
|
|
13
11
|
*/
|
|
14
12
|
function applyChildRatio(result, childRatioX, childRatioY) {
|
|
15
13
|
if (require_core__internal_hasValue(childRatioX) || require_core__internal_hasValue(childRatioY)) {
|
|
16
|
-
result.className = (
|
|
17
|
-
result.style[
|
|
14
|
+
result.className = require_core__internal_mergeClassName(result.className, require_core__constants.clsLayoutChildRatio);
|
|
15
|
+
result.style[require_core__constants.varLayoutChildRatio] = `${childRatioX ?? 1} / ${childRatioY ?? 1}`;
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
18
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { clsLayoutChildRatio, varLayoutChildRatio } from "../
|
|
1
|
+
import { clsLayoutChildRatio, varLayoutChildRatio } from "../_constants.mjs";
|
|
2
2
|
import hasValue from "./hasValue.mjs";
|
|
3
|
-
import
|
|
3
|
+
import mergeClassName from "./mergeClassName.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/core/_internal/applyChildRatio.ts
|
|
6
6
|
/**
|
|
@@ -11,7 +11,7 @@ import clsx from "clsx";
|
|
|
11
11
|
*/
|
|
12
12
|
function applyChildRatio(result, childRatioX, childRatioY) {
|
|
13
13
|
if (hasValue(childRatioX) || hasValue(childRatioY)) {
|
|
14
|
-
result.className =
|
|
14
|
+
result.className = mergeClassName(result.className, clsLayoutChildRatio);
|
|
15
15
|
result.style[varLayoutChildRatio] = `${childRatioX ?? 1} / ${childRatioY ?? 1}`;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_core_constants = require('../constants.cjs');
|
|
1
|
+
const require_core__constants = require('../_constants.cjs');
|
|
3
2
|
const require_core__internal_hasValue = require('./hasValue.cjs');
|
|
3
|
+
const require_core__internal_mergeClassName = require('./mergeClassName.cjs');
|
|
4
4
|
const require_core__internal_unit = require('./unit.cjs');
|
|
5
|
-
let clsx = require("clsx");
|
|
6
|
-
clsx = require_runtime.__toESM(clsx, 1);
|
|
7
5
|
|
|
8
6
|
//#region src/core/_internal/applyChildSize.ts
|
|
9
7
|
/**
|
|
@@ -14,12 +12,12 @@ clsx = require_runtime.__toESM(clsx, 1);
|
|
|
14
12
|
*/
|
|
15
13
|
function applyChildSize(result, childSizeX, childSizeY) {
|
|
16
14
|
if (require_core__internal_hasValue(childSizeX)) {
|
|
17
|
-
result.className = (
|
|
18
|
-
result.style[
|
|
15
|
+
result.className = require_core__internal_mergeClassName(result.className, require_core__constants.clsLayoutChildSizeX);
|
|
16
|
+
result.style[require_core__constants.varLayoutChildSizeX] = require_core__internal_unit(childSizeX);
|
|
19
17
|
}
|
|
20
18
|
if (require_core__internal_hasValue(childSizeY)) {
|
|
21
|
-
result.className = (
|
|
22
|
-
result.style[
|
|
19
|
+
result.className = require_core__internal_mergeClassName(result.className, require_core__constants.clsLayoutChildSizeY);
|
|
20
|
+
result.style[require_core__constants.varLayoutChildSizeY] = require_core__internal_unit(childSizeY);
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { clsLayoutChildSizeX, clsLayoutChildSizeY, varLayoutChildSizeX, varLayoutChildSizeY } from "../
|
|
1
|
+
import { clsLayoutChildSizeX, clsLayoutChildSizeY, varLayoutChildSizeX, varLayoutChildSizeY } from "../_constants.mjs";
|
|
2
2
|
import hasValue from "./hasValue.mjs";
|
|
3
|
+
import mergeClassName from "./mergeClassName.mjs";
|
|
3
4
|
import unit from "./unit.mjs";
|
|
4
|
-
import clsx from "clsx";
|
|
5
5
|
|
|
6
6
|
//#region src/core/_internal/applyChildSize.ts
|
|
7
7
|
/**
|
|
@@ -12,11 +12,11 @@ import clsx from "clsx";
|
|
|
12
12
|
*/
|
|
13
13
|
function applyChildSize(result, childSizeX, childSizeY) {
|
|
14
14
|
if (hasValue(childSizeX)) {
|
|
15
|
-
result.className =
|
|
15
|
+
result.className = mergeClassName(result.className, clsLayoutChildSizeX);
|
|
16
16
|
result.style[varLayoutChildSizeX] = unit(childSizeX);
|
|
17
17
|
}
|
|
18
18
|
if (hasValue(childSizeY)) {
|
|
19
|
-
result.className =
|
|
19
|
+
result.className = mergeClassName(result.className, clsLayoutChildSizeY);
|
|
20
20
|
result.style[varLayoutChildSizeY] = unit(childSizeY);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_core_constants = require('../constants.cjs');
|
|
1
|
+
const require_core__constants = require('../_constants.cjs');
|
|
3
2
|
const require_core__internal_hasValue = require('./hasValue.cjs');
|
|
3
|
+
const require_core__internal_mergeClassName = require('./mergeClassName.cjs');
|
|
4
4
|
const require_core__internal_unit = require('./unit.cjs');
|
|
5
|
-
let clsx = require("clsx");
|
|
6
|
-
clsx = require_runtime.__toESM(clsx, 1);
|
|
7
5
|
|
|
8
6
|
//#region src/core/_internal/applyGap.ts
|
|
9
7
|
/**
|
|
@@ -16,13 +14,13 @@ clsx = require_runtime.__toESM(clsx, 1);
|
|
|
16
14
|
function applyGap(result, gap, gapX, gapY) {
|
|
17
15
|
gapX = gapX ?? gap;
|
|
18
16
|
if (require_core__internal_hasValue(gapX)) {
|
|
19
|
-
result.className = (
|
|
20
|
-
result.style[
|
|
17
|
+
result.className = require_core__internal_mergeClassName(result.className, require_core__constants.clsLayoutGapX);
|
|
18
|
+
result.style[require_core__constants.varLayoutGapX] = require_core__internal_unit(gapX);
|
|
21
19
|
}
|
|
22
20
|
gapY = gapY ?? gap;
|
|
23
21
|
if (require_core__internal_hasValue(gapY)) {
|
|
24
|
-
result.className = (
|
|
25
|
-
result.style[
|
|
22
|
+
result.className = require_core__internal_mergeClassName(result.className, require_core__constants.clsLayoutGapY);
|
|
23
|
+
result.style[require_core__constants.varLayoutGapY] = require_core__internal_unit(gapY);
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { clsLayoutGapX, clsLayoutGapY, varLayoutGapX, varLayoutGapY } from "../
|
|
1
|
+
import { clsLayoutGapX, clsLayoutGapY, varLayoutGapX, varLayoutGapY } from "../_constants.mjs";
|
|
2
2
|
import hasValue from "./hasValue.mjs";
|
|
3
|
+
import mergeClassName from "./mergeClassName.mjs";
|
|
3
4
|
import unit from "./unit.mjs";
|
|
4
|
-
import clsx from "clsx";
|
|
5
5
|
|
|
6
6
|
//#region src/core/_internal/applyGap.ts
|
|
7
7
|
/**
|
|
@@ -14,12 +14,12 @@ import clsx from "clsx";
|
|
|
14
14
|
function applyGap(result, gap, gapX, gapY) {
|
|
15
15
|
gapX = gapX ?? gap;
|
|
16
16
|
if (hasValue(gapX)) {
|
|
17
|
-
result.className =
|
|
17
|
+
result.className = mergeClassName(result.className, clsLayoutGapX);
|
|
18
18
|
result.style[varLayoutGapX] = unit(gapX);
|
|
19
19
|
}
|
|
20
20
|
gapY = gapY ?? gap;
|
|
21
21
|
if (hasValue(gapY)) {
|
|
22
|
-
result.className =
|
|
22
|
+
result.className = mergeClassName(result.className, clsLayoutGapY);
|
|
23
23
|
result.style[varLayoutGapY] = unit(gapY);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/core/_internal/mergeClassName.ts
|
|
3
|
+
function mergeClassName(...classNames) {
|
|
4
|
+
return classNames.reduce((result, className) => {
|
|
5
|
+
if (className) result.push(className);
|
|
6
|
+
return result;
|
|
7
|
+
}, []).join(" ");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
module.exports = mergeClassName;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/core/_internal/mergeClassName.ts
|
|
2
|
+
function mergeClassName(...classNames) {
|
|
3
|
+
return classNames.reduce((result, className) => {
|
|
4
|
+
if (className) result.push(className);
|
|
5
|
+
return result;
|
|
6
|
+
}, []).join(" ");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { mergeClassName as default };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
let clsx = require("clsx");
|
|
3
|
-
clsx = require_runtime.__toESM(clsx, 1);
|
|
1
|
+
const require_core__internal_mergeClassName = require('./mergeClassName.cjs');
|
|
4
2
|
|
|
5
3
|
//#region src/core/_internal/mergeLayoutResults.ts
|
|
6
4
|
function mergeLayoutResults(results) {
|
|
7
5
|
return results.reduce((layoutResult, result) => {
|
|
8
|
-
if (result.className) layoutResult.className = (
|
|
6
|
+
if (result.className) layoutResult.className = require_core__internal_mergeClassName(layoutResult.className, result.className);
|
|
9
7
|
if (result.style) layoutResult.style = {
|
|
10
8
|
...layoutResult.style,
|
|
11
9
|
...result.style
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import mergeClassName from "./mergeClassName.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/core/_internal/mergeLayoutResults.ts
|
|
4
4
|
function mergeLayoutResults(results) {
|
|
5
5
|
return results.reduce((layoutResult, result) => {
|
|
6
|
-
if (result.className) layoutResult.className =
|
|
6
|
+
if (result.className) layoutResult.className = mergeClassName(layoutResult.className, result.className);
|
|
7
7
|
if (result.style) layoutResult.style = {
|
|
8
8
|
...layoutResult.style,
|
|
9
9
|
...result.style
|
package/core/_types.d.cts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { Adjust, AlignX, AlignY, Direction } from "./constants.cjs";
|
|
2
|
-
import CSS from "csstype";
|
|
3
2
|
|
|
4
3
|
//#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
4
|
/**
|
|
13
5
|
* 子要素を並べる方向
|
|
14
6
|
*/
|
|
@@ -120,4 +112,4 @@ type TracksOptions = {
|
|
|
120
112
|
tracksY?: (string | number)[] | null;
|
|
121
113
|
};
|
|
122
114
|
//#endregion
|
|
123
|
-
export { AdjustOptions, AlignOptions,
|
|
115
|
+
export { AdjustOptions, AlignOptions, ChildCountOptions, ChildRatioOptions, ChildSizeOptions, DirectionOptions, GapOptions, TracksOptions };
|
package/core/_types.d.mts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { Adjust, AlignX, AlignY, Direction } from "./constants.mjs";
|
|
2
|
-
import CSS from "csstype";
|
|
3
2
|
|
|
4
3
|
//#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
4
|
/**
|
|
13
5
|
* 子要素を並べる方向
|
|
14
6
|
*/
|
|
@@ -120,4 +112,4 @@ type TracksOptions = {
|
|
|
120
112
|
tracksY?: (string | number)[] | null;
|
|
121
113
|
};
|
|
122
114
|
//#endregion
|
|
123
|
-
export { AdjustOptions, AlignOptions,
|
|
115
|
+
export { AdjustOptions, AlignOptions, ChildCountOptions, ChildRatioOptions, ChildSizeOptions, DirectionOptions, GapOptions, TracksOptions };
|
package/core/balance/balance.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
const require_core_constants = require('../constants.cjs');
|
|
3
2
|
const require_core__constants = require('../_constants.cjs');
|
|
3
|
+
const require_core__internal_mergeClassName = require('../_internal/mergeClassName.cjs');
|
|
4
4
|
const require_core__internal_applyChildRatio = require('../_internal/applyChildRatio.cjs');
|
|
5
5
|
const require_core__internal_applyChildSize = require('../_internal/applyChildSize.cjs');
|
|
6
6
|
const require_core__internal_applyGap = require('../_internal/applyGap.cjs');
|
|
7
7
|
let _niche_works_utils_object_maybeDefault = require("@niche-works/utils/object/maybeDefault");
|
|
8
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
9
|
|
|
12
10
|
//#region src/core/balance/balance.ts
|
|
13
11
|
/**
|
|
14
12
|
* balanceレイアウト
|
|
15
13
|
*
|
|
16
14
|
* - 子要素を均等に配置する
|
|
15
|
+
* - `adjust`が効いていない場合は、子要素のサイズを維持したまま、余白を均等に配分する
|
|
16
|
+
* - `adjust`が効いている場合は、子要素のサイズを調整してコンテナを満たす
|
|
17
17
|
*/
|
|
18
18
|
const balance = (options = {}) => {
|
|
19
19
|
const { direction, alignX, alignY, adjustX, adjustY, gap, gapX, gapY, childSizeX, childSizeY, childRatioX, childRatioY } = (0, _niche_works_utils_object_maybeDefault.default)(options, {
|
|
@@ -22,7 +22,7 @@ const balance = (options = {}) => {
|
|
|
22
22
|
alignY: "top"
|
|
23
23
|
}, { overwriteNull: true });
|
|
24
24
|
const result = {
|
|
25
|
-
className: (
|
|
25
|
+
className: require_core__internal_mergeClassName(require_core__constants.clsLayoutBalance, require_core__constants.clsLayout.direction[direction], require_core__constants.clsLayout.align.x[alignX], require_core__constants.clsLayout.align.y[alignY], require_core__constants.clsLayout.adjust.x[adjustX], require_core__constants.clsLayout.adjust.y[adjustY]),
|
|
26
26
|
style: {}
|
|
27
27
|
};
|
|
28
28
|
require_core__internal_applyGap(result, gap, gapX, gapY);
|
|
@@ -6,6 +6,8 @@ import { BalanceLayoutOptions } from "./types.cjs";
|
|
|
6
6
|
* balanceレイアウト
|
|
7
7
|
*
|
|
8
8
|
* - 子要素を均等に配置する
|
|
9
|
+
* - `adjust`が効いていない場合は、子要素のサイズを維持したまま、余白を均等に配分する
|
|
10
|
+
* - `adjust`が効いている場合は、子要素のサイズを調整してコンテナを満たす
|
|
9
11
|
*/
|
|
10
12
|
declare const balance: StyleLayout<BalanceLayoutOptions>;
|
|
11
13
|
export = balance;
|
|
@@ -6,6 +6,8 @@ import { BalanceLayoutOptions } from "./types.mjs";
|
|
|
6
6
|
* balanceレイアウト
|
|
7
7
|
*
|
|
8
8
|
* - 子要素を均等に配置する
|
|
9
|
+
* - `adjust`が効いていない場合は、子要素のサイズを維持したまま、余白を均等に配分する
|
|
10
|
+
* - `adjust`が効いている場合は、子要素のサイズを調整してコンテナを満たす
|
|
9
11
|
*/
|
|
10
12
|
declare const balance: StyleLayout<BalanceLayoutOptions>;
|
|
11
13
|
//#endregion
|
package/core/balance/balance.mjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { clsLayoutBalance } from "../
|
|
2
|
-
import
|
|
1
|
+
import { clsLayout, clsLayoutBalance } from "../_constants.mjs";
|
|
2
|
+
import mergeClassName from "../_internal/mergeClassName.mjs";
|
|
3
3
|
import applyChildRatio from "../_internal/applyChildRatio.mjs";
|
|
4
4
|
import applyChildSize from "../_internal/applyChildSize.mjs";
|
|
5
5
|
import applyGap from "../_internal/applyGap.mjs";
|
|
6
6
|
import maybeDefault from "@niche-works/utils/object/maybeDefault";
|
|
7
|
-
import clsx from "clsx";
|
|
8
7
|
|
|
9
8
|
//#region src/core/balance/balance.ts
|
|
10
9
|
/**
|
|
11
10
|
* balanceレイアウト
|
|
12
11
|
*
|
|
13
12
|
* - 子要素を均等に配置する
|
|
13
|
+
* - `adjust`が効いていない場合は、子要素のサイズを維持したまま、余白を均等に配分する
|
|
14
|
+
* - `adjust`が効いている場合は、子要素のサイズを調整してコンテナを満たす
|
|
14
15
|
*/
|
|
15
16
|
const balance = (options = {}) => {
|
|
16
17
|
const { direction, alignX, alignY, adjustX, adjustY, gap, gapX, gapY, childSizeX, childSizeY, childRatioX, childRatioY } = maybeDefault(options, {
|
|
@@ -19,7 +20,7 @@ const balance = (options = {}) => {
|
|
|
19
20
|
alignY: "top"
|
|
20
21
|
}, { overwriteNull: true });
|
|
21
22
|
const result = {
|
|
22
|
-
className:
|
|
23
|
+
className: mergeClassName(clsLayoutBalance, clsLayout.direction[direction], clsLayout.align.x[alignX], clsLayout.align.y[alignY], clsLayout.adjust.x[adjustX], clsLayout.adjust.y[adjustY]),
|
|
23
24
|
style: {}
|
|
24
25
|
};
|
|
25
26
|
applyGap(result, gap, gapX, gapY);
|
package/core/balance/styles.css
CHANGED
|
@@ -8,9 +8,29 @@
|
|
|
8
8
|
}
|
|
9
9
|
.nws-layout-balance.nws-layout-direction-x {
|
|
10
10
|
grid-auto-flow: column;
|
|
11
|
+
grid-auto-columns: max-content;
|
|
12
|
+
}
|
|
13
|
+
.nws-layout-balance.nws-layout-direction-x.nws-layout-adjustX-grow, .nws-layout-balance.nws-layout-direction-x.nws-layout-adjustX-fit {
|
|
14
|
+
grid-auto-columns: auto;
|
|
15
|
+
}
|
|
16
|
+
.nws-layout-balance.nws-layout-direction-x.nws-layout-adjustX-shrink {
|
|
17
|
+
grid-auto-columns: minmax(0, max-content);
|
|
18
|
+
}
|
|
19
|
+
.nws-layout-balance.nws-layout-direction-x.nws-layout-childSizeX {
|
|
20
|
+
grid-auto-columns: auto;
|
|
11
21
|
}
|
|
12
22
|
.nws-layout-balance.nws-layout-direction-y {
|
|
13
23
|
grid-auto-flow: row;
|
|
24
|
+
grid-auto-rows: max-content;
|
|
25
|
+
}
|
|
26
|
+
.nws-layout-balance.nws-layout-direction-y.nws-layout-adjustY-grow, .nws-layout-balance.nws-layout-direction-y.nws-layout-adjustY-fit {
|
|
27
|
+
grid-auto-rows: auto;
|
|
28
|
+
}
|
|
29
|
+
.nws-layout-balance.nws-layout-direction-y.nws-layout-adjustY-shrink {
|
|
30
|
+
grid-auto-rows: minmax(0, max-content);
|
|
31
|
+
}
|
|
32
|
+
.nws-layout-balance.nws-layout-direction-y.nws-layout-childSizeY {
|
|
33
|
+
grid-auto-rows: auto;
|
|
14
34
|
}
|
|
15
35
|
.nws-layout-balance.nws-layout-alignX-left {
|
|
16
36
|
justify-items: flex-start;
|
|
@@ -22,13 +42,13 @@
|
|
|
22
42
|
justify-items: flex-end;
|
|
23
43
|
}
|
|
24
44
|
.nws-layout-balance.nws-layout-alignX-spaceBetween {
|
|
25
|
-
justify-
|
|
45
|
+
justify-content: space-between;
|
|
26
46
|
}
|
|
27
47
|
.nws-layout-balance.nws-layout-alignX-spaceAround {
|
|
28
|
-
justify-
|
|
48
|
+
justify-content: space-around;
|
|
29
49
|
}
|
|
30
50
|
.nws-layout-balance.nws-layout-alignX-spaceEvenly {
|
|
31
|
-
justify-
|
|
51
|
+
justify-content: space-evenly;
|
|
32
52
|
}
|
|
33
53
|
.nws-layout-balance.nws-layout-alignY-top {
|
|
34
54
|
align-items: flex-start;
|
|
@@ -40,13 +60,13 @@
|
|
|
40
60
|
align-items: flex-end;
|
|
41
61
|
}
|
|
42
62
|
.nws-layout-balance.nws-layout-alignY-spaceBetween {
|
|
43
|
-
align-
|
|
63
|
+
align-content: space-between;
|
|
44
64
|
}
|
|
45
65
|
.nws-layout-balance.nws-layout-alignY-spaceAround {
|
|
46
|
-
align-
|
|
66
|
+
align-content: space-around;
|
|
47
67
|
}
|
|
48
68
|
.nws-layout-balance.nws-layout-alignY-spaceEvenly {
|
|
49
|
-
align-
|
|
69
|
+
align-content: space-evenly;
|
|
50
70
|
}
|
|
51
71
|
.nws-layout-balance > * {
|
|
52
72
|
min-width: 0;
|
|
@@ -64,9 +84,15 @@
|
|
|
64
84
|
.nws-layout-balance.nws-layout-adjustX-grow > *, .nws-layout-balance.nws-layout-adjustX-shrink > * {
|
|
65
85
|
width: 100%;
|
|
66
86
|
}
|
|
87
|
+
.nws-layout-balance.nws-layout-adjustX-grow > * {
|
|
88
|
+
min-width: max-content;
|
|
89
|
+
}
|
|
67
90
|
.nws-layout-balance.nws-layout-adjustX-grow.nws-layout-childSizeX > * {
|
|
68
91
|
min-width: var(--nws-layout-childSizeX);
|
|
69
92
|
}
|
|
93
|
+
.nws-layout-balance.nws-layout-adjustX-shrink > * {
|
|
94
|
+
max-width: max-content;
|
|
95
|
+
}
|
|
70
96
|
.nws-layout-balance.nws-layout-adjustX-shrink.nws-layout-childSizeX > * {
|
|
71
97
|
max-width: var(--nws-layout-childSizeX);
|
|
72
98
|
}
|
|
@@ -82,9 +108,15 @@
|
|
|
82
108
|
.nws-layout-balance.nws-layout-adjustY-grow > *, .nws-layout-balance.nws-layout-adjustY-shrink > * {
|
|
83
109
|
height: 100%;
|
|
84
110
|
}
|
|
111
|
+
.nws-layout-balance.nws-layout-adjustY-grow:not(.nws-layout-childSizeY) > * {
|
|
112
|
+
min-height: max-content;
|
|
113
|
+
}
|
|
85
114
|
.nws-layout-balance.nws-layout-adjustY-grow.nws-layout-childSizeY > * {
|
|
86
115
|
min-height: var(--nws-layout-childSizeY);
|
|
87
116
|
}
|
|
117
|
+
.nws-layout-balance.nws-layout-adjustY-shrink:not(.nws-layout-childSizeY) > * {
|
|
118
|
+
max-height: max-content;
|
|
119
|
+
}
|
|
88
120
|
.nws-layout-balance.nws-layout-adjustY-shrink.nws-layout-childSizeY > * {
|
|
89
121
|
max-height: var(--nws-layout-childSizeY);
|
|
90
122
|
}
|
package/core/center/center.cjs
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
const require_core_constants = require('../constants.cjs');
|
|
3
2
|
const require_core__constants = require('../_constants.cjs');
|
|
3
|
+
const require_core__internal_mergeClassName = require('../_internal/mergeClassName.cjs');
|
|
4
4
|
const require_core__internal_applyChildRatio = require('../_internal/applyChildRatio.cjs');
|
|
5
5
|
const require_core__internal_applyChildSize = require('../_internal/applyChildSize.cjs');
|
|
6
6
|
const require_core__internal_applyGap = require('../_internal/applyGap.cjs');
|
|
7
7
|
let _niche_works_utils_object_maybeDefault = require("@niche-works/utils/object/maybeDefault");
|
|
8
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
9
|
|
|
12
10
|
//#region src/core/center/center.ts
|
|
13
11
|
/**
|
|
14
12
|
* centerレイアウト
|
|
15
13
|
*
|
|
16
14
|
* - 子要素を中央に配置する
|
|
15
|
+
* - 親要素が子要素のサイズよりも小さくなっても左上が親要素内に収まる
|
|
17
16
|
*/
|
|
18
17
|
const center = (options = {}) => {
|
|
19
18
|
const { direction, adjustX, adjustY, gap, gapX, gapY, childSizeX, childSizeY, childRatioX, childRatioY } = (0, _niche_works_utils_object_maybeDefault.default)(options, { direction: "x" }, { overwriteNull: true });
|
|
20
19
|
const result = {
|
|
21
|
-
className: (
|
|
20
|
+
className: require_core__internal_mergeClassName(require_core__constants.clsLayoutCenter, require_core__constants.clsLayout.direction[direction], require_core__constants.clsLayout.adjust.x[adjustX], require_core__constants.clsLayout.adjust.y[adjustY]),
|
|
22
21
|
style: {}
|
|
23
22
|
};
|
|
24
23
|
require_core__internal_applyGap(result, gap, gapX, gapY);
|
package/core/center/center.d.cts
CHANGED
package/core/center/center.d.mts
CHANGED
package/core/center/center.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { clsLayoutCenter } from "../
|
|
2
|
-
import
|
|
1
|
+
import { clsLayout, clsLayoutCenter } from "../_constants.mjs";
|
|
2
|
+
import mergeClassName from "../_internal/mergeClassName.mjs";
|
|
3
3
|
import applyChildRatio from "../_internal/applyChildRatio.mjs";
|
|
4
4
|
import applyChildSize from "../_internal/applyChildSize.mjs";
|
|
5
5
|
import applyGap from "../_internal/applyGap.mjs";
|
|
6
6
|
import maybeDefault from "@niche-works/utils/object/maybeDefault";
|
|
7
|
-
import clsx from "clsx";
|
|
8
7
|
|
|
9
8
|
//#region src/core/center/center.ts
|
|
10
9
|
/**
|
|
11
10
|
* centerレイアウト
|
|
12
11
|
*
|
|
13
12
|
* - 子要素を中央に配置する
|
|
13
|
+
* - 親要素が子要素のサイズよりも小さくなっても左上が親要素内に収まる
|
|
14
14
|
*/
|
|
15
15
|
const center = (options = {}) => {
|
|
16
16
|
const { direction, adjustX, adjustY, gap, gapX, gapY, childSizeX, childSizeY, childRatioX, childRatioY } = maybeDefault(options, { direction: "x" }, { overwriteNull: true });
|
|
17
17
|
const result = {
|
|
18
|
-
className:
|
|
18
|
+
className: mergeClassName(clsLayoutCenter, clsLayout.direction[direction], clsLayout.adjust.x[adjustX], clsLayout.adjust.y[adjustY]),
|
|
19
19
|
style: {}
|
|
20
20
|
};
|
|
21
21
|
applyGap(result, gap, gapX, gapY);
|
package/core/center/styles.css
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
}
|
|
22
22
|
.nws-layout-center.nws-layout-direction-x > * {
|
|
23
23
|
max-width: none;
|
|
24
|
+
max-height: none;
|
|
24
25
|
flex-grow: 0;
|
|
25
26
|
flex-shrink: 0;
|
|
26
27
|
margin-top: auto;
|
|
@@ -36,9 +37,6 @@
|
|
|
36
37
|
width: var(--nws-layout-childSizeX);
|
|
37
38
|
flex-basis: var(--nws-layout-childSizeX);
|
|
38
39
|
}
|
|
39
|
-
.nws-layout-center.nws-layout-direction-x.nws-layout-adjustX-fit {
|
|
40
|
-
justify-content: stretch;
|
|
41
|
-
}
|
|
42
40
|
.nws-layout-center.nws-layout-direction-x.nws-layout-adjustX-fit > * {
|
|
43
41
|
width: 100%;
|
|
44
42
|
max-width: none;
|
|
@@ -46,29 +44,19 @@
|
|
|
46
44
|
flex-shrink: 1;
|
|
47
45
|
flex-basis: 0%;
|
|
48
46
|
}
|
|
49
|
-
.nws-layout-center.nws-layout-direction-x.nws-layout-adjustX-grow {
|
|
50
|
-
justify-content: stretch;
|
|
51
|
-
}
|
|
52
47
|
.nws-layout-center.nws-layout-direction-x.nws-layout-adjustX-grow > * {
|
|
53
48
|
width: 100%;
|
|
54
49
|
min-width: var(--nws-layout-childSizeX);
|
|
55
50
|
max-width: none;
|
|
56
51
|
flex-grow: 1;
|
|
57
|
-
flex-shrink: 0;
|
|
58
52
|
flex-basis: var(--nws-layout-childSizeX);
|
|
59
53
|
}
|
|
60
54
|
.nws-layout-center.nws-layout-direction-x.nws-layout-adjustX-shrink > * {
|
|
61
55
|
width: var(--nws-layout-childSizeX);
|
|
62
56
|
max-width: 100%;
|
|
63
|
-
flex-grow: 0;
|
|
64
57
|
flex-shrink: 1;
|
|
65
58
|
flex-basis: var(--nws-layout-childSizeX);
|
|
66
59
|
}
|
|
67
|
-
.nws-layout-center.nws-layout-direction-x > * {
|
|
68
|
-
max-height: none;
|
|
69
|
-
margin-top: auto;
|
|
70
|
-
margin-bottom: auto;
|
|
71
|
-
}
|
|
72
60
|
.nws-layout-center.nws-layout-direction-x.nws-layout-childSizeY > * {
|
|
73
61
|
height: var(--nws-layout-childSizeY);
|
|
74
62
|
}
|
|
@@ -112,6 +100,9 @@
|
|
|
112
100
|
}
|
|
113
101
|
.nws-layout-center.nws-layout-direction-y > * {
|
|
114
102
|
max-width: none;
|
|
103
|
+
max-height: none;
|
|
104
|
+
flex-grow: 0;
|
|
105
|
+
flex-shrink: 0;
|
|
115
106
|
margin-left: auto;
|
|
116
107
|
margin-right: auto;
|
|
117
108
|
}
|
|
@@ -145,18 +136,10 @@
|
|
|
145
136
|
margin-left: auto;
|
|
146
137
|
margin-right: auto;
|
|
147
138
|
}
|
|
148
|
-
.nws-layout-center.nws-layout-direction-y > * {
|
|
149
|
-
max-height: none;
|
|
150
|
-
flex-grow: 0;
|
|
151
|
-
flex-shrink: 0;
|
|
152
|
-
}
|
|
153
139
|
.nws-layout-center.nws-layout-direction-y.nws-layout-childSizeY > * {
|
|
154
140
|
height: var(--nws-layout-childSizeY);
|
|
155
141
|
flex-basis: var(--nws-layout-childSizeY);
|
|
156
142
|
}
|
|
157
|
-
.nws-layout-center.nws-layout-direction-y.nws-layout-adjustY-fit {
|
|
158
|
-
justify-content: stretch;
|
|
159
|
-
}
|
|
160
143
|
.nws-layout-center.nws-layout-direction-y.nws-layout-adjustY-fit > * {
|
|
161
144
|
height: 100%;
|
|
162
145
|
max-height: none;
|
|
@@ -164,21 +147,16 @@
|
|
|
164
147
|
flex-shrink: 1;
|
|
165
148
|
flex-basis: 0%;
|
|
166
149
|
}
|
|
167
|
-
.nws-layout-center.nws-layout-direction-y.nws-layout-adjustY-grow {
|
|
168
|
-
justify-content: stretch;
|
|
169
|
-
}
|
|
170
150
|
.nws-layout-center.nws-layout-direction-y.nws-layout-adjustY-grow > * {
|
|
171
151
|
height: 100%;
|
|
172
152
|
min-height: var(--nws-layout-childSizeY);
|
|
173
153
|
max-height: none;
|
|
174
154
|
flex-grow: 1;
|
|
175
|
-
flex-shrink: 0;
|
|
176
155
|
flex-basis: var(--nws-layout-childSizeY);
|
|
177
156
|
}
|
|
178
157
|
.nws-layout-center.nws-layout-direction-y.nws-layout-adjustY-shrink > * {
|
|
179
158
|
height: var(--nws-layout-childSizeY);
|
|
180
159
|
max-height: 100%;
|
|
181
|
-
flex-grow: 0;
|
|
182
160
|
flex-shrink: 1;
|
|
183
161
|
flex-basis: var(--nws-layout-childSizeY);
|
|
184
162
|
}
|