cnhis-design-vue 3.3.3-beta.75 → 3.3.3-beta.76

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/README.md CHANGED
@@ -1,87 +1,87 @@
1
- # 安装
2
-
3
- ```shell
4
- npm i cnhis-design-vue@[版本号]
5
- # or
6
- yarn add cnhis-design-vue@[版本号] #推荐
7
- ```
8
-
9
- ## 1.全局引入
10
-
11
- ```typescript
12
- // main.ts
13
- import { createApp } from 'vue';
14
- import App from './App.vue';
15
- import 'cnhis-design-vue/es/packages/index.css';
16
- import cui from 'cnhis-design-vue';
17
-
18
- const app = createApp(App);
19
- app.use(cui).mount('#app');
20
- ```
21
-
22
- ## 2. 按需引入
23
-
24
- 组件现在支持了自动按需引入, 但是样式文件需要额外的处理
25
-
26
- ### 2.1 样式处理方式1 (按需引入样式)
27
-
28
- ```shell
29
- # 安装自动导入样式的插件
30
- npm i -d vite-plugin-style-import
31
- ```
32
-
33
- ```typescript
34
- // vite.config.ts
35
- import { defineConfig } from 'vite';
36
- import { createStyleImportPlugin } from 'vite-plugin-style-import';
37
-
38
- export default defineConfig({
39
- plugins: [
40
- // ...otherPlugins
41
- createStyleImportPlugin({
42
- libs: [
43
- {
44
- libraryName: 'cnhis-design-vue',
45
- esModule: true,
46
- ensureStyleFile: true,
47
- resolveStyle: name => {
48
- return `cnhis-design-vue/es/components/${ name.slice(2) }/style/index.css`;
49
- }
50
- }
51
- ]
52
- })
53
- ]
54
- });
55
- ```
56
-
57
- ### 2.2 样式处理方式2 (全局引入样式)
58
-
59
- ```typescript
60
- // main.ts
61
- import 'cnhis-design-vue/es/components/index.css';
62
- ```
63
-
64
- ## 3.FAQ
65
-
66
- ### 3.1 项目打包后样式丢失
67
-
68
- 处理方法, 将 cnhis-design-vue 从 vendor 包中移除 (没有出现此问题则不需要)
69
-
70
- ```typescript
71
- // vite.config.ts
72
- import { defineConfig } from 'vite';
73
-
74
- export default defineConfig({
75
- build: {
76
- rollupOptions: {
77
- // ..otherOptions
78
- output: {
79
- dir: './dist',
80
- manualChunks: {
81
- 'cnhis-vendor': ['cnhis-design-vue']
82
- }
83
- }
84
- }
85
- }
86
- });
87
- ```
1
+ # 安装
2
+
3
+ ```shell
4
+ npm i cnhis-design-vue@[版本号]
5
+ # or
6
+ yarn add cnhis-design-vue@[版本号] #推荐
7
+ ```
8
+
9
+ ## 1.全局引入
10
+
11
+ ```typescript
12
+ // main.ts
13
+ import { createApp } from 'vue';
14
+ import App from './App.vue';
15
+ import 'cnhis-design-vue/es/packages/index.css';
16
+ import cui from 'cnhis-design-vue';
17
+
18
+ const app = createApp(App);
19
+ app.use(cui).mount('#app');
20
+ ```
21
+
22
+ ## 2. 按需引入
23
+
24
+ 组件现在支持了自动按需引入, 但是样式文件需要额外的处理
25
+
26
+ ### 2.1 样式处理方式1 (按需引入样式)
27
+
28
+ ```shell
29
+ # 安装自动导入样式的插件
30
+ npm i -d vite-plugin-style-import
31
+ ```
32
+
33
+ ```typescript
34
+ // vite.config.ts
35
+ import { defineConfig } from 'vite';
36
+ import { createStyleImportPlugin } from 'vite-plugin-style-import';
37
+
38
+ export default defineConfig({
39
+ plugins: [
40
+ // ...otherPlugins
41
+ createStyleImportPlugin({
42
+ libs: [
43
+ {
44
+ libraryName: 'cnhis-design-vue',
45
+ esModule: true,
46
+ ensureStyleFile: true,
47
+ resolveStyle: name => {
48
+ return `cnhis-design-vue/es/components/${ name.slice(2) }/style/index.css`;
49
+ }
50
+ }
51
+ ]
52
+ })
53
+ ]
54
+ });
55
+ ```
56
+
57
+ ### 2.2 样式处理方式2 (全局引入样式)
58
+
59
+ ```typescript
60
+ // main.ts
61
+ import 'cnhis-design-vue/es/components/index.css';
62
+ ```
63
+
64
+ ## 3.FAQ
65
+
66
+ ### 3.1 项目打包后样式丢失
67
+
68
+ 处理方法, 将 cnhis-design-vue 从 vendor 包中移除 (没有出现此问题则不需要)
69
+
70
+ ```typescript
71
+ // vite.config.ts
72
+ import { defineConfig } from 'vite';
73
+
74
+ export default defineConfig({
75
+ build: {
76
+ rollupOptions: {
77
+ // ..otherOptions
78
+ output: {
79
+ dir: './dist',
80
+ manualChunks: {
81
+ 'cnhis-vendor': ['cnhis-design-vue']
82
+ }
83
+ }
84
+ }
85
+ }
86
+ });
87
+ ```
@@ -175,6 +175,9 @@ declare const _default: import("vue").DefineComponent<{
175
175
  modelValue: unknown[];
176
176
  componentData: Record<string, any>;
177
177
  } & {
178
+ /**
179
+ * 改变弹窗大小
180
+ */
178
181
  itemKey?: string | Function | undefined;
179
182
  }>, {
180
183
  move: Function;
@@ -539,9 +539,9 @@ declare const _default: import("vue").DefineComponent<{
539
539
  }>;
540
540
  developMode: boolean;
541
541
  draggable: boolean;
542
- isHighlightRow: boolean;
543
542
  idx: number;
544
543
  isHighlight: boolean;
544
+ isHighlightRow: boolean;
545
545
  isFieldSet: boolean;
546
546
  fieldDescribeMode: "column" | "tooltip";
547
547
  hideExpressionOption: AnyObject[];
@@ -568,9 +568,9 @@ declare const _default: import("vue").DefineComponent<{
568
568
  }>;
569
569
  developMode: boolean;
570
570
  draggable: boolean;
571
- isHighlightRow: boolean;
572
571
  idx: number;
573
572
  isHighlight: boolean;
573
+ isHighlightRow: boolean;
574
574
  isFieldSet: boolean;
575
575
  fieldDescribeMode: "column" | "tooltip";
576
576
  hideExpressionOption: AnyObject[];
@@ -759,9 +759,9 @@ declare const _default: import("vue").DefineComponent<{
759
759
  }>;
760
760
  developMode: boolean;
761
761
  draggable: boolean;
762
- isHighlightRow: boolean;
763
762
  idx: number;
764
763
  isHighlight: boolean;
764
+ isHighlightRow: boolean;
765
765
  isFieldSet: boolean;
766
766
  fieldDescribeMode: "column" | "tooltip";
767
767
  hideExpressionOption: AnyObject[];
@@ -384,9 +384,9 @@ declare const _default: import("vue").DefineComponent<{
384
384
  }>;
385
385
  developMode: boolean;
386
386
  draggable: boolean;
387
- isHighlightRow: boolean;
388
387
  idx: number;
389
388
  isHighlight: boolean;
389
+ isHighlightRow: boolean;
390
390
  isFieldSet: boolean;
391
391
  fieldDescribeMode: "column" | "tooltip";
392
392
  hideExpressionOption: AnyObject[];
@@ -253,7 +253,7 @@ const DATE_CON_LIST = [{
253
253
  text: function() {
254
254
  var _a, _b, _c;
255
255
  try {
256
- return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.334")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.334")) || "\u8FC7\u53BB\u5185";
256
+ return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.672")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.672")) || "\u8FC7\u53BB\u5185";
257
257
  } catch (e) {
258
258
  return "\u8FC7\u53BB\u5185";
259
259
  }
@@ -263,7 +263,7 @@ const DATE_CON_LIST = [{
263
263
  text: function() {
264
264
  var _a, _b, _c;
265
265
  try {
266
- return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.335")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.335")) || "\u672A\u6765\u5185";
266
+ return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.673")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.673")) || "\u672A\u6765\u5185";
267
267
  } catch (e) {
268
268
  return "\u672A\u6765\u5185";
269
269
  }
@@ -273,7 +273,7 @@ const DATE_CON_LIST = [{
273
273
  text: function() {
274
274
  var _a, _b, _c;
275
275
  try {
276
- return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.336")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.336")) || "\u8FC7\u53BB\u7B2C";
276
+ return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.674")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.674")) || "\u8FC7\u53BB\u7B2C";
277
277
  } catch (e) {
278
278
  return "\u8FC7\u53BB\u7B2C";
279
279
  }
@@ -283,7 +283,7 @@ const DATE_CON_LIST = [{
283
283
  text: function() {
284
284
  var _a, _b, _c;
285
285
  try {
286
- return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.337")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.337")) || "\u672A\u6765\u7B2C";
286
+ return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.675")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.675")) || "\u672A\u6765\u7B2C";
287
287
  } catch (e) {
288
288
  return "\u672A\u6765\u7B2C";
289
289
  }
@@ -603,7 +603,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
603
603
  }, {
604
604
  default: withCtx(() => [!unref(isAudioOrVideoMessage)(item.content) ? (openBlock(), createElementBlock(Fragment, {
605
605
  key: 0
606
- }, [createCommentVNode(' <n-button\n quaternary\n size="tiny"\n @click="(event: MouseEvent) => handleSelectLabel(event, item.id)"\n >\n <template #icon>\n <n-icon size="17" :component="HappyOutline" />\n </template>\n </n-button> '), createVNode(unref(NButton), {
606
+ }, [createCommentVNode(' <n-button\r\n quaternary\r\n size="tiny"\r\n @click="(event: MouseEvent) => handleSelectLabel(event, item.id)"\r\n >\r\n <template #icon>\r\n <n-icon size="17" :component="HappyOutline" />\r\n </template>\r\n </n-button> '), createVNode(unref(NButton), {
607
607
  quaternary: "",
608
608
  size: "tiny",
609
609
  onClick: () => setReferenceMsg(item)
@@ -225,7 +225,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
225
225
  round: "",
226
226
  size: 100,
227
227
  onClickCapture: _cache[0] || (_cache[0] = ($event) => showLargeAvatar.value = true)
228
- }, null, 8, ["src"]), createCommentVNode(' <n-upload abstract accept="image/*" @change="onChange">\n <n-upload-trigger #="{ handleClick }" abstract>\n <n-button\n circle\n secondary\n class="edit-avatar"\n v-show="userDetail.id === state.userInfo.id"\n @click="handleClick"\n >\n <template #icon>\n <n-icon size="16" color="#666666" :component="Camera" />\n </template>\n </n-button>\n </n-upload-trigger>\n </n-upload> '), createElementVNode("div", _hoisted_4, [createElementVNode("h4", null, [createElementVNode("label", _hoisted_5, toDisplayString(userDetail.name), 1), withDirectives(createElementVNode("label", {
228
+ }, null, 8, ["src"]), createCommentVNode(' <n-upload abstract accept="image/*" @change="onChange">\r\n <n-upload-trigger #="{ handleClick }" abstract>\r\n <n-button\r\n circle\r\n secondary\r\n class="edit-avatar"\r\n v-show="userDetail.id === state.userInfo.id"\r\n @click="handleClick"\r\n >\r\n <template #icon>\r\n <n-icon size="16" color="#666666" :component="Camera" />\r\n </template>\r\n </n-button>\r\n </n-upload-trigger>\r\n </n-upload> '), createElementVNode("div", _hoisted_4, [createElementVNode("h4", null, [createElementVNode("label", _hoisted_5, toDisplayString(userDetail.name), 1), withDirectives(createElementVNode("label", {
229
229
  class: normalizeClass(["iho-chatRole", unref(isDoctorRole)(userDetail.roleInfo) ? "isDoctor" : ""])
230
230
  }, toDisplayString(unref(getRoleName)(userDetail.roleInfo)), 3), [[vShow, unref(getRoleName)(userDetail.roleInfo)]])]), createElementVNode("p", null, toDisplayString(userDetail.orgName), 1)]), createVNode(unref(NButton), {
231
231
  strong: "",
@@ -82,27 +82,59 @@ declare const _default: import("vue").DefineComponent<{
82
82
  type: PropType<string | false | HTMLElement>;
83
83
  default: string;
84
84
  };
85
+ shortcuts: {
86
+ type: PropType<string[]>;
87
+ default: () => never[];
88
+ };
85
89
  }, {
86
90
  attrs: {
87
91
  [x: string]: unknown;
88
92
  };
93
+ emit: (event: "update:formatted-value" | "update:show", ...args: any[]) => void;
89
94
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
90
95
  to: {
91
96
  type: PropType<string | false | HTMLElement>;
92
97
  default: string;
93
98
  };
94
- }>> & {}>>;
95
- timePickerRef: import("vue").Ref<AnyObject | null>;
99
+ shortcuts: {
100
+ type: PropType<string[]>;
101
+ default: () => never[];
102
+ };
103
+ }>> & {
104
+ "onUpdate:formatted-value"?: ((...args: any[]) => any) | undefined;
105
+ "onUpdate:show"?: ((...args: any[]) => any) | undefined;
106
+ }>>;
107
+ timePickerRef: import("vue").Ref<AnyObject | null | undefined>;
108
+ isTimePickerOpen: import("vue").Ref<boolean>;
109
+ panelContainer: import("vue").Ref<HTMLElement | null | undefined>;
110
+ timePickerAttrs: import("vue").ComputedRef<{
111
+ [x: string]: unknown;
112
+ }>;
96
113
  formatRef: import("vue").ComputedRef<string>;
114
+ handleFormattedTimeUpdate: (value: string) => void;
115
+ handleShortcutClick: (shortcut: string) => void;
116
+ isDisabled: (value: string) => any;
117
+ onUpdateShow: (show: boolean) => void;
97
118
  focus: () => any;
98
119
  blur: () => any;
99
120
  NTimePicker: any;
100
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
121
+ NScrollbar: any;
122
+ NButton: any;
123
+ NSpace: any;
124
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:formatted-value" | "update:show")[], "update:formatted-value" | "update:show", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
101
125
  to: {
102
126
  type: PropType<string | false | HTMLElement>;
103
127
  default: string;
104
128
  };
105
- }>>, {
129
+ shortcuts: {
130
+ type: PropType<string[]>;
131
+ default: () => never[];
132
+ };
133
+ }>> & {
134
+ "onUpdate:formatted-value"?: ((...args: any[]) => any) | undefined;
135
+ "onUpdate:show"?: ((...args: any[]) => any) | undefined;
136
+ }, {
137
+ shortcuts: string[];
106
138
  to: string | false | HTMLElement;
107
139
  }>>;
108
140
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "update:formattedValue")[], "click" | "update:formattedValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
@@ -52,7 +52,7 @@ const dateConditionOptions = [
52
52
  label: function() {
53
53
  var _a, _b, _c;
54
54
  try {
55
- return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.334")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.334")) || "\u8FC7\u53BB\u5185";
55
+ return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.672")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.672")) || "\u8FC7\u53BB\u5185";
56
56
  } catch (e) {
57
57
  return "\u8FC7\u53BB\u5185";
58
58
  }
@@ -63,7 +63,7 @@ const dateConditionOptions = [
63
63
  label: function() {
64
64
  var _a, _b, _c;
65
65
  try {
66
- return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.335")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.335")) || "\u672A\u6765\u5185";
66
+ return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.673")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.673")) || "\u672A\u6765\u5185";
67
67
  } catch (e) {
68
68
  return "\u672A\u6765\u5185";
69
69
  }
@@ -74,7 +74,7 @@ const dateConditionOptions = [
74
74
  label: function() {
75
75
  var _a, _b, _c;
76
76
  try {
77
- return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.336")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.336")) || "\u8FC7\u53BB\u7B2C";
77
+ return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.674")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.674")) || "\u8FC7\u53BB\u7B2C";
78
78
  } catch (e) {
79
79
  return "\u8FC7\u53BB\u7B2C";
80
80
  }
@@ -85,7 +85,7 @@ const dateConditionOptions = [
85
85
  label: function() {
86
86
  var _a, _b, _c;
87
87
  try {
88
- return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.337")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.337")) || "\u672A\u6765\u7B2C";
88
+ return ((_a = window.getLanguageByCode) == null ? void 0 : _a.call(window, "10010.1.675")) || ((_c = (_b = window.top) == null ? void 0 : _b.getLanguageByCode) == null ? void 0 : _c.call(_b, "10010.1.675")) || "\u672A\u6765\u7B2C";
89
89
  } catch (e) {
90
90
  return "\u672A\u6765\u7B2C";
91
91
  }
@@ -4,27 +4,59 @@ declare const TimePicker: SFCWithInstall<import("vue").DefineComponent<{
4
4
  type: import("vue").PropType<string | false | HTMLElement>;
5
5
  default: string;
6
6
  };
7
+ shortcuts: {
8
+ type: import("vue").PropType<string[]>;
9
+ default: () => never[];
10
+ };
7
11
  }, {
8
12
  attrs: {
9
13
  [x: string]: unknown;
10
14
  };
15
+ emit: (event: "update:formatted-value" | "update:show", ...args: any[]) => void;
11
16
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
12
17
  to: {
13
18
  type: import("vue").PropType<string | false | HTMLElement>;
14
19
  default: string;
15
20
  };
16
- }>> & {}>>;
17
- timePickerRef: import("vue").Ref<import("../../shared/types").AnyObject | null>;
21
+ shortcuts: {
22
+ type: import("vue").PropType<string[]>;
23
+ default: () => never[];
24
+ };
25
+ }>> & {
26
+ "onUpdate:formatted-value"?: ((...args: any[]) => any) | undefined;
27
+ "onUpdate:show"?: ((...args: any[]) => any) | undefined;
28
+ }>>;
29
+ timePickerRef: import("vue").Ref<import("../../shared/types").AnyObject | null | undefined>;
30
+ isTimePickerOpen: import("vue").Ref<boolean>;
31
+ panelContainer: import("vue").Ref<HTMLElement | null | undefined>;
32
+ timePickerAttrs: import("vue").ComputedRef<{
33
+ [x: string]: unknown;
34
+ }>;
18
35
  formatRef: import("vue").ComputedRef<string>;
36
+ handleFormattedTimeUpdate: (value: string) => void;
37
+ handleShortcutClick: (shortcut: string) => void;
38
+ isDisabled: (value: string) => any;
39
+ onUpdateShow: (show: boolean) => void;
19
40
  focus: () => any;
20
41
  blur: () => any;
21
42
  NTimePicker: any;
22
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
43
+ NScrollbar: any;
44
+ NButton: any;
45
+ NSpace: any;
46
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:formatted-value" | "update:show")[], "update:formatted-value" | "update:show", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
23
47
  to: {
24
48
  type: import("vue").PropType<string | false | HTMLElement>;
25
49
  default: string;
26
50
  };
27
- }>>, {
51
+ shortcuts: {
52
+ type: import("vue").PropType<string[]>;
53
+ default: () => never[];
54
+ };
55
+ }>> & {
56
+ "onUpdate:formatted-value"?: ((...args: any[]) => any) | undefined;
57
+ "onUpdate:show"?: ((...args: any[]) => any) | undefined;
58
+ }, {
59
+ shortcuts: string[];
28
60
  to: string | false | HTMLElement;
29
61
  }>>;
30
62
  export default TimePicker;
@@ -5,27 +5,59 @@ declare const _default: import("vue").DefineComponent<{
5
5
  type: PropType<string | false | HTMLElement>;
6
6
  default: string;
7
7
  };
8
+ shortcuts: {
9
+ type: PropType<string[]>;
10
+ default: () => never[];
11
+ };
8
12
  }, {
9
13
  attrs: {
10
14
  [x: string]: unknown;
11
15
  };
16
+ emit: (event: "update:formatted-value" | "update:show", ...args: any[]) => void;
12
17
  props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
13
18
  to: {
14
19
  type: PropType<string | false | HTMLElement>;
15
20
  default: string;
16
21
  };
17
- }>> & {}>>;
18
- timePickerRef: import("vue").Ref<AnyObject | null>;
22
+ shortcuts: {
23
+ type: PropType<string[]>;
24
+ default: () => never[];
25
+ };
26
+ }>> & {
27
+ "onUpdate:formatted-value"?: ((...args: any[]) => any) | undefined;
28
+ "onUpdate:show"?: ((...args: any[]) => any) | undefined;
29
+ }>>;
30
+ timePickerRef: import("vue").Ref<AnyObject | null | undefined>;
31
+ isTimePickerOpen: import("vue").Ref<boolean>;
32
+ panelContainer: import("vue").Ref<HTMLElement | null | undefined>;
33
+ timePickerAttrs: import("vue").ComputedRef<{
34
+ [x: string]: unknown;
35
+ }>;
19
36
  formatRef: import("vue").ComputedRef<string>;
37
+ handleFormattedTimeUpdate: (value: string) => void;
38
+ handleShortcutClick: (shortcut: string) => void;
39
+ isDisabled: (value: string) => any;
40
+ onUpdateShow: (show: boolean) => void;
20
41
  focus: () => any;
21
42
  blur: () => any;
22
43
  NTimePicker: any;
23
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
44
+ NScrollbar: any;
45
+ NButton: any;
46
+ NSpace: any;
47
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:formatted-value" | "update:show")[], "update:formatted-value" | "update:show", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
24
48
  to: {
25
49
  type: PropType<string | false | HTMLElement>;
26
50
  default: string;
27
51
  };
28
- }>>, {
52
+ shortcuts: {
53
+ type: PropType<string[]>;
54
+ default: () => never[];
55
+ };
56
+ }>> & {
57
+ "onUpdate:formatted-value"?: ((...args: any[]) => any) | undefined;
58
+ "onUpdate:show"?: ((...args: any[]) => any) | undefined;
59
+ }, {
60
+ shortcuts: string[];
29
61
  to: string | false | HTMLElement;
30
62
  }>;
31
63
  export default _default;
@@ -1,13 +1,14 @@
1
- import { defineComponent, useAttrs, ref, computed, openBlock, createBlock, unref, createSlots, renderList, withCtx, renderSlot } from 'vue';
2
- import { NTimePicker } from 'naive-ui';
1
+ import { defineComponent, useAttrs, ref, computed, openBlock, createElementBlock, createVNode, unref, mergeProps, createSlots, renderList, withCtx, renderSlot, normalizeProps, guardReactiveProps, createCommentVNode, createBlock, Teleport, Fragment, createTextVNode, toDisplayString, nextTick } from 'vue';
2
+ import { NTimePicker, NScrollbar, NSpace, NButton } from 'naive-ui';
3
3
  import '../../../shared/utils/index.js';
4
4
  import { useDateTime } from '../../../shared/hooks/useDateTime.js';
5
- import 'lodash-es';
5
+ import { isFunction } from 'lodash-es';
6
6
  import '@vue/shared';
7
7
  import '@vueuse/shared';
8
8
  import '../../../shared/hooks/selectHooks/useSearchContent.js';
9
9
  import '@vicons/ionicons5';
10
10
  import '../../../shared/hooks/useScrollLoading.js';
11
+ import { parse, isValid, getHours, getMinutes, getSeconds } from 'date-fns';
11
12
 
12
13
  var _sfc_main = /* @__PURE__ */ defineComponent({
13
14
  __name: "TimePicker",
@@ -15,24 +16,78 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
15
16
  to: {
16
17
  type: [Object, String, Boolean],
17
18
  default: "body"
19
+ },
20
+ shortcuts: {
21
+ type: Array,
22
+ default: () => []
18
23
  }
19
24
  },
25
+ emits: ["update:formatted-value", "update:show"],
20
26
  setup(__props, {
21
- expose
27
+ expose,
28
+ emit
22
29
  }) {
30
+ const props = __props;
23
31
  const attrs = useAttrs();
24
- const timePickerRef = ref(null);
32
+ const timePickerRef = ref();
33
+ const isTimePickerOpen = ref(false);
34
+ const panelContainer = ref();
35
+ const timePickerAttrs = computed(() => {
36
+ const {
37
+ shortcuts,
38
+ ...restAttrs
39
+ } = attrs;
40
+ return restAttrs;
41
+ });
25
42
  const formatRef = computed(() => {
26
43
  if (Reflect.get(attrs, "format"))
27
44
  return attrs["format"];
28
45
  return "HH:mm:ss";
29
46
  });
47
+ const handleFormattedTimeUpdate = (value) => {
48
+ emit("update:formatted-value", value);
49
+ };
50
+ const handleShortcutClick = (shortcut) => {
51
+ const timeValue = shortcut;
52
+ emit("update:formatted-value", timeValue);
53
+ emit("update:show", false);
54
+ isTimePickerOpen.value = false;
55
+ };
56
+ const isDisabled = (value) => {
57
+ const parsedTime = parse(value, formatRef.value, new Date());
58
+ if (!isValid(parsedTime))
59
+ return false;
60
+ const hours = getHours(parsedTime);
61
+ const minutes = getMinutes(parsedTime);
62
+ const seconds = getSeconds(parsedTime);
63
+ const attrs2 = timePickerAttrs.value;
64
+ const isHourDisabled = isFunction(attrs2.isHourDisabled) ? attrs2.isHourDisabled(hours) : false;
65
+ const isMinuteDisabled = isFunction(attrs2.isMinuteDisabled) ? attrs2.isMinuteDisabled(minutes, hours) : false;
66
+ const isSecondDisabled = isFunction(attrs2.isSecondDisabled) ? attrs2.isSecondDisabled(seconds, minutes, hours) : false;
67
+ return isHourDisabled || isMinuteDisabled || isSecondDisabled;
68
+ };
69
+ const onUpdateShow = (show) => {
70
+ emit("update:show", show);
71
+ isTimePickerOpen.value = show;
72
+ if (show && props.shortcuts && props.shortcuts.length > 0) {
73
+ nextTick(() => {
74
+ var _a, _b;
75
+ const panel = (_b = (_a = timePickerRef.value) == null ? void 0 : _a.panelInstRef) == null ? void 0 : _b.$el;
76
+ const teleportTo = panel == null ? void 0 : panel.querySelector(".n-time-picker-cols");
77
+ if (teleportTo) {
78
+ panelContainer.value = teleportTo;
79
+ }
80
+ });
81
+ } else {
82
+ panelContainer.value = null;
83
+ }
84
+ };
30
85
  const {
31
86
  focus,
32
87
  blur
33
88
  } = useDateTime(timePickerRef, {
34
89
  formatRef,
35
- attrs
90
+ attrs: timePickerAttrs
36
91
  });
37
92
  expose({
38
93
  $timePicker: timePickerRef,
@@ -40,18 +95,48 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
40
95
  blur
41
96
  });
42
97
  return (_ctx, _cache) => {
43
- return openBlock(), createBlock(unref(NTimePicker), {
98
+ return openBlock(), createElementBlock("div", null, [createVNode(unref(NTimePicker), mergeProps({
44
99
  ref_key: "timePickerRef",
45
- ref: timePickerRef,
46
- to: __props.to
47
- }, createSlots({
100
+ ref: timePickerRef
101
+ }, unref(timePickerAttrs), {
102
+ to: __props.to,
103
+ "onUpdate:formattedValue": handleFormattedTimeUpdate,
104
+ "onUpdate:show": onUpdateShow
105
+ }), createSlots({
48
106
  _: 2
49
- }, [renderList(_ctx.$slots, (v, k) => {
107
+ }, [renderList(_ctx.$slots, (_, k) => {
50
108
  return {
51
109
  name: k,
52
- fn: withCtx(() => [renderSlot(_ctx.$slots, k)])
110
+ fn: withCtx((slotProps) => [renderSlot(_ctx.$slots, k, normalizeProps(guardReactiveProps(slotProps || {})))])
53
111
  };
54
- })]), 1032, ["to"]);
112
+ })]), 1040, ["to"]), createCommentVNode(" \u5FEB\u6377\u9009\u9879 - \u901A\u8FC7CSS\u63D2\u5165\u5230\u9762\u677F\u5185\u90E8 "), __props.shortcuts && __props.shortcuts.length > 0 && isTimePickerOpen.value && panelContainer.value ? (openBlock(), createBlock(Teleport, {
113
+ key: 0,
114
+ to: panelContainer.value
115
+ }, [createVNode(unref(NScrollbar), {
116
+ style: {
117
+ "max-height": "255px",
118
+ "margin": "8px"
119
+ }
120
+ }, {
121
+ default: withCtx(() => [createVNode(unref(NSpace), {
122
+ vertical: "",
123
+ wrap: false
124
+ }, {
125
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.shortcuts, (shortcut) => {
126
+ return openBlock(), createBlock(unref(NButton), {
127
+ size: "tiny",
128
+ disabled: isDisabled(shortcut),
129
+ key: shortcut,
130
+ onClick: ($event) => handleShortcutClick(shortcut)
131
+ }, {
132
+ default: withCtx(() => [createTextVNode(toDisplayString(shortcut), 1)]),
133
+ _: 2
134
+ }, 1032, ["disabled", "onClick"]);
135
+ }), 128))]),
136
+ _: 1
137
+ })]),
138
+ _: 1
139
+ })], 8, ["to"])) : createCommentVNode("v-if", true)]);
55
140
  };
56
141
  }
57
142
  });
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,7 +1,7 @@
1
1
  import { Ref, ComputedRef } from 'vue';
2
2
  import { AnyObject, AnyFn } from '../../shared/types';
3
3
  export declare function handleInputEvent(target: HTMLInputElement, value?: string): void;
4
- export declare function useDateTime(datePickerRef: Ref<AnyObject | null>, { formatRef, attrs, emit, allowedInvalidValue, isPanel }: {
4
+ export declare function useDateTime(datePickerRef: Ref<AnyObject | null | undefined>, { formatRef, attrs, emit, allowedInvalidValue, isPanel }: {
5
5
  formatRef: ComputedRef<string | [string, string]>;
6
6
  attrs: AnyObject;
7
7
  allowedInvalidValue?: string;
@@ -1,5 +1,5 @@
1
1
  var name = "@cnhis-design-vue/shared";
2
- var version = "3.3.3-beta.75";
2
+ var version = "3.3.3-beta.76";
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.75",
3
+ "version": "3.3.3-beta.76",
4
4
  "license": "ISC",
5
5
  "module": "./es/components/index.js",
6
6
  "main": "./es/components/index.js",
@@ -73,5 +73,5 @@
73
73
  "iOS 7",
74
74
  "last 3 iOS versions"
75
75
  ],
76
- "gitHead": "585f553ca4e29cb4d932e6a3a7b684f06ad8c106"
76
+ "gitHead": "c5ca3c0973aa44c9235ce5d60662317954130ec9"
77
77
  }