@pisell/materials 1.0.1057 → 1.0.1059
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +3 -3
- package/build/lowcode/preview.js +9 -9
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +20 -20
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +23 -23
- package/es/components/PisellCards/index.d.ts +3 -0
- package/es/components/PisellCards/index.js +3 -1
- package/es/components/PisellContactBrief/PisellContactBrief.d.ts +13 -0
- package/es/components/PisellContactBrief/PisellContactBrief.js +223 -0
- package/es/components/PisellContactBrief/PisellContactBrief.less +192 -0
- package/es/components/PisellContactBrief/PisellContactBrief.stories.d.ts +31 -0
- package/es/components/PisellContactBrief/PisellContactBrief.stories.js +196 -0
- package/es/components/PisellContactBrief/components/ContactFormModal.d.ts +23 -0
- package/es/components/PisellContactBrief/components/ContactFormModal.js +177 -0
- package/es/components/PisellContactBrief/components/index.d.ts +5 -0
- package/es/components/PisellContactBrief/components/index.js +4 -0
- package/es/components/PisellContactBrief/index.d.ts +6 -0
- package/es/components/PisellContactBrief/index.js +5 -0
- package/es/components/PisellContactBrief/locales.d.ts +55 -0
- package/es/components/PisellContactBrief/locales.js +54 -0
- package/es/components/PisellContactBrief/types.d.ts +82 -0
- package/es/components/PisellContactBrief/types.js +1 -0
- package/es/components/dataSourceComponents/fields/Tabs/Tabs.less +8 -0
- package/es/components/pisellActionPanel/PisellActionPanel.d.ts +13 -0
- package/es/components/pisellActionPanel/PisellActionPanel.js +98 -0
- package/es/components/pisellActionPanel/PisellActionPanel.less +69 -0
- package/es/components/pisellActionPanel/PisellActionPanel.stories.d.ts +19 -0
- package/es/components/pisellActionPanel/PisellActionPanel.stories.js +208 -0
- package/es/components/pisellActionPanel/index.d.ts +6 -0
- package/es/components/pisellActionPanel/index.js +5 -0
- package/es/components/pisellActionPanel/types.d.ts +83 -0
- package/es/components/pisellActionPanel/types.js +1 -0
- package/es/components/pisellBaseCard/PisellBaseCard.d.ts +8 -0
- package/es/components/pisellBaseCard/PisellBaseCard.js +96 -0
- package/es/components/pisellBaseCard/PisellBaseCard.less +25 -0
- package/es/components/pisellBaseCard/PisellBaseCard.stories.d.ts +19 -0
- package/es/components/pisellBaseCard/PisellBaseCard.stories.js +99 -0
- package/es/components/pisellBaseCard/index.d.ts +5 -0
- package/es/components/pisellBaseCard/index.js +4 -0
- package/es/components/pisellBaseCard/types.d.ts +45 -0
- package/es/components/pisellBaseCard/types.js +1 -0
- package/es/components/pisellCurrency/PisellCurrency.js +18 -12
- package/es/components/pisellCurrency/PisellCurrency.less +0 -123
- package/es/components/pisellCustomerBrief/PisellCustomerBrief.d.ts +15 -0
- package/es/components/pisellCustomerBrief/PisellCustomerBrief.js +145 -0
- package/es/components/pisellCustomerBrief/PisellCustomerBrief.less +8 -0
- package/es/components/pisellCustomerBrief/PisellCustomerBrief.stories.d.ts +23 -0
- package/es/components/pisellCustomerBrief/PisellCustomerBrief.stories.js +193 -0
- package/es/components/pisellCustomerBrief/index.d.ts +6 -0
- package/es/components/pisellCustomerBrief/index.js +5 -0
- package/es/components/pisellCustomerBrief/types.d.ts +82 -0
- package/es/components/pisellCustomerBrief/types.js +1 -0
- package/es/components/pisellEmail/PisellEmail.js +48 -42
- package/es/components/pisellEmail/PisellEmail.less +0 -92
- package/es/components/pisellEntityCard/PisellEntityCard.d.ts +8 -0
- package/es/components/pisellEntityCard/PisellEntityCard.js +474 -0
- package/es/components/pisellEntityCard/PisellEntityCard.less +362 -0
- package/es/components/pisellEntityCard/PisellEntityCard.stories.d.ts +47 -0
- package/es/components/pisellEntityCard/PisellEntityCard.stories.js +450 -0
- package/es/components/pisellEntityCard/index.d.ts +5 -0
- package/es/components/pisellEntityCard/index.js +4 -0
- package/es/components/pisellEntityCard/types.d.ts +144 -0
- package/es/components/pisellEntityCard/types.js +1 -0
- package/es/components/pisellFloorMapLayout/PisellFloorMapLayout.js +32 -4
- package/es/components/pisellFloorMapLayout/PisellFloorMapLayout.stories.js +4 -2
- package/es/components/pisellFloorMapLayout/components/ViewControls.d.ts +4 -0
- package/es/components/pisellFloorMapLayout/components/ViewControls.js +12 -2
- package/es/components/pisellFloorMapLayout/types.d.ts +2 -0
- package/es/components/pisellLongText/PisellLongText.js +18 -12
- package/es/components/pisellLongText/PisellLongText.less +0 -67
- package/es/components/pisellLookup/PisellLookup.js +8 -1
- package/es/components/pisellMultipleSelect/PisellMultipleSelect.js +14 -6
- package/es/components/pisellMultipleSelect/PisellMultipleSelect.less +18 -139
- package/es/components/pisellMultipleSelect/components/EditView.js +1 -0
- package/es/components/pisellNumber/PisellNumber.js +18 -12
- package/es/components/pisellNumber/PisellNumber.less +0 -103
- package/es/components/pisellPhone/PisellPhone.js +18 -12
- package/es/components/pisellPhone/PisellPhone.less +0 -119
- package/es/components/pisellPhone/components/EditView.js +44 -33
- package/es/components/pisellPhone/constants/countryCodes.d.ts +1 -0
- package/es/components/pisellPhone/constants/countryCodes.js +26 -25
- package/es/components/pisellPhone/types.d.ts +2 -2
- package/es/components/pisellPhone/utils/countryCodeHelper.d.ts +4 -4
- package/es/components/pisellPhone/utils/countryCodeHelper.js +5 -5
- package/es/components/pisellRating/PisellRating.js +7 -3
- package/es/components/pisellSingleLineText/PisellSingleLineText.js +27 -20
- package/es/components/pisellSingleLineText/PisellSingleLineText.less +58 -201
- package/es/components/pisellSingleSelect/PisellSingleSelect.js +14 -5
- package/es/components/pisellSingleSelect/PisellSingleSelect.less +5 -106
- package/es/components/pisellUrl/PisellUrl.js +48 -42
- package/es/components/pisellWalletPassCard/index.js +2 -1
- package/es/index.d.ts +15 -4
- package/es/index.js +8 -4
- package/es/theme/pisell-components.d.ts +14 -0
- package/es/theme/pisell-components.js +74 -0
- package/lib/components/PisellCards/index.d.ts +3 -0
- package/lib/components/PisellCards/index.js +3 -1
- package/lib/components/PisellContactBrief/PisellContactBrief.d.ts +13 -0
- package/lib/components/PisellContactBrief/PisellContactBrief.js +231 -0
- package/lib/components/PisellContactBrief/PisellContactBrief.less +192 -0
- package/lib/components/PisellContactBrief/PisellContactBrief.stories.d.ts +31 -0
- package/lib/components/PisellContactBrief/PisellContactBrief.stories.js +188 -0
- package/lib/components/PisellContactBrief/components/ContactFormModal.d.ts +23 -0
- package/lib/components/PisellContactBrief/components/ContactFormModal.js +154 -0
- package/lib/components/PisellContactBrief/components/index.d.ts +5 -0
- package/lib/components/PisellContactBrief/components/index.js +29 -0
- package/lib/components/PisellContactBrief/index.d.ts +6 -0
- package/lib/components/PisellContactBrief/index.js +29 -0
- package/lib/components/PisellContactBrief/locales.d.ts +55 -0
- package/lib/components/PisellContactBrief/locales.js +74 -0
- package/lib/components/PisellContactBrief/types.d.ts +82 -0
- package/lib/components/PisellContactBrief/types.js +17 -0
- package/lib/components/dataSourceComponents/fields/Tabs/Tabs.less +8 -0
- package/lib/components/pisellActionPanel/PisellActionPanel.d.ts +13 -0
- package/lib/components/pisellActionPanel/PisellActionPanel.js +124 -0
- package/lib/components/pisellActionPanel/PisellActionPanel.less +69 -0
- package/lib/components/pisellActionPanel/PisellActionPanel.stories.d.ts +19 -0
- package/lib/components/pisellActionPanel/PisellActionPanel.stories.js +186 -0
- package/lib/components/pisellActionPanel/index.d.ts +6 -0
- package/lib/components/pisellActionPanel/index.js +29 -0
- package/lib/components/pisellActionPanel/types.d.ts +83 -0
- package/lib/components/pisellActionPanel/types.js +17 -0
- package/lib/components/pisellBaseCard/PisellBaseCard.d.ts +8 -0
- package/lib/components/pisellBaseCard/PisellBaseCard.js +124 -0
- package/lib/components/pisellBaseCard/PisellBaseCard.less +25 -0
- package/lib/components/pisellBaseCard/PisellBaseCard.stories.d.ts +19 -0
- package/lib/components/pisellBaseCard/PisellBaseCard.stories.js +107 -0
- package/lib/components/pisellBaseCard/index.d.ts +5 -0
- package/lib/components/pisellBaseCard/index.js +29 -0
- package/lib/components/pisellBaseCard/types.d.ts +45 -0
- package/lib/components/pisellBaseCard/types.js +17 -0
- package/lib/components/pisellCurrency/PisellCurrency.js +16 -10
- package/lib/components/pisellCurrency/PisellCurrency.less +0 -123
- package/lib/components/pisellCustomerBrief/PisellCustomerBrief.d.ts +15 -0
- package/lib/components/pisellCustomerBrief/PisellCustomerBrief.js +143 -0
- package/lib/components/pisellCustomerBrief/PisellCustomerBrief.less +8 -0
- package/lib/components/pisellCustomerBrief/PisellCustomerBrief.stories.d.ts +23 -0
- package/lib/components/pisellCustomerBrief/PisellCustomerBrief.stories.js +171 -0
- package/lib/components/pisellCustomerBrief/index.d.ts +6 -0
- package/lib/components/pisellCustomerBrief/index.js +29 -0
- package/lib/components/pisellCustomerBrief/types.d.ts +82 -0
- package/lib/components/pisellCustomerBrief/types.js +17 -0
- package/lib/components/pisellEmail/PisellEmail.js +16 -10
- package/lib/components/pisellEmail/PisellEmail.less +0 -92
- package/lib/components/pisellEntityCard/PisellEntityCard.d.ts +8 -0
- package/lib/components/pisellEntityCard/PisellEntityCard.js +426 -0
- package/lib/components/pisellEntityCard/PisellEntityCard.less +362 -0
- package/lib/components/pisellEntityCard/PisellEntityCard.stories.d.ts +47 -0
- package/lib/components/pisellEntityCard/PisellEntityCard.stories.js +349 -0
- package/lib/components/pisellEntityCard/index.d.ts +5 -0
- package/lib/components/pisellEntityCard/index.js +29 -0
- package/lib/components/pisellEntityCard/types.d.ts +144 -0
- package/lib/components/pisellEntityCard/types.js +17 -0
- package/lib/components/pisellFloorMapLayout/PisellFloorMapLayout.js +22 -3
- package/lib/components/pisellFloorMapLayout/PisellFloorMapLayout.stories.js +2 -2
- package/lib/components/pisellFloorMapLayout/components/ViewControls.d.ts +4 -0
- package/lib/components/pisellFloorMapLayout/components/ViewControls.js +11 -1
- package/lib/components/pisellFloorMapLayout/types.d.ts +2 -0
- package/lib/components/pisellLongText/PisellLongText.js +16 -10
- package/lib/components/pisellLongText/PisellLongText.less +0 -67
- package/lib/components/pisellLookup/PisellLookup.js +5 -1
- package/lib/components/pisellMultipleSelect/PisellMultipleSelect.js +62 -53
- package/lib/components/pisellMultipleSelect/PisellMultipleSelect.less +18 -139
- package/lib/components/pisellMultipleSelect/components/EditView.js +42 -30
- package/lib/components/pisellNumber/PisellNumber.js +16 -10
- package/lib/components/pisellNumber/PisellNumber.less +0 -103
- package/lib/components/pisellPhone/PisellPhone.js +16 -10
- package/lib/components/pisellPhone/PisellPhone.less +0 -119
- package/lib/components/pisellPhone/components/EditView.js +40 -24
- package/lib/components/pisellPhone/constants/countryCodes.d.ts +1 -0
- package/lib/components/pisellPhone/constants/countryCodes.js +24 -24
- package/lib/components/pisellPhone/types.d.ts +2 -2
- package/lib/components/pisellPhone/utils/countryCodeHelper.d.ts +4 -4
- package/lib/components/pisellPhone/utils/countryCodeHelper.js +1 -1
- package/lib/components/pisellRating/PisellRating.js +4 -2
- package/lib/components/pisellSingleLineText/PisellSingleLineText.js +16 -10
- package/lib/components/pisellSingleLineText/PisellSingleLineText.less +58 -201
- package/lib/components/pisellSingleSelect/PisellSingleSelect.js +34 -35
- package/lib/components/pisellSingleSelect/PisellSingleSelect.less +5 -106
- package/lib/components/pisellUrl/PisellUrl.js +16 -10
- package/lib/components/pisellWalletPassCard/index.js +1 -1
- package/lib/index.d.ts +15 -4
- package/lib/index.js +18 -3
- package/lib/theme/pisell-components.d.ts +14 -0
- package/lib/theme/pisell-components.js +89 -0
- package/lowcode/pisell-action-panel/meta.ts +146 -0
- package/lowcode/pisell-action-panel/snippets.ts +42 -0
- package/lowcode/pisell-base-card/meta.ts +98 -0
- package/lowcode/pisell-base-card/snippets.ts +13 -0
- package/lowcode/pisell-contact-brief/meta.ts +178 -0
- package/lowcode/pisell-contact-brief/snippets.ts +40 -0
- package/lowcode/pisell-customer-brief/meta.ts +262 -0
- package/lowcode/pisell-customer-brief/snippets.ts +46 -0
- package/lowcode/pisell-entity-card/meta.ts +296 -0
- package/lowcode/pisell-entity-card/snippets.ts +41 -0
- package/lowcode/pisell-floor-map-layout/meta.ts +37 -1
- package/package.json +4 -4
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
14
|
+
import classNames from 'classnames';
|
|
15
|
+
import { Avatar, Typography } from 'antd';
|
|
16
|
+
import { InfoCircleOutlined } from '@ant-design/icons';
|
|
17
|
+
import { PisellBaseCard } from "../pisellBaseCard";
|
|
18
|
+
import "./PisellEntityCard.less";
|
|
19
|
+
|
|
20
|
+
/** 左滑删除区域宽度(px) */
|
|
21
|
+
var SWIPE_DELETE_WIDTH = 72;
|
|
22
|
+
/** 触发显示删除按钮的滑动阈值(px) */
|
|
23
|
+
var SWIPE_THRESHOLD = 36;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 设计准则(见设计文档 6):
|
|
27
|
+
* - 当信息字段缺少时,不显示:例如选 B5 但只有 2 条次级,则只展示 2 条,视觉与 B2 一致。
|
|
28
|
+
* - 当字段超出规范时,不展示:例如选 B2 但有 5 条次级,只展示前 2 条。
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/** 按密度得到次级文案最大行数:B1 不展示,B2=2,B5=5,B9 不限制 */
|
|
32
|
+
function getSecondaryLineClampByDensity(density) {
|
|
33
|
+
switch (density) {
|
|
34
|
+
case 'B1':
|
|
35
|
+
return 0;
|
|
36
|
+
case 'B2':
|
|
37
|
+
return 2;
|
|
38
|
+
case 'B5':
|
|
39
|
+
return 5;
|
|
40
|
+
case 'B9':
|
|
41
|
+
default:
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** 按密度得到次级文案最大条数(超出则只展示前 N 条) */
|
|
47
|
+
function getSecondaryMaxItemsByDensity(density) {
|
|
48
|
+
switch (density) {
|
|
49
|
+
case 'B1':
|
|
50
|
+
return 0;
|
|
51
|
+
case 'B2':
|
|
52
|
+
return 2;
|
|
53
|
+
case 'B5':
|
|
54
|
+
return 5;
|
|
55
|
+
case 'B9':
|
|
56
|
+
default:
|
|
57
|
+
return 999;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** 按密度得到标签最大条数(与次级文案规则一致) */
|
|
62
|
+
function getTagsMaxByDensity(density) {
|
|
63
|
+
switch (density) {
|
|
64
|
+
case 'B1':
|
|
65
|
+
return 2;
|
|
66
|
+
// B1 一行时 inline 最多 2 个
|
|
67
|
+
case 'B2':
|
|
68
|
+
return 2;
|
|
69
|
+
case 'B5':
|
|
70
|
+
return 5;
|
|
71
|
+
case 'B9':
|
|
72
|
+
default:
|
|
73
|
+
return 999;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 渲染媒体区:头像 / 缩略图 / 图标
|
|
79
|
+
*/
|
|
80
|
+
function renderMediaNode(config) {
|
|
81
|
+
var _config$size, _config$shape;
|
|
82
|
+
var size = (_config$size = config.size) !== null && _config$size !== void 0 ? _config$size : 40;
|
|
83
|
+
var sizePx = typeof size === 'number' ? "".concat(size, "px") : size;
|
|
84
|
+
var shape = (_config$shape = config.shape) !== null && _config$shape !== void 0 ? _config$shape : 'circle';
|
|
85
|
+
if (config.type === 'icon' && config.icon) {
|
|
86
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
87
|
+
className: "pisell-entity-card-media pisell-entity-card-media-icon",
|
|
88
|
+
style: {
|
|
89
|
+
width: sizePx,
|
|
90
|
+
height: sizePx,
|
|
91
|
+
color: config.color,
|
|
92
|
+
fontSize: sizePx,
|
|
93
|
+
display: 'inline-flex',
|
|
94
|
+
alignItems: 'center',
|
|
95
|
+
justifyContent: 'center'
|
|
96
|
+
}
|
|
97
|
+
}, config.icon);
|
|
98
|
+
}
|
|
99
|
+
if (config.type === 'avatar' || config.type === 'thumbnail') {
|
|
100
|
+
return /*#__PURE__*/React.createElement(Avatar, {
|
|
101
|
+
src: config.src,
|
|
102
|
+
alt: config.alt,
|
|
103
|
+
shape: shape === 'circle' ? 'circle' : 'square',
|
|
104
|
+
style: {
|
|
105
|
+
width: sizePx,
|
|
106
|
+
height: sizePx,
|
|
107
|
+
flexShrink: 0
|
|
108
|
+
},
|
|
109
|
+
className: "pisell-entity-card-media pisell-entity-card-media-avatar"
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* PisellEntityCard 实体卡片
|
|
117
|
+
* 基于 PisellBaseCard,使用结构化配置展示实体信息,支持密度、布局、左滑删除与插槽
|
|
118
|
+
*/
|
|
119
|
+
export function PisellEntityCard(_ref) {
|
|
120
|
+
var children = _ref.children,
|
|
121
|
+
className = _ref.className,
|
|
122
|
+
style = _ref.style,
|
|
123
|
+
hoverStyle = _ref.hoverStyle,
|
|
124
|
+
activeStyle = _ref.activeStyle,
|
|
125
|
+
disabledStyle = _ref.disabledStyle,
|
|
126
|
+
_ref$clickable = _ref.clickable,
|
|
127
|
+
clickable = _ref$clickable === void 0 ? true : _ref$clickable,
|
|
128
|
+
_ref$disabled = _ref.disabled,
|
|
129
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
130
|
+
onClick = _ref.onClick,
|
|
131
|
+
media = _ref.media,
|
|
132
|
+
primaryText = _ref.primaryText,
|
|
133
|
+
subtitleText = _ref.subtitleText,
|
|
134
|
+
_ref$secondaryTexts = _ref.secondaryTexts,
|
|
135
|
+
secondaryTexts = _ref$secondaryTexts === void 0 ? [] : _ref$secondaryTexts,
|
|
136
|
+
_ref$tags = _ref.tags,
|
|
137
|
+
tags = _ref$tags === void 0 ? [] : _ref$tags,
|
|
138
|
+
_ref$actions = _ref.actions,
|
|
139
|
+
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
140
|
+
_ref$showMedia = _ref.showMedia,
|
|
141
|
+
showMedia = _ref$showMedia === void 0 ? true : _ref$showMedia,
|
|
142
|
+
_ref$showPrimaryText = _ref.showPrimaryText,
|
|
143
|
+
showPrimaryText = _ref$showPrimaryText === void 0 ? true : _ref$showPrimaryText,
|
|
144
|
+
_ref$showSubtitle = _ref.showSubtitle,
|
|
145
|
+
showSubtitle = _ref$showSubtitle === void 0 ? true : _ref$showSubtitle,
|
|
146
|
+
_ref$showSecondaryTex = _ref.showSecondaryText,
|
|
147
|
+
showSecondaryText = _ref$showSecondaryTex === void 0 ? true : _ref$showSecondaryTex,
|
|
148
|
+
_ref$showTags = _ref.showTags,
|
|
149
|
+
showTags = _ref$showTags === void 0 ? true : _ref$showTags,
|
|
150
|
+
_ref$showActions = _ref.showActions,
|
|
151
|
+
showActions = _ref$showActions === void 0 ? false : _ref$showActions,
|
|
152
|
+
_ref$density = _ref.density,
|
|
153
|
+
density = _ref$density === void 0 ? 'B2' : _ref$density,
|
|
154
|
+
_ref$layout = _ref.layout,
|
|
155
|
+
layout = _ref$layout === void 0 ? 'horizontal' : _ref$layout,
|
|
156
|
+
_ref$width = _ref.width,
|
|
157
|
+
width = _ref$width === void 0 ? 'content' : _ref$width,
|
|
158
|
+
_ref$swipeToDelete = _ref.swipeToDelete,
|
|
159
|
+
swipeToDelete = _ref$swipeToDelete === void 0 ? false : _ref$swipeToDelete,
|
|
160
|
+
onDelete = _ref.onDelete,
|
|
161
|
+
_ref$tagPosition = _ref.tagPosition,
|
|
162
|
+
tagPosition = _ref$tagPosition === void 0 ? 'below' : _ref$tagPosition,
|
|
163
|
+
contentGap = _ref.contentGap,
|
|
164
|
+
primaryLineClamp = _ref.primaryLineClamp,
|
|
165
|
+
secondaryLineClampProp = _ref.secondaryLineClamp,
|
|
166
|
+
renderMedia = _ref.renderMedia,
|
|
167
|
+
renderPrimary = _ref.renderPrimary,
|
|
168
|
+
renderSubtitle = _ref.renderSubtitle,
|
|
169
|
+
renderSecondary = _ref.renderSecondary,
|
|
170
|
+
renderTags = _ref.renderTags,
|
|
171
|
+
renderActions = _ref.renderActions;
|
|
172
|
+
var _useState = useState(0),
|
|
173
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
174
|
+
swipeOffset = _useState2[0],
|
|
175
|
+
setSwipeOffset = _useState2[1];
|
|
176
|
+
var _useState3 = useState(null),
|
|
177
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
178
|
+
swipeStart = _useState4[0],
|
|
179
|
+
setSwipeStart = _useState4[1];
|
|
180
|
+
/** 同步写入,保证 touchmove/mousemove 在当次事件流中能读到起始位置(setState 异步会滞后) */
|
|
181
|
+
var swipeStartDataRef = useRef(null);
|
|
182
|
+
var swipeOffsetRef = useRef(swipeOffset);
|
|
183
|
+
swipeOffsetRef.current = swipeOffset;
|
|
184
|
+
var swipeContainerRef = useRef(null);
|
|
185
|
+
var secondaryLineClamp = secondaryLineClampProp !== null && secondaryLineClampProp !== void 0 ? secondaryLineClampProp : getSecondaryLineClampByDensity(density);
|
|
186
|
+
var secondaryMaxItems = getSecondaryMaxItemsByDensity(density);
|
|
187
|
+
var tagsMaxItems = getTagsMaxByDensity(density);
|
|
188
|
+
/** 次级文案:按密度截断,缺时不补空(选 B5 仅 2 条则只显示 2 条,与 B2 一致) */
|
|
189
|
+
var effectiveSecondary = useMemo(function () {
|
|
190
|
+
return secondaryLineClamp === 0 ? [] : secondaryTexts.slice(0, secondaryMaxItems);
|
|
191
|
+
}, [secondaryTexts, secondaryLineClamp, secondaryMaxItems]);
|
|
192
|
+
/** 标签:按密度截断,超出规范只展示前 N 个 */
|
|
193
|
+
var effectiveTags = useMemo(function () {
|
|
194
|
+
return tags.slice(0, tagsMaxItems);
|
|
195
|
+
}, [tags, tagsMaxItems]);
|
|
196
|
+
var rootWidthStyle = useMemo(function () {
|
|
197
|
+
if (width === 'full') return {
|
|
198
|
+
width: '100%'
|
|
199
|
+
};
|
|
200
|
+
if (typeof width === 'number') return {
|
|
201
|
+
width: "".concat(width, "px")
|
|
202
|
+
};
|
|
203
|
+
return {
|
|
204
|
+
width: 'fit-content'
|
|
205
|
+
};
|
|
206
|
+
}, [width]);
|
|
207
|
+
var handleSwipeStart = useCallback(function (x, isTouch) {
|
|
208
|
+
if (!swipeToDelete || !onDelete) return;
|
|
209
|
+
swipeStartDataRef.current = {
|
|
210
|
+
x: x,
|
|
211
|
+
isTouch: isTouch
|
|
212
|
+
};
|
|
213
|
+
setSwipeStart({
|
|
214
|
+
x: x,
|
|
215
|
+
isTouch: isTouch
|
|
216
|
+
});
|
|
217
|
+
}, [swipeToDelete, onDelete]);
|
|
218
|
+
|
|
219
|
+
/** 左滑删除:手指往左滑 → 内容往左移 → 露出右侧删除。delta = start - currentX:左滑时 currentX 变小 delta>0,取 -delta 为负 offset */
|
|
220
|
+
var handleSwipeMove = useCallback(function (currentX) {
|
|
221
|
+
var start = swipeStartDataRef.current;
|
|
222
|
+
if (start === null) return;
|
|
223
|
+
var delta = start.x - currentX;
|
|
224
|
+
var next = Math.max(-SWIPE_DELETE_WIDTH, Math.min(0, -delta));
|
|
225
|
+
swipeOffsetRef.current = next;
|
|
226
|
+
setSwipeOffset(next);
|
|
227
|
+
}, []);
|
|
228
|
+
var handleSwipeEnd = useCallback(function () {
|
|
229
|
+
var start = swipeStartDataRef.current;
|
|
230
|
+
var offset = swipeOffsetRef.current;
|
|
231
|
+
swipeStartDataRef.current = null;
|
|
232
|
+
if (start === null) return;
|
|
233
|
+
var committed = offset <= -SWIPE_THRESHOLD ? -SWIPE_DELETE_WIDTH : 0;
|
|
234
|
+
setSwipeOffset(committed);
|
|
235
|
+
setSwipeStart(null);
|
|
236
|
+
}, []);
|
|
237
|
+
|
|
238
|
+
/** 文档级鼠标滑动:鼠标移出容器后仍能继续滑动与松手 */
|
|
239
|
+
useEffect(function () {
|
|
240
|
+
if ((swipeStart === null || swipeStart === void 0 ? void 0 : swipeStart.isTouch) !== false) return;
|
|
241
|
+
var onDocMove = function onDocMove(e) {
|
|
242
|
+
var start = swipeStartDataRef.current;
|
|
243
|
+
if (start === null) return;
|
|
244
|
+
var delta = start.x - e.clientX;
|
|
245
|
+
var next = Math.max(-SWIPE_DELETE_WIDTH, Math.min(0, -delta));
|
|
246
|
+
swipeOffsetRef.current = next;
|
|
247
|
+
setSwipeOffset(next);
|
|
248
|
+
};
|
|
249
|
+
var onDocUp = function onDocUp() {
|
|
250
|
+
var start = swipeStartDataRef.current;
|
|
251
|
+
var offset = swipeOffsetRef.current;
|
|
252
|
+
if (start === null) return;
|
|
253
|
+
var committed = offset <= -SWIPE_THRESHOLD ? -SWIPE_DELETE_WIDTH : 0;
|
|
254
|
+
setSwipeOffset(committed);
|
|
255
|
+
setSwipeStart(null);
|
|
256
|
+
};
|
|
257
|
+
document.addEventListener('mousemove', onDocMove);
|
|
258
|
+
document.addEventListener('mouseup', onDocUp);
|
|
259
|
+
return function () {
|
|
260
|
+
document.removeEventListener('mousemove', onDocMove);
|
|
261
|
+
document.removeEventListener('mouseup', onDocUp);
|
|
262
|
+
};
|
|
263
|
+
}, [swipeStart === null || swipeStart === void 0 ? void 0 : swipeStart.isTouch]);
|
|
264
|
+
var onTouchStart = useCallback(function (e) {
|
|
265
|
+
return handleSwipeStart(e.touches[0].clientX, true);
|
|
266
|
+
}, [handleSwipeStart]);
|
|
267
|
+
var onTouchMove = useCallback(function (e) {
|
|
268
|
+
if (swipeStartDataRef.current !== null) {
|
|
269
|
+
e.preventDefault();
|
|
270
|
+
handleSwipeMove(e.touches[0].clientX);
|
|
271
|
+
}
|
|
272
|
+
}, [handleSwipeMove]);
|
|
273
|
+
var onTouchEnd = useCallback(function () {
|
|
274
|
+
return handleSwipeEnd();
|
|
275
|
+
}, [handleSwipeEnd]);
|
|
276
|
+
var onMouseDown = useCallback(function (e) {
|
|
277
|
+
e.preventDefault();
|
|
278
|
+
handleSwipeStart(e.clientX, false);
|
|
279
|
+
}, [handleSwipeStart]);
|
|
280
|
+
var onMouseMove = useCallback(function (e) {
|
|
281
|
+
var _swipeStartDataRef$cu;
|
|
282
|
+
if (((_swipeStartDataRef$cu = swipeStartDataRef.current) === null || _swipeStartDataRef$cu === void 0 ? void 0 : _swipeStartDataRef$cu.isTouch) === false) handleSwipeMove(e.clientX);
|
|
283
|
+
}, [handleSwipeMove]);
|
|
284
|
+
var onMouseUp = useCallback(function () {
|
|
285
|
+
return handleSwipeEnd();
|
|
286
|
+
}, [handleSwipeEnd]);
|
|
287
|
+
var onMouseLeave = useCallback(function () {
|
|
288
|
+
if (swipeStartDataRef.current !== null) {
|
|
289
|
+
swipeStartDataRef.current = null;
|
|
290
|
+
setSwipeOffset(0);
|
|
291
|
+
setSwipeStart(null);
|
|
292
|
+
}
|
|
293
|
+
}, []);
|
|
294
|
+
var handleDeleteClick = useCallback(function (e) {
|
|
295
|
+
e.stopPropagation();
|
|
296
|
+
onDelete === null || onDelete === void 0 || onDelete();
|
|
297
|
+
}, [onDelete]);
|
|
298
|
+
var hasSwipe = swipeToDelete && !!onDelete;
|
|
299
|
+
|
|
300
|
+
/** 移动端:用原生 touchmove 且 passive: false,否则 preventDefault 不生效,无法拦截滚动 */
|
|
301
|
+
useEffect(function () {
|
|
302
|
+
if (!hasSwipe || !swipeContainerRef.current) return;
|
|
303
|
+
var el = swipeContainerRef.current;
|
|
304
|
+
var onTouchMoveNative = function onTouchMoveNative(e) {
|
|
305
|
+
if (swipeStartDataRef.current !== null) {
|
|
306
|
+
e.preventDefault();
|
|
307
|
+
handleSwipeMove(e.touches[0].clientX);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
el.addEventListener('touchmove', onTouchMoveNative, {
|
|
311
|
+
passive: false
|
|
312
|
+
});
|
|
313
|
+
return function () {
|
|
314
|
+
return el.removeEventListener('touchmove', onTouchMoveNative);
|
|
315
|
+
};
|
|
316
|
+
}, [hasSwipe, handleSwipeMove]);
|
|
317
|
+
|
|
318
|
+
/** 滑出删除后,点击/触摸别处关闭滑出 */
|
|
319
|
+
useEffect(function () {
|
|
320
|
+
if (!hasSwipe || swipeOffset >= 0) return;
|
|
321
|
+
var closeIfOutside = function closeIfOutside(e) {
|
|
322
|
+
var target = e.target;
|
|
323
|
+
if (target && swipeContainerRef.current && !swipeContainerRef.current.contains(target)) {
|
|
324
|
+
setSwipeOffset(0);
|
|
325
|
+
setSwipeStart(null);
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
document.addEventListener('click', closeIfOutside);
|
|
329
|
+
document.addEventListener('touchend', closeIfOutside);
|
|
330
|
+
return function () {
|
|
331
|
+
document.removeEventListener('click', closeIfOutside);
|
|
332
|
+
document.removeEventListener('touchend', closeIfOutside);
|
|
333
|
+
};
|
|
334
|
+
}, [hasSwipe, swipeOffset]);
|
|
335
|
+
var contentGapStyle = contentGap !== undefined ? {
|
|
336
|
+
gap: typeof contentGap === 'number' ? "".concat(contentGap, "px") : contentGap
|
|
337
|
+
} : undefined;
|
|
338
|
+
|
|
339
|
+
/** Figma 设计稿默认卡片样式:8px 圆角、8px 内边距、Gray/300 边框、白底、无阴影 */
|
|
340
|
+
var defaultCardStyle = {
|
|
341
|
+
padding: 8,
|
|
342
|
+
borderRadius: 8,
|
|
343
|
+
border: '1px solid #d0d5dd',
|
|
344
|
+
backgroundColor: '#ffffff',
|
|
345
|
+
boxShadow: 'none'
|
|
346
|
+
};
|
|
347
|
+
var mergedCardStyle = useMemo(function () {
|
|
348
|
+
return style ? _objectSpread(_objectSpread({}, defaultCardStyle), style) : defaultCardStyle;
|
|
349
|
+
}, [style]);
|
|
350
|
+
var summaryContent = /*#__PURE__*/React.createElement(React.Fragment, null, showMedia && (media || renderMedia) && /*#__PURE__*/React.createElement("div", {
|
|
351
|
+
className: "pisell-entity-card-media-wrap"
|
|
352
|
+
}, renderMedia ? renderMedia() : media ? renderMediaNode(media) : null), /*#__PURE__*/React.createElement("div", {
|
|
353
|
+
className: "pisell-entity-card-text-wrap",
|
|
354
|
+
style: contentGapStyle
|
|
355
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
356
|
+
className: "pisell-entity-card-primary-row"
|
|
357
|
+
}, showPrimaryText && (primaryText != null || renderPrimary) && /*#__PURE__*/React.createElement("div", {
|
|
358
|
+
className: "pisell-entity-card-primary"
|
|
359
|
+
}, renderPrimary ? renderPrimary() : /*#__PURE__*/React.createElement(Typography.Text, {
|
|
360
|
+
className: classNames('pisell-entity-card-primary-text', primaryLineClamp && 'pisell-entity-card-primary-text-has-line-clamp'),
|
|
361
|
+
ellipsis: primaryLineClamp ? undefined : true,
|
|
362
|
+
style: primaryLineClamp ? {
|
|
363
|
+
display: '-webkit-box',
|
|
364
|
+
WebkitLineClamp: primaryLineClamp,
|
|
365
|
+
WebkitBoxOrient: 'vertical',
|
|
366
|
+
overflow: 'hidden',
|
|
367
|
+
whiteSpace: 'normal',
|
|
368
|
+
textOverflow: 'ellipsis'
|
|
369
|
+
} : undefined
|
|
370
|
+
}, primaryText)), (showSubtitle && (subtitleText != null || renderSubtitle) || tagPosition === 'inline' && showTags && effectiveTags.length > 0 && !renderTags) && /*#__PURE__*/React.createElement("div", {
|
|
371
|
+
className: "pisell-entity-card-primary-extra"
|
|
372
|
+
}, showSubtitle && (subtitleText != null || renderSubtitle) && /*#__PURE__*/React.createElement("div", {
|
|
373
|
+
className: "pisell-entity-card-subtitle-wrap"
|
|
374
|
+
}, renderSubtitle ? renderSubtitle() : /*#__PURE__*/React.createElement("span", {
|
|
375
|
+
className: "pisell-entity-card-subtitle"
|
|
376
|
+
}, subtitleText)), tagPosition === 'inline' && showTags && effectiveTags.length > 0 && !renderTags && /*#__PURE__*/React.createElement("div", {
|
|
377
|
+
className: "pisell-entity-card-tags pisell-entity-card-tags-inline"
|
|
378
|
+
}, effectiveTags.map(function (t, i) {
|
|
379
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
380
|
+
key: i,
|
|
381
|
+
className: "pisell-entity-card-tag",
|
|
382
|
+
style: t.style
|
|
383
|
+
}, t.text);
|
|
384
|
+
})))), showSecondaryText && effectiveSecondary.length > 0 && !renderSecondary && /*#__PURE__*/React.createElement("div", {
|
|
385
|
+
className: "pisell-entity-card-secondary"
|
|
386
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
387
|
+
className: "pisell-entity-card-secondary-text",
|
|
388
|
+
style: secondaryLineClamp ? {
|
|
389
|
+
display: '-webkit-box',
|
|
390
|
+
WebkitLineClamp: secondaryLineClamp,
|
|
391
|
+
WebkitBoxOrient: 'vertical',
|
|
392
|
+
overflow: 'hidden'
|
|
393
|
+
} : undefined
|
|
394
|
+
}, effectiveSecondary.map(function (item, i) {
|
|
395
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
396
|
+
key: i,
|
|
397
|
+
className: "pisell-entity-card-secondary-line"
|
|
398
|
+
}, item.showTooltip && /*#__PURE__*/React.createElement(InfoCircleOutlined, {
|
|
399
|
+
className: "pisell-entity-card-secondary-tooltip-icon"
|
|
400
|
+
}), item.text);
|
|
401
|
+
}))), renderSecondary && renderSecondary(), tagPosition === 'below' && showTags && (effectiveTags.length > 0 || renderTags) && /*#__PURE__*/React.createElement("div", {
|
|
402
|
+
className: "pisell-entity-card-tags pisell-entity-card-tags-below"
|
|
403
|
+
}, renderTags ? renderTags() : effectiveTags.map(function (t, i) {
|
|
404
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
405
|
+
key: i,
|
|
406
|
+
className: "pisell-entity-card-tag",
|
|
407
|
+
style: t.style
|
|
408
|
+
}, t.text);
|
|
409
|
+
}))));
|
|
410
|
+
|
|
411
|
+
/** 设计稿:Action 在右侧与 summary 同一行(justify-between),非底部 */
|
|
412
|
+
var cardBody = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
413
|
+
className: "pisell-entity-card-body"
|
|
414
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
415
|
+
className: "pisell-entity-card-summary",
|
|
416
|
+
"data-layout": layout,
|
|
417
|
+
style: contentGapStyle
|
|
418
|
+
}, summaryContent), showActions && (actions.length > 0 || renderActions) && /*#__PURE__*/React.createElement("div", {
|
|
419
|
+
className: "pisell-entity-card-actions"
|
|
420
|
+
}, renderActions ? renderActions() : actions.map(function (a, i) {
|
|
421
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
422
|
+
key: i,
|
|
423
|
+
type: "button",
|
|
424
|
+
className: classNames('pisell-entity-card-action', "pisell-entity-card-action-".concat(a.type), a.className),
|
|
425
|
+
style: a.style,
|
|
426
|
+
onClick: function onClick(e) {
|
|
427
|
+
var _a$onClick;
|
|
428
|
+
e.stopPropagation();
|
|
429
|
+
(_a$onClick = a.onClick) === null || _a$onClick === void 0 || _a$onClick.call(a);
|
|
430
|
+
}
|
|
431
|
+
}, a.icon, (a.type === 'text' || a.type === 'button') && a.label);
|
|
432
|
+
}))), children);
|
|
433
|
+
var wrappedByBaseCard = /*#__PURE__*/React.createElement(PisellBaseCard, {
|
|
434
|
+
className: classNames('pisell-entity-card-root', className),
|
|
435
|
+
style: mergedCardStyle,
|
|
436
|
+
hoverStyle: hoverStyle,
|
|
437
|
+
activeStyle: activeStyle,
|
|
438
|
+
disabledStyle: disabledStyle,
|
|
439
|
+
clickable: clickable,
|
|
440
|
+
disabled: disabled,
|
|
441
|
+
onClick: onClick
|
|
442
|
+
}, cardBody);
|
|
443
|
+
if (!hasSwipe) {
|
|
444
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
445
|
+
className: "pisell-entity-card-wrap",
|
|
446
|
+
style: rootWidthStyle
|
|
447
|
+
}, wrappedByBaseCard);
|
|
448
|
+
}
|
|
449
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
450
|
+
className: "pisell-entity-card-wrap pisell-entity-card-wrap-swipe",
|
|
451
|
+
style: rootWidthStyle
|
|
452
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
453
|
+
ref: swipeContainerRef,
|
|
454
|
+
className: "pisell-entity-card-swipe-container",
|
|
455
|
+
onTouchStart: onTouchStart,
|
|
456
|
+
onTouchMove: onTouchMove,
|
|
457
|
+
onTouchEnd: onTouchEnd,
|
|
458
|
+
onMouseDown: onMouseDown,
|
|
459
|
+
onMouseMove: onMouseMove,
|
|
460
|
+
onMouseUp: onMouseUp,
|
|
461
|
+
onMouseLeave: onMouseLeave
|
|
462
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
463
|
+
className: "pisell-entity-card-swipe-delete",
|
|
464
|
+
style: {
|
|
465
|
+
width: SWIPE_DELETE_WIDTH
|
|
466
|
+
},
|
|
467
|
+
onClick: handleDeleteClick
|
|
468
|
+
}, "\u5220\u9664"), /*#__PURE__*/React.createElement("div", {
|
|
469
|
+
className: "pisell-entity-card-swipe-content",
|
|
470
|
+
style: {
|
|
471
|
+
transform: "translateX(".concat(swipeOffset, "px)")
|
|
472
|
+
}
|
|
473
|
+
}, wrappedByBaseCard)));
|
|
474
|
+
}
|