deepsea-components 5.7.7 → 5.7.9
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/dist/cjs/components/CircleText.js +1 -0
- package/dist/cjs/components/CircleText.js.map +2 -2
- package/dist/cjs/components/FormLabel.d.ts +9 -3
- package/dist/cjs/components/FormLabel.js +14 -18
- package/dist/cjs/components/FormLabel.js.map +2 -2
- package/dist/cjs/components/Ring.js +1 -0
- package/dist/cjs/components/Ring.js.map +2 -2
- package/dist/cjs/components/Skeleton.js +1 -0
- package/dist/cjs/components/Skeleton.js.map +2 -2
- package/dist/cjs/components/Trapezium.js +1 -0
- package/dist/cjs/components/Trapezium.js.map +2 -2
- package/dist/esm/components/CircleText.js +2 -0
- package/dist/esm/components/CircleText.js.map +1 -1
- package/dist/esm/components/FormLabel.d.ts +9 -3
- package/dist/esm/components/FormLabel.js +44 -26
- package/dist/esm/components/FormLabel.js.map +1 -1
- package/dist/esm/components/Ring.js +2 -0
- package/dist/esm/components/Ring.js.map +1 -1
- package/dist/esm/components/Skeleton.js +2 -0
- package/dist/esm/components/Skeleton.js.map +1 -1
- package/dist/esm/components/Trapezium.js +2 -0
- package/dist/esm/components/Trapezium.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CircleText.tsx +2 -0
- package/src/components/FormLabel.tsx +27 -21
- package/src/components/Ring.tsx +2 -0
- package/src/components/Skeleton.tsx +2 -0
- package/src/components/Trapezium.tsx +2 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/CircleText.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport { FC, Fragment, HTMLAttributes } from \"react\"\n\nexport interface CircleTextProps extends Omit<HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /** 每一个方块的宽度 */\n width: number\n /** 每一个方块的高度 */\n height: number\n /** 圆弧的半径,不包含方块的高度 */\n radius: number\n /** 开始旋转的弧度,逆时针增加,0 为 x 轴方向 */\n startAngel?: number\n /** 每一个方块之间间隔的弧度 */\n gapAngel?: number\n /** 文字对齐的方式,默认居中 */\n align?: \"left\" | \"center\" | \"right\"\n /** 文字朝向圆心还是外侧,默认外侧 */\n direction?: \"inner\" | \"outer\"\n /** 是否反转文字顺序 */\n reverse?: boolean\n /** 分割文字的方法 */\n separator?: string | RegExp | ((text: string) => string[])\n /** 显示的文字 */\n children: string\n}\n\n/** 环形文字 */\nexport const CircleText: FC<CircleTextProps> = props => {\n const {\n width,\n height,\n radius,\n startAngel = 0,\n gapAngel = 0,\n align = \"center\",\n style,\n direction = \"outer\",\n reverse = false,\n separator,\n children,\n ...rest\n } = props\n const unitAngle = Math.atan(width / 2 / radius) * 2\n const totalAngle = (unitAngle + gapAngel) * children.length - gapAngel\n const offsetAngle = align === \"left\" ? 0 : align === \"right\" ? totalAngle : totalAngle / 2\n\n function getTransform(idx: number) {\n const angle = startAngel - idx * (unitAngle + gapAngel) + offsetAngle - unitAngle / 2\n const x = (radius + height / 2) * Math.cos(angle) - width / 2\n const y = (radius + height / 2) * Math.sin(angle) * -1 - height / 2\n const z = Math.PI / 2 - angle + (direction === \"inner\" ? Math.PI : 0)\n return `translateX(${x}px) translateY(${y}px) rotateZ(${(z / Math.PI) * 180}deg)`\n }\n\n const words = typeof separator === \"function\" ? separator(children) : children.split(separator ?? \"\")\n\n if (reverse) words.reverse()\n\n return (\n <Fragment>\n {words.map((w, idx) => (\n <span\n key={idx}\n style={{\n position: \"absolute\",\n ...style,\n transform: getTransform(idx),\n textAlign: \"center\",\n width,\n lineHeight: `${height}px`,\n height: height,\n }}\n {...rest}\n >\n {w}\n </span>\n ))}\n </Fragment>\n )\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA6C;AA0BtC,IAAM,aAAkC,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"react";
|
|
2
|
-
export type
|
|
1
|
+
import { ComponentPropsWithoutRef, FC, ReactNode } from "react";
|
|
2
|
+
export type FormLabelConfig = {
|
|
3
3
|
/**
|
|
4
4
|
* Label 的宽度.
|
|
5
5
|
*/
|
|
@@ -7,8 +7,14 @@ export type FormLabelProps = ComponentPropsWithoutRef<"div"> & {
|
|
|
7
7
|
/**
|
|
8
8
|
* 是否在 Label 前面添加一个空白区域,只有当前 Label 为非必选,而存在其他 Label 为必选的时候开启
|
|
9
9
|
*/
|
|
10
|
-
before?: boolean;
|
|
10
|
+
before?: boolean | number;
|
|
11
11
|
};
|
|
12
|
+
export type FormLabelProps = ComponentPropsWithoutRef<"div"> & FormLabelConfig;
|
|
13
|
+
export declare const FormLabelConfigContext: import("react").Context<Partial<FormLabelConfig>>;
|
|
14
|
+
export type FormLabelConfigProviderProps = FormLabelConfig & {
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
export declare const FormLabelConfigProvider: FC<FormLabelConfigProviderProps>;
|
|
12
18
|
/**
|
|
13
19
|
* 为 Ant Design 的 FormItem 设计的 Label 组件
|
|
14
20
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -19,28 +20,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
20
|
// src/components/FormLabel.tsx
|
|
20
21
|
var FormLabel_exports = {};
|
|
21
22
|
__export(FormLabel_exports, {
|
|
22
|
-
FormLabel: () => FormLabel
|
|
23
|
+
FormLabel: () => FormLabel,
|
|
24
|
+
FormLabelConfigContext: () => FormLabelConfigContext,
|
|
25
|
+
FormLabelConfigProvider: () => FormLabelConfigProvider
|
|
23
26
|
});
|
|
24
27
|
module.exports = __toCommonJS(FormLabel_exports);
|
|
25
|
-
var import_deepsea_tools = require("deepsea-tools");
|
|
26
28
|
var import_react = require("react");
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
text-align-last: justify;
|
|
35
|
-
`,
|
|
36
|
-
className
|
|
37
|
-
),
|
|
38
|
-
style: { width, ...style },
|
|
39
|
-
...rest
|
|
40
|
-
}
|
|
41
|
-
));
|
|
29
|
+
var FormLabelConfigContext = (0, import_react.createContext)({});
|
|
30
|
+
var FormLabelConfigProvider = ({ width, before, children }) => /* @__PURE__ */ React.createElement(FormLabelConfigContext.Provider, { value: { width, before } }, children);
|
|
31
|
+
var FormLabel = (props) => {
|
|
32
|
+
const { width: _width, before: _before } = (0, import_react.useContext)(FormLabelConfigContext);
|
|
33
|
+
const { style, width = _width, before = _before, ...rest } = props;
|
|
34
|
+
return /* @__PURE__ */ React.createElement(import_react.Fragment, null, !!before && /* @__PURE__ */ React.createElement("div", { style: { width: 11, color: "transparent" } }, " "), /* @__PURE__ */ React.createElement("div", { style: { width, textAlign: "justify", textAlignLast: "justify", ...style }, ...rest }));
|
|
35
|
+
};
|
|
42
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
37
|
0 && (module.exports = {
|
|
44
|
-
FormLabel
|
|
38
|
+
FormLabel,
|
|
39
|
+
FormLabelConfigContext,
|
|
40
|
+
FormLabelConfigProvider
|
|
45
41
|
});
|
|
46
42
|
//# sourceMappingURL=FormLabel.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/FormLabel.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport { ComponentPropsWithoutRef, FC, Fragment, ReactNode, createContext, useContext } from \"react\"\n\nexport type FormLabelConfig = {\n /**\n * Label 的宽度.\n */\n width: number\n /**\n * 是否在 Label 前面添加一个空白区域,只有当前 Label 为非必选,而存在其他 Label 为必选的时候开启\n */\n before?: boolean | number\n}\n\nexport type FormLabelProps = ComponentPropsWithoutRef<\"div\"> & FormLabelConfig\n\nexport const FormLabelConfigContext = createContext<Partial<FormLabelConfig>>({})\n\nexport type FormLabelConfigProviderProps = FormLabelConfig & {\n children?: ReactNode\n}\n\nexport const FormLabelConfigProvider: FC<FormLabelConfigProviderProps> = ({ width, before, children }) => (\n <FormLabelConfigContext.Provider value={{ width, before }}>{children}</FormLabelConfigContext.Provider>\n)\n\n/**\n * 为 Ant Design 的 FormItem 设计的 Label 组件\n */\nexport const FormLabel: FC<FormLabelProps> = props => {\n const { width: _width, before: _before } = useContext(FormLabelConfigContext)\n const { style, width = _width, before = _before, ...rest } = props\n\n return (\n <Fragment>\n {!!before && <div style={{ width: 11, color: \"transparent\" }}> </div>}\n <div style={{ width, textAlign: \"justify\", textAlignLast: \"justify\", ...style }} {...rest} />\n </Fragment>\n )\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA6F;AAetF,IAAM,6BAAyB,4BAAwC,CAAC,CAAC;AAMzE,IAAM,0BAA4D,CAAC,EAAE,OAAO,QAAQ,SAAS,MAChG,oCAAC,uBAAuB,UAAvB,EAAgC,OAAO,EAAE,OAAO,OAAO,KAAI,QAAS;AAMlE,IAAM,YAAgC,WAAS;AAClD,QAAM,EAAE,OAAO,QAAQ,QAAQ,QAAQ,QAAI,yBAAW,sBAAsB;AAC5E,QAAM,EAAE,OAAO,QAAQ,QAAQ,SAAS,SAAS,GAAG,KAAK,IAAI;AAE7D,SACI,oCAAC,6BACI,CAAC,CAAC,UAAU,oCAAC,SAAI,OAAO,EAAE,OAAO,IAAI,OAAO,cAAc,KAAG,GAAM,GACpE,oCAAC,SAAI,OAAO,EAAE,OAAO,WAAW,WAAW,eAAe,WAAW,GAAG,MAAM,GAAI,GAAG,MAAM,CAC/F;AAER;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/Ring.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport { HTMLAttributes, forwardRef } from \"react\"\n\nexport interface RingProps extends HTMLAttributes<HTMLDivElement> {\n outerWidth: number\n innerWidth: number\n}\n\n/** 环形组件 */\nexport const Ring = forwardRef<HTMLDivElement, RingProps>((props, ref) => {\n const { outerWidth, innerWidth, style, ...rest } = props\n\n const outerRadius = outerWidth / 2\n\n const innerRadius = innerWidth / 2\n\n return (\n <div\n ref={ref}\n style={{\n ...style,\n width: `${outerWidth}px`,\n height: `${outerWidth}px`,\n clipPath: `path(\"M0,${outerRadius} a${outerRadius},${outerRadius},0,1,0,${outerWidth},0 a${outerRadius},${outerRadius},0,1,0,-${outerWidth},0 l${outerRadius - innerRadius},0 a${innerRadius},${innerRadius},0,0,1,${innerRadius * 2},0 a${innerRadius},${innerRadius},0,0,1,-${innerRadius * 2},0 Z\")`,\n }}\n {...rest}\n />\n )\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA2C;AAQpC,IAAM,WAAO,yBAAsC,CAAC,OAAO,QAAQ;AACtE,QAAM,EAAE,YAAY,YAAY,OAAO,GAAG,KAAK,IAAI;AAEnD,QAAM,cAAc,aAAa;AAEjC,QAAM,cAAc,aAAa;AAEjC,SACI;AAAA,IAAC;AAAA;AAAA,MACG;AAAA,MACA,OAAO;AAAA,QACH,GAAG;AAAA,QACH,OAAO,GAAG;AAAA,QACV,QAAQ,GAAG;AAAA,QACX,UAAU,YAAY,gBAAgB,eAAe,qBAAqB,iBAAiB,eAAe,sBAAsB,iBAAiB,cAAc,kBAAkB,eAAe,qBAAqB,cAAc,QAAQ,eAAe,sBAAsB,cAAc;AAAA,MAClS;AAAA,MACC,GAAG;AAAA;AAAA,EACR;AAER,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/Skeleton.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport { clsx } from \"deepsea-tools\"\nimport { HTMLAttributes, forwardRef } from \"react\"\n\nimport { css } from \"@emotion/css\"\n\nexport interface SkeletonProps extends HTMLAttributes<HTMLDivElement> {\n loading?: boolean\n}\n\nexport const Skeleton = forwardRef<HTMLDivElement, SkeletonProps>((props, ref) => {\n const { className, children, loading = children === undefined || children === null, ...rest } = props\n\n return (\n <div\n ref={ref}\n className={clsx(\n css`\n @keyframes shimmer {\n 0% {\n background-position: -400px 0px;\n }\n 100% {\n background-position: 400px 0px;\n }\n }\n `,\n loading &&\n css`\n background-image: linear-gradient(to right, rgba(0, 0, 0, 0.067) 8%, rgba(0, 0, 0, 0.133) 18%, rgba(0, 0, 0, 0.067) 33%);\n animation-duration: 1s;\n animation-fill-mode: forwards;\n animation-iteration-count: infinite;\n animation-name: shimmer;\n animation-timing-function: linear;\n background-size: 800px 104px;\n `,\n className,\n )}\n {...rest}\n >\n {children}\n </div>\n )\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,2BAAqB;AACrB,mBAA2C;AAE3C,iBAAoB;AAMb,IAAM,eAAW,yBAA0C,CAAC,OAAO,QAAQ;AAC9E,QAAM,EAAE,WAAW,UAAU,UAAU,aAAa,UAAa,aAAa,MAAM,GAAG,KAAK,IAAI;AAEhG,SACI;AAAA,IAAC;AAAA;AAAA,MACG;AAAA,MACA,eAAW;AAAA,QACP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAUA,WACI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QASJ;AAAA,MACJ;AAAA,MACC,GAAG;AAAA;AAAA,IAEH;AAAA,EACL;AAER,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/Trapezium.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport { clsx } from \"deepsea-tools\"\nimport { HTMLAttributes, forwardRef } from \"react\"\n\nimport { css } from \"@emotion/css\"\nimport { px, transformCSSVariable } from \"../utils\"\n\nexport interface TrapeziumProps extends HTMLAttributes<HTMLDivElement> {\n top: number\n bottom: number\n height: number\n borderRadius: number\n}\n\n/** 梯形组件 */\nexport const Trapezium = forwardRef<HTMLDivElement, TrapeziumProps>((props, ref) => {\n const { top, bottom, height, borderRadius, className, style, ...rest } = props\n\n const diff = (bottom - top) / 2\n\n const a = Math.atan(height / diff) / 2\n\n const b = borderRadius / Math.tan(a)\n\n const c = b * Math.cos(a * 2)\n\n const d = b * Math.sin(a * 2)\n\n const e = Math.PI / 2 - a\n\n const f = borderRadius / Math.tan(e)\n\n const g = f * Math.cos(a * 2)\n\n const h = f * Math.sin(a * 2)\n\n return (\n <div\n ref={ref}\n className={clsx(\n css`\n width: var(--width);\n height: var(--height);\n clip-path: var(--clip-path);\n `,\n className,\n )}\n style={transformCSSVariable(\n {\n width: px(bottom),\n height: px(height),\n clipath: `path(\"M ${diff + f} ${0} A ${borderRadius} ${borderRadius} 0 0 0 ${diff - g} ${h} L ${c} ${height - d} A ${borderRadius} ${borderRadius} 0 0 0 ${b} ${height} L ${bottom - b} ${height} A ${borderRadius} ${borderRadius} 0 0 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AAAA,QAChW;AAAA,QACA;AAAA,MACJ;AAAA,MACC,GAAG;AAAA;AAAA,EACR;AAER,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Fragment","jsx","_jsx","CircleText","props","width","height","radius","startAngel","gapAngel","align","style","direction","reverse","separator","children","rest","unitAngle","Math","atan","totalAngle","length","offsetAngle","getTransform","idx","angle","x","cos","y","sin","z","PI","words","split","map","w","position","transform","textAlign","lineHeight"],"sources":["../../../src/components/CircleText.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":["Fragment","jsx","_jsx","CircleText","props","width","height","radius","startAngel","gapAngel","align","style","direction","reverse","separator","children","rest","unitAngle","Math","atan","totalAngle","length","offsetAngle","getTransform","idx","angle","x","cos","y","sin","z","PI","words","split","map","w","position","transform","textAlign","lineHeight"],"sources":["../../../src/components/CircleText.tsx"],"sourcesContent":["\"use client\"\n\nimport { FC, Fragment, HTMLAttributes } from \"react\"\n\nexport interface CircleTextProps extends Omit<HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /** 每一个方块的宽度 */\n width: number\n /** 每一个方块的高度 */\n height: number\n /** 圆弧的半径,不包含方块的高度 */\n radius: number\n /** 开始旋转的弧度,逆时针增加,0 为 x 轴方向 */\n startAngel?: number\n /** 每一个方块之间间隔的弧度 */\n gapAngel?: number\n /** 文字对齐的方式,默认居中 */\n align?: \"left\" | \"center\" | \"right\"\n /** 文字朝向圆心还是外侧,默认外侧 */\n direction?: \"inner\" | \"outer\"\n /** 是否反转文字顺序 */\n reverse?: boolean\n /** 分割文字的方法 */\n separator?: string | RegExp | ((text: string) => string[])\n /** 显示的文字 */\n children: string\n}\n\n/** 环形文字 */\nexport const CircleText: FC<CircleTextProps> = props => {\n const {\n width,\n height,\n radius,\n startAngel = 0,\n gapAngel = 0,\n align = \"center\",\n style,\n direction = \"outer\",\n reverse = false,\n separator,\n children,\n ...rest\n } = props\n const unitAngle = Math.atan(width / 2 / radius) * 2\n const totalAngle = (unitAngle + gapAngel) * children.length - gapAngel\n const offsetAngle = align === \"left\" ? 0 : align === \"right\" ? totalAngle : totalAngle / 2\n\n function getTransform(idx: number) {\n const angle = startAngel - idx * (unitAngle + gapAngel) + offsetAngle - unitAngle / 2\n const x = (radius + height / 2) * Math.cos(angle) - width / 2\n const y = (radius + height / 2) * Math.sin(angle) * -1 - height / 2\n const z = Math.PI / 2 - angle + (direction === \"inner\" ? Math.PI : 0)\n return `translateX(${x}px) translateY(${y}px) rotateZ(${(z / Math.PI) * 180}deg)`\n }\n\n const words = typeof separator === \"function\" ? separator(children) : children.split(separator ?? \"\")\n\n if (reverse) words.reverse()\n\n return (\n <Fragment>\n {words.map((w, idx) => (\n <span\n key={idx}\n style={{\n position: \"absolute\",\n ...style,\n transform: getTransform(idx),\n textAlign: \"center\",\n width,\n lineHeight: `${height}px`,\n height: height,\n }}\n {...rest}\n >\n {w}\n </span>\n ))}\n </Fragment>\n )\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAAaA,QAAQ,QAAwB,OAAO;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAyBpD;AACA,OAAO,MAAMC,UAA+B,GAAGC,KAAK,IAAI;EACpD,MAAM;IACFC,KAAK;IACLC,MAAM;IACNC,MAAM;IACNC,UAAU,GAAG,CAAC;IACdC,QAAQ,GAAG,CAAC;IACZC,KAAK,GAAG,QAAQ;IAChBC,KAAK;IACLC,SAAS,GAAG,OAAO;IACnBC,OAAO,GAAG,KAAK;IACfC,SAAS;IACTC,QAAQ;IACR,GAAGC;EACP,CAAC,GAAGZ,KAAK;EACT,MAAMa,SAAS,GAAGC,IAAI,CAACC,IAAI,CAACd,KAAK,GAAG,CAAC,GAAGE,MAAM,CAAC,GAAG,CAAC;EACnD,MAAMa,UAAU,GAAG,CAACH,SAAS,GAAGR,QAAQ,IAAIM,QAAQ,CAACM,MAAM,GAAGZ,QAAQ;EACtE,MAAMa,WAAW,GAAGZ,K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,EAAE,QAAQ;QACnBjC,KAAK;QACLkC,UAAU,EAAG,GAAEjC,MAAO,IAAG;QACzBA,MAAM,EAAEA;MACZ,CAAE;MAAA,GACEU,IAAI;MAAAD,QAAA,EAEPoB;IAAC,GAZGX,GAaH,CACT;EAAC,CACI,CAAC;AAEnB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, FC } from "react";
|
|
2
|
-
export type
|
|
1
|
+
import { ComponentPropsWithoutRef, FC, ReactNode } from "react";
|
|
2
|
+
export type FormLabelConfig = {
|
|
3
3
|
/**
|
|
4
4
|
* Label 的宽度.
|
|
5
5
|
*/
|
|
@@ -7,8 +7,14 @@ export type FormLabelProps = ComponentPropsWithoutRef<"div"> & {
|
|
|
7
7
|
/**
|
|
8
8
|
* 是否在 Label 前面添加一个空白区域,只有当前 Label 为非必选,而存在其他 Label 为必选的时候开启
|
|
9
9
|
*/
|
|
10
|
-
before?: boolean;
|
|
10
|
+
before?: boolean | number;
|
|
11
11
|
};
|
|
12
|
+
export type FormLabelProps = ComponentPropsWithoutRef<"div"> & FormLabelConfig;
|
|
13
|
+
export declare const FormLabelConfigContext: import("react").Context<Partial<FormLabelConfig>>;
|
|
14
|
+
export type FormLabelConfigProviderProps = FormLabelConfig & {
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
export declare const FormLabelConfigProvider: FC<FormLabelConfigProviderProps>;
|
|
12
18
|
/**
|
|
13
19
|
* 为 Ant Design 的 FormItem 设计的 Label 组件
|
|
14
20
|
*/
|
|
@@ -1,33 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Fragment, createContext, useContext } from "react";
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
export const FormLabelConfigContext = /*#__PURE__*/createContext({});
|
|
7
|
+
export const FormLabelConfigProvider = ({
|
|
8
|
+
width,
|
|
9
|
+
before,
|
|
10
|
+
children
|
|
11
|
+
}) => /*#__PURE__*/_jsx(FormLabelConfigContext.Provider, {
|
|
12
|
+
value: {
|
|
13
|
+
width,
|
|
14
|
+
before
|
|
15
|
+
},
|
|
16
|
+
children: children
|
|
17
|
+
});
|
|
18
|
+
|
|
6
19
|
/**
|
|
7
20
|
* 为 Ant Design 的 FormItem 设计的 Label 组件
|
|
8
21
|
*/
|
|
9
|
-
export const FormLabel =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
width: 11
|
|
19
|
-
},
|
|
20
|
-
children: "\u2002"
|
|
21
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
22
|
-
className: clsx(css`
|
|
23
|
-
text-align: justify;
|
|
24
|
-
text-align-last: justify;
|
|
25
|
-
`, className),
|
|
26
|
-
style: {
|
|
27
|
-
width,
|
|
28
|
-
...style
|
|
29
|
-
},
|
|
22
|
+
export const FormLabel = props => {
|
|
23
|
+
const {
|
|
24
|
+
width: _width,
|
|
25
|
+
before: _before
|
|
26
|
+
} = useContext(FormLabelConfigContext);
|
|
27
|
+
const {
|
|
28
|
+
style,
|
|
29
|
+
width = _width,
|
|
30
|
+
before = _before,
|
|
30
31
|
...rest
|
|
31
|
-
}
|
|
32
|
-
|
|
32
|
+
} = props;
|
|
33
|
+
return /*#__PURE__*/_jsxs(Fragment, {
|
|
34
|
+
children: [!!before && /*#__PURE__*/_jsx("div", {
|
|
35
|
+
style: {
|
|
36
|
+
width: 11,
|
|
37
|
+
color: "transparent"
|
|
38
|
+
},
|
|
39
|
+
children: "\u2002"
|
|
40
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
41
|
+
style: {
|
|
42
|
+
width,
|
|
43
|
+
textAlign: "justify",
|
|
44
|
+
textAlignLast: "justify",
|
|
45
|
+
...style
|
|
46
|
+
},
|
|
47
|
+
...rest
|
|
48
|
+
})]
|
|
49
|
+
});
|
|
50
|
+
};
|
|
33
51
|
//# sourceMappingURL=FormLabel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Fragment","createContext","useContext","jsx","_jsx","jsxs","_jsxs","FormLabelConfigContext","FormLabelConfigProvider","width","before","children","Provider","value","FormLabel","props","_width","_before","style","rest","color","textAlign","textAlignLast"],"sources":["../../../src/components/FormLabel.tsx"],"sourcesContent":["\"use client\"\n\nimport { ComponentPropsWithoutRef, FC, Fragment, ReactNode, createContext, useContext } from \"react\"\n\nexport type FormLabelConfig = {\n /**\n * Label 的宽度.\n */\n width: number\n /**\n * 是否在 Label 前面添加一个空白区域,只有当前 Label 为非必选,而存在其他 Label 为必选的时候开启\n */\n before?: boolean | number\n}\n\nexport type FormLabelProps = ComponentPropsWithoutRef<\"div\"> & FormLabelConfig\n\nexport const FormLabelConfigContext = createContext<Partial<FormLabelConfig>>({})\n\nexport type FormLabelConfigProviderProps = FormLabelConfig & {\n children?: ReactNode\n}\n\nexport const FormLabelConfigProvider: FC<FormLabelConfigProviderProps> = ({ width, before, children }) => (\n <FormLabelConfigContext.Provider value={{ width, before }}>{children}</FormLabelConfigContext.Provider>\n)\n\n/**\n * 为 Ant Design 的 FormItem 设计的 Label 组件\n */\nexport const FormLabel: FC<FormLabelProps> = props => {\n const { width: _width, before: _before } = useContext(FormLabelConfigContext)\n const { style, width = _width, before = _before, ...rest } = props\n\n return (\n <Fragment>\n {!!before && <div style={{ width: 11, color: \"transparent\" }}> </div>}\n <div style={{ width, textAlign: \"justify\", textAlignLast: \"justify\", ...style }} {...rest} />\n </Fragment>\n )\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAAuCA,QAAQ,EAAaC,aAAa,EAAEC,UAAU,QAAQ,OAAO;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAepG,OAAO,MAAMC,sBAAsB,gBAAGN,aAAa,CAA2B,CAAC,CAAC,CAAC;AAMjF,OAAO,MAAMO,uBAAyD,GAAGA,CAAC;EAAEC,KAAK;EAAEC,MAAM;EAAEC;AAAS,CAAC,kBACjGP,IAAA,CAACG,sBAAsB,CAACK,QAAQ;EAACC,KAAK,EAAE;IAAEJ,KAAK;IAAEC;EAAO,CAAE;EAAAC,QAAA,EAAEA;AAAQ,CAAkC,CACzG;;AAED;AACA;AACA;AACA,OAAO,MAAMG,SAA6B,GAAGC,KAAK,IAAI;EAClD,MAAM;IAAEN,KAAK,EAAEO,MAAM;IAAEN,MAAM,EAAEO;EAAQ,CAAC,GAAGf,UAAU,CAACK,sBAAsB,CAAC;EAC7E,MAAM;IAAEW,KAAK;IAAET,KAAK,GAAGO,MAAM;IAAEN,MAAM,GAAGO,OAAO;IAAE,GAAGE;EAAK,CAAC,GAAGJ,KAAK;EAElE,oBACIT,KAAA,CAACN,QAAQ;IAAAW,QAAA,GACJ,CAAC,CAACD,MAAM,iBAAIN,IAAA;MAAKc,KAAK,EAAE;QAAET,KAAK,EAAE,EAAE;QAAEW,KAAK,EAAE;MAAc,CAAE;MAAAT,QAAA,EAAC;IAAM,CAAK,CAAC,eAC1EP,IAAA;MAAKc,KAAK,EAAE;QAAET,KAAK;QAAEY,SAAS,EAAE,SAAS;QAAEC,aAAa,EAAE,SAAS;QAAE,GAAGJ;MAAM,CAAE;MAAA,GAAKC;IAAI,CAAG,CAAC;EAAA,CACvF,CAAC;AAEnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","jsx","_jsx","Ring","props","ref","outerWidth","innerWidth","style","rest","outerRadius","innerRadius","width","height","clipPath"],"sources":["../../../src/components/Ring.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":["forwardRef","jsx","_jsx","Ring","props","ref","outerWidth","innerWidth","style","rest","outerRadius","innerRadius","width","height","clipPath"],"sources":["../../../src/components/Ring.tsx"],"sourcesContent":["\"use client\"\n\nimport { HTMLAttributes, forwardRef } from \"react\"\n\nexport interface RingProps extends HTMLAttributes<HTMLDivElement> {\n outerWidth: number\n innerWidth: number\n}\n\n/** 环形组件 */\nexport const Ring = forwardRef<HTMLDivElement, RingProps>((props, ref) => {\n const { outerWidth, innerWidth, style, ...rest } = props\n\n const outerRadius = outerWidth / 2\n\n const innerRadius = innerWidth / 2\n\n return (\n <div\n ref={ref}\n style={{\n ...style,\n width: `${outerWidth}px`,\n height: `${outerWidth}px`,\n clipPath: `path(\"M0,${outerRadius} a${outerRadius},${outerRadius},0,1,0,${outerWidth},0 a${outerRadius},${outerRadius},0,1,0,-${outerWidth},0 l${outerRadius - innerRadius},0 a${innerRadius},${innerRadius},0,0,1,${innerRadius * 2},0 a${innerRadius},${innerRadius},0,0,1,-${innerRadius * 2},0 Z\")`,\n }}\n {...rest}\n />\n )\n})\n"],"mappings":"AAAA,YAAY;;AAEZ,SAAyBA,UAAU,QAAQ,OAAO;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAOlD;AACA,OAAO,MAAMC,IAAI,gBAAGH,UAAU,CAA4B,CAACI,KAAK,EAAEC,GAAG,KAAK;EACtE,MAAM;IAAEC,UAAU;IAAEC,UAAU;IAAEC,KAAK;IAAE,GAAGC;EAAK,CAAC,GAAGL,KAAK;EAExD,MAAMM,WAAW,GAAGJ,UAAU,GAAG,CAAC;EAElC,MAAMK,WAAW,GAAGJ,UAAU,GAAG,CAAC;EAElC,oBACIL,IAAA;IACIG,GAAG,EAAEA,GAAI;IACTG,KAAK,EAAE;MACH,GAAGA,KAAK;MACRI,KAAK,EAAG,GAAEN,UAAW,IAAG;MACxBO,MAAM,EAAG,GAAEP,UAAW,IAAG;MACzBQ,QAAQ,EAAG,YAAWJ,WAAY,KAAIA,WAAY,IAAGA,WAAY,UAASJ,UAAW,OAAMI,WAAY,IAAGA,WAAY,WAAUJ,UAAW,OAAMI,WAAW,GAAGC,WAAY,OAAMA,WAAY,IAAGA,WAAY,UAASA,WAAW,GAAG,CAAE,OAAMA,WAAY,IAAGA,WAAY,WAAUA,WAAW,GAAG,CAAE;IACpS,CAAE;IAAA,GACEF;EAAI,CACX,CAAC;AAEV,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","forwardRef","css","jsx","_jsx","Skeleton","props","ref","className","children","loading","undefined","rest"],"sources":["../../../src/components/Skeleton.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":["clsx","forwardRef","css","jsx","_jsx","Skeleton","props","ref","className","children","loading","undefined","rest"],"sources":["../../../src/components/Skeleton.tsx"],"sourcesContent":["\"use client\"\n\nimport { clsx } from \"deepsea-tools\"\nimport { HTMLAttributes, forwardRef } from \"react\"\n\nimport { css } from \"@emotion/css\"\n\nexport interface SkeletonProps extends HTMLAttributes<HTMLDivElement> {\n loading?: boolean\n}\n\nexport const Skeleton = forwardRef<HTMLDivElement, SkeletonProps>((props, ref) => {\n const { className, children, loading = children === undefined || children === null, ...rest } = props\n\n return (\n <div\n ref={ref}\n className={clsx(\n css`\n @keyframes shimmer {\n 0% {\n background-position: -400px 0px;\n }\n 100% {\n background-position: 400px 0px;\n }\n }\n `,\n loading &&\n css`\n background-image: linear-gradient(to right, rgba(0, 0, 0, 0.067) 8%, rgba(0, 0, 0, 0.133) 18%, rgba(0, 0, 0, 0.067) 33%);\n animation-duration: 1s;\n animation-fill-mode: forwards;\n animation-iteration-count: infinite;\n animation-name: shimmer;\n animation-timing-function: linear;\n background-size: 800px 104px;\n `,\n className,\n )}\n {...rest}\n >\n {children}\n </div>\n )\n})\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,IAAI,QAAQ,eAAe;AACpC,SAAyBC,UAAU,QAAQ,OAAO;AAElD,SAASC,GAAG,QAAQ,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAMlC,OAAO,MAAMC,QAAQ,gBAAGJ,UAAU,CAAgC,CAACK,KAAK,EAAEC,GAAG,KAAK;EAC9E,MAAM;IAAEC,SAAS;IAAEC,QAAQ;IAAEC,OAAO,GAAGD,QAAQ,KAAKE,SAAS,IAAIF,QAAQ,KAAK,IAAI;IAAE,GAAGG;EAAK,CAAC,GAAGN,KAAK;EAErG,oBACIF,IAAA;IACIG,GAAG,EAAEA,GAAI;IACTC,SAAS,EAAER,IAAI,CACXE,GAAI;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,EACDQ,OAAO,IACHR,GAAI;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,EACLM,SACJ,CAAE;IAAA,GACEI,IAAI;IAAAH,QAAA,EAEPA;EAAQ,CACR,CAAC;AAEd,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","forwardRef","css","px","transformCSSVariable","jsx","_jsx","Trapezium","props","ref","top","bottom","height","borderRadius","className","style","rest","diff","a","Math","atan","b","tan","c","cos","d","sin","e","PI","f","g","h","width","clipath"],"sources":["../../../src/components/Trapezium.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":["clsx","forwardRef","css","px","transformCSSVariable","jsx","_jsx","Trapezium","props","ref","top","bottom","height","borderRadius","className","style","rest","diff","a","Math","atan","b","tan","c","cos","d","sin","e","PI","f","g","h","width","clipath"],"sources":["../../../src/components/Trapezium.tsx"],"sourcesContent":["\"use client\"\n\nimport { clsx } from \"deepsea-tools\"\nimport { HTMLAttributes, forwardRef } from \"react\"\n\nimport { css } from \"@emotion/css\"\nimport { px, transformCSSVariable } from \"../utils\"\n\nexport interface TrapeziumProps extends HTMLAttributes<HTMLDivElement> {\n top: number\n bottom: number\n height: number\n borderRadius: number\n}\n\n/** 梯形组件 */\nexport const Trapezium = forwardRef<HTMLDivElement, TrapeziumProps>((props, ref) => {\n const { top, bottom, height, borderRadius, className, style, ...rest } = props\n\n const diff = (bottom - top) / 2\n\n const a = Math.atan(height / diff) / 2\n\n const b = borderRadius / Math.tan(a)\n\n const c = b * Math.cos(a * 2)\n\n const d = b * Math.sin(a * 2)\n\n const e = Math.PI / 2 - a\n\n const f = borderRadius / Math.tan(e)\n\n const g = f * Math.cos(a * 2)\n\n const h = f * Math.sin(a * 2)\n\n return (\n <div\n ref={ref}\n className={clsx(\n css`\n width: var(--width);\n height: var(--height);\n clip-path: var(--clip-path);\n `,\n className,\n )}\n style={transformCSSVariable(\n {\n width: px(bottom),\n height: px(height),\n clipath: `path(\"M ${diff + f} ${0} A ${borderRadius} ${borderRadius} 0 0 0 ${diff - g} ${h} L ${c} ${height - d} A ${borderRadius} ${borderRadius} 0 0 0 ${b} ${height} L ${bottom - b} ${height} A ${borderRadius} ${borderRadius} 0 0 0 ${bottom - c} ${height - d} L ${top + diff + g} ${h} A ${borderRadius} ${borderRadius} 0 0 0 ${top + diff - f} ${0} Z\")`,\n },\n style,\n )}\n {...rest}\n />\n )\n})\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,IAAI,QAAQ,eAAe;AACpC,SAAyBC,UAAU,QAAQ,OAAO;AAElD,SAASC,GAAG,QAAQ,cAAc;AAClC,SAASC,EAAE,EAAEC,oBAAoB;AAAkB,SAAAC,GAAA,IAAAC,IAAA;AASnD;AACA,OAAO,MAAMC,SAAS,gBAAGN,UAAU,CAAiC,CAACO,KAAK,EAAEC,GAAG,KAAK;EAChF,MAAM;IAAEC,GAAG;IAAEC,MAAM;IAAEC,MAAM;IAAEC,YAAY;IAAEC,SAAS;IAAEC,KAAK;IAAE,GAAGC;EAAK,CAAC,GAAGR,KAAK;EAE9E,MAAMS,IAAI,GAAG,CAACN,MAAM,GAAGD,GAAG,IAAI,CAAC;EAE/B,MAAMQ,CAAC,GAAGC,IAAI,CAACC,IAAI,CAACR,MAAM,GAAGK,IAAI,CAAC,GAAG,CAAC;EAEtC,MAAMI,CAAC,GAAGR,YAAY,GAAGM,IAAI,CAACG,GAAG,CAACJ,CAAC,CAAC;EAEpC,MAAMK,CA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KACJ,CAAE;IAAA,GACEC;EAAI,CACX,CAAC;AAEV,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import { ComponentPropsWithoutRef, FC, Fragment } from "react"
|
|
1
|
+
"use client"
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { ComponentPropsWithoutRef, FC, Fragment, ReactNode, createContext, useContext } from "react"
|
|
5
4
|
|
|
6
|
-
export type
|
|
5
|
+
export type FormLabelConfig = {
|
|
7
6
|
/**
|
|
8
7
|
* Label 的宽度.
|
|
9
8
|
*/
|
|
@@ -11,25 +10,32 @@ export type FormLabelProps = ComponentPropsWithoutRef<"div"> & {
|
|
|
11
10
|
/**
|
|
12
11
|
* 是否在 Label 前面添加一个空白区域,只有当前 Label 为非必选,而存在其他 Label 为必选的时候开启
|
|
13
12
|
*/
|
|
14
|
-
before?: boolean
|
|
13
|
+
before?: boolean | number
|
|
15
14
|
}
|
|
16
15
|
|
|
16
|
+
export type FormLabelProps = ComponentPropsWithoutRef<"div"> & FormLabelConfig
|
|
17
|
+
|
|
18
|
+
export const FormLabelConfigContext = createContext<Partial<FormLabelConfig>>({})
|
|
19
|
+
|
|
20
|
+
export type FormLabelConfigProviderProps = FormLabelConfig & {
|
|
21
|
+
children?: ReactNode
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const FormLabelConfigProvider: FC<FormLabelConfigProviderProps> = ({ width, before, children }) => (
|
|
25
|
+
<FormLabelConfigContext.Provider value={{ width, before }}>{children}</FormLabelConfigContext.Provider>
|
|
26
|
+
)
|
|
27
|
+
|
|
17
28
|
/**
|
|
18
29
|
* 为 Ant Design 的 FormItem 设计的 Label 组件
|
|
19
30
|
*/
|
|
20
|
-
export const FormLabel: FC<FormLabelProps> =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
style={{ width, ...style }}
|
|
32
|
-
{...rest}
|
|
33
|
-
/>
|
|
34
|
-
</Fragment>
|
|
35
|
-
)
|
|
31
|
+
export const FormLabel: FC<FormLabelProps> = props => {
|
|
32
|
+
const { width: _width, before: _before } = useContext(FormLabelConfigContext)
|
|
33
|
+
const { style, width = _width, before = _before, ...rest } = props
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Fragment>
|
|
37
|
+
{!!before && <div style={{ width: 11, color: "transparent" }}> </div>}
|
|
38
|
+
<div style={{ width, textAlign: "justify", textAlignLast: "justify", ...style }} {...rest} />
|
|
39
|
+
</Fragment>
|
|
40
|
+
)
|
|
41
|
+
}
|
package/src/components/Ring.tsx
CHANGED