@pisell/materials 1.0.434 → 1.0.436

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.
@@ -2,7 +2,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
2
2
  import { createFromIconfontCN } from '@ant-design/icons';
3
3
  import React from 'react';
4
4
  var MyIcon = createFromIconfontCN({
5
- scriptUrl: 'https://unpkg.com/@pisell/materials@3.0.37/iconfont/iconfont.js' // 在 iconfont.cn 上生成
5
+ scriptUrl: 'https://static.pisellcdn.com/pisell2iconfont.js' // 在 iconfont.cn 上生成
6
6
  });
7
7
 
8
8
  var IconFont = function IconFont(props) {
@@ -1,3 +1,13 @@
1
1
  import { EntryModeType } from './index';
2
2
  export declare const entryModeTextIcon: Record<EntryModeType['type'], any>;
3
+ export declare const entryModeErrorTextIcon: {
4
+ scanner: {
5
+ icon: string;
6
+ text: string;
7
+ };
8
+ nfc: {
9
+ icon: string;
10
+ text: string;
11
+ };
12
+ };
3
13
  export declare const passiveModeType: string[];
@@ -16,6 +16,16 @@ export var entryModeTextIcon = {
16
16
  text: 'NFC ready'
17
17
  }
18
18
  };
19
+ export var entryModeErrorTextIcon = {
20
+ scanner: {
21
+ icon: 'pisell2-a-Scanner11',
22
+ text: 'Scanner'
23
+ },
24
+ nfc: {
25
+ icon: 'pisell2-a-NFC1',
26
+ text: 'NFC'
27
+ }
28
+ };
19
29
 
20
30
  // 没有操作界面的输入模式
21
31
  export var passiveModeType = ['scanner', 'nfc'];
@@ -1,6 +1,6 @@
1
1
  declare type Peripherals = {
2
- scanner: 'none' | 'connected' | 'notConnected';
3
- nfc: 'none' | 'connected' | 'notConnected';
2
+ scanner: 'none' | 'connected' | 'disconnect';
3
+ nfc: 'none' | 'connected' | 'disconnect';
4
4
  };
5
5
  declare const useTerminalPeripherals: (onChange?: ((val: string) => void) | undefined) => {
6
6
  peripheralsStatus: Peripherals;
@@ -21,8 +21,13 @@ var useTerminalPeripherals = function useTerminalPeripherals(onChange) {
21
21
  useEffect(function () {
22
22
  var _interaction$utils, _interaction$utils$mo, _interaction$utils2, _interaction$utils2$p, _interaction$utils3, _interaction$utils3$m;
23
23
  // 获取外部设备扫描结果
24
- interaction === null || interaction === void 0 ? void 0 : (_interaction$utils = interaction.utils) === null || _interaction$utils === void 0 ? void 0 : (_interaction$utils$mo = _interaction$utils.mountFunction) === null || _interaction$utils$mo === void 0 ? void 0 : _interaction$utils$mo.call(_interaction$utils, 'global', 'peripheralsResult', function (val) {
25
- onChange === null || onChange === void 0 ? void 0 : onChange(val.value);
24
+ interaction === null || interaction === void 0 ? void 0 : (_interaction$utils = interaction.utils) === null || _interaction$utils === void 0 ? void 0 : (_interaction$utils$mo = _interaction$utils.mountFunction) === null || _interaction$utils$mo === void 0 ? void 0 : _interaction$utils$mo.call(_interaction$utils, 'global', 'peripheralsResult', function (strVal) {
25
+ try {
26
+ var _val = JSON.parse(strVal);
27
+ onChange === null || onChange === void 0 ? void 0 : onChange(_val.value);
28
+ } catch (err) {
29
+ console.error(err);
30
+ }
26
31
  });
27
32
 
28
33
  // 主动获取设备连接状态
@@ -33,8 +38,13 @@ var useTerminalPeripherals = function useTerminalPeripherals(onChange) {
33
38
  });
34
39
 
35
40
  // 设备当前连接状态返回
36
- interaction === null || interaction === void 0 ? void 0 : (_interaction$utils3 = interaction.utils) === null || _interaction$utils3 === void 0 ? void 0 : (_interaction$utils3$m = _interaction$utils3.mountFunction) === null || _interaction$utils3$m === void 0 ? void 0 : _interaction$utils3$m.call(_interaction$utils3, 'global', 'peripheralsStatus', function (peripherals) {
37
- setPeripheralsStatus(peripherals);
41
+ interaction === null || interaction === void 0 ? void 0 : (_interaction$utils3 = interaction.utils) === null || _interaction$utils3 === void 0 ? void 0 : (_interaction$utils3$m = _interaction$utils3.mountFunction) === null || _interaction$utils3$m === void 0 ? void 0 : _interaction$utils3$m.call(_interaction$utils3, 'global', 'peripheralsStatus', function (strPeripherals) {
42
+ try {
43
+ var peripherals = JSON.parse(strPeripherals);
44
+ setPeripheralsStatus(peripherals);
45
+ } catch (err) {
46
+ console.error(err);
47
+ }
38
48
  });
39
49
  }, []);
40
50
  return {
@@ -19,7 +19,7 @@ import classNames from 'classnames';
19
19
  import usePisellConfig from "../pisell-config-provider/hooks/usePisellConfig";
20
20
  import PisellCard from "../pisellCard";
21
21
  import Iconfont from "../iconfont";
22
- import { entryModeTextIcon, passiveModeType } from "./constants";
22
+ import { entryModeErrorTextIcon, entryModeTextIcon, passiveModeType } from "./constants";
23
23
  import Scan from "./Scan";
24
24
  import Button from "../button";
25
25
  import Input from "./Input";
@@ -176,10 +176,15 @@ var PisellInformationEntry = function PisellInformationEntry(props) {
176
176
  className: "pisell-information-entry-modes"
177
177
  }, availableEntryModes.map(function (item) {
178
178
  var detail = entryModeTextIcon[item.type];
179
+ var icon = detail.icon;
180
+ if (['scanner', 'nfc'].includes(item.type)) {
181
+ var disconnect = entryModeErrorTextIcon[item.type];
182
+ icon = peripheralsStatus[item.type] === 'connected' ? detail.icon : disconnect.icon;
183
+ }
179
184
  return /*#__PURE__*/React.createElement(CardButton, {
180
185
  bordered: !passiveModeType.includes(item.type),
181
186
  icon: /*#__PURE__*/React.createElement(Iconfont, {
182
- type: detail.icon,
187
+ type: icon,
183
188
  className: "pisell-card-button-icon"
184
189
  }),
185
190
  className: classNames('pisell-information-entry-item', _defineProperty({}, 'pisell-entry-ready', passiveModeType.includes(item.type))),
@@ -23,7 +23,7 @@
23
23
  flex: 1;
24
24
  text-align: center;
25
25
  cursor: pointer;
26
- min-width: 165px;
26
+ min-width: 140px;
27
27
  .pisell-card-button-icon {
28
28
  height: 48px;
29
29
  font-size: 36px;
@@ -35,7 +35,7 @@ module.exports = __toCommonJS(iconfont_exports);
35
35
  var import_icons = require("@ant-design/icons");
36
36
  var import_react = __toESM(require("react"));
37
37
  var MyIcon = (0, import_icons.createFromIconfontCN)({
38
- scriptUrl: "https://unpkg.com/@pisell/materials@3.0.37/iconfont/iconfont.js"
38
+ scriptUrl: "https://static.pisellcdn.com/pisell2iconfont.js"
39
39
  // 在 iconfont.cn 上生成
40
40
  });
41
41
  var IconFont = (props) => {
@@ -1,3 +1,13 @@
1
1
  import { EntryModeType } from './index';
2
2
  export declare const entryModeTextIcon: Record<EntryModeType['type'], any>;
3
+ export declare const entryModeErrorTextIcon: {
4
+ scanner: {
5
+ icon: string;
6
+ text: string;
7
+ };
8
+ nfc: {
9
+ icon: string;
10
+ text: string;
11
+ };
12
+ };
3
13
  export declare const passiveModeType: string[];
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/components/pisellInformationEntry/constants.ts
20
20
  var constants_exports = {};
21
21
  __export(constants_exports, {
22
+ entryModeErrorTextIcon: () => entryModeErrorTextIcon,
22
23
  entryModeTextIcon: () => entryModeTextIcon,
23
24
  passiveModeType: () => passiveModeType
24
25
  });
@@ -41,9 +42,20 @@ var entryModeTextIcon = {
41
42
  text: "NFC ready"
42
43
  }
43
44
  };
45
+ var entryModeErrorTextIcon = {
46
+ scanner: {
47
+ icon: "pisell2-a-Scanner11",
48
+ text: "Scanner"
49
+ },
50
+ nfc: {
51
+ icon: "pisell2-a-NFC1",
52
+ text: "NFC"
53
+ }
54
+ };
44
55
  var passiveModeType = ["scanner", "nfc"];
45
56
  // Annotate the CommonJS export names for ESM import in node:
46
57
  0 && (module.exports = {
58
+ entryModeErrorTextIcon,
47
59
  entryModeTextIcon,
48
60
  passiveModeType
49
61
  });
@@ -1,6 +1,6 @@
1
1
  declare type Peripherals = {
2
- scanner: 'none' | 'connected' | 'notConnected';
3
- nfc: 'none' | 'connected' | 'notConnected';
2
+ scanner: 'none' | 'connected' | 'disconnect';
3
+ nfc: 'none' | 'connected' | 'disconnect';
4
4
  };
5
5
  declare const useTerminalPeripherals: (onChange?: ((val: string) => void) | undefined) => {
6
6
  peripheralsStatus: Peripherals;
@@ -48,8 +48,13 @@ var useTerminalPeripherals = (onChange) => {
48
48
  _a2,
49
49
  "global",
50
50
  "peripheralsResult",
51
- (val) => {
52
- onChange == null ? void 0 : onChange(val.value);
51
+ (strVal) => {
52
+ try {
53
+ const val = JSON.parse(strVal);
54
+ onChange == null ? void 0 : onChange(val.value);
55
+ } catch (err) {
56
+ console.error(err);
57
+ }
53
58
  }
54
59
  );
55
60
  (_d = (_c = interaction == null ? void 0 : interaction.utils) == null ? void 0 : _c.postMessageToApp) == null ? void 0 : _d.call(_c, {
@@ -61,8 +66,13 @@ var useTerminalPeripherals = (onChange) => {
61
66
  _e,
62
67
  "global",
63
68
  "peripheralsStatus",
64
- (peripherals) => {
65
- setPeripheralsStatus(peripherals);
69
+ (strPeripherals) => {
70
+ try {
71
+ const peripherals = JSON.parse(strPeripherals);
72
+ setPeripheralsStatus(peripherals);
73
+ } catch (err) {
74
+ console.error(err);
75
+ }
66
76
  }
67
77
  );
68
78
  }, []);
@@ -150,6 +150,11 @@ var PisellInformationEntry = (props) => {
150
150
  }
151
151
  ))), isShowEntryModes && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-information-entry-modes" }, availableEntryModes.map((item) => {
152
152
  const detail = import_constants.entryModeTextIcon[item.type];
153
+ let icon = detail.icon;
154
+ if (["scanner", "nfc"].includes(item.type)) {
155
+ const disconnect = import_constants.entryModeErrorTextIcon[item.type];
156
+ icon = peripheralsStatus[item.type] === "connected" ? detail.icon : disconnect.icon;
157
+ }
153
158
  return /* @__PURE__ */ import_react.default.createElement(
154
159
  CardButton,
155
160
  {
@@ -157,7 +162,7 @@ var PisellInformationEntry = (props) => {
157
162
  icon: /* @__PURE__ */ import_react.default.createElement(
158
163
  import_iconfont.default,
159
164
  {
160
- type: detail.icon,
165
+ type: icon,
161
166
  className: "pisell-card-button-icon"
162
167
  }
163
168
  ),
@@ -23,7 +23,7 @@
23
23
  flex: 1;
24
24
  text-align: center;
25
25
  cursor: pointer;
26
- min-width: 165px;
26
+ min-width: 140px;
27
27
  .pisell-card-button-icon {
28
28
  height: 48px;
29
29
  font-size: 36px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "1.0.434",
3
+ "version": "1.0.436",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -64,9 +64,9 @@
64
64
  "react-virtualized-auto-sizer": "^1.0.20",
65
65
  "crypto-js": "^4.2.0",
66
66
  "@zxing/library": "0.21.2",
67
+ "@pisell/utils": "1.0.42",
67
68
  "@pisell/icon": "0.0.10",
68
- "@pisell/date-picker": "1.0.111",
69
- "@pisell/utils": "1.0.42"
69
+ "@pisell/date-picker": "1.0.111"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "react": "^18.0.0",