@fangzhongya/fang-ui 0.1.46 → 0.1.48

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 (82) hide show
  1. package/dist/components/cascaders/index.css +6 -0
  2. package/dist/components/cascaders/index.scss +6 -0
  3. package/dist/components/common/compons/components.cjs +0 -16
  4. package/dist/components/common/compons/components.d.ts +0 -8
  5. package/dist/components/common/compons/components.js +0 -16
  6. package/dist/components/common/compons/index.scss +0 -8
  7. package/dist/components/common/compons/index2.scss +0 -8
  8. package/dist/components/dates-divide/index.css +6 -0
  9. package/dist/components/dates-divide/index.scss +6 -0
  10. package/dist/components/dates-divide/src/index2.cjs +4 -2
  11. package/dist/components/dates-divide/src/index2.js +4 -2
  12. package/dist/components/dates-picker/index.css +2 -2
  13. package/dist/components/dates-picker/index.scss +4 -4
  14. package/dist/components/dates-picker/src/index2.cjs +2 -1
  15. package/dist/components/dates-picker/src/index2.js +2 -1
  16. package/dist/components/dates2/index.css +9 -0
  17. package/dist/components/dates2/index.scss +3 -0
  18. package/dist/components/dates2/src/index2.cjs +6 -4
  19. package/dist/components/dates2/src/index2.js +6 -4
  20. package/dist/components/double/index.css +45 -10
  21. package/dist/components/double/index.scss +30 -17
  22. package/dist/components/double/src/data.cjs +24 -5
  23. package/dist/components/double/src/data.d.ts +23 -1
  24. package/dist/components/double/src/data.js +24 -5
  25. package/dist/components/double/src/index2.cjs +129 -64
  26. package/dist/components/double/src/index2.js +126 -61
  27. package/dist/components/double/style/index2.scss +1 -0
  28. package/dist/components/forms/common/config.cjs +3 -2
  29. package/dist/components/forms/common/config.js +3 -2
  30. package/dist/components/forms/index.css +74 -162
  31. package/dist/components/forms/src/util.cjs +30 -33
  32. package/dist/components/forms/src/util.js +29 -32
  33. package/dist/components/forms-item/index.css +3 -0
  34. package/dist/components/forms-item/index.scss +5 -0
  35. package/dist/components/forms-items/index.css +3 -0
  36. package/dist/components/input-history/index.css +3 -0
  37. package/dist/components/input-history/index.scss +3 -1
  38. package/dist/components/input-history/src/data.d.ts +1 -0
  39. package/dist/components/input-history/src/index2.cjs +23 -19
  40. package/dist/components/input-history/src/index2.js +15 -11
  41. package/dist/components/input-select/index.css +35 -7
  42. package/dist/components/input-select/index.scss +10 -7
  43. package/dist/components/input-select/src/index2.cjs +26 -19
  44. package/dist/components/input-select/src/index2.js +23 -16
  45. package/dist/components/input-select/style/index2.scss +2 -1
  46. package/dist/components/list/src/index2.cjs +5 -0
  47. package/dist/components/list/src/index2.js +6 -1
  48. package/dist/components/page/index.css +74 -162
  49. package/dist/components/scss/function.scss +3 -1
  50. package/dist/components/select-scroll/src/index2.cjs +1 -1
  51. package/dist/components/select-scroll/src/index2.js +2 -2
  52. package/dist/components/selector/index.css +50 -10
  53. package/dist/components/selector/index.scss +5 -0
  54. package/dist/components/selector/src/data.cjs +7 -3
  55. package/dist/components/selector/src/data.d.ts +8 -4
  56. package/dist/components/selector/src/data.js +7 -3
  57. package/dist/components/selector/src/index2.cjs +127 -91
  58. package/dist/components/selector/src/index2.js +124 -88
  59. package/dist/components/tables/common/pagin.d.ts +4 -4
  60. package/dist/components/tables/src/index2.cjs +9 -3
  61. package/dist/components/tables/src/index2.js +10 -4
  62. package/dist/components/tablesv/src/index2.cjs +9 -3
  63. package/dist/components/tablesv/src/index2.js +10 -4
  64. package/dist/css/cascaders.css +6 -0
  65. package/dist/css/dates-divide.css +6 -0
  66. package/dist/css/dates-picker.css +2 -2
  67. package/dist/css/dates2.css +9 -0
  68. package/dist/css/double.css +45 -10
  69. package/dist/css/forms-item.css +3 -0
  70. package/dist/css/forms-items.css +3 -0
  71. package/dist/css/forms.css +74 -162
  72. package/dist/css/index.css +227 -186
  73. package/dist/css/input-history.css +3 -0
  74. package/dist/css/input-select.css +35 -7
  75. package/dist/css/page.css +74 -162
  76. package/dist/css/selector.css +50 -10
  77. package/dist/icons/index.json +1 -1
  78. package/dist/index.css +227 -186
  79. package/dist/type.d.ts +2 -2
  80. package/package.json +5 -5
  81. /package/dist/components/{global-config → keep-com}/index.css +0 -0
  82. /package/dist/css/{global-config.css → keep-com.css} +0 -0
@@ -1,4 +1,5 @@
1
- import { defineComponent, computed, ref, watch, onMounted, createElementBlock, openBlock, withModifiers, normalizeClass, unref, renderSlot, createBlock, createElementVNode, createCommentVNode, resolveDynamicComponent, mergeProps, toDisplayString, createVNode, withCtx } from "vue";
1
+ import { defineComponent, ref, computed, watch, onMounted, onUnmounted, createElementBlock, openBlock, withModifiers, normalizeClass, unref, renderSlot, createBlock, createElementVNode, createCommentVNode, resolveDynamicComponent, mergeProps, toDisplayString, createVNode, withCtx } from "vue";
2
+ import { isEqual } from "@fangzhongya/utils/basic/object/isEqual";
2
3
  import { name, dataProps, dataExpose, dataSlot, dataEmits } from "./data.js";
3
4
  import { useCssName } from "../../../hooks/cssname/index.js";
4
5
  import { Icon } from "../../icon/index.js";
@@ -7,12 +8,16 @@ import { useComponsGet } from "../../../hooks/compons/index.js";
7
8
  import { usePropsDefault, getProps } from "../../../hooks/props-default/index.js";
8
9
  import { lineToLargeHump } from "@fangzhongya/utils/name/lineToLargeHump";
9
10
  import { useLocale } from "../../../hooks/locale/index.js";
11
+ import { Message } from "../../message/index.js";
12
+ import "../../form/index.js";
13
+ import { useDisabled, useFormItem } from "element-plus/es/components/form/index";
10
14
  const _sfc_main = /* @__PURE__ */ defineComponent({
11
15
  __name: "index",
12
16
  props: getProps(dataProps),
13
17
  emits: dataEmits,
14
18
  setup(__props, { expose: __expose, emit: __emit }) {
15
19
  const { getLocale } = useLocale();
20
+ let doubleValueDate = 0;
16
21
  const cs = useCssName(name);
17
22
  const prs = __props;
18
23
  const props = usePropsDefault(name, prs, dataProps, {
@@ -26,6 +31,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
26
31
  return getLocale("end");
27
32
  }
28
33
  });
34
+ const disabled = useDisabled();
35
+ const { formItem: elFormItem } = useFormItem();
36
+ const refDom = ref();
29
37
  const compons = useComponsGet(props.compons);
30
38
  const pcompon = computed(() => {
31
39
  if (typeof props.compon == "string") {
@@ -36,13 +44,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
36
44
  }
37
45
  });
38
46
  const emit = __emit;
39
- const refInput = ref();
40
47
  const isfocus = ref(false);
41
48
  const start = ref();
42
49
  const end = ref();
43
50
  const emove = ref(false);
51
+ watch(
52
+ () => props.mouse,
53
+ () => {
54
+ emove.value = props.mouse;
55
+ }
56
+ );
44
57
  const isclear = computed(() => {
45
- if (props.clearable) {
58
+ if (props.clearable && disabled.value === false) {
46
59
  if (start.value || end.value) {
47
60
  if (emove.value || isfocus.value) {
48
61
  return true;
@@ -73,14 +86,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
73
86
  }
74
87
  }
75
88
  if (v) {
89
+ if (props.isDoubleValue && v.length == 0) {
90
+ if (doubleValueDate > Date.now() - 400) {
91
+ return;
92
+ }
93
+ }
76
94
  const s = v[0];
77
95
  const e = v[1];
78
96
  if (s !== start.value) {
79
97
  start.value = s;
98
+ onInput(0);
80
99
  }
81
100
  if (e !== end.value) {
82
101
  end.value = e;
102
+ onInput(1);
83
103
  }
104
+ } else {
105
+ start.value = void 0;
106
+ end.value = void 0;
84
107
  }
85
108
  },
86
109
  {
@@ -88,30 +111,26 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
88
111
  deep: true
89
112
  }
90
113
  );
91
- watch(
92
- () => isfocus.value,
93
- () => {
94
- if (isfocus.value) {
95
- emit("focus");
96
- } else {
97
- emit("blur");
98
- }
114
+ function validateEvent() {
115
+ var _a;
116
+ if (props.validateEvent) {
117
+ (_a = elFormItem == null ? void 0 : elFormItem.validate) == null ? void 0 : _a.call(elFormItem, "blur").catch((err) => console.log("err", err));
99
118
  }
100
- );
119
+ }
101
120
  function onMouseenter() {
102
121
  emove.value = true;
103
122
  }
104
123
  function onMouseleave() {
105
124
  emove.value = false;
106
125
  }
107
- const errer = ref();
126
+ const error = ref();
108
127
  function onInput(type) {
109
128
  var _a, _b;
110
129
  if (!props.check) {
111
130
  setValue([start.value, end.value]);
112
131
  return;
113
132
  }
114
- errer.value = void 0;
133
+ error.value = void 0;
115
134
  if (!start.value || !end.value) {
116
135
  handleValidationSuccess(type);
117
136
  return;
@@ -121,11 +140,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
121
140
  handleValidationError(e, type);
122
141
  } else {
123
142
  handleValidationSuccess(type);
124
- setValue([start.value, end.value]);
125
143
  }
144
+ setValue([start.value, end.value]);
126
145
  };
127
146
  if (typeof props.check === "function") {
128
- const v = props.check(start.value, end.value, callback);
147
+ const v = props.check(callback, start.value, end.value);
129
148
  if (v === false) {
130
149
  return false;
131
150
  }
@@ -141,29 +160,50 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
141
160
  }
142
161
  handleValidationSuccess(type);
143
162
  }
163
+ function errorPrompt(ts, num) {
164
+ if (props.errorPrompt) {
165
+ props.errorPrompt(ts, num);
166
+ } else {
167
+ Message.error(ts);
168
+ }
169
+ }
144
170
  function handleValidationError(e, type) {
171
+ if (type === 0) {
172
+ start.value = void 0;
173
+ } else if (type === 1) {
174
+ end.value = void 0;
175
+ }
145
176
  if (typeof e === "string") {
146
177
  e = new Error(e);
147
178
  }
148
- e.type = type;
149
- errer.value = e;
150
- emit("validate", void 0, false, e.message);
179
+ errorPrompt(e.message, type);
151
180
  }
152
181
  function handleValidationSuccess(type) {
153
- emit("validate", void 0, true, "");
154
182
  setValue([start.value, end.value]);
155
183
  }
156
- function onClear() {
184
+ function onClear(...arr) {
157
185
  start.value = void 0;
158
186
  end.value = void 0;
159
187
  if (props.check) {
160
- errer.value = void 0;
161
- emit("validate", void 0, true, "");
188
+ error.value = void 0;
162
189
  }
163
190
  setValue(void 0);
164
191
  emit("clear");
192
+ if (!isfocus.value) {
193
+ isfocus.value = true;
194
+ emit("focus", ...arr);
195
+ }
165
196
  }
166
197
  function setValue(value) {
198
+ if (value && (value[0] === void 0 || value[0] === null) && (value[1] === void 0 || value[1] === null)) {
199
+ value = [];
200
+ }
201
+ if (props.isDoubleValue && value) {
202
+ if (value[0] === void 0 || value[0] === null || value[1] === void 0 || value[1] === null) {
203
+ doubleValueDate = Date.now();
204
+ value = [];
205
+ }
206
+ }
167
207
  if (props.multiple && value) {
168
208
  let v = "";
169
209
  if (typeof props.multiple != "string") {
@@ -171,53 +211,83 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
171
211
  } else {
172
212
  v = value.join(props.multiple);
173
213
  }
174
- emit("update:modelValue", v);
175
- emit("change", v);
214
+ if (!isEqual(v, props.modelValue)) {
215
+ emit("update:modelValue", v);
216
+ emit("change", v);
217
+ validateEvent();
218
+ }
176
219
  } else {
177
- emit("update:modelValue", value);
178
- emit("change", value);
220
+ if (!isEqual(value, props.modelValue)) {
221
+ emit("update:modelValue", value);
222
+ emit("change", value);
223
+ validateEvent();
224
+ }
179
225
  }
180
226
  }
181
- function onClick() {
182
- isfocus.value = true;
183
- if (refInput.value) {
184
- refInput.value.focus();
227
+ function onClick(...arr) {
228
+ if (!disabled.value) {
229
+ if (!isfocus.value) {
230
+ isfocus.value = true;
231
+ emit("focus", ...arr);
232
+ }
185
233
  }
186
- clearBlur();
187
- }
188
- function onFocus() {
189
- isfocus.value = true;
190
- clearBlur();
234
+ emit("click", ...arr);
191
235
  }
192
- let timeout;
193
- function onBlur() {
194
- timeout = setTimeout(() => {
195
- isfocus.value = false;
196
- }, 200);
236
+ const isfocusCom = ref(false);
237
+ function onFocus(...arr) {
238
+ isfocusCom.value = true;
239
+ if (!isfocus.value) {
240
+ isfocus.value = true;
241
+ emit("focus", ...arr);
242
+ }
197
243
  }
198
- function clearBlur() {
199
- clearTimeout(timeout);
244
+ function onBlur(...arr) {
245
+ isfocusCom.value = false;
246
+ if (!emove.value) {
247
+ if (isfocus.value) {
248
+ isfocus.value = false;
249
+ emit("blur", ...arr);
250
+ validateEvent();
251
+ }
252
+ }
200
253
  }
254
+ const onClickTotal = (event) => {
255
+ var _a;
256
+ if (!((_a = refDom.value) == null ? void 0 : _a.contains(event.target)) && isfocusCom.value == false) {
257
+ if (isfocus.value) {
258
+ isfocus.value = false;
259
+ emit("blur", event);
260
+ validateEvent();
261
+ }
262
+ }
263
+ };
201
264
  onMounted(() => {
202
265
  if (globalThis) {
203
- globalThis.addEventListener("click", () => {
204
- isfocus.value = false;
205
- });
266
+ globalThis.addEventListener("click", onClickTotal);
267
+ }
268
+ });
269
+ onUnmounted(() => {
270
+ if (globalThis) {
271
+ globalThis.removeEventListener("click", onClickTotal);
206
272
  }
207
273
  });
208
274
  __expose({
209
- ...dataExpose
275
+ ...dataExpose,
276
+ focus: onClick
210
277
  });
211
278
  return (_ctx, _cache) => {
212
279
  var _a, _b, _c, _d;
213
280
  return openBlock(), createElementBlock("div", {
214
- class: normalizeClass([unref(cs).z(), unref(cs).is("focus", isfocus.value)]),
281
+ class: normalizeClass([unref(cs).z(), unref(cs).is("focus", isfocus.value), unref(cs).is("disabled", unref(disabled))]),
282
+ ref_key: "refDom",
283
+ ref: refDom,
215
284
  onMouseenter,
216
285
  onMouseleave,
217
286
  onClick: withModifiers(onClick, ["stop"])
218
287
  }, [
219
288
  renderSlot(_ctx.$slots, unref(dataSlot).prefix),
220
289
  (openBlock(), createBlock(resolveDynamicComponent(pcompon.value), mergeProps(unref(props).config, {
290
+ disabled: unref(disabled),
221
291
  multiple: multiple.value,
222
292
  class: [unref(cs).z("value"), unref(cs).z("start")],
223
293
  modelValue: start.value,
@@ -226,13 +296,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
226
296
  _cache[1] || (_cache[1] = ($event) => onInput(0))
227
297
  ],
228
298
  placeholder: unref(props).startPlaceholder + (((_a = unref(props).config) == null ? void 0 : _a.placeholder) ?? ""),
229
- onClick: withModifiers(onFocus, ["stop"]),
299
+ onFocus,
230
300
  onBlur
231
- }), null, 16, ["multiple", "class", "modelValue", "placeholder"])),
301
+ }), null, 16, ["disabled", "multiple", "class", "modelValue", "placeholder"])),
232
302
  createElementVNode("span", {
233
303
  class: normalizeClass([unref(cs).z("range")])
234
304
  }, toDisplayString(unref(props).rangeSeparator), 3),
235
305
  (openBlock(), createBlock(resolveDynamicComponent(pcompon.value), mergeProps(unref(props).config, {
306
+ disabled: unref(disabled),
236
307
  multiple: multiple.value,
237
308
  class: [unref(cs).z("value"), unref(cs).z("end")],
238
309
  modelValue: end.value,
@@ -241,23 +312,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
241
312
  _cache[3] || (_cache[3] = ($event) => onInput(1))
242
313
  ],
243
314
  placeholder: unref(props).endPlaceholder + (((_b = unref(props).config) == null ? void 0 : _b.placeholder) ?? ""),
244
- onClick: withModifiers(onFocus, ["stop"]),
315
+ onFocus,
245
316
  onBlur
246
- }), null, 16, ["multiple", "class", "modelValue", "placeholder"])),
247
- errer.value ? (openBlock(), createElementBlock("span", {
317
+ }), null, 16, ["disabled", "multiple", "class", "modelValue", "placeholder"])),
318
+ error.value ? (openBlock(), createElementBlock("span", {
248
319
  key: 0,
249
320
  class: normalizeClass([
250
321
  unref(cs).z("error"),
251
322
  unref(cs).is("clear", isclear.value),
252
- "type-" + ((_c = errer.value) == null ? void 0 : _c.type)
323
+ "type-" + ((_c = error.value) == null ? void 0 : _c.type)
253
324
  ])
254
- }, toDisplayString(((_d = errer.value) == null ? void 0 : _d.message) ? errer.value.message : errer.value), 3)) : createCommentVNode("", true),
255
- createElementVNode("input", {
256
- class: normalizeClass(unref(cs).z("focus")),
257
- ref_key: "refInput",
258
- ref: refInput,
259
- onBlur
260
- }, null, 34),
325
+ }, toDisplayString(((_d = error.value) == null ? void 0 : _d.message) ? error.value.message : error.value), 3)) : createCommentVNode("", true),
261
326
  isclear.value ? (openBlock(), createElementBlock("span", {
262
327
  key: 1,
263
328
  class: normalizeClass([unref(cs).z("icon"), unref(cs).z("clear")]),
@@ -1 +1,2 @@
1
+ @use '../../icon/style/index2.scss' as *;
1
2
  @use '../index.scss' as *;
@@ -7,11 +7,12 @@ const provides = {
7
7
  const changes = [
8
8
  "Select",
9
9
  "Date",
10
- "Array",
11
10
  "Check",
12
11
  "Labels",
13
12
  "Switch",
14
- "Cascader"
13
+ "Cascader",
14
+ "Selector"
15
+ // 'Double',
15
16
  ];
16
17
  exports.changes = changes;
17
18
  exports.provides = provides;
@@ -5,11 +5,12 @@ const provides = {
5
5
  const changes = [
6
6
  "Select",
7
7
  "Date",
8
- "Array",
9
8
  "Check",
10
9
  "Labels",
11
10
  "Switch",
12
- "Cascader"
11
+ "Cascader",
12
+ "Selector"
13
+ // 'Double',
13
14
  ];
14
15
  export {
15
16
  changes,