@fringeworks/react-layouts 0.8.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 (220) hide show
  1. package/LICENSE +21 -0
  2. package/README.ja.md +234 -0
  3. package/README.md +236 -0
  4. package/_internal/_constants.cjs +27 -0
  5. package/_internal/_constants.d.cts +7 -0
  6. package/_internal/_constants.d.mts +7 -0
  7. package/_internal/_constants.mjs +25 -0
  8. package/_internal/applyLayout/applyLayout.cjs +26 -0
  9. package/_internal/applyLayout/applyLayout.d.cts +13 -0
  10. package/_internal/applyLayout/applyLayout.d.mts +14 -0
  11. package/_internal/applyLayout/applyLayout.mjs +24 -0
  12. package/_internal/applyLayout/index.cjs +3 -0
  13. package/_internal/applyLayout/index.d.cts +3 -0
  14. package/_internal/applyLayout/index.d.mts +3 -0
  15. package/_internal/applyLayout/index.mjs +3 -0
  16. package/_internal/applyLayout/types.cjs +0 -0
  17. package/_internal/applyLayout/types.d.cts +37 -0
  18. package/_internal/applyLayout/types.d.mts +37 -0
  19. package/_internal/applyLayout/types.mjs +1 -0
  20. package/_internal/withLayoutBase/index.cjs +3 -0
  21. package/_internal/withLayoutBase/index.d.cts +3 -0
  22. package/_internal/withLayoutBase/index.d.mts +3 -0
  23. package/_internal/withLayoutBase/index.mjs +3 -0
  24. package/_internal/withLayoutBase/types.cjs +0 -0
  25. package/_internal/withLayoutBase/types.d.cts +43 -0
  26. package/_internal/withLayoutBase/types.d.mts +43 -0
  27. package/_internal/withLayoutBase/types.mjs +1 -0
  28. package/_internal/withLayoutBase/withLayoutBase.cjs +50 -0
  29. package/_internal/withLayoutBase/withLayoutBase.d.cts +13 -0
  30. package/_internal/withLayoutBase/withLayoutBase.d.mts +14 -0
  31. package/_internal/withLayoutBase/withLayoutBase.mjs +47 -0
  32. package/_virtual/_rolldown/runtime.cjs +43 -0
  33. package/_virtual/_rolldown/runtime.mjs +18 -0
  34. package/constants.cjs +57 -0
  35. package/constants.d.cts +20 -0
  36. package/constants.d.mts +20 -0
  37. package/constants.mjs +20 -0
  38. package/css/balance.css +171 -0
  39. package/css/center.css +189 -0
  40. package/css/flow.css +205 -0
  41. package/css/layer.css +72 -0
  42. package/css/matrix.css +184 -0
  43. package/css/pack.css +42 -0
  44. package/css/pin.css +23 -0
  45. package/css/stack.css +216 -0
  46. package/css/styles.css +1346 -0
  47. package/css/tile.css +236 -0
  48. package/index.cjs +61 -0
  49. package/index.d.cts +22 -0
  50. package/index.d.mts +22 -0
  51. package/index.mjs +13 -0
  52. package/package.json +56 -0
  53. package/with-css/index.cjs +68 -0
  54. package/with-css/index.d.cts +23 -0
  55. package/with-css/index.d.mts +23 -0
  56. package/with-css/index.mjs +14 -0
  57. package/with-css/styles.cjs +14 -0
  58. package/with-css/styles.d.cts +2 -0
  59. package/with-css/styles.d.mts +2 -0
  60. package/with-css/styles.mjs +8 -0
  61. package/with-css/withBalanceLayout/index.cjs +4 -0
  62. package/with-css/withBalanceLayout/index.d.cts +3 -0
  63. package/with-css/withBalanceLayout/index.d.mts +3 -0
  64. package/with-css/withBalanceLayout/index.mjs +4 -0
  65. package/with-css/withCenterLayout/index.cjs +4 -0
  66. package/with-css/withCenterLayout/index.d.cts +3 -0
  67. package/with-css/withCenterLayout/index.d.mts +3 -0
  68. package/with-css/withCenterLayout/index.mjs +4 -0
  69. package/with-css/withFlowLayout/index.cjs +4 -0
  70. package/with-css/withFlowLayout/index.d.cts +3 -0
  71. package/with-css/withFlowLayout/index.d.mts +3 -0
  72. package/with-css/withFlowLayout/index.mjs +4 -0
  73. package/with-css/withLayerLayout/index.cjs +4 -0
  74. package/with-css/withLayerLayout/index.d.cts +3 -0
  75. package/with-css/withLayerLayout/index.d.mts +3 -0
  76. package/with-css/withLayerLayout/index.mjs +4 -0
  77. package/with-css/withLayout/index.cjs +4 -0
  78. package/with-css/withLayout/index.d.cts +3 -0
  79. package/with-css/withLayout/index.d.mts +3 -0
  80. package/with-css/withLayout/index.mjs +4 -0
  81. package/with-css/withMatrixLayout/index.cjs +4 -0
  82. package/with-css/withMatrixLayout/index.d.cts +3 -0
  83. package/with-css/withMatrixLayout/index.d.mts +3 -0
  84. package/with-css/withMatrixLayout/index.mjs +4 -0
  85. package/with-css/withPackLayout/index.cjs +4 -0
  86. package/with-css/withPackLayout/index.d.cts +3 -0
  87. package/with-css/withPackLayout/index.d.mts +3 -0
  88. package/with-css/withPackLayout/index.mjs +4 -0
  89. package/with-css/withPinLayout/index.cjs +4 -0
  90. package/with-css/withPinLayout/index.d.cts +3 -0
  91. package/with-css/withPinLayout/index.d.mts +3 -0
  92. package/with-css/withPinLayout/index.mjs +4 -0
  93. package/with-css/withStackLayout/index.cjs +4 -0
  94. package/with-css/withStackLayout/index.d.cts +3 -0
  95. package/with-css/withStackLayout/index.d.mts +3 -0
  96. package/with-css/withStackLayout/index.mjs +4 -0
  97. package/with-css/withTileLayout/index.cjs +4 -0
  98. package/with-css/withTileLayout/index.d.cts +3 -0
  99. package/with-css/withTileLayout/index.d.mts +3 -0
  100. package/with-css/withTileLayout/index.mjs +4 -0
  101. package/withBalanceLayout/index.cjs +3 -0
  102. package/withBalanceLayout/index.d.cts +3 -0
  103. package/withBalanceLayout/index.d.mts +3 -0
  104. package/withBalanceLayout/index.mjs +3 -0
  105. package/withBalanceLayout/types.cjs +0 -0
  106. package/withBalanceLayout/types.d.cts +10 -0
  107. package/withBalanceLayout/types.d.mts +10 -0
  108. package/withBalanceLayout/types.mjs +1 -0
  109. package/withBalanceLayout/withBalanceLayout.cjs +18 -0
  110. package/withBalanceLayout/withBalanceLayout.d.cts +12 -0
  111. package/withBalanceLayout/withBalanceLayout.d.mts +13 -0
  112. package/withBalanceLayout/withBalanceLayout.mjs +16 -0
  113. package/withCenterLayout/index.cjs +3 -0
  114. package/withCenterLayout/index.d.cts +3 -0
  115. package/withCenterLayout/index.d.mts +3 -0
  116. package/withCenterLayout/index.mjs +3 -0
  117. package/withCenterLayout/types.cjs +0 -0
  118. package/withCenterLayout/types.d.cts +10 -0
  119. package/withCenterLayout/types.d.mts +10 -0
  120. package/withCenterLayout/types.mjs +1 -0
  121. package/withCenterLayout/withCenterLayout.cjs +18 -0
  122. package/withCenterLayout/withCenterLayout.d.cts +12 -0
  123. package/withCenterLayout/withCenterLayout.d.mts +13 -0
  124. package/withCenterLayout/withCenterLayout.mjs +16 -0
  125. package/withFlowLayout/index.cjs +3 -0
  126. package/withFlowLayout/index.d.cts +3 -0
  127. package/withFlowLayout/index.d.mts +3 -0
  128. package/withFlowLayout/index.mjs +3 -0
  129. package/withFlowLayout/types.cjs +0 -0
  130. package/withFlowLayout/types.d.cts +10 -0
  131. package/withFlowLayout/types.d.mts +10 -0
  132. package/withFlowLayout/types.mjs +1 -0
  133. package/withFlowLayout/withFlowLayout.cjs +18 -0
  134. package/withFlowLayout/withFlowLayout.d.cts +12 -0
  135. package/withFlowLayout/withFlowLayout.d.mts +13 -0
  136. package/withFlowLayout/withFlowLayout.mjs +16 -0
  137. package/withLayerLayout/index.cjs +3 -0
  138. package/withLayerLayout/index.d.cts +3 -0
  139. package/withLayerLayout/index.d.mts +3 -0
  140. package/withLayerLayout/index.mjs +3 -0
  141. package/withLayerLayout/types.cjs +0 -0
  142. package/withLayerLayout/types.d.cts +10 -0
  143. package/withLayerLayout/types.d.mts +10 -0
  144. package/withLayerLayout/types.mjs +1 -0
  145. package/withLayerLayout/withLayerLayout.cjs +18 -0
  146. package/withLayerLayout/withLayerLayout.d.cts +12 -0
  147. package/withLayerLayout/withLayerLayout.d.mts +13 -0
  148. package/withLayerLayout/withLayerLayout.mjs +16 -0
  149. package/withLayout/index.cjs +3 -0
  150. package/withLayout/index.d.cts +3 -0
  151. package/withLayout/index.d.mts +3 -0
  152. package/withLayout/index.mjs +3 -0
  153. package/withLayout/types.cjs +0 -0
  154. package/withLayout/types.d.cts +37 -0
  155. package/withLayout/types.d.mts +37 -0
  156. package/withLayout/types.mjs +1 -0
  157. package/withLayout/withLayout.cjs +48 -0
  158. package/withLayout/withLayout.d.cts +14 -0
  159. package/withLayout/withLayout.d.mts +15 -0
  160. package/withLayout/withLayout.mjs +38 -0
  161. package/withMatrixLayout/index.cjs +3 -0
  162. package/withMatrixLayout/index.d.cts +3 -0
  163. package/withMatrixLayout/index.d.mts +3 -0
  164. package/withMatrixLayout/index.mjs +3 -0
  165. package/withMatrixLayout/types.cjs +0 -0
  166. package/withMatrixLayout/types.d.cts +10 -0
  167. package/withMatrixLayout/types.d.mts +10 -0
  168. package/withMatrixLayout/types.mjs +1 -0
  169. package/withMatrixLayout/withMatrixLayout.cjs +18 -0
  170. package/withMatrixLayout/withMatrixLayout.d.cts +12 -0
  171. package/withMatrixLayout/withMatrixLayout.d.mts +13 -0
  172. package/withMatrixLayout/withMatrixLayout.mjs +16 -0
  173. package/withPackLayout/index.cjs +3 -0
  174. package/withPackLayout/index.d.cts +3 -0
  175. package/withPackLayout/index.d.mts +3 -0
  176. package/withPackLayout/index.mjs +3 -0
  177. package/withPackLayout/types.cjs +0 -0
  178. package/withPackLayout/types.d.cts +10 -0
  179. package/withPackLayout/types.d.mts +10 -0
  180. package/withPackLayout/types.mjs +1 -0
  181. package/withPackLayout/withPackLayout.cjs +18 -0
  182. package/withPackLayout/withPackLayout.d.cts +12 -0
  183. package/withPackLayout/withPackLayout.d.mts +13 -0
  184. package/withPackLayout/withPackLayout.mjs +16 -0
  185. package/withPinLayout/index.cjs +3 -0
  186. package/withPinLayout/index.d.cts +3 -0
  187. package/withPinLayout/index.d.mts +3 -0
  188. package/withPinLayout/index.mjs +3 -0
  189. package/withPinLayout/types.cjs +0 -0
  190. package/withPinLayout/types.d.cts +10 -0
  191. package/withPinLayout/types.d.mts +10 -0
  192. package/withPinLayout/types.mjs +1 -0
  193. package/withPinLayout/withPinLayout.cjs +18 -0
  194. package/withPinLayout/withPinLayout.d.cts +12 -0
  195. package/withPinLayout/withPinLayout.d.mts +13 -0
  196. package/withPinLayout/withPinLayout.mjs +16 -0
  197. package/withStackLayout/index.cjs +3 -0
  198. package/withStackLayout/index.d.cts +3 -0
  199. package/withStackLayout/index.d.mts +3 -0
  200. package/withStackLayout/index.mjs +3 -0
  201. package/withStackLayout/types.cjs +0 -0
  202. package/withStackLayout/types.d.cts +10 -0
  203. package/withStackLayout/types.d.mts +10 -0
  204. package/withStackLayout/types.mjs +1 -0
  205. package/withStackLayout/withStackLayout.cjs +18 -0
  206. package/withStackLayout/withStackLayout.d.cts +12 -0
  207. package/withStackLayout/withStackLayout.d.mts +13 -0
  208. package/withStackLayout/withStackLayout.mjs +16 -0
  209. package/withTileLayout/index.cjs +3 -0
  210. package/withTileLayout/index.d.cts +3 -0
  211. package/withTileLayout/index.d.mts +3 -0
  212. package/withTileLayout/index.mjs +3 -0
  213. package/withTileLayout/types.cjs +0 -0
  214. package/withTileLayout/types.d.cts +10 -0
  215. package/withTileLayout/types.d.mts +10 -0
  216. package/withTileLayout/types.mjs +1 -0
  217. package/withTileLayout/withTileLayout.cjs +18 -0
  218. package/withTileLayout/withTileLayout.d.cts +12 -0
  219. package/withTileLayout/withTileLayout.d.mts +13 -0
  220. package/withTileLayout/withTileLayout.mjs +16 -0
@@ -0,0 +1,37 @@
1
+ import { LooseDictionary } from "@fringeworks/types";
2
+ import { CSSProperties } from "react";
3
+
4
+ //#region src/_internal/applyLayout/types.d.ts
5
+ /**
6
+ * レイアウト機能が消費する共通のプロパティ
7
+ */
8
+ type LayoutBaseProps = {
9
+ /**
10
+ * クラス
11
+ */
12
+ className?: string;
13
+ /**
14
+ * スクロールの有無
15
+ */
16
+ scroll?: boolean;
17
+ /**
18
+ * スタイル
19
+ */
20
+ style?: CSSProperties;
21
+ };
22
+ /**
23
+ * レイアウト用のスタイルを適用する際のオプション
24
+ */
25
+ type ApplyLayoutOptions<O extends object = LooseDictionary> = O & LayoutBaseProps;
26
+ type ApplyLayoutResult = {
27
+ /**
28
+ * クラス
29
+ */
30
+ className: string;
31
+ /**
32
+ * スタイル
33
+ */
34
+ style: CSSProperties;
35
+ };
36
+ //#endregion
37
+ export { ApplyLayoutOptions, ApplyLayoutResult, LayoutBaseProps };
@@ -0,0 +1,37 @@
1
+ import { CSSProperties } from "react";
2
+ import { LooseDictionary } from "@fringeworks/types";
3
+
4
+ //#region src/_internal/applyLayout/types.d.ts
5
+ /**
6
+ * レイアウト機能が消費する共通のプロパティ
7
+ */
8
+ type LayoutBaseProps = {
9
+ /**
10
+ * クラス
11
+ */
12
+ className?: string;
13
+ /**
14
+ * スクロールの有無
15
+ */
16
+ scroll?: boolean;
17
+ /**
18
+ * スタイル
19
+ */
20
+ style?: CSSProperties;
21
+ };
22
+ /**
23
+ * レイアウト用のスタイルを適用する際のオプション
24
+ */
25
+ type ApplyLayoutOptions<O extends object = LooseDictionary> = O & LayoutBaseProps;
26
+ type ApplyLayoutResult = {
27
+ /**
28
+ * クラス
29
+ */
30
+ className: string;
31
+ /**
32
+ * スタイル
33
+ */
34
+ style: CSSProperties;
35
+ };
36
+ //#endregion
37
+ export { ApplyLayoutOptions, ApplyLayoutResult, LayoutBaseProps };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,3 @@
1
+ const require__internal_withLayoutBase_withLayoutBase = require('./withLayoutBase.cjs');
2
+
3
+ module.exports = require__internal_withLayoutBase_withLayoutBase;
@@ -0,0 +1,3 @@
1
+ import { AllKeys, LayoutComponentBase, LayoutSource, WithLayoutBaseOptions, WithLayoutProps } from "./types.cjs";
2
+ import withLayoutBase from "./withLayoutBase.cjs";
3
+ export { type AllKeys, type LayoutComponentBase, type LayoutSource, type WithLayoutBaseOptions, type WithLayoutProps, withLayoutBase as default };
@@ -0,0 +1,3 @@
1
+ import { AllKeys, LayoutComponentBase, LayoutSource, WithLayoutBaseOptions, WithLayoutProps } from "./types.mjs";
2
+ import withLayoutBase from "./withLayoutBase.mjs";
3
+ export { type AllKeys, type LayoutComponentBase, type LayoutSource, type WithLayoutBaseOptions, type WithLayoutProps, withLayoutBase as default };
@@ -0,0 +1,3 @@
1
+ import withLayoutBase from "./withLayoutBase.mjs";
2
+
3
+ export { withLayoutBase as default };
File without changes
@@ -0,0 +1,43 @@
1
+ import { LayoutBaseProps } from "../applyLayout/types.cjs";
2
+ import { CreateLayoutStyle } from "@fringeworks/style-layouts";
3
+ import { ComponentPropsWithoutRef, ComponentRef, ElementType, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
4
+ import { StyleProxyOptions } from "@fringeworks/react-style-proxy/styleProxy";
5
+
6
+ //#region src/_internal/withLayoutBase/types.d.ts
7
+ /**
8
+ * ユニオン型を分配して全てのキーを取り出す
9
+ *
10
+ * `keyof`をユニオン型へそのまま適用すると共通のキーしか得られないため、
11
+ * 分配してから取り出す
12
+ */
13
+ type AllKeys<T> = T extends unknown ? keyof T : never;
14
+ /**
15
+ * 適用するレイアウト
16
+ *
17
+ * - レイアウト関数: 常にそのレイアウトを適用する(静的)
18
+ * - レイアウト関数のマップ: `layout`プロパティで選択したレイアウトを適用する(動的)
19
+ */
20
+ type LayoutSource<O> = CreateLayoutStyle<O> | Record<string, CreateLayoutStyle<never>>;
21
+ /**
22
+ * HOCのオプション
23
+ */
24
+ type WithLayoutBaseOptions = Omit<StyleProxyOptions, 'styleAsDefault'> & {
25
+ /**
26
+ * コンポーネントに設定するdisplayName
27
+ */
28
+ displayName?: string;
29
+ /**
30
+ * クラス名
31
+ */
32
+ className?: string;
33
+ };
34
+ /**
35
+ * レイアウト機能を追加したコンポーネントのプロパティ
36
+ */
37
+ type WithLayoutProps<C extends ElementType, O> = Omit<ComponentPropsWithoutRef<C>, AllKeys<O> | keyof LayoutBaseProps> & O & LayoutBaseProps;
38
+ /**
39
+ * レイアウト機能を追加したコンポーネント
40
+ */
41
+ type LayoutComponentBase<C extends ElementType, O> = ForwardRefExoticComponent<PropsWithoutRef<WithLayoutProps<C, O>> & RefAttributes<ComponentRef<C>>>;
42
+ //#endregion
43
+ export { AllKeys, LayoutComponentBase, LayoutSource, WithLayoutBaseOptions, WithLayoutProps };
@@ -0,0 +1,43 @@
1
+ import { LayoutBaseProps } from "../applyLayout/types.mjs";
2
+ import { ComponentPropsWithoutRef, ComponentRef, ElementType, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
3
+ import { CreateLayoutStyle } from "@fringeworks/style-layouts";
4
+ import { StyleProxyOptions } from "@fringeworks/react-style-proxy/styleProxy";
5
+
6
+ //#region src/_internal/withLayoutBase/types.d.ts
7
+ /**
8
+ * ユニオン型を分配して全てのキーを取り出す
9
+ *
10
+ * `keyof`をユニオン型へそのまま適用すると共通のキーしか得られないため、
11
+ * 分配してから取り出す
12
+ */
13
+ type AllKeys<T> = T extends unknown ? keyof T : never;
14
+ /**
15
+ * 適用するレイアウト
16
+ *
17
+ * - レイアウト関数: 常にそのレイアウトを適用する(静的)
18
+ * - レイアウト関数のマップ: `layout`プロパティで選択したレイアウトを適用する(動的)
19
+ */
20
+ type LayoutSource<O> = CreateLayoutStyle<O> | Record<string, CreateLayoutStyle<never>>;
21
+ /**
22
+ * HOCのオプション
23
+ */
24
+ type WithLayoutBaseOptions = Omit<StyleProxyOptions, 'styleAsDefault'> & {
25
+ /**
26
+ * コンポーネントに設定するdisplayName
27
+ */
28
+ displayName?: string;
29
+ /**
30
+ * クラス名
31
+ */
32
+ className?: string;
33
+ };
34
+ /**
35
+ * レイアウト機能を追加したコンポーネントのプロパティ
36
+ */
37
+ type WithLayoutProps<C extends ElementType, O> = Omit<ComponentPropsWithoutRef<C>, AllKeys<O> | keyof LayoutBaseProps> & O & LayoutBaseProps;
38
+ /**
39
+ * レイアウト機能を追加したコンポーネント
40
+ */
41
+ type LayoutComponentBase<C extends ElementType, O> = ForwardRefExoticComponent<PropsWithoutRef<WithLayoutProps<C, O>> & RefAttributes<ComponentRef<C>>>;
42
+ //#endregion
43
+ export { AllKeys, LayoutComponentBase, LayoutSource, WithLayoutBaseOptions, WithLayoutProps };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,50 @@
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
+ const require__internal__constants = require('../_constants.cjs');
3
+ const require__internal_applyLayout_applyLayout = require('../applyLayout/applyLayout.cjs');
4
+ let _fringeworks_react_style_proxy = require("@fringeworks/react-style-proxy");
5
+ let _fringeworks_react_utils_utils_ensureComponent = require("@fringeworks/react-utils/utils/ensureComponent");
6
+ _fringeworks_react_utils_utils_ensureComponent = require_runtime.__toESM(_fringeworks_react_utils_utils_ensureComponent, 1);
7
+ let _fringeworks_utils = require("@fringeworks/utils");
8
+ let clsx = require("clsx");
9
+ clsx = require_runtime.__toESM(clsx, 1);
10
+ let react = require("react");
11
+
12
+ //#region src/_internal/withLayoutBase/withLayoutBase.tsx
13
+ /**
14
+ * コンテナーのレイアウト機能を追加するHOC
15
+ * @param Component コンポーネント
16
+ * @param layout 適用するレイアウト
17
+ * @param options オプション
18
+ * @returns
19
+ */
20
+ function withLayoutBase(Component, layout, options = {}) {
21
+ const EnsuredComponent = (0, _fringeworks_react_utils_utils_ensureComponent.default)((0, _fringeworks_utils.unsafeCast)(Component));
22
+ const name = EnsuredComponent.displayName ?? EnsuredComponent.name ?? "Unknown";
23
+ const { displayName = `withLayout(${name})`, className: staticClassName, ...restOptions } = options;
24
+ const styleProxyOptions = {
25
+ styleAsDefault: true,
26
+ ...restOptions
27
+ };
28
+ const resolveLayout = typeof layout === "function" ? (layout, props) => {
29
+ return [(0, _fringeworks_utils.unsafeCast)(layout), props];
30
+ } : (layout, props) => {
31
+ const { layout: type, ...rest } = props;
32
+ return [(0, _fringeworks_utils.unsafeCast)(layout[type]), rest];
33
+ };
34
+ const LayoutComponent = (0, react.forwardRef)((props, ref) => {
35
+ const [createLayoutStyle, layoutOptions] = resolveLayout(layout, props);
36
+ const layoutProps = require__internal_applyLayout_applyLayout(createLayoutStyle, (0, _fringeworks_utils.unsafeCast)(layoutOptions));
37
+ const containerProps = { ...layoutOptions };
38
+ for (const key in require__internal__constants.LAYOUT_PROPS_KEYS) delete containerProps[key];
39
+ return (0, react.createElement)(EnsuredComponent, {
40
+ ref,
41
+ className: (0, clsx.default)(staticClassName, layoutProps.className),
42
+ ...(0, _fringeworks_react_style_proxy.styleProxy)(containerProps, layoutProps.style, styleProxyOptions)
43
+ });
44
+ });
45
+ LayoutComponent.displayName = displayName;
46
+ return LayoutComponent;
47
+ }
48
+
49
+ //#endregion
50
+ module.exports = withLayoutBase;
@@ -0,0 +1,13 @@
1
+ import { LayoutComponentBase, LayoutSource, WithLayoutBaseOptions } from "./types.cjs";
2
+ import { ElementType } from "react";
3
+
4
+ //#region src/_internal/withLayoutBase/withLayoutBase.d.ts
5
+ /**
6
+ * コンテナーのレイアウト機能を追加するHOC
7
+ * @param Component コンポーネント
8
+ * @param layout 適用するレイアウト
9
+ * @param options オプション
10
+ * @returns
11
+ */
12
+ declare function withLayoutBase<C extends ElementType, O extends object>(Component: C, layout: LayoutSource<O>, options?: WithLayoutBaseOptions): LayoutComponentBase<C, O>;
13
+ export = withLayoutBase;
@@ -0,0 +1,14 @@
1
+ import { LayoutComponentBase, LayoutSource, WithLayoutBaseOptions } from "./types.mjs";
2
+ import { ElementType } from "react";
3
+
4
+ //#region src/_internal/withLayoutBase/withLayoutBase.d.ts
5
+ /**
6
+ * コンテナーのレイアウト機能を追加するHOC
7
+ * @param Component コンポーネント
8
+ * @param layout 適用するレイアウト
9
+ * @param options オプション
10
+ * @returns
11
+ */
12
+ declare function withLayoutBase<C extends ElementType, O extends object>(Component: C, layout: LayoutSource<O>, options?: WithLayoutBaseOptions): LayoutComponentBase<C, O>;
13
+ //#endregion
14
+ export { withLayoutBase as default };
@@ -0,0 +1,47 @@
1
+ import { LAYOUT_PROPS_KEYS } from "../_constants.mjs";
2
+ import applyLayout from "../applyLayout/applyLayout.mjs";
3
+ import { styleProxy } from "@fringeworks/react-style-proxy";
4
+ import ensureComponent from "@fringeworks/react-utils/utils/ensureComponent";
5
+ import { unsafeCast } from "@fringeworks/utils";
6
+ import clsx from "clsx";
7
+ import { createElement, forwardRef } from "react";
8
+
9
+ //#region src/_internal/withLayoutBase/withLayoutBase.tsx
10
+ /**
11
+ * コンテナーのレイアウト機能を追加するHOC
12
+ * @param Component コンポーネント
13
+ * @param layout 適用するレイアウト
14
+ * @param options オプション
15
+ * @returns
16
+ */
17
+ function withLayoutBase(Component, layout, options = {}) {
18
+ const EnsuredComponent = ensureComponent(unsafeCast(Component));
19
+ const name = EnsuredComponent.displayName ?? EnsuredComponent.name ?? "Unknown";
20
+ const { displayName = `withLayout(${name})`, className: staticClassName, ...restOptions } = options;
21
+ const styleProxyOptions = {
22
+ styleAsDefault: true,
23
+ ...restOptions
24
+ };
25
+ const resolveLayout = typeof layout === "function" ? (layout, props) => {
26
+ return [unsafeCast(layout), props];
27
+ } : (layout, props) => {
28
+ const { layout: type, ...rest } = props;
29
+ return [unsafeCast(layout[type]), rest];
30
+ };
31
+ const LayoutComponent = forwardRef((props, ref) => {
32
+ const [createLayoutStyle, layoutOptions] = resolveLayout(layout, props);
33
+ const layoutProps = applyLayout(createLayoutStyle, unsafeCast(layoutOptions));
34
+ const containerProps = { ...layoutOptions };
35
+ for (const key in LAYOUT_PROPS_KEYS) delete containerProps[key];
36
+ return createElement(EnsuredComponent, {
37
+ ref,
38
+ className: clsx(staticClassName, layoutProps.className),
39
+ ...styleProxy(containerProps, layoutProps.style, styleProxyOptions)
40
+ });
41
+ });
42
+ LayoutComponent.displayName = displayName;
43
+ return LayoutComponent;
44
+ }
45
+
46
+ //#endregion
47
+ export { withLayoutBase as default };
@@ -0,0 +1,43 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __exportAll = (all, no_symbols) => {
9
+ let target = {};
10
+ for (var name in all) {
11
+ __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ }
16
+ if (!no_symbols) {
17
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
18
+ }
19
+ return target;
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
24
+ key = keys[i];
25
+ if (!__hasOwnProp.call(to, key) && key !== except) {
26
+ __defProp(to, key, {
27
+ get: ((k) => from[k]).bind(null, key),
28
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
+ });
30
+ }
31
+ }
32
+ }
33
+ return to;
34
+ };
35
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
36
+ value: mod,
37
+ enumerable: true
38
+ }) : target, mod));
39
+
40
+ //#endregion
41
+
42
+ exports.__exportAll = __exportAll;
43
+ exports.__toESM = __toESM;
@@ -0,0 +1,18 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) {
6
+ __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ }
11
+ if (!no_symbols) {
12
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ }
14
+ return target;
15
+ };
16
+
17
+ //#endregion
18
+ export { __exportAll };
package/constants.cjs ADDED
@@ -0,0 +1,57 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _fringeworks_style_layouts_constants = require("@fringeworks/style-layouts/constants");
3
+
4
+ //#region src/constants.ts
5
+ /**
6
+ * レイアウト種別
7
+ */
8
+ const LayoutType = {
9
+ balance: "balance",
10
+ center: "center",
11
+ flow: "flow",
12
+ layer: "layer",
13
+ matrix: "matrix",
14
+ pack: "pack",
15
+ pin: "pin",
16
+ stack: "stack",
17
+ tile: "tile"
18
+ };
19
+
20
+ //#endregion
21
+ Object.defineProperty(exports, 'Adjust', {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _fringeworks_style_layouts_constants.Adjust;
25
+ }
26
+ });
27
+ Object.defineProperty(exports, 'AlignX', {
28
+ enumerable: true,
29
+ get: function () {
30
+ return _fringeworks_style_layouts_constants.AlignX;
31
+ }
32
+ });
33
+ Object.defineProperty(exports, 'AlignXBase', {
34
+ enumerable: true,
35
+ get: function () {
36
+ return _fringeworks_style_layouts_constants.AlignXBase;
37
+ }
38
+ });
39
+ Object.defineProperty(exports, 'AlignY', {
40
+ enumerable: true,
41
+ get: function () {
42
+ return _fringeworks_style_layouts_constants.AlignY;
43
+ }
44
+ });
45
+ Object.defineProperty(exports, 'AlignYBase', {
46
+ enumerable: true,
47
+ get: function () {
48
+ return _fringeworks_style_layouts_constants.AlignYBase;
49
+ }
50
+ });
51
+ Object.defineProperty(exports, 'Direction', {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _fringeworks_style_layouts_constants.Direction;
55
+ }
56
+ });
57
+ exports.LayoutType = LayoutType;
@@ -0,0 +1,20 @@
1
+ import { Adjust, AlignX, AlignXBase, AlignY, AlignYBase, Direction } from "@fringeworks/style-layouts/constants";
2
+
3
+ //#region src/constants.d.ts
4
+ /**
5
+ * レイアウト種別
6
+ */
7
+ declare const LayoutType: {
8
+ readonly balance: "balance";
9
+ readonly center: "center";
10
+ readonly flow: "flow";
11
+ readonly layer: "layer";
12
+ readonly matrix: "matrix";
13
+ readonly pack: "pack";
14
+ readonly pin: "pin";
15
+ readonly stack: "stack";
16
+ readonly tile: "tile";
17
+ };
18
+ type LayoutType = (typeof LayoutType)[keyof typeof LayoutType];
19
+ //#endregion
20
+ export { Adjust, AlignX, AlignXBase, AlignY, AlignYBase, Direction, LayoutType };
@@ -0,0 +1,20 @@
1
+ import { Adjust, AlignX, AlignXBase, AlignY, AlignYBase, Direction } from "@fringeworks/style-layouts/constants";
2
+
3
+ //#region src/constants.d.ts
4
+ /**
5
+ * レイアウト種別
6
+ */
7
+ declare const LayoutType: {
8
+ readonly balance: "balance";
9
+ readonly center: "center";
10
+ readonly flow: "flow";
11
+ readonly layer: "layer";
12
+ readonly matrix: "matrix";
13
+ readonly pack: "pack";
14
+ readonly pin: "pin";
15
+ readonly stack: "stack";
16
+ readonly tile: "tile";
17
+ };
18
+ type LayoutType = (typeof LayoutType)[keyof typeof LayoutType];
19
+ //#endregion
20
+ export { Adjust, AlignX, AlignXBase, AlignY, AlignYBase, Direction, LayoutType };
package/constants.mjs ADDED
@@ -0,0 +1,20 @@
1
+ import { Adjust, AlignX, AlignXBase, AlignY, AlignYBase, Direction } from "@fringeworks/style-layouts/constants";
2
+
3
+ //#region src/constants.ts
4
+ /**
5
+ * レイアウト種別
6
+ */
7
+ const LayoutType = {
8
+ balance: "balance",
9
+ center: "center",
10
+ flow: "flow",
11
+ layer: "layer",
12
+ matrix: "matrix",
13
+ pack: "pack",
14
+ pin: "pin",
15
+ stack: "stack",
16
+ tile: "tile"
17
+ };
18
+
19
+ //#endregion
20
+ export { Adjust, AlignX, AlignXBase, AlignY, AlignYBase, Direction, LayoutType };
@@ -0,0 +1,171 @@
1
+ .lx-layout-balance {
2
+ --lx-layout-gapX: 0px;
3
+ --lx-layout-gapY: 0px;
4
+ --lx-layout-itemSizeX: auto;
5
+ --lx-layout-itemSizeY: auto;
6
+ --lx-layout-itemRatio: auto;
7
+ display: grid;
8
+ }
9
+
10
+ .lx-layout-balance.lx-layout-direction-x {
11
+ grid-auto-flow: column;
12
+ grid-auto-columns: max-content;
13
+ }
14
+
15
+ .lx-layout-balance.lx-layout-direction-x.lx-layout-adjustX-grow, .lx-layout-balance.lx-layout-direction-x.lx-layout-adjustX-fit {
16
+ grid-auto-columns: auto;
17
+ }
18
+
19
+ .lx-layout-balance.lx-layout-direction-x.lx-layout-adjustX-shrink {
20
+ grid-auto-columns: minmax(0, max-content);
21
+ }
22
+
23
+ .lx-layout-balance.lx-layout-direction-x.lx-layout-itemSizeX {
24
+ grid-auto-columns: auto;
25
+ }
26
+
27
+ .lx-layout-balance.lx-layout-direction-y {
28
+ grid-auto-flow: row;
29
+ grid-auto-rows: max-content;
30
+ }
31
+
32
+ .lx-layout-balance.lx-layout-direction-y.lx-layout-adjustY-grow, .lx-layout-balance.lx-layout-direction-y.lx-layout-adjustY-fit {
33
+ grid-auto-rows: auto;
34
+ }
35
+
36
+ .lx-layout-balance.lx-layout-direction-y.lx-layout-adjustY-shrink {
37
+ grid-auto-rows: minmax(0, max-content);
38
+ }
39
+
40
+ .lx-layout-balance.lx-layout-direction-y.lx-layout-itemSizeY {
41
+ grid-auto-rows: auto;
42
+ }
43
+
44
+ .lx-layout-balance.lx-layout-alignX-left {
45
+ justify-items: flex-start;
46
+ }
47
+
48
+ .lx-layout-balance.lx-layout-alignX-center {
49
+ justify-items: center;
50
+ }
51
+
52
+ .lx-layout-balance.lx-layout-alignX-right {
53
+ justify-items: flex-end;
54
+ }
55
+
56
+ .lx-layout-balance.lx-layout-alignX-spaceBetween {
57
+ justify-content: space-between;
58
+ }
59
+
60
+ .lx-layout-balance.lx-layout-alignX-spaceAround {
61
+ justify-content: space-around;
62
+ }
63
+
64
+ .lx-layout-balance.lx-layout-alignX-spaceEvenly {
65
+ justify-content: space-evenly;
66
+ }
67
+
68
+ .lx-layout-balance.lx-layout-alignY-top {
69
+ align-items: flex-start;
70
+ }
71
+
72
+ .lx-layout-balance.lx-layout-alignY-middle {
73
+ align-items: center;
74
+ }
75
+
76
+ .lx-layout-balance.lx-layout-alignY-bottom {
77
+ align-items: flex-end;
78
+ }
79
+
80
+ .lx-layout-balance.lx-layout-alignY-spaceBetween {
81
+ align-content: space-between;
82
+ }
83
+
84
+ .lx-layout-balance.lx-layout-alignY-spaceAround {
85
+ align-content: space-around;
86
+ }
87
+
88
+ .lx-layout-balance.lx-layout-alignY-spaceEvenly {
89
+ align-content: space-evenly;
90
+ }
91
+
92
+ .lx-layout-balance > * {
93
+ min-width: 0;
94
+ min-height: 0;
95
+ }
96
+
97
+ .lx-layout-balance.lx-layout-itemSizeX > * {
98
+ width: var(--lx-layout-itemSizeX);
99
+ }
100
+
101
+ .lx-layout-balance.lx-layout-adjustX-fit {
102
+ justify-items: stretch;
103
+ }
104
+
105
+ .lx-layout-balance.lx-layout-adjustX-fit > * {
106
+ width: auto;
107
+ }
108
+
109
+ .lx-layout-balance.lx-layout-adjustX-grow > *, .lx-layout-balance.lx-layout-adjustX-shrink > * {
110
+ width: 100%;
111
+ }
112
+
113
+ .lx-layout-balance.lx-layout-adjustX-grow > * {
114
+ min-width: max-content;
115
+ }
116
+
117
+ .lx-layout-balance.lx-layout-adjustX-grow.lx-layout-itemSizeX > * {
118
+ min-width: var(--lx-layout-itemSizeX);
119
+ }
120
+
121
+ .lx-layout-balance.lx-layout-adjustX-shrink > * {
122
+ max-width: max-content;
123
+ }
124
+
125
+ .lx-layout-balance.lx-layout-adjustX-shrink.lx-layout-itemSizeX > * {
126
+ max-width: var(--lx-layout-itemSizeX);
127
+ }
128
+
129
+ .lx-layout-balance.lx-layout-itemSizeY > * {
130
+ height: var(--lx-layout-itemSizeY);
131
+ }
132
+
133
+ .lx-layout-balance.lx-layout-adjustY-fit {
134
+ align-items: stretch;
135
+ }
136
+
137
+ .lx-layout-balance.lx-layout-adjustY-fit > * {
138
+ height: auto;
139
+ }
140
+
141
+ .lx-layout-balance.lx-layout-adjustY-grow > *, .lx-layout-balance.lx-layout-adjustY-shrink > * {
142
+ height: 100%;
143
+ }
144
+
145
+ .lx-layout-balance.lx-layout-adjustY-grow:not(.lx-layout-itemSizeY) > * {
146
+ min-height: max-content;
147
+ }
148
+
149
+ .lx-layout-balance.lx-layout-adjustY-grow.lx-layout-itemSizeY > * {
150
+ min-height: var(--lx-layout-itemSizeY);
151
+ }
152
+
153
+ .lx-layout-balance.lx-layout-adjustY-shrink:not(.lx-layout-itemSizeY) > * {
154
+ max-height: max-content;
155
+ }
156
+
157
+ .lx-layout-balance.lx-layout-adjustY-shrink.lx-layout-itemSizeY > * {
158
+ max-height: var(--lx-layout-itemSizeY);
159
+ }
160
+
161
+ .lx-layout-balance.lx-layout-itemRatio > * {
162
+ aspect-ratio: var(--lx-layout-itemRatio);
163
+ }
164
+
165
+ .lx-layout-balance.lx-layout-gapX {
166
+ column-gap: var(--lx-layout-gapX);
167
+ }
168
+
169
+ .lx-layout-balance.lx-layout-gapY {
170
+ row-gap: var(--lx-layout-gapY);
171
+ }