@pisell/materials 6.4.7 → 6.4.9

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 (124) 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 +7 -7
  6. package/build/lowcode/preview.js +146 -146
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +24 -23
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +25 -24
  11. package/es/components/auto-resize-text/auto-text-size-standalone.d.ts +20 -0
  12. package/es/components/auto-resize-text/auto-text-size-standalone.js +258 -0
  13. package/es/components/auto-resize-text/index.d.ts +6 -0
  14. package/es/components/auto-resize-text/index.js +40 -0
  15. package/es/components/dataSourceComponents/dataSourceTable/BaseTable.js +11 -4
  16. package/es/components/dataSourceComponents/dataSourceTable/filter/index.d.ts +1 -0
  17. package/es/components/dataSourceComponents/dataSourceTable/filter/index.js +7 -2
  18. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +6 -7
  19. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +11 -4
  20. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableQuery.d.ts +2 -1
  21. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableQuery.js +92 -6
  22. package/es/components/dataSourceComponents/dataSourceTable/type.d.ts +5 -0
  23. package/es/components/filter/types.d.ts +2 -0
  24. package/es/components/keyboard/index.d.ts +22 -0
  25. package/es/components/keyboard/index.js +159 -0
  26. package/es/components/keyboard/index.less +44 -0
  27. package/es/components/pisellQRScanner/index.d.ts +0 -13
  28. package/es/components/pisellQRScanner/index.js +0 -8
  29. package/es/components/pisellWalletPassCard/index.d.ts +1 -1
  30. package/es/components/pisellWalletPassCard/index.js +2 -1
  31. package/es/components/productCard/cartSkuCard/components/packages/utils.d.ts +1 -1
  32. package/es/components/productCard/cartSkuCard/components/swipeAction/index.d.ts +1 -0
  33. package/es/components/productCard/cartSkuCard/components/swipeAction/index.js +73 -5
  34. package/es/components/productCard/cartSkuCard/components/swipeAction/index.less +39 -0
  35. package/es/components/productCard/cartSkuCard/index.js +2 -11
  36. package/es/components/productCard/components/Packages/utils.d.ts +1 -1
  37. package/es/components/table/Table/utils.d.ts +1 -1
  38. package/es/components/table/Table/utils.js +22 -1
  39. package/es/components/table/hooks/useTableSetting.d.ts +3 -4
  40. package/es/components/table/hooks/useTableSetting.js +113 -5
  41. package/es/components/table/index.js +14 -3
  42. package/es/components/table/types.d.ts +17 -0
  43. package/es/components/virtual-keyboard/BaseNumberKeyboard/Presets.d.ts +5 -1
  44. package/es/components/virtual-keyboard/BaseNumberKeyboard/Presets.js +21 -7
  45. package/es/components/virtual-keyboard/BaseNumberKeyboard/Presets.less +9 -5
  46. package/es/components/virtual-keyboard/BaseNumberKeyboard/index.d.ts +4 -0
  47. package/es/components/virtual-keyboard/BaseNumberKeyboard/index.js +44 -25
  48. package/es/components/virtualInput/BaseVirtualInput/index.d.ts +40 -0
  49. package/es/components/virtualInput/BaseVirtualInput/index.js +163 -0
  50. package/es/components/virtualInput/BaseVirtualInput/index.less +78 -0
  51. package/es/components/virtualInput/index.d.ts +24 -0
  52. package/es/components/virtualInput/index.js +60 -0
  53. package/es/components/virtualInput/index.less +42 -0
  54. package/es/index.d.ts +2 -0
  55. package/es/index.js +3 -1
  56. package/es/locales/en-US.d.ts +1 -0
  57. package/es/locales/en-US.js +1 -0
  58. package/es/locales/zh-CN.d.ts +1 -0
  59. package/es/locales/zh-CN.js +1 -0
  60. package/es/locales/zh-TW.d.ts +1 -0
  61. package/es/locales/zh-TW.js +1 -0
  62. package/es/utils/platform.d.ts +1 -1
  63. package/lib/components/auto-resize-text/auto-text-size-standalone.d.ts +20 -0
  64. package/lib/components/auto-resize-text/auto-text-size-standalone.js +273 -0
  65. package/lib/components/auto-resize-text/index.d.ts +6 -0
  66. package/lib/components/auto-resize-text/index.js +71 -0
  67. package/lib/components/dataSourceComponents/dataSourceTable/BaseTable.js +8 -2
  68. package/lib/components/dataSourceComponents/dataSourceTable/filter/index.d.ts +1 -0
  69. package/lib/components/dataSourceComponents/dataSourceTable/filter/index.js +7 -2
  70. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +6 -7
  71. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +11 -4
  72. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableQuery.d.ts +2 -1
  73. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableQuery.js +78 -7
  74. package/lib/components/dataSourceComponents/dataSourceTable/type.d.ts +5 -0
  75. package/lib/components/filter/types.d.ts +2 -0
  76. package/lib/components/keyboard/index.d.ts +22 -0
  77. package/lib/components/keyboard/index.js +223 -0
  78. package/lib/components/keyboard/index.less +44 -0
  79. package/lib/components/pisellQRScanner/index.d.ts +0 -13
  80. package/lib/components/pisellWalletPassCard/index.d.ts +1 -1
  81. package/lib/components/pisellWalletPassCard/index.js +2 -1
  82. package/lib/components/productCard/cartSkuCard/components/packages/utils.d.ts +1 -1
  83. package/lib/components/productCard/cartSkuCard/components/swipeAction/index.d.ts +1 -0
  84. package/lib/components/productCard/cartSkuCard/components/swipeAction/index.js +45 -11
  85. package/lib/components/productCard/cartSkuCard/components/swipeAction/index.less +39 -0
  86. package/lib/components/productCard/cartSkuCard/index.js +2 -13
  87. package/lib/components/productCard/components/Packages/utils.d.ts +1 -1
  88. package/lib/components/table/Table/utils.d.ts +1 -1
  89. package/lib/components/table/Table/utils.js +18 -1
  90. package/lib/components/table/hooks/useTableSetting.d.ts +3 -4
  91. package/lib/components/table/hooks/useTableSetting.js +114 -4
  92. package/lib/components/table/index.js +12 -1
  93. package/lib/components/table/types.d.ts +17 -0
  94. package/lib/components/virtual-keyboard/BaseNumberKeyboard/Presets.d.ts +5 -1
  95. package/lib/components/virtual-keyboard/BaseNumberKeyboard/Presets.js +19 -2
  96. package/lib/components/virtual-keyboard/BaseNumberKeyboard/Presets.less +9 -5
  97. package/lib/components/virtual-keyboard/BaseNumberKeyboard/index.d.ts +4 -0
  98. package/lib/components/virtual-keyboard/BaseNumberKeyboard/index.js +45 -27
  99. package/lib/components/virtualInput/BaseVirtualInput/index.d.ts +40 -0
  100. package/lib/components/virtualInput/BaseVirtualInput/index.js +179 -0
  101. package/lib/components/virtualInput/BaseVirtualInput/index.less +78 -0
  102. package/lib/components/virtualInput/index.d.ts +24 -0
  103. package/lib/components/virtualInput/index.js +102 -0
  104. package/lib/components/virtualInput/index.less +42 -0
  105. package/lib/index.d.ts +2 -0
  106. package/lib/index.js +6 -0
  107. package/lib/locales/en-US.d.ts +1 -0
  108. package/lib/locales/en-US.js +1 -0
  109. package/lib/locales/zh-CN.d.ts +1 -0
  110. package/lib/locales/zh-CN.js +1 -0
  111. package/lib/locales/zh-TW.d.ts +1 -0
  112. package/lib/locales/zh-TW.js +1 -0
  113. package/lib/utils/platform.d.ts +1 -1
  114. package/lowcode/data-source-table/meta.ts +239 -0
  115. package/lowcode/table/meta.ts +104 -0
  116. package/package.json +1 -1
  117. package/dist/umd/materials.min.css +0 -1
  118. package/dist/umd/materials.min.js +0 -1
  119. package/dist/umd/static/DotsSix.57d66266.svg +0 -1
  120. package/dist/umd/static/arrow-left.e542294f.svg +0 -1
  121. package/dist/umd/static/arrow-right.763f03e0.svg +0 -1
  122. package/dist/umd/static/filter-lines.04a54ae9.svg +0 -1
  123. package/dist/umd/static/help-circle.31c9be40.svg +0 -1
  124. package/dist/umd/static/switch-vertical-01.7ebe3ba8.svg +0 -1
@@ -10,13 +10,24 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
10
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
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
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- import { useState } from 'react';
13
+ import { useEffect, useMemo, useState } from 'react';
14
14
  import { useMemoizedFn } from 'ahooks';
15
- var useTableQuery = function useTableQuery(props) {
15
+ import { getCurrentViewModeFromLocalStorage, getTableSettingByCurrentViewMode, setTableSettingToLocalStorage } from "../../../table/Table/utils";
16
+ var useTableQuery = function useTableQuery(props, currentSettingHash) {
16
17
  var _tabs$items, _tabs$items2;
17
18
  var filterBy = props.filterBy,
18
19
  sortBy = props.sortBy,
19
- tabs = props.tabs;
20
+ tabs = props.tabs,
21
+ localSettings = props.localSettings;
22
+ var tableId = useMemo(function () {
23
+ if (props.__designMode === 'design') {
24
+ return 'designMode-mock-table-id';
25
+ }
26
+ return (props === null || props === void 0 ? void 0 : props.currentComponentId) || props.__id;
27
+ }, [props.__id, props.__designMode, props === null || props === void 0 ? void 0 : props.currentComponentId]);
28
+ var currentViewMode = useMemo(function () {
29
+ return getCurrentViewModeFromLocalStorage(tableId) || 'grid';
30
+ }, [tableId]);
20
31
 
21
32
  // 分页配置
22
33
  var _useState = useState({
@@ -28,19 +39,50 @@ var useTableQuery = function useTableQuery(props) {
28
39
  _useState2 = _slicedToArray(_useState, 2),
29
40
  queryPageConfig = _useState2[0],
30
41
  setQueryPageConfig = _useState2[1];
42
+ var getInitialValues = useMemoizedFn(function () {
43
+ try {
44
+ if (!tableId) return {};
45
+ var setting = getTableSettingByCurrentViewMode(tableId, currentViewMode);
46
+ console.log('setting22', setting);
47
+ return (setting === null || setting === void 0 ? void 0 : setting.filters) || {};
48
+ } catch (e) {
49
+ return {};
50
+ }
51
+ });
52
+
53
+ // 初始读取本地 filters(若开启本地记忆且 scope 包含 filters)
54
+ useEffect(function () {
55
+ var _localSettings$scope;
56
+ if (!tableId) return;
57
+ var enable = !!(localSettings !== null && localSettings !== void 0 && localSettings.enable && (_localSettings$scope = localSettings.scope) !== null && _localSettings$scope !== void 0 && _localSettings$scope.includes('filters'));
58
+ if (!enable) return;
59
+ var setting = getTableSettingByCurrentViewMode(tableId, currentViewMode);
60
+ var persisted = (setting === null || setting === void 0 ? void 0 : setting.filters) || {};
61
+ if (persisted && Object.keys(persisted).length > 0) {
62
+ setQueryPageConfig(function (prev) {
63
+ return _objectSpread(_objectSpread({}, prev), {}, {
64
+ filter: _objectSpread(_objectSpread({}, prev.filter), persisted)
65
+ });
66
+ });
67
+ }
68
+ }, [tableId, currentViewMode, JSON.stringify(localSettings)]);
31
69
 
32
70
  // 分页变化
33
71
  var handleValuesChange = useMemoizedFn(function (params, allParams) {
72
+ var _localSettings$scope2;
34
73
  var _ref = params.pagination || {},
35
74
  page = _ref.page,
36
75
  size = _ref.size;
76
+ var nextFilterForSave = null;
37
77
  setQueryPageConfig(function (prev) {
38
78
  var sort = prev.sort || sortBy;
39
79
  var filter = prev.filter;
40
80
  if ("tabs" in params) {
41
81
  var _params$tabs, _params$tabs2;
42
82
  sort = ((_params$tabs = params.tabs) === null || _params$tabs === void 0 ? void 0 : _params$tabs.sortBy) || sortBy || "";
43
- filter = _objectSpread(_objectSpread({}, prev.filter), ((_params$tabs2 = params.tabs) === null || _params$tabs2 === void 0 ? void 0 : _params$tabs2.filterBy) || {});
83
+ var tabsFilter = ((_params$tabs2 = params.tabs) === null || _params$tabs2 === void 0 ? void 0 : _params$tabs2.filterBy) || {};
84
+ filter = _objectSpread(_objectSpread({}, prev.filter), tabsFilter);
85
+ nextFilterForSave = filter;
44
86
  }
45
87
  if ("order_by" in params) {
46
88
  var _allParams$tabs;
@@ -53,14 +95,57 @@ var useTableQuery = function useTableQuery(props) {
53
95
  filter: filter
54
96
  });
55
97
  });
98
+
99
+ // 当 tabs 变化导致 filter 变更时,同步写入本地(遵循 localSettings)
100
+ var enable = !!(localSettings !== null && localSettings !== void 0 && localSettings.enable && (_localSettings$scope2 = localSettings.scope) !== null && _localSettings$scope2 !== void 0 && _localSettings$scope2.includes('filters'));
101
+ if (enable && tableId && nextFilterForSave) {
102
+ var excluded = new Set((localSettings === null || localSettings === void 0 ? void 0 : localSettings.excludedFilterFields) || []);
103
+ var filtered = {};
104
+ Object.keys(nextFilterForSave).forEach(function (k) {
105
+ if (!excluded.has(k)) {
106
+ filtered[k] = nextFilterForSave[k];
107
+ }
108
+ });
109
+ setTableSettingToLocalStorage({
110
+ tableId: tableId,
111
+ tableSettingObj: {
112
+ filters: filtered
113
+ },
114
+ currentViewMode: currentViewMode,
115
+ currentSettingHash: currentSettingHash
116
+ });
117
+ }
56
118
  });
57
119
  var handleFilterChange = useMemoizedFn(function (changedFields, allFields) {
120
+ var _localSettings$scope3;
121
+ var nextFilter = _objectSpread({}, allFields);
58
122
  setQueryPageConfig(function (prev) {
59
123
  return _objectSpread(_objectSpread({}, prev), {}, {
60
124
  page: 1,
61
- filter: _objectSpread(_objectSpread(_objectSpread({}, prev.filter), allFields), filterBy || {})
125
+ filter: _objectSpread(_objectSpread(_objectSpread({}, prev.filter), nextFilter), filterBy || {})
62
126
  });
63
127
  });
128
+
129
+ // 写入本地(仅当开启本地记忆且 scope 包含 filters)
130
+ var enable = !!(localSettings !== null && localSettings !== void 0 && localSettings.enable && (_localSettings$scope3 = localSettings.scope) !== null && _localSettings$scope3 !== void 0 && _localSettings$scope3.includes('filters'));
131
+ if (enable && tableId) {
132
+ // 按 excludedFilterFields 过滤写入
133
+ var excluded = new Set((localSettings === null || localSettings === void 0 ? void 0 : localSettings.excludedFilterFields) || []);
134
+ var filtered = {};
135
+ Object.keys(nextFilter || {}).forEach(function (k) {
136
+ if (!excluded.has(k)) {
137
+ filtered[k] = nextFilter[k];
138
+ }
139
+ });
140
+ setTableSettingToLocalStorage({
141
+ tableId: tableId,
142
+ tableSettingObj: {
143
+ filters: filtered
144
+ },
145
+ currentViewMode: currentViewMode,
146
+ currentSettingHash: currentSettingHash
147
+ });
148
+ }
64
149
  });
65
150
  var refreshData = useMemoizedFn(function () {
66
151
  setQueryPageConfig(function (prev) {
@@ -80,7 +165,8 @@ var useTableQuery = function useTableQuery(props) {
80
165
  handleValuesChange: handleValuesChange,
81
166
  refreshData: refreshData,
82
167
  handleFilterChange: handleFilterChange,
83
- refreshCurrentPage: refreshCurrentPage
168
+ refreshCurrentPage: refreshCurrentPage,
169
+ getInitialValues: getInitialValues
84
170
  };
85
171
  };
86
172
  export default useTableQuery;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { ColumnType } from 'antd/es/table';
3
+ import { LocalSettingsType } from '../../table/types';
3
4
  import { DataSourceType } from '../provider/dataSource/DataSourceContext';
4
5
  export declare type OperationItem = {
5
6
  label?: string;
@@ -13,6 +14,9 @@ export declare type OperationItem = {
13
14
  afterClose?: () => void;
14
15
  };
15
16
  export interface DataSourceTableProps {
17
+ __id?: string;
18
+ currentComponentId?: string;
19
+ currentSettingKey?: string;
16
20
  title?: string | React.ReactNode | (() => React.ReactNode);
17
21
  subTitle?: string | React.ReactNode | (() => React.ReactNode);
18
22
  titleButtons?: {
@@ -76,4 +80,5 @@ export interface DataSourceTableProps {
76
80
  create?: Record<string, any>;
77
81
  destroy?: Record<string, any>;
78
82
  };
83
+ localSettings?: LocalSettingsType;
79
84
  }
@@ -9,6 +9,8 @@ export declare type FilterType = {
9
9
  sortButtonShow: boolean;
10
10
  /** 筛选列表 */
11
11
  list: FilterItemProps[];
12
+ items?: string[];
13
+ __items: string[];
12
14
  /** 快速筛选最大长度 */
13
15
  quickFilterMaxLength: number;
14
16
  /** 配置存储模式 */
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ export declare type ItemValue = string | number;
4
+ export interface Item {
5
+ value: ItemValue;
6
+ label: React.ReactNode;
7
+ disabled: boolean;
8
+ type: 'text' | 'primary';
9
+ style?: React.CSSProperties;
10
+ size?: number;
11
+ }
12
+ export interface KeyboardProps {
13
+ id?: string;
14
+ className?: string;
15
+ style?: React.CSSProperties;
16
+ onChange?: (value?: ItemValue) => void;
17
+ items?: Item[];
18
+ rightItems?: Item[];
19
+ keydown?: boolean;
20
+ }
21
+ declare const _default: React.MemoExoticComponent<(props: KeyboardProps) => JSX.Element>;
22
+ export default _default;
@@ -0,0 +1,159 @@
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
+ import React, { useRef } from 'react';
8
+ import { Button } from 'antd';
9
+ import "./index.less";
10
+ import classNames from 'classnames';
11
+ import { useEventListener, useMemoizedFn, useSize } from 'ahooks';
12
+ var list = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '+', 'ok'];
13
+ var defaultArr = [{
14
+ value: 1,
15
+ label: '1',
16
+ disabled: false,
17
+ type: 'text'
18
+ }, {
19
+ value: 2,
20
+ label: '2',
21
+ disabled: false,
22
+ type: 'text'
23
+ }, {
24
+ value: 3,
25
+ label: '3',
26
+ disabled: false,
27
+ type: 'text'
28
+ }, {
29
+ value: 4,
30
+ label: '4',
31
+ disabled: false,
32
+ type: 'text'
33
+ }, {
34
+ value: 5,
35
+ label: '5',
36
+ disabled: false,
37
+ type: 'text'
38
+ }, {
39
+ value: 6,
40
+ label: '6',
41
+ disabled: false,
42
+ type: 'text'
43
+ }, {
44
+ value: 7,
45
+ label: '7',
46
+ disabled: false,
47
+ type: 'text'
48
+ }, {
49
+ value: 8,
50
+ label: '8',
51
+ disabled: false,
52
+ type: 'text'
53
+ }, {
54
+ value: 9,
55
+ label: '9',
56
+ disabled: false,
57
+ type: 'text'
58
+ }, {
59
+ value: '0',
60
+ label: '0',
61
+ disabled: false,
62
+ type: 'text'
63
+ }, {
64
+ value: '00',
65
+ label: '00',
66
+ disabled: false,
67
+ type: 'text'
68
+ }, {
69
+ value: '.',
70
+ label: '.',
71
+ disabled: false,
72
+ type: 'text'
73
+ }];
74
+ var Keyboard = function Keyboard(props) {
75
+ var _props$items = props.items,
76
+ items = _props$items === void 0 ? defaultArr : _props$items,
77
+ className = props.className,
78
+ style = props.style,
79
+ onChange = props.onChange,
80
+ rightItems = props.rightItems,
81
+ _props$keydown = props.keydown,
82
+ keydown = _props$keydown === void 0 ? true : _props$keydown;
83
+ var contentRef = useRef(null);
84
+ var size = useSize(contentRef);
85
+ useEventListener('keydown', function (ev) {
86
+ console.log('ev', ev);
87
+ if (!keydown) {
88
+ return;
89
+ }
90
+ var key = ev.key;
91
+ if (key === 'Enter') {
92
+ key = 'ok';
93
+ }
94
+ if (key === 'keydown') {
95
+ key = '+';
96
+ }
97
+ if (list.includes(key)) {
98
+ onChange === null || onChange === void 0 || onChange(key);
99
+ }
100
+ });
101
+ var getHeight = useMemoizedFn(function () {
102
+ var itemSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
103
+ // 默认高度为25% 的容器宽度 * size大小 + 间距
104
+ return ((size === null || size === void 0 ? void 0 : size.width) || 0) / 4 * itemSize + (itemSize - 1) * 7;
105
+ });
106
+ return /*#__PURE__*/React.createElement("div", {
107
+ id: props.id || '',
108
+ className: classNames('pisell-virtual-keyboard-wrap', className),
109
+ style: style
110
+ }, /*#__PURE__*/React.createElement("div", {
111
+ className: classNames('pisell-virtual-keyboard-content'),
112
+ ref: contentRef
113
+ }, items.map(function (item) {
114
+ var _item$style;
115
+ return /*#__PURE__*/React.createElement("div", {
116
+ className: "pisell-virtual-keyboard-item",
117
+ style: item.style
118
+ }, /*#__PURE__*/React.createElement(Button, {
119
+ id: "pisell-virtual-keyboard-".concat(item.value),
120
+ key: item.value,
121
+ type: item.type,
122
+ className: "pisell-virtual-keyboard-item-button",
123
+ style: {
124
+ color: item.type === 'primary' ? '#fff' : ((_item$style = item.style) === null || _item$style === void 0 ? void 0 : _item$style.color) || undefined
125
+ },
126
+ disabled: item.disabled,
127
+ onClick: function onClick(e) {
128
+ onChange === null || onChange === void 0 || onChange(item.value);
129
+ }
130
+ }, item.label));
131
+ })), rightItems && /*#__PURE__*/React.createElement("div", {
132
+ className: classNames('pisell-virtual-keyboard-content', 'pisell-virtual-keyboard-right'),
133
+ style: {
134
+ flex: "0 0 calc((100% - 21px) / 4 * 1)"
135
+ }
136
+ }, rightItems === null || rightItems === void 0 ? void 0 : rightItems.map(function (item) {
137
+ var _item$style2, _item$style3;
138
+ return /*#__PURE__*/React.createElement("div", {
139
+ className: "pisell-virtual-keyboard-item",
140
+ style: _objectSpread(_objectSpread({}, item.style || {}), {}, {
141
+ height: getHeight(item.size)
142
+ })
143
+ }, /*#__PURE__*/React.createElement(Button, {
144
+ id: "pisell-virtual-keyboard-".concat(item.value),
145
+ key: item.value,
146
+ type: item.type,
147
+ className: "pisell-virtual-keyboard-item-button",
148
+ style: _objectSpread({
149
+ fontSize: ((_item$style2 = item.style) === null || _item$style2 === void 0 ? void 0 : _item$style2.fontSize) || 25,
150
+ color: item.type === 'primary' ? '#fff' : ((_item$style3 = item.style) === null || _item$style3 === void 0 ? void 0 : _item$style3.color) || undefined
151
+ }, item.type === 'primary' ? item.style || {} : {}),
152
+ disabled: item.disabled,
153
+ onClick: function onClick(e) {
154
+ onChange === null || onChange === void 0 || onChange(item.value);
155
+ }
156
+ }, item.label));
157
+ })));
158
+ };
159
+ export default /*#__PURE__*/React.memo(Keyboard);
@@ -0,0 +1,44 @@
1
+ .pisell-virtual-keyboard-wrap {
2
+ display: flex;
3
+ gap: 7px;
4
+ .pisell-virtual-keyboard-content {
5
+ width: 100%;
6
+ display: flex;
7
+ flex-wrap: wrap;
8
+ align-items: center;
9
+ justify-content: flex-end;
10
+ gap: 7px;
11
+
12
+ .pisell-virtual-keyboard-item {
13
+ border-radius: 5px;
14
+ background: var(--Base-White, #fff);
15
+ box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.06);;
16
+ overflow: hidden;
17
+ width: calc((100% - 14px) / 3 * 1);
18
+ padding-top: 25%;
19
+ position: relative;
20
+
21
+ .pisell-virtual-keyboard-item-button {
22
+ position: absolute;
23
+ left: 0;
24
+ top: 0;
25
+ width: 100%;
26
+ height: 100%;
27
+ border-radius: 5px;
28
+ color: var(--Base-Black, #000);
29
+ font-size: 25px;
30
+ font-style: normal;
31
+ font-weight: 400;
32
+ box-shadow: none;
33
+ padding: 0 !important;
34
+ }
35
+ }
36
+ }
37
+ .pisell-virtual-keyboard-right {
38
+ flex-direction: column;
39
+ justify-content: start;
40
+ .pisell-virtual-keyboard-item{
41
+ width: 100%;
42
+ }
43
+ }
44
+ }
@@ -1,18 +1,5 @@
1
1
  import React from 'react';
2
2
  import './index.less';
3
- import type { DetailedHTMLProps, HTMLAttributes, VideoHTMLAttributes, InputHTMLAttributes } from 'react';
4
- declare type ExtendedDetailedHTMLProps<T extends HTMLAttributes<E>, E extends HTMLElement> = DetailedHTMLProps<T, E> & {
5
- children?: React.ReactNode;
6
- };
7
- declare global {
8
- namespace JSX {
9
- interface IntrinsicElements {
10
- div: ExtendedDetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
11
- video: DetailedHTMLProps<VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
12
- input: DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
13
- }
14
- }
15
- }
16
3
  export interface PisellQRScannerProps {
17
4
  /** 是否可见 */
18
5
  visible: boolean;
@@ -18,14 +18,6 @@ import "./index.less";
18
18
  import { createPortal } from 'react-dom';
19
19
  import { getText } from "../../locales";
20
20
 
21
- // 不使用全局声明,改用本地引入React类型
22
-
23
- // 扩展HTMLAttributes接口以包含children属性
24
-
25
- // 扩展DetailedHTMLProps类型以使用扩展的HTMLAttributes
26
-
27
- // 声明JSX命名空间,解决JSX.IntrinsicElements错误
28
-
29
21
  // 精确定义组件属性,只接收需要的属性
30
22
 
31
23
  /**
@@ -117,7 +117,7 @@ export interface PisellWalletPassCardProps {
117
117
  color: string;
118
118
  };
119
119
  /** 卡片状态 */
120
- cardStatus?: 'used' | 'expired' | 'disabled' | 'conflict';
120
+ cardStatus?: 'used' | 'expired' | 'disabled' | 'conflict' | 'lastPayment';
121
121
  /** 自定义余额格式化函数,如果提供则优先使用 */
122
122
  formatBalance?: (balance?: number, option?: FormatOption) => React.ReactNode;
123
123
  /** 自定义余额标题格式化函数,如果提供则优先使用 */
@@ -34,7 +34,8 @@ var cardStatusMap = {
34
34
  used: 'warning',
35
35
  expired: 'error',
36
36
  conflict: 'error',
37
- disabled: 'gray'
37
+ disabled: 'gray',
38
+ lastPayment: 'gray'
38
39
  };
39
40
  var PisellWalletPassCard = function PisellWalletPassCard(props) {
40
41
  var _React$useState = React.useState(false),
@@ -17,4 +17,4 @@ export declare const minusSign: (item: any, type?: string) => "" | "-";
17
17
  * @Author: WangHan
18
18
  * @Date: 2024-11-22 10:58
19
19
  */
20
- export declare const _formatAmount: (price?: number, amountSymbol?: string, digit?: number) => any;
20
+ export declare const _formatAmount: (price?: number, amountSymbol?: string, digit?: number) => string | number;
@@ -17,6 +17,7 @@ export declare type Action = {
17
17
  text: ReactNode;
18
18
  color?: ActionColor | string;
19
19
  onClick?: (e: React.MouseEvent) => void;
20
+ style?: React.CSSProperties;
20
21
  };
21
22
  export declare type SwipeActionProps = {
22
23
  rightActions?: Action[];
@@ -13,7 +13,8 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
13
13
  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); }
14
14
  import { animated, useSpring } from '@react-spring/web';
15
15
  import { useDrag } from '@use-gesture/react/dist/use-gesture-react.cjs';
16
- import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
16
+ import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
17
+
17
18
  // 本地实现的工具函数和类型
18
19
 
19
20
  // withNativeProps 工具函数
@@ -85,17 +86,35 @@ export var SwipeAction = /*#__PURE__*/forwardRef(function (p, ref) {
85
86
  var rootRef = useRef(null);
86
87
  var leftRef = useRef(null);
87
88
  var rightRef = useRef(null);
89
+
90
+ // 添加容器高度状态
91
+ var _useState = useState(0),
92
+ _useState2 = _slicedToArray(_useState, 2),
93
+ containerHeight = _useState2[0],
94
+ setContainerHeight = _useState2[1];
88
95
  function getWidth(ref) {
89
96
  var element = ref.current;
90
97
  if (!element) return 0;
91
98
  return element.offsetWidth;
92
99
  }
100
+
101
+ // 添加获取高度的函数
102
+ function getHeight(ref) {
103
+ var element = ref.current;
104
+ if (!element) return 0;
105
+ return element.offsetHeight;
106
+ }
93
107
  function getLeftWidth() {
94
108
  return getWidth(leftRef);
95
109
  }
96
110
  function getRightWidth() {
97
111
  return getWidth(rightRef);
98
112
  }
113
+
114
+ // 添加获取根容器高度的函数
115
+ function getRootHeight() {
116
+ return getHeight(rootRef);
117
+ }
99
118
  var _useSpring = useSpring(function () {
100
119
  return {
101
120
  x: 0,
@@ -198,6 +217,26 @@ export var SwipeAction = /*#__PURE__*/forwardRef(function (p, ref) {
198
217
  close: close
199
218
  };
200
219
  });
220
+
221
+ // 添加高度检测的 useEffect
222
+ useEffect(function () {
223
+ var updateHeight = function updateHeight() {
224
+ var height = getRootHeight();
225
+ setContainerHeight(height);
226
+ };
227
+
228
+ // 组件挂载后检测高度
229
+ updateHeight();
230
+
231
+ // 监听窗口大小变化
232
+ var resizeObserver = new ResizeObserver(updateHeight);
233
+ if (rootRef.current) {
234
+ resizeObserver.observe(rootRef.current);
235
+ }
236
+ return function () {
237
+ resizeObserver.disconnect();
238
+ };
239
+ }, []);
201
240
  useEffect(function () {
202
241
  if (!props.closeOnTouchOutside) return;
203
242
  function handle(e) {
@@ -224,13 +263,38 @@ export var SwipeAction = /*#__PURE__*/forwardRef(function (p, ref) {
224
263
  document.removeEventListener('mousedown', handle);
225
264
  };
226
265
  }, [props.closeOnTouchOutside, props.escapeDom]);
266
+
267
+ // 根据容器高度获取右侧容器的 class 名称
268
+ var getRightContainerClass = function getRightContainerClass() {
269
+ var baseClass = "".concat(classPrefix, "-actions ").concat(classPrefix, "-actions-right");
270
+ if (containerHeight > 180) {
271
+ return "".concat(baseClass, " ").concat(classPrefix, "-height-large");
272
+ } else if (containerHeight > 120) {
273
+ return "".concat(baseClass, " ").concat(classPrefix, "-height-medium");
274
+ }
275
+ return "".concat(baseClass, " ").concat(classPrefix, "-height-small");
276
+ };
277
+
278
+ // 根据容器高度获取右侧按钮的 class 名称
279
+ var getRightActionButtonClass = function getRightActionButtonClass() {
280
+ if (containerHeight > 180) {
281
+ return "".concat(classPrefix, "-action-height-large");
282
+ } else if (containerHeight > 120) {
283
+ return "".concat(classPrefix, "-action-height-medium");
284
+ }
285
+ return "".concat(classPrefix, "-action-height-small");
286
+ };
227
287
  function renderAction(action) {
228
288
  var _action$color, _colorRecord$color;
289
+ var isRightAction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
229
290
  var color = (_action$color = action.color) !== null && _action$color !== void 0 ? _action$color : 'light';
230
291
  var _style = action.style || {};
292
+
293
+ // 为右侧按钮添加基于高度的 class
294
+ var buttonClass = isRightAction ? "".concat(classPrefix, "-action-button ").concat(getRightActionButtonClass()) : "".concat(classPrefix, "-action-button");
231
295
  return /*#__PURE__*/React.createElement(Button, {
232
296
  key: action.key,
233
- className: "".concat(classPrefix, "-action-button"),
297
+ className: buttonClass,
234
298
  style: _objectSpread({
235
299
  '--background-color': (_colorRecord$color = colorRecord[color]) !== null && _colorRecord$color !== void 0 ? _colorRecord$color : color
236
300
  }, _style),
@@ -262,7 +326,9 @@ export var SwipeAction = /*#__PURE__*/forwardRef(function (p, ref) {
262
326
  }, withStopPropagation(props.stopPropagation, /*#__PURE__*/React.createElement("div", {
263
327
  className: "".concat(classPrefix, "-actions ").concat(classPrefix, "-actions-left"),
264
328
  ref: leftRef
265
- }, props.leftActions.map(renderAction))), /*#__PURE__*/React.createElement("div", {
329
+ }, props.leftActions.map(function (action) {
330
+ return renderAction(action, false);
331
+ }))), /*#__PURE__*/React.createElement("div", {
266
332
  className: "".concat(classPrefix, "-content"),
267
333
  onClickCapture: function onClickCapture(e) {
268
334
  if (x.goal !== 0) {
@@ -278,9 +344,11 @@ export var SwipeAction = /*#__PURE__*/forwardRef(function (p, ref) {
278
344
  })
279
345
  }
280
346
  }, props.children)), withStopPropagation(props.stopPropagation, /*#__PURE__*/React.createElement("div", {
281
- className: "".concat(classPrefix, "-actions ").concat(classPrefix, "-actions-right"),
347
+ className: getRightContainerClass(),
282
348
  ref: rightRef
283
- }, props.rightActions.map(renderAction))))));
349
+ }, props.rightActions.map(function (action) {
350
+ return renderAction(action, true);
351
+ }))))));
284
352
  });
285
353
  var colorRecord = {
286
354
  light: '#ccc',
@@ -33,3 +33,42 @@
33
33
  padding-right: 4px;
34
34
  }
35
35
  }
36
+
37
+ .pisell-custom-swipe-action-action-button {
38
+ min-width: 80px;
39
+ }
40
+
41
+ /* 容器样式 */
42
+ .pisell-custom-swipe-action-height-large {
43
+ display: flex;
44
+ flex-direction: column;
45
+ background-color: rgba(67, 93, 147, 0.3);
46
+ justify-content: flex-start;
47
+
48
+ .pisell-number-selector-btn {
49
+ width: 40px !important;
50
+ height: 40px !important;
51
+ }
52
+ }
53
+
54
+ .pisell-custom-swipe-action-height-medium {
55
+ display: flex;
56
+ flex-direction: column;
57
+ background-color: rgba(67, 93, 147, 0.3);
58
+
59
+ .pisell-number-selector-btn {
60
+ width: 40px !important;
61
+ height: 40px !important;
62
+ }
63
+ }
64
+
65
+ /* 按钮样式 */
66
+ .pisell-custom-swipe-action-action-height-large {
67
+ height: 60px;
68
+ width: 200px;
69
+ }
70
+
71
+ .pisell-custom-swipe-action-action-height-medium {
72
+ flex: 1;
73
+ width: 200px;
74
+ }