1 | function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
2 |
|
3 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
4 |
|
5 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
6 |
|
7 |
|
8 |
|
9 | import * as React from 'react';
|
10 | import { useStyleRegister } from '@ant-design/cssinjs';
|
11 | import { theme as antdTheme, ConfigProvider } from 'antd';
|
12 | import { resetComponent, clearFix } from "antd/es/style";
|
13 | import { resetForm } from "./mixin";
|
14 | import { genFormLayoutStyle } from "./layout";
|
15 | import { genFeedbackStyle } from "./feedback";
|
16 |
|
17 |
|
18 | var genFormStyle = function genFormStyle(token) {
|
19 | var _objectSpread3;
|
20 |
|
21 | var antCls = token.antCls,
|
22 | iconCls = token.iconCls,
|
23 | componentCls = token.componentCls,
|
24 | controlHeightLG = token.controlHeightLG,
|
25 | controlHeight = token.controlHeight,
|
26 | colorTextHeading = token.colorTextHeading,
|
27 | colorHighlight = token.colorHighlight,
|
28 | colorTextSecondary = token.colorTextSecondary,
|
29 | fontSize = token.fontSize,
|
30 | lineHeight = token.lineHeight,
|
31 | marginXS = token.marginXS,
|
32 | marginXXS = token.marginXXS,
|
33 | marginLG = token.marginLG,
|
34 | motionEaseOut = token.motionEaseOut,
|
35 | motionDurationSlow = token.motionDurationSlow,
|
36 | paddingXXS = token.paddingXXS,
|
37 | paddingXS = token.paddingXS,
|
38 | formExplainPrecision = token.formExplainPrecision;
|
39 | var formExplainHeight = Math.floor(fontSize * lineHeight);
|
40 | var formHelpMarginTop = (controlHeight - controlHeightLG) / 2 + 2;
|
41 | return _defineProperty({}, componentCls, _objectSpread(_objectSpread(_objectSpread({}, resetComponent(token)), resetForm(token)), {}, (_objectSpread3 = {}, _defineProperty(_objectSpread3, "".concat(componentCls, "-item-required::before"), {
|
42 | display: 'inline-block',
|
43 | marginRight: 4,
|
44 | color: colorHighlight,
|
45 | fontSize: fontSize,
|
46 | fontFamily: 'SimSun, sans-serif',
|
47 | lineHeight: 1,
|
48 | content: '" * "'
|
49 | }), _defineProperty(_objectSpread3, "".concat(componentCls, "-hide-required-mark ").concat(componentCls, "-item-required::before"), {
|
50 | display: 'none'
|
51 | }), _defineProperty(_objectSpread3, "".concat(componentCls, "-item-label > label"), {
|
52 | color: colorTextHeading,
|
53 | '&::after': {
|
54 | content: ':'
|
55 | },
|
56 | position: 'relative',
|
57 | top: -0.5,
|
58 | margin: "0 ".concat(marginXS, "px 0 ").concat(marginXXS / 2, "px")
|
59 | }), _defineProperty(_objectSpread3, "&".concat(componentCls, "-item-no-colon::after"), {
|
60 | content: ' '
|
61 | }), _defineProperty(_objectSpread3, "".concat(componentCls, "-item"), _objectSpread(_objectSpread({
|
62 | label: _defineProperty({
|
63 | position: 'relative'
|
64 | }, "> ".concat(iconCls), {
|
65 | fontSize: fontSize,
|
66 | verticalAlign: 'top'
|
67 | })
|
68 | }, resetComponent(token)), {}, _defineProperty({
|
69 | marginBottom: marginLG,
|
70 | verticalAlign: 'top',
|
71 | '&-control': _objectSpread({
|
72 | position: 'relative',
|
73 | lineHeight: "".concat(controlHeightLG, "px")
|
74 | }, clearFix()),
|
75 | '&-children': {
|
76 | position: 'relative'
|
77 | },
|
78 | '&-with-help': {
|
79 | marginBottom: Math.max(0, marginLG - formExplainHeight - formHelpMarginTop)
|
80 | },
|
81 | '&-label': {
|
82 | display: 'inline-block',
|
83 | overflow: 'hidden',
|
84 | lineHeight: "".concat(controlHeightLG - 0.0001, "px"),
|
85 | whiteSpace: 'nowrap',
|
86 | textAlign: 'right',
|
87 | verticalAlign: 'middle',
|
88 | flexGrow: '0',
|
89 | '&-left': {
|
90 | textAlign: 'left'
|
91 | }
|
92 | },
|
93 | '&-control-wrapper': {
|
94 | flex: '1 1 0'
|
95 | }
|
96 | }, "".concat(antCls, "-switch"), {
|
97 | margin: '2px 0 4px'
|
98 | }))), _defineProperty(_objectSpread3, "".concat(componentCls, "-explain, ").concat(componentCls, "-extra"), {
|
99 | clear: 'both',
|
100 | minHeight: formExplainHeight + formExplainPrecision,
|
101 | marginTop: formHelpMarginTop,
|
102 | color: colorTextSecondary,
|
103 | fontSize: fontSize,
|
104 | lineHeight: lineHeight,
|
105 | transition: "color ".concat(motionDurationSlow, " ").concat(motionEaseOut)
|
106 | }), _defineProperty(_objectSpread3, "".concat(componentCls, "-explain"), {
|
107 | marginBottom: -formExplainPrecision
|
108 | }), _defineProperty(_objectSpread3, "".concat(componentCls, "-extra"), {
|
109 | paddingTop: paddingXXS
|
110 | }), _defineProperty(_objectSpread3, "".concat(componentCls, "-text"), {
|
111 | display: 'inline-block',
|
112 | paddingRight: paddingXS
|
113 | }), _defineProperty(_objectSpread3, "".concat(componentCls, "-split"), {
|
114 | display: 'block',
|
115 | textAlign: 'center'
|
116 | }), _objectSpread3)));
|
117 | };
|
118 |
|
119 | export default function useStyle(prefixCls) {
|
120 | var _antdTheme$useToken = antdTheme.useToken(),
|
121 | theme = _antdTheme$useToken.theme,
|
122 | token = _antdTheme$useToken.token,
|
123 | hashId = _antdTheme$useToken.hashId;
|
124 |
|
125 | var _React$useContext = React.useContext(ConfigProvider.ConfigContext),
|
126 | iconPrefixCls = _React$useContext.iconPrefixCls,
|
127 | getPrefixCls = _React$useContext.getPrefixCls;
|
128 |
|
129 | var rootPrefixCls = getPrefixCls();
|
130 | return [useStyleRegister({
|
131 | theme: theme,
|
132 | token: token,
|
133 | hashId: hashId,
|
134 | path: ['compatible', 'Form', prefixCls, iconPrefixCls]
|
135 | }, function () {
|
136 | var mergedToken = _objectSpread({
|
137 | componentCls: ".".concat(prefixCls),
|
138 | antCls: ".".concat(rootPrefixCls),
|
139 | iconCls: ".".concat(iconPrefixCls),
|
140 | formExplainPrecision: 1
|
141 | }, token);
|
142 |
|
143 | return [genFormStyle(mergedToken), genFormLayoutStyle(mergedToken), genFeedbackStyle(mergedToken)];
|
144 | }), hashId];
|
145 | } |
\ | No newline at end of file |