@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.
Files changed (227) hide show
  1. package/LICENSE +21 -0
  2. package/README.ja.md +320 -0
  3. package/README.md +320 -0
  4. package/_virtual/_rolldown/runtime.cjs +29 -0
  5. package/balance/index.cjs +4 -0
  6. package/balance/index.d.cts +3 -0
  7. package/balance/index.d.mts +3 -0
  8. package/balance/index.mjs +4 -0
  9. package/center/index.cjs +4 -0
  10. package/center/index.d.cts +3 -0
  11. package/center/index.d.mts +3 -0
  12. package/center/index.mjs +4 -0
  13. package/constants.cjs +59 -0
  14. package/constants.d.cts +2 -0
  15. package/constants.d.mts +2 -0
  16. package/constants.mjs +3 -0
  17. package/core/_constants.cjs +94 -0
  18. package/core/_constants.d.cts +83 -0
  19. package/core/_constants.d.mts +83 -0
  20. package/core/_constants.mjs +86 -0
  21. package/core/_internal/applyChildCount.cjs +26 -0
  22. package/core/_internal/applyChildCount.d.cts +11 -0
  23. package/core/_internal/applyChildCount.d.mts +12 -0
  24. package/core/_internal/applyChildCount.mjs +24 -0
  25. package/core/_internal/applyChildRatio.cjs +22 -0
  26. package/core/_internal/applyChildRatio.d.cts +11 -0
  27. package/core/_internal/applyChildRatio.d.mts +12 -0
  28. package/core/_internal/applyChildRatio.mjs +20 -0
  29. package/core/_internal/applyChildSize.cjs +27 -0
  30. package/core/_internal/applyChildSize.d.cts +11 -0
  31. package/core/_internal/applyChildSize.d.mts +12 -0
  32. package/core/_internal/applyChildSize.mjs +25 -0
  33. package/core/_internal/applyGap.cjs +30 -0
  34. package/core/_internal/applyGap.d.cts +12 -0
  35. package/core/_internal/applyGap.d.mts +13 -0
  36. package/core/_internal/applyGap.mjs +28 -0
  37. package/core/_internal/hasValue.cjs +15 -0
  38. package/core/_internal/hasValue.d.cts +8 -0
  39. package/core/_internal/hasValue.d.mts +9 -0
  40. package/core/_internal/hasValue.mjs +14 -0
  41. package/core/_internal/mergeLayoutResults.cjs +18 -0
  42. package/core/_internal/mergeLayoutResults.d.cts +5 -0
  43. package/core/_internal/mergeLayoutResults.d.mts +6 -0
  44. package/core/_internal/mergeLayoutResults.mjs +16 -0
  45. package/core/_internal/unit.cjs +16 -0
  46. package/core/_internal/unit.d.cts +10 -0
  47. package/core/_internal/unit.d.mts +11 -0
  48. package/core/_internal/unit.mjs +15 -0
  49. package/core/_internal/warnIfUnsupported.cjs +15 -0
  50. package/core/_internal/warnIfUnsupported.d.cts +3 -0
  51. package/core/_internal/warnIfUnsupported.d.mts +4 -0
  52. package/core/_internal/warnIfUnsupported.mjs +14 -0
  53. package/core/_styles.scss.cjs +1 -0
  54. package/core/_styles.scss.d.cts +1 -0
  55. package/core/_styles.scss.d.mts +1 -0
  56. package/core/_styles.scss.mjs +3 -0
  57. package/core/_types.cjs +0 -0
  58. package/core/_types.d.cts +123 -0
  59. package/core/_types.d.mts +123 -0
  60. package/core/_types.mjs +1 -0
  61. package/core/balance/balance.cjs +35 -0
  62. package/core/balance/balance.d.cts +11 -0
  63. package/core/balance/balance.d.mts +12 -0
  64. package/core/balance/balance.mjs +32 -0
  65. package/core/balance/index.cjs +3 -0
  66. package/core/balance/index.d.cts +3 -0
  67. package/core/balance/index.d.mts +3 -0
  68. package/core/balance/index.mjs +3 -0
  69. package/core/balance/styles.css +113 -0
  70. package/core/balance/types.cjs +0 -0
  71. package/core/balance/types.d.cts +21 -0
  72. package/core/balance/types.d.mts +21 -0
  73. package/core/balance/types.mjs +1 -0
  74. package/core/center/center.cjs +31 -0
  75. package/core/center/center.d.cts +11 -0
  76. package/core/center/center.d.mts +12 -0
  77. package/core/center/center.mjs +28 -0
  78. package/core/center/index.cjs +3 -0
  79. package/core/center/index.d.cts +3 -0
  80. package/core/center/index.d.mts +3 -0
  81. package/core/center/index.mjs +3 -0
  82. package/core/center/styles.css +166 -0
  83. package/core/center/types.cjs +0 -0
  84. package/core/center/types.d.cts +9 -0
  85. package/core/center/types.d.mts +9 -0
  86. package/core/center/types.mjs +1 -0
  87. package/core/constants.cjs +362 -0
  88. package/core/constants.d.cts +316 -0
  89. package/core/constants.d.mts +316 -0
  90. package/core/constants.mjs +305 -0
  91. package/core/flow/flow.cjs +71 -0
  92. package/core/flow/flow.d.cts +12 -0
  93. package/core/flow/flow.d.mts +13 -0
  94. package/core/flow/flow.mjs +68 -0
  95. package/core/flow/index.cjs +3 -0
  96. package/core/flow/index.d.cts +3 -0
  97. package/core/flow/index.d.mts +3 -0
  98. package/core/flow/index.mjs +3 -0
  99. package/core/flow/styles.css +166 -0
  100. package/core/flow/types.cjs +0 -0
  101. package/core/flow/types.d.cts +21 -0
  102. package/core/flow/types.d.mts +21 -0
  103. package/core/flow/types.mjs +1 -0
  104. package/core/index.cjs +20 -0
  105. package/core/index.d.cts +20 -0
  106. package/core/index.d.mts +20 -0
  107. package/core/index.mjs +11 -0
  108. package/core/layer/index.cjs +3 -0
  109. package/core/layer/index.d.cts +3 -0
  110. package/core/layer/index.d.mts +3 -0
  111. package/core/layer/index.mjs +3 -0
  112. package/core/layer/layer.cjs +34 -0
  113. package/core/layer/layer.d.cts +13 -0
  114. package/core/layer/layer.d.mts +14 -0
  115. package/core/layer/layer.mjs +31 -0
  116. package/core/layer/styles.css +64 -0
  117. package/core/layer/types.cjs +0 -0
  118. package/core/layer/types.d.cts +13 -0
  119. package/core/layer/types.d.mts +13 -0
  120. package/core/layer/types.mjs +1 -0
  121. package/core/matrix/index.cjs +3 -0
  122. package/core/matrix/index.d.cts +3 -0
  123. package/core/matrix/index.d.mts +3 -0
  124. package/core/matrix/index.mjs +3 -0
  125. package/core/matrix/matrix.cjs +110 -0
  126. package/core/matrix/matrix.d.cts +11 -0
  127. package/core/matrix/matrix.d.mts +12 -0
  128. package/core/matrix/matrix.mjs +107 -0
  129. package/core/matrix/styles.css +63 -0
  130. package/core/matrix/types.cjs +0 -0
  131. package/core/matrix/types.d.cts +46 -0
  132. package/core/matrix/types.d.mts +46 -0
  133. package/core/matrix/types.mjs +1 -0
  134. package/core/pack/index.cjs +3 -0
  135. package/core/pack/index.d.cts +3 -0
  136. package/core/pack/index.d.mts +3 -0
  137. package/core/pack/index.mjs +3 -0
  138. package/core/pack/pack.cjs +27 -0
  139. package/core/pack/pack.d.cts +11 -0
  140. package/core/pack/pack.d.mts +12 -0
  141. package/core/pack/pack.mjs +24 -0
  142. package/core/pack/styles.css +36 -0
  143. package/core/pack/types.cjs +0 -0
  144. package/core/pack/types.d.cts +6 -0
  145. package/core/pack/types.d.mts +6 -0
  146. package/core/pack/types.mjs +1 -0
  147. package/core/pin/index.cjs +3 -0
  148. package/core/pin/index.d.cts +3 -0
  149. package/core/pin/index.d.mts +3 -0
  150. package/core/pin/index.mjs +3 -0
  151. package/core/pin/pin.cjs +23 -0
  152. package/core/pin/pin.d.cts +11 -0
  153. package/core/pin/pin.d.mts +12 -0
  154. package/core/pin/pin.mjs +23 -0
  155. package/core/pin/styles.css +18 -0
  156. package/core/pin/types.cjs +0 -0
  157. package/core/pin/types.d.cts +6 -0
  158. package/core/pin/types.d.mts +6 -0
  159. package/core/pin/types.mjs +1 -0
  160. package/core/stack/index.cjs +3 -0
  161. package/core/stack/index.d.cts +3 -0
  162. package/core/stack/index.d.mts +3 -0
  163. package/core/stack/index.mjs +3 -0
  164. package/core/stack/stack.cjs +99 -0
  165. package/core/stack/stack.d.cts +11 -0
  166. package/core/stack/stack.d.mts +12 -0
  167. package/core/stack/stack.mjs +96 -0
  168. package/core/stack/styles.css +175 -0
  169. package/core/stack/types.cjs +0 -0
  170. package/core/stack/types.d.cts +21 -0
  171. package/core/stack/types.d.mts +21 -0
  172. package/core/stack/types.mjs +1 -0
  173. package/core/styles.css +917 -0
  174. package/core/tile/index.cjs +3 -0
  175. package/core/tile/index.d.cts +3 -0
  176. package/core/tile/index.d.mts +3 -0
  177. package/core/tile/index.mjs +3 -0
  178. package/core/tile/styles.css +108 -0
  179. package/core/tile/tile.cjs +86 -0
  180. package/core/tile/tile.d.cts +12 -0
  181. package/core/tile/tile.d.mts +13 -0
  182. package/core/tile/tile.mjs +83 -0
  183. package/core/tile/types.cjs +0 -0
  184. package/core/tile/types.d.cts +9 -0
  185. package/core/tile/types.d.mts +9 -0
  186. package/core/tile/types.mjs +1 -0
  187. package/core/types.cjs +0 -0
  188. package/core/types.d.cts +23 -0
  189. package/core/types.d.mts +23 -0
  190. package/core/types.mjs +1 -0
  191. package/flow/index.cjs +4 -0
  192. package/flow/index.d.cts +3 -0
  193. package/flow/index.d.mts +3 -0
  194. package/flow/index.mjs +4 -0
  195. package/index.cjs +20 -0
  196. package/index.d.cts +20 -0
  197. package/index.d.mts +20 -0
  198. package/index.mjs +11 -0
  199. package/layer/index.cjs +4 -0
  200. package/layer/index.d.cts +3 -0
  201. package/layer/index.d.mts +3 -0
  202. package/layer/index.mjs +4 -0
  203. package/matrix/index.cjs +4 -0
  204. package/matrix/index.d.cts +3 -0
  205. package/matrix/index.d.mts +3 -0
  206. package/matrix/index.mjs +4 -0
  207. package/pack/index.cjs +4 -0
  208. package/pack/index.d.cts +3 -0
  209. package/pack/index.d.mts +3 -0
  210. package/pack/index.mjs +4 -0
  211. package/package.json +51 -0
  212. package/pin/index.cjs +4 -0
  213. package/pin/index.d.cts +3 -0
  214. package/pin/index.d.mts +3 -0
  215. package/pin/index.mjs +4 -0
  216. package/stack/index.cjs +4 -0
  217. package/stack/index.d.cts +3 -0
  218. package/stack/index.d.mts +3 -0
  219. package/stack/index.mjs +4 -0
  220. package/tile/index.cjs +4 -0
  221. package/tile/index.d.cts +3 -0
  222. package/tile/index.d.mts +3 -0
  223. package/tile/index.mjs +4 -0
  224. package/types.cjs +0 -0
  225. package/types.d.cts +2 -0
  226. package/types.d.mts +2 -0
  227. package/types.mjs +1 -0
@@ -0,0 +1,18 @@
1
+ .nws-layout-pin {
2
+ --nws-layout-childSizeX: auto;
3
+ --nws-layout-childSizeY: auto;
4
+ display: block;
5
+ position: relative;
6
+ }
7
+ .nws-layout-pin > * {
8
+ position: absolute;
9
+ }
10
+ .nws-layout-pin.nws-layout-childSizeX > * {
11
+ width: var(--nws-layout-childSizeX);
12
+ }
13
+ .nws-layout-pin.nws-layout-childSizeY > * {
14
+ height: var(--nws-layout-childSizeY);
15
+ }
16
+ .nws-layout-pin.nws-layout-childRatio > * {
17
+ aspect-ratio: var(--nws-layout-childRatio);
18
+ }
File without changes
@@ -0,0 +1,6 @@
1
+ import { ChildRatioOptions, ChildSizeOptions } from "../_types.cjs";
2
+
3
+ //#region src/core/pin/types.d.ts
4
+ type PinLayoutOptions = ChildSizeOptions & ChildRatioOptions;
5
+ //#endregion
6
+ export { PinLayoutOptions };
@@ -0,0 +1,6 @@
1
+ import { ChildRatioOptions, ChildSizeOptions } from "../_types.mjs";
2
+
3
+ //#region src/core/pin/types.d.ts
4
+ type PinLayoutOptions = ChildSizeOptions & ChildRatioOptions;
5
+ //#endregion
6
+ export { PinLayoutOptions };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,3 @@
1
+ const require_core_stack_stack = require('./stack.cjs');
2
+
3
+ module.exports = require_core_stack_stack;
@@ -0,0 +1,3 @@
1
+ import { StackLayoutOptions } from "./types.cjs";
2
+ import stack from "./stack.cjs";
3
+ export { StackLayoutOptions, stack as default };
@@ -0,0 +1,3 @@
1
+ import { StackLayoutOptions } from "./types.mjs";
2
+ import stack from "./stack.mjs";
3
+ export { StackLayoutOptions, stack as default };
@@ -0,0 +1,3 @@
1
+ import stack from "./stack.mjs";
2
+
3
+ export { stack as default };
@@ -0,0 +1,99 @@
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_applyGap = require('../_internal/applyGap.cjs');
8
+ const require_core__internal_mergeLayoutResults = require('../_internal/mergeLayoutResults.cjs');
9
+ let _niche_works_utils_object_maybeDefault = require("@niche-works/utils/object/maybeDefault");
10
+ _niche_works_utils_object_maybeDefault = require_runtime.__toESM(_niche_works_utils_object_maybeDefault, 1);
11
+ let clsx = require("clsx");
12
+ clsx = require_runtime.__toESM(clsx, 1);
13
+
14
+ //#region src/core/stack/stack.ts
15
+ /**
16
+ * stackレイアウト
17
+ *
18
+ * - 子要素を並べて配置する
19
+ */
20
+ const stack = (options = {}) => {
21
+ const { direction, alignX, alignY, adjustX, adjustY, gap, gapX = gap, gapY = gap, childSizeX, childSizeY, childRatioX, childRatioY } = (0, _niche_works_utils_object_maybeDefault.default)(options, {
22
+ direction: "x",
23
+ alignX: "left",
24
+ alignY: "top"
25
+ }, { overwriteNull: true });
26
+ const result = {
27
+ className: (0, clsx.default)(require_core_constants.clsLayoutStack, require_core__constants.clsLayoutDirection[direction], require_core__constants.clsLayoutAlign.x[alignX], require_core__constants.clsLayoutAlign.y[alignY]),
28
+ style: {}
29
+ };
30
+ require_core__internal_applyGap(result, gap, gapX, gapY);
31
+ require_core__internal_applyChildRatio(result, childRatioX, childRatioY);
32
+ const resultList = [result];
33
+ if (direction === "x") {
34
+ resultList.push(_getStackMainAxisStyle("x", alignX, adjustX, childSizeX));
35
+ resultList.push(_getStackClossAxisStyle("y", alignY, adjustY, childSizeY));
36
+ } else {
37
+ resultList.push(_getStackClossAxisStyle("x", alignX, adjustX, childSizeX));
38
+ resultList.push(_getStackMainAxisStyle("y", alignY, adjustY, childSizeY));
39
+ }
40
+ return require_core__internal_mergeLayoutResults(resultList);
41
+ };
42
+ /**
43
+ * 主軸方向のスタイル
44
+ * @param axis 横 or 縦
45
+ * @param align 位置
46
+ * @param adjust 子要素のサイズの調整
47
+ * @param childSize 子要素のサイズ
48
+ * @returns スタイル
49
+ */
50
+ function _getStackMainAxisStyle(axis, align, adjust, childSize) {
51
+ const result = { className: (0, clsx.default)(require_core__constants.clsLayoutAlign[axis][align], require_core__constants.clsLayoutAdjust[axis][adjust]) };
52
+ if (require_core__internal_hasValue(childSize)) {
53
+ result.className = (0, clsx.default)(result.className, require_core__constants.clsLayoutChildSize[axis]);
54
+ result.style = { [require_core__constants.varLayoutChildSize[axis]]: require_core__internal_unit(childSize) };
55
+ }
56
+ return result;
57
+ }
58
+ /**
59
+ * 交差軸方向のクラス
60
+ * @param axis 横 or 縦
61
+ * @param align 位置
62
+ * @param adjust 子要素のサイズの調整
63
+ * @param childSize 子要素のサイズ
64
+ * @returns スタイル
65
+ */
66
+ function _getStackClossAxisStyle(axis, align, adjust, childSize) {
67
+ if (adjust === "fit") return {
68
+ className: (0, clsx.default)(require_core__constants.clsLayoutAlign[axis][align], require_core__constants.clsLayoutAdjust[axis][adjust]),
69
+ style: {
70
+ [`min-${require_core__constants.cssLayoutAxisSizeProp[axis]}`]: "100%",
71
+ [require_core__constants.varLayoutChildSize[axis]]: `min(0, 100%)`
72
+ }
73
+ };
74
+ else if (adjust === "grow") {
75
+ const result = {
76
+ className: (0, clsx.default)(require_core__constants.clsLayoutAlign[axis][align], require_core__constants.clsLayoutAdjust[axis][adjust]),
77
+ style: { [`min-${require_core__constants.cssLayoutAxisSizeProp[axis]}`]: "100%" }
78
+ };
79
+ if (require_core__internal_hasValue(childSize)) {
80
+ result.className = (0, clsx.default)(result.className, require_core__constants.clsLayoutChildSize[axis]);
81
+ result.style[require_core__constants.varLayoutChildSize[axis]] = require_core__internal_unit(childSize);
82
+ }
83
+ return result;
84
+ } else if (adjust === "shrink") {
85
+ const result = { className: (0, clsx.default)(require_core__constants.clsLayoutAlign[axis][align], require_core__constants.clsLayoutAdjust[axis][adjust]) };
86
+ if (require_core__internal_hasValue(childSize)) {
87
+ result.className = (0, clsx.default)(result.className, require_core__constants.clsLayoutChildSize[axis]);
88
+ result.style = { [require_core__constants.varLayoutChildSize[axis]]: `min(${require_core__internal_unit(childSize)}, 100%)` };
89
+ }
90
+ return result;
91
+ } else if (require_core__internal_hasValue(childSize)) return {
92
+ className: (0, clsx.default)(require_core__constants.clsLayoutAlign[axis][align], require_core__constants.clsLayoutChildSize[axis]),
93
+ style: { [require_core__constants.varLayoutChildSize[axis]]: require_core__internal_unit(childSize) }
94
+ };
95
+ else return { className: (0, clsx.default)(require_core__constants.clsLayoutAlign[axis][align]) };
96
+ }
97
+
98
+ //#endregion
99
+ module.exports = stack;
@@ -0,0 +1,11 @@
1
+ import { StyleLayout } from "../types.cjs";
2
+ import { StackLayoutOptions } from "./types.cjs";
3
+
4
+ //#region src/core/stack/stack.d.ts
5
+ /**
6
+ * stackレイアウト
7
+ *
8
+ * - 子要素を並べて配置する
9
+ */
10
+ declare const stack: StyleLayout<StackLayoutOptions>;
11
+ export = stack;
@@ -0,0 +1,12 @@
1
+ import { StyleLayout } from "../types.mjs";
2
+ import { StackLayoutOptions } from "./types.mjs";
3
+
4
+ //#region src/core/stack/stack.d.ts
5
+ /**
6
+ * stackレイアウト
7
+ *
8
+ * - 子要素を並べて配置する
9
+ */
10
+ declare const stack: StyleLayout<StackLayoutOptions>;
11
+ //#endregion
12
+ export { stack as default };
@@ -0,0 +1,96 @@
1
+ import { clsLayoutStack } from "../constants.mjs";
2
+ import { clsLayoutAdjust, clsLayoutAlign, clsLayoutChildSize, clsLayoutDirection, cssLayoutAxisSizeProp, varLayoutChildSize } 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 applyGap from "../_internal/applyGap.mjs";
7
+ import mergeLayoutResults from "../_internal/mergeLayoutResults.mjs";
8
+ import maybeDefault from "@niche-works/utils/object/maybeDefault";
9
+ import clsx from "clsx";
10
+
11
+ //#region src/core/stack/stack.ts
12
+ /**
13
+ * stackレイアウト
14
+ *
15
+ * - 子要素を並べて配置する
16
+ */
17
+ const stack = (options = {}) => {
18
+ const { direction, alignX, alignY, adjustX, adjustY, gap, gapX = gap, gapY = gap, childSizeX, childSizeY, childRatioX, childRatioY } = maybeDefault(options, {
19
+ direction: "x",
20
+ alignX: "left",
21
+ alignY: "top"
22
+ }, { overwriteNull: true });
23
+ const result = {
24
+ className: clsx(clsLayoutStack, clsLayoutDirection[direction], clsLayoutAlign.x[alignX], clsLayoutAlign.y[alignY]),
25
+ style: {}
26
+ };
27
+ applyGap(result, gap, gapX, gapY);
28
+ applyChildRatio(result, childRatioX, childRatioY);
29
+ const resultList = [result];
30
+ if (direction === "x") {
31
+ resultList.push(_getStackMainAxisStyle("x", alignX, adjustX, childSizeX));
32
+ resultList.push(_getStackClossAxisStyle("y", alignY, adjustY, childSizeY));
33
+ } else {
34
+ resultList.push(_getStackClossAxisStyle("x", alignX, adjustX, childSizeX));
35
+ resultList.push(_getStackMainAxisStyle("y", alignY, adjustY, childSizeY));
36
+ }
37
+ return mergeLayoutResults(resultList);
38
+ };
39
+ /**
40
+ * 主軸方向のスタイル
41
+ * @param axis 横 or 縦
42
+ * @param align 位置
43
+ * @param adjust 子要素のサイズの調整
44
+ * @param childSize 子要素のサイズ
45
+ * @returns スタイル
46
+ */
47
+ function _getStackMainAxisStyle(axis, align, adjust, childSize) {
48
+ const result = { className: clsx(clsLayoutAlign[axis][align], clsLayoutAdjust[axis][adjust]) };
49
+ if (hasValue(childSize)) {
50
+ result.className = clsx(result.className, clsLayoutChildSize[axis]);
51
+ result.style = { [varLayoutChildSize[axis]]: unit(childSize) };
52
+ }
53
+ return result;
54
+ }
55
+ /**
56
+ * 交差軸方向のクラス
57
+ * @param axis 横 or 縦
58
+ * @param align 位置
59
+ * @param adjust 子要素のサイズの調整
60
+ * @param childSize 子要素のサイズ
61
+ * @returns スタイル
62
+ */
63
+ function _getStackClossAxisStyle(axis, align, adjust, childSize) {
64
+ if (adjust === "fit") return {
65
+ className: clsx(clsLayoutAlign[axis][align], clsLayoutAdjust[axis][adjust]),
66
+ style: {
67
+ [`min-${cssLayoutAxisSizeProp[axis]}`]: "100%",
68
+ [varLayoutChildSize[axis]]: `min(0, 100%)`
69
+ }
70
+ };
71
+ else if (adjust === "grow") {
72
+ const result = {
73
+ className: clsx(clsLayoutAlign[axis][align], clsLayoutAdjust[axis][adjust]),
74
+ style: { [`min-${cssLayoutAxisSizeProp[axis]}`]: "100%" }
75
+ };
76
+ if (hasValue(childSize)) {
77
+ result.className = clsx(result.className, clsLayoutChildSize[axis]);
78
+ result.style[varLayoutChildSize[axis]] = unit(childSize);
79
+ }
80
+ return result;
81
+ } else if (adjust === "shrink") {
82
+ const result = { className: clsx(clsLayoutAlign[axis][align], clsLayoutAdjust[axis][adjust]) };
83
+ if (hasValue(childSize)) {
84
+ result.className = clsx(result.className, clsLayoutChildSize[axis]);
85
+ result.style = { [varLayoutChildSize[axis]]: `min(${unit(childSize)}, 100%)` };
86
+ }
87
+ return result;
88
+ } else if (hasValue(childSize)) return {
89
+ className: clsx(clsLayoutAlign[axis][align], clsLayoutChildSize[axis]),
90
+ style: { [varLayoutChildSize[axis]]: unit(childSize) }
91
+ };
92
+ else return { className: clsx(clsLayoutAlign[axis][align]) };
93
+ }
94
+
95
+ //#endregion
96
+ export { stack as default };
@@ -0,0 +1,175 @@
1
+ .nws-layout-stack {
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
+ display: flex;
8
+ }
9
+ .nws-layout-stack.nws-layout-direction-x {
10
+ flex-direction: row;
11
+ }
12
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-alignX-left {
13
+ justify-content: flex-start;
14
+ }
15
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-alignX-center {
16
+ justify-content: center;
17
+ }
18
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-alignX-right {
19
+ justify-content: flex-end;
20
+ }
21
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-alignX-spaceBetween {
22
+ justify-content: space-between;
23
+ }
24
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-alignX-spaceAround {
25
+ justify-content: space-around;
26
+ }
27
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-alignX-spaceEvenly {
28
+ justify-content: space-evenly;
29
+ }
30
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-alignY-top {
31
+ align-items: flex-start;
32
+ }
33
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-alignY-middle {
34
+ align-items: center;
35
+ }
36
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-alignY-bottom {
37
+ align-items: flex-end;
38
+ }
39
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-childSizeX > * {
40
+ flex-basis: var(--nws-layout-childSizeX);
41
+ }
42
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-childSizeY > * {
43
+ height: var(--nws-layout-childSizeY);
44
+ }
45
+ .nws-layout-stack.nws-layout-direction-x > * {
46
+ flex-grow: 0;
47
+ flex-shrink: 0;
48
+ min-width: 0;
49
+ }
50
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-adjustX-fit {
51
+ justify-content: flex-start;
52
+ }
53
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-adjustX-fit > * {
54
+ flex-grow: 1;
55
+ flex-shrink: 1;
56
+ flex-basis: auto;
57
+ min-width: 0;
58
+ }
59
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-adjustX-fit.nws-layout-childSizeX > * {
60
+ flex-basis: var(--nws-layout-childSizeX);
61
+ }
62
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-adjustX-grow > * {
63
+ flex-grow: 1;
64
+ }
65
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-adjustX-shrink > * {
66
+ flex-shrink: 1;
67
+ }
68
+ .nws-layout-stack.nws-layout-direction-x > * {
69
+ min-height: 0;
70
+ }
71
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-adjustY-fit {
72
+ align-items: stretch;
73
+ }
74
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-adjustY-fit > * {
75
+ min-height: 100%;
76
+ max-height: 100%;
77
+ }
78
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-adjustY-fit.nws-layout-childSizeY > * {
79
+ height: auto;
80
+ }
81
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-adjustY-grow > * {
82
+ min-height: 100%;
83
+ }
84
+ .nws-layout-stack.nws-layout-direction-x.nws-layout-adjustY-shrink > * {
85
+ min-height: 0;
86
+ max-height: 100%;
87
+ }
88
+ .nws-layout-stack.nws-layout-direction-y {
89
+ flex-direction: column;
90
+ }
91
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-alignX-left {
92
+ align-items: flex-start;
93
+ }
94
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-alignX-center {
95
+ align-items: center;
96
+ }
97
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-alignX-right {
98
+ align-items: flex-end;
99
+ }
100
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-alignY-top {
101
+ justify-content: flex-start;
102
+ }
103
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-alignY-middle {
104
+ justify-content: center;
105
+ }
106
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-alignY-bottom {
107
+ justify-content: flex-end;
108
+ }
109
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-alignY-spaceBetween {
110
+ justify-content: space-between;
111
+ }
112
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-alignY-spaceAround {
113
+ justify-content: space-around;
114
+ }
115
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-alignY-spaceEvenly {
116
+ justify-content: space-evenly;
117
+ }
118
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-childSizeX > * {
119
+ width: var(--nws-layout-childSizeX);
120
+ }
121
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-childSizeY > * {
122
+ flex-basis: var(--nws-layout-childSizeY);
123
+ }
124
+ .nws-layout-stack.nws-layout-direction-y > * {
125
+ min-width: 0;
126
+ }
127
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-adjustX-fit {
128
+ align-items: stretch;
129
+ }
130
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-adjustX-fit > * {
131
+ min-width: 100%;
132
+ max-width: 100%;
133
+ }
134
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-adjustX-fit.nws-layout-childSizeX > * {
135
+ width: auto;
136
+ }
137
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-adjustX-grow > * {
138
+ min-width: 100%;
139
+ }
140
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-adjustX-shrink > * {
141
+ min-width: 0;
142
+ max-width: 100%;
143
+ }
144
+ .nws-layout-stack.nws-layout-direction-y > * {
145
+ flex-grow: 0;
146
+ flex-shrink: 0;
147
+ min-height: 0;
148
+ }
149
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-adjustY-fit {
150
+ justify-content: flex-start;
151
+ }
152
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-adjustY-fit > * {
153
+ flex-grow: 1;
154
+ flex-shrink: 1;
155
+ flex-basis: auto;
156
+ min-height: 0;
157
+ }
158
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-adjustY-fit.nws-layout-childSizeY > * {
159
+ flex-basis: var(--nws-layout-childSizeY);
160
+ }
161
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-adjustY-grow > * {
162
+ flex-grow: 1;
163
+ }
164
+ .nws-layout-stack.nws-layout-direction-y.nws-layout-adjustY-shrink > * {
165
+ flex-shrink: 1;
166
+ }
167
+ .nws-layout-stack.nws-layout-childRatio > * {
168
+ aspect-ratio: var(--nws-layout-childRatio);
169
+ }
170
+ .nws-layout-stack.nws-layout-gapX {
171
+ column-gap: var(--nws-layout-gapX);
172
+ }
173
+ .nws-layout-stack.nws-layout-gapY {
174
+ row-gap: var(--nws-layout-gapY);
175
+ }
File without changes
@@ -0,0 +1,21 @@
1
+ import { AlignXBase, AlignYBase } from "../constants.cjs";
2
+ import { AdjustOptions, AlignOptions, ChildRatioOptions, ChildSizeOptions, DirectionOptions, GapOptions } from "../_types.cjs";
3
+
4
+ //#region src/core/stack/types.d.ts
5
+ /**
6
+ * stackのオプション
7
+ *
8
+ * - `direction='x'` 時: `alignY` に `space-between`,`space-around`,`space-evenly` 指定不可
9
+ * - `direction='y'` 時: `alignX` に `space-between`,`space-around`,`space-evenly` 指定不可
10
+ */
11
+ type StackLayoutOptions = AdjustOptions & ChildSizeOptions & ChildRatioOptions & GapOptions & StackDirectionWithAlignOptions;
12
+ /**
13
+ * direction & alignのオプション
14
+ */
15
+ type StackDirectionWithAlignOptions = (DirectionOptions<'x'> & Omit<AlignOptions, 'alignY'> & {
16
+ alignY?: AlignYBase;
17
+ }) | (DirectionOptions<'y'> & Omit<AlignOptions, 'alignX'> & {
18
+ alignX?: AlignXBase;
19
+ });
20
+ //#endregion
21
+ export { StackLayoutOptions };
@@ -0,0 +1,21 @@
1
+ import { AlignXBase, AlignYBase } from "../constants.mjs";
2
+ import { AdjustOptions, AlignOptions, ChildRatioOptions, ChildSizeOptions, DirectionOptions, GapOptions } from "../_types.mjs";
3
+
4
+ //#region src/core/stack/types.d.ts
5
+ /**
6
+ * stackのオプション
7
+ *
8
+ * - `direction='x'` 時: `alignY` に `space-between`,`space-around`,`space-evenly` 指定不可
9
+ * - `direction='y'` 時: `alignX` に `space-between`,`space-around`,`space-evenly` 指定不可
10
+ */
11
+ type StackLayoutOptions = AdjustOptions & ChildSizeOptions & ChildRatioOptions & GapOptions & StackDirectionWithAlignOptions;
12
+ /**
13
+ * direction & alignのオプション
14
+ */
15
+ type StackDirectionWithAlignOptions = (DirectionOptions<'x'> & Omit<AlignOptions, 'alignY'> & {
16
+ alignY?: AlignYBase;
17
+ }) | (DirectionOptions<'y'> & Omit<AlignOptions, 'alignX'> & {
18
+ alignX?: AlignXBase;
19
+ });
20
+ //#endregion
21
+ export { StackLayoutOptions };
@@ -0,0 +1 @@
1
+ export { };