@fangzhongya/fang-ui 0.1.46 → 0.1.47
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/dist/components/cascaders/index.css +6 -0
- package/dist/components/cascaders/index.scss +6 -0
- package/dist/components/common/compons/components.cjs +0 -16
- package/dist/components/common/compons/components.d.ts +0 -8
- package/dist/components/common/compons/components.js +0 -16
- package/dist/components/common/compons/index.scss +0 -8
- package/dist/components/common/compons/index2.scss +0 -8
- package/dist/components/date-picker/style/element.scss +1 -1
- package/dist/components/dates-divide/index.css +6 -0
- package/dist/components/dates-divide/index.scss +6 -0
- package/dist/components/dates-divide/src/index2.cjs +4 -2
- package/dist/components/dates-divide/src/index2.js +4 -2
- package/dist/components/dates-picker/index.css +2 -2
- package/dist/components/dates-picker/index.scss +4 -4
- package/dist/components/dates-picker/src/index2.cjs +2 -1
- package/dist/components/dates-picker/src/index2.js +2 -1
- package/dist/components/dates2/index.css +9 -0
- package/dist/components/dates2/index.scss +3 -0
- package/dist/components/dates2/src/index2.cjs +6 -4
- package/dist/components/dates2/src/index2.js +6 -4
- package/dist/components/double/index.css +45 -10
- package/dist/components/double/index.scss +30 -17
- package/dist/components/double/src/data.cjs +24 -5
- package/dist/components/double/src/data.d.ts +23 -1
- package/dist/components/double/src/data.js +24 -5
- package/dist/components/double/src/index2.cjs +129 -64
- package/dist/components/double/src/index2.js +126 -61
- package/dist/components/double/style/index2.scss +1 -0
- package/dist/components/forms/common/config.cjs +3 -2
- package/dist/components/forms/common/config.js +3 -2
- package/dist/components/forms/index.css +74 -162
- package/dist/components/forms/src/util.cjs +30 -33
- package/dist/components/forms/src/util.js +29 -32
- package/dist/components/forms-item/index.css +3 -0
- package/dist/components/forms-item/index.scss +5 -0
- package/dist/components/forms-items/index.css +3 -0
- package/dist/components/input-history/index.css +3 -0
- package/dist/components/input-history/index.scss +3 -1
- package/dist/components/input-history/src/data.d.ts +1 -0
- package/dist/components/input-history/src/index2.cjs +23 -19
- package/dist/components/input-history/src/index2.js +15 -11
- package/dist/components/input-select/index.css +35 -7
- package/dist/components/input-select/index.scss +10 -7
- package/dist/components/input-select/src/index2.cjs +26 -19
- package/dist/components/input-select/src/index2.js +23 -16
- package/dist/components/input-select/style/index2.scss +2 -1
- package/dist/components/list/src/index2.cjs +5 -0
- package/dist/components/list/src/index2.js +6 -1
- package/dist/components/page/index.css +74 -162
- package/dist/components/scss/function.scss +3 -1
- package/dist/components/select-scroll/src/index2.cjs +1 -1
- package/dist/components/select-scroll/src/index2.js +2 -2
- package/dist/components/selector/index.css +50 -10
- package/dist/components/selector/index.scss +5 -0
- package/dist/components/selector/src/data.cjs +7 -3
- package/dist/components/selector/src/data.d.ts +8 -4
- package/dist/components/selector/src/data.js +7 -3
- package/dist/components/selector/src/index2.cjs +127 -91
- package/dist/components/selector/src/index2.js +124 -88
- package/dist/components/tables/common/pagin.d.ts +4 -4
- package/dist/components/tables/src/index2.cjs +9 -3
- package/dist/components/tables/src/index2.js +10 -4
- package/dist/components/tablesv/src/index2.cjs +9 -3
- package/dist/components/tablesv/src/index2.js +10 -4
- package/dist/css/cascaders.css +6 -0
- package/dist/css/dates-divide.css +6 -0
- package/dist/css/dates-picker.css +2 -2
- package/dist/css/dates2.css +9 -0
- package/dist/css/double.css +45 -10
- package/dist/css/forms-item.css +3 -0
- package/dist/css/forms-items.css +3 -0
- package/dist/css/forms.css +74 -162
- package/dist/css/index.css +227 -186
- package/dist/css/input-history.css +3 -0
- package/dist/css/input-select.css +35 -7
- package/dist/css/page.css +74 -162
- package/dist/css/selector.css +50 -10
- package/dist/icons/index.json +1 -1
- package/dist/index.css +227 -186
- package/dist/type.d.ts +2 -2
- package/package.json +2 -2
- /package/dist/components/{global-config → alert}/index.css +0 -0
- /package/dist/css/{global-config.css → alert.css} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { defineComponent,
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
()
|
|
94
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
175
|
-
|
|
214
|
+
if (!isEqual(v, props.modelValue)) {
|
|
215
|
+
emit("update:modelValue", v);
|
|
216
|
+
emit("change", v);
|
|
217
|
+
validateEvent();
|
|
218
|
+
}
|
|
176
219
|
} else {
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
227
|
+
function onClick(...arr) {
|
|
228
|
+
if (!disabled.value) {
|
|
229
|
+
if (!isfocus.value) {
|
|
230
|
+
isfocus.value = true;
|
|
231
|
+
emit("focus", ...arr);
|
|
232
|
+
}
|
|
185
233
|
}
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
function onFocus() {
|
|
189
|
-
isfocus.value = true;
|
|
190
|
-
clearBlur();
|
|
234
|
+
emit("click", ...arr);
|
|
191
235
|
}
|
|
192
|
-
|
|
193
|
-
function
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
|
199
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
315
|
+
onFocus,
|
|
245
316
|
onBlur
|
|
246
|
-
}), null, 16, ["multiple", "class", "modelValue", "placeholder"])),
|
|
247
|
-
|
|
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 =
|
|
323
|
+
"type-" + ((_c = error.value) == null ? void 0 : _c.type)
|
|
253
324
|
])
|
|
254
|
-
}, toDisplayString(((_d =
|
|
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")]),
|