@omnific/atelier 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/box/Box.d.ts +1 -1
- package/dist/box/Box.js +8 -13
- package/dist/box/types.d.ts +6 -30
- package/dist/props/display.props.d.ts +10 -0
- package/dist/props/display.props.js +15 -0
- package/dist/props/flex.props.d.ts +58 -0
- package/dist/props/flex.props.js +72 -0
- package/dist/props/gap.props.d.ts +10 -0
- package/dist/props/gap.props.js +18 -0
- package/dist/props/height.props.d.ts +10 -0
- package/dist/props/height.props.js +27 -0
- package/dist/props/index.d.ts +95 -0
- package/dist/props/index.js +158 -0
- package/dist/props/justify.props.d.ts +34 -0
- package/dist/props/justify.props.js +43 -0
- package/dist/props/margin.props.d.ts +10 -0
- package/dist/props/margin.props.js +27 -0
- package/dist/props/overflow.props.d.ts +10 -0
- package/dist/props/overflow.props.js +13 -0
- package/dist/props/padding.props.d.ts +10 -0
- package/dist/props/padding.props.js +18 -0
- package/dist/props/position.props.d.ts +18 -0
- package/dist/props/position.props.js +38 -0
- package/dist/props/radius.props.d.ts +10 -0
- package/dist/props/radius.props.js +19 -0
- package/dist/props/scaling.props.d.ts +10 -0
- package/dist/props/shadow.props.d.ts +10 -0
- package/dist/props/shadow.props.js +16 -0
- package/dist/props/width.props.d.ts +10 -0
- package/dist/props/width.props.js +26 -0
- package/dist/styles.css +2387 -27
- package/dist/system/create-system.d.ts +9 -4
- package/dist/system/create-system.js +9 -8
- package/dist/system/css-vars.d.ts +5 -40
- package/dist/system/css-vars.js +5 -61
- package/dist/system/default-system.d.ts +7 -3
- package/dist/system/default-system.js +3 -3
- package/dist/system/defaults/colors.d.ts +147 -74
- package/dist/system/defaults/colors.js +86 -60
- package/dist/system/define-colors.d.ts +7 -0
- package/dist/system/define-colors.js +7 -0
- package/dist/system/index.d.ts +6 -14
- package/dist/system/index.js +5 -13
- package/dist/system/merge-colors.d.ts +10 -0
- package/dist/system/merge-colors.js +21 -0
- package/dist/system/types.d.ts +14 -50
- package/dist/system/use-theme.d.ts +3 -23
- package/dist/system/use-theme.js +2 -21
- package/dist/utils/extractProps.js +34 -0
- package/package.json +6 -7
- package/dist/system/defaults/control-heights.d.ts +0 -16
- package/dist/system/defaults/control-heights.js +0 -11
- package/dist/system/defaults/focus-rings.d.ts +0 -10
- package/dist/system/defaults/focus-rings.js +0 -7
- package/dist/system/defaults/font-sizes.d.ts +0 -13
- package/dist/system/defaults/font-sizes.js +0 -10
- package/dist/system/defaults/fonts.d.ts +0 -10
- package/dist/system/defaults/fonts.js +0 -7
- package/dist/system/defaults/index.d.ts +0 -422
- package/dist/system/defaults/index.js +0 -28
- package/dist/system/defaults/radii.d.ts +0 -40
- package/dist/system/defaults/radii.js +0 -19
- package/dist/system/defaults/shadows.d.ts +0 -31
- package/dist/system/defaults/shadows.js +0 -16
- package/dist/system/defaults/spacing.d.ts +0 -112
- package/dist/system/defaults/spacing.js +0 -43
- package/dist/system/define-tokens.d.ts +0 -7
- package/dist/system/define-tokens.js +0 -7
- package/dist/system/merge-tokens.d.ts +0 -20
- package/dist/system/merge-tokens.js +0 -27
package/README.md
CHANGED
|
@@ -4,10 +4,10 @@ A refined React component library for Omnific.
|
|
|
4
4
|
|
|
5
5
|
```tsx
|
|
6
6
|
import { Button } from '@omnific/atelier';
|
|
7
|
-
import { createSystem,
|
|
7
|
+
import { createSystem, defaultColors, useTheme } from '@omnific/atelier/system';
|
|
8
8
|
import '@omnific/atelier/styles.css';
|
|
9
9
|
|
|
10
|
-
const system = createSystem('app',
|
|
10
|
+
const system = createSystem('app', defaultColors);
|
|
11
11
|
|
|
12
12
|
function App() {
|
|
13
13
|
useTheme(system); // injects CSS variables onto :root
|
|
@@ -15,8 +15,8 @@ function App() {
|
|
|
15
15
|
}
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
Color values come from `createSystem` and are injected at runtime by `useTheme`.
|
|
19
|
+
Spacing, radii, fonts, control heights, shadows and component styles ship via `@omnific/atelier/styles.css`.
|
|
20
20
|
|
|
21
21
|
## Storybook
|
|
22
22
|
|
package/dist/box/Box.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BoxProps } from "./types.js";
|
|
2
2
|
//#region box/Box.d.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 通用样式容器,通过共享静态 class 应用间距、布局与外观。
|
|
5
5
|
*/
|
|
6
6
|
export declare const Box: (props: BoxProps) => import("react").JSX.Element;
|
|
7
7
|
//#endregion
|
package/dist/box/Box.js
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
+
import { getPrefixCls } from "../utils/getPrefixCls.js";
|
|
1
2
|
import { boxPrefixCls } from "./constants.js";
|
|
2
|
-
import {
|
|
3
|
+
import { extractProps } from "../utils/extractProps.js";
|
|
3
4
|
import { clsx } from "clsx";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
//#region box/Box.tsx
|
|
7
|
+
const borderClassName = getPrefixCls("border");
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
9
|
+
* 通用样式容器,通过共享静态 class 应用间距、布局与外观。
|
|
8
10
|
*/
|
|
9
11
|
const Box = (props) => {
|
|
10
|
-
const {
|
|
12
|
+
const { border = false, children, className, ref, scaling, style, ...rest } = extractProps(props);
|
|
11
13
|
return /* @__PURE__ */ jsx("div", {
|
|
12
14
|
...rest,
|
|
13
|
-
className: clsx(boxPrefixCls, border &&
|
|
15
|
+
className: clsx(boxPrefixCls, border && borderClassName, className),
|
|
16
|
+
"data-scaling": scaling,
|
|
14
17
|
ref,
|
|
15
|
-
style
|
|
16
|
-
["padding", p],
|
|
17
|
-
["paddingInline", px],
|
|
18
|
-
["paddingBlock", py],
|
|
19
|
-
["background", bg],
|
|
20
|
-
["borderColor", borderColor],
|
|
21
|
-
["borderRadius", rounded],
|
|
22
|
-
["boxShadow", shadow]
|
|
23
|
-
], style),
|
|
18
|
+
style,
|
|
24
19
|
children
|
|
25
20
|
});
|
|
26
21
|
};
|
package/dist/box/types.d.ts
CHANGED
|
@@ -1,43 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../
|
|
1
|
+
import { AtelierProps } from "../props/index.js";
|
|
2
|
+
import { ScalingValue } from "../props/scaling.props.js";
|
|
3
3
|
import { ComponentPropsWithRef } from "react";
|
|
4
4
|
//#region box/types.d.ts
|
|
5
5
|
/**
|
|
6
|
-
* Box
|
|
6
|
+
* Box 组件自有样式属性。
|
|
7
7
|
*/
|
|
8
|
-
export type BoxOwnProps = {
|
|
9
|
-
/**
|
|
10
|
-
* 内边距,对应 `padding`。
|
|
11
|
-
*/
|
|
12
|
-
p?: SpacingToken;
|
|
13
|
-
/**
|
|
14
|
-
* 水平内边距,对应 `padding-inline`。
|
|
15
|
-
*/
|
|
16
|
-
px?: SpacingToken;
|
|
17
|
-
/**
|
|
18
|
-
* 垂直内边距,对应 `padding-block`。
|
|
19
|
-
*/
|
|
20
|
-
py?: SpacingToken;
|
|
21
|
-
/**
|
|
22
|
-
* 背景色语义 token。
|
|
23
|
-
*/
|
|
24
|
-
bg?: ColorToken;
|
|
25
|
-
/**
|
|
26
|
-
* 圆角预设。
|
|
27
|
-
*/
|
|
28
|
-
rounded?: RadiiToken;
|
|
8
|
+
export type BoxOwnProps = AtelierProps & {
|
|
29
9
|
/**
|
|
30
10
|
* 是否显示默认 1px solid 边框。
|
|
31
11
|
*/
|
|
32
12
|
border?: boolean;
|
|
33
13
|
/**
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
borderColor?: ColorToken;
|
|
37
|
-
/**
|
|
38
|
-
* 阴影预设。
|
|
14
|
+
* 调整结构 token 的缩放比例。
|
|
39
15
|
*/
|
|
40
|
-
|
|
16
|
+
scaling?: ScalingValue;
|
|
41
17
|
};
|
|
42
18
|
/**
|
|
43
19
|
* 通用样式容器属性。
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region props/display.props.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Atelier display 的静态值。
|
|
4
|
+
*/
|
|
5
|
+
export declare const displayValues: readonly ["none", "inline", "inline-block", "block", "flex", "inline-flex", "contents"];
|
|
6
|
+
/**
|
|
7
|
+
* Atelier display 值。
|
|
8
|
+
*/
|
|
9
|
+
export type DisplayValue = (typeof displayValues)[number];
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region props/flex.props.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Atelier flex-basis 的静态值。
|
|
4
|
+
*/
|
|
5
|
+
export declare const flexBasisValues: readonly ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "50%", "100%", "auto", "content", "fit-content", "min-content", "max-content"];
|
|
6
|
+
/**
|
|
7
|
+
* Atelier flex-basis 值。
|
|
8
|
+
*/
|
|
9
|
+
export type FlexBasisValue = (typeof flexBasisValues)[number];
|
|
10
|
+
/**
|
|
11
|
+
* Atelier flex-grow 的静态值。
|
|
12
|
+
*/
|
|
13
|
+
export declare const flexGrowValues: readonly ["0", "1"];
|
|
14
|
+
/**
|
|
15
|
+
* Atelier flex-grow 值。
|
|
16
|
+
*/
|
|
17
|
+
export type FlexGrowValue = (typeof flexGrowValues)[number];
|
|
18
|
+
/**
|
|
19
|
+
* Atelier flex-shrink 的静态值。
|
|
20
|
+
*/
|
|
21
|
+
export declare const flexShrinkValues: readonly ["0", "1"];
|
|
22
|
+
/**
|
|
23
|
+
* Atelier flex-shrink 值。
|
|
24
|
+
*/
|
|
25
|
+
export type FlexShrinkValue = (typeof flexShrinkValues)[number];
|
|
26
|
+
/**
|
|
27
|
+
* Atelier flex-direction 的静态值。
|
|
28
|
+
*/
|
|
29
|
+
export declare const flexDirectionValues: readonly ["row", "row-reverse", "column", "column-reverse"];
|
|
30
|
+
/**
|
|
31
|
+
* Atelier flex-direction 值。
|
|
32
|
+
*/
|
|
33
|
+
export type FlexDirectionValue = (typeof flexDirectionValues)[number];
|
|
34
|
+
/**
|
|
35
|
+
* Atelier flex-wrap 的静态值。
|
|
36
|
+
*/
|
|
37
|
+
export declare const flexWrapValues: readonly ["nowrap", "wrap", "wrap-reverse"];
|
|
38
|
+
/**
|
|
39
|
+
* Atelier flex-wrap 值。
|
|
40
|
+
*/
|
|
41
|
+
export type FlexWrapValue = (typeof flexWrapValues)[number];
|
|
42
|
+
/**
|
|
43
|
+
* Atelier align-items 与 align-self 的静态值。
|
|
44
|
+
*/
|
|
45
|
+
export declare const alignValues: readonly ["start", "center", "end", "baseline", "stretch"];
|
|
46
|
+
/**
|
|
47
|
+
* Atelier align-items 与 align-self 值。
|
|
48
|
+
*/
|
|
49
|
+
export type AlignValue = (typeof alignValues)[number];
|
|
50
|
+
/**
|
|
51
|
+
* Atelier align-content 的静态值。
|
|
52
|
+
*/
|
|
53
|
+
export declare const alignContentValues: readonly ["start", "center", "end", "space-between", "space-around", "space-evenly", "stretch"];
|
|
54
|
+
/**
|
|
55
|
+
* Atelier align-content 值。
|
|
56
|
+
*/
|
|
57
|
+
export type AlignContentValue = (typeof alignContentValues)[number];
|
|
58
|
+
//#endregion
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region props/flex.props.ts
|
|
2
|
+
/**
|
|
3
|
+
* Atelier flex-basis 的静态值。
|
|
4
|
+
*/
|
|
5
|
+
const flexBasisValues = [
|
|
6
|
+
"0",
|
|
7
|
+
"1",
|
|
8
|
+
"2",
|
|
9
|
+
"3",
|
|
10
|
+
"4",
|
|
11
|
+
"5",
|
|
12
|
+
"6",
|
|
13
|
+
"7",
|
|
14
|
+
"8",
|
|
15
|
+
"9",
|
|
16
|
+
"50%",
|
|
17
|
+
"100%",
|
|
18
|
+
"auto",
|
|
19
|
+
"content",
|
|
20
|
+
"fit-content",
|
|
21
|
+
"min-content",
|
|
22
|
+
"max-content"
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Atelier flex-grow 的静态值。
|
|
26
|
+
*/
|
|
27
|
+
const flexGrowValues = ["0", "1"];
|
|
28
|
+
/**
|
|
29
|
+
* Atelier flex-shrink 的静态值。
|
|
30
|
+
*/
|
|
31
|
+
const flexShrinkValues = ["0", "1"];
|
|
32
|
+
/**
|
|
33
|
+
* Atelier flex-direction 的静态值。
|
|
34
|
+
*/
|
|
35
|
+
const flexDirectionValues = [
|
|
36
|
+
"row",
|
|
37
|
+
"row-reverse",
|
|
38
|
+
"column",
|
|
39
|
+
"column-reverse"
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* Atelier flex-wrap 的静态值。
|
|
43
|
+
*/
|
|
44
|
+
const flexWrapValues = [
|
|
45
|
+
"nowrap",
|
|
46
|
+
"wrap",
|
|
47
|
+
"wrap-reverse"
|
|
48
|
+
];
|
|
49
|
+
/**
|
|
50
|
+
* Atelier align-items 与 align-self 的静态值。
|
|
51
|
+
*/
|
|
52
|
+
const alignValues = [
|
|
53
|
+
"start",
|
|
54
|
+
"center",
|
|
55
|
+
"end",
|
|
56
|
+
"baseline",
|
|
57
|
+
"stretch"
|
|
58
|
+
];
|
|
59
|
+
/**
|
|
60
|
+
* Atelier align-content 的静态值。
|
|
61
|
+
*/
|
|
62
|
+
const alignContentValues = [
|
|
63
|
+
"start",
|
|
64
|
+
"center",
|
|
65
|
+
"end",
|
|
66
|
+
"space-between",
|
|
67
|
+
"space-around",
|
|
68
|
+
"space-evenly",
|
|
69
|
+
"stretch"
|
|
70
|
+
];
|
|
71
|
+
//#endregion
|
|
72
|
+
export { alignContentValues, alignValues, flexBasisValues, flexDirectionValues, flexGrowValues, flexShrinkValues, flexWrapValues };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region props/gap.props.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Atelier gap 的静态刻度。
|
|
4
|
+
*/
|
|
5
|
+
export declare const gapValues: readonly ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
|
6
|
+
/**
|
|
7
|
+
* Atelier gap、column-gap 与 row-gap 值。
|
|
8
|
+
*/
|
|
9
|
+
export type GapValue = (typeof gapValues)[number];
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region props/height.props.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Atelier height 的静态刻度、百分比、视口单位与关键字值。
|
|
4
|
+
*/
|
|
5
|
+
export declare const heightValues: readonly ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "50%", "75%", "100%", "100vh", "100dvh", "auto", "min-content", "max-content", "fit-content"];
|
|
6
|
+
/**
|
|
7
|
+
* Atelier height 值。
|
|
8
|
+
*/
|
|
9
|
+
export type HeightValue = (typeof heightValues)[number];
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region props/height.props.ts
|
|
2
|
+
/**
|
|
3
|
+
* Atelier height 的静态刻度、百分比、视口单位与关键字值。
|
|
4
|
+
*/
|
|
5
|
+
const heightValues = [
|
|
6
|
+
"0",
|
|
7
|
+
"1",
|
|
8
|
+
"2",
|
|
9
|
+
"3",
|
|
10
|
+
"4",
|
|
11
|
+
"5",
|
|
12
|
+
"6",
|
|
13
|
+
"7",
|
|
14
|
+
"8",
|
|
15
|
+
"9",
|
|
16
|
+
"50%",
|
|
17
|
+
"75%",
|
|
18
|
+
"100%",
|
|
19
|
+
"100vh",
|
|
20
|
+
"100dvh",
|
|
21
|
+
"auto",
|
|
22
|
+
"min-content",
|
|
23
|
+
"max-content",
|
|
24
|
+
"fit-content"
|
|
25
|
+
];
|
|
26
|
+
//#endregion
|
|
27
|
+
export { heightValues };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { DisplayValue } from "./display.props.js";
|
|
2
|
+
import { AlignContentValue, AlignValue, FlexBasisValue, FlexDirectionValue, FlexGrowValue, FlexShrinkValue, FlexWrapValue } from "./flex.props.js";
|
|
3
|
+
import { GapValue } from "./gap.props.js";
|
|
4
|
+
import { HeightValue } from "./height.props.js";
|
|
5
|
+
import { ContentDistributionValue, JustifyItemsValue, JustifySelfValue, PlaceItemsValue } from "./justify.props.js";
|
|
6
|
+
import { MarginValue } from "./margin.props.js";
|
|
7
|
+
import { OverflowValue } from "./overflow.props.js";
|
|
8
|
+
import { PaddingValue } from "./padding.props.js";
|
|
9
|
+
import { PositionEdgeValue, PositionValue } from "./position.props.js";
|
|
10
|
+
import { RadiusValue } from "./radius.props.js";
|
|
11
|
+
import { ShadowValue } from "./shadow.props.js";
|
|
12
|
+
import { WidthValue } from "./width.props.js";
|
|
13
|
+
import { DefaultColorKey } from "../system/defaults/colors.js";
|
|
14
|
+
import { CSSProperties } from "react";
|
|
15
|
+
//#region props/index.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* Atelier class 类型 props。
|
|
18
|
+
*/
|
|
19
|
+
export type AtelierClassProps = {
|
|
20
|
+
p?: PaddingValue;
|
|
21
|
+
px?: PaddingValue;
|
|
22
|
+
py?: PaddingValue;
|
|
23
|
+
pt?: PaddingValue;
|
|
24
|
+
pr?: PaddingValue;
|
|
25
|
+
pb?: PaddingValue;
|
|
26
|
+
pl?: PaddingValue;
|
|
27
|
+
m?: MarginValue;
|
|
28
|
+
mx?: MarginValue;
|
|
29
|
+
my?: MarginValue;
|
|
30
|
+
mt?: MarginValue;
|
|
31
|
+
mr?: MarginValue;
|
|
32
|
+
mb?: MarginValue;
|
|
33
|
+
ml?: MarginValue;
|
|
34
|
+
display?: DisplayValue;
|
|
35
|
+
position?: PositionValue;
|
|
36
|
+
inset?: PositionEdgeValue;
|
|
37
|
+
top?: PositionEdgeValue;
|
|
38
|
+
right?: PositionEdgeValue;
|
|
39
|
+
bottom?: PositionEdgeValue;
|
|
40
|
+
left?: PositionEdgeValue;
|
|
41
|
+
overflow?: OverflowValue;
|
|
42
|
+
overflowX?: OverflowValue;
|
|
43
|
+
overflowY?: OverflowValue;
|
|
44
|
+
width?: WidthValue;
|
|
45
|
+
minWidth?: WidthValue;
|
|
46
|
+
maxWidth?: WidthValue;
|
|
47
|
+
height?: HeightValue;
|
|
48
|
+
minHeight?: HeightValue;
|
|
49
|
+
maxHeight?: HeightValue;
|
|
50
|
+
flexBasis?: FlexBasisValue;
|
|
51
|
+
flexGrow?: FlexGrowValue;
|
|
52
|
+
flexShrink?: FlexShrinkValue;
|
|
53
|
+
flexDirection?: FlexDirectionValue;
|
|
54
|
+
flexWrap?: FlexWrapValue;
|
|
55
|
+
alignItems?: AlignValue;
|
|
56
|
+
alignContent?: AlignContentValue;
|
|
57
|
+
alignSelf?: AlignValue;
|
|
58
|
+
justifyItems?: JustifyItemsValue;
|
|
59
|
+
justifyContent?: ContentDistributionValue;
|
|
60
|
+
justifySelf?: JustifySelfValue;
|
|
61
|
+
placeItems?: PlaceItemsValue;
|
|
62
|
+
placeContent?: ContentDistributionValue;
|
|
63
|
+
gap?: GapValue;
|
|
64
|
+
columnGap?: GapValue;
|
|
65
|
+
rowGap?: GapValue;
|
|
66
|
+
radius?: RadiusValue;
|
|
67
|
+
shadow?: ShadowValue;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Atelier style 类型 props。
|
|
71
|
+
*/
|
|
72
|
+
export type AtelierStyleProps = {
|
|
73
|
+
bg?: DefaultColorKey;
|
|
74
|
+
borderColor?: DefaultColorKey;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Atelier 全量公共 props 类型。
|
|
78
|
+
*/
|
|
79
|
+
export type AtelierProps = AtelierClassProps & AtelierStyleProps;
|
|
80
|
+
/**
|
|
81
|
+
* 按需生成单个 prop 与值对应的 Atelier 类名,并只缓存实际用到的那一条。
|
|
82
|
+
*
|
|
83
|
+
* 非 class prop 或非法值返回 `undefined`,由调用方继续透传。
|
|
84
|
+
*/
|
|
85
|
+
export declare const getAtelierClassName: (propName: keyof AtelierClassProps, value: string) => string | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Atelier 全量 style 映射。
|
|
88
|
+
*/
|
|
89
|
+
export declare const atelierStyleMaps: {
|
|
90
|
+
bg: (value: string) => {
|
|
91
|
+
background: string;
|
|
92
|
+
};
|
|
93
|
+
borderColor: (value: string) => CSSProperties;
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { getPrefixCls } from "../utils/getPrefixCls.js";
|
|
2
|
+
import { displayValues } from "./display.props.js";
|
|
3
|
+
import { alignContentValues, alignValues, flexBasisValues, flexDirectionValues, flexGrowValues, flexShrinkValues, flexWrapValues } from "./flex.props.js";
|
|
4
|
+
import { gapValues } from "./gap.props.js";
|
|
5
|
+
import { heightValues } from "./height.props.js";
|
|
6
|
+
import { contentDistributionValues, justifyItemsValues, justifySelfValues, placeItemsValues } from "./justify.props.js";
|
|
7
|
+
import { marginValues } from "./margin.props.js";
|
|
8
|
+
import { overflowValues } from "./overflow.props.js";
|
|
9
|
+
import { paddingValues } from "./padding.props.js";
|
|
10
|
+
import { positionEdgeValues, positionValues } from "./position.props.js";
|
|
11
|
+
import { radiusValues } from "./radius.props.js";
|
|
12
|
+
import { shadowValues } from "./shadow.props.js";
|
|
13
|
+
import { widthValues } from "./width.props.js";
|
|
14
|
+
import { toColorVarName } from "../system/css-vars.js";
|
|
15
|
+
import { hasValue, isNil, kebabCase } from "@omnific/utils";
|
|
16
|
+
//#region props/index.ts
|
|
17
|
+
const parseSizingValue = (value) => value.endsWith("%") ? value.slice(0, -1) : value;
|
|
18
|
+
/**
|
|
19
|
+
* Atelier class props 的静态配置:只声明值域与命名规则,不预先展开成 class 名。
|
|
20
|
+
*/
|
|
21
|
+
const classPropConfigs = {
|
|
22
|
+
p: { values: paddingValues },
|
|
23
|
+
px: { values: paddingValues },
|
|
24
|
+
py: { values: paddingValues },
|
|
25
|
+
pt: { values: paddingValues },
|
|
26
|
+
pr: { values: paddingValues },
|
|
27
|
+
pb: { values: paddingValues },
|
|
28
|
+
pl: { values: paddingValues },
|
|
29
|
+
m: {
|
|
30
|
+
values: marginValues,
|
|
31
|
+
allowNegative: true
|
|
32
|
+
},
|
|
33
|
+
mx: {
|
|
34
|
+
values: marginValues,
|
|
35
|
+
allowNegative: true
|
|
36
|
+
},
|
|
37
|
+
my: {
|
|
38
|
+
values: marginValues,
|
|
39
|
+
allowNegative: true
|
|
40
|
+
},
|
|
41
|
+
mt: {
|
|
42
|
+
values: marginValues,
|
|
43
|
+
allowNegative: true
|
|
44
|
+
},
|
|
45
|
+
mr: {
|
|
46
|
+
values: marginValues,
|
|
47
|
+
allowNegative: true
|
|
48
|
+
},
|
|
49
|
+
mb: {
|
|
50
|
+
values: marginValues,
|
|
51
|
+
allowNegative: true
|
|
52
|
+
},
|
|
53
|
+
ml: {
|
|
54
|
+
values: marginValues,
|
|
55
|
+
allowNegative: true
|
|
56
|
+
},
|
|
57
|
+
display: { values: displayValues },
|
|
58
|
+
position: { values: positionValues },
|
|
59
|
+
inset: {
|
|
60
|
+
values: positionEdgeValues,
|
|
61
|
+
allowNegative: true
|
|
62
|
+
},
|
|
63
|
+
top: {
|
|
64
|
+
values: positionEdgeValues,
|
|
65
|
+
allowNegative: true
|
|
66
|
+
},
|
|
67
|
+
right: {
|
|
68
|
+
values: positionEdgeValues,
|
|
69
|
+
allowNegative: true
|
|
70
|
+
},
|
|
71
|
+
bottom: {
|
|
72
|
+
values: positionEdgeValues,
|
|
73
|
+
allowNegative: true
|
|
74
|
+
},
|
|
75
|
+
left: {
|
|
76
|
+
values: positionEdgeValues,
|
|
77
|
+
allowNegative: true
|
|
78
|
+
},
|
|
79
|
+
overflow: { values: overflowValues },
|
|
80
|
+
overflowX: { values: overflowValues },
|
|
81
|
+
overflowY: { values: overflowValues },
|
|
82
|
+
width: {
|
|
83
|
+
values: widthValues,
|
|
84
|
+
parseValue: parseSizingValue
|
|
85
|
+
},
|
|
86
|
+
minWidth: {
|
|
87
|
+
values: widthValues,
|
|
88
|
+
parseValue: parseSizingValue
|
|
89
|
+
},
|
|
90
|
+
maxWidth: {
|
|
91
|
+
values: widthValues,
|
|
92
|
+
parseValue: parseSizingValue
|
|
93
|
+
},
|
|
94
|
+
height: {
|
|
95
|
+
values: heightValues,
|
|
96
|
+
parseValue: parseSizingValue
|
|
97
|
+
},
|
|
98
|
+
minHeight: {
|
|
99
|
+
values: heightValues,
|
|
100
|
+
parseValue: parseSizingValue
|
|
101
|
+
},
|
|
102
|
+
maxHeight: {
|
|
103
|
+
values: heightValues,
|
|
104
|
+
parseValue: parseSizingValue
|
|
105
|
+
},
|
|
106
|
+
flexBasis: {
|
|
107
|
+
values: flexBasisValues,
|
|
108
|
+
parseValue: parseSizingValue
|
|
109
|
+
},
|
|
110
|
+
flexGrow: { values: flexGrowValues },
|
|
111
|
+
flexShrink: { values: flexShrinkValues },
|
|
112
|
+
flexDirection: { values: flexDirectionValues },
|
|
113
|
+
flexWrap: { values: flexWrapValues },
|
|
114
|
+
alignItems: { values: alignValues },
|
|
115
|
+
alignContent: { values: alignContentValues },
|
|
116
|
+
alignSelf: { values: alignValues },
|
|
117
|
+
justifyItems: { values: justifyItemsValues },
|
|
118
|
+
justifyContent: { values: contentDistributionValues },
|
|
119
|
+
justifySelf: { values: justifySelfValues },
|
|
120
|
+
placeItems: { values: placeItemsValues },
|
|
121
|
+
placeContent: { values: contentDistributionValues },
|
|
122
|
+
gap: { values: gapValues },
|
|
123
|
+
columnGap: { values: gapValues },
|
|
124
|
+
rowGap: { values: gapValues },
|
|
125
|
+
radius: { values: radiusValues },
|
|
126
|
+
shadow: { values: shadowValues }
|
|
127
|
+
};
|
|
128
|
+
const classCache = /* @__PURE__ */ new Map();
|
|
129
|
+
/**
|
|
130
|
+
* 按需生成单个 prop 与值对应的 Atelier 类名,并只缓存实际用到的那一条。
|
|
131
|
+
*
|
|
132
|
+
* 非 class prop 或非法值返回 `undefined`,由调用方继续透传。
|
|
133
|
+
*/
|
|
134
|
+
const getAtelierClassName = (propName, value) => {
|
|
135
|
+
const config = Object.hasOwn(classPropConfigs, propName) ? classPropConfigs[propName] : void 0;
|
|
136
|
+
if (isNil(config)) return void 0;
|
|
137
|
+
const cachedClassNames = classCache.get(propName);
|
|
138
|
+
const cachedClassName = cachedClassNames?.get(value);
|
|
139
|
+
if (hasValue(cachedClassName)) return cachedClassName;
|
|
140
|
+
const { allowNegative = false, parseValue, values } = config;
|
|
141
|
+
if (!values.includes(value)) return void 0;
|
|
142
|
+
const isNegative = allowNegative && value.startsWith("-");
|
|
143
|
+
const valueWithoutSign = isNegative ? value.slice(1) : value;
|
|
144
|
+
const parsedValue = parseValue ? parseValue(valueWithoutSign) : valueWithoutSign;
|
|
145
|
+
const className = `${isNegative ? "-" : ""}${getPrefixCls(kebabCase(propName))}-${parsedValue}`;
|
|
146
|
+
if (hasValue(cachedClassNames)) cachedClassNames.set(value, className);
|
|
147
|
+
else classCache.set(propName, /* @__PURE__ */ new Map([[value, className]]));
|
|
148
|
+
return className;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Atelier 全量 style 映射。
|
|
152
|
+
*/
|
|
153
|
+
const atelierStyleMaps = {
|
|
154
|
+
bg: (value) => ({ background: `var(${toColorVarName(value)})` }),
|
|
155
|
+
borderColor: (value) => ({ "--color-border": `var(${toColorVarName(value)})` })
|
|
156
|
+
};
|
|
157
|
+
//#endregion
|
|
158
|
+
export { atelierStyleMaps, getAtelierClassName };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region props/justify.props.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Atelier justify-items 的静态值。
|
|
4
|
+
*/
|
|
5
|
+
export declare const justifyItemsValues: readonly ["start", "center", "end", "stretch"];
|
|
6
|
+
/**
|
|
7
|
+
* Atelier justify-items 值。
|
|
8
|
+
*/
|
|
9
|
+
export type JustifyItemsValue = (typeof justifyItemsValues)[number];
|
|
10
|
+
/**
|
|
11
|
+
* Atelier justify-content 与 place-content 的静态值。
|
|
12
|
+
*/
|
|
13
|
+
export declare const contentDistributionValues: readonly ["start", "center", "end", "space-between", "space-around", "space-evenly", "stretch"];
|
|
14
|
+
/**
|
|
15
|
+
* Atelier justify-content 与 place-content 值。
|
|
16
|
+
*/
|
|
17
|
+
export type ContentDistributionValue = (typeof contentDistributionValues)[number];
|
|
18
|
+
/**
|
|
19
|
+
* Atelier justify-self 的静态值。
|
|
20
|
+
*/
|
|
21
|
+
export declare const justifySelfValues: readonly ["start", "center", "end", "baseline", "stretch"];
|
|
22
|
+
/**
|
|
23
|
+
* Atelier justify-self 值。
|
|
24
|
+
*/
|
|
25
|
+
export type JustifySelfValue = (typeof justifySelfValues)[number];
|
|
26
|
+
/**
|
|
27
|
+
* Atelier place-items 的静态值。
|
|
28
|
+
*/
|
|
29
|
+
export declare const placeItemsValues: readonly ["start", "center", "end", "stretch"];
|
|
30
|
+
/**
|
|
31
|
+
* Atelier place-items 值。
|
|
32
|
+
*/
|
|
33
|
+
export type PlaceItemsValue = (typeof placeItemsValues)[number];
|
|
34
|
+
//#endregion
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region props/justify.props.ts
|
|
2
|
+
/**
|
|
3
|
+
* Atelier justify-items 的静态值。
|
|
4
|
+
*/
|
|
5
|
+
const justifyItemsValues = [
|
|
6
|
+
"start",
|
|
7
|
+
"center",
|
|
8
|
+
"end",
|
|
9
|
+
"stretch"
|
|
10
|
+
];
|
|
11
|
+
/**
|
|
12
|
+
* Atelier justify-content 与 place-content 的静态值。
|
|
13
|
+
*/
|
|
14
|
+
const contentDistributionValues = [
|
|
15
|
+
"start",
|
|
16
|
+
"center",
|
|
17
|
+
"end",
|
|
18
|
+
"space-between",
|
|
19
|
+
"space-around",
|
|
20
|
+
"space-evenly",
|
|
21
|
+
"stretch"
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Atelier justify-self 的静态值。
|
|
25
|
+
*/
|
|
26
|
+
const justifySelfValues = [
|
|
27
|
+
"start",
|
|
28
|
+
"center",
|
|
29
|
+
"end",
|
|
30
|
+
"baseline",
|
|
31
|
+
"stretch"
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Atelier place-items 的静态值。
|
|
35
|
+
*/
|
|
36
|
+
const placeItemsValues = [
|
|
37
|
+
"start",
|
|
38
|
+
"center",
|
|
39
|
+
"end",
|
|
40
|
+
"stretch"
|
|
41
|
+
];
|
|
42
|
+
//#endregion
|
|
43
|
+
export { contentDistributionValues, justifyItemsValues, justifySelfValues, placeItemsValues };
|