@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,32 @@
1
+ import { clsLayoutBalance } from "../constants.mjs";
2
+ import { clsLayoutAdjust, clsLayoutAlign, clsLayoutDirection } from "../_constants.mjs";
3
+ import applyChildRatio from "../_internal/applyChildRatio.mjs";
4
+ import applyChildSize from "../_internal/applyChildSize.mjs";
5
+ import applyGap from "../_internal/applyGap.mjs";
6
+ import maybeDefault from "@niche-works/utils/object/maybeDefault";
7
+ import clsx from "clsx";
8
+
9
+ //#region src/core/balance/balance.ts
10
+ /**
11
+ * balanceレイアウト
12
+ *
13
+ * - 子要素を均等に配置する
14
+ */
15
+ const balance = (options = {}) => {
16
+ const { direction, alignX, alignY, adjustX, adjustY, gap, gapX, gapY, childSizeX, childSizeY, childRatioX, childRatioY } = maybeDefault(options, {
17
+ direction: "x",
18
+ alignX: "left",
19
+ alignY: "top"
20
+ }, { overwriteNull: true });
21
+ const result = {
22
+ className: clsx(clsLayoutBalance, clsLayoutDirection[direction], clsLayoutAlign.x[alignX], clsLayoutAlign.y[alignY], clsLayoutAdjust.x[adjustX], clsLayoutAdjust.y[adjustY]),
23
+ style: {}
24
+ };
25
+ applyGap(result, gap, gapX, gapY);
26
+ applyChildSize(result, childSizeX, childSizeY);
27
+ applyChildRatio(result, childRatioX, childRatioY);
28
+ return result;
29
+ };
30
+
31
+ //#endregion
32
+ export { balance as default };
@@ -0,0 +1,3 @@
1
+ const require_core_balance_balance = require('./balance.cjs');
2
+
3
+ module.exports = require_core_balance_balance;
@@ -0,0 +1,3 @@
1
+ import { BalanceLayoutOptions } from "./types.cjs";
2
+ import balance from "./balance.cjs";
3
+ export { BalanceLayoutOptions, balance as default };
@@ -0,0 +1,3 @@
1
+ import { BalanceLayoutOptions } from "./types.mjs";
2
+ import balance from "./balance.mjs";
3
+ export { BalanceLayoutOptions, balance as default };
@@ -0,0 +1,3 @@
1
+ import balance from "./balance.mjs";
2
+
3
+ export { balance as default };
@@ -0,0 +1,113 @@
1
+ .nws-layout-balance {
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: grid;
8
+ }
9
+ .nws-layout-balance.nws-layout-direction-x {
10
+ grid-auto-flow: column;
11
+ }
12
+ .nws-layout-balance.nws-layout-direction-y {
13
+ grid-auto-flow: row;
14
+ }
15
+ .nws-layout-balance.nws-layout-alignX-left {
16
+ justify-items: flex-start;
17
+ }
18
+ .nws-layout-balance.nws-layout-alignX-center {
19
+ justify-items: center;
20
+ }
21
+ .nws-layout-balance.nws-layout-alignX-right {
22
+ justify-items: flex-end;
23
+ }
24
+ .nws-layout-balance.nws-layout-alignX-spaceBetween {
25
+ justify-items: space-between;
26
+ }
27
+ .nws-layout-balance.nws-layout-alignX-spaceAround {
28
+ justify-items: space-around;
29
+ }
30
+ .nws-layout-balance.nws-layout-alignX-spaceEvenly {
31
+ justify-items: space-evenly;
32
+ }
33
+ .nws-layout-balance.nws-layout-alignY-top {
34
+ align-items: flex-start;
35
+ }
36
+ .nws-layout-balance.nws-layout-alignY-middle {
37
+ align-items: center;
38
+ }
39
+ .nws-layout-balance.nws-layout-alignY-bottom {
40
+ align-items: flex-end;
41
+ }
42
+ .nws-layout-balance.nws-layout-alignY-spaceBetween {
43
+ align-items: space-between;
44
+ }
45
+ .nws-layout-balance.nws-layout-alignY-spaceAround {
46
+ align-items: space-around;
47
+ }
48
+ .nws-layout-balance.nws-layout-alignY-spaceEvenly {
49
+ align-items: space-evenly;
50
+ }
51
+ .nws-layout-balance.nws-layout-childSizeX > * {
52
+ width: var(--nws-layout-childSizeX);
53
+ }
54
+ .nws-layout-balance.nws-layout-childSizeY > * {
55
+ height: var(--nws-layout-childSizeY);
56
+ }
57
+ .nws-layout-balance > * {
58
+ min-width: 0;
59
+ }
60
+ .nws-layout-balance.nws-layout-adjustX-fit {
61
+ justify-items: stretch;
62
+ }
63
+ .nws-layout-balance.nws-layout-adjustX-fit > * {
64
+ width: auto;
65
+ }
66
+ .nws-layout-balance.nws-layout-adjustX-fit.nws-layout-childSizeX > * {
67
+ width: auto;
68
+ }
69
+ .nws-layout-balance.nws-layout-adjustX-grow > * {
70
+ width: 100%;
71
+ }
72
+ .nws-layout-balance.nws-layout-adjustX-grow.nws-layout-childSizeX > * {
73
+ min-width: var(--nws-layout-childSizeX);
74
+ }
75
+ .nws-layout-balance.nws-layout-adjustX-shrink > * {
76
+ width: 100%;
77
+ }
78
+ .nws-layout-balance.nws-layout-adjustX-shrink.nws-layout-childSizeX > * {
79
+ max-width: var(--nws-layout-childSizeX);
80
+ }
81
+ .nws-layout-balance > * {
82
+ min-height: 0;
83
+ }
84
+ .nws-layout-balance.nws-layout-adjustY-fit {
85
+ align-items: stretch;
86
+ }
87
+ .nws-layout-balance.nws-layout-adjustY-fit > * {
88
+ height: auto;
89
+ }
90
+ .nws-layout-balance.nws-layout-adjustY-fit.nws-layout-childSizeY > * {
91
+ height: auto;
92
+ }
93
+ .nws-layout-balance.nws-layout-adjustY-grow > * {
94
+ height: 100%;
95
+ }
96
+ .nws-layout-balance.nws-layout-adjustY-grow.nws-layout-childSizeY > * {
97
+ min-height: var(--nws-layout-childSizeY);
98
+ }
99
+ .nws-layout-balance.nws-layout-adjustY-shrink > * {
100
+ height: 100%;
101
+ }
102
+ .nws-layout-balance.nws-layout-adjustY-shrink.nws-layout-childSizeY > * {
103
+ max-height: var(--nws-layout-childSizeY);
104
+ }
105
+ .nws-layout-balance.nws-layout-childRatio > * {
106
+ aspect-ratio: var(--nws-layout-childRatio);
107
+ }
108
+ .nws-layout-balance.nws-layout-gapX {
109
+ column-gap: var(--nws-layout-gapX);
110
+ }
111
+ .nws-layout-balance.nws-layout-gapY {
112
+ row-gap: var(--nws-layout-gapY);
113
+ }
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/balance/types.d.ts
5
+ /**
6
+ * balanceのオプション
7
+ *
8
+ * - `direction='x'` 時: `alignY` に `space-between`,`space-around`,`space-evenly` 指定不可
9
+ * - `direction='y'` 時: `alignX` に `space-between`,`space-around`,`space-evenly` 指定不可
10
+ */
11
+ type BalanceLayoutOptions = AdjustOptions & GapOptions & ChildSizeOptions & ChildRatioOptions & BalanceDirectionWithAlignOptions;
12
+ /**
13
+ * direction & alignのオプション
14
+ */
15
+ type BalanceDirectionWithAlignOptions = (DirectionOptions<'x'> & Omit<AlignOptions, 'alignY'> & {
16
+ alignY?: AlignYBase;
17
+ }) | (DirectionOptions<'y'> & Omit<AlignOptions, 'alignX'> & {
18
+ alignX?: AlignXBase;
19
+ });
20
+ //#endregion
21
+ export { BalanceLayoutOptions };
@@ -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/balance/types.d.ts
5
+ /**
6
+ * balanceのオプション
7
+ *
8
+ * - `direction='x'` 時: `alignY` に `space-between`,`space-around`,`space-evenly` 指定不可
9
+ * - `direction='y'` 時: `alignX` に `space-between`,`space-around`,`space-evenly` 指定不可
10
+ */
11
+ type BalanceLayoutOptions = AdjustOptions & GapOptions & ChildSizeOptions & ChildRatioOptions & BalanceDirectionWithAlignOptions;
12
+ /**
13
+ * direction & alignのオプション
14
+ */
15
+ type BalanceDirectionWithAlignOptions = (DirectionOptions<'x'> & Omit<AlignOptions, 'alignY'> & {
16
+ alignY?: AlignYBase;
17
+ }) | (DirectionOptions<'y'> & Omit<AlignOptions, 'alignX'> & {
18
+ alignX?: AlignXBase;
19
+ });
20
+ //#endregion
21
+ export { BalanceLayoutOptions };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,31 @@
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
+ const require_core_constants = require('../constants.cjs');
3
+ const require_core__constants = require('../_constants.cjs');
4
+ const require_core__internal_applyChildRatio = require('../_internal/applyChildRatio.cjs');
5
+ const require_core__internal_applyChildSize = require('../_internal/applyChildSize.cjs');
6
+ const require_core__internal_applyGap = require('../_internal/applyGap.cjs');
7
+ let _niche_works_utils_object_maybeDefault = require("@niche-works/utils/object/maybeDefault");
8
+ _niche_works_utils_object_maybeDefault = require_runtime.__toESM(_niche_works_utils_object_maybeDefault, 1);
9
+ let clsx = require("clsx");
10
+ clsx = require_runtime.__toESM(clsx, 1);
11
+
12
+ //#region src/core/center/center.ts
13
+ /**
14
+ * centerレイアウト
15
+ *
16
+ * - 子要素を中央に配置する
17
+ */
18
+ const center = (options = {}) => {
19
+ const { direction, adjustX, adjustY, gap, gapX, gapY, childSizeX, childSizeY, childRatioX, childRatioY } = (0, _niche_works_utils_object_maybeDefault.default)(options, { direction: "x" }, { overwriteNull: true });
20
+ const result = {
21
+ className: (0, clsx.default)(require_core_constants.clsLayoutCenter, require_core__constants.clsLayoutDirection[direction], require_core__constants.clsLayoutAdjust.x[adjustX], require_core__constants.clsLayoutAdjust.y[adjustY]),
22
+ style: {}
23
+ };
24
+ require_core__internal_applyGap(result, gap, gapX, gapY);
25
+ require_core__internal_applyChildSize(result, childSizeX, childSizeY);
26
+ require_core__internal_applyChildRatio(result, childRatioX, childRatioY);
27
+ return result;
28
+ };
29
+
30
+ //#endregion
31
+ module.exports = center;
@@ -0,0 +1,11 @@
1
+ import { StyleLayout } from "../types.cjs";
2
+ import { CenterLayoutOptions } from "./types.cjs";
3
+
4
+ //#region src/core/center/center.d.ts
5
+ /**
6
+ * centerレイアウト
7
+ *
8
+ * - 子要素を中央に配置する
9
+ */
10
+ declare const center: StyleLayout<CenterLayoutOptions>;
11
+ export = center;
@@ -0,0 +1,12 @@
1
+ import { StyleLayout } from "../types.mjs";
2
+ import { CenterLayoutOptions } from "./types.mjs";
3
+
4
+ //#region src/core/center/center.d.ts
5
+ /**
6
+ * centerレイアウト
7
+ *
8
+ * - 子要素を中央に配置する
9
+ */
10
+ declare const center: StyleLayout<CenterLayoutOptions>;
11
+ //#endregion
12
+ export { center as default };
@@ -0,0 +1,28 @@
1
+ import { clsLayoutCenter } from "../constants.mjs";
2
+ import { clsLayoutAdjust, clsLayoutDirection } from "../_constants.mjs";
3
+ import applyChildRatio from "../_internal/applyChildRatio.mjs";
4
+ import applyChildSize from "../_internal/applyChildSize.mjs";
5
+ import applyGap from "../_internal/applyGap.mjs";
6
+ import maybeDefault from "@niche-works/utils/object/maybeDefault";
7
+ import clsx from "clsx";
8
+
9
+ //#region src/core/center/center.ts
10
+ /**
11
+ * centerレイアウト
12
+ *
13
+ * - 子要素を中央に配置する
14
+ */
15
+ const center = (options = {}) => {
16
+ const { direction, adjustX, adjustY, gap, gapX, gapY, childSizeX, childSizeY, childRatioX, childRatioY } = maybeDefault(options, { direction: "x" }, { overwriteNull: true });
17
+ const result = {
18
+ className: clsx(clsLayoutCenter, clsLayoutDirection[direction], clsLayoutAdjust.x[adjustX], clsLayoutAdjust.y[adjustY]),
19
+ style: {}
20
+ };
21
+ applyGap(result, gap, gapX, gapY);
22
+ applyChildSize(result, childSizeX, childSizeY);
23
+ applyChildRatio(result, childRatioX, childRatioY);
24
+ return result;
25
+ };
26
+
27
+ //#endregion
28
+ export { center as default };
@@ -0,0 +1,3 @@
1
+ const require_core_center_center = require('./center.cjs');
2
+
3
+ module.exports = require_core_center_center;
@@ -0,0 +1,3 @@
1
+ import { CenterLayoutOptions } from "./types.cjs";
2
+ import center from "./center.cjs";
3
+ export { CenterLayoutOptions, center as default };
@@ -0,0 +1,3 @@
1
+ import { CenterLayoutOptions } from "./types.mjs";
2
+ import center from "./center.mjs";
3
+ export { CenterLayoutOptions, center as default };
@@ -0,0 +1,3 @@
1
+ import center from "./center.mjs";
2
+
3
+ export { center as default };
@@ -0,0 +1,166 @@
1
+ .nws-layout-center {
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
+ justify-content: safe center;
9
+ align-content: safe center;
10
+ align-items: flex-start;
11
+ flex-wrap: nowrap;
12
+ }
13
+ .nws-layout-center > * {
14
+ min-width: 0;
15
+ max-width: 100%;
16
+ min-height: 0;
17
+ max-height: 100%;
18
+ margin: 0;
19
+ }
20
+ .nws-layout-center.nws-layout-direction-x {
21
+ flex-direction: row;
22
+ }
23
+ .nws-layout-center.nws-layout-direction-x.nws-layout-childSizeX > * {
24
+ width: var(--nws-layout-childSizeX);
25
+ flex-basis: var(--nws-layout-childSizeX);
26
+ }
27
+ .nws-layout-center.nws-layout-direction-x > * {
28
+ max-width: none;
29
+ flex-grow: 0;
30
+ flex-shrink: 0;
31
+ }
32
+ .nws-layout-center.nws-layout-direction-x.nws-layout-adjustX-fit {
33
+ justify-content: stretch;
34
+ }
35
+ .nws-layout-center.nws-layout-direction-x.nws-layout-adjustX-fit > * {
36
+ width: 100%;
37
+ max-width: none;
38
+ flex-grow: 1;
39
+ flex-shrink: 1;
40
+ flex-basis: 0%;
41
+ }
42
+ .nws-layout-center.nws-layout-direction-x.nws-layout-adjustX-grow {
43
+ justify-content: stretch;
44
+ }
45
+ .nws-layout-center.nws-layout-direction-x.nws-layout-adjustX-grow > * {
46
+ width: 100%;
47
+ min-width: var(--nws-layout-childSizeX);
48
+ max-width: none;
49
+ flex-grow: 1;
50
+ flex-shrink: 0;
51
+ flex-basis: var(--nws-layout-childSizeX);
52
+ }
53
+ .nws-layout-center.nws-layout-direction-x.nws-layout-adjustX-shrink > * {
54
+ width: var(--nws-layout-childSizeX);
55
+ max-width: 100%;
56
+ flex-grow: 0;
57
+ flex-shrink: 1;
58
+ flex-basis: var(--nws-layout-childSizeX);
59
+ }
60
+ .nws-layout-center.nws-layout-direction-x.nws-layout-childSizeY > * {
61
+ height: var(--nws-layout-childSizeY);
62
+ }
63
+ .nws-layout-center.nws-layout-direction-x > * {
64
+ max-height: none;
65
+ margin-top: auto;
66
+ margin-bottom: auto;
67
+ }
68
+ .nws-layout-center.nws-layout-direction-x.nws-layout-adjustY-fit {
69
+ align-items: stretch;
70
+ }
71
+ .nws-layout-center.nws-layout-direction-x.nws-layout-adjustY-fit > * {
72
+ height: 100%;
73
+ max-height: none;
74
+ }
75
+ .nws-layout-center.nws-layout-direction-x.nws-layout-adjustY-grow {
76
+ align-items: stretch;
77
+ }
78
+ .nws-layout-center.nws-layout-direction-x.nws-layout-adjustY-grow > * {
79
+ height: 100%;
80
+ min-height: var(--nws-layout-childSizeY);
81
+ max-height: none;
82
+ }
83
+ .nws-layout-center.nws-layout-direction-x.nws-layout-adjustY-shrink > * {
84
+ height: var(--nws-layout-childSizeY);
85
+ max-height: 100%;
86
+ margin-top: auto;
87
+ margin-bottom: auto;
88
+ }
89
+ .nws-layout-center.nws-layout-direction-y {
90
+ flex-direction: column;
91
+ }
92
+ .nws-layout-center.nws-layout-direction-y.nws-layout-childSizeX > * {
93
+ width: var(--nws-layout-childSizeX);
94
+ }
95
+ .nws-layout-center.nws-layout-direction-y > * {
96
+ max-width: none;
97
+ margin-left: auto;
98
+ margin-right: auto;
99
+ }
100
+ .nws-layout-center.nws-layout-direction-y.nws-layout-adjustX-fit {
101
+ align-items: stretch;
102
+ }
103
+ .nws-layout-center.nws-layout-direction-y.nws-layout-adjustX-fit > * {
104
+ width: 100%;
105
+ max-width: none;
106
+ }
107
+ .nws-layout-center.nws-layout-direction-y.nws-layout-adjustX-grow {
108
+ align-items: stretch;
109
+ }
110
+ .nws-layout-center.nws-layout-direction-y.nws-layout-adjustX-grow > * {
111
+ width: 100%;
112
+ max-width: none;
113
+ min-width: var(--nws-layout-childSizeX);
114
+ }
115
+ .nws-layout-center.nws-layout-direction-y.nws-layout-adjustX-shrink > * {
116
+ width: var(--nws-layout-childSizeX);
117
+ max-width: 100%;
118
+ margin-left: auto;
119
+ margin-right: auto;
120
+ }
121
+ .nws-layout-center.nws-layout-direction-y.nws-layout-childSizeY > * {
122
+ height: var(--nws-layout-childSizeY);
123
+ flex-basis: var(--nws-layout-childSizeY);
124
+ }
125
+ .nws-layout-center.nws-layout-direction-y > * {
126
+ max-height: none;
127
+ flex-grow: 0;
128
+ flex-shrink: 0;
129
+ }
130
+ .nws-layout-center.nws-layout-direction-y.nws-layout-adjustY-fit {
131
+ justify-content: stretch;
132
+ }
133
+ .nws-layout-center.nws-layout-direction-y.nws-layout-adjustY-fit > * {
134
+ height: 100%;
135
+ max-height: none;
136
+ flex-grow: 1;
137
+ flex-shrink: 1;
138
+ flex-basis: 0%;
139
+ }
140
+ .nws-layout-center.nws-layout-direction-y.nws-layout-adjustY-grow {
141
+ justify-content: stretch;
142
+ }
143
+ .nws-layout-center.nws-layout-direction-y.nws-layout-adjustY-grow > * {
144
+ height: 100%;
145
+ min-height: var(--nws-layout-childSizeY);
146
+ max-height: none;
147
+ flex-grow: 1;
148
+ flex-shrink: 0;
149
+ flex-basis: var(--nws-layout-childSizeY);
150
+ }
151
+ .nws-layout-center.nws-layout-direction-y.nws-layout-adjustY-shrink > * {
152
+ height: var(--nws-layout-childSizeY);
153
+ max-height: 100%;
154
+ flex-grow: 0;
155
+ flex-shrink: 1;
156
+ flex-basis: var(--nws-layout-childSizeY);
157
+ }
158
+ .nws-layout-center.nws-layout-childRatio > * {
159
+ aspect-ratio: var(--nws-layout-childRatio);
160
+ }
161
+ .nws-layout-center.nws-layout-gapX {
162
+ column-gap: var(--nws-layout-gapX);
163
+ }
164
+ .nws-layout-center.nws-layout-gapY {
165
+ row-gap: var(--nws-layout-gapY);
166
+ }
File without changes
@@ -0,0 +1,9 @@
1
+ import { AdjustOptions, ChildRatioOptions, ChildSizeOptions, DirectionOptions, GapOptions } from "../_types.cjs";
2
+
3
+ //#region src/core/center/types.d.ts
4
+ /**
5
+ * centerのオプション
6
+ */
7
+ type CenterLayoutOptions = DirectionOptions & AdjustOptions & GapOptions & ChildSizeOptions & ChildRatioOptions;
8
+ //#endregion
9
+ export { CenterLayoutOptions };
@@ -0,0 +1,9 @@
1
+ import { AdjustOptions, ChildRatioOptions, ChildSizeOptions, DirectionOptions, GapOptions } from "../_types.mjs";
2
+
3
+ //#region src/core/center/types.d.ts
4
+ /**
5
+ * centerのオプション
6
+ */
7
+ type CenterLayoutOptions = DirectionOptions & AdjustOptions & GapOptions & ChildSizeOptions & ChildRatioOptions;
8
+ //#endregion
9
+ export { CenterLayoutOptions };
@@ -0,0 +1 @@
1
+ export { };