@tachybase/client 1.6.5 → 1.6.7

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.
@@ -48,7 +48,7 @@ function filterByCleanedFields(mergeFilter) {
48
48
  '$or'
49
49
  ].includes(p));
50
50
  const fieldPath = filteredParts.join('.');
51
- const uniqueKey = "".concat(fieldPath, "|").concat(JSON.stringify(value));
51
+ const uniqueKey = "".concat(fieldPath);
52
52
  if (!seen.has(uniqueKey)) {
53
53
  seen.add(uniqueKey);
54
54
  result[key] = value;
@@ -1,5 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useContext } from "react";
2
+ import { useContext, useState } from "react";
3
+ import { observer } from "@tachybase/schema";
4
+ import { DndContext, DragOverlay, MouseSensor, useDraggable, useDroppable, useSensor, useSensors } from "@dnd-kit/core";
3
5
  import { css } from "@emotion/css";
4
6
  import { Button } from "antd";
5
7
  import classnames from "classnames";
@@ -57,17 +59,134 @@ const TabHeader = ()=>{
57
59
  const { styles } = useStyles();
58
60
  return /*#__PURE__*/ jsx("div", {
59
61
  className: styles.tabWrapper,
60
- children: items.map((item)=>/*#__PURE__*/ jsx(Tag, {
61
- active: item.key === targetKey,
62
- onClick: ()=>{
63
- navigate(item.key);
64
- },
65
- onClose: (e)=>{
66
- e.stopPropagation();
67
- setItems((items)=>items.filter((i)=>i.key !== item.key));
68
- },
69
- children: item.label
70
- }, item.key))
62
+ children: /*#__PURE__*/ jsx(DndProvider, {
63
+ targetKey: targetKey,
64
+ navigate: navigate,
65
+ setItems: setItems,
66
+ items: items,
67
+ children: items.map((item)=>/*#__PURE__*/ jsx(TabTitle, {
68
+ item: item,
69
+ targetKey: targetKey,
70
+ navigate: navigate,
71
+ setItems: setItems
72
+ }))
73
+ })
71
74
  });
72
75
  };
76
+ const TabTag = (props)=>{
77
+ const { item, targetKey, navigate, setItems } = props;
78
+ return /*#__PURE__*/ jsx(Tag, {
79
+ active: item.key === targetKey,
80
+ onClick: ()=>{
81
+ navigate(item.key);
82
+ },
83
+ onClose: (e)=>{
84
+ e.stopPropagation();
85
+ setItems((items)=>items.filter((i)=>i.key !== item.key));
86
+ },
87
+ children: item.label
88
+ }, item.key);
89
+ };
90
+ const DndProvider = observer((props)=>{
91
+ const { targetKey, navigate, setItems, items } = props;
92
+ const [activeTab, setActiveId] = useState(null);
93
+ const onDragEnd = async (props)=>{
94
+ const { active, over } = props;
95
+ setTimeout(()=>{
96
+ setActiveId(null);
97
+ });
98
+ if (over && over.id !== active.id) {
99
+ const newItems = [
100
+ ...items
101
+ ];
102
+ const activeIndex = newItems.findIndex((item)=>item.key === active.id);
103
+ const overIndex = newItems.findIndex((item)=>item.key === over.id);
104
+ const item = newItems.splice(activeIndex, 1);
105
+ newItems.splice(overIndex, 0, ...item);
106
+ setItems(newItems);
107
+ }
108
+ };
109
+ function onDragStart(event) {
110
+ var _event_active;
111
+ setActiveId(null == (_event_active = event.active) ? void 0 : _event_active.data.current);
112
+ }
113
+ const mouseSensor = useSensor(MouseSensor, {
114
+ activationConstraint: {
115
+ distance: 10
116
+ }
117
+ });
118
+ const sensors = useSensors(mouseSensor);
119
+ return /*#__PURE__*/ jsxs(DndContext, {
120
+ sensors: sensors,
121
+ onDragEnd: onDragEnd,
122
+ onDragStart: onDragStart,
123
+ children: [
124
+ props.children,
125
+ /*#__PURE__*/ jsx(DragOverlay, {
126
+ children: activeTab ? /*#__PURE__*/ jsx("span", {
127
+ style: {
128
+ whiteSpace: 'nowrap'
129
+ },
130
+ children: /*#__PURE__*/ jsx(TabTag, {
131
+ item: activeTab,
132
+ targetKey: targetKey,
133
+ navigate: navigate,
134
+ setItems: setItems
135
+ })
136
+ }) : null
137
+ })
138
+ ]
139
+ });
140
+ }, {
141
+ displayName: 'DndProvider'
142
+ });
143
+ const Draggable = (props)=>{
144
+ const { attributes, listeners, setNodeRef } = useDraggable({
145
+ id: props.id,
146
+ data: props.data
147
+ });
148
+ return /*#__PURE__*/ jsx("div", {
149
+ ref: setNodeRef,
150
+ ...listeners,
151
+ ...attributes,
152
+ children: /*#__PURE__*/ jsx("div", {
153
+ children: props.children
154
+ })
155
+ });
156
+ };
157
+ function Droppable(props) {
158
+ const { isOver, setNodeRef } = useDroppable({
159
+ id: props.id,
160
+ data: props.data
161
+ });
162
+ const style = isOver ? {
163
+ color: 'green'
164
+ } : void 0;
165
+ return /*#__PURE__*/ jsx("div", {
166
+ ref: setNodeRef,
167
+ style: style,
168
+ children: props.children
169
+ });
170
+ }
171
+ const TabTitle = observer((props)=>{
172
+ const { item, targetKey, navigate, setItems } = props;
173
+ return /*#__PURE__*/ jsx(Droppable, {
174
+ id: item.key,
175
+ data: item,
176
+ children: /*#__PURE__*/ jsx("div", {
177
+ children: /*#__PURE__*/ jsx(Draggable, {
178
+ id: item.key,
179
+ data: item,
180
+ children: /*#__PURE__*/ jsx(TabTag, {
181
+ item: item,
182
+ targetKey: targetKey,
183
+ navigate: navigate,
184
+ setItems: setItems
185
+ })
186
+ })
187
+ })
188
+ });
189
+ }, {
190
+ displayName: 'TabTitle'
191
+ });
73
192
  export { TabHeader, Tag };
@@ -129,6 +129,26 @@ class NumberFieldInterface extends CollectionFieldInterface {
129
129
  {
130
130
  value: '0.00001',
131
131
  label: '1.00000'
132
+ },
133
+ {
134
+ value: '0.000001',
135
+ label: '1.000000'
136
+ },
137
+ {
138
+ value: '0.0000001',
139
+ label: '1.0000000'
140
+ },
141
+ {
142
+ value: '0.00000001',
143
+ label: '1.00000000'
144
+ },
145
+ {
146
+ value: '0.000000001',
147
+ label: '1.000000000'
148
+ },
149
+ {
150
+ value: '0.0000000001',
151
+ label: '1.0000000000'
132
152
  }
133
153
  ]
134
154
  },
@@ -96,6 +96,26 @@ class PercentFieldInterface extends CollectionFieldInterface {
96
96
  {
97
97
  value: '0.00001',
98
98
  label: '1.00000%'
99
+ },
100
+ {
101
+ value: '0.000001',
102
+ label: '1.000000%'
103
+ },
104
+ {
105
+ value: '0.0000001',
106
+ label: '1.0000000%'
107
+ },
108
+ {
109
+ value: '0.00000001',
110
+ label: '1.00000000%'
111
+ },
112
+ {
113
+ value: '0.000000001',
114
+ label: '1.000000000%'
115
+ },
116
+ {
117
+ value: '0.0000000001',
118
+ label: '1.0000000000%'
99
119
  }
100
120
  ]
101
121
  },
@@ -7,7 +7,10 @@ import { round } from "mathjs";
7
7
  function countDecimalPlaces(value) {
8
8
  const number = Number(value);
9
9
  if (!Number.isFinite(number)) return 0;
10
- const decimalPart = String(number).split('.')[1];
10
+ const decimalPart = number.toLocaleString('en-US', {
11
+ useGrouping: false,
12
+ maximumSignificantDigits: 10
13
+ }).split('.')[1];
11
14
  return decimalPart ? decimalPart.length : 0;
12
15
  }
13
16
  const separators = {
@@ -130,6 +130,26 @@ const SchemaSettingsNumberFormat = function(props) {
130
130
  {
131
131
  value: '0.00001',
132
132
  label: '1.00000'
133
+ },
134
+ {
135
+ value: '0.000001',
136
+ label: '1.000000'
137
+ },
138
+ {
139
+ value: '0.0000001',
140
+ label: '1.0000000'
141
+ },
142
+ {
143
+ value: '0.00000001',
144
+ label: '1.00000000'
145
+ },
146
+ {
147
+ value: '0.000000001',
148
+ label: '1.000000000'
149
+ },
150
+ {
151
+ value: '0.0000000001',
152
+ label: '1.0000000000'
133
153
  }
134
154
  ]
135
155
  },
@@ -155,7 +175,7 @@ const SchemaSettingsNumberFormat = function(props) {
155
175
  };
156
176
  schema['x-component-props'] = fieldSchema['x-component-props'] || {};
157
177
  fieldSchema['x-component-props'] = {
158
- ...fieldSchema['x-component-props'] || {},
178
+ ...fieldSchema['x-component-props'],
159
179
  ...data
160
180
  };
161
181
  schema['x-component-props'] = fieldSchema['x-component-props'];
@@ -15,7 +15,7 @@ var __webpack_modules__ = {
15
15
  "../../filter-provider/utils": function(module) {
16
16
  module.exports = require("../../filter-provider/utils.js");
17
17
  },
18
- "../../../schema-component": function(module) {
18
+ "../../index": function(module) {
19
19
  module.exports = require("../../index.js");
20
20
  },
21
21
  "../../record-provider": function(module) {
@@ -182,7 +182,7 @@ var __webpack_exports__ = {};
182
182
  var react_i18next__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__("react-i18next");
183
183
  var react_router_dom__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__("react-router-dom");
184
184
  var react_to_print__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__("react-to-print");
185
- var ___WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__("../../../schema-component");
185
+ var ___WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__("../../index");
186
186
  var _api_client__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__("../../api-client");
187
187
  var _built_in_dynamic_page_utils__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__("../../built-in/dynamic-page/utils");
188
188
  var _collection_manager__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__("../../collection-manager");
@@ -361,7 +361,7 @@ var __webpack_exports__ = {};
361
361
  '$or'
362
362
  ].includes(p));
363
363
  const fieldPath = filteredParts.join('.');
364
- const uniqueKey = "".concat(fieldPath, "|").concat(JSON.stringify(value));
364
+ const uniqueKey = "".concat(fieldPath);
365
365
  if (!seen.has(uniqueKey)) {
366
366
  seen.add(uniqueKey);
367
367
  result[key] = value;
@@ -38,6 +38,8 @@ __webpack_require__.d(__webpack_exports__, {
38
38
  });
39
39
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
40
40
  const external_react_namespaceObject = require("react");
41
+ const schema_namespaceObject = require("@tachybase/schema");
42
+ const core_namespaceObject = require("@dnd-kit/core");
41
43
  const css_namespaceObject = require("@emotion/css");
42
44
  const external_antd_namespaceObject = require("antd");
43
45
  const external_classnames_namespaceObject = require("classnames");
@@ -96,19 +98,136 @@ const TabHeader = ()=>{
96
98
  const { styles } = (0, external_TabHeader_style_js_namespaceObject.useStyles)();
97
99
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
98
100
  className: styles.tabWrapper,
99
- children: items.map((item)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Tag, {
100
- active: item.key === targetKey,
101
- onClick: ()=>{
102
- navigate(item.key);
103
- },
104
- onClose: (e)=>{
105
- e.stopPropagation();
106
- setItems((items)=>items.filter((i)=>i.key !== item.key));
107
- },
108
- children: item.label
109
- }, item.key))
101
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(DndProvider, {
102
+ targetKey: targetKey,
103
+ navigate: navigate,
104
+ setItems: setItems,
105
+ items: items,
106
+ children: items.map((item)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TabTitle, {
107
+ item: item,
108
+ targetKey: targetKey,
109
+ navigate: navigate,
110
+ setItems: setItems
111
+ }))
112
+ })
110
113
  });
111
114
  };
115
+ const TabTag = (props)=>{
116
+ const { item, targetKey, navigate, setItems } = props;
117
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Tag, {
118
+ active: item.key === targetKey,
119
+ onClick: ()=>{
120
+ navigate(item.key);
121
+ },
122
+ onClose: (e)=>{
123
+ e.stopPropagation();
124
+ setItems((items)=>items.filter((i)=>i.key !== item.key));
125
+ },
126
+ children: item.label
127
+ }, item.key);
128
+ };
129
+ const DndProvider = (0, schema_namespaceObject.observer)((props)=>{
130
+ const { targetKey, navigate, setItems, items } = props;
131
+ const [activeTab, setActiveId] = (0, external_react_namespaceObject.useState)(null);
132
+ const onDragEnd = async (props)=>{
133
+ const { active, over } = props;
134
+ setTimeout(()=>{
135
+ setActiveId(null);
136
+ });
137
+ if (over && over.id !== active.id) {
138
+ const newItems = [
139
+ ...items
140
+ ];
141
+ const activeIndex = newItems.findIndex((item)=>item.key === active.id);
142
+ const overIndex = newItems.findIndex((item)=>item.key === over.id);
143
+ const item = newItems.splice(activeIndex, 1);
144
+ newItems.splice(overIndex, 0, ...item);
145
+ setItems(newItems);
146
+ }
147
+ };
148
+ function onDragStart(event) {
149
+ var _event_active;
150
+ setActiveId(null == (_event_active = event.active) ? void 0 : _event_active.data.current);
151
+ }
152
+ const mouseSensor = (0, core_namespaceObject.useSensor)(core_namespaceObject.MouseSensor, {
153
+ activationConstraint: {
154
+ distance: 10
155
+ }
156
+ });
157
+ const sensors = (0, core_namespaceObject.useSensors)(mouseSensor);
158
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.DndContext, {
159
+ sensors: sensors,
160
+ onDragEnd: onDragEnd,
161
+ onDragStart: onDragStart,
162
+ children: [
163
+ props.children,
164
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(core_namespaceObject.DragOverlay, {
165
+ children: activeTab ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
166
+ style: {
167
+ whiteSpace: 'nowrap'
168
+ },
169
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TabTag, {
170
+ item: activeTab,
171
+ targetKey: targetKey,
172
+ navigate: navigate,
173
+ setItems: setItems
174
+ })
175
+ }) : null
176
+ })
177
+ ]
178
+ });
179
+ }, {
180
+ displayName: 'DndProvider'
181
+ });
182
+ const Draggable = (props)=>{
183
+ const { attributes, listeners, setNodeRef } = (0, core_namespaceObject.useDraggable)({
184
+ id: props.id,
185
+ data: props.data
186
+ });
187
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
188
+ ref: setNodeRef,
189
+ ...listeners,
190
+ ...attributes,
191
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
192
+ children: props.children
193
+ })
194
+ });
195
+ };
196
+ function Droppable(props) {
197
+ const { isOver, setNodeRef } = (0, core_namespaceObject.useDroppable)({
198
+ id: props.id,
199
+ data: props.data
200
+ });
201
+ const style = isOver ? {
202
+ color: 'green'
203
+ } : void 0;
204
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
205
+ ref: setNodeRef,
206
+ style: style,
207
+ children: props.children
208
+ });
209
+ }
210
+ const TabTitle = (0, schema_namespaceObject.observer)((props)=>{
211
+ const { item, targetKey, navigate, setItems } = props;
212
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Droppable, {
213
+ id: item.key,
214
+ data: item,
215
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
216
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Draggable, {
217
+ id: item.key,
218
+ data: item,
219
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TabTag, {
220
+ item: item,
221
+ targetKey: targetKey,
222
+ navigate: navigate,
223
+ setItems: setItems
224
+ })
225
+ })
226
+ })
227
+ });
228
+ }, {
229
+ displayName: 'TabTitle'
230
+ });
112
231
  exports.TabHeader = __webpack_exports__.TabHeader;
113
232
  exports.Tag = __webpack_exports__.Tag;
114
233
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
@@ -157,6 +157,26 @@ class NumberFieldInterface extends CollectionFieldInterface_js_namespaceObject.C
157
157
  {
158
158
  value: '0.00001',
159
159
  label: '1.00000'
160
+ },
161
+ {
162
+ value: '0.000001',
163
+ label: '1.000000'
164
+ },
165
+ {
166
+ value: '0.0000001',
167
+ label: '1.0000000'
168
+ },
169
+ {
170
+ value: '0.00000001',
171
+ label: '1.00000000'
172
+ },
173
+ {
174
+ value: '0.000000001',
175
+ label: '1.000000000'
176
+ },
177
+ {
178
+ value: '0.0000000001',
179
+ label: '1.0000000000'
160
180
  }
161
181
  ]
162
182
  },
@@ -124,6 +124,26 @@ class PercentFieldInterface extends CollectionFieldInterface_js_namespaceObject.
124
124
  {
125
125
  value: '0.00001',
126
126
  label: '1.00000%'
127
+ },
128
+ {
129
+ value: '0.000001',
130
+ label: '1.000000%'
131
+ },
132
+ {
133
+ value: '0.0000001',
134
+ label: '1.0000000%'
135
+ },
136
+ {
137
+ value: '0.00000001',
138
+ label: '1.00000000%'
139
+ },
140
+ {
141
+ value: '0.000000001',
142
+ label: '1.000000000%'
143
+ },
144
+ {
145
+ value: '0.0000000001',
146
+ label: '1.0000000000%'
127
147
  }
128
148
  ]
129
149
  },
@@ -39,7 +39,10 @@ const external_mathjs_namespaceObject = require("mathjs");
39
39
  function countDecimalPlaces(value) {
40
40
  const number = Number(value);
41
41
  if (!Number.isFinite(number)) return 0;
42
- const decimalPart = String(number).split('.')[1];
42
+ const decimalPart = number.toLocaleString('en-US', {
43
+ useGrouping: false,
44
+ maximumSignificantDigits: 10
45
+ }).split('.')[1];
43
46
  return decimalPart ? decimalPart.length : 0;
44
47
  }
45
48
  const separators = {
@@ -158,6 +158,26 @@ const SchemaSettingsNumberFormat = function(props) {
158
158
  {
159
159
  value: '0.00001',
160
160
  label: '1.00000'
161
+ },
162
+ {
163
+ value: '0.000001',
164
+ label: '1.000000'
165
+ },
166
+ {
167
+ value: '0.0000001',
168
+ label: '1.0000000'
169
+ },
170
+ {
171
+ value: '0.00000001',
172
+ label: '1.00000000'
173
+ },
174
+ {
175
+ value: '0.000000001',
176
+ label: '1.000000000'
177
+ },
178
+ {
179
+ value: '0.0000000001',
180
+ label: '1.0000000000'
161
181
  }
162
182
  ]
163
183
  },
@@ -183,7 +203,7 @@ const SchemaSettingsNumberFormat = function(props) {
183
203
  };
184
204
  schema['x-component-props'] = fieldSchema['x-component-props'] || {};
185
205
  fieldSchema['x-component-props'] = {
186
- ...fieldSchema['x-component-props'] || {},
206
+ ...fieldSchema['x-component-props'],
187
207
  ...data
188
208
  };
189
209
  schema['x-component-props'] = fieldSchema['x-component-props'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachybase/client",
3
- "version": "1.6.5",
3
+ "version": "1.6.7",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.mjs",
@@ -21,8 +21,8 @@
21
21
  "@floating-ui/react": "0.26.28",
22
22
  "@js-preview/excel": "^1.7.14",
23
23
  "@lottiefiles/dotlottie-react": "^0.9.3",
24
- "@tachybase/schema": "1.6.2",
25
- "@tego/client": "1.6.2",
24
+ "@tachybase/schema": "1.6.3",
25
+ "@tego/client": "1.6.3",
26
26
  "ahooks": "^3.9.0",
27
27
  "antd": "5.22.5",
28
28
  "antd-style": "3.7.1",