@pisell/materials 1.0.83 → 1.0.85
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 +2 -2
- package/build/lowcode/preview.js +8 -8
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +12 -12
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +11 -11
- package/es/components/table/Table/fields/text/Show/index.d.ts +1 -0
- package/es/components/table/Table/fields/text/Show/index.js +22 -2
- package/es/components/table/Table/fields/text/Show/index.less +9 -0
- package/es/components/table/Table/fields/types/index.d.ts +2 -0
- package/es/components/table/Table/index.js +3 -1
- package/es/components/table/index.d.ts +1 -0
- package/es/components/table/index.js +10 -0
- package/es/components/table/model.d.ts +1 -0
- package/es/components/table/model.js +6 -0
- package/es/components/translation/index.d.ts +13 -0
- package/es/components/translation/index.js +154 -0
- package/es/components/translation/index.less +15 -0
- package/es/components/translation/utils.d.ts +7 -0
- package/es/components/translation/utils.js +32 -0
- package/es/hooks/useEngineContext.d.ts +9 -0
- package/es/hooks/useEngineContext.js +7 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/lib/components/table/Table/fields/text/Show/index.d.ts +1 -0
- package/lib/components/table/Table/fields/text/Show/index.js +40 -1
- package/lib/components/table/Table/fields/text/Show/index.less +9 -0
- package/lib/components/table/Table/fields/types/index.d.ts +2 -0
- package/lib/components/table/Table/index.js +3 -1
- package/lib/components/table/index.d.ts +1 -0
- package/lib/components/table/index.js +14 -4
- package/lib/components/table/model.d.ts +1 -0
- package/lib/components/table/model.js +4 -0
- package/lib/components/translation/index.d.ts +13 -0
- package/lib/components/translation/index.js +173 -0
- package/lib/components/translation/index.less +15 -0
- package/lib/components/translation/utils.d.ts +7 -0
- package/lib/components/translation/utils.js +55 -0
- package/lib/hooks/useEngineContext.d.ts +9 -0
- package/lib/hooks/useEngineContext.js +33 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -0
- package/lowcode/translation/__screenshots__/input-1.png +0 -0
- package/lowcode/translation/meta.ts +186 -0
- package/lowcode/translation/snippets.ts +12 -0
- package/package.json +1 -1
- package/dist/umd/materials.min.css +0 -1
- package/dist/umd/materials.min.js +0 -1
- package/dist/umd/static/DotsSix.57d66266.svg +0 -1
- package/dist/umd/static/arrow-left.e542294f.svg +0 -1
- package/dist/umd/static/arrow-right.763f03e0.svg +0 -1
- package/dist/umd/static/filter-lines.04a54ae9.svg +0 -1
- package/dist/umd/static/help-circle.31c9be40.svg +0 -1
- package/dist/umd/static/switch-vertical-01.7ebe3ba8.svg +0 -1
|
@@ -1,16 +1,36 @@
|
|
|
1
|
-
var _excluded = ["title", "editable", "dataIndex", "field_type", "record", "handleSave"];
|
|
1
|
+
var _excluded = ["title", "editable", "dataIndex", "field_type", "record", "handleSave", "action", "contentClassName"];
|
|
2
2
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
3
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
|
+
import { useSharedState } from "../../../../../../hooks";
|
|
5
|
+
import { Context } from "../../../../model";
|
|
6
|
+
import classNames from "classnames";
|
|
7
|
+
import "./index.less";
|
|
4
8
|
var Show = function Show(props) {
|
|
9
|
+
var modal = useSharedState(Context);
|
|
5
10
|
var title = props.title,
|
|
6
11
|
editable = props.editable,
|
|
7
12
|
dataIndex = props.dataIndex,
|
|
8
13
|
field_type = props.field_type,
|
|
9
14
|
record = props.record,
|
|
10
15
|
handleSave = props.handleSave,
|
|
16
|
+
action = props.action,
|
|
17
|
+
contentClassName = props.contentClassName,
|
|
11
18
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
19
|
+
var onClick = function onClick() {
|
|
20
|
+
var _modal$state, _modal$state$utils;
|
|
21
|
+
if (action && modal !== null && modal !== void 0 && (_modal$state = modal.state) !== null && _modal$state !== void 0 && (_modal$state$utils = _modal$state.utils) !== null && _modal$state$utils !== void 0 && _modal$state$utils.action) {
|
|
22
|
+
var _modal$state2, _modal$state2$utils;
|
|
23
|
+
modal === null || modal === void 0 ? void 0 : (_modal$state2 = modal.state) === null || _modal$state2 === void 0 ? void 0 : (_modal$state2$utils = _modal$state2.utils) === null || _modal$state2$utils === void 0 ? void 0 : _modal$state2$utils.action({
|
|
24
|
+
type: action,
|
|
25
|
+
data: record
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
12
29
|
return /*#__PURE__*/React.createElement("div", {
|
|
13
|
-
className: ""
|
|
30
|
+
className: classNames(contentClassName || "", {
|
|
31
|
+
"table-fields-text-link": action
|
|
32
|
+
}, contentClassName),
|
|
33
|
+
onClick: onClick
|
|
14
34
|
}, record[dataIndex]);
|
|
15
35
|
};
|
|
16
36
|
export default Show;
|
|
@@ -11,6 +11,8 @@ export declare type FieldPropsType = {
|
|
|
11
11
|
}[];
|
|
12
12
|
handleSave: () => void;
|
|
13
13
|
onChange: (value: any, record: any) => void;
|
|
14
|
+
action?: string;
|
|
15
|
+
contentClassName?: string;
|
|
14
16
|
};
|
|
15
17
|
export declare type FieldType = "text" | "image";
|
|
16
18
|
export declare type EditPropsType = {
|
|
@@ -73,7 +73,9 @@ var GridViewTable = function GridViewTable(_ref) {
|
|
|
73
73
|
field_type: col.field_type,
|
|
74
74
|
lock: col.lock,
|
|
75
75
|
width: col.width || 0,
|
|
76
|
-
|
|
76
|
+
action: col.action || "",
|
|
77
|
+
render: col.render,
|
|
78
|
+
contentClassName: col.contentClassName || ""
|
|
77
79
|
};
|
|
78
80
|
var filterObj = {};
|
|
79
81
|
|
|
@@ -22,7 +22,9 @@ import GridViewTable from "./Table";
|
|
|
22
22
|
import { useSharedState } from "../../hooks";
|
|
23
23
|
import "./index.less";
|
|
24
24
|
import { Provider, Context } from "./model";
|
|
25
|
+
import useEngineContext from "../../hooks/useEngineContext";
|
|
25
26
|
var GridView = Provider(function (props) {
|
|
27
|
+
var _context$appHelper;
|
|
26
28
|
var modal = useSharedState(Context);
|
|
27
29
|
var _Form$useForm = Form.useForm(),
|
|
28
30
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
@@ -38,6 +40,14 @@ var GridView = Provider(function (props) {
|
|
|
38
40
|
summary = props.summary,
|
|
39
41
|
_onValuesChange = props.onValuesChange,
|
|
40
42
|
other = _objectWithoutProperties(props, _excluded);
|
|
43
|
+
var context = useEngineContext();
|
|
44
|
+
var utils = context === null || context === void 0 ? void 0 : (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils;
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
modal.dispatch({
|
|
47
|
+
type: "setUtils",
|
|
48
|
+
payload: utils || {}
|
|
49
|
+
});
|
|
50
|
+
}, [utils]);
|
|
41
51
|
useEffect(function () {
|
|
42
52
|
modal.dispatch({
|
|
43
53
|
type: "setDefaultColumns",
|
|
@@ -52,6 +52,7 @@ var defaultState = {
|
|
|
52
52
|
currentCell: null,
|
|
53
53
|
quickFilter: [],
|
|
54
54
|
otherFilter: [],
|
|
55
|
+
utils: {},
|
|
55
56
|
setting: {
|
|
56
57
|
field: {
|
|
57
58
|
edit: 0
|
|
@@ -87,6 +88,11 @@ var _getContext = getContext({
|
|
|
87
88
|
quickFilter: payload
|
|
88
89
|
});
|
|
89
90
|
},
|
|
91
|
+
setUtils: function setUtils(state, payload) {
|
|
92
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
93
|
+
utils: payload
|
|
94
|
+
});
|
|
95
|
+
},
|
|
90
96
|
syncStorage: function syncStorage(state, payload) {
|
|
91
97
|
return _objectSpread({}, state);
|
|
92
98
|
},
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import './index.less';
|
|
3
|
+
declare type Value = {
|
|
4
|
+
en: string;
|
|
5
|
+
"zh-CN": string;
|
|
6
|
+
"zh-HK": string;
|
|
7
|
+
};
|
|
8
|
+
interface TranslationProps {
|
|
9
|
+
value: Value;
|
|
10
|
+
onChange: (value: Value) => void;
|
|
11
|
+
}
|
|
12
|
+
declare const Translation: React.FC<TranslationProps>;
|
|
13
|
+
export default Translation;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _excluded = ["value", "onChange"];
|
|
3
|
+
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); }
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
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; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
+
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; }
|
|
13
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
14
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
16
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
18
|
+
import { Input, Modal, Form } from "antd";
|
|
19
|
+
import { isString } from "@pisell/utils";
|
|
20
|
+
import { GlobalOutlined } from "@ant-design/icons";
|
|
21
|
+
import classNames from "classnames";
|
|
22
|
+
import useEngineContext from "../../hooks/useEngineContext";
|
|
23
|
+
import { checkIfAllValuesAreEqual, createTranslationText, locales } from "./utils";
|
|
24
|
+
import "./index.less";
|
|
25
|
+
var defaultGlobal = {
|
|
26
|
+
shopLanguages: {
|
|
27
|
+
primary: "en",
|
|
28
|
+
list: [{
|
|
29
|
+
id: 1,
|
|
30
|
+
code: "zh-CN",
|
|
31
|
+
text: "简体中文",
|
|
32
|
+
primary: 1,
|
|
33
|
+
status: "published"
|
|
34
|
+
}, {
|
|
35
|
+
id: 2,
|
|
36
|
+
code: "en",
|
|
37
|
+
text: "English",
|
|
38
|
+
primary: 0,
|
|
39
|
+
status: "published"
|
|
40
|
+
}, {
|
|
41
|
+
id: 3,
|
|
42
|
+
code: "zh-HK",
|
|
43
|
+
text: "繁體中文",
|
|
44
|
+
primary: 0,
|
|
45
|
+
status: "published"
|
|
46
|
+
}]
|
|
47
|
+
},
|
|
48
|
+
primary_locale: "en"
|
|
49
|
+
};
|
|
50
|
+
var defaultObj = {};
|
|
51
|
+
var Translation = function Translation(props) {
|
|
52
|
+
var _context$appHelper, _store$getState;
|
|
53
|
+
var _props$value = props.value,
|
|
54
|
+
value = _props$value === void 0 ? defaultObj : _props$value,
|
|
55
|
+
onChange = props.onChange,
|
|
56
|
+
others = _objectWithoutProperties(props, _excluded);
|
|
57
|
+
var context = useEngineContext();
|
|
58
|
+
var _useState = useState(false),
|
|
59
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
60
|
+
open = _useState2[0],
|
|
61
|
+
setOpen = _useState2[1];
|
|
62
|
+
var _useState3 = useState(value),
|
|
63
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
64
|
+
_value = _useState4[0],
|
|
65
|
+
set_value = _useState4[1];
|
|
66
|
+
var store = context === null || context === void 0 ? void 0 : (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.store;
|
|
67
|
+
var _ref = (store === null || store === void 0 ? void 0 : (_store$getState = store.getState()) === null || _store$getState === void 0 ? void 0 : _store$getState.global) || defaultGlobal,
|
|
68
|
+
shopLanguages = _ref.shopLanguages;
|
|
69
|
+
useEffect(function () {
|
|
70
|
+
var _newValue = _objectSpread({}, value);
|
|
71
|
+
if (isString(value)) {
|
|
72
|
+
_newValue = createTranslationText(value);
|
|
73
|
+
}
|
|
74
|
+
set_value(_objectSpread(_objectSpread({}, defaultValue), _newValue));
|
|
75
|
+
}, [value]);
|
|
76
|
+
var currentLocale = useMemo(function () {
|
|
77
|
+
return shopLanguages.primary;
|
|
78
|
+
}, [shopLanguages.primary]);
|
|
79
|
+
var inputValue = useMemo(function () {
|
|
80
|
+
if (isString(value)) {
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
return value[currentLocale];
|
|
84
|
+
}, [value, currentLocale]);
|
|
85
|
+
var languageList = useMemo(function () {
|
|
86
|
+
return shopLanguages.list;
|
|
87
|
+
}, [shopLanguages.list]);
|
|
88
|
+
var defaultValue = useMemo(function () {
|
|
89
|
+
var obj = {};
|
|
90
|
+
for (var item in locales) {
|
|
91
|
+
obj[item] = "";
|
|
92
|
+
}
|
|
93
|
+
return obj;
|
|
94
|
+
}, []);
|
|
95
|
+
var allChange = function allChange(e) {
|
|
96
|
+
var newValue = _objectSpread(_objectSpread({}, defaultValue), value || {});
|
|
97
|
+
if (checkIfAllValuesAreEqual(newValue)) {
|
|
98
|
+
for (var key in newValue) {
|
|
99
|
+
newValue[key] = e || "";
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
newValue[currentLocale] = e || "";
|
|
103
|
+
}
|
|
104
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
105
|
+
};
|
|
106
|
+
var isActive = useMemo(function () {
|
|
107
|
+
var bol = false;
|
|
108
|
+
for (var key in value) {
|
|
109
|
+
if (key !== currentLocale && value[key]) {
|
|
110
|
+
bol = true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return bol;
|
|
114
|
+
}, [value, currentLocale]);
|
|
115
|
+
var _onOk = function _onOk() {
|
|
116
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(_value);
|
|
117
|
+
setOpen(false);
|
|
118
|
+
};
|
|
119
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Input, _extends({}, others, {
|
|
120
|
+
value: inputValue,
|
|
121
|
+
onChange: allChange,
|
|
122
|
+
suffix: /*#__PURE__*/React.createElement(GlobalOutlined, {
|
|
123
|
+
className: classNames("pisell-lowcode-translation-icon", {
|
|
124
|
+
active: isActive
|
|
125
|
+
}),
|
|
126
|
+
onClick: function onClick() {
|
|
127
|
+
return setOpen(true);
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
})), /*#__PURE__*/React.createElement(Modal, {
|
|
131
|
+
open: open,
|
|
132
|
+
onOk: _onOk,
|
|
133
|
+
onCancel: function onCancel() {
|
|
134
|
+
set_value(value || defaultValue);
|
|
135
|
+
setOpen(false);
|
|
136
|
+
}
|
|
137
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
138
|
+
className: "pisell-lowcode-translation-modal"
|
|
139
|
+
}, languageList.map(function (d) {
|
|
140
|
+
return /*#__PURE__*/React.createElement(Form.Item, {
|
|
141
|
+
label: d.text,
|
|
142
|
+
labelCol: {
|
|
143
|
+
span: 24
|
|
144
|
+
},
|
|
145
|
+
key: d.code
|
|
146
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
147
|
+
value: _value[d.code],
|
|
148
|
+
onChange: function onChange(e) {
|
|
149
|
+
set_value(_objectSpread(_objectSpread({}, _value), {}, _defineProperty({}, d.code, e.target.value)));
|
|
150
|
+
}
|
|
151
|
+
}));
|
|
152
|
+
}))));
|
|
153
|
+
};
|
|
154
|
+
export default Translation;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.pisell-lowcode-translation-icon {
|
|
2
|
+
cursor: pointer;
|
|
3
|
+
color: #d9d9d9;
|
|
4
|
+
:hover {
|
|
5
|
+
color: var(--theme-color);
|
|
6
|
+
}
|
|
7
|
+
&.active {
|
|
8
|
+
color: var(--theme-color);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.pisell-lowcode-translation-modal {
|
|
13
|
+
position: relative;
|
|
14
|
+
width: 100%;
|
|
15
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
export var locales = {
|
|
8
|
+
en: "",
|
|
9
|
+
"zh-CN": "",
|
|
10
|
+
"zh-HK": ""
|
|
11
|
+
};
|
|
12
|
+
export var checkIfAllValuesAreEqual = function checkIfAllValuesAreEqual(obj) {
|
|
13
|
+
var valuesArray = Object.values(obj);
|
|
14
|
+
return valuesArray.every(function (value) {
|
|
15
|
+
return value === valuesArray[0];
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export var createTranslationText = function createTranslationText(text) {
|
|
19
|
+
var isAll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
20
|
+
var primary = localStorage.getItem("shop_primary_locale") || "en";
|
|
21
|
+
var _locales = _objectSpread({}, locales);
|
|
22
|
+
if (text !== "" && text !== undefined) {
|
|
23
|
+
if (isAll) {
|
|
24
|
+
for (var key in _locales) {
|
|
25
|
+
_locales[key] = text;
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
_locales[primary] = text;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return _locales;
|
|
32
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
var defaultContext = /*#__PURE__*/createContext({});
|
|
3
|
+
var useEngineContext = function useEngineContext() {
|
|
4
|
+
var context = useContext(window.__appContext || defaultContext);
|
|
5
|
+
return context || {};
|
|
6
|
+
};
|
|
7
|
+
export default useEngineContext;
|
package/es/index.d.ts
CHANGED
|
@@ -62,3 +62,4 @@ export { default as AutoComplete } from "./components/auto-complete";
|
|
|
62
62
|
export { default as Div } from "./components/div";
|
|
63
63
|
export { default as Page } from "./components/page";
|
|
64
64
|
export { default as Filter } from './components/filter';
|
|
65
|
+
export { default as Translation } from './components/translation';
|
package/es/index.js
CHANGED
|
@@ -89,4 +89,5 @@ export { default as Cascader } from "./components/cascader";
|
|
|
89
89
|
export { default as AutoComplete } from "./components/auto-complete";
|
|
90
90
|
export { default as Div } from "./components/div";
|
|
91
91
|
export { default as Page } from "./components/page";
|
|
92
|
-
export { default as Filter } from "./components/filter";
|
|
92
|
+
export { default as Filter } from "./components/filter";
|
|
93
|
+
export { default as Translation } from "./components/translation";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
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
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/components/table/Table/fields/text/Show/index.tsx
|
|
@@ -22,7 +32,12 @@ __export(Show_exports, {
|
|
|
22
32
|
default: () => Show_default
|
|
23
33
|
});
|
|
24
34
|
module.exports = __toCommonJS(Show_exports);
|
|
35
|
+
var import_hooks = require("../../../../../../hooks");
|
|
36
|
+
var import_model = require("../../../../model");
|
|
37
|
+
var import_classnames = __toESM(require("classnames"));
|
|
38
|
+
var import_index = require("./index.less");
|
|
25
39
|
var Show = (props) => {
|
|
40
|
+
const modal = (0, import_hooks.useSharedState)(import_model.Context);
|
|
26
41
|
const {
|
|
27
42
|
title,
|
|
28
43
|
editable,
|
|
@@ -30,8 +45,32 @@ var Show = (props) => {
|
|
|
30
45
|
field_type,
|
|
31
46
|
record,
|
|
32
47
|
handleSave,
|
|
48
|
+
action,
|
|
49
|
+
contentClassName,
|
|
33
50
|
...restProps
|
|
34
51
|
} = props;
|
|
35
|
-
|
|
52
|
+
const onClick = () => {
|
|
53
|
+
var _a, _b, _c, _d;
|
|
54
|
+
if (action && ((_b = (_a = modal == null ? void 0 : modal.state) == null ? void 0 : _a.utils) == null ? void 0 : _b.action)) {
|
|
55
|
+
(_d = (_c = modal == null ? void 0 : modal.state) == null ? void 0 : _c.utils) == null ? void 0 : _d.action({
|
|
56
|
+
type: action,
|
|
57
|
+
data: record
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return /* @__PURE__ */ React.createElement(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
className: (0, import_classnames.default)(
|
|
65
|
+
contentClassName || "",
|
|
66
|
+
{
|
|
67
|
+
"table-fields-text-link": action
|
|
68
|
+
},
|
|
69
|
+
contentClassName
|
|
70
|
+
),
|
|
71
|
+
onClick
|
|
72
|
+
},
|
|
73
|
+
record[dataIndex]
|
|
74
|
+
);
|
|
36
75
|
};
|
|
37
76
|
var Show_default = Show;
|
|
@@ -11,6 +11,8 @@ export declare type FieldPropsType = {
|
|
|
11
11
|
}[];
|
|
12
12
|
handleSave: () => void;
|
|
13
13
|
onChange: (value: any, record: any) => void;
|
|
14
|
+
action?: string;
|
|
15
|
+
contentClassName?: string;
|
|
14
16
|
};
|
|
15
17
|
export declare type FieldType = "text" | "image";
|
|
16
18
|
export declare type EditPropsType = {
|
|
@@ -87,7 +87,9 @@ var GridViewTable = ({ tableProps }) => {
|
|
|
87
87
|
field_type: col.field_type,
|
|
88
88
|
lock: col.lock,
|
|
89
89
|
width: col.width || 0,
|
|
90
|
-
|
|
90
|
+
action: col.action || "",
|
|
91
|
+
render: col.render,
|
|
92
|
+
contentClassName: col.contentClassName || ""
|
|
91
93
|
};
|
|
92
94
|
let filterObj = {};
|
|
93
95
|
if (col.defaultFilters) {
|
|
@@ -41,7 +41,9 @@ var import_Table = __toESM(require("./Table"));
|
|
|
41
41
|
var import_hooks = require("../../hooks");
|
|
42
42
|
var import_index = require("./index.less");
|
|
43
43
|
var import_model = require("./model");
|
|
44
|
+
var import_useEngineContext = __toESM(require("../../hooks/useEngineContext"));
|
|
44
45
|
var GridView = (0, import_model.Provider)((props) => {
|
|
46
|
+
var _a;
|
|
45
47
|
const modal = (0, import_hooks.useSharedState)(import_model.Context);
|
|
46
48
|
const [form] = import_antd.Form.useForm();
|
|
47
49
|
const {
|
|
@@ -58,6 +60,14 @@ var GridView = (0, import_model.Provider)((props) => {
|
|
|
58
60
|
// pagination,
|
|
59
61
|
...other
|
|
60
62
|
} = props;
|
|
63
|
+
const context = (0, import_useEngineContext.default)();
|
|
64
|
+
const utils = (_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils;
|
|
65
|
+
(0, import_react.useEffect)(() => {
|
|
66
|
+
modal.dispatch({
|
|
67
|
+
type: "setUtils",
|
|
68
|
+
payload: utils || {}
|
|
69
|
+
});
|
|
70
|
+
}, [utils]);
|
|
61
71
|
(0, import_react.useEffect)(() => {
|
|
62
72
|
modal.dispatch({
|
|
63
73
|
type: "setDefaultColumns",
|
|
@@ -75,10 +85,10 @@ var GridView = (0, import_model.Provider)((props) => {
|
|
|
75
85
|
const initialValues = (0, import_react.useMemo)(
|
|
76
86
|
() => ((filter == null ? void 0 : filter.list) || []).reduce(
|
|
77
87
|
(p, c) => {
|
|
78
|
-
var
|
|
88
|
+
var _a2;
|
|
79
89
|
return {
|
|
80
90
|
...p,
|
|
81
|
-
[c.name]: (
|
|
91
|
+
[c.name]: (_a2 = c == null ? void 0 : c.other) == null ? void 0 : _a2.defaultValue
|
|
82
92
|
};
|
|
83
93
|
},
|
|
84
94
|
{}
|
|
@@ -91,7 +101,7 @@ var GridView = (0, import_model.Provider)((props) => {
|
|
|
91
101
|
form,
|
|
92
102
|
layout: "vertical",
|
|
93
103
|
onValuesChange: (cur, values) => {
|
|
94
|
-
var
|
|
104
|
+
var _a2;
|
|
95
105
|
let _values = { ...values };
|
|
96
106
|
const currentKey = Object.keys(cur)[0];
|
|
97
107
|
if (currentKey !== "pagination") {
|
|
@@ -100,7 +110,7 @@ var GridView = (0, import_model.Provider)((props) => {
|
|
|
100
110
|
page: 1
|
|
101
111
|
};
|
|
102
112
|
} else {
|
|
103
|
-
if ((
|
|
113
|
+
if ((_a2 = other == null ? void 0 : other.pagination) == null ? void 0 : _a2.localPagination) {
|
|
104
114
|
return;
|
|
105
115
|
}
|
|
106
116
|
}
|
|
@@ -89,6 +89,7 @@ var defaultState = {
|
|
|
89
89
|
currentCell: null,
|
|
90
90
|
quickFilter: [],
|
|
91
91
|
otherFilter: [],
|
|
92
|
+
utils: {},
|
|
92
93
|
setting: {
|
|
93
94
|
field: {
|
|
94
95
|
edit: 0
|
|
@@ -117,6 +118,9 @@ var { Provider, Context } = (0, import_miniRedux.default)({
|
|
|
117
118
|
setQuickFilter(state, payload) {
|
|
118
119
|
return { ...state, quickFilter: payload };
|
|
119
120
|
},
|
|
121
|
+
setUtils(state, payload) {
|
|
122
|
+
return { ...state, utils: payload };
|
|
123
|
+
},
|
|
120
124
|
syncStorage(state, payload) {
|
|
121
125
|
return { ...state };
|
|
122
126
|
},
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import './index.less';
|
|
3
|
+
declare type Value = {
|
|
4
|
+
en: string;
|
|
5
|
+
"zh-CN": string;
|
|
6
|
+
"zh-HK": string;
|
|
7
|
+
};
|
|
8
|
+
interface TranslationProps {
|
|
9
|
+
value: Value;
|
|
10
|
+
onChange: (value: Value) => void;
|
|
11
|
+
}
|
|
12
|
+
declare const Translation: React.FC<TranslationProps>;
|
|
13
|
+
export default Translation;
|