@pisell/materials 2.2.91 → 2.2.93

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.
Files changed (57) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +4 -4
  6. package/build/lowcode/preview.js +164 -148
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +39 -34
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +39 -34
  11. package/es/components/colorPicker/index.d.ts +0 -1
  12. package/es/components/dataSourceComponents/fields/Select/index.d.ts +0 -1
  13. package/es/components/dataSourceComponents/fields/index.d.ts +0 -1
  14. package/es/components/filter/components/items/index.d.ts +0 -1
  15. package/es/components/filter/components/items/text/Editor/index.d.ts +0 -1
  16. package/es/components/filter/components/items/text/Preview/index.d.ts +0 -1
  17. package/es/components/filter/components/items/text/index.d.ts +0 -1
  18. package/es/components/pisellGoodPassCard/index.d.ts +1 -0
  19. package/es/components/pisellGoodPassCard/index.js +13 -2
  20. package/es/components/productCard/cartSkuCard/components/basicInfo/index.js +17 -5
  21. package/es/components/productCard/cartSkuCard/components/basicInfo/index.less +15 -0
  22. package/es/components/productCard/cartSkuCard/components/swipeAction/index.d.ts +43 -0
  23. package/es/components/productCard/cartSkuCard/components/swipeAction/index.js +282 -0
  24. package/es/components/productCard/cartSkuCard/components/swipeAction/index.less +35 -0
  25. package/es/components/productCard/cartSkuCard/index.d.ts +1 -0
  26. package/es/components/productCard/cartSkuCard/index.js +28 -9
  27. package/es/components/productCard/cartSkuCard/index.less +1 -1
  28. package/es/components/productCard/components/Header/index.js +17 -5
  29. package/es/components/productCard/components/Header/index.less +15 -0
  30. package/es/components/productCard/index.js +3 -2
  31. package/es/components/productCard/index.less +6 -0
  32. package/es/components/table/Table/SelectField/index.d.ts +0 -1
  33. package/es/components/table/Table/tableConfig/summary/index.d.ts +0 -1
  34. package/lib/components/colorPicker/index.d.ts +0 -1
  35. package/lib/components/dataSourceComponents/fields/Select/index.d.ts +0 -1
  36. package/lib/components/dataSourceComponents/fields/index.d.ts +0 -1
  37. package/lib/components/filter/components/items/index.d.ts +0 -1
  38. package/lib/components/filter/components/items/text/Editor/index.d.ts +0 -1
  39. package/lib/components/filter/components/items/text/Preview/index.d.ts +0 -1
  40. package/lib/components/filter/components/items/text/index.d.ts +0 -1
  41. package/lib/components/pisellGoodPassCard/index.d.ts +1 -0
  42. package/lib/components/pisellGoodPassCard/index.js +6 -2
  43. package/lib/components/productCard/cartSkuCard/components/basicInfo/index.js +10 -2
  44. package/lib/components/productCard/cartSkuCard/components/basicInfo/index.less +15 -0
  45. package/lib/components/productCard/cartSkuCard/components/swipeAction/index.d.ts +43 -0
  46. package/lib/components/productCard/cartSkuCard/components/swipeAction/index.js +330 -0
  47. package/lib/components/productCard/cartSkuCard/components/swipeAction/index.less +35 -0
  48. package/lib/components/productCard/cartSkuCard/index.d.ts +1 -0
  49. package/lib/components/productCard/cartSkuCard/index.js +29 -13
  50. package/lib/components/productCard/cartSkuCard/index.less +1 -1
  51. package/lib/components/productCard/components/Header/index.js +16 -8
  52. package/lib/components/productCard/components/Header/index.less +15 -0
  53. package/lib/components/productCard/index.js +4 -2
  54. package/lib/components/productCard/index.less +6 -0
  55. package/lib/components/table/Table/SelectField/index.d.ts +0 -1
  56. package/lib/components/table/Table/tableConfig/summary/index.d.ts +0 -1
  57. package/package.json +6 -4
@@ -19,6 +19,21 @@
19
19
  border-radius: 8px;
20
20
  }
21
21
 
22
+ &-product-header-cover-text {
23
+ width: 64px;
24
+ height: 64px;
25
+ flex-shrink: 0;
26
+ border-radius: 8px;
27
+ background-color: #DEDEDE;
28
+ color: #7E7E7E;
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: center;
32
+ font-size: 22px;
33
+ font-weight: 500;
34
+ line-height: 1;
35
+ }
36
+
22
37
  &-product-right-wrap {
23
38
  display: flex;
24
39
  flex-direction: column;
@@ -1,5 +1,5 @@
1
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
- var _excluded = ["dataSource", "isShowImage", "isShowHolder", "isShowNote", "isShowDelete", "isShowPackageNote", "isShowEditProduct", "onEditProduct", "onAction", "onDelete", "onNote", "onLike", "onCard", "onChangeResource", "onChangeHolder"];
2
+ var _excluded = ["dataSource", "isShowImage", "isShowHolder", "isShowNote", "isShowDelete", "isShowPackageNote", "isShowEditProduct", "scenario", "onEditProduct", "onAction", "onDelete", "onNote", "onLike", "onCard", "onChangeResource", "onChangeHolder"];
3
3
  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; }
4
4
  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; }
5
5
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -46,6 +46,7 @@ var ProductCard = function ProductCard(props) {
46
46
  isShowPackageNote = _props$isShowPackageN === void 0 ? defaultValue.isShowPackageNote : _props$isShowPackageN,
47
47
  _props$isShowEditProd = props.isShowEditProduct,
48
48
  isShowEditProduct = _props$isShowEditProd === void 0 ? defaultValue.isShowEditProduct : _props$isShowEditProd,
49
+ scenario = props.scenario,
49
50
  _onEditProduct = props.onEditProduct,
50
51
  _onAction = props.onAction,
51
52
  _onDelete = props.onDelete,
@@ -102,7 +103,7 @@ var ProductCard = function ProductCard(props) {
102
103
  return _onDelete === null || _onDelete === void 0 ? void 0 : _onDelete(dataSource);
103
104
  }
104
105
  })), /*#__PURE__*/React.createElement(CardPro, {
105
- className: classNames('pisell-lowcode-product-card', _defineProperty(_defineProperty({}, 'pisell-lowcode-product-card-image', !showImage), 'pisell-lowcode-normal-product-card', !showImage && isNormalProduct)),
106
+ className: classNames('pisell-lowcode-product-card', _defineProperty(_defineProperty(_defineProperty({}, 'pisell-lowcode-product-card-image', !showImage && scenario !== 'booking2'), 'pisell-lowcode-normal-product-card', !showImage && isNormalProduct && scenario !== 'booking2'), 'pisell-lowcode-product-card-image-booking2', scenario === 'booking2')),
106
107
  key: _id
107
108
  }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
108
109
  onClick: function onClick(e) {
@@ -47,6 +47,12 @@
47
47
  }
48
48
  }
49
49
 
50
+ .pisell-lowcode-product-card-image-booking2 {
51
+ .pisell-cardPro-content {
52
+ padding: 4px;
53
+ }
54
+ }
55
+
50
56
  .pisell-lowcode-product-card-wrap {
51
57
  position: relative;
52
58
  }
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const SelectField: () => JSX.Element;
3
2
  export default SelectField;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const summary: (props: any) => JSX.Element;
3
2
  export default summary;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ColorPickerProps } from 'antd';
3
2
  declare const ColorPicker: (props: ColorPickerProps) => JSX.Element;
4
3
  export default ColorPicker;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare const SelectWithDataSource: (props: import("antd").SelectProps<any, import("antd/es/select").DefaultOptionType> & import("../../dataSourceForm/utils").WithModeProps & import("../../dataSourceForm/utils").WithFormItemProps & {
3
2
  options?: any;
4
3
  optionSourceType?: "default" | "custom" | "api" | undefined;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare const formFieldMap: {
3
2
  FormItemCheckbox: import("react").FC<{}> & {
4
3
  Group: import("react").FC<import("./Checkbox/type").CheckboxGroupProps & import("../dataSourceForm/utils").WithModeProps>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const fieldMaps: {
3
2
  text: {
4
3
  field: {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const Text: () => JSX.Element;
3
2
  export default Text;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const Text: (props: any) => JSX.Element;
3
2
  export default Text;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare const _default: {
3
2
  field: {
4
3
  field_icon: string;
@@ -44,6 +44,7 @@ export interface PisellGoodPassCardProps {
44
44
  style: React.CSSProperties;
45
45
  /**快捷展示排序 */
46
46
  mixedSort?: (val: Discount[]) => Discount[];
47
+ isInModal: boolean;
47
48
  }
48
49
  declare const index: (props: PisellGoodPassCardProps) => JSX.Element;
49
50
  export default index;
@@ -94,7 +94,11 @@ var index = (props) => {
94
94
  const list = sortList.length > 3 ? sortList.slice(0, 3) : sortList;
95
95
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: `${clsPrefix}-header` }, /* @__PURE__ */ import_react.default.createElement("div", null, (0, import_locales.getText)("pisell2.text.goodpass.product-vouchers")), /* @__PURE__ */ import_react.default.createElement(import_antd.Typography.Text, { underline: true, onClick: () => setShowModal(true) }, (0, import_locales.getText)("pisell2.text.goodpass.view-more"))), /* @__PURE__ */ import_react.default.createElement(import_antd.Divider, { style: { margin: 4 } }), /* @__PURE__ */ import_react.default.createElement("div", { className: `${clsPrefix}-body` }, list.map(renderVoucherItem)));
96
96
  };
97
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, renderModal(), /* @__PURE__ */ import_react.default.createElement(
97
+ const renderModalMode = () => {
98
+ const sortList = (mixedSort == null ? void 0 : mixedSort(dataSource)) || dataSource;
99
+ return /* @__PURE__ */ import_react.default.createElement("div", { style: { padding: "10px 0", display: "flex", flexDirection: "column", gap: 12 } }, sortList.map(renderVoucherItem));
100
+ };
101
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, !props.isInModal ? renderModal() : null, /* @__PURE__ */ import_react.default.createElement(
98
102
  import__.PisellCard,
99
103
  {
100
104
  padding: 8,
@@ -105,7 +109,7 @@ var index = (props) => {
105
109
  },
106
110
  className: clsPrefix
107
111
  },
108
- renderMixedMode()
112
+ props.isInModal ? renderModalMode() : renderMixedMode()
109
113
  ));
110
114
  };
111
115
  var pisellGoodPassCard_default = index;
@@ -61,11 +61,19 @@ var BasicInfo = (props) => {
61
61
  "is-main": isMainProduct
62
62
  })
63
63
  },
64
- num < 99 ? num : "99+"
64
+ num < 100 ? num : "99+"
65
65
  );
66
66
  return null;
67
67
  };
68
68
  const hasSpecs = (bundle == null ? void 0 : bundle.length) || (options == null ? void 0 : options.length) || product_option_string;
69
- return /* @__PURE__ */ import_react.default.createElement("div", { className: `${import__.PREFIX}__basic-info`, style: style || {} }, renderNumTag(), isShowImage && image && /* @__PURE__ */ import_react.default.createElement("img", { src: import_utils.image.ali(image, 64), className: `product-cover` }), (!isShowImage || !image) && num > 1 ? /* @__PURE__ */ import_react.default.createElement("div", { style: { width: 26 } }) : null, /* @__PURE__ */ import_react.default.createElement("div", { className: `product-info` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `product-name` }, name), hasSpecs ? /* @__PURE__ */ import_react.default.createElement(import_specs.default, { dataSource }) : /* @__PURE__ */ import_react.default.createElement("div", { className: `product-price` }, (0, import_utils.formatAmount)(price, 2, symbol))), /* @__PURE__ */ import_react.default.createElement("div", { className: `product-amount` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `total-amont` }, (0, import_utils.formatAmount)(total * num, 2, symbol)), origin_total && Number(total) !== Number(origin_total) ? /* @__PURE__ */ import_react.default.createElement("div", { className: `origin-amount` }, (0, import_utils.formatAmount)(origin_total * num, 2, symbol)) : null));
69
+ const renderImage = () => {
70
+ if (!isShowImage) return null;
71
+ if (image) {
72
+ return /* @__PURE__ */ import_react.default.createElement("img", { src: import_utils.image.ali(image, 64), className: `product-cover` });
73
+ }
74
+ const displayText = name ? name.slice(0, 2) : "";
75
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: `product-cover-text` }, displayText);
76
+ };
77
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: `${import__.PREFIX}__basic-info`, style: style || {} }, renderNumTag(), renderImage(), (!isShowImage || !image && !name) && num > 1 ? /* @__PURE__ */ import_react.default.createElement("div", { style: { width: 26 } }) : null, /* @__PURE__ */ import_react.default.createElement("div", { className: `product-info` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `product-name` }, name), hasSpecs ? /* @__PURE__ */ import_react.default.createElement(import_specs.default, { dataSource }) : /* @__PURE__ */ import_react.default.createElement("div", { className: `product-price` }, (0, import_utils.formatAmount)(price, 2, symbol))), /* @__PURE__ */ import_react.default.createElement("div", { className: `product-amount` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `total-amont` }, (0, import_utils.formatAmount)(total * num, 2, symbol)), origin_total && Number(total) !== Number(origin_total) ? /* @__PURE__ */ import_react.default.createElement("div", { className: `origin-amount` }, (0, import_utils.formatAmount)(origin_total * num, 2, symbol)) : null));
70
78
  };
71
79
  var basicInfo_default = BasicInfo;
@@ -36,6 +36,21 @@
36
36
  border-radius: 6px;
37
37
  }
38
38
 
39
+ .product-cover-text {
40
+ width: 48px;
41
+ height: 48px;
42
+ flex-shrink: 0;
43
+ border-radius: 8px;
44
+ background-color: #DEDEDE;
45
+ color: #7E7E7E;
46
+ display: flex;
47
+ align-items: center;
48
+ justify-content: center;
49
+ font-size: 22px;
50
+ font-weight: 500;
51
+ line-height: 1;
52
+ }
53
+
39
54
  .product-info {
40
55
  flex: 1;
41
56
  display: flex;
@@ -0,0 +1,43 @@
1
+ import type { ReactNode } from 'react';
2
+ import React from 'react';
3
+ declare type NativeProps<S extends string = never> = {
4
+ className?: string;
5
+ style?: React.CSSProperties & Partial<Record<S, string>>;
6
+ };
7
+ declare type PropagationEvent = 'click';
8
+ import './index.less';
9
+ declare type SideType = 'left' | 'right';
10
+ export declare type SwipeActionRef = {
11
+ close: () => void;
12
+ show: (side?: SideType) => void;
13
+ };
14
+ declare type ActionColor = 'light' | 'weak' | 'primary' | 'success' | 'warning' | 'danger';
15
+ export declare type Action = {
16
+ key: string | number;
17
+ text: ReactNode;
18
+ color?: ActionColor | string;
19
+ onClick?: (e: React.MouseEvent) => void;
20
+ };
21
+ export declare type SwipeActionProps = {
22
+ rightActions?: Action[];
23
+ leftActions?: Action[];
24
+ onAction?: (action: Action, e: React.MouseEvent) => void;
25
+ closeOnTouchOutside?: boolean;
26
+ closeOnAction?: boolean;
27
+ children: ReactNode;
28
+ stopPropagation?: PropagationEvent[];
29
+ onActionsReveal?: (side: SideType) => void;
30
+ onClose?: () => void;
31
+ } & NativeProps<'--background'>;
32
+ export declare const SwipeAction: React.ForwardRefExoticComponent<{
33
+ rightActions?: Action[] | undefined;
34
+ leftActions?: Action[] | undefined;
35
+ onAction?: ((action: Action, e: React.MouseEvent) => void) | undefined;
36
+ closeOnTouchOutside?: boolean | undefined;
37
+ closeOnAction?: boolean | undefined;
38
+ children: ReactNode;
39
+ stopPropagation?: "click"[] | undefined;
40
+ onActionsReveal?: ((side: SideType) => void) | undefined;
41
+ onClose?: (() => void) | undefined;
42
+ } & NativeProps<"--background"> & React.RefAttributes<SwipeActionRef>>;
43
+ export {};
@@ -0,0 +1,330 @@
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/productCard/cartSkuCard/components/swipeAction/index.tsx
30
+ var swipeAction_exports = {};
31
+ __export(swipeAction_exports, {
32
+ SwipeAction: () => SwipeAction
33
+ });
34
+ module.exports = __toCommonJS(swipeAction_exports);
35
+ var import_web = require("@react-spring/web");
36
+ var import_use_gesture_react = require("@use-gesture/react/dist/use-gesture-react.cjs");
37
+ var import_react = __toESM(require("react"));
38
+ var import_index = require("./index.less");
39
+ function withNativeProps(props, element) {
40
+ const p = {
41
+ ...element.props
42
+ };
43
+ if (props.className) {
44
+ p.className = props.className + (element.props.className ? ` ${element.props.className}` : "");
45
+ }
46
+ if (props.style) {
47
+ p.style = {
48
+ ...props.style,
49
+ ...element.props.style
50
+ };
51
+ }
52
+ return import_react.default.cloneElement(element, p);
53
+ }
54
+ function nearest(arr, target) {
55
+ return arr.reduce((prev, curr) => {
56
+ return Math.abs(curr - target) < Math.abs(prev - target) ? curr : prev;
57
+ });
58
+ }
59
+ function mergeProps(a, b) {
60
+ return {
61
+ ...a,
62
+ ...b
63
+ };
64
+ }
65
+ function withStopPropagation(events, element) {
66
+ if (!events.includes("click")) {
67
+ return element;
68
+ }
69
+ const onClick = (e) => {
70
+ var _a, _b;
71
+ e.stopPropagation();
72
+ (_b = (_a = element.props).onClick) == null ? void 0 : _b.call(_a, e);
73
+ };
74
+ return import_react.default.cloneElement(element, {
75
+ ...element.props,
76
+ onClick
77
+ });
78
+ }
79
+ var Button = ({
80
+ children,
81
+ className,
82
+ style,
83
+ onClick
84
+ }) => {
85
+ return /* @__PURE__ */ import_react.default.createElement(
86
+ "button",
87
+ {
88
+ className,
89
+ style: {
90
+ border: "none",
91
+ background: (style == null ? void 0 : style["--background-color"]) || "transparent",
92
+ ...style
93
+ },
94
+ onClick
95
+ },
96
+ children
97
+ );
98
+ };
99
+ var classPrefix = `pisell-custom-swipe-action`;
100
+ var defaultProps = {
101
+ rightActions: [],
102
+ leftActions: [],
103
+ closeOnTouchOutside: true,
104
+ closeOnAction: true,
105
+ stopPropagation: []
106
+ };
107
+ var SwipeAction = (0, import_react.forwardRef)(
108
+ (p, ref) => {
109
+ const props = mergeProps(defaultProps, p);
110
+ const rootRef = (0, import_react.useRef)(null);
111
+ const leftRef = (0, import_react.useRef)(null);
112
+ const rightRef = (0, import_react.useRef)(null);
113
+ function getWidth(ref2) {
114
+ const element = ref2.current;
115
+ if (!element) return 0;
116
+ return element.offsetWidth;
117
+ }
118
+ function getLeftWidth() {
119
+ return getWidth(leftRef);
120
+ }
121
+ function getRightWidth() {
122
+ return getWidth(rightRef);
123
+ }
124
+ const [{ x }, api] = (0, import_web.useSpring)(
125
+ () => ({
126
+ x: 0,
127
+ config: { tension: 200, friction: 30 }
128
+ }),
129
+ []
130
+ );
131
+ const draggingRef = (0, import_react.useRef)(false);
132
+ const dragCancelRef = (0, import_react.useRef)(null);
133
+ function forceCancelDrag() {
134
+ var _a;
135
+ (_a = dragCancelRef.current) == null ? void 0 : _a.call(dragCancelRef);
136
+ draggingRef.current = false;
137
+ }
138
+ const bind = (0, import_use_gesture_react.useDrag)(
139
+ (state) => {
140
+ var _a;
141
+ dragCancelRef.current = state.cancel;
142
+ if (!state.intentional) return;
143
+ if (state.down) {
144
+ draggingRef.current = true;
145
+ }
146
+ if (!draggingRef.current) return;
147
+ const [offsetX] = state.offset;
148
+ if (state.last) {
149
+ const leftWidth = getLeftWidth();
150
+ const rightWidth = getRightWidth();
151
+ let position = offsetX + state.velocity[0] * state.direction[0] * 50;
152
+ if (offsetX > 0) {
153
+ position = Math.max(0, position);
154
+ } else if (offsetX < 0) {
155
+ position = Math.min(0, position);
156
+ } else {
157
+ position = 0;
158
+ }
159
+ const targetX = nearest([-rightWidth, 0, leftWidth], position);
160
+ api.start({
161
+ x: targetX
162
+ });
163
+ if (targetX !== 0) {
164
+ (_a = p.onActionsReveal) == null ? void 0 : _a.call(p, targetX > 0 ? "left" : "right");
165
+ }
166
+ window.setTimeout(() => {
167
+ draggingRef.current = false;
168
+ });
169
+ } else {
170
+ api.start({
171
+ x: offsetX,
172
+ immediate: true
173
+ });
174
+ }
175
+ },
176
+ {
177
+ from: () => [x.get(), 0],
178
+ bounds: () => {
179
+ const leftWidth = getLeftWidth();
180
+ const rightWidth = getRightWidth();
181
+ return {
182
+ left: -rightWidth,
183
+ right: leftWidth
184
+ };
185
+ },
186
+ axis: "x",
187
+ preventScroll: true,
188
+ pointer: { touch: true },
189
+ triggerAllEvents: true
190
+ }
191
+ );
192
+ const close = () => {
193
+ var _a;
194
+ api.start({
195
+ x: 0
196
+ });
197
+ forceCancelDrag();
198
+ (_a = props.onClose) == null ? void 0 : _a.call(props);
199
+ };
200
+ (0, import_react.useImperativeHandle)(ref, () => ({
201
+ show: (side = "right") => {
202
+ var _a;
203
+ if (side === "right") {
204
+ api.start({
205
+ x: -getRightWidth()
206
+ });
207
+ } else if (side === "left") {
208
+ api.start({
209
+ x: getLeftWidth()
210
+ });
211
+ }
212
+ (_a = p.onActionsReveal) == null ? void 0 : _a.call(p, side);
213
+ },
214
+ close
215
+ }));
216
+ (0, import_react.useEffect)(() => {
217
+ if (!props.closeOnTouchOutside) return;
218
+ function handle(e) {
219
+ if (x.get() === 0) {
220
+ return;
221
+ }
222
+ const root = rootRef.current;
223
+ if (root && !root.contains(e.target)) {
224
+ close();
225
+ }
226
+ }
227
+ document.addEventListener("touchstart", handle);
228
+ return () => {
229
+ document.removeEventListener("touchstart", handle);
230
+ };
231
+ }, [props.closeOnTouchOutside]);
232
+ function renderAction(action) {
233
+ const color = action.color ?? "light";
234
+ const _style = action.style || {};
235
+ return /* @__PURE__ */ import_react.default.createElement(
236
+ Button,
237
+ {
238
+ key: action.key,
239
+ className: `${classPrefix}-action-button`,
240
+ style: {
241
+ "--background-color": colorRecord[color] ?? color,
242
+ ..._style
243
+ },
244
+ onClick: (e) => {
245
+ var _a, _b;
246
+ if (props.closeOnAction) {
247
+ close();
248
+ }
249
+ (_a = action.onClick) == null ? void 0 : _a.call(action, e);
250
+ (_b = props.onAction) == null ? void 0 : _b.call(props, action, e);
251
+ }
252
+ },
253
+ action.text
254
+ );
255
+ }
256
+ return withNativeProps(
257
+ props,
258
+ /* @__PURE__ */ import_react.default.createElement(
259
+ "div",
260
+ {
261
+ className: classPrefix,
262
+ ...bind(),
263
+ ref: rootRef,
264
+ onClickCapture: (e) => {
265
+ if (draggingRef.current) {
266
+ e.stopPropagation();
267
+ e.preventDefault();
268
+ }
269
+ }
270
+ },
271
+ /* @__PURE__ */ import_react.default.createElement(import_web.animated.div, { className: `${classPrefix}-track`, style: { x } }, withStopPropagation(
272
+ props.stopPropagation,
273
+ /* @__PURE__ */ import_react.default.createElement(
274
+ "div",
275
+ {
276
+ className: `${classPrefix}-actions ${classPrefix}-actions-left`,
277
+ ref: leftRef
278
+ },
279
+ props.leftActions.map(renderAction)
280
+ )
281
+ ), /* @__PURE__ */ import_react.default.createElement(
282
+ "div",
283
+ {
284
+ className: `${classPrefix}-content`,
285
+ onClickCapture: (e) => {
286
+ if (x.goal !== 0) {
287
+ e.preventDefault();
288
+ e.stopPropagation();
289
+ close();
290
+ }
291
+ }
292
+ },
293
+ /* @__PURE__ */ import_react.default.createElement(
294
+ import_web.animated.div,
295
+ {
296
+ style: {
297
+ pointerEvents: x.to(
298
+ (v) => v !== 0 && x.goal !== 0 ? "none" : "auto"
299
+ )
300
+ }
301
+ },
302
+ props.children
303
+ )
304
+ ), withStopPropagation(
305
+ props.stopPropagation,
306
+ /* @__PURE__ */ import_react.default.createElement(
307
+ "div",
308
+ {
309
+ className: `${classPrefix}-actions ${classPrefix}-actions-right`,
310
+ ref: rightRef
311
+ },
312
+ props.rightActions.map(renderAction)
313
+ )
314
+ ))
315
+ )
316
+ );
317
+ }
318
+ );
319
+ var colorRecord = {
320
+ light: "#ccc",
321
+ weak: "#999",
322
+ primary: "#1677ff",
323
+ success: "#00b578",
324
+ warning: "#ff8f1f",
325
+ danger: "#ff3141"
326
+ };
327
+ // Annotate the CommonJS export names for ESM import in node:
328
+ 0 && (module.exports = {
329
+ SwipeAction
330
+ });
@@ -0,0 +1,35 @@
1
+ .pisell-custom-swipe-action {
2
+ cursor: grab;
3
+ overflow: hidden;
4
+ touch-action: pan-y;
5
+ &-track {
6
+ position: relative;
7
+ overflow: visible;
8
+ }
9
+ &-content {
10
+ }
11
+ &-actions {
12
+ position: absolute;
13
+ display: flex;
14
+ justify-content: center;
15
+ align-items: stretch;
16
+ width: auto;
17
+ white-space: nowrap;
18
+ &-right {
19
+ left: 100%;
20
+ top: 0;
21
+ height: 100%;
22
+ }
23
+ &-left {
24
+ right: 100%;
25
+ top: 0;
26
+ height: 100%;
27
+ }
28
+ }
29
+ &-action-button {
30
+ --border-radius: 0;
31
+ --border-width: 0;
32
+ padding-left: 4px;
33
+ padding-right: 4px;
34
+ }
35
+ }
@@ -2,6 +2,7 @@ import './index.less';
2
2
  import { ProductCardTypes } from '../types';
3
3
  interface ISKUCardProps extends ProductCardTypes {
4
4
  type: 'a2' | 'a5';
5
+ rightActions: any[];
5
6
  }
6
7
  export declare const PREFIX = "pisell-cart-sku-card";
7
8
  declare const CartSkuCard: (props: ISKUCardProps) => JSX.Element;