hy-dispatch-ui-v3 0.2.2 → 0.2.3

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.
Files changed (63) hide show
  1. package/es/components/appConfigProvider/appConfigProvider.vue.mjs +3 -1
  2. package/es/components/appDatePicker/appDatePicker.vue.mjs +57 -3
  3. package/es/components/appDatePicker/index.mjs +2 -1
  4. package/es/components/appForm/cpns/appFormItem.vue.mjs +37 -7
  5. package/es/components/appForm/js/useAppForm.mjs +5 -40
  6. package/es/components/appIcon/appIcon.vue.mjs +5 -1
  7. package/es/components/appSearch/cpns/appSearchItem.vue.mjs +33 -3
  8. package/es/components/appSearch/js/index.mjs +1 -1
  9. package/es/components/appSearch/js/useAppSearch.mjs +9 -39
  10. package/es/components/appTimePicker/appTimePicker.vue.mjs +154 -0
  11. package/es/components/appTimePicker/index.mjs +7 -0
  12. package/es/components/appTimePicker/style/appTimePicker.scss +0 -0
  13. package/es/components/appTree/appTree.vue.mjs +11 -8
  14. package/es/components/appTree/config/tree-config.mjs +33 -0
  15. package/es/components/appTree/js/index.mjs +10 -12
  16. package/es/components/appVideoPlayer/appVideoPlayer.vue.mjs +6 -6
  17. package/es/components/index.mjs +2 -1
  18. package/es/hooks/index.mjs +1 -0
  19. package/es/hooks/useEnsureHyIcon.mjs +12 -0
  20. package/es/hooks/useGlobalConfig.mjs +5 -0
  21. package/es/index.mjs +3 -1
  22. package/es/locale/en.mjs +21 -11
  23. package/es/locale/zh_CN.mjs +21 -11
  24. package/es/static/_sprite.js +33 -0
  25. package/es/static/hy-svg-icons/ai.js +30 -0
  26. package/es/static/hy-svg-icons/batch.js +8 -0
  27. package/es/static/hy-svg-icons.js +10 -10
  28. package/es/static/index.js +2 -2
  29. package/es/static/protocolcheck.js +109 -85
  30. package/es/static/vite-plugin-hy-svg-icons.js +240 -0
  31. package/es/utils/date.mjs +1 -0
  32. package/lib/components/appConfigProvider/appConfigProvider.vue.js +3 -1
  33. package/lib/components/appDatePicker/appDatePicker.vue.js +56 -2
  34. package/lib/components/appDatePicker/index.js +2 -0
  35. package/lib/components/appForm/cpns/appFormItem.vue.js +38 -8
  36. package/lib/components/appForm/js/useAppForm.js +5 -40
  37. package/lib/components/appIcon/appIcon.vue.js +4 -0
  38. package/lib/components/appSearch/cpns/appSearchItem.vue.js +34 -4
  39. package/lib/components/appSearch/js/index.js +1 -1
  40. package/lib/components/appSearch/js/useAppSearch.js +9 -39
  41. package/lib/components/appTimePicker/appTimePicker.vue.js +158 -0
  42. package/lib/components/appTimePicker/index.js +13 -0
  43. package/lib/components/appTimePicker/style/appTimePicker.scss +0 -0
  44. package/lib/components/appTree/appTree.vue.js +10 -7
  45. package/lib/components/appTree/config/tree-config.js +37 -0
  46. package/lib/components/appTree/js/index.js +10 -12
  47. package/lib/components/appVideoPlayer/appVideoPlayer.vue.js +6 -6
  48. package/lib/components/index.js +12 -8
  49. package/lib/hooks/index.js +3 -0
  50. package/lib/hooks/useEnsureHyIcon.js +15 -0
  51. package/lib/hooks/useGlobalConfig.js +5 -0
  52. package/lib/index.js +15 -8
  53. package/lib/locale/en.js +21 -11
  54. package/lib/locale/zh_CN.js +21 -11
  55. package/lib/static/_sprite.js +33 -0
  56. package/lib/static/hy-svg-icons/ai.js +30 -0
  57. package/lib/static/hy-svg-icons/batch.js +8 -0
  58. package/lib/static/hy-svg-icons.js +10 -12
  59. package/lib/static/index.js +2 -5
  60. package/lib/static/protocolcheck.js +109 -87
  61. package/lib/static/vite-plugin-hy-svg-icons.js +240 -0
  62. package/lib/utils/date.js +1 -0
  63. package/package.json +3 -3
@@ -71,7 +71,8 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
71
71
  videoPlayer: {
72
72
  type: Object,
73
73
  required: false
74
- }
74
+ },
75
+ ensureHyIcon: Function
75
76
  },
76
77
  setup(__props) {
77
78
  const props = __props;
@@ -84,6 +85,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
84
85
  permissionMap,
85
86
  audioPlayer,
86
87
  videoPlayer,
88
+ ensureHyIcon,
87
89
  ...config2
88
90
  } = globalConfig.value;
89
91
  return {
@@ -1,6 +1,8 @@
1
- import { defineComponent, useTemplateRef, useModel, watch, unref, openBlock, createBlock, mergeProps, mergeModels } from 'vue';
1
+ import { defineComponent, useTemplateRef, useModel, computed, watch, unref, openBlock, createBlock, mergeProps, mergeModels } from 'vue';
2
2
  import { ElDatePicker } from 'element-plus';
3
+ import { getDefaultValueFormatByType } from '../../utils/date.mjs';
3
4
  import { isArray } from '../../utils/is.mjs';
5
+ import { useLocale } from '../../hooks/useLocale.mjs';
4
6
 
5
7
  import "./style/appDatePicker.scss";
6
8
 
@@ -21,7 +23,15 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
21
23
  type: String,
22
24
  default: "date"
23
25
  // 'year' | 'years' |'month' | 'months' | 'date' | 'dates' | 'datetime' | 'week' | 'datetimerange' | 'daterange' | 'monthrange' | 'yearrange'
24
- }
26
+ },
27
+ format: {
28
+ type: String
29
+ },
30
+ valueFormat: {
31
+ type: String
32
+ },
33
+ startPlaceholder: String,
34
+ endPlaceholder: String
25
35
  }, {
26
36
  "modelValue": { type: [String, Date, Array] },
27
37
  "modelModifiers": {},
@@ -34,10 +44,43 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
34
44
  setup(__props, { expose: __expose, emit: __emit }) {
35
45
  const props = __props;
36
46
  const emits = __emit;
47
+ const { t } = useLocale();
37
48
  const appDatePicker = useTemplateRef("appDatePicker");
38
49
  const dateValue = useModel(__props, "modelValue");
39
50
  const startValue = useModel(__props, "start");
40
51
  const endValue = useModel(__props, "end");
52
+ const startPlaceholder = computed(() => {
53
+ if (props.startPlaceholder) {
54
+ return props.startPlaceholder;
55
+ }
56
+ switch (props.type) {
57
+ case "daterange":
58
+ return t("datePicker.startDate");
59
+ case "datetimerange":
60
+ return t("datePicker.startDateTime");
61
+ case "monthrange":
62
+ return t("datePicker.startMonth");
63
+ case "yearrange":
64
+ return t("datePicker.startYear");
65
+ }
66
+ return null;
67
+ });
68
+ const endPlaceholder = computed(() => {
69
+ if (props.endPlaceholder) {
70
+ return props.endPlaceholder;
71
+ }
72
+ switch (props.type) {
73
+ case "daterange":
74
+ return t("datePicker.endDate");
75
+ case "datetimerange":
76
+ return t("datePicker.endDateTime");
77
+ case "monthrange":
78
+ return t("datePicker.endMonth");
79
+ case "yearrange":
80
+ return t("datePicker.endYear");
81
+ }
82
+ return null;
83
+ });
41
84
  watch(
42
85
  () => [startValue.value, endValue.value],
43
86
  ([start, end]) => {
@@ -51,6 +94,10 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
51
94
  },
52
95
  { immediate: true }
53
96
  );
97
+ function dateFormHandler(format) {
98
+ if (format) return format;
99
+ return getDefaultValueFormatByType(props.type);
100
+ }
54
101
  function onChangeHandler(value) {
55
102
  const { timeRangeFill } = props;
56
103
  const isFill = timeRangeFill && ["daterange"].includes(props.type);
@@ -90,7 +137,14 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
90
137
  modelValue: dateValue.value,
91
138
  "onUpdate:modelValue": ($event) => dateValue.value = $event,
92
139
  type: __props.type
93
- }, _ctx.$attrs, { onChange: onChangeHandler }), null, 16, ["modelValue", "onUpdate:modelValue", "type"]);
140
+ }, _ctx.$attrs, {
141
+ format: dateFormHandler(__props.format),
142
+ valueFormat: dateFormHandler(__props.valueFormat),
143
+ "start-placeholder": startPlaceholder.value,
144
+ "range-separator": unref(t)("datePicker.to"),
145
+ "end-placeholder": endPlaceholder.value,
146
+ onChange: onChangeHandler
147
+ }), null, 16, ["modelValue", "onUpdate:modelValue", "type", "format", "valueFormat", "start-placeholder", "range-separator", "end-placeholder"]);
94
148
  };
95
149
  }
96
150
  });
@@ -2,5 +2,6 @@ import _sfc_main from './appDatePicker.vue.mjs';
2
2
  import { withInstall } from '../../utils/handler.mjs';
3
3
 
4
4
  const AppDatePicker = withInstall(_sfc_main);
5
+ const ElDatePicker = withInstall(_sfc_main, "ElDatePicker");
5
6
 
6
- export { AppDatePicker, AppDatePicker as default };
7
+ export { AppDatePicker, ElDatePicker, AppDatePicker as default };
@@ -1,12 +1,13 @@
1
1
  import { computed, unref, openBlock, createBlock, normalizeStyle, withCtx, createCommentVNode, createElementVNode, renderSlot, toDisplayString, createElementBlock, createVNode, Fragment, mergeProps } from 'vue';
2
2
  import { ElFormItem, ElIcon, ElSelect, ElRadioGroup, ElCheckboxGroup, ElSwitch, ElInputNumber } from 'element-plus';
3
3
  import { QuestionFilled } from '@element-plus/icons-vue';
4
- import { AppDatePicker } from '../../appDatePicker/index.mjs';
5
- import { AppOrgCascader } from '../../appOrgCascader/index.mjs';
6
4
  import { columnShowHandler, columnItemStyle, isRequired, renderText, isDisabled, optionsHandler } from '../js/index.mjs';
7
5
  import { setValueByProp, getValueByProp } from '../../../utils/form.mjs';
8
6
  import { AppTooltip } from '../../appTooltip/index.mjs';
9
7
  import { AppInput } from '../../appInput/index.mjs';
8
+ import { AppDatePicker } from '../../appDatePicker/index.mjs';
9
+ import { AppTimePicker } from '../../appTimePicker/index.mjs';
10
+ import { AppOrgCascader } from '../../appOrgCascader/index.mjs';
10
11
  import { isArray } from '../../../utils/is.mjs';
11
12
  import { funRunHandler } from '../../../utils/handler.mjs';
12
13
 
@@ -218,9 +219,38 @@ const _sfc_main = {
218
219
  ],
219
220
  64
220
221
  /* STABLE_FRAGMENT */
221
- )) : __props.column.type === "radio" ? (openBlock(), createElementBlock(
222
+ )) : __props.column.type === "time-picker" ? (openBlock(), createElementBlock(
222
223
  Fragment,
223
224
  { key: 4 },
225
+ [
226
+ createCommentVNode(" \u65F6\u95F4\u9009\u62E9\u6846 "),
227
+ __props.column.attrs.isRange ? (openBlock(), createBlock(unref(AppTimePicker), mergeProps({
228
+ key: 0,
229
+ start: bindValue.value,
230
+ "onUpdate:start": ($event) => bindValue.value = $event,
231
+ end: bindValue2.value,
232
+ "onUpdate:end": ($event) => bindValue2.value = $event,
233
+ "is-range": true,
234
+ style: { "width": "100%" }
235
+ }, __props.column.attrs, {
236
+ disabled: unref(isDisabled)(props, __props.column),
237
+ onChange: onChangeHandler
238
+ }), null, 16, ["start", "onUpdate:start", "end", "onUpdate:end", "disabled"])) : (openBlock(), createBlock(unref(AppTimePicker), mergeProps({
239
+ key: 1,
240
+ modelValue: bindValue.value,
241
+ "onUpdate:modelValue": ($event) => bindValue.value = $event,
242
+ "is-range": false,
243
+ style: { "width": "100%" }
244
+ }, __props.column.attrs, {
245
+ disabled: unref(isDisabled)(props, __props.column),
246
+ onChange: onChangeHandler
247
+ }), null, 16, ["modelValue", "onUpdate:modelValue", "disabled"]))
248
+ ],
249
+ 64
250
+ /* STABLE_FRAGMENT */
251
+ )) : __props.column.type === "radio" ? (openBlock(), createElementBlock(
252
+ Fragment,
253
+ { key: 5 },
224
254
  [
225
255
  createCommentVNode(" \u5355\u9009 "),
226
256
  createVNode(unref(ElRadioGroup), mergeProps({
@@ -236,7 +266,7 @@ const _sfc_main = {
236
266
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
237
267
  )) : __props.column.type === "checkbox" ? (openBlock(), createElementBlock(
238
268
  Fragment,
239
- { key: 5 },
269
+ { key: 6 },
240
270
  [
241
271
  createCommentVNode(" \u591A\u9009 "),
242
272
  createVNode(unref(ElCheckboxGroup), mergeProps({
@@ -252,7 +282,7 @@ const _sfc_main = {
252
282
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
253
283
  )) : __props.column.type === "switch" ? (openBlock(), createElementBlock(
254
284
  Fragment,
255
- { key: 6 },
285
+ { key: 7 },
256
286
  [
257
287
  createCommentVNode(" \u5F00\u5173 "),
258
288
  createVNode(unref(ElSwitch), mergeProps({
@@ -267,7 +297,7 @@ const _sfc_main = {
267
297
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
268
298
  )) : __props.column.type === "input-number" ? (openBlock(), createElementBlock(
269
299
  Fragment,
270
- { key: 7 },
300
+ { key: 8 },
271
301
  [
272
302
  createCommentVNode(" \u6570\u5B57\u8F93\u5165\u6846 "),
273
303
  createVNode(unref(ElInputNumber), mergeProps({
@@ -282,7 +312,7 @@ const _sfc_main = {
282
312
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
283
313
  )) : __props.column.type === "org-cascader" ? (openBlock(), createElementBlock(
284
314
  Fragment,
285
- { key: 8 },
315
+ { key: 9 },
286
316
  [
287
317
  createCommentVNode(" \u90E8\u95E8\u7EA7\u8054\u9009\u62E9\u6846 "),
288
318
  createVNode(unref(AppOrgCascader), mergeProps({
@@ -1,7 +1,6 @@
1
1
  import { unref, toRef } from 'vue';
2
2
  import { genValueByProp } from '../../../utils/form.mjs';
3
3
  import { funRunHandler, mergeDeep } from '../../../utils/handler.mjs';
4
- import { getDefaultValueFormatByType } from '../../../utils/date.mjs';
5
4
  import { isArray } from '../../../utils/is.mjs';
6
5
  import { useLocale } from '../../../hooks/useLocale.mjs';
7
6
 
@@ -23,33 +22,9 @@ const genPlaceholderHandler = (config) => {
23
22
  placeholder = placeholder || t("hy.pleaseEnterPlaceholder", [label]);
24
23
  break;
25
24
  case "select":
26
- placeholder = placeholder || t("hy.pleaseSelectPlaceholder", [label]);
27
- break;
28
25
  case "date-picker":
29
- if (["datetimerange", "daterange", "monthrange", "yearrange"].includes(
30
- attrs?.type
31
- )) {
32
- switch (attrs.type) {
33
- case "yearrange":
34
- startPlaceholder = startPlaceholder || t("hy.startYear");
35
- endPlaceholder = endPlaceholder || t("hy.endYear");
36
- break;
37
- case "monthrange":
38
- startPlaceholder = startPlaceholder || t("hy.startMonth");
39
- endPlaceholder = endPlaceholder || t("hy.endMonth");
40
- break;
41
- case "daterange":
42
- startPlaceholder = startPlaceholder || t("hy.startDate");
43
- endPlaceholder = endPlaceholder || t("hy.endDate");
44
- break;
45
- case "datetimerange":
46
- startPlaceholder = startPlaceholder || t("hy.startDateTime");
47
- endPlaceholder = endPlaceholder || t("hy.endDateTime");
48
- break;
49
- }
50
- } else {
51
- placeholder = placeholder || t("hy.pleaseSelectPlaceholder", [label]);
52
- }
26
+ case "time-picker":
27
+ placeholder = placeholder || t("hy.pleaseSelectPlaceholder", [label]);
53
28
  break;
54
29
  default:
55
30
  placeholder = placeholder || label;
@@ -86,7 +61,7 @@ const rulesHandler = (config) => {
86
61
  };
87
62
  function appFormItemHandler(column = {}) {
88
63
  const label = genDefaultLabel(column);
89
- const { placeholder, startPlaceholder, endPlaceholder } = genPlaceholderHandler({ ...column, label });
64
+ const { placeholder} = genPlaceholderHandler({ ...column, label });
90
65
  const attrs = { ...column.attrs || {}, placeholder };
91
66
  column = mergeDeep(
92
67
  { ...column },
@@ -95,7 +70,8 @@ function appFormItemHandler(column = {}) {
95
70
  field: column.prop,
96
71
  label,
97
72
  readonly: column.readonly || false,
98
- rules: rulesHandler(column)
73
+ rules: rulesHandler(column),
74
+ attrs
99
75
  }
100
76
  );
101
77
  if (/^(input)$/.test(column.type)) {
@@ -120,17 +96,6 @@ function appFormItemHandler(column = {}) {
120
96
  }
121
97
  }
122
98
  };
123
- } else if (/^date-picker$/.test(column.type)) {
124
- return {
125
- ...column,
126
- attrs: {
127
- format: attrs.format || getDefaultValueFormatByType(attrs.type),
128
- valueFormat: attrs.valueFormat || getDefaultValueFormatByType(attrs.type),
129
- ...attrs,
130
- startPlaceholder,
131
- endPlaceholder
132
- }
133
- };
134
99
  } else if (/^(extra)$/.test(column.type)) {
135
100
  return {
136
101
  ...column,
@@ -1,4 +1,5 @@
1
- import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, createElementVNode } from 'vue';
1
+ import { defineComponent, onMounted, watch, computed, openBlock, createElementBlock, normalizeClass, createElementVNode } from 'vue';
2
+ import { useEnsureHyIcon } from '../../hooks/useEnsureHyIcon.mjs';
2
3
 
3
4
  import "./style/appIcon.scss";
4
5
 
@@ -23,6 +24,9 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
23
24
  },
24
25
  setup(__props) {
25
26
  const props = __props;
27
+ const { ensureHyIcon } = useEnsureHyIcon();
28
+ onMounted(() => ensureHyIcon(props.svgName));
29
+ watch(() => props.svgName, ensureHyIcon);
26
30
  const iconName = computed(() => `#${props.prefix}${props.svgName}`);
27
31
  const svgClass = computed(() => {
28
32
  if (props.className) {
@@ -1,11 +1,12 @@
1
1
  import { computed, unref, openBlock, createBlock, withCtx, createElementVNode, normalizeStyle, createCommentVNode, renderSlot, createElementBlock, toDisplayString, normalizeClass, Fragment, createVNode, mergeProps, withKeys, renderList } from 'vue';
2
2
  import { ElFormItem, ElSelect } from 'element-plus';
3
3
  import { columnShowHandler, columnItemStyle, columnItemInputStyle, isDisabled, optionsHandler, isSelectedTimeRange, timeRangeHandler } from '../js/index.mjs';
4
- import { AppDatePicker } from '../../appDatePicker/index.mjs';
5
- import { AppOrgCascader } from '../../appOrgCascader/index.mjs';
6
4
  import { isArray } from '../../../utils/is.mjs';
7
5
  import { setValueByProp, getValueByProp } from '../../../utils/form.mjs';
8
6
  import { AppInput } from '../../appInput/index.mjs';
7
+ import { AppDatePicker } from '../../appDatePicker/index.mjs';
8
+ import { AppTimePicker } from '../../appTimePicker/index.mjs';
9
+ import { AppOrgCascader } from '../../appOrgCascader/index.mjs';
9
10
 
10
11
  const _sfc_main = {
11
12
  __name: "appSearchItem",
@@ -175,9 +176,38 @@ const _sfc_main = {
175
176
  ],
176
177
  64
177
178
  /* STABLE_FRAGMENT */
178
- )) : __props.column.type === "org-cascader" ? (openBlock(), createElementBlock(
179
+ )) : __props.column.type === "time-picker" ? (openBlock(), createElementBlock(
179
180
  Fragment,
180
181
  { key: 4 },
182
+ [
183
+ createCommentVNode(" \u65F6\u95F4\u9009\u62E9\u6846 "),
184
+ __props.column.attrs.isRange ? (openBlock(), createBlock(unref(AppTimePicker), mergeProps({
185
+ key: 0,
186
+ start: bindValue.value,
187
+ "onUpdate:start": ($event) => bindValue.value = $event,
188
+ end: bindValue2.value,
189
+ "onUpdate:end": ($event) => bindValue2.value = $event,
190
+ "is-range": true,
191
+ style: { "width": "100%" }
192
+ }, __props.column.attrs, {
193
+ disabled: unref(isDisabled)(props, __props.column),
194
+ onChange: onChangeHandler
195
+ }), null, 16, ["start", "onUpdate:start", "end", "onUpdate:end", "disabled"])) : (openBlock(), createBlock(unref(AppTimePicker), mergeProps({
196
+ key: 1,
197
+ modelValue: bindValue.value,
198
+ "onUpdate:modelValue": ($event) => bindValue.value = $event,
199
+ "is-range": false,
200
+ style: { "width": "100%" }
201
+ }, __props.column.attrs, {
202
+ disabled: unref(isDisabled)(props, __props.column),
203
+ onChange: onChangeHandler
204
+ }), null, 16, ["modelValue", "onUpdate:modelValue", "disabled"]))
205
+ ],
206
+ 64
207
+ /* STABLE_FRAGMENT */
208
+ )) : __props.column.type === "org-cascader" ? (openBlock(), createElementBlock(
209
+ Fragment,
210
+ { key: 5 },
181
211
  [
182
212
  createCommentVNode(" \u90E8\u95E8\u7EA7\u8054\u9009\u62E9\u6846 "),
183
213
  createVNode(unref(AppOrgCascader), mergeProps({
@@ -9,7 +9,7 @@ function columnItemStyle(props, column) {
9
9
  if (isNumber(width)) {
10
10
  style.width = `${width}px`;
11
11
  } else if (isString(width)) {
12
- style.width = /(px|em|rem|vw|vh)$/.test(width) ? width : `${width}px`;
12
+ style.width = /^\d+$/.test(width) ? `${width}px` : width;
13
13
  }
14
14
  return style;
15
15
  }
@@ -1,7 +1,6 @@
1
1
  import { unref, toRef } from 'vue';
2
2
  import { funRunHandler, mergeDeep } from '../../../utils/handler.mjs';
3
3
  import { genValueByProp } from '../../../utils/form.mjs';
4
- import { getDefaultValueFormatByType } from '../../../utils/date.mjs';
5
4
  import { useLocale } from '../../../hooks/useLocale.mjs';
6
5
  import { isNumber } from '../../../utils/is.mjs';
7
6
 
@@ -21,33 +20,12 @@ const genPlaceholderHandler = (config) => {
21
20
  switch (type) {
22
21
  case "input":
23
22
  placeholder = placeholder || t("hy.pleaseEnterPlaceholder", [label]);
23
+ break;
24
24
  case "select":
25
- placeholder = placeholder || t("hy.pleaseSelectPlaceholder", [label]);
26
25
  case "date-picker":
27
- if (["datetimerange", "daterange", "monthrange", "yearrange"].includes(
28
- attrs?.type
29
- )) {
30
- switch (attrs.type) {
31
- case "yearrange":
32
- startPlaceholder = startPlaceholder || t("hy.startYear");
33
- endPlaceholder = endPlaceholder || t("hy.endYear");
34
- break;
35
- case "monthrange":
36
- startPlaceholder = startPlaceholder || t("hy.startMonth");
37
- endPlaceholder = endPlaceholder || t("hy.endMonth");
38
- break;
39
- case "daterange":
40
- startPlaceholder = startPlaceholder || t("hy.startDate");
41
- endPlaceholder = endPlaceholder || t("hy.endDate");
42
- break;
43
- case "datetimerange":
44
- startPlaceholder = startPlaceholder || t("hy.startDateTime");
45
- endPlaceholder = endPlaceholder || t("hy.endDateTime");
46
- break;
47
- }
48
- } else {
49
- placeholder = placeholder || t("hy.pleaseSelectPlaceholder", [label]);
50
- }
26
+ case "time-picker":
27
+ placeholder = placeholder || t("hy.pleaseSelectPlaceholder", [label]);
28
+ break;
51
29
  default:
52
30
  placeholder = placeholder || label;
53
31
  }
@@ -71,6 +49,8 @@ const genColumnWidth = (config) => {
71
49
  default:
72
50
  inputWidth = 145;
73
51
  }
52
+ } else if (type === "time-picker" && attrs.isRange) {
53
+ width = 350;
74
54
  } else {
75
55
  width = 250;
76
56
  }
@@ -105,7 +85,7 @@ const timeRangeOptionsHandler = (config) => {
105
85
  };
106
86
  function appSearchItemHandler(column = {}) {
107
87
  const label = genDefaultLabel(column);
108
- const { placeholder, startPlaceholder, endPlaceholder } = genPlaceholderHandler({ ...column, label });
88
+ const { placeholder} = genPlaceholderHandler({ ...column, label });
109
89
  const attrs = {
110
90
  clearable: true,
111
91
  ...column.attrs || {},
@@ -121,7 +101,8 @@ function appSearchItemHandler(column = {}) {
121
101
  readonly: column.readonly || false,
122
102
  width,
123
103
  inputWidth,
124
- timeRangeOptions: timeRangeOptionsHandler(column)
104
+ timeRangeOptions: timeRangeOptionsHandler(column),
105
+ attrs
125
106
  }
126
107
  );
127
108
  if (/^(input)$/.test(column.type)) {
@@ -146,17 +127,6 @@ function appSearchItemHandler(column = {}) {
146
127
  }
147
128
  }
148
129
  };
149
- } else if (/^date-picker$/.test(column.type)) {
150
- return {
151
- ...column,
152
- attrs: {
153
- format: attrs.format || getDefaultValueFormatByType(attrs.type),
154
- valueFormat: attrs.valueFormat || getDefaultValueFormatByType(attrs.type),
155
- ...attrs,
156
- startPlaceholder,
157
- endPlaceholder
158
- }
159
- };
160
130
  }
161
131
  return column;
162
132
  }
@@ -0,0 +1,154 @@
1
+ import { useTemplateRef, useModel, computed, watch, unref, openBlock, createBlock, mergeProps, mergeModels, defineComponent } from 'vue';
2
+ import dayjs from 'dayjs';
3
+ import { ElTimePicker } from 'element-plus';
4
+ import { useLocale } from '../../hooks/useLocale.mjs';
5
+ import { isArray } from '../../utils/is.mjs';
6
+
7
+ import "./style/appTimePicker.scss";
8
+
9
+ const __default__ = defineComponent({
10
+ name: "AppTimePicker"
11
+ });
12
+ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
13
+ props: /* @__PURE__ */ mergeModels({
14
+ isRange: {
15
+ type: Boolean,
16
+ default: false
17
+ },
18
+ format: {
19
+ type: String,
20
+ default: "HH:mm:ss"
21
+ },
22
+ valueFormat: {
23
+ type: String
24
+ },
25
+ disabledSeconds: Function,
26
+ startPlaceholder: String,
27
+ endPlaceholder: String
28
+ }, {
29
+ "modelValue": {
30
+ type: [String, Number, Date, Array]
31
+ },
32
+ "modelModifiers": {},
33
+ "start": { type: [String, Number, Date] },
34
+ "startModifiers": {},
35
+ "end": { type: [String, Number, Date] },
36
+ "endModifiers": {}
37
+ }),
38
+ emits: /* @__PURE__ */ mergeModels(["change"], ["update:modelValue", "update:start", "update:end"]),
39
+ setup(__props, { expose: __expose, emit: __emit }) {
40
+ const props = __props;
41
+ const emits = __emit;
42
+ const { t } = useLocale();
43
+ const appTimePicker = useTemplateRef("appTimePicker");
44
+ const timeValue = useModel(__props, "modelValue");
45
+ const startValue = useModel(__props, "start");
46
+ const endValue = useModel(__props, "end");
47
+ const startPlaceholder = computed(() => {
48
+ if (props.startPlaceholder) {
49
+ return props.startPlaceholder;
50
+ }
51
+ return t("timePicker.startTime");
52
+ });
53
+ const endPlaceholder = computed(() => {
54
+ if (props.endPlaceholder) {
55
+ return props.endPlaceholder;
56
+ }
57
+ return t("timePicker.endTime");
58
+ });
59
+ const disabledSecondsHandler = computed(() => {
60
+ return (hour, minute, role, comparingDate) => {
61
+ if (props.disabledSeconds) {
62
+ return props.disabledSeconds(hour, minute, role, comparingDate);
63
+ }
64
+ if (props.isRange && isArray(timeValue.value) && timeValue.value.length === 2) {
65
+ const spinnerValue = role === "start" ? timeValue.value[1] : timeValue.value[0];
66
+ const spinnerHours = sliceTime(spinnerValue, "HH");
67
+ const spinnerMinutes = sliceTime(spinnerValue, "mm");
68
+ const spinnerSeconds = sliceTime(spinnerValue, "ss");
69
+ const isEqual = spinnerHours === hour && spinnerMinutes === minute;
70
+ if (isEqual) {
71
+ return role === "start" ? makeRange(Math.max(0, spinnerSeconds), 60) : makeRange(0, Math.min(spinnerSeconds, 60));
72
+ }
73
+ }
74
+ };
75
+ });
76
+ watch(
77
+ () => [startValue.value, endValue.value],
78
+ ([start, end]) => {
79
+ if (props.isRange && start && end) {
80
+ timeValue.value = [start, end];
81
+ }
82
+ },
83
+ { immediate: true }
84
+ );
85
+ const makeRange = (start, end) => {
86
+ const result = [];
87
+ for (let i = start; i <= end; i++) {
88
+ result.push(i);
89
+ }
90
+ return result;
91
+ };
92
+ const sliceTime = (date, format) => {
93
+ if (!date) return null;
94
+ const valueFormat = timeFormHandler(props.valueFormat);
95
+ if (!valueFormat) {
96
+ return Number(dayjs(date).format(format));
97
+ }
98
+ const result = valueFormat.match(format);
99
+ if (!result) return null;
100
+ return Number(date.slice(result.index, result.index + format.length));
101
+ };
102
+ function timeFormHandler(format) {
103
+ if (format) return format;
104
+ return "HH:mm:ss";
105
+ }
106
+ function onChangeHandler(value) {
107
+ const { timeRangeFill } = props;
108
+ if (props.isRange) {
109
+ startValue.value = isArray(value) ? value[0] : null;
110
+ endValue.value = isArray(value) ? value[1] : null;
111
+ } else {
112
+ timeValue.value = value;
113
+ }
114
+ emits("change", timeValue.value);
115
+ }
116
+ __expose({
117
+ focus() {
118
+ if (!unref(appTimePicker)) return;
119
+ unref(appTimePicker).focus();
120
+ },
121
+ blur() {
122
+ if (!unref(appTimePicker)) return;
123
+ unref(appTimePicker).blur();
124
+ },
125
+ handleOpen() {
126
+ if (!unref(appTimePicker)) return;
127
+ unref(appTimePicker).handleOpen();
128
+ },
129
+ handleClose() {
130
+ if (!unref(appTimePicker)) return;
131
+ unref(appTimePicker).handleClose();
132
+ }
133
+ });
134
+ return (_ctx, _cache) => {
135
+ return openBlock(), createBlock(unref(ElTimePicker), mergeProps({
136
+ ref_key: "appTimePicker",
137
+ ref: appTimePicker,
138
+ modelValue: timeValue.value,
139
+ "onUpdate:modelValue": ($event) => timeValue.value = $event
140
+ }, _ctx.$attrs, {
141
+ isRange: __props.isRange,
142
+ format: timeFormHandler(__props.format),
143
+ valueFormat: timeFormHandler(__props.valueFormat),
144
+ disabledSeconds: disabledSecondsHandler.value,
145
+ "start-placeholder": startPlaceholder.value,
146
+ "range-separator": unref(t)("timePicker.to"),
147
+ "end-placeholder": endPlaceholder.value,
148
+ onChange: onChangeHandler
149
+ }), null, 16, ["modelValue", "onUpdate:modelValue", "isRange", "format", "valueFormat", "disabledSeconds", "start-placeholder", "range-separator", "end-placeholder"]);
150
+ };
151
+ }
152
+ });
153
+
154
+ export { _sfc_main as default };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from './appTimePicker.vue.mjs';
2
+ import { withInstall } from '../../utils/handler.mjs';
3
+
4
+ const AppTimePicker = withInstall(_sfc_main);
5
+ const ElTimePicker = withInstall(_sfc_main, "ElTimePicker");
6
+
7
+ export { AppTimePicker, ElTimePicker, AppTimePicker as default };