tntd 2.7.28 → 2.7.29-beta.1
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/es/_util/context.js +14 -0
- package/es/_util/context.js.map +1 -0
- package/es/_util/defaultRenderEmpty.js +20 -0
- package/es/_util/defaultRenderEmpty.js.map +1 -0
- package/es/_util/hooks/useFlexGapSupport.js +10 -0
- package/es/_util/hooks/useFlexGapSupport.js.map +1 -0
- package/es/_util/hooks/useForceUpdate.js +6 -0
- package/es/_util/hooks/useForceUpdate.js.map +1 -0
- package/es/_util/motion.js +22 -0
- package/es/_util/motion.js.map +1 -1
- package/es/_util/reactNode.js +15 -0
- package/es/_util/reactNode.js.map +1 -0
- package/es/_util/responsiveObserve.js +58 -0
- package/es/_util/responsiveObserve.js.map +1 -0
- package/es/_util/styleChecker.js +27 -0
- package/es/_util/styleChecker.js.map +1 -0
- package/es/_util/type.js.map +1 -1
- package/es/_util/warning.js.map +1 -1
- package/es/grid/RowContext.js +4 -0
- package/es/grid/RowContext.js.map +1 -0
- package/es/grid/col.js +78 -0
- package/es/grid/col.js.map +1 -0
- package/es/grid/hooks/useBreakpoint.js +19 -0
- package/es/grid/hooks/useBreakpoint.js.map +1 -0
- package/es/grid/index.js +13 -0
- package/es/grid/index.js.map +1 -0
- package/es/grid/row.js +141 -0
- package/es/grid/row.js.map +1 -0
- package/es/grid/style/index.js +3 -0
- package/es/grid/style/index.js.map +1 -0
- package/es/grid/style/index.less +124 -0
- package/es/grid/style/mixin.less +57 -0
- package/es/grid/style/rtl.less +69 -0
- package/es/index.js +2 -0
- package/es/index.js.map +1 -1
- package/es/tntd-form/ErrorList.js +1 -1
- package/es/tntd-form/ErrorList.js.map +1 -1
- package/es/tntd-form/FormItem/ItemHolder.js +1 -1
- package/es/tntd-form/FormItem/ItemHolder.js.map +1 -1
- package/es/tntd-form/FormItem/index.js +3 -3
- package/es/tntd-form/FormItem/index.js.map +1 -1
- package/es/tntd-form/FormItemInput.js +1 -1
- package/es/tntd-form/FormItemInput.js.map +1 -1
- package/es/tntd-form/FormItemLabel.js +1 -1
- package/es/tntd-form/FormItemLabel.js.map +1 -1
- package/es/tntd-form/FormList.js +1 -1
- package/es/tntd-form/FormList.js.map +1 -1
- package/es/tntd-form/hooks/useFormItemStatus.js +1 -1
- package/es/tntd-form/hooks/useFormItemStatus.js.map +1 -1
- package/es/tntd-form/index.js +0 -1
- package/es/tntd-form/index.js.map +1 -1
- package/lib/_util/context.d.ts +42 -0
- package/lib/_util/context.d.ts.map +1 -0
- package/lib/_util/context.js +20 -0
- package/lib/_util/context.js.map +1 -0
- package/lib/_util/defaultRenderEmpty.d.ts +5 -0
- package/lib/_util/defaultRenderEmpty.d.ts.map +1 -0
- package/lib/_util/defaultRenderEmpty.js +48 -0
- package/lib/_util/defaultRenderEmpty.js.map +1 -0
- package/lib/_util/hooks/useFlexGapSupport.d.ts +3 -0
- package/lib/_util/hooks/useFlexGapSupport.d.ts.map +1 -0
- package/lib/_util/hooks/useFlexGapSupport.js +35 -0
- package/lib/_util/hooks/useFlexGapSupport.js.map +1 -0
- package/lib/_util/hooks/useForceUpdate.d.ts +3 -0
- package/lib/_util/hooks/useForceUpdate.d.ts.map +1 -0
- package/lib/_util/hooks/useForceUpdate.js +32 -0
- package/lib/_util/hooks/useForceUpdate.js.map +1 -0
- package/lib/_util/motion.d.ts +3 -0
- package/lib/_util/motion.d.ts.map +1 -1
- package/lib/_util/motion.js +22 -0
- package/lib/_util/motion.js.map +1 -1
- package/lib/_util/reactNode.d.ts +9 -0
- package/lib/_util/reactNode.d.ts.map +1 -0
- package/lib/_util/reactNode.js +44 -0
- package/lib/_util/reactNode.js.map +1 -0
- package/lib/_util/responsiveObserve.d.ts +22 -0
- package/lib/_util/responsiveObserve.d.ts.map +1 -0
- package/lib/_util/responsiveObserve.js +61 -0
- package/lib/_util/responsiveObserve.js.map +1 -0
- package/lib/_util/styleChecker.d.ts +5 -0
- package/lib/_util/styleChecker.d.ts.map +1 -0
- package/lib/_util/styleChecker.js +35 -0
- package/lib/_util/styleChecker.js.map +1 -0
- package/lib/_util/type.d.ts.map +1 -1
- package/lib/_util/type.js.map +1 -1
- package/lib/_util/warning.d.ts.map +1 -1
- package/lib/_util/warning.js.map +1 -1
- package/lib/checkbox/checkbox-group.d.ts +1 -1
- package/lib/descriptions/descriptions.d.ts +1 -1
- package/lib/descriptions/descriptions.d.ts.map +1 -1
- package/lib/grid/RowContext.d.ts +9 -0
- package/lib/grid/RowContext.d.ts.map +1 -0
- package/lib/grid/RowContext.js +6 -0
- package/lib/grid/RowContext.js.map +1 -0
- package/lib/grid/col.d.ts +29 -0
- package/lib/grid/col.d.ts.map +1 -0
- package/lib/grid/col.js +106 -0
- package/lib/grid/col.js.map +1 -0
- package/lib/grid/hooks/useBreakpoint.d.ts +4 -0
- package/lib/grid/hooks/useBreakpoint.d.ts.map +1 -0
- package/lib/grid/hooks/useBreakpoint.js +24 -0
- package/lib/grid/hooks/useBreakpoint.js.map +1 -0
- package/lib/grid/index.d.ts +12 -0
- package/lib/grid/index.d.ts.map +1 -0
- package/lib/grid/index.js +20 -0
- package/lib/grid/index.js.map +1 -0
- package/lib/grid/row.d.ts +21 -0
- package/lib/grid/row.d.ts.map +1 -0
- package/lib/grid/row.js +169 -0
- package/lib/grid/row.js.map +1 -0
- package/lib/grid/style/index.d.ts +2 -0
- package/lib/grid/style/index.d.ts.map +1 -0
- package/lib/grid/style/index.js +5 -0
- package/lib/grid/style/index.js.map +1 -0
- package/lib/grid/style/index.less +124 -0
- package/lib/grid/style/mixin.less +57 -0
- package/lib/grid/style/rtl.less +69 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/input/input.d.ts +4 -4
- package/lib/input/input.d.ts.map +1 -1
- package/lib/input-number/index.d.ts +1 -1
- package/lib/query-form/Field/fieldsMap.d.ts +3 -3
- package/lib/radio/radio-group.d.ts +1 -1
- package/lib/segmented/index.d.ts +1 -1
- package/lib/segmented/index.d.ts.map +1 -1
- package/lib/svg-components/illustration-403.d.ts +1 -1
- package/lib/svg-components/illustration-404.d.ts +1 -1
- package/lib/svg-components/illustration-500.d.ts +1 -1
- package/lib/svg-components/illustration-empty.d.ts +1 -1
- package/lib/svg-components/illustration-failure.d.ts +1 -1
- package/lib/svg-components/illustration-no-access.d.ts +1 -1
- package/lib/svg-components/illustration-no-chart.d.ts +1 -1
- package/lib/svg-components/illustration-no-result.d.ts +1 -1
- package/lib/svg-components/illustration-offline.d.ts +1 -1
- package/lib/svg-components/illustration-success.d.ts +1 -1
- package/lib/table/assets/image-loading-background.d.ts +1 -1
- package/lib/table/assets/image-loading.d.ts +1 -1
- package/lib/time-picker/index.d.ts +1 -1
- package/lib/tntd-cascader/AntdCascader/config/utils.d.ts +1 -1
- package/lib/tntd-form/ErrorList.js +1 -1
- package/lib/tntd-form/ErrorList.js.map +1 -1
- package/lib/tntd-form/FormItem/ItemHolder.js +2 -2
- package/lib/tntd-form/FormItem/ItemHolder.js.map +1 -1
- package/lib/tntd-form/FormItem/index.js +3 -3
- package/lib/tntd-form/FormItem/index.js.map +1 -1
- package/lib/tntd-form/FormItemInput.d.ts +1 -1
- package/lib/tntd-form/FormItemInput.d.ts.map +1 -1
- package/lib/tntd-form/FormItemInput.js +1 -1
- package/lib/tntd-form/FormItemInput.js.map +1 -1
- package/lib/tntd-form/FormItemLabel.d.ts +1 -1
- package/lib/tntd-form/FormItemLabel.d.ts.map +1 -1
- package/lib/tntd-form/FormItemLabel.js +1 -1
- package/lib/tntd-form/FormItemLabel.js.map +1 -1
- package/lib/tntd-form/FormList.js +1 -1
- package/lib/tntd-form/FormList.js.map +1 -1
- package/lib/tntd-form/hooks/useFormItemStatus.js +1 -1
- package/lib/tntd-form/hooks/useFormItemStatus.js.map +1 -1
- package/lib/tntd-form/index.d.ts.map +1 -1
- package/lib/tntd-form/index.js +0 -1
- package/lib/tntd-form/index.js.map +1 -1
- package/lib/tntd-form/tntd-form.stories.d.ts +1 -1
- package/package.json +104 -105
- package/themes/default/variables.less +124 -7
- package/themes/utils/colorPalette.less +12 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.detectFlexGapSupported = exports.isStyleSupport = exports.canUseDocElement = void 0;
|
|
7
|
+
const canUseDom_1 = __importDefault(require("rc-util/lib/Dom/canUseDom"));
|
|
8
|
+
const styleChecker_1 = require("rc-util/lib/Dom/styleChecker");
|
|
9
|
+
Object.defineProperty(exports, "isStyleSupport", { enumerable: true, get: function () { return styleChecker_1.isStyleSupport; } });
|
|
10
|
+
const canUseDocElement = () => (0, canUseDom_1.default)() && window.document.documentElement;
|
|
11
|
+
exports.canUseDocElement = canUseDocElement;
|
|
12
|
+
let flexGapSupported;
|
|
13
|
+
const detectFlexGapSupported = () => {
|
|
14
|
+
if (!(0, exports.canUseDocElement)()) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (flexGapSupported !== undefined) {
|
|
18
|
+
return flexGapSupported;
|
|
19
|
+
}
|
|
20
|
+
// create flex container with row-gap set
|
|
21
|
+
const flex = document.createElement('div');
|
|
22
|
+
flex.style.display = 'flex';
|
|
23
|
+
flex.style.flexDirection = 'column';
|
|
24
|
+
flex.style.rowGap = '1px';
|
|
25
|
+
// create two, elements inside it
|
|
26
|
+
flex.appendChild(document.createElement('div'));
|
|
27
|
+
flex.appendChild(document.createElement('div'));
|
|
28
|
+
// append to the DOM (needed to obtain scrollHeight)
|
|
29
|
+
document.body.appendChild(flex);
|
|
30
|
+
flexGapSupported = flex.scrollHeight === 1; // flex container should be 1px high from the row-gap
|
|
31
|
+
document.body.removeChild(flex);
|
|
32
|
+
return flexGapSupported;
|
|
33
|
+
};
|
|
34
|
+
exports.detectFlexGapSupported = detectFlexGapSupported;
|
|
35
|
+
//# sourceMappingURL=styleChecker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styleChecker.js","sourceRoot":"","sources":["../../src/_util/styleChecker.tsx"],"names":[],"mappings":";;;;;;AAAA,0EAAiD;AACjD,+DAA6D;AAIpD,+FAJA,6BAAc,OAIA;AAFhB,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,IAAA,mBAAS,GAAE,IAAI,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAA;AAAvE,QAAA,gBAAgB,oBAAuD;AAIpF,IAAI,gBAAqC,CAAA;AAClC,MAAM,sBAAsB,GAAG,GAAG,EAAE;IACzC,IAAI,CAAC,IAAA,wBAAgB,GAAE,EAAE;QACvB,OAAO,KAAK,CAAA;KACb;IAED,IAAI,gBAAgB,KAAK,SAAS,EAAE;QAClC,OAAO,gBAAgB,CAAA;KACxB;IAED,yCAAyC;IACzC,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAC1C,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAA;IAC3B,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,QAAQ,CAAA;IACnC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAA;IAEzB,iCAAiC;IACjC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/C,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAA;IAE/C,oDAAoD;IACpD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IAC/B,gBAAgB,GAAG,IAAI,CAAC,YAAY,KAAK,CAAC,CAAA,CAAC,qDAAqD;IAChG,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IAE/B,OAAO,gBAAgB,CAAA;AACzB,CAAC,CAAA;AAzBY,QAAA,sBAAsB,0BAyBlC","sourcesContent":["import canUseDom from 'rc-util/lib/Dom/canUseDom'\nimport { isStyleSupport } from 'rc-util/lib/Dom/styleChecker'\n\nexport const canUseDocElement = () => canUseDom() && window.document.documentElement\n\nexport { isStyleSupport }\n\nlet flexGapSupported: boolean | undefined\nexport const detectFlexGapSupported = () => {\n if (!canUseDocElement()) {\n return false\n }\n\n if (flexGapSupported !== undefined) {\n return flexGapSupported\n }\n\n // create flex container with row-gap set\n const flex = document.createElement('div')\n flex.style.display = 'flex'\n flex.style.flexDirection = 'column'\n flex.style.rowGap = '1px'\n\n // create two, elements inside it\n flex.appendChild(document.createElement('div'))\n flex.appendChild(document.createElement('div'))\n\n // append to the DOM (needed to obtain scrollHeight)\n document.body.appendChild(flex)\n flexGapSupported = flex.scrollHeight === 1 // flex container should be 1px high from the row-gap\n document.body.removeChild(flex)\n\n return flexGapSupported\n}\n"]}
|
package/lib/_util/type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/_util/type.ts"],"names":[],"mappings":"AAAA,oBAAY,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/_util/type.ts"],"names":[],"mappings":"AAAA,oBAAY,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAErE,eAAO,MAAM,KAAK,uCAA2C,CAAA;AAE7D,eAAO,MAAM,QAAQ,uCAA2C,CAAA"}
|
package/lib/_util/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/_util/type.ts"],"names":[],"mappings":";;;AACA,qHAAqH;AAC9G,MAAM,KAAK,GAAG,CAAqB,GAAG,IAAO,EAAE,EAAE,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/_util/type.ts"],"names":[],"mappings":";;;AACA,qHAAqH;AAC9G,MAAM,KAAK,GAAG,CAAqB,GAAG,IAAO,EAAE,EAAE,CAAC,IAAI,CAAA;AAAhD,QAAA,KAAK,SAA2C;AAEtD,MAAM,QAAQ,GAAG,CAAqB,GAAG,IAAO,EAAE,EAAE,CAAC,IAAI,CAAA;AAAnD,QAAA,QAAQ,YAA2C","sourcesContent":["export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>\n// https://stackoverflow.com/questions/46176165/ways-to-get-string-literal-type-of-array-values-without-enum-overhead\nexport const tuple = <T extends string[]>(...args: T) => args\n\nexport const tupleNum = <T extends number[]>(...args: T) => args\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warning.d.ts","sourceRoot":"","sources":["../../src/_util/warning.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,WAAW,EAAE,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"warning.d.ts","sourceRoot":"","sources":["../../src/_util/warning.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,EAAE,WAAW,EAAE,CAAA;gCAEC,OAAO,aAAa,MAAM,WAAW,MAAM,KAAG,IAAI;AAAzE,wBAEC"}
|
package/lib/_util/warning.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warning.js","sourceRoot":"","sources":["../../src/_util/warning.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"warning.js","sourceRoot":"","sources":["../../src/_util/warning.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAA0D;AAEjD,4FAFS,qBAAW,OAET;AAEpB,kBAAe,CAAC,KAAc,EAAE,SAAiB,EAAE,OAAe,EAAQ,EAAE;IAC1E,IAAA,iBAAO,EAAC,KAAK,EAAE,UAAU,SAAS,KAAK,OAAO,EAAE,CAAC,CAAA;AACnD,CAAC,CAAA","sourcesContent":["import warning, { resetWarned } from 'rc-util/lib/warning'\n\nexport { resetWarned }\n\nexport default (valid: boolean, component: string, message: string): void => {\n warning(valid, `[antd: ${component}] ${message}`)\n}\n"]}
|
|
@@ -3,6 +3,6 @@ import type { CheckboxGroupProps as AntdCheckboxGroupProps } from 'antd/es/check
|
|
|
3
3
|
export declare type CheckboxGroupProps = AntdCheckboxGroupProps & {
|
|
4
4
|
readonly?: boolean;
|
|
5
5
|
};
|
|
6
|
-
declare const _default: React.ForwardRefExoticComponent<
|
|
6
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<unknown>>;
|
|
7
7
|
export default _default;
|
|
8
8
|
//# sourceMappingURL=checkbox-group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptions.d.ts","sourceRoot":"","sources":["../../src/descriptions/descriptions.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"descriptions.d.ts","sourceRoot":"","sources":["../../src/descriptions/descriptions.tsx"],"names":[],"mappings":";AAUA,OAAO,KAAK,EAAE,iBAAiB,IAAI,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAKtF,cAAc,sBAAsB,CAAA;AAEpC,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAmC3F;yBAnCe,YAAY"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Context } from 'react';
|
|
2
|
+
export interface RowContextState {
|
|
3
|
+
gutter?: [number, number];
|
|
4
|
+
wrap?: boolean;
|
|
5
|
+
supportFlexGap?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const RowContext: Context<RowContextState>;
|
|
8
|
+
export default RowContext;
|
|
9
|
+
//# sourceMappingURL=RowContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RowContext.d.ts","sourceRoot":"","sources":["../../src/grid/RowContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAGpC,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,QAAA,MAAM,UAAU,EAAE,OAAO,CAAC,eAAe,CAAqB,CAAA;AAE9D,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RowContext.js","sourceRoot":"","sources":["../../src/grid/RowContext.tsx"],"names":[],"mappings":";;AACA,iCAAqC;AAQrC,MAAM,UAAU,GAA6B,IAAA,qBAAa,EAAC,EAAE,CAAC,CAAA;AAE9D,kBAAe,UAAU,CAAA","sourcesContent":["import type { Context } from 'react'\nimport { createContext } from 'react'\n\nexport interface RowContextState {\n gutter?: [number, number]\n wrap?: boolean\n supportFlexGap?: boolean\n}\n\nconst RowContext: Context<RowContextState> = createContext({})\n\nexport default RowContext\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
declare type ColSpanType = number | string;
|
|
3
|
+
declare type FlexType = number | 'none' | 'auto' | string;
|
|
4
|
+
export interface ColSize {
|
|
5
|
+
flex?: FlexType;
|
|
6
|
+
span?: ColSpanType;
|
|
7
|
+
order?: ColSpanType;
|
|
8
|
+
offset?: ColSpanType;
|
|
9
|
+
push?: ColSpanType;
|
|
10
|
+
pull?: ColSpanType;
|
|
11
|
+
}
|
|
12
|
+
export interface ColProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
13
|
+
flex?: FlexType;
|
|
14
|
+
span?: ColSpanType;
|
|
15
|
+
order?: ColSpanType;
|
|
16
|
+
offset?: ColSpanType;
|
|
17
|
+
push?: ColSpanType;
|
|
18
|
+
pull?: ColSpanType;
|
|
19
|
+
xs?: ColSpanType | ColSize;
|
|
20
|
+
sm?: ColSpanType | ColSize;
|
|
21
|
+
md?: ColSpanType | ColSize;
|
|
22
|
+
lg?: ColSpanType | ColSize;
|
|
23
|
+
xl?: ColSpanType | ColSize;
|
|
24
|
+
xxl?: ColSpanType | ColSize;
|
|
25
|
+
prefixCls?: string;
|
|
26
|
+
}
|
|
27
|
+
declare const Col: React.ForwardRefExoticComponent<ColProps & React.RefAttributes<HTMLDivElement>>;
|
|
28
|
+
export default Col;
|
|
29
|
+
//# sourceMappingURL=col.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"col.d.ts","sourceRoot":"","sources":["../../src/grid/col.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,aAAK,WAAW,GAAG,MAAM,GAAG,MAAM,CAAA;AAElC,aAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAEjD,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,IAAI,CAAC,EAAE,WAAW,CAAA;CACnB;AAED,MAAM,WAAW,QAAS,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IACpE,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAA;IAC1B,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAA;IAC1B,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAA;IAC1B,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAA;IAC1B,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAA;IAC1B,GAAG,CAAC,EAAE,WAAW,GAAG,OAAO,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAcD,QAAA,MAAM,GAAG,iFAuFP,CAAA;AAMF,eAAe,GAAG,CAAA"}
|
package/lib/grid/col.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const context_1 = require("../_util/context");
|
|
43
|
+
const RowContext_1 = __importDefault(require("./RowContext"));
|
|
44
|
+
function parseFlex(flex) {
|
|
45
|
+
if (typeof flex === 'number') {
|
|
46
|
+
return `${flex} ${flex} auto`;
|
|
47
|
+
}
|
|
48
|
+
if (/^\d+(\.\d+)?(px|em|rem|%)$/.test(flex)) {
|
|
49
|
+
return `0 0 ${flex}`;
|
|
50
|
+
}
|
|
51
|
+
return flex;
|
|
52
|
+
}
|
|
53
|
+
const sizes = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
54
|
+
const Col = React.forwardRef((props, ref) => {
|
|
55
|
+
const { getPrefixCls, direction } = React.useContext(context_1.ConfigContext);
|
|
56
|
+
const { gutter, wrap, supportFlexGap } = React.useContext(RowContext_1.default);
|
|
57
|
+
const { prefixCls: customizePrefixCls = 'tnt-col', span, order, offset, push, pull, className, children, flex, style } = props, others = __rest(props, ["prefixCls", "span", "order", "offset", "push", "pull", "className", "children", "flex", "style"]);
|
|
58
|
+
const prefixCls = getPrefixCls('col', customizePrefixCls);
|
|
59
|
+
let sizeClassObj = {};
|
|
60
|
+
sizes.forEach((size) => {
|
|
61
|
+
let sizeProps = {};
|
|
62
|
+
const propSize = props[size];
|
|
63
|
+
if (typeof propSize === 'number') {
|
|
64
|
+
sizeProps.span = propSize;
|
|
65
|
+
}
|
|
66
|
+
else if (typeof propSize === 'object') {
|
|
67
|
+
sizeProps = propSize || {};
|
|
68
|
+
}
|
|
69
|
+
delete others[size];
|
|
70
|
+
sizeClassObj = Object.assign(Object.assign({}, sizeClassObj), { [`${prefixCls}-${size}-${sizeProps.span}`]: sizeProps.span !== undefined, [`${prefixCls}-${size}-order-${sizeProps.order}`]: sizeProps.order || sizeProps.order === 0, [`${prefixCls}-${size}-offset-${sizeProps.offset}`]: sizeProps.offset || sizeProps.offset === 0, [`${prefixCls}-${size}-push-${sizeProps.push}`]: sizeProps.push || sizeProps.push === 0, [`${prefixCls}-${size}-pull-${sizeProps.pull}`]: sizeProps.pull || sizeProps.pull === 0, [`${prefixCls}-rtl`]: direction === 'rtl' });
|
|
71
|
+
});
|
|
72
|
+
const classes = (0, classnames_1.default)(prefixCls, {
|
|
73
|
+
[`${prefixCls}-${span}`]: span !== undefined,
|
|
74
|
+
[`${prefixCls}-order-${order}`]: order,
|
|
75
|
+
[`${prefixCls}-offset-${offset}`]: offset,
|
|
76
|
+
[`${prefixCls}-push-${push}`]: push,
|
|
77
|
+
[`${prefixCls}-pull-${pull}`]: pull,
|
|
78
|
+
}, className, sizeClassObj);
|
|
79
|
+
const mergedStyle = {};
|
|
80
|
+
// Horizontal gutter use padding
|
|
81
|
+
if (gutter && gutter[0] > 0) {
|
|
82
|
+
const horizontalGutter = gutter[0] / 2;
|
|
83
|
+
mergedStyle.paddingLeft = horizontalGutter;
|
|
84
|
+
mergedStyle.paddingRight = horizontalGutter;
|
|
85
|
+
}
|
|
86
|
+
// Vertical gutter use padding when gap not support
|
|
87
|
+
if (gutter && gutter[1] > 0 && !supportFlexGap) {
|
|
88
|
+
const verticalGutter = gutter[1] / 2;
|
|
89
|
+
mergedStyle.paddingTop = verticalGutter;
|
|
90
|
+
mergedStyle.paddingBottom = verticalGutter;
|
|
91
|
+
}
|
|
92
|
+
if (flex) {
|
|
93
|
+
mergedStyle.flex = parseFlex(flex);
|
|
94
|
+
// Hack for Firefox to avoid size issue
|
|
95
|
+
// https://github.com/ant-design/ant-design/pull/20023#issuecomment-564389553
|
|
96
|
+
if (wrap === false && !mergedStyle.minWidth) {
|
|
97
|
+
mergedStyle.minWidth = 0;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return (React.createElement("div", Object.assign({}, others, { style: Object.assign(Object.assign({}, mergedStyle), style), className: classes, ref: ref }), children));
|
|
101
|
+
});
|
|
102
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
103
|
+
Col.displayName = 'Col';
|
|
104
|
+
}
|
|
105
|
+
exports.default = Col;
|
|
106
|
+
//# sourceMappingURL=col.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"col.js","sourceRoot":"","sources":["../../src/grid/col.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAmC;AACnC,6CAA8B;AAC9B,8CAAgD;AAChD,8DAAqC;AAgCrC,SAAS,SAAS,CAA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EACD,SAAS,EACT,YAAY,CACb,CAAA;IAED,MAAM,WAAW,GAAwB,EAAE,CAAA;IAC3C,gCAAgC;IAChC,IAAI,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;QAC3B,MAAM,gBAAgB,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QACtC,WAAW,CAAC,WAAW,GAAG,gBAAgB,CAAA;QAC1C,WAAW,CAAC,YAAY,GAAG,gBAAgB,CAAA;KAC5C;IAED,mDAAmD;IACnD,IAAI,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE;QAC9C,MAAM,cAAc,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QACpC,WAAW,CAAC,UAAU,GAAG,cAAc,CAAA;QACvC,WAAW,CAAC,aAAa,GAAG,cAAc,CAAA;KAC3C;IAED,IAAI,IAAI,EAAE;QACR,WAAW,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;QAElC,uCAAuC;QACvC,6EAA6E;QAC7E,IAAI,IAAI,KAAK,KAAK,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE;YAC3C,WAAW,CAAC,QAAQ,GAAG,CAAC,CAAA;SACzB;KACF;IAED,OAAO,CACL,6CAAS,MAAM,IAAE,KAAK,kCAAO,WAAW,GAAK,KAAK,GAAI,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,KAC/E,QAAQ,CACL,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,GAAG,CAAC,WAAW,GAAG,KAAK,CAAA;CACxB;AAED,kBAAe,GAAG,CAAA","sourcesContent":["import classNames from 'classnames'\nimport * as React from 'react'\nimport { ConfigContext } from '../_util/context'\nimport RowContext from './RowContext'\n\n// https://github.com/ant-design/ant-design/issues/14324\ntype ColSpanType = number | string\n\ntype FlexType = number | 'none' | 'auto' | string\n\nexport interface ColSize {\n flex?: FlexType\n span?: ColSpanType\n order?: ColSpanType\n offset?: ColSpanType\n push?: ColSpanType\n pull?: ColSpanType\n}\n\nexport interface ColProps extends React.HTMLAttributes<HTMLDivElement> {\n flex?: FlexType\n span?: ColSpanType\n order?: ColSpanType\n offset?: ColSpanType\n push?: ColSpanType\n pull?: ColSpanType\n xs?: ColSpanType | ColSize\n sm?: ColSpanType | ColSize\n md?: ColSpanType | ColSize\n lg?: ColSpanType | ColSize\n xl?: ColSpanType | ColSize\n xxl?: ColSpanType | ColSize\n prefixCls?: string\n}\n\nfunction parseFlex(flex: FlexType): string {\n if (typeof flex === 'number') {\n return `${flex} ${flex} auto`\n }\n\n if (/^\\d+(\\.\\d+)?(px|em|rem|%)$/.test(flex)) {\n return `0 0 ${flex}`\n }\n\n return flex\n}\nconst sizes = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'] as const\nconst Col = React.forwardRef<HTMLDivElement, ColProps>((props, ref) => {\n const { getPrefixCls, direction } = React.useContext(ConfigContext)\n const { gutter, wrap, supportFlexGap } = React.useContext(RowContext)\n\n const {\n prefixCls: customizePrefixCls = 'tnt-col',\n span,\n order,\n offset,\n push,\n pull,\n className,\n children,\n flex,\n style,\n ...others\n } = props\n\n const prefixCls = getPrefixCls('col', customizePrefixCls)\n\n let sizeClassObj = {}\n sizes.forEach((size) => {\n let sizeProps: ColSize = {}\n const propSize = props[size]\n if (typeof propSize === 'number') {\n sizeProps.span = propSize\n } else if (typeof propSize === 'object') {\n sizeProps = propSize || {}\n }\n\n delete others[size]\n\n sizeClassObj = {\n ...sizeClassObj,\n [`${prefixCls}-${size}-${sizeProps.span}`]: sizeProps.span !== undefined,\n [`${prefixCls}-${size}-order-${sizeProps.order}`]: sizeProps.order || sizeProps.order === 0,\n [`${prefixCls}-${size}-offset-${sizeProps.offset}`]:\n sizeProps.offset || sizeProps.offset === 0,\n [`${prefixCls}-${size}-push-${sizeProps.push}`]: sizeProps.push || sizeProps.push === 0,\n [`${prefixCls}-${size}-pull-${sizeProps.pull}`]: sizeProps.pull || sizeProps.pull === 0,\n [`${prefixCls}-rtl`]: direction === 'rtl',\n }\n })\n\n const classes = classNames(\n prefixCls,\n {\n [`${prefixCls}-${span}`]: span !== undefined,\n [`${prefixCls}-order-${order}`]: order,\n [`${prefixCls}-offset-${offset}`]: offset,\n [`${prefixCls}-push-${push}`]: push,\n [`${prefixCls}-pull-${pull}`]: pull,\n },\n className,\n sizeClassObj\n )\n\n const mergedStyle: React.CSSProperties = {}\n // Horizontal gutter use padding\n if (gutter && gutter[0] > 0) {\n const horizontalGutter = gutter[0] / 2\n mergedStyle.paddingLeft = horizontalGutter\n mergedStyle.paddingRight = horizontalGutter\n }\n\n // Vertical gutter use padding when gap not support\n if (gutter && gutter[1] > 0 && !supportFlexGap) {\n const verticalGutter = gutter[1] / 2\n mergedStyle.paddingTop = verticalGutter\n mergedStyle.paddingBottom = verticalGutter\n }\n\n if (flex) {\n mergedStyle.flex = parseFlex(flex)\n\n // Hack for Firefox to avoid size issue\n // https://github.com/ant-design/ant-design/pull/20023#issuecomment-564389553\n if (wrap === false && !mergedStyle.minWidth) {\n mergedStyle.minWidth = 0\n }\n }\n\n return (\n <div {...others} style={{ ...mergedStyle, ...style }} className={classes} ref={ref}>\n {children}\n </div>\n )\n})\n\nif (process.env.NODE_ENV !== 'production') {\n Col.displayName = 'Col'\n}\n\nexport default Col\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBreakpoint.d.ts","sourceRoot":"","sources":["../../../src/grid/hooks/useBreakpoint.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAG9D,iBAAS,aAAa,CAAC,eAAe,GAAE,OAAc,GAAG,SAAS,CAgBjE;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const useForceUpdate_1 = __importDefault(require("../../_util/hooks/useForceUpdate"));
|
|
8
|
+
const responsiveObserve_1 = __importDefault(require("../../_util/responsiveObserve"));
|
|
9
|
+
function useBreakpoint(refreshOnChange = true) {
|
|
10
|
+
const screensRef = (0, react_1.useRef)({});
|
|
11
|
+
const forceUpdate = (0, useForceUpdate_1.default)();
|
|
12
|
+
(0, react_1.useEffect)(() => {
|
|
13
|
+
const token = responsiveObserve_1.default.subscribe((supportScreens) => {
|
|
14
|
+
screensRef.current = supportScreens;
|
|
15
|
+
if (refreshOnChange) {
|
|
16
|
+
forceUpdate();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return () => responsiveObserve_1.default.unsubscribe(token);
|
|
20
|
+
}, []);
|
|
21
|
+
return screensRef.current;
|
|
22
|
+
}
|
|
23
|
+
exports.default = useBreakpoint;
|
|
24
|
+
//# sourceMappingURL=useBreakpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBreakpoint.js","sourceRoot":"","sources":["../../../src/grid/hooks/useBreakpoint.tsx"],"names":[],"mappings":";;;;;AAAA,iCAAyC;AACzC,sFAA6D;AAE7D,sFAA6D;AAE7D,SAAS,aAAa,CAAC,kBAA2B,IAAI;IACpD,MAAM,UAAU,GAAG,IAAA,cAAM,EAAY,EAAE,CAAC,CAAA;IACxC,MAAM,WAAW,GAAG,IAAA,wBAAc,GAAE,CAAA;IAEpC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,KAAK,GAAG,2BAAiB,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE,EAAE;YAC3D,UAAU,CAAC,OAAO,GAAG,cAAc,CAAA;YACnC,IAAI,eAAe,EAAE;gBACnB,WAAW,EAAE,CAAA;aACd;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,GAAG,EAAE,CAAC,2BAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IACnD,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,UAAU,CAAC,OAAO,CAAA;AAC3B,CAAC;AAED,kBAAe,aAAa,CAAA","sourcesContent":["import { useEffect, useRef } from 'react'\nimport useForceUpdate from '../../_util/hooks/useForceUpdate'\nimport type { ScreenMap } from '../../_util/responsiveObserve'\nimport ResponsiveObserve from '../../_util/responsiveObserve'\n\nfunction useBreakpoint(refreshOnChange: boolean = true): ScreenMap {\n const screensRef = useRef<ScreenMap>({})\n const forceUpdate = useForceUpdate()\n\n useEffect(() => {\n const token = ResponsiveObserve.subscribe((supportScreens) => {\n screensRef.current = supportScreens\n if (refreshOnChange) {\n forceUpdate()\n }\n })\n\n return () => ResponsiveObserve.unsubscribe(token)\n }, [])\n\n return screensRef.current\n}\n\nexport default useBreakpoint\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Col from './col';
|
|
2
|
+
import Row from './row';
|
|
3
|
+
import './style';
|
|
4
|
+
declare function useBreakpoint(): Partial<Record<import("../_util/responsiveObserve").Breakpoint, boolean>>;
|
|
5
|
+
export { ColProps, ColSize } from './col';
|
|
6
|
+
export { RowProps } from './row';
|
|
7
|
+
export { Row, Col };
|
|
8
|
+
declare const _default: {
|
|
9
|
+
useBreakpoint: typeof useBreakpoint;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/grid/index.tsx"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,OAAO,CAAA;AAEvB,OAAO,GAAG,MAAM,OAAO,CAAA;AAEvB,OAAO,SAAS,CAAA;AAGhB,iBAAS,aAAa,8EAErB;AAED,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAA;;;;AAEnB,wBAAgC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Col = exports.Row = void 0;
|
|
7
|
+
const col_1 = __importDefault(require("./col"));
|
|
8
|
+
exports.Col = col_1.default;
|
|
9
|
+
const useBreakpoint_1 = __importDefault(require("./hooks/useBreakpoint"));
|
|
10
|
+
const row_1 = __importDefault(require("./row"));
|
|
11
|
+
exports.Row = row_1.default;
|
|
12
|
+
require("./style");
|
|
13
|
+
// Do not export params
|
|
14
|
+
function useBreakpoint() {
|
|
15
|
+
return (0, useBreakpoint_1.default)();
|
|
16
|
+
}
|
|
17
|
+
var col_2 = require("./col");
|
|
18
|
+
var row_2 = require("./row");
|
|
19
|
+
exports.default = { useBreakpoint };
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/grid/index.tsx"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AAaT,cAbP,aAAG,CAaO;AAZjB,0EAAyD;AACzD,gDAAuB;AAWd,cAXF,aAAG,CAWE;AATZ,mBAAgB;AAEhB,uBAAuB;AACvB,SAAS,aAAa;IACpB,OAAO,IAAA,uBAAqB,GAAE,CAAA;AAChC,CAAC;AAED,6BAAyC;AACzC,6BAAgC;AAGhC,kBAAe,EAAE,aAAa,EAAE,CAAA","sourcesContent":["import Col from './col'\nimport useInternalBreakpoint from './hooks/useBreakpoint'\nimport Row from './row'\n\nimport './style'\n\n// Do not export params\nfunction useBreakpoint() {\n return useInternalBreakpoint()\n}\n\nexport { ColProps, ColSize } from './col'\nexport { RowProps } from './row'\nexport { Row, Col }\n\nexport default { useBreakpoint }\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Breakpoint } from '../_util/responsiveObserve';
|
|
3
|
+
declare const RowAligns: ["top", "middle", "bottom", "stretch"];
|
|
4
|
+
declare const RowJustify: ["start", "end", "center", "space-around", "space-between", "space-evenly"];
|
|
5
|
+
declare type Responsive = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
|
6
|
+
declare type ResponsiveLike<T> = {
|
|
7
|
+
[key in Responsive]?: T;
|
|
8
|
+
};
|
|
9
|
+
export declare type Gutter = number | undefined | Partial<Record<Breakpoint, number>>;
|
|
10
|
+
declare type ResponsiveAligns = ResponsiveLike<typeof RowAligns[number]>;
|
|
11
|
+
declare type ResponsiveJustify = ResponsiveLike<typeof RowJustify[number]>;
|
|
12
|
+
export interface RowProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
13
|
+
gutter?: Gutter | [Gutter, Gutter];
|
|
14
|
+
align?: typeof RowAligns[number] | ResponsiveAligns;
|
|
15
|
+
justify?: typeof RowJustify[number] | ResponsiveJustify;
|
|
16
|
+
prefixCls?: string;
|
|
17
|
+
wrap?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare const Row: React.ForwardRefExoticComponent<RowProps & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
export default Row;
|
|
21
|
+
//# sourceMappingURL=row.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row.d.ts","sourceRoot":"","sources":["../../src/grid/row.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,4BAA4B,CAAA;AAKvE,QAAA,MAAM,SAAS,wCAA8C,CAAA;AAC7D,QAAA,MAAM,UAAU,6EAAmF,CAAA;AAEnG,aAAK,UAAU,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAC1D,aAAK,cAAc,CAAC,CAAC,IAAI;KACtB,GAAG,IAAI,UAAU,CAAC,CAAC,EAAE,CAAC;CACxB,CAAA;AAGD,oBAAY,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAA;AAE7E,aAAK,gBAAgB,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;AAChE,aAAK,iBAAiB,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA;AAClE,MAAM,WAAW,QAAS,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IACpE,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC,KAAK,CAAC,EAAE,OAAO,SAAS,CAAC,MAAM,CAAC,GAAG,gBAAgB,CAAA;IACnD,OAAO,CAAC,EAAE,OAAO,UAAU,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAAA;IACvD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AA+BD,QAAA,MAAM,GAAG,iFA4HP,CAAA;AAMF,eAAe,GAAG,CAAA"}
|
package/lib/grid/row.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const context_1 = require("../_util/context");
|
|
43
|
+
const useFlexGapSupport_1 = __importDefault(require("../_util/hooks/useFlexGapSupport"));
|
|
44
|
+
const responsiveObserve_1 = __importStar(require("../_util/responsiveObserve"));
|
|
45
|
+
const type_1 = require("../_util/type");
|
|
46
|
+
const RowContext_1 = __importDefault(require("./RowContext"));
|
|
47
|
+
const RowAligns = (0, type_1.tuple)('top', 'middle', 'bottom', 'stretch');
|
|
48
|
+
const RowJustify = (0, type_1.tuple)('start', 'end', 'center', 'space-around', 'space-between', 'space-evenly');
|
|
49
|
+
function useMergePropByScreen(oriProp, screen) {
|
|
50
|
+
const [prop, setProp] = React.useState(typeof oriProp === 'string' ? oriProp : '');
|
|
51
|
+
const clacMergeAlignOrJustify = () => {
|
|
52
|
+
if (typeof oriProp === 'string') {
|
|
53
|
+
setProp(oriProp);
|
|
54
|
+
}
|
|
55
|
+
if (typeof oriProp !== 'object') {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
for (let i = 0; i < responsiveObserve_1.responsiveArray.length; i++) {
|
|
59
|
+
const breakpoint = responsiveObserve_1.responsiveArray[i];
|
|
60
|
+
// if do not match, do nothing
|
|
61
|
+
if (!screen[breakpoint])
|
|
62
|
+
continue;
|
|
63
|
+
const curVal = oriProp[breakpoint];
|
|
64
|
+
if (curVal !== undefined) {
|
|
65
|
+
setProp(curVal);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
clacMergeAlignOrJustify();
|
|
72
|
+
}, [JSON.stringify(oriProp), screen]);
|
|
73
|
+
return prop;
|
|
74
|
+
}
|
|
75
|
+
const Row = React.forwardRef((props, ref) => {
|
|
76
|
+
const { prefixCls: customizePrefixCls = 'tnt-row', justify, align, className, style, children, gutter = 0, wrap } = props, others = __rest(props, ["prefixCls", "justify", "align", "className", "style", "children", "gutter", "wrap"]);
|
|
77
|
+
const { getPrefixCls, direction } = React.useContext(context_1.ConfigContext);
|
|
78
|
+
const [screens, setScreens] = React.useState({
|
|
79
|
+
xs: true,
|
|
80
|
+
sm: true,
|
|
81
|
+
md: true,
|
|
82
|
+
lg: true,
|
|
83
|
+
xl: true,
|
|
84
|
+
xxl: true,
|
|
85
|
+
});
|
|
86
|
+
// to save screens info when responsiveObserve callback had been call
|
|
87
|
+
const [curScreens, setCurScreens] = React.useState({
|
|
88
|
+
xs: false,
|
|
89
|
+
sm: false,
|
|
90
|
+
md: false,
|
|
91
|
+
lg: false,
|
|
92
|
+
xl: false,
|
|
93
|
+
xxl: false,
|
|
94
|
+
});
|
|
95
|
+
// ================================== calc reponsive data ==================================
|
|
96
|
+
const mergeAlign = useMergePropByScreen(align, curScreens);
|
|
97
|
+
const mergeJustify = useMergePropByScreen(justify, curScreens);
|
|
98
|
+
const supportFlexGap = (0, useFlexGapSupport_1.default)();
|
|
99
|
+
const gutterRef = React.useRef(gutter);
|
|
100
|
+
// ================================== Effect ==================================
|
|
101
|
+
React.useEffect(() => {
|
|
102
|
+
const token = responsiveObserve_1.default.subscribe((screen) => {
|
|
103
|
+
setCurScreens(screen);
|
|
104
|
+
const currentGutter = gutterRef.current || 0;
|
|
105
|
+
if ((!Array.isArray(currentGutter) && typeof currentGutter === 'object') ||
|
|
106
|
+
(Array.isArray(currentGutter) &&
|
|
107
|
+
(typeof currentGutter[0] === 'object' || typeof currentGutter[1] === 'object'))) {
|
|
108
|
+
setScreens(screen);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
return () => responsiveObserve_1.default.unsubscribe(token);
|
|
112
|
+
}, []);
|
|
113
|
+
// ================================== Render ==================================
|
|
114
|
+
const getGutter = () => {
|
|
115
|
+
const results = [undefined, undefined];
|
|
116
|
+
const normalizedGutter = Array.isArray(gutter) ? gutter : [gutter, undefined];
|
|
117
|
+
normalizedGutter.forEach((g, index) => {
|
|
118
|
+
if (typeof g === 'object') {
|
|
119
|
+
for (let i = 0; i < responsiveObserve_1.responsiveArray.length; i++) {
|
|
120
|
+
const breakpoint = responsiveObserve_1.responsiveArray[i];
|
|
121
|
+
if (screens[breakpoint] && g[breakpoint] !== undefined) {
|
|
122
|
+
results[index] = g[breakpoint];
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
results[index] = g;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return results;
|
|
132
|
+
};
|
|
133
|
+
const prefixCls = getPrefixCls('row', customizePrefixCls);
|
|
134
|
+
const gutters = getGutter();
|
|
135
|
+
const classes = (0, classnames_1.default)(prefixCls, {
|
|
136
|
+
[`${prefixCls}-no-wrap`]: wrap === false,
|
|
137
|
+
[`${prefixCls}-${mergeJustify}`]: mergeJustify,
|
|
138
|
+
[`${prefixCls}-${mergeAlign}`]: mergeAlign,
|
|
139
|
+
[`${prefixCls}-rtl`]: direction === 'rtl',
|
|
140
|
+
}, className);
|
|
141
|
+
// Add gutter related style
|
|
142
|
+
const rowStyle = {};
|
|
143
|
+
const horizontalGutter = gutters[0] != null && gutters[0] > 0 ? gutters[0] / -2 : undefined;
|
|
144
|
+
const verticalGutter = gutters[1] != null && gutters[1] > 0 ? gutters[1] / -2 : undefined;
|
|
145
|
+
if (horizontalGutter) {
|
|
146
|
+
rowStyle.marginLeft = horizontalGutter;
|
|
147
|
+
rowStyle.marginRight = horizontalGutter;
|
|
148
|
+
}
|
|
149
|
+
if (supportFlexGap) {
|
|
150
|
+
// Set gap direct if flex gap support
|
|
151
|
+
;
|
|
152
|
+
[, rowStyle.rowGap] = gutters;
|
|
153
|
+
}
|
|
154
|
+
else if (verticalGutter) {
|
|
155
|
+
rowStyle.marginTop = verticalGutter;
|
|
156
|
+
rowStyle.marginBottom = verticalGutter;
|
|
157
|
+
}
|
|
158
|
+
// "gutters" is a new array in each rendering phase, it'll make 'React.useMemo' effectless.
|
|
159
|
+
// So we deconstruct "gutters" variable here.
|
|
160
|
+
const [gutterH, gutterV] = gutters;
|
|
161
|
+
const rowContext = React.useMemo(() => ({ gutter: [gutterH, gutterV], wrap, supportFlexGap }), [gutterH, gutterV, wrap, supportFlexGap]);
|
|
162
|
+
return (React.createElement(RowContext_1.default.Provider, { value: rowContext },
|
|
163
|
+
React.createElement("div", Object.assign({}, others, { className: classes, style: Object.assign(Object.assign({}, rowStyle), style), ref: ref }), children)));
|
|
164
|
+
});
|
|
165
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
166
|
+
Row.displayName = 'Row';
|
|
167
|
+
}
|
|
168
|
+
exports.default = Row;
|
|
169
|
+
//# sourceMappingURL=row.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row.js","sourceRoot":"","sources":["../../src/grid/row.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAmC;AACnC,6CAA8B;AAC9B,8CAAgD;AAChD,yFAAgE;AAEhE,gFAA+E;AAC/E,wCAAqC;AACrC,8DAAqC;AAErC,MAAM,SAAS,GAAG,IAAA,YAAK,EAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAA;AAC7D,MAAM,UAAU,GAAG,IAAA,YAAK,EAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,CAAC,CAAA;AAoBnG,SAAS,oBAAoB,CAAC,OAAgD,EAAE,MAAiB;IAC/F,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;IAElF,MAAM,uBAAuB,GAAG,GAAG,EAAE;QACnC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,OAAO,CAAC,OAAO,CAAC,CAAA;SACjB;QACD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,OAAM;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AAI,GAAG,EAAE,GAAG,KAC5E,QAAQ,CACL,CACc,CACvB,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,GAAG,CAAC,WAAW,GAAG,KAAK,CAAA;CACxB;AAED,kBAAe,GAAG,CAAA","sourcesContent":["import classNames from 'classnames'\nimport * as React from 'react'\nimport { ConfigContext } from '../_util/context'\nimport useFlexGapSupport from '../_util/hooks/useFlexGapSupport'\nimport type { Breakpoint, ScreenMap } from '../_util/responsiveObserve'\nimport ResponsiveObserve, { responsiveArray } from '../_util/responsiveObserve'\nimport { tuple } from '../_util/type'\nimport RowContext from './RowContext'\n\nconst RowAligns = tuple('top', 'middle', 'bottom', 'stretch')\nconst RowJustify = tuple('start', 'end', 'center', 'space-around', 'space-between', 'space-evenly')\n\ntype Responsive = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs'\ntype ResponsiveLike<T> = {\n [key in Responsive]?: T\n}\n\ntype Gap = number | undefined\nexport type Gutter = number | undefined | Partial<Record<Breakpoint, number>>\n\ntype ResponsiveAligns = ResponsiveLike<typeof RowAligns[number]>\ntype ResponsiveJustify = ResponsiveLike<typeof RowJustify[number]>\nexport interface RowProps extends React.HTMLAttributes<HTMLDivElement> {\n gutter?: Gutter | [Gutter, Gutter]\n align?: typeof RowAligns[number] | ResponsiveAligns\n justify?: typeof RowJustify[number] | ResponsiveJustify\n prefixCls?: string\n wrap?: boolean\n}\n\nfunction useMergePropByScreen(oriProp: RowProps['align'] | RowProps['justify'], screen: ScreenMap) {\n const [prop, setProp] = React.useState(typeof oriProp === 'string' ? oriProp : '')\n\n const clacMergeAlignOrJustify = () => {\n if (typeof oriProp === 'string') {\n setProp(oriProp)\n }\n if (typeof oriProp !== 'object') {\n return\n }\n for (let i = 0; i < responsiveArray.length; i++) {\n const breakpoint: Breakpoint = responsiveArray[i]\n // if do not match, do nothing\n if (!screen[breakpoint]) continue\n const curVal = oriProp[breakpoint]\n if (curVal !== undefined) {\n setProp(curVal)\n return\n }\n }\n }\n\n React.useEffect(() => {\n clacMergeAlignOrJustify()\n }, [JSON.stringify(oriProp), screen])\n\n return prop\n}\n\nconst Row = React.forwardRef<HTMLDivElement, RowProps>((props, ref) => {\n const {\n prefixCls: customizePrefixCls = 'tnt-row',\n justify,\n align,\n className,\n style,\n children,\n gutter = 0,\n wrap,\n ...others\n } = props\n\n const { getPrefixCls, direction } = React.useContext(ConfigContext)\n\n const [screens, setScreens] = React.useState<ScreenMap>({\n xs: true,\n sm: true,\n md: true,\n lg: true,\n xl: true,\n xxl: true,\n })\n // to save screens info when responsiveObserve callback had been call\n const [curScreens, setCurScreens] = React.useState<ScreenMap>({\n xs: false,\n sm: false,\n md: false,\n lg: false,\n xl: false,\n xxl: false,\n })\n\n // ================================== calc reponsive data ==================================\n const mergeAlign = useMergePropByScreen(align, curScreens)\n\n const mergeJustify = useMergePropByScreen(justify, curScreens)\n\n const supportFlexGap = useFlexGapSupport()\n\n const gutterRef = React.useRef<Gutter | [Gutter, Gutter]>(gutter)\n\n // ================================== Effect ==================================\n React.useEffect(() => {\n const token = ResponsiveObserve.subscribe((screen) => {\n setCurScreens(screen)\n const currentGutter = gutterRef.current || 0\n if (\n (!Array.isArray(currentGutter) && typeof currentGutter === 'object') ||\n (Array.isArray(currentGutter) &&\n (typeof currentGutter[0] === 'object' || typeof currentGutter[1] === 'object'))\n ) {\n setScreens(screen)\n }\n })\n return () => ResponsiveObserve.unsubscribe(token)\n }, [])\n\n // ================================== Render ==================================\n const getGutter = (): [Gap, Gap] => {\n const results: [Gap, Gap] = [undefined, undefined]\n const normalizedGutter = Array.isArray(gutter) ? gutter : [gutter, undefined]\n normalizedGutter.forEach((g, index) => {\n if (typeof g === 'object') {\n for (let i = 0; i < responsiveArray.length; i++) {\n const breakpoint: Breakpoint = responsiveArray[i]\n if (screens[breakpoint] && g[breakpoint] !== undefined) {\n results[index] = g[breakpoint] as number\n break\n }\n }\n } else {\n results[index] = g\n }\n })\n return results\n }\n\n const prefixCls = getPrefixCls('row', customizePrefixCls)\n const gutters = getGutter()\n const classes = classNames(\n prefixCls,\n {\n [`${prefixCls}-no-wrap`]: wrap === false,\n [`${prefixCls}-${mergeJustify}`]: mergeJustify,\n [`${prefixCls}-${mergeAlign}`]: mergeAlign,\n [`${prefixCls}-rtl`]: direction === 'rtl',\n },\n className\n )\n\n // Add gutter related style\n const rowStyle: React.CSSProperties = {}\n const horizontalGutter = gutters[0] != null && gutters[0] > 0 ? gutters[0] / -2 : undefined\n const verticalGutter = gutters[1] != null && gutters[1] > 0 ? gutters[1] / -2 : undefined\n\n if (horizontalGutter) {\n rowStyle.marginLeft = horizontalGutter\n rowStyle.marginRight = horizontalGutter\n }\n\n if (supportFlexGap) {\n // Set gap direct if flex gap support\n ;[, rowStyle.rowGap] = gutters\n } else if (verticalGutter) {\n rowStyle.marginTop = verticalGutter\n rowStyle.marginBottom = verticalGutter\n }\n\n // \"gutters\" is a new array in each rendering phase, it'll make 'React.useMemo' effectless.\n // So we deconstruct \"gutters\" variable here.\n const [gutterH, gutterV] = gutters\n const rowContext = React.useMemo(\n () => ({ gutter: [gutterH, gutterV] as [number, number], wrap, supportFlexGap }),\n [gutterH, gutterV, wrap, supportFlexGap]\n )\n\n return (\n <RowContext.Provider value={rowContext}>\n <div {...others} className={classes} style={{ ...rowStyle, ...style }} ref={ref}>\n {children}\n </div>\n </RowContext.Provider>\n )\n})\n\nif (process.env.NODE_ENV !== 'production') {\n Row.displayName = 'Row'\n}\n\nexport default Row\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/grid/style/index.tsx"],"names":[],"mappings":"AACA,OAAO,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/grid/style/index.tsx"],"names":[],"mappings":";;AAAA,mCAAmC;AACnC,wBAAqB","sourcesContent":["// import '../../style/index.less';\nimport './index.less'\n"]}
|