@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,13 @@
1
+ import { StyleLayout } from "../types.mjs";
2
+ import { FlowLayoutOptions } from "./types.mjs";
3
+
4
+ //#region src/core/flow/flow.d.ts
5
+ /**
6
+ * flowレイアウト
7
+ *
8
+ * - 子要素を並べて配置し、親要素のサイズに達したら折り返す
9
+ * - stackとの違いは flex-wrap: wrap が常に有効な点
10
+ */
11
+ declare const flow: StyleLayout<FlowLayoutOptions>;
12
+ //#endregion
13
+ export { flow as default };
@@ -0,0 +1,68 @@
1
+ import { clsLayoutFlow } from "../constants.mjs";
2
+ import { clsLayoutAdjust, clsLayoutAlign, clsLayoutChildSize, clsLayoutDirection, 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/flow/flow.ts
12
+ /**
13
+ * flowレイアウト
14
+ *
15
+ * - 子要素を並べて配置し、親要素のサイズに達したら折り返す
16
+ * - stackとの違いは flex-wrap: wrap が常に有効な点
17
+ */
18
+ const flow = (options = {}) => {
19
+ const { direction, alignX, alignY, adjustX, adjustY, gap, gapX = gap, gapY = gap, childSizeX, childSizeY, childRatioX, childRatioY } = maybeDefault(options, {
20
+ direction: "x",
21
+ alignX: "left",
22
+ alignY: "top"
23
+ }, { overwriteNull: true });
24
+ const result = {
25
+ className: clsx(clsLayoutFlow, clsLayoutDirection[direction], clsLayoutAlign.x[alignX], clsLayoutAlign.y[alignY]),
26
+ style: {}
27
+ };
28
+ applyGap(result, gap, gapX, gapY);
29
+ applyChildRatio(result, childRatioX, childRatioY);
30
+ const resultList = [result];
31
+ if (direction === "x") {
32
+ resultList.push(_getFlowMainAxisStyle("x", alignX, adjustX, childSizeX));
33
+ resultList.push(_getFlowCrossAxisStyle("y", alignY, childSizeY));
34
+ } else {
35
+ resultList.push(_getFlowCrossAxisStyle("x", alignX, childSizeX));
36
+ resultList.push(_getFlowMainAxisStyle("y", alignY, adjustY, childSizeY));
37
+ }
38
+ return mergeLayoutResults(resultList);
39
+ };
40
+ /**
41
+ * 主軸方向のスタイル
42
+ *
43
+ * stackの _getStackMainAxisStyle に相当。flowでは主軸の挙動はstackと同じ。
44
+ */
45
+ function _getFlowMainAxisStyle(axis, align, adjust, childSize) {
46
+ const result = { className: clsx(clsLayoutAlign[axis][align], clsLayoutAdjust[axis][adjust]) };
47
+ if (hasValue(childSize)) {
48
+ result.className = clsx(result.className, clsLayoutChildSize[axis]);
49
+ result.style = { [varLayoutChildSize[axis]]: unit(childSize) };
50
+ }
51
+ return result;
52
+ }
53
+ /**
54
+ * 交差軸方向のスタイル
55
+ *
56
+ * stackの _getStackClossAxisStyle に相当。
57
+ * flowは交差軸方向のadjustはできないため、常にnoneのスタイルを返す
58
+ */
59
+ function _getFlowCrossAxisStyle(axis, align, childSize) {
60
+ if (hasValue(childSize)) return {
61
+ className: clsx(clsLayoutAlign[axis][align], clsLayoutChildSize[axis]),
62
+ style: { [varLayoutChildSize[axis]]: unit(childSize) }
63
+ };
64
+ else return { className: clsLayoutAlign[axis][align] };
65
+ }
66
+
67
+ //#endregion
68
+ export { flow as default };
@@ -0,0 +1,3 @@
1
+ const require_core_flow_flow = require('./flow.cjs');
2
+
3
+ module.exports = require_core_flow_flow;
@@ -0,0 +1,3 @@
1
+ import { FlowLayoutOptions } from "./types.cjs";
2
+ import flow from "./flow.cjs";
3
+ export { FlowLayoutOptions, flow as default };
@@ -0,0 +1,3 @@
1
+ import { FlowLayoutOptions } from "./types.mjs";
2
+ import flow from "./flow.mjs";
3
+ export { FlowLayoutOptions, flow as default };
@@ -0,0 +1,3 @@
1
+ import flow from "./flow.mjs";
2
+
3
+ export { flow as default };
@@ -0,0 +1,166 @@
1
+ .nws-layout-flow {
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
+ flex-wrap: wrap;
9
+ }
10
+ .nws-layout-flow.nws-layout-direction-x {
11
+ flex-direction: row;
12
+ }
13
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-alignX-left {
14
+ justify-content: flex-start;
15
+ }
16
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-alignX-center {
17
+ justify-content: center;
18
+ }
19
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-alignX-right {
20
+ justify-content: flex-end;
21
+ }
22
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-alignX-spaceBetween {
23
+ justify-content: space-between;
24
+ }
25
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-alignX-spaceAround {
26
+ justify-content: space-around;
27
+ }
28
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-alignX-spaceEvenly {
29
+ justify-content: space-evenly;
30
+ }
31
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-alignY-top {
32
+ align-items: flex-start;
33
+ align-content: flex-start;
34
+ }
35
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-alignY-middle {
36
+ align-items: center;
37
+ align-content: center;
38
+ }
39
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-alignY-bottom {
40
+ align-items: flex-end;
41
+ align-content: flex-end;
42
+ }
43
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-alignY-spaceBetween {
44
+ align-content: space-between;
45
+ }
46
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-alignY-spaceAround {
47
+ align-content: space-around;
48
+ }
49
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-alignY-spaceEvenly {
50
+ align-content: space-evenly;
51
+ }
52
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-childSizeX > * {
53
+ flex-basis: var(--nws-layout-childSizeX);
54
+ }
55
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-childSizeY > * {
56
+ height: var(--nws-layout-childSizeY);
57
+ }
58
+ .nws-layout-flow.nws-layout-direction-x > * {
59
+ flex-grow: 0;
60
+ flex-shrink: 0;
61
+ min-width: 0;
62
+ }
63
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-adjustX-fit {
64
+ justify-content: flex-start;
65
+ }
66
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-adjustX-fit > * {
67
+ flex-grow: 1;
68
+ flex-shrink: 1;
69
+ flex-basis: auto;
70
+ min-width: 0;
71
+ }
72
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-adjustX-fit.nws-layout-childSizeX > * {
73
+ flex-basis: var(--nws-layout-childSizeX);
74
+ }
75
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-adjustX-grow > * {
76
+ flex-grow: 1;
77
+ }
78
+ .nws-layout-flow.nws-layout-direction-x.nws-layout-adjustX-shrink > * {
79
+ flex-shrink: 1;
80
+ }
81
+ .nws-layout-flow.nws-layout-direction-x > * {
82
+ min-height: 0;
83
+ }
84
+ .nws-layout-flow.nws-layout-direction-y {
85
+ flex-direction: column;
86
+ }
87
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-alignX-left {
88
+ align-items: flex-start;
89
+ align-content: flex-start;
90
+ }
91
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-alignX-center {
92
+ align-items: center;
93
+ align-content: center;
94
+ }
95
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-alignX-right {
96
+ align-items: flex-end;
97
+ align-content: flex-end;
98
+ }
99
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-alignX-spaceBetween {
100
+ align-content: space-between;
101
+ }
102
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-alignX-spaceAround {
103
+ align-content: space-around;
104
+ }
105
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-alignX-spaceEvenly {
106
+ align-content: space-evenly;
107
+ }
108
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-alignY-top {
109
+ justify-content: flex-start;
110
+ }
111
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-alignY-middle {
112
+ justify-content: center;
113
+ }
114
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-alignY-bottom {
115
+ justify-content: flex-end;
116
+ }
117
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-alignY-spaceBetween {
118
+ justify-content: space-between;
119
+ }
120
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-alignY-spaceAround {
121
+ justify-content: space-around;
122
+ }
123
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-alignY-spaceEvenly {
124
+ justify-content: space-evenly;
125
+ }
126
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-childSizeX > * {
127
+ width: var(--nws-layout-childSizeX);
128
+ }
129
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-childSizeY > * {
130
+ flex-basis: var(--nws-layout-childSizeY);
131
+ }
132
+ .nws-layout-flow.nws-layout-direction-y > * {
133
+ min-width: 0;
134
+ }
135
+ .nws-layout-flow.nws-layout-direction-y > * {
136
+ flex-grow: 0;
137
+ flex-shrink: 0;
138
+ min-height: 0;
139
+ }
140
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-adjustY-fit {
141
+ justify-content: flex-start;
142
+ }
143
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-adjustY-fit > * {
144
+ flex-grow: 1;
145
+ flex-shrink: 1;
146
+ flex-basis: auto;
147
+ min-height: 0;
148
+ }
149
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-adjustY-fit.nws-layout-childSizeY > * {
150
+ flex-basis: var(--nws-layout-childSizeY);
151
+ }
152
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-adjustY-grow > * {
153
+ flex-grow: 1;
154
+ }
155
+ .nws-layout-flow.nws-layout-direction-y.nws-layout-adjustY-shrink > * {
156
+ flex-shrink: 1;
157
+ }
158
+ .nws-layout-flow.nws-layout-childRatio > * {
159
+ aspect-ratio: var(--nws-layout-childRatio);
160
+ }
161
+ .nws-layout-flow.nws-layout-gapX {
162
+ column-gap: var(--nws-layout-gapX);
163
+ }
164
+ .nws-layout-flow.nws-layout-gapY {
165
+ row-gap: var(--nws-layout-gapY);
166
+ }
File without changes
@@ -0,0 +1,21 @@
1
+ import { AdjustBase } from "../constants.cjs";
2
+ import { AdjustOptions, AlignOptions, ChildRatioOptions, ChildSizeOptions, DirectionOptions, GapOptions } from "../_types.cjs";
3
+
4
+ //#region src/core/flow/types.d.ts
5
+ /**
6
+ * flowのオプション
7
+ *
8
+ * - `direction='x'` 時: `adjustY` に `fit`,`grow`,`shrink` 指定不可
9
+ * - `direction='y'` 時: `adjustX` に `fit`,`grow`,`shrink` 指定不可
10
+ */
11
+ type FlowLayoutOptions = AlignOptions & GapOptions & ChildSizeOptions & ChildRatioOptions & FlowDirectionWithAdjustOptions;
12
+ /**
13
+ * direction & adjustのオプション
14
+ */
15
+ type FlowDirectionWithAdjustOptions = (DirectionOptions<'x'> & Omit<AdjustOptions, 'adjustY'> & {
16
+ adjustY?: AdjustBase;
17
+ }) | (DirectionOptions<'y'> & Omit<AdjustOptions, 'adjustX'> & {
18
+ adjustX?: AdjustBase;
19
+ });
20
+ //#endregion
21
+ export { FlowLayoutOptions };
@@ -0,0 +1,21 @@
1
+ import { AdjustBase } from "../constants.mjs";
2
+ import { AdjustOptions, AlignOptions, ChildRatioOptions, ChildSizeOptions, DirectionOptions, GapOptions } from "../_types.mjs";
3
+
4
+ //#region src/core/flow/types.d.ts
5
+ /**
6
+ * flowのオプション
7
+ *
8
+ * - `direction='x'` 時: `adjustY` に `fit`,`grow`,`shrink` 指定不可
9
+ * - `direction='y'` 時: `adjustX` に `fit`,`grow`,`shrink` 指定不可
10
+ */
11
+ type FlowLayoutOptions = AlignOptions & GapOptions & ChildSizeOptions & ChildRatioOptions & FlowDirectionWithAdjustOptions;
12
+ /**
13
+ * direction & adjustのオプション
14
+ */
15
+ type FlowDirectionWithAdjustOptions = (DirectionOptions<'x'> & Omit<AdjustOptions, 'adjustY'> & {
16
+ adjustY?: AdjustBase;
17
+ }) | (DirectionOptions<'y'> & Omit<AdjustOptions, 'adjustX'> & {
18
+ adjustX?: AdjustBase;
19
+ });
20
+ //#endregion
21
+ export { FlowLayoutOptions };
@@ -0,0 +1 @@
1
+ export { };
package/core/index.cjs ADDED
@@ -0,0 +1,20 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_core_balance_balance = require('./balance/balance.cjs');
3
+ const require_core_center_center = require('./center/center.cjs');
4
+ const require_core_flow_flow = require('./flow/flow.cjs');
5
+ const require_core_layer_layer = require('./layer/layer.cjs');
6
+ const require_core_matrix_matrix = require('./matrix/matrix.cjs');
7
+ const require_core_pack_pack = require('./pack/pack.cjs');
8
+ const require_core_pin_pin = require('./pin/pin.cjs');
9
+ const require_core_stack_stack = require('./stack/stack.cjs');
10
+ const require_core_tile_tile = require('./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;
@@ -0,0 +1,20 @@
1
+ import { StyleLayout, StyleLayoutResult } from "./types.cjs";
2
+ import { BalanceLayoutOptions } from "./balance/types.cjs";
3
+ import balance from "./balance/balance.cjs";
4
+ import { CenterLayoutOptions } from "./center/types.cjs";
5
+ import center from "./center/center.cjs";
6
+ import { FlowLayoutOptions } from "./flow/types.cjs";
7
+ import flow from "./flow/flow.cjs";
8
+ import { LayerLayoutOptions } from "./layer/types.cjs";
9
+ import layer from "./layer/layer.cjs";
10
+ import { MatrixLayoutOptions } from "./matrix/types.cjs";
11
+ import matrix from "./matrix/matrix.cjs";
12
+ import { PackLayoutOptions } from "./pack/types.cjs";
13
+ import pack from "./pack/pack.cjs";
14
+ import { PinLayoutOptions } from "./pin/types.cjs";
15
+ import pin from "./pin/pin.cjs";
16
+ import { StackLayoutOptions } from "./stack/types.cjs";
17
+ import stack from "./stack/stack.cjs";
18
+ import { TileLayoutOptions } from "./tile/types.cjs";
19
+ import tile from "./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 };
@@ -0,0 +1,20 @@
1
+ import { StyleLayout, StyleLayoutResult } from "./types.mjs";
2
+ import { BalanceLayoutOptions } from "./balance/types.mjs";
3
+ import balance from "./balance/balance.mjs";
4
+ import { CenterLayoutOptions } from "./center/types.mjs";
5
+ import center from "./center/center.mjs";
6
+ import { FlowLayoutOptions } from "./flow/types.mjs";
7
+ import flow from "./flow/flow.mjs";
8
+ import { LayerLayoutOptions } from "./layer/types.mjs";
9
+ import layer from "./layer/layer.mjs";
10
+ import { MatrixLayoutOptions } from "./matrix/types.mjs";
11
+ import matrix from "./matrix/matrix.mjs";
12
+ import { PackLayoutOptions } from "./pack/types.mjs";
13
+ import pack from "./pack/pack.mjs";
14
+ import { PinLayoutOptions } from "./pin/types.mjs";
15
+ import pin from "./pin/pin.mjs";
16
+ import { StackLayoutOptions } from "./stack/types.mjs";
17
+ import stack from "./stack/stack.mjs";
18
+ import { TileLayoutOptions } from "./tile/types.mjs";
19
+ import tile from "./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/core/index.mjs ADDED
@@ -0,0 +1,11 @@
1
+ import balance from "./balance/balance.mjs";
2
+ import center from "./center/center.mjs";
3
+ import flow from "./flow/flow.mjs";
4
+ import layer from "./layer/layer.mjs";
5
+ import matrix from "./matrix/matrix.mjs";
6
+ import pack from "./pack/pack.mjs";
7
+ import pin from "./pin/pin.mjs";
8
+ import stack from "./stack/stack.mjs";
9
+ import tile from "./tile/tile.mjs";
10
+
11
+ export { balance, center, flow, layer, matrix, pack, pin, stack, tile };
@@ -0,0 +1,3 @@
1
+ const require_core_layer_layer = require('./layer.cjs');
2
+
3
+ module.exports = require_core_layer_layer;
@@ -0,0 +1,3 @@
1
+ import { LayerLayoutOptions } from "./types.cjs";
2
+ import layer from "./layer.cjs";
3
+ export { LayerLayoutOptions, layer as default };
@@ -0,0 +1,3 @@
1
+ import { LayerLayoutOptions } from "./types.mjs";
2
+ import layer from "./layer.mjs";
3
+ export { LayerLayoutOptions, layer as default };
@@ -0,0 +1,3 @@
1
+ import layer from "./layer.mjs";
2
+
3
+ export { layer as default };
@@ -0,0 +1,34 @@
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
+ const require_core_constants = require('../constants.cjs');
3
+ const require_core__constants = require('../_constants.cjs');
4
+ const require_core__internal_applyChildRatio = require('../_internal/applyChildRatio.cjs');
5
+ const require_core__internal_applyChildSize = require('../_internal/applyChildSize.cjs');
6
+ let _niche_works_utils_object_maybeDefault = require("@niche-works/utils/object/maybeDefault");
7
+ _niche_works_utils_object_maybeDefault = require_runtime.__toESM(_niche_works_utils_object_maybeDefault, 1);
8
+ let clsx = require("clsx");
9
+ clsx = require_runtime.__toESM(clsx, 1);
10
+
11
+ //#region src/core/layer/layer.ts
12
+ /**
13
+ * layerレイアウト
14
+ *
15
+ * - 子要素を重ねて配置する
16
+ * - alignX / alignY で重なる位置を制御する
17
+ * - 子要素の重なり順はDOM順に従う
18
+ */
19
+ const layer = (options = {}) => {
20
+ const { alignX, alignY, adjustX, adjustY, childSizeX, childSizeY, childRatioX, childRatioY } = (0, _niche_works_utils_object_maybeDefault.default)(options, {
21
+ alignX: "left",
22
+ alignY: "top"
23
+ }, { overwriteNull: true });
24
+ const result = {
25
+ className: (0, clsx.default)(require_core_constants.clsLayoutLayer, require_core__constants.clsLayoutAlign.x[alignX], require_core__constants.clsLayoutAlign.y[alignY], require_core__constants.clsLayoutAdjust.x[adjustX], require_core__constants.clsLayoutAdjust.y[adjustY]),
26
+ style: {}
27
+ };
28
+ require_core__internal_applyChildSize(result, childSizeX, childSizeY);
29
+ require_core__internal_applyChildRatio(result, childRatioX, childRatioY);
30
+ return result;
31
+ };
32
+
33
+ //#endregion
34
+ module.exports = layer;
@@ -0,0 +1,13 @@
1
+ import { StyleLayout } from "../types.cjs";
2
+ import { LayerLayoutOptions } from "./types.cjs";
3
+
4
+ //#region src/core/layer/layer.d.ts
5
+ /**
6
+ * layerレイアウト
7
+ *
8
+ * - 子要素を重ねて配置する
9
+ * - alignX / alignY で重なる位置を制御する
10
+ * - 子要素の重なり順はDOM順に従う
11
+ */
12
+ declare const layer: StyleLayout<LayerLayoutOptions>;
13
+ export = layer;
@@ -0,0 +1,14 @@
1
+ import { StyleLayout } from "../types.mjs";
2
+ import { LayerLayoutOptions } from "./types.mjs";
3
+
4
+ //#region src/core/layer/layer.d.ts
5
+ /**
6
+ * layerレイアウト
7
+ *
8
+ * - 子要素を重ねて配置する
9
+ * - alignX / alignY で重なる位置を制御する
10
+ * - 子要素の重なり順はDOM順に従う
11
+ */
12
+ declare const layer: StyleLayout<LayerLayoutOptions>;
13
+ //#endregion
14
+ export { layer as default };
@@ -0,0 +1,31 @@
1
+ import { clsLayoutLayer } from "../constants.mjs";
2
+ import { clsLayoutAdjust, clsLayoutAlign } from "../_constants.mjs";
3
+ import applyChildRatio from "../_internal/applyChildRatio.mjs";
4
+ import applyChildSize from "../_internal/applyChildSize.mjs";
5
+ import maybeDefault from "@niche-works/utils/object/maybeDefault";
6
+ import clsx from "clsx";
7
+
8
+ //#region src/core/layer/layer.ts
9
+ /**
10
+ * layerレイアウト
11
+ *
12
+ * - 子要素を重ねて配置する
13
+ * - alignX / alignY で重なる位置を制御する
14
+ * - 子要素の重なり順はDOM順に従う
15
+ */
16
+ const layer = (options = {}) => {
17
+ const { alignX, alignY, adjustX, adjustY, childSizeX, childSizeY, childRatioX, childRatioY } = maybeDefault(options, {
18
+ alignX: "left",
19
+ alignY: "top"
20
+ }, { overwriteNull: true });
21
+ const result = {
22
+ className: clsx(clsLayoutLayer, clsLayoutAlign.x[alignX], clsLayoutAlign.y[alignY], clsLayoutAdjust.x[adjustX], clsLayoutAdjust.y[adjustY]),
23
+ style: {}
24
+ };
25
+ applyChildSize(result, childSizeX, childSizeY);
26
+ applyChildRatio(result, childRatioX, childRatioY);
27
+ return result;
28
+ };
29
+
30
+ //#endregion
31
+ export { layer as default };
@@ -0,0 +1,64 @@
1
+ .nws-layout-layer {
2
+ --nws-layout-childSizeX: auto;
3
+ --nws-layout-childSizeY: auto;
4
+ --nws-layout-childRatio: auto;
5
+ display: grid;
6
+ }
7
+ .nws-layout-layer > * {
8
+ grid-area: 1/1;
9
+ }
10
+ .nws-layout-layer.nws-layout-alignX-left > * {
11
+ justify-self: start;
12
+ }
13
+ .nws-layout-layer.nws-layout-alignX-center > * {
14
+ justify-self: center;
15
+ }
16
+ .nws-layout-layer.nws-layout-alignX-right > * {
17
+ justify-self: end;
18
+ }
19
+ .nws-layout-layer.nws-layout-alignY-top > * {
20
+ align-self: start;
21
+ }
22
+ .nws-layout-layer.nws-layout-alignY-middle > * {
23
+ align-self: center;
24
+ }
25
+ .nws-layout-layer.nws-layout-alignY-bottom > * {
26
+ align-self: end;
27
+ }
28
+ .nws-layout-layer.nws-layout-childSizeX > * {
29
+ width: var(--nws-layout-childSizeX);
30
+ }
31
+ .nws-layout-layer.nws-layout-childSizeY > * {
32
+ height: var(--nws-layout-childSizeY);
33
+ }
34
+ .nws-layout-layer.nws-layout-adjustX-fit > * {
35
+ justify-self: stretch;
36
+ width: auto;
37
+ }
38
+ .nws-layout-layer.nws-layout-adjustX-grow > * {
39
+ justify-self: stretch;
40
+ width: auto;
41
+ min-width: var(--nws-layout-childSizeX);
42
+ }
43
+ .nws-layout-layer.nws-layout-adjustX-shrink > * {
44
+ width: clamp(0px, 100%, var(--nws-layout-childSizeX));
45
+ min-width: 0;
46
+ max-width: 100%;
47
+ }
48
+ .nws-layout-layer.nws-layout-adjustY-fit > * {
49
+ align-self: stretch;
50
+ height: auto;
51
+ }
52
+ .nws-layout-layer.nws-layout-adjustY-grow > * {
53
+ align-self: stretch;
54
+ height: auto;
55
+ min-height: var(--nws-layout-childSizeY);
56
+ }
57
+ .nws-layout-layer.nws-layout-adjustY-shrink > * {
58
+ height: clamp(0px, 100%, var(--nws-layout-childSizeY));
59
+ min-height: 0;
60
+ max-height: 100%;
61
+ }
62
+ .nws-layout-layer.nws-layout-childRatio > * {
63
+ aspect-ratio: var(--nws-layout-childRatio);
64
+ }
File without changes
@@ -0,0 +1,13 @@
1
+ import { AlignXBase, AlignYBase } from "../constants.cjs";
2
+ import { AdjustOptions, ChildRatioOptions, ChildSizeOptions } from "../_types.cjs";
3
+
4
+ //#region src/core/layer/types.d.ts
5
+ /**
6
+ * layerのオプション
7
+ */
8
+ type LayerLayoutOptions = AdjustOptions & ChildSizeOptions & ChildRatioOptions & {
9
+ alignX?: AlignXBase;
10
+ alignY?: AlignYBase;
11
+ };
12
+ //#endregion
13
+ export { LayerLayoutOptions };
@@ -0,0 +1,13 @@
1
+ import { AlignXBase, AlignYBase } from "../constants.mjs";
2
+ import { AdjustOptions, ChildRatioOptions, ChildSizeOptions } from "../_types.mjs";
3
+
4
+ //#region src/core/layer/types.d.ts
5
+ /**
6
+ * layerのオプション
7
+ */
8
+ type LayerLayoutOptions = AdjustOptions & ChildSizeOptions & ChildRatioOptions & {
9
+ alignX?: AlignXBase;
10
+ alignY?: AlignYBase;
11
+ };
12
+ //#endregion
13
+ export { LayerLayoutOptions };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,3 @@
1
+ const require_core_matrix_matrix = require('./matrix.cjs');
2
+
3
+ module.exports = require_core_matrix_matrix;
@@ -0,0 +1,3 @@
1
+ import { MatrixLayoutOptions } from "./types.cjs";
2
+ import matrix from "./matrix.cjs";
3
+ export { MatrixLayoutOptions, matrix as default };
@@ -0,0 +1,3 @@
1
+ import { MatrixLayoutOptions } from "./types.mjs";
2
+ import matrix from "./matrix.mjs";
3
+ export { MatrixLayoutOptions, matrix as default };
@@ -0,0 +1,3 @@
1
+ import matrix from "./matrix.mjs";
2
+
3
+ export { matrix as default };