@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,426 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/pisellEntityCard/PisellEntityCard.tsx
|
|
30
|
+
var PisellEntityCard_exports = {};
|
|
31
|
+
__export(PisellEntityCard_exports, {
|
|
32
|
+
PisellEntityCard: () => PisellEntityCard
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(PisellEntityCard_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_classnames = __toESM(require("classnames"));
|
|
37
|
+
var import_antd = require("antd");
|
|
38
|
+
var import_icons = require("@ant-design/icons");
|
|
39
|
+
var import_pisellBaseCard = require("../pisellBaseCard");
|
|
40
|
+
var import_PisellEntityCard = require("./PisellEntityCard.less");
|
|
41
|
+
var SWIPE_DELETE_WIDTH = 72;
|
|
42
|
+
var SWIPE_THRESHOLD = 36;
|
|
43
|
+
function getSecondaryLineClampByDensity(density) {
|
|
44
|
+
switch (density) {
|
|
45
|
+
case "B1":
|
|
46
|
+
return 0;
|
|
47
|
+
case "B2":
|
|
48
|
+
return 2;
|
|
49
|
+
case "B5":
|
|
50
|
+
return 5;
|
|
51
|
+
case "B9":
|
|
52
|
+
default:
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function getSecondaryMaxItemsByDensity(density) {
|
|
57
|
+
switch (density) {
|
|
58
|
+
case "B1":
|
|
59
|
+
return 0;
|
|
60
|
+
case "B2":
|
|
61
|
+
return 2;
|
|
62
|
+
case "B5":
|
|
63
|
+
return 5;
|
|
64
|
+
case "B9":
|
|
65
|
+
default:
|
|
66
|
+
return 999;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function getTagsMaxByDensity(density) {
|
|
70
|
+
switch (density) {
|
|
71
|
+
case "B1":
|
|
72
|
+
return 2;
|
|
73
|
+
case "B2":
|
|
74
|
+
return 2;
|
|
75
|
+
case "B5":
|
|
76
|
+
return 5;
|
|
77
|
+
case "B9":
|
|
78
|
+
default:
|
|
79
|
+
return 999;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function renderMediaNode(config) {
|
|
83
|
+
const size = config.size ?? 40;
|
|
84
|
+
const sizePx = typeof size === "number" ? `${size}px` : size;
|
|
85
|
+
const shape = config.shape ?? "circle";
|
|
86
|
+
if (config.type === "icon" && config.icon) {
|
|
87
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
88
|
+
"span",
|
|
89
|
+
{
|
|
90
|
+
className: "pisell-entity-card-media pisell-entity-card-media-icon",
|
|
91
|
+
style: {
|
|
92
|
+
width: sizePx,
|
|
93
|
+
height: sizePx,
|
|
94
|
+
color: config.color,
|
|
95
|
+
fontSize: sizePx,
|
|
96
|
+
display: "inline-flex",
|
|
97
|
+
alignItems: "center",
|
|
98
|
+
justifyContent: "center"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
config.icon
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
if (config.type === "avatar" || config.type === "thumbnail") {
|
|
105
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
106
|
+
import_antd.Avatar,
|
|
107
|
+
{
|
|
108
|
+
src: config.src,
|
|
109
|
+
alt: config.alt,
|
|
110
|
+
shape: shape === "circle" ? "circle" : "square",
|
|
111
|
+
style: {
|
|
112
|
+
width: sizePx,
|
|
113
|
+
height: sizePx,
|
|
114
|
+
flexShrink: 0
|
|
115
|
+
},
|
|
116
|
+
className: "pisell-entity-card-media pisell-entity-card-media-avatar"
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
function PisellEntityCard({
|
|
123
|
+
// BaseCard 透传
|
|
124
|
+
children,
|
|
125
|
+
className,
|
|
126
|
+
style,
|
|
127
|
+
hoverStyle,
|
|
128
|
+
activeStyle,
|
|
129
|
+
disabledStyle,
|
|
130
|
+
clickable = true,
|
|
131
|
+
disabled = false,
|
|
132
|
+
onClick,
|
|
133
|
+
// 数据源
|
|
134
|
+
media,
|
|
135
|
+
primaryText,
|
|
136
|
+
subtitleText,
|
|
137
|
+
secondaryTexts = [],
|
|
138
|
+
tags = [],
|
|
139
|
+
actions = [],
|
|
140
|
+
// 显隐
|
|
141
|
+
showMedia = true,
|
|
142
|
+
showPrimaryText = true,
|
|
143
|
+
showSubtitle = true,
|
|
144
|
+
showSecondaryText = true,
|
|
145
|
+
showTags = true,
|
|
146
|
+
showActions = false,
|
|
147
|
+
// 密度与布局
|
|
148
|
+
density = "B2",
|
|
149
|
+
layout = "horizontal",
|
|
150
|
+
width = "content",
|
|
151
|
+
// 左滑删除
|
|
152
|
+
swipeToDelete = false,
|
|
153
|
+
onDelete,
|
|
154
|
+
// 样式扩展
|
|
155
|
+
tagPosition = "below",
|
|
156
|
+
contentGap,
|
|
157
|
+
primaryLineClamp,
|
|
158
|
+
secondaryLineClamp: secondaryLineClampProp,
|
|
159
|
+
// 插槽
|
|
160
|
+
renderMedia,
|
|
161
|
+
renderPrimary,
|
|
162
|
+
renderSubtitle,
|
|
163
|
+
renderSecondary,
|
|
164
|
+
renderTags,
|
|
165
|
+
renderActions
|
|
166
|
+
}) {
|
|
167
|
+
const [swipeOffset, setSwipeOffset] = (0, import_react.useState)(0);
|
|
168
|
+
const [swipeStart, setSwipeStart] = (0, import_react.useState)(null);
|
|
169
|
+
const swipeStartDataRef = (0, import_react.useRef)(null);
|
|
170
|
+
const swipeOffsetRef = (0, import_react.useRef)(swipeOffset);
|
|
171
|
+
swipeOffsetRef.current = swipeOffset;
|
|
172
|
+
const swipeContainerRef = (0, import_react.useRef)(null);
|
|
173
|
+
const secondaryLineClamp = secondaryLineClampProp ?? getSecondaryLineClampByDensity(density);
|
|
174
|
+
const secondaryMaxItems = getSecondaryMaxItemsByDensity(density);
|
|
175
|
+
const tagsMaxItems = getTagsMaxByDensity(density);
|
|
176
|
+
const effectiveSecondary = (0, import_react.useMemo)(
|
|
177
|
+
() => secondaryLineClamp === 0 ? [] : secondaryTexts.slice(0, secondaryMaxItems),
|
|
178
|
+
[secondaryTexts, secondaryLineClamp, secondaryMaxItems]
|
|
179
|
+
);
|
|
180
|
+
const effectiveTags = (0, import_react.useMemo)(
|
|
181
|
+
() => tags.slice(0, tagsMaxItems),
|
|
182
|
+
[tags, tagsMaxItems]
|
|
183
|
+
);
|
|
184
|
+
const rootWidthStyle = (0, import_react.useMemo)(() => {
|
|
185
|
+
if (width === "full") return { width: "100%" };
|
|
186
|
+
if (typeof width === "number") return { width: `${width}px` };
|
|
187
|
+
return { width: "fit-content" };
|
|
188
|
+
}, [width]);
|
|
189
|
+
const handleSwipeStart = (0, import_react.useCallback)(
|
|
190
|
+
(x, isTouch) => {
|
|
191
|
+
if (!swipeToDelete || !onDelete) return;
|
|
192
|
+
swipeStartDataRef.current = { x, isTouch };
|
|
193
|
+
setSwipeStart({ x, isTouch });
|
|
194
|
+
},
|
|
195
|
+
[swipeToDelete, onDelete]
|
|
196
|
+
);
|
|
197
|
+
const handleSwipeMove = (0, import_react.useCallback)((currentX) => {
|
|
198
|
+
const start = swipeStartDataRef.current;
|
|
199
|
+
if (start === null) return;
|
|
200
|
+
const delta = start.x - currentX;
|
|
201
|
+
const next = Math.max(-SWIPE_DELETE_WIDTH, Math.min(0, -delta));
|
|
202
|
+
swipeOffsetRef.current = next;
|
|
203
|
+
setSwipeOffset(next);
|
|
204
|
+
}, []);
|
|
205
|
+
const handleSwipeEnd = (0, import_react.useCallback)(() => {
|
|
206
|
+
const start = swipeStartDataRef.current;
|
|
207
|
+
const offset = swipeOffsetRef.current;
|
|
208
|
+
swipeStartDataRef.current = null;
|
|
209
|
+
if (start === null) return;
|
|
210
|
+
const committed = offset <= -SWIPE_THRESHOLD ? -SWIPE_DELETE_WIDTH : 0;
|
|
211
|
+
setSwipeOffset(committed);
|
|
212
|
+
setSwipeStart(null);
|
|
213
|
+
}, []);
|
|
214
|
+
(0, import_react.useEffect)(() => {
|
|
215
|
+
if ((swipeStart == null ? void 0 : swipeStart.isTouch) !== false) return;
|
|
216
|
+
const onDocMove = (e) => {
|
|
217
|
+
const start = swipeStartDataRef.current;
|
|
218
|
+
if (start === null) return;
|
|
219
|
+
const delta = start.x - e.clientX;
|
|
220
|
+
const next = Math.max(-SWIPE_DELETE_WIDTH, Math.min(0, -delta));
|
|
221
|
+
swipeOffsetRef.current = next;
|
|
222
|
+
setSwipeOffset(next);
|
|
223
|
+
};
|
|
224
|
+
const onDocUp = () => {
|
|
225
|
+
const start = swipeStartDataRef.current;
|
|
226
|
+
const offset = swipeOffsetRef.current;
|
|
227
|
+
if (start === null) return;
|
|
228
|
+
const committed = offset <= -SWIPE_THRESHOLD ? -SWIPE_DELETE_WIDTH : 0;
|
|
229
|
+
setSwipeOffset(committed);
|
|
230
|
+
setSwipeStart(null);
|
|
231
|
+
};
|
|
232
|
+
document.addEventListener("mousemove", onDocMove);
|
|
233
|
+
document.addEventListener("mouseup", onDocUp);
|
|
234
|
+
return () => {
|
|
235
|
+
document.removeEventListener("mousemove", onDocMove);
|
|
236
|
+
document.removeEventListener("mouseup", onDocUp);
|
|
237
|
+
};
|
|
238
|
+
}, [swipeStart == null ? void 0 : swipeStart.isTouch]);
|
|
239
|
+
const onTouchStart = (0, import_react.useCallback)(
|
|
240
|
+
(e) => handleSwipeStart(e.touches[0].clientX, true),
|
|
241
|
+
[handleSwipeStart]
|
|
242
|
+
);
|
|
243
|
+
const onTouchMove = (0, import_react.useCallback)(
|
|
244
|
+
(e) => {
|
|
245
|
+
if (swipeStartDataRef.current !== null) {
|
|
246
|
+
e.preventDefault();
|
|
247
|
+
handleSwipeMove(e.touches[0].clientX);
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
[handleSwipeMove]
|
|
251
|
+
);
|
|
252
|
+
const onTouchEnd = (0, import_react.useCallback)(() => handleSwipeEnd(), [handleSwipeEnd]);
|
|
253
|
+
const onMouseDown = (0, import_react.useCallback)(
|
|
254
|
+
(e) => {
|
|
255
|
+
e.preventDefault();
|
|
256
|
+
handleSwipeStart(e.clientX, false);
|
|
257
|
+
},
|
|
258
|
+
[handleSwipeStart]
|
|
259
|
+
);
|
|
260
|
+
const onMouseMove = (0, import_react.useCallback)(
|
|
261
|
+
(e) => {
|
|
262
|
+
var _a;
|
|
263
|
+
if (((_a = swipeStartDataRef.current) == null ? void 0 : _a.isTouch) === false) handleSwipeMove(e.clientX);
|
|
264
|
+
},
|
|
265
|
+
[handleSwipeMove]
|
|
266
|
+
);
|
|
267
|
+
const onMouseUp = (0, import_react.useCallback)(() => handleSwipeEnd(), [handleSwipeEnd]);
|
|
268
|
+
const onMouseLeave = (0, import_react.useCallback)(() => {
|
|
269
|
+
if (swipeStartDataRef.current !== null) {
|
|
270
|
+
swipeStartDataRef.current = null;
|
|
271
|
+
setSwipeOffset(0);
|
|
272
|
+
setSwipeStart(null);
|
|
273
|
+
}
|
|
274
|
+
}, []);
|
|
275
|
+
const handleDeleteClick = (0, import_react.useCallback)(
|
|
276
|
+
(e) => {
|
|
277
|
+
e.stopPropagation();
|
|
278
|
+
onDelete == null ? void 0 : onDelete();
|
|
279
|
+
},
|
|
280
|
+
[onDelete]
|
|
281
|
+
);
|
|
282
|
+
const hasSwipe = swipeToDelete && !!onDelete;
|
|
283
|
+
(0, import_react.useEffect)(() => {
|
|
284
|
+
if (!hasSwipe || !swipeContainerRef.current) return;
|
|
285
|
+
const el = swipeContainerRef.current;
|
|
286
|
+
const onTouchMoveNative = (e) => {
|
|
287
|
+
if (swipeStartDataRef.current !== null) {
|
|
288
|
+
e.preventDefault();
|
|
289
|
+
handleSwipeMove(e.touches[0].clientX);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
el.addEventListener("touchmove", onTouchMoveNative, { passive: false });
|
|
293
|
+
return () => el.removeEventListener("touchmove", onTouchMoveNative);
|
|
294
|
+
}, [hasSwipe, handleSwipeMove]);
|
|
295
|
+
(0, import_react.useEffect)(() => {
|
|
296
|
+
if (!hasSwipe || swipeOffset >= 0) return;
|
|
297
|
+
const closeIfOutside = (e) => {
|
|
298
|
+
const target = e.target;
|
|
299
|
+
if (target && swipeContainerRef.current && !swipeContainerRef.current.contains(target)) {
|
|
300
|
+
setSwipeOffset(0);
|
|
301
|
+
setSwipeStart(null);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
document.addEventListener("click", closeIfOutside);
|
|
305
|
+
document.addEventListener("touchend", closeIfOutside);
|
|
306
|
+
return () => {
|
|
307
|
+
document.removeEventListener("click", closeIfOutside);
|
|
308
|
+
document.removeEventListener("touchend", closeIfOutside);
|
|
309
|
+
};
|
|
310
|
+
}, [hasSwipe, swipeOffset]);
|
|
311
|
+
const contentGapStyle = contentGap !== void 0 ? { gap: typeof contentGap === "number" ? `${contentGap}px` : contentGap } : void 0;
|
|
312
|
+
const defaultCardStyle = {
|
|
313
|
+
padding: 8,
|
|
314
|
+
borderRadius: 8,
|
|
315
|
+
border: "1px solid #d0d5dd",
|
|
316
|
+
backgroundColor: "#ffffff",
|
|
317
|
+
boxShadow: "none"
|
|
318
|
+
};
|
|
319
|
+
const mergedCardStyle = (0, import_react.useMemo)(
|
|
320
|
+
() => style ? { ...defaultCardStyle, ...style } : defaultCardStyle,
|
|
321
|
+
[style]
|
|
322
|
+
);
|
|
323
|
+
const summaryContent = /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, showMedia && (media || renderMedia) && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-entity-card-media-wrap" }, renderMedia ? renderMedia() : media ? renderMediaNode(media) : null), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-entity-card-text-wrap", style: contentGapStyle }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-entity-card-primary-row" }, showPrimaryText && (primaryText != null || renderPrimary) && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-entity-card-primary" }, renderPrimary ? renderPrimary() : /* @__PURE__ */ import_react.default.createElement(
|
|
324
|
+
import_antd.Typography.Text,
|
|
325
|
+
{
|
|
326
|
+
className: (0, import_classnames.default)(
|
|
327
|
+
"pisell-entity-card-primary-text",
|
|
328
|
+
primaryLineClamp && "pisell-entity-card-primary-text-has-line-clamp"
|
|
329
|
+
),
|
|
330
|
+
ellipsis: primaryLineClamp ? void 0 : true,
|
|
331
|
+
style: primaryLineClamp ? {
|
|
332
|
+
display: "-webkit-box",
|
|
333
|
+
WebkitLineClamp: primaryLineClamp,
|
|
334
|
+
WebkitBoxOrient: "vertical",
|
|
335
|
+
overflow: "hidden",
|
|
336
|
+
whiteSpace: "normal",
|
|
337
|
+
textOverflow: "ellipsis"
|
|
338
|
+
} : void 0
|
|
339
|
+
},
|
|
340
|
+
primaryText
|
|
341
|
+
)), (showSubtitle && (subtitleText != null || renderSubtitle) || tagPosition === "inline" && showTags && effectiveTags.length > 0 && !renderTags) && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-entity-card-primary-extra" }, showSubtitle && (subtitleText != null || renderSubtitle) && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-entity-card-subtitle-wrap" }, renderSubtitle ? renderSubtitle() : /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-entity-card-subtitle" }, subtitleText)), tagPosition === "inline" && showTags && effectiveTags.length > 0 && !renderTags && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-entity-card-tags pisell-entity-card-tags-inline" }, effectiveTags.map((t, i) => /* @__PURE__ */ import_react.default.createElement("span", { key: i, className: "pisell-entity-card-tag", style: t.style }, t.text))))), showSecondaryText && effectiveSecondary.length > 0 && !renderSecondary && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-entity-card-secondary" }, /* @__PURE__ */ import_react.default.createElement(
|
|
342
|
+
"div",
|
|
343
|
+
{
|
|
344
|
+
className: "pisell-entity-card-secondary-text",
|
|
345
|
+
style: secondaryLineClamp ? {
|
|
346
|
+
display: "-webkit-box",
|
|
347
|
+
WebkitLineClamp: secondaryLineClamp,
|
|
348
|
+
WebkitBoxOrient: "vertical",
|
|
349
|
+
overflow: "hidden"
|
|
350
|
+
} : void 0
|
|
351
|
+
},
|
|
352
|
+
effectiveSecondary.map((item, i) => /* @__PURE__ */ import_react.default.createElement("span", { key: i, className: "pisell-entity-card-secondary-line" }, item.showTooltip && /* @__PURE__ */ import_react.default.createElement(import_icons.InfoCircleOutlined, { className: "pisell-entity-card-secondary-tooltip-icon" }), item.text))
|
|
353
|
+
)), renderSecondary && renderSecondary(), tagPosition === "below" && showTags && (effectiveTags.length > 0 || renderTags) && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-entity-card-tags pisell-entity-card-tags-below" }, renderTags ? renderTags() : effectiveTags.map((t, i) => /* @__PURE__ */ import_react.default.createElement("span", { key: i, className: "pisell-entity-card-tag", style: t.style }, t.text)))));
|
|
354
|
+
const cardBody = /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-entity-card-body" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-entity-card-summary", "data-layout": layout, style: contentGapStyle }, summaryContent), showActions && (actions.length > 0 || renderActions) && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-entity-card-actions" }, renderActions ? renderActions() : actions.map((a, i) => /* @__PURE__ */ import_react.default.createElement(
|
|
355
|
+
"button",
|
|
356
|
+
{
|
|
357
|
+
key: i,
|
|
358
|
+
type: "button",
|
|
359
|
+
className: (0, import_classnames.default)(
|
|
360
|
+
"pisell-entity-card-action",
|
|
361
|
+
`pisell-entity-card-action-${a.type}`,
|
|
362
|
+
a.className
|
|
363
|
+
),
|
|
364
|
+
style: a.style,
|
|
365
|
+
onClick: (e) => {
|
|
366
|
+
var _a;
|
|
367
|
+
e.stopPropagation();
|
|
368
|
+
(_a = a.onClick) == null ? void 0 : _a.call(a);
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
a.icon,
|
|
372
|
+
(a.type === "text" || a.type === "button") && a.label
|
|
373
|
+
)))), children);
|
|
374
|
+
const wrappedByBaseCard = /* @__PURE__ */ import_react.default.createElement(
|
|
375
|
+
import_pisellBaseCard.PisellBaseCard,
|
|
376
|
+
{
|
|
377
|
+
className: (0, import_classnames.default)("pisell-entity-card-root", className),
|
|
378
|
+
style: mergedCardStyle,
|
|
379
|
+
hoverStyle,
|
|
380
|
+
activeStyle,
|
|
381
|
+
disabledStyle,
|
|
382
|
+
clickable,
|
|
383
|
+
disabled,
|
|
384
|
+
onClick
|
|
385
|
+
},
|
|
386
|
+
cardBody
|
|
387
|
+
);
|
|
388
|
+
if (!hasSwipe) {
|
|
389
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-entity-card-wrap", style: rootWidthStyle }, wrappedByBaseCard);
|
|
390
|
+
}
|
|
391
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-entity-card-wrap pisell-entity-card-wrap-swipe", style: rootWidthStyle }, /* @__PURE__ */ import_react.default.createElement(
|
|
392
|
+
"div",
|
|
393
|
+
{
|
|
394
|
+
ref: swipeContainerRef,
|
|
395
|
+
className: "pisell-entity-card-swipe-container",
|
|
396
|
+
onTouchStart,
|
|
397
|
+
onTouchMove,
|
|
398
|
+
onTouchEnd,
|
|
399
|
+
onMouseDown,
|
|
400
|
+
onMouseMove,
|
|
401
|
+
onMouseUp,
|
|
402
|
+
onMouseLeave
|
|
403
|
+
},
|
|
404
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
405
|
+
"div",
|
|
406
|
+
{
|
|
407
|
+
className: "pisell-entity-card-swipe-delete",
|
|
408
|
+
style: { width: SWIPE_DELETE_WIDTH },
|
|
409
|
+
onClick: handleDeleteClick
|
|
410
|
+
},
|
|
411
|
+
"删除"
|
|
412
|
+
),
|
|
413
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
414
|
+
"div",
|
|
415
|
+
{
|
|
416
|
+
className: "pisell-entity-card-swipe-content",
|
|
417
|
+
style: { transform: `translateX(${swipeOffset}px)` }
|
|
418
|
+
},
|
|
419
|
+
wrappedByBaseCard
|
|
420
|
+
)
|
|
421
|
+
));
|
|
422
|
+
}
|
|
423
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
424
|
+
0 && (module.exports = {
|
|
425
|
+
PisellEntityCard
|
|
426
|
+
});
|