cnhis-design-vue 3.3.3-beta.42 → 3.3.3-beta.45

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.
@@ -8,6 +8,9 @@ import { InjectionInfoHeaderFormRef } from '../../constants/index.js';
8
8
  import HiddenContent from './HiddenContent.vue.js';
9
9
  import InfoEllipsis from './InfoEllipsis.vue.js';
10
10
  import script from '../../../../../shared/components/SlotRender/SlotRender.js';
11
+ import { promiseTimeout } from '@vueuse/shared';
12
+ import { findAncestor } from '../../../../../shared/utils/index.js';
13
+ import { castArray } from 'lodash-es';
11
14
  import { useFieldListAdaptor } from '../../../../form-render/src/hooks/useFieldListAdaptor.js';
12
15
  import { createObjSchema } from '../../../../form-render/src/utils/schema.js';
13
16
 
@@ -73,48 +76,63 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
73
76
  } = useFieldListAdaptor(collector);
74
77
  const formModel = useForm();
75
78
  const schema = computed(() => {
76
- var _a, _b, _c, _d;
79
+ var _a, _b, _c, _d, _e;
77
80
  const field = props.infoItem.formField;
78
81
  if (!field)
79
82
  return {};
83
+ const onBlur = (_a = field.componentProps) == null ? void 0 : _a.onBlur;
84
+ const bindOnBlur = async (event) => {
85
+ if (!props.infoItem.edit)
86
+ return;
87
+ await promiseTimeout(50);
88
+ if (findAncestor(document.querySelector(":focus"), (ele) => ele.getAttribute("__infoHeader") === fieldKey))
89
+ return;
90
+ const eventTarget = event.target;
91
+ if (eventTarget && eventTarget.classList.contains("n-base-select-option"))
92
+ return;
93
+ if (!formModel || !formModel.value)
94
+ return;
95
+ try {
96
+ const fieldInstance = formModel.value.query(fieldKey).take();
97
+ await (fieldInstance && isField(fieldInstance) && fieldInstance.validate());
98
+ setEdit(false);
99
+ onBlur == null ? void 0 : onBlur(event);
100
+ } catch (e) {
101
+ }
102
+ };
80
103
  const fieldKey = props.infoItem[props.labelField];
81
104
  const fieldItem = {
82
105
  ...field,
83
- html_type: (_a = field.html_type) != null ? _a : "INPUT",
106
+ html_type: (_b = field.html_type) != null ? _b : "INPUT",
84
107
  val_key: fieldKey,
85
108
  decoratorProps: {
86
109
  showLabel: false,
87
110
  ...field.decoratorProps,
88
111
  style: {
89
112
  marginBottom: "-12px",
90
- ...(_b = field.decoratorProps) == null ? void 0 : _b.style
113
+ ...(_c = field.decoratorProps) == null ? void 0 : _c.style
91
114
  },
92
- async onClickOutside(event) {
93
- if (!props.infoItem.edit)
94
- return;
95
- const eventTarget = event.target;
96
- if (eventTarget && eventTarget.classList.contains("n-base-select-option"))
97
- return;
98
- if (!formModel || !formModel.value)
99
- return;
100
- try {
101
- const fieldInstance = formModel.value.query(fieldKey).take();
102
- await (fieldInstance && isField(fieldInstance) && fieldInstance.validate());
103
- setEdit(false);
104
- } catch (e) {
105
- }
106
- }
115
+ __infoHeader: fieldKey
107
116
  },
108
117
  componentProps: {
109
118
  size: "tiny",
110
119
  clearable: true,
120
+ onBlur: bindOnBlur,
111
121
  ...field.componentProps,
112
122
  style: {
113
- fontWeight: ((_c = props.infoItem) == null ? void 0 : _c.bold) ? 700 : 500,
114
- ...(_d = field.componentProps) == null ? void 0 : _d.style
123
+ fontWeight: ((_d = props.infoItem) == null ? void 0 : _d.bold) ? 700 : 500,
124
+ ...(_e = field.componentProps) == null ? void 0 : _e.style
115
125
  }
116
126
  }
117
127
  };
128
+ if (fieldItem.suffixConfig) {
129
+ castArray(field.suffixConfig).forEach((item) => {
130
+ item.componentProps = {
131
+ ...item.componentProps,
132
+ onBlur: bindOnBlur
133
+ };
134
+ });
135
+ }
118
136
  pauseTracking();
119
137
  fieldItem.default_val = props.infoItem[props.valueField];
120
138
  enableTracking();
@@ -122,10 +140,18 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
122
140
  return createObjSchema(fields);
123
141
  });
124
142
  watch(() => props.width, (width) => {
125
- var _a;
143
+ var _a, _b;
126
144
  if (!width || !props.infoItem.formField)
127
145
  return;
128
- (_a = formRenderRef.value) == null ? void 0 : _a.setFieldState(props.infoItem[props.labelField], (state) => {
146
+ const parentNode = (_a = formRenderRef.value) == null ? void 0 : _a.formModel.query(props.infoItem[props.labelField] + "-~").take();
147
+ if (parentNode) {
148
+ parentNode.componentProps.style = {
149
+ ...parentNode.componentProps.style,
150
+ maxWidth: width + "px"
151
+ };
152
+ return;
153
+ }
154
+ (_b = formRenderRef.value) == null ? void 0 : _b.setFieldState(props.infoItem[props.labelField], (state) => {
129
155
  if (!state.componentProps)
130
156
  return;
131
157
  state.componentProps.style = {
@@ -162,7 +188,10 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
162
188
  return (_ctx, _cache) => {
163
189
  return openBlock(), createElementBlock("section", {
164
190
  onDblclick: _cache[0] || (_cache[0] = ($event) => onItemDblclick(__props.infoItem)),
165
- onClick: _cache[1] || (_cache[1] = ($event) => onItemClick(__props.infoItem))
191
+ onClick: _cache[1] || (_cache[1] = ($event) => onItemClick(__props.infoItem)),
192
+ style: {
193
+ "min-height": "20px"
194
+ }
166
195
  }, [__props.infoItem.slot ? (openBlock(), createBlock(unref(script), {
167
196
  key: 0,
168
197
  renderer: __props.infoItem.slot,
package/es/env.d.ts CHANGED
@@ -1,25 +1,25 @@
1
- /// <reference types="vite/client" />
2
-
3
- interface ImportMetaEnv {
4
- readonly VITE_APP_TYPE: string;
5
- // 更多环境变量...
6
- }
7
-
8
- interface ImportMeta {
9
- readonly env: ImportMetaEnv;
10
- }
11
-
12
- declare module '*.vue' {
13
- // @ts-ignore
14
- import type { App, defineComponent } from 'vue';
15
- // // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
16
- // // const component: DefineComponent<{}, {}, any>
17
- const component: ReturnType<typeof defineComponent> & {
18
- install(app: App): void;
19
- };
20
- // @ts-ignore
21
- export default component;
22
- }
23
-
24
- declare module '*.js';
25
-
1
+ /// <reference types="vite/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly VITE_APP_TYPE: string;
5
+ // 更多环境变量...
6
+ }
7
+
8
+ interface ImportMeta {
9
+ readonly env: ImportMetaEnv;
10
+ }
11
+
12
+ declare module '*.vue' {
13
+ // @ts-ignore
14
+ import type { App, defineComponent } from 'vue';
15
+ // // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
16
+ // // const component: DefineComponent<{}, {}, any>
17
+ const component: ReturnType<typeof defineComponent> & {
18
+ install(app: App): void;
19
+ };
20
+ // @ts-ignore
21
+ export default component;
22
+ }
23
+
24
+ declare module '*.js';
25
+
@@ -1,5 +1,5 @@
1
1
  var name = "@cnhis-design-vue/shared";
2
- var version = "3.3.3-beta.42";
2
+ var version = "3.3.3-beta.45";
3
3
  var main = "index.ts";
4
4
  var peerDependencies = {
5
5
  "naive-ui": "^2.30.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cnhis-design-vue",
3
- "version": "3.3.3-beta.42",
3
+ "version": "3.3.3-beta.45",
4
4
  "license": "ISC",
5
5
  "module": "./es/components/index.js",
6
6
  "main": "./es/components/index.js",
@@ -74,5 +74,5 @@
74
74
  "iOS 7",
75
75
  "last 3 iOS versions"
76
76
  ],
77
- "gitHead": "8e38f2480288b70e5e6fdb233ad1a8541fd792fe"
77
+ "gitHead": "0e34bd7613d179f6970d9ededc7d08273ea24162"
78
78
  }