@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,108 @@
|
|
|
1
|
+
.nws-layout-tile {
|
|
2
|
+
--nws-layout-gapX: 0px;
|
|
3
|
+
--nws-layout-gapY: 0px;
|
|
4
|
+
--nws-layout-childSizeX: auto;
|
|
5
|
+
--nws-layout-childSizeY: auto;
|
|
6
|
+
--nws-layout-childRatio: auto;
|
|
7
|
+
--nws-layout-templateX: none;
|
|
8
|
+
--nws-layout-templateY: none;
|
|
9
|
+
--nws-layout-autoTracX: auto;
|
|
10
|
+
--nws-layout-autoTracY: auto;
|
|
11
|
+
display: grid;
|
|
12
|
+
}
|
|
13
|
+
.nws-layout-tile.nws-layout-direction-x {
|
|
14
|
+
grid-auto-flow: row;
|
|
15
|
+
grid-template-columns: var(--nws-layout-templateX);
|
|
16
|
+
grid-auto-rows: var(--nws-layout-autoTracY);
|
|
17
|
+
}
|
|
18
|
+
.nws-layout-tile.nws-layout-direction-y {
|
|
19
|
+
grid-auto-flow: column;
|
|
20
|
+
grid-auto-columns: var(--nws-layout-autoTracX);
|
|
21
|
+
grid-template-rows: var(--nws-layout-templateY);
|
|
22
|
+
}
|
|
23
|
+
.nws-layout-tile.nws-layout-alignX-left {
|
|
24
|
+
justify-content: flex-start;
|
|
25
|
+
}
|
|
26
|
+
.nws-layout-tile.nws-layout-alignX-center {
|
|
27
|
+
justify-content: center;
|
|
28
|
+
}
|
|
29
|
+
.nws-layout-tile.nws-layout-alignX-right {
|
|
30
|
+
justify-content: flex-end;
|
|
31
|
+
}
|
|
32
|
+
.nws-layout-tile.nws-layout-alignX-spaceBetween {
|
|
33
|
+
justify-content: space-between;
|
|
34
|
+
}
|
|
35
|
+
.nws-layout-tile.nws-layout-alignX-spaceAround {
|
|
36
|
+
justify-content: space-around;
|
|
37
|
+
}
|
|
38
|
+
.nws-layout-tile.nws-layout-alignX-spaceEvenly {
|
|
39
|
+
justify-content: space-evenly;
|
|
40
|
+
}
|
|
41
|
+
.nws-layout-tile.nws-layout-alignY-top {
|
|
42
|
+
align-content: flex-start;
|
|
43
|
+
}
|
|
44
|
+
.nws-layout-tile.nws-layout-alignY-middle {
|
|
45
|
+
align-content: center;
|
|
46
|
+
}
|
|
47
|
+
.nws-layout-tile.nws-layout-alignY-bottom {
|
|
48
|
+
align-content: flex-end;
|
|
49
|
+
}
|
|
50
|
+
.nws-layout-tile.nws-layout-alignY-spaceBetween {
|
|
51
|
+
align-content: space-between;
|
|
52
|
+
}
|
|
53
|
+
.nws-layout-tile.nws-layout-alignY-spaceAround {
|
|
54
|
+
align-content: space-around;
|
|
55
|
+
}
|
|
56
|
+
.nws-layout-tile.nws-layout-alignY-spaceEvenly {
|
|
57
|
+
align-content: space-evenly;
|
|
58
|
+
}
|
|
59
|
+
.nws-layout-tile.nws-layout-childSizeX > * {
|
|
60
|
+
width: var(--nws-layout-childSizeX);
|
|
61
|
+
}
|
|
62
|
+
.nws-layout-tile.nws-layout-childSizeY > * {
|
|
63
|
+
height: var(--nws-layout-childSizeY);
|
|
64
|
+
}
|
|
65
|
+
.nws-layout-tile > * {
|
|
66
|
+
min-width: 0;
|
|
67
|
+
}
|
|
68
|
+
.nws-layout-tile.nws-layout-adjustX-fit > * {
|
|
69
|
+
width: auto;
|
|
70
|
+
}
|
|
71
|
+
.nws-layout-tile.nws-layout-adjustX-grow > * {
|
|
72
|
+
width: auto;
|
|
73
|
+
}
|
|
74
|
+
.nws-layout-tile.nws-layout-adjustX-shrink > * {
|
|
75
|
+
width: auto;
|
|
76
|
+
}
|
|
77
|
+
.nws-layout-tile > * {
|
|
78
|
+
min-height: 0;
|
|
79
|
+
}
|
|
80
|
+
.nws-layout-tile.nws-layout-adjustY-fit {
|
|
81
|
+
align-content: stretch;
|
|
82
|
+
}
|
|
83
|
+
.nws-layout-tile.nws-layout-adjustY-fit > * {
|
|
84
|
+
height: auto;
|
|
85
|
+
}
|
|
86
|
+
.nws-layout-tile.nws-layout-adjustY-grow > * {
|
|
87
|
+
max-height: 100%;
|
|
88
|
+
height: 100%;
|
|
89
|
+
}
|
|
90
|
+
.nws-layout-tile.nws-layout-adjustY-grow.nws-layout-childSizeY > * {
|
|
91
|
+
min-height: var(--nws-layout-childSizeY);
|
|
92
|
+
}
|
|
93
|
+
.nws-layout-tile.nws-layout-adjustY-shrink > * {
|
|
94
|
+
min-height: 100%;
|
|
95
|
+
height: 100%;
|
|
96
|
+
}
|
|
97
|
+
.nws-layout-tile.nws-layout-adjustY-shrink.nws-layout-childSizeY > * {
|
|
98
|
+
max-height: var(--nws-layout-childSizeY);
|
|
99
|
+
}
|
|
100
|
+
.nws-layout-tile.nws-layout-childRatio > * {
|
|
101
|
+
aspect-ratio: var(--nws-layout-childRatio);
|
|
102
|
+
}
|
|
103
|
+
.nws-layout-tile.nws-layout-gapX {
|
|
104
|
+
column-gap: var(--nws-layout-gapX);
|
|
105
|
+
}
|
|
106
|
+
.nws-layout-tile.nws-layout-gapY {
|
|
107
|
+
row-gap: var(--nws-layout-gapY);
|
|
108
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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_hasValue = require('../_internal/hasValue.cjs');
|
|
5
|
+
const require_core__internal_applyChildRatio = require('../_internal/applyChildRatio.cjs');
|
|
6
|
+
const require_core__internal_unit = require('../_internal/unit.cjs');
|
|
7
|
+
const require_core__internal_applyChildSize = require('../_internal/applyChildSize.cjs');
|
|
8
|
+
const require_core__internal_applyGap = require('../_internal/applyGap.cjs');
|
|
9
|
+
const require_core__internal_mergeLayoutResults = require('../_internal/mergeLayoutResults.cjs');
|
|
10
|
+
let _niche_works_utils_object_maybeDefault = require("@niche-works/utils/object/maybeDefault");
|
|
11
|
+
_niche_works_utils_object_maybeDefault = require_runtime.__toESM(_niche_works_utils_object_maybeDefault, 1);
|
|
12
|
+
let clsx = require("clsx");
|
|
13
|
+
clsx = require_runtime.__toESM(clsx, 1);
|
|
14
|
+
|
|
15
|
+
//#region src/core/tile/tile.ts
|
|
16
|
+
/**
|
|
17
|
+
* tileレイアウト
|
|
18
|
+
*
|
|
19
|
+
* - 子要素の高さ・幅を基準にして格子状に並べる
|
|
20
|
+
* - 親要素のサイズが子要素に依存していないことを前提とする
|
|
21
|
+
*/
|
|
22
|
+
const tile = (options = {}) => {
|
|
23
|
+
const { direction, alignX, alignY, adjustX, adjustY, gap, gapX, gapY, childSizeX, childSizeY, childRatioX, childRatioY } = (0, _niche_works_utils_object_maybeDefault.default)(options, {
|
|
24
|
+
direction: "x",
|
|
25
|
+
alignX: "left",
|
|
26
|
+
alignY: "top"
|
|
27
|
+
}, { overwriteNull: true });
|
|
28
|
+
const result = {
|
|
29
|
+
className: (0, clsx.default)(require_core_constants.clsLayoutTile, 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]),
|
|
30
|
+
style: {}
|
|
31
|
+
};
|
|
32
|
+
require_core__internal_applyGap(result, gap, gapX, gapY);
|
|
33
|
+
require_core__internal_applyChildSize(result, childSizeX, childSizeY);
|
|
34
|
+
require_core__internal_applyChildRatio(result, childRatioX, childRatioY);
|
|
35
|
+
return require_core__internal_mergeLayoutResults([result, _getLayoutResultByDirection[direction](options)]);
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* 並べる方向によるスタイル
|
|
39
|
+
*/
|
|
40
|
+
const _getLayoutResultByDirection = {
|
|
41
|
+
x: ({ adjustX, adjustY, childSizeX, childSizeY }) => {
|
|
42
|
+
return require_core__internal_mergeLayoutResults([_getGridMainAxisTemplate(adjustX, childSizeX, require_core_constants.varLayoutTemplateX), _getGridClossAxisAuto(adjustY, childSizeY, require_core_constants.varLayoutAutoTracY)]);
|
|
43
|
+
},
|
|
44
|
+
y: ({ adjustX, adjustY, childSizeY, childSizeX }) => {
|
|
45
|
+
return require_core__internal_mergeLayoutResults([_getGridClossAxisAuto(adjustX, childSizeX, require_core_constants.varLayoutAutoTracX), _getGridMainAxisTemplate(adjustY, childSizeY, require_core_constants.varLayoutTemplateY)]);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* direction方向の子要素のサイズを指定するためのテンプレート
|
|
50
|
+
* @param align 子要素の配置
|
|
51
|
+
* @param childSize 子要素のサイズ
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
function _getGridMainAxisTemplate(adjust, childSize, varName) {
|
|
55
|
+
const hasChildSize = require_core__internal_hasValue(childSize);
|
|
56
|
+
const style = {};
|
|
57
|
+
if (adjust === "fit") if (hasChildSize) style[varName] = `repeat(auto-fit, minmax(clamp(0px, 100%, ${require_core__internal_unit(childSize)}), 1fr))`;
|
|
58
|
+
else style[varName] = "repeat(auto-fit, minmax(0, 1fr))";
|
|
59
|
+
else if (adjust === "grow") if (hasChildSize) style[varName] = `repeat(auto-fit, minmax(${require_core__internal_unit(childSize)}, 1fr))`;
|
|
60
|
+
else style[varName] = "repeat(auto-fit, minmax(0, 1fr))";
|
|
61
|
+
else if (adjust === "shrink") if (hasChildSize) style[varName] = `repeat(auto-fit, minmax(0, ${require_core__internal_unit(childSize)}))`;
|
|
62
|
+
else style[varName] = "repeat(auto-fit, minmax(0, 1fr))";
|
|
63
|
+
else if (hasChildSize) style[varName] = `repeat(auto-fit, ${require_core__internal_unit(childSize)})`;
|
|
64
|
+
else style[varName] = "repeat(auto-fit, minmax(max-content, 100%))";
|
|
65
|
+
return { style };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 交差軸方向
|
|
69
|
+
* @param adjust
|
|
70
|
+
* @param childSize
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
73
|
+
function _getGridClossAxisAuto(adjust, childSize, varName) {
|
|
74
|
+
const hasChildSize = require_core__internal_hasValue(childSize);
|
|
75
|
+
const style = {};
|
|
76
|
+
if (adjust === "fit") if (hasChildSize) style[varName] = `minmax(0, 100%)`;
|
|
77
|
+
else style[varName] = `minmax(0, 100%)`;
|
|
78
|
+
else if (adjust === "grow") if (hasChildSize) style[varName] = `minmax(${require_core__internal_unit(childSize)}, 100%)`;
|
|
79
|
+
else style[varName] = `minmax(auto, 100%)`;
|
|
80
|
+
else if (adjust === "shrink") if (hasChildSize) style[varName] = `minmax(0, ${require_core__internal_unit(childSize)})`;
|
|
81
|
+
else style[varName] = `minmax(0, auto)`;
|
|
82
|
+
return { style };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
86
|
+
module.exports = tile;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StyleLayout } from "../types.cjs";
|
|
2
|
+
import { TileLayoutOptions } from "./types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/core/tile/tile.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* tileレイアウト
|
|
7
|
+
*
|
|
8
|
+
* - 子要素の高さ・幅を基準にして格子状に並べる
|
|
9
|
+
* - 親要素のサイズが子要素に依存していないことを前提とする
|
|
10
|
+
*/
|
|
11
|
+
declare const tile: StyleLayout<TileLayoutOptions>;
|
|
12
|
+
export = tile;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StyleLayout } from "../types.mjs";
|
|
2
|
+
import { TileLayoutOptions } from "./types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/core/tile/tile.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* tileレイアウト
|
|
7
|
+
*
|
|
8
|
+
* - 子要素の高さ・幅を基準にして格子状に並べる
|
|
9
|
+
* - 親要素のサイズが子要素に依存していないことを前提とする
|
|
10
|
+
*/
|
|
11
|
+
declare const tile: StyleLayout<TileLayoutOptions>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { tile as default };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { clsLayoutTile, varLayoutAutoTracX, varLayoutAutoTracY, varLayoutTemplateX, varLayoutTemplateY } from "../constants.mjs";
|
|
2
|
+
import { clsLayoutAdjust, clsLayoutAlign, clsLayoutDirection } from "../_constants.mjs";
|
|
3
|
+
import hasValue from "../_internal/hasValue.mjs";
|
|
4
|
+
import applyChildRatio from "../_internal/applyChildRatio.mjs";
|
|
5
|
+
import unit from "../_internal/unit.mjs";
|
|
6
|
+
import applyChildSize from "../_internal/applyChildSize.mjs";
|
|
7
|
+
import applyGap from "../_internal/applyGap.mjs";
|
|
8
|
+
import mergeLayoutResults from "../_internal/mergeLayoutResults.mjs";
|
|
9
|
+
import maybeDefault from "@niche-works/utils/object/maybeDefault";
|
|
10
|
+
import clsx from "clsx";
|
|
11
|
+
|
|
12
|
+
//#region src/core/tile/tile.ts
|
|
13
|
+
/**
|
|
14
|
+
* tileレイアウト
|
|
15
|
+
*
|
|
16
|
+
* - 子要素の高さ・幅を基準にして格子状に並べる
|
|
17
|
+
* - 親要素のサイズが子要素に依存していないことを前提とする
|
|
18
|
+
*/
|
|
19
|
+
const tile = (options = {}) => {
|
|
20
|
+
const { direction, alignX, alignY, adjustX, adjustY, gap, gapX, gapY, childSizeX, childSizeY, childRatioX, childRatioY } = maybeDefault(options, {
|
|
21
|
+
direction: "x",
|
|
22
|
+
alignX: "left",
|
|
23
|
+
alignY: "top"
|
|
24
|
+
}, { overwriteNull: true });
|
|
25
|
+
const result = {
|
|
26
|
+
className: clsx(clsLayoutTile, clsLayoutDirection[direction], clsLayoutAlign.x[alignX], clsLayoutAlign.y[alignY], clsLayoutAdjust.x[adjustX], clsLayoutAdjust.y[adjustY]),
|
|
27
|
+
style: {}
|
|
28
|
+
};
|
|
29
|
+
applyGap(result, gap, gapX, gapY);
|
|
30
|
+
applyChildSize(result, childSizeX, childSizeY);
|
|
31
|
+
applyChildRatio(result, childRatioX, childRatioY);
|
|
32
|
+
return mergeLayoutResults([result, _getLayoutResultByDirection[direction](options)]);
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 並べる方向によるスタイル
|
|
36
|
+
*/
|
|
37
|
+
const _getLayoutResultByDirection = {
|
|
38
|
+
x: ({ adjustX, adjustY, childSizeX, childSizeY }) => {
|
|
39
|
+
return mergeLayoutResults([_getGridMainAxisTemplate(adjustX, childSizeX, varLayoutTemplateX), _getGridClossAxisAuto(adjustY, childSizeY, varLayoutAutoTracY)]);
|
|
40
|
+
},
|
|
41
|
+
y: ({ adjustX, adjustY, childSizeY, childSizeX }) => {
|
|
42
|
+
return mergeLayoutResults([_getGridClossAxisAuto(adjustX, childSizeX, varLayoutAutoTracX), _getGridMainAxisTemplate(adjustY, childSizeY, varLayoutTemplateY)]);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* direction方向の子要素のサイズを指定するためのテンプレート
|
|
47
|
+
* @param align 子要素の配置
|
|
48
|
+
* @param childSize 子要素のサイズ
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
function _getGridMainAxisTemplate(adjust, childSize, varName) {
|
|
52
|
+
const hasChildSize = hasValue(childSize);
|
|
53
|
+
const style = {};
|
|
54
|
+
if (adjust === "fit") if (hasChildSize) style[varName] = `repeat(auto-fit, minmax(clamp(0px, 100%, ${unit(childSize)}), 1fr))`;
|
|
55
|
+
else style[varName] = "repeat(auto-fit, minmax(0, 1fr))";
|
|
56
|
+
else if (adjust === "grow") if (hasChildSize) style[varName] = `repeat(auto-fit, minmax(${unit(childSize)}, 1fr))`;
|
|
57
|
+
else style[varName] = "repeat(auto-fit, minmax(0, 1fr))";
|
|
58
|
+
else if (adjust === "shrink") if (hasChildSize) style[varName] = `repeat(auto-fit, minmax(0, ${unit(childSize)}))`;
|
|
59
|
+
else style[varName] = "repeat(auto-fit, minmax(0, 1fr))";
|
|
60
|
+
else if (hasChildSize) style[varName] = `repeat(auto-fit, ${unit(childSize)})`;
|
|
61
|
+
else style[varName] = "repeat(auto-fit, minmax(max-content, 100%))";
|
|
62
|
+
return { style };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 交差軸方向
|
|
66
|
+
* @param adjust
|
|
67
|
+
* @param childSize
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
function _getGridClossAxisAuto(adjust, childSize, varName) {
|
|
71
|
+
const hasChildSize = hasValue(childSize);
|
|
72
|
+
const style = {};
|
|
73
|
+
if (adjust === "fit") if (hasChildSize) style[varName] = `minmax(0, 100%)`;
|
|
74
|
+
else style[varName] = `minmax(0, 100%)`;
|
|
75
|
+
else if (adjust === "grow") if (hasChildSize) style[varName] = `minmax(${unit(childSize)}, 100%)`;
|
|
76
|
+
else style[varName] = `minmax(auto, 100%)`;
|
|
77
|
+
else if (adjust === "shrink") if (hasChildSize) style[varName] = `minmax(0, ${unit(childSize)})`;
|
|
78
|
+
else style[varName] = `minmax(0, auto)`;
|
|
79
|
+
return { style };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
export { tile as default };
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AdjustOptions, AlignOptions, ChildRatioOptions, ChildSizeOptions, DirectionOptions, GapOptions } from "../_types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/tile/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* tileのオプション
|
|
6
|
+
*/
|
|
7
|
+
type TileLayoutOptions = DirectionOptions & AlignOptions & AdjustOptions & GapOptions & ChildSizeOptions & ChildRatioOptions;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { TileLayoutOptions };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AdjustOptions, AlignOptions, ChildRatioOptions, ChildSizeOptions, DirectionOptions, GapOptions } from "../_types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/tile/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* tileのオプション
|
|
6
|
+
*/
|
|
7
|
+
type TileLayoutOptions = DirectionOptions & AlignOptions & AdjustOptions & GapOptions & ChildSizeOptions & ChildRatioOptions;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { TileLayoutOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/core/types.cjs
ADDED
|
File without changes
|
package/core/types.d.cts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CSSCustomProperties } from "./_types.cjs";
|
|
2
|
+
import { LooseDictionary } from "@niche-works/types";
|
|
3
|
+
|
|
4
|
+
//#region src/core/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* レイアウトを作る関数
|
|
7
|
+
*/
|
|
8
|
+
type StyleLayout<O = LooseDictionary> = (options?: O) => StyleLayoutResult;
|
|
9
|
+
/**
|
|
10
|
+
* レイアウト
|
|
11
|
+
*/
|
|
12
|
+
type StyleLayoutResult = {
|
|
13
|
+
/**
|
|
14
|
+
* クラス
|
|
15
|
+
*/
|
|
16
|
+
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* スタイル
|
|
19
|
+
*/
|
|
20
|
+
style?: CSSCustomProperties;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { StyleLayout, StyleLayoutResult };
|
package/core/types.d.mts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CSSCustomProperties } from "./_types.mjs";
|
|
2
|
+
import { LooseDictionary } from "@niche-works/types";
|
|
3
|
+
|
|
4
|
+
//#region src/core/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* レイアウトを作る関数
|
|
7
|
+
*/
|
|
8
|
+
type StyleLayout<O = LooseDictionary> = (options?: O) => StyleLayoutResult;
|
|
9
|
+
/**
|
|
10
|
+
* レイアウト
|
|
11
|
+
*/
|
|
12
|
+
type StyleLayoutResult = {
|
|
13
|
+
/**
|
|
14
|
+
* クラス
|
|
15
|
+
*/
|
|
16
|
+
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* スタイル
|
|
19
|
+
*/
|
|
20
|
+
style?: CSSCustomProperties;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { StyleLayout, StyleLayoutResult };
|
package/core/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/flow/index.cjs
ADDED
package/flow/index.d.cts
ADDED
package/flow/index.d.mts
ADDED
package/flow/index.mjs
ADDED
package/index.cjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_core_balance_balance = require('./core/balance/balance.cjs');
|
|
3
|
+
const require_core_center_center = require('./core/center/center.cjs');
|
|
4
|
+
const require_core_flow_flow = require('./core/flow/flow.cjs');
|
|
5
|
+
const require_core_layer_layer = require('./core/layer/layer.cjs');
|
|
6
|
+
const require_core_matrix_matrix = require('./core/matrix/matrix.cjs');
|
|
7
|
+
const require_core_pack_pack = require('./core/pack/pack.cjs');
|
|
8
|
+
const require_core_pin_pin = require('./core/pin/pin.cjs');
|
|
9
|
+
const require_core_stack_stack = require('./core/stack/stack.cjs');
|
|
10
|
+
const require_core_tile_tile = require('./core/tile/tile.cjs');
|
|
11
|
+
|
|
12
|
+
exports.balance = require_core_balance_balance;
|
|
13
|
+
exports.center = require_core_center_center;
|
|
14
|
+
exports.flow = require_core_flow_flow;
|
|
15
|
+
exports.layer = require_core_layer_layer;
|
|
16
|
+
exports.matrix = require_core_matrix_matrix;
|
|
17
|
+
exports.pack = require_core_pack_pack;
|
|
18
|
+
exports.pin = require_core_pin_pin;
|
|
19
|
+
exports.stack = require_core_stack_stack;
|
|
20
|
+
exports.tile = require_core_tile_tile;
|
package/index.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { StyleLayout, StyleLayoutResult } from "./core/types.cjs";
|
|
2
|
+
import { BalanceLayoutOptions } from "./core/balance/types.cjs";
|
|
3
|
+
import balance from "./core/balance/balance.cjs";
|
|
4
|
+
import { CenterLayoutOptions } from "./core/center/types.cjs";
|
|
5
|
+
import center from "./core/center/center.cjs";
|
|
6
|
+
import { FlowLayoutOptions } from "./core/flow/types.cjs";
|
|
7
|
+
import flow from "./core/flow/flow.cjs";
|
|
8
|
+
import { LayerLayoutOptions } from "./core/layer/types.cjs";
|
|
9
|
+
import layer from "./core/layer/layer.cjs";
|
|
10
|
+
import { MatrixLayoutOptions } from "./core/matrix/types.cjs";
|
|
11
|
+
import matrix from "./core/matrix/matrix.cjs";
|
|
12
|
+
import { PackLayoutOptions } from "./core/pack/types.cjs";
|
|
13
|
+
import pack from "./core/pack/pack.cjs";
|
|
14
|
+
import { PinLayoutOptions } from "./core/pin/types.cjs";
|
|
15
|
+
import pin from "./core/pin/pin.cjs";
|
|
16
|
+
import { StackLayoutOptions } from "./core/stack/types.cjs";
|
|
17
|
+
import stack from "./core/stack/stack.cjs";
|
|
18
|
+
import { TileLayoutOptions } from "./core/tile/types.cjs";
|
|
19
|
+
import tile from "./core/tile/tile.cjs";
|
|
20
|
+
export { BalanceLayoutOptions, CenterLayoutOptions, FlowLayoutOptions, LayerLayoutOptions, MatrixLayoutOptions, PackLayoutOptions, PinLayoutOptions, StackLayoutOptions, StyleLayout, StyleLayoutResult, TileLayoutOptions, balance, center, flow, layer, matrix, pack, pin, stack, tile };
|
package/index.d.mts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { StyleLayout, StyleLayoutResult } from "./core/types.mjs";
|
|
2
|
+
import { BalanceLayoutOptions } from "./core/balance/types.mjs";
|
|
3
|
+
import balance from "./core/balance/balance.mjs";
|
|
4
|
+
import { CenterLayoutOptions } from "./core/center/types.mjs";
|
|
5
|
+
import center from "./core/center/center.mjs";
|
|
6
|
+
import { FlowLayoutOptions } from "./core/flow/types.mjs";
|
|
7
|
+
import flow from "./core/flow/flow.mjs";
|
|
8
|
+
import { LayerLayoutOptions } from "./core/layer/types.mjs";
|
|
9
|
+
import layer from "./core/layer/layer.mjs";
|
|
10
|
+
import { MatrixLayoutOptions } from "./core/matrix/types.mjs";
|
|
11
|
+
import matrix from "./core/matrix/matrix.mjs";
|
|
12
|
+
import { PackLayoutOptions } from "./core/pack/types.mjs";
|
|
13
|
+
import pack from "./core/pack/pack.mjs";
|
|
14
|
+
import { PinLayoutOptions } from "./core/pin/types.mjs";
|
|
15
|
+
import pin from "./core/pin/pin.mjs";
|
|
16
|
+
import { StackLayoutOptions } from "./core/stack/types.mjs";
|
|
17
|
+
import stack from "./core/stack/stack.mjs";
|
|
18
|
+
import { TileLayoutOptions } from "./core/tile/types.mjs";
|
|
19
|
+
import tile from "./core/tile/tile.mjs";
|
|
20
|
+
export { BalanceLayoutOptions, CenterLayoutOptions, FlowLayoutOptions, LayerLayoutOptions, MatrixLayoutOptions, PackLayoutOptions, PinLayoutOptions, StackLayoutOptions, StyleLayout, StyleLayoutResult, TileLayoutOptions, balance, center, flow, layer, matrix, pack, pin, stack, tile };
|
package/index.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import balance from "./core/balance/balance.mjs";
|
|
2
|
+
import center from "./core/center/center.mjs";
|
|
3
|
+
import flow from "./core/flow/flow.mjs";
|
|
4
|
+
import layer from "./core/layer/layer.mjs";
|
|
5
|
+
import matrix from "./core/matrix/matrix.mjs";
|
|
6
|
+
import pack from "./core/pack/pack.mjs";
|
|
7
|
+
import pin from "./core/pin/pin.mjs";
|
|
8
|
+
import stack from "./core/stack/stack.mjs";
|
|
9
|
+
import tile from "./core/tile/tile.mjs";
|
|
10
|
+
|
|
11
|
+
export { balance, center, flow, layer, matrix, pack, pin, stack, tile };
|
package/layer/index.cjs
ADDED
package/layer/index.mjs
ADDED
package/matrix/index.cjs
ADDED
package/matrix/index.mjs
ADDED
package/pack/index.cjs
ADDED
package/pack/index.d.cts
ADDED
package/pack/index.d.mts
ADDED
package/pack/index.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@niche-works/style-layouts",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"css",
|
|
6
|
+
"style",
|
|
7
|
+
"layout"
|
|
8
|
+
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/mitsuhiroseino/niche-works-style-layouts.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "Mitsuhiro Seino",
|
|
15
|
+
"sideEffects": [
|
|
16
|
+
"**/*.css"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./index.mjs",
|
|
22
|
+
"require": "./index.cjs"
|
|
23
|
+
},
|
|
24
|
+
"./*": {
|
|
25
|
+
"import": "./*/index.mjs",
|
|
26
|
+
"require": "./*/index.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./constants": {
|
|
29
|
+
"import": "./constants.mjs",
|
|
30
|
+
"require": "./constants.cjs"
|
|
31
|
+
},
|
|
32
|
+
"./core/*": {
|
|
33
|
+
"import": "./core/*/index.mjs",
|
|
34
|
+
"require": "./core/*/index.cjs"
|
|
35
|
+
},
|
|
36
|
+
"./core/constants": {
|
|
37
|
+
"import": "./core/constants.mjs",
|
|
38
|
+
"require": "./core/constants.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./core/styles.css": "./core/styles.css",
|
|
41
|
+
"./core/*.css": "./core/*/styles.css"
|
|
42
|
+
},
|
|
43
|
+
"main": "./index.cjs",
|
|
44
|
+
"module": "./index.mjs",
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@niche-works/types": "^0.3.1",
|
|
47
|
+
"@niche-works/utils": "^0.4.0",
|
|
48
|
+
"clsx": "^2.1.1",
|
|
49
|
+
"csstype": "^3.2.3"
|
|
50
|
+
}
|
|
51
|
+
}
|
package/pin/index.cjs
ADDED
package/pin/index.d.cts
ADDED
package/pin/index.d.mts
ADDED
package/pin/index.mjs
ADDED