@pixelium/web-vue 0.0.2 → 0.0.3-alpha
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 +42 -0
- package/README.zh.md +6 -3
- package/dist/font.css +1 -1
- package/dist/index.d.ts +1602 -248
- package/dist/normalize.css +2 -0
- package/dist/pixelium-vue-icon-hn.cjs +1 -1
- package/dist/pixelium-vue-icon-hn.css +2 -1
- package/dist/pixelium-vue-icon-hn.js +8533 -8154
- package/dist/pixelium-vue-icon-hn.umd.cjs +1 -1
- package/dist/pixelium-vue-icon-pa.cjs +1 -1
- package/dist/pixelium-vue-icon-pa.css +2 -1
- package/dist/pixelium-vue-icon-pa.js +10625 -10143
- package/dist/pixelium-vue-icon-pa.umd.cjs +1 -1
- package/dist/pixelium-vue.cjs +2 -2
- package/dist/pixelium-vue.css +2 -1
- package/dist/pixelium-vue.js +7407 -5852
- package/dist/pixelium-vue.umd.cjs +2 -2
- package/es/aside/index.css +1 -0
- package/es/aside/index.js +46 -151
- package/es/auto-complete/draw.d.ts +1 -1
- package/es/auto-complete/draw.js +26 -51
- package/es/auto-complete/index.css +92 -32
- package/es/auto-complete/index.d.ts +12 -15
- package/es/auto-complete/index.js +338 -400
- package/es/auto-complete/type.d.ts +25 -13
- package/es/avatar/css.js +2 -0
- package/es/avatar/draw.d.ts +2 -0
- package/es/avatar/draw.js +11 -0
- package/es/avatar/index.css +49 -0
- package/es/avatar/index.d.ts +15 -0
- package/es/avatar/index.js +110 -0
- package/es/avatar/type.d.ts +34 -0
- package/es/button/draw.d.ts +4 -4
- package/es/button/draw.js +213 -297
- package/es/button/index.css +40 -30
- package/es/button/index.d.ts +0 -4
- package/es/button/index.js +230 -256
- package/es/button/type.d.ts +3 -3
- package/es/button-group/index.css +0 -3
- package/es/button-group/index.d.ts +1 -2
- package/es/button-group/index.js +59 -31
- package/es/button-group/type.d.ts +21 -4
- package/es/checkbox/css.js +2 -0
- package/es/checkbox/draw.d.ts +4 -0
- package/es/checkbox/draw.js +46 -0
- package/es/checkbox/index.css +85 -0
- package/es/checkbox/index.d.ts +31 -0
- package/es/checkbox/index.js +206 -0
- package/es/checkbox/type.d.ts +88 -0
- package/es/checkbox-group/css.js +2 -0
- package/es/checkbox-group/index.css +20 -0
- package/es/checkbox-group/index.d.ts +23 -0
- package/es/checkbox-group/index.js +84 -0
- package/es/checkbox-group/type.d.ts +78 -0
- package/es/col/index.d.ts +2 -2
- package/es/col/index.js +43 -58
- package/es/container/index.css +1 -0
- package/es/container/index.js +18 -31
- package/es/divider/index.js +39 -53
- package/es/empty/index.css +4 -4
- package/es/empty/index.js +16 -71
- package/es/entry.js +102 -0
- package/es/footer/index.css +1 -0
- package/es/footer/index.js +31 -40
- package/es/form/css.js +1 -0
- package/es/form/index.d.ts +27 -0
- package/es/form/index.js +125 -0
- package/es/form/type.d.ts +238 -0
- package/es/form/use-form.d.ts +4 -0
- package/es/form/use-form.js +48 -0
- package/es/form-item/css.js +2 -0
- package/es/form-item/index.css +77 -0
- package/es/form-item/index.d.ts +37 -0
- package/es/form-item/index.js +318 -0
- package/es/form-item/type.d.ts +96 -0
- package/es/grid/index.js +56 -75
- package/es/grid-item/css.js +0 -1
- package/es/grid-item/index.d.ts +1 -1
- package/es/grid-item/index.js +85 -121
- package/es/header/index.css +1 -0
- package/es/header/index.js +31 -40
- package/es/icon/index.js +44 -55
- package/es/icons/css-hn.js +0 -1
- package/es/icons/css-pa.js +0 -1
- package/es/icons/icon-hn.js +10337 -15986
- package/es/icons/icon-pa.js +12573 -17447
- package/es/image/css.js +2 -0
- package/es/image/index.css +69 -0
- package/es/image/index.d.ts +35 -0
- package/es/image/index.js +199 -0
- package/es/image/type.d.ts +126 -0
- package/es/index.css +1 -515
- package/es/index.d.ts +22 -2
- package/es/index.js +144 -123
- package/es/input/draw.d.ts +1 -1
- package/es/input/draw.js +26 -51
- package/es/input/index.css +85 -33
- package/es/input/index.d.ts +9 -16
- package/es/input/index.js +319 -423
- package/es/input/type.d.ts +3 -3
- package/es/input-group/index.css +0 -1
- package/es/input-group/index.d.ts +2 -2
- package/es/input-group/index.js +66 -37
- package/es/input-group/type.d.ts +16 -4
- package/es/input-group-label/draw.d.ts +1 -1
- package/es/input-group-label/draw.js +26 -51
- package/es/input-group-label/index.css +33 -22
- package/es/input-group-label/index.d.ts +1 -4
- package/es/input-group-label/index.js +104 -127
- package/es/input-group-label/type.d.ts +3 -3
- package/es/input-number/draw.d.ts +1 -1
- package/es/input-number/draw.js +26 -51
- package/es/input-number/index.css +90 -35
- package/es/input-number/index.d.ts +9 -16
- package/es/input-number/index.js +428 -536
- package/es/input-number/type.d.ts +3 -3
- package/es/input-tag/draw.d.ts +1 -1
- package/es/input-tag/draw.js +26 -48
- package/es/input-tag/index.css +100 -33
- package/es/input-tag/index.d.ts +7 -13
- package/es/input-tag/index.js +442 -467
- package/es/input-tag/type.d.ts +24 -13
- package/es/link/index.js +75 -106
- package/es/main/index.css +4 -0
- package/es/main/index.d.ts +4 -1
- package/es/main/index.js +15 -15
- package/es/main/type.d.ts +7 -0
- package/es/mask/index.js +94 -115
- package/es/message/index.css +1 -1
- package/es/message/index.js +168 -346
- package/es/message-box/css.js +1 -1
- package/es/message-box/index.js +98 -114
- package/es/message-box/message-box-wrapped.js +33 -46
- package/es/message-box/message-box.js +79 -111
- package/es/option-list/index.css +13 -13
- package/es/option-list/index.d.ts +4 -31
- package/es/option-list/index.js +99 -167
- package/es/option-list/type.d.ts +5 -1
- package/es/pixelate/pixel.d.ts +5 -0
- package/es/pixelate/pixel.js +70 -0
- package/es/pixelate/pixelate.worker.d.ts +1 -0
- package/es/popover/index.d.ts +13 -99
- package/es/popover/index.js +75 -238
- package/es/popover/type.d.ts +7 -2
- package/es/popup/css.js +1 -0
- package/es/popup/index.d.ts +210 -0
- package/es/popup/index.js +203 -0
- package/es/popup/type.d.ts +105 -0
- package/es/popup-content/draw.d.ts +2 -2
- package/es/popup-content/draw.js +98 -143
- package/es/popup-content/index.css +11 -11
- package/es/popup-content/index.d.ts +1 -0
- package/es/popup-content/index.js +253 -1576
- package/es/popup-content/type.d.ts +1 -0
- package/es/popup-trigger/index.d.ts +8 -2
- package/es/popup-trigger/index.js +122 -95
- package/es/popup-trigger/type.d.ts +4 -1
- package/es/popup-wrapper/css.js +2 -0
- package/es/popup-wrapper/index.css +14 -0
- package/es/popup-wrapper/index.d.ts +18 -0
- package/es/popup-wrapper/index.js +67 -0
- package/es/popup-wrapper/type.d.ts +9 -0
- package/es/radio/css.js +1 -0
- package/es/radio/draw.d.ts +4 -0
- package/es/radio/draw.js +47 -0
- package/es/radio/index.d.ts +30 -0
- package/es/radio/index.js +190 -0
- package/es/radio/style.css +73 -0
- package/es/radio/type.d.ts +76 -0
- package/es/radio-group/css.js +2 -0
- package/es/radio-group/index.css +20 -0
- package/es/radio-group/index.d.ts +23 -0
- package/es/radio-group/index.js +77 -0
- package/es/radio-group/type.d.ts +77 -0
- package/es/row/index.js +56 -70
- package/es/select/draw.d.ts +1 -1
- package/es/select/draw.js +26 -51
- package/es/select/index.css +118 -36
- package/es/select/index.d.ts +14 -16
- package/es/select/index.js +625 -672
- package/es/select/type.d.ts +60 -25
- package/es/share/const/event-bus-key.js +1 -6
- package/es/share/const/index.d.ts +4 -0
- package/es/share/const/index.js +22 -24
- package/es/share/const/provide-key.d.ts +5 -0
- package/es/share/const/provide-key.js +6 -5
- package/es/share/const/style.d.ts +6 -0
- package/es/share/const/style.js +7 -0
- package/es/share/hook/use-cancelable-delay.d.ts +1 -0
- package/es/share/hook/use-cancelable-delay.js +42 -0
- package/es/share/hook/use-click-outside-listener.d.ts +1 -1
- package/es/share/hook/use-click-outside-listener.js +28 -41
- package/es/share/hook/use-composition.js +17 -15
- package/es/share/hook/use-controlled-mode.d.ts +3 -3
- package/es/share/hook/use-controlled-mode.js +20 -23
- package/es/share/hook/use-dark-mode.js +51 -65
- package/es/share/hook/use-index-of-children.d.ts +2 -1
- package/es/share/hook/use-index-of-children.js +47 -45
- package/es/share/hook/use-lazy-load.d.ts +10 -0
- package/es/share/hook/use-lazy-load.js +133 -0
- package/es/share/hook/use-props-detect.d.ts +2 -0
- package/es/share/hook/use-resize-observer.d.ts +1 -2
- package/es/share/hook/use-resize-observer.js +28 -20
- package/es/share/hook/use-screen-width.js +27 -36
- package/es/share/hook/use-smooth-transition.d.ts +2 -0
- package/es/share/hook/use-smooth-transition.js +65 -0
- package/es/share/hook/use-textarea-height.js +86 -92
- package/es/share/hook/use-theme-mode.js +41 -42
- package/es/share/hook/use-transition-end.d.ts +2 -0
- package/es/share/hook/use-transition-end.js +12 -0
- package/es/share/hook/use-watch-global-css-var.js +12 -16
- package/es/share/hook/use-window-resize-listener.d.ts +1 -0
- package/es/share/hook/use-window-resize-listener.js +15 -0
- package/es/share/hook/use-z-index.js +30 -27
- package/es/share/style/index.css +5 -0
- package/es/share/type/index.d.ts +18 -3
- package/es/share/util/color.d.ts +5 -3
- package/es/share/util/color.js +156 -149
- package/es/share/util/common.d.ts +7 -2
- package/es/share/util/common.js +127 -65
- package/es/share/util/console.d.ts +3 -3
- package/es/share/util/console.js +10 -7
- package/es/share/util/dom.d.ts +19 -0
- package/es/share/util/dom.js +88 -0
- package/es/share/util/env.d.ts +1 -0
- package/es/share/util/env.js +5 -4
- package/es/share/util/event-bus.js +3 -20
- package/es/share/util/lru-cache.js +29 -33
- package/es/share/util/pixel.d.ts +4 -0
- package/es/share/util/plot.d.ts +8 -3
- package/es/share/util/plot.js +457 -229
- package/es/share/util/reactivity.d.ts +8 -0
- package/es/share/util/reactivity.js +23 -0
- package/es/share/util/render.js +31 -41
- package/es/share/util/theme.d.ts +3 -0
- package/es/share/util/theme.js +77 -57
- package/es/slider/css.js +2 -0
- package/es/slider/draw.d.ts +25 -0
- package/es/slider/draw.js +113 -0
- package/es/slider/index.css +119 -0
- package/es/slider/index.d.ts +66 -0
- package/es/slider/index.js +503 -0
- package/es/slider/type.d.ts +162 -0
- package/es/slider/util.d.ts +37 -0
- package/es/slider/util.js +130 -0
- package/es/space/index.css +24 -29
- package/es/space/index.js +73 -97
- package/es/spin/index.css +18 -17
- package/es/spin/index.js +72 -102
- package/es/spin/type.d.ts +11 -5
- package/es/switch/css.js +2 -0
- package/es/switch/draw.d.ts +2 -0
- package/es/switch/draw.js +18 -0
- package/es/switch/index.css +121 -0
- package/es/switch/index.d.ts +42 -0
- package/es/switch/index.js +259 -0
- package/es/switch/type.d.ts +133 -0
- package/es/tag/draw.d.ts +2 -2
- package/es/tag/draw.js +80 -127
- package/es/tag/index.css +38 -22
- package/es/tag/index.d.ts +2 -2
- package/es/tag/index.js +121 -190
- package/es/tag/type.d.ts +3 -3
- package/es/text-outline/css.js +2 -0
- package/es/text-outline/index.css +4 -0
- package/es/text-outline/index.d.ts +17 -0
- package/es/text-outline/index.js +33 -0
- package/es/text-outline/type.d.ts +23 -0
- package/es/textarea/draw.js +9 -11
- package/es/textarea/index.css +37 -23
- package/es/textarea/index.d.ts +8 -14
- package/es/textarea/index.js +274 -262
- package/es/tooltip/index.d.ts +100 -4
- package/es/tooltip/index.js +70 -226
- package/es/tooltip/type.d.ts +7 -2
- package/es/vendor.js +504 -0
- package/es/virtual-list/css.js +2 -0
- package/es/virtual-list/index.css +25 -0
- package/es/virtual-list/index.d.ts +11 -0
- package/es/virtual-list/index.js +313 -0
- package/es/virtual-list/type.d.ts +26 -0
- package/package.json +10 -16
- package/es/grid-item/index.css +0 -0
- /package/es/message-box/{message-box.css → index.css} +0 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import './css.js'
|
|
2
|
+
import { B as y, C as Pn, D as S, F as m, I as on, M as f, N as gn, R as tn, _ as E, b as Ln, g as A, k as Wn, w as Qn, y as Ge, z as v } from "../vendor.js";
|
|
3
|
+
import { a as isUrl } from "../share/util/common.js";
|
|
4
|
+
import { t as useResizeObserver } from "../share/hook/use-resize-observer.js";
|
|
5
|
+
import { a as FORM_PROVIDE, i as FORM_ITEM_PROVIDE } from "../share/const/provide-key.js";
|
|
6
|
+
import { t as createProvideComputed } from "../share/util/reactivity.js";
|
|
7
|
+
import { t as row_default } from "../row/index.js";
|
|
8
|
+
import { t as col_default } from "../col/index.js";
|
|
9
|
+
import { r as throwError } from "../share/util/console.js";
|
|
10
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, inject, mergeProps, nextTick, normalizeClass, onBeforeUnmount, onMounted, onUnmounted, openBlock, provide, ref, renderSlot, shallowRef, toDisplayString, unref, useId, useSlots, withCtx } from "vue";
|
|
11
|
+
var _hoisted_1 = {
|
|
12
|
+
key: 0,
|
|
13
|
+
class: "px-form-item-asterisk"
|
|
14
|
+
};
|
|
15
|
+
var _hoisted_2 = {
|
|
16
|
+
key: 1,
|
|
17
|
+
class: "px-form-item-asterisk"
|
|
18
|
+
};
|
|
19
|
+
var _hoisted_3 = {
|
|
20
|
+
key: 0,
|
|
21
|
+
class: "px-form-item-asterisk"
|
|
22
|
+
};
|
|
23
|
+
var _hoisted_4 = { class: "px-form-item-addition" };
|
|
24
|
+
var _hoisted_5 = {
|
|
25
|
+
key: 1,
|
|
26
|
+
class: "px-form-item-extra"
|
|
27
|
+
};
|
|
28
|
+
var form_item_default = /* @__PURE__ */ defineComponent({
|
|
29
|
+
name: "FormItem",
|
|
30
|
+
__name: "index",
|
|
31
|
+
props: {
|
|
32
|
+
field: null,
|
|
33
|
+
label: null,
|
|
34
|
+
rule: null,
|
|
35
|
+
disabled: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: void 0
|
|
38
|
+
},
|
|
39
|
+
readonly: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: void 0
|
|
42
|
+
},
|
|
43
|
+
labelAlign: { default: void 0 },
|
|
44
|
+
showAsterisk: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: void 0
|
|
47
|
+
},
|
|
48
|
+
asteriskPlacement: { default: void 0 },
|
|
49
|
+
rowProps: { default: void 0 },
|
|
50
|
+
labelProps: { default: void 0 },
|
|
51
|
+
contentProps: { default: void 0 }
|
|
52
|
+
},
|
|
53
|
+
setup(__props, { expose: __expose }) {
|
|
54
|
+
const props = __props;
|
|
55
|
+
const formContext = inject(FORM_PROVIDE, void 0);
|
|
56
|
+
if (!formContext) throwError("FormItem must be used inside Form.");
|
|
57
|
+
const disabledComputed = createProvideComputed("disabled", [formContext, props], "or");
|
|
58
|
+
const readonlyComputed = createProvideComputed("readonly", [formContext, props], "or");
|
|
59
|
+
const id = useId();
|
|
60
|
+
const slots = useSlots();
|
|
61
|
+
const IGNORE_CONTEXT_FIELDS = [
|
|
62
|
+
"model",
|
|
63
|
+
"rule",
|
|
64
|
+
"registerField",
|
|
65
|
+
"unregisterField",
|
|
66
|
+
"collectLabelWidth",
|
|
67
|
+
"removeLabelWidth"
|
|
68
|
+
];
|
|
69
|
+
const mergedProps = computed(() => {
|
|
70
|
+
return Qn(gn(Wn(formContext, IGNORE_CONTEXT_FIELDS), (e) => e.value), props);
|
|
71
|
+
});
|
|
72
|
+
const labelRef = shallowRef(null);
|
|
73
|
+
useResizeObserver(labelRef, () => {
|
|
74
|
+
if (!labelRef.value) return;
|
|
75
|
+
formContext.collectLabelWidth({
|
|
76
|
+
id,
|
|
77
|
+
width: labelRef.value.clientWidth
|
|
78
|
+
});
|
|
79
|
+
}, true);
|
|
80
|
+
onBeforeUnmount(() => {
|
|
81
|
+
formContext.removeLabelWidth(id);
|
|
82
|
+
});
|
|
83
|
+
let initValue = null;
|
|
84
|
+
const reset = async () => {
|
|
85
|
+
if (!props.field) return;
|
|
86
|
+
on(formContext.model.value, props.field, initValue);
|
|
87
|
+
await nextTick();
|
|
88
|
+
clearValidation();
|
|
89
|
+
};
|
|
90
|
+
const createFieldItem = () => {
|
|
91
|
+
return {
|
|
92
|
+
field: props.field,
|
|
93
|
+
validate: doValidate,
|
|
94
|
+
reset,
|
|
95
|
+
clearValidation
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
onMounted(() => {
|
|
99
|
+
if (props.field) {
|
|
100
|
+
formContext.registerField(createFieldItem());
|
|
101
|
+
initValue = f(formContext.model.value, props.field);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
onUnmounted(() => {
|
|
105
|
+
if (props.field) formContext.unregisterField(props.field);
|
|
106
|
+
});
|
|
107
|
+
const shouldShowAsterisk = computed(() => {
|
|
108
|
+
var _formContext$rules$va;
|
|
109
|
+
if (!mergedProps.value.showAsterisk) return;
|
|
110
|
+
if (!props.field) return false;
|
|
111
|
+
let rules = props.rule || ((_formContext$rules$va = formContext.rules.value) === null || _formContext$rules$va === void 0 ? void 0 : _formContext$rules$va[props.field]);
|
|
112
|
+
if (!rules) return false;
|
|
113
|
+
if (!S(rules)) rules = [rules];
|
|
114
|
+
return rules.some((rule) => rule.required);
|
|
115
|
+
});
|
|
116
|
+
const inputHandler = async () => {
|
|
117
|
+
if (!props.field) return;
|
|
118
|
+
await nextTick();
|
|
119
|
+
doValidate("input");
|
|
120
|
+
};
|
|
121
|
+
const blurHandler = async () => {
|
|
122
|
+
if (!props.field) return;
|
|
123
|
+
await nextTick();
|
|
124
|
+
doValidate("blur");
|
|
125
|
+
};
|
|
126
|
+
const changeHandler = async () => {
|
|
127
|
+
if (!props.field) return;
|
|
128
|
+
await nextTick();
|
|
129
|
+
doValidate("change");
|
|
130
|
+
};
|
|
131
|
+
const formatTipMessage = (nextMessage) => {
|
|
132
|
+
return {
|
|
133
|
+
message: (nextMessage === null || nextMessage === void 0 ? void 0 : nextMessage.message) || "",
|
|
134
|
+
level: !(nextMessage === null || nextMessage === void 0 ? void 0 : nextMessage.message) ? "normal" : (nextMessage === null || nextMessage === void 0 ? void 0 : nextMessage.level) || "normal"
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
const tipMessage = ref(formatTipMessage());
|
|
138
|
+
const clearValidation = () => {
|
|
139
|
+
tipMessage.value = formatTipMessage();
|
|
140
|
+
};
|
|
141
|
+
const provideStatus = computed(() => {
|
|
142
|
+
return tipMessage.value.level;
|
|
143
|
+
});
|
|
144
|
+
provide(FORM_ITEM_PROVIDE, {
|
|
145
|
+
size: formContext.size,
|
|
146
|
+
disabled: disabledComputed,
|
|
147
|
+
readonly: readonlyComputed,
|
|
148
|
+
changeHandler,
|
|
149
|
+
blurHandler,
|
|
150
|
+
inputHandler,
|
|
151
|
+
status: provideStatus
|
|
152
|
+
});
|
|
153
|
+
const doValidate = async (trigger) => {
|
|
154
|
+
var _formContext$rules$va2;
|
|
155
|
+
if (!props.field) {
|
|
156
|
+
tipMessage.value = formatTipMessage();
|
|
157
|
+
return tipMessage.value;
|
|
158
|
+
}
|
|
159
|
+
let rules = props.rule || ((_formContext$rules$va2 = formContext.rules.value) === null || _formContext$rules$va2 === void 0 ? void 0 : _formContext$rules$va2[props.field]);
|
|
160
|
+
if (!rules) {
|
|
161
|
+
tipMessage.value = formatTipMessage();
|
|
162
|
+
return tipMessage.value;
|
|
163
|
+
}
|
|
164
|
+
if (!S(rules)) rules = [rules];
|
|
165
|
+
const value = f(formContext.model.value, props.field);
|
|
166
|
+
const currentRules = trigger ? rules.filter((rule) => rule.trigger ? S(rule.trigger) ? rule.trigger.includes(trigger) : rule.trigger === trigger : trigger === "change" || trigger === "blur") : rules;
|
|
167
|
+
if (currentRules.length === 0) return tipMessage.value;
|
|
168
|
+
for (const rule of currentRules) {
|
|
169
|
+
if (rule.validator) try {
|
|
170
|
+
tipMessage.value = formatTipMessage({
|
|
171
|
+
message: await Promise.resolve(rule.validator(value, formContext.model)),
|
|
172
|
+
level: rule.level || "error"
|
|
173
|
+
});
|
|
174
|
+
return tipMessage.value;
|
|
175
|
+
} catch {
|
|
176
|
+
tipMessage.value = formatTipMessage({
|
|
177
|
+
message: rule.message ?? `${props.field} didn't pass the check.`,
|
|
178
|
+
level: rule.level || "error"
|
|
179
|
+
});
|
|
180
|
+
return tipMessage.value;
|
|
181
|
+
}
|
|
182
|
+
if (rule.required && Ln(value)) {
|
|
183
|
+
tipMessage.value = formatTipMessage({
|
|
184
|
+
message: rule.message ?? `${props.field} is required`,
|
|
185
|
+
level: rule.level || "error"
|
|
186
|
+
});
|
|
187
|
+
return tipMessage.value;
|
|
188
|
+
}
|
|
189
|
+
if (rule.type) {
|
|
190
|
+
if (!(Array.isArray(rule.type) ? rule.type : [rule.type]).some((t) => {
|
|
191
|
+
switch (t) {
|
|
192
|
+
case "number": return A(value) && !isNaN(value);
|
|
193
|
+
case "string": return y(value);
|
|
194
|
+
case "boolean": return Pn(value);
|
|
195
|
+
case "array": return S(value);
|
|
196
|
+
case "dict": return tn(value) && !S(value);
|
|
197
|
+
case "function": return m(value);
|
|
198
|
+
case "date": return value instanceof Date && !isNaN(value.getTime());
|
|
199
|
+
default: return true;
|
|
200
|
+
}
|
|
201
|
+
})) {
|
|
202
|
+
tipMessage.value = formatTipMessage({
|
|
203
|
+
message: rule.message ?? `${props.field} type mismatch`,
|
|
204
|
+
level: rule.level || "error"
|
|
205
|
+
});
|
|
206
|
+
return tipMessage.value;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (A(value)) {
|
|
210
|
+
if (!E(rule.min) && value < rule.min) {
|
|
211
|
+
tipMessage.value = formatTipMessage({
|
|
212
|
+
message: rule.message ?? `${props.field} must be >= ${rule.min}`,
|
|
213
|
+
level: rule.level || "error"
|
|
214
|
+
});
|
|
215
|
+
return tipMessage.value;
|
|
216
|
+
}
|
|
217
|
+
if (!E(rule.max) && value > rule.max) {
|
|
218
|
+
tipMessage.value = formatTipMessage({
|
|
219
|
+
message: rule.message ?? `${props.field} must be <= ${rule.max}`,
|
|
220
|
+
level: rule.level || "error"
|
|
221
|
+
});
|
|
222
|
+
return tipMessage.value;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (y(value) || S(value)) {
|
|
226
|
+
const len = value.length;
|
|
227
|
+
if (!E(rule.minLength) && len < rule.minLength) {
|
|
228
|
+
tipMessage.value = formatTipMessage({
|
|
229
|
+
message: rule.message ?? `${props.field} length must be >= ${rule.minLength}`,
|
|
230
|
+
level: rule.level || "error"
|
|
231
|
+
});
|
|
232
|
+
return tipMessage.value;
|
|
233
|
+
}
|
|
234
|
+
if (!E(rule.maxLength) && len > rule.maxLength) {
|
|
235
|
+
tipMessage.value = formatTipMessage({
|
|
236
|
+
message: rule.message ?? `${props.field} length must be <= ${rule.maxLength}`,
|
|
237
|
+
level: rule.level || "error"
|
|
238
|
+
});
|
|
239
|
+
return tipMessage.value;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (rule.email && !Ge(value)) {
|
|
243
|
+
tipMessage.value = formatTipMessage({
|
|
244
|
+
message: rule.message ?? `${props.field} is not a valid email.`,
|
|
245
|
+
level: rule.level || "error"
|
|
246
|
+
});
|
|
247
|
+
return tipMessage.value;
|
|
248
|
+
}
|
|
249
|
+
if (rule.url && !isUrl(value)) {
|
|
250
|
+
tipMessage.value = formatTipMessage({
|
|
251
|
+
message: rule.message ?? `${props.field} is not a valid URL.`,
|
|
252
|
+
level: rule.level || "error"
|
|
253
|
+
});
|
|
254
|
+
return tipMessage.value;
|
|
255
|
+
}
|
|
256
|
+
if (rule.numberString && !v(value)) {
|
|
257
|
+
tipMessage.value = formatTipMessage({
|
|
258
|
+
message: rule.message ?? `${props.field} is not a valid numeric string.`,
|
|
259
|
+
level: rule.level || "error"
|
|
260
|
+
});
|
|
261
|
+
return tipMessage.value;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
tipMessage.value = formatTipMessage();
|
|
265
|
+
return tipMessage.value;
|
|
266
|
+
};
|
|
267
|
+
__expose({ validate: doValidate });
|
|
268
|
+
return (_ctx, _cache) => {
|
|
269
|
+
return openBlock(), createBlock(row_default, mergeProps({
|
|
270
|
+
class: "px-form-item",
|
|
271
|
+
gutter: {
|
|
272
|
+
x: 16,
|
|
273
|
+
y: 8
|
|
274
|
+
}
|
|
275
|
+
}, mergedProps.value.rowProps), {
|
|
276
|
+
default: withCtx(() => [__props.label || unref(slots).label ? (openBlock(), createBlock(col_default, mergeProps({
|
|
277
|
+
key: 0,
|
|
278
|
+
span: mergedProps.value.labelAlign === "top" ? 24 : 6,
|
|
279
|
+
class: ["px-form-item-label-wrapper", { "px-form-item-label-wrapper__auto": mergedProps.value.labelAutoWidth }],
|
|
280
|
+
style: { width: mergedProps.value.labelAutoWidth ? `${unref(formContext).maxLabelWidth.value}px` : void 0 }
|
|
281
|
+
}, mergedProps.value.labelProps), {
|
|
282
|
+
default: withCtx(() => [createElementVNode("label", {
|
|
283
|
+
class: normalizeClass(["px-form-item-label", {
|
|
284
|
+
"px-form-item-label__auto": mergedProps.value.labelAutoWidth,
|
|
285
|
+
[`px-form-item-label__${mergedProps.value.labelAlign}`]: mergedProps.value.labelAlign && mergedProps.value.labelAlign !== "top",
|
|
286
|
+
[`px-form-item-label__${mergedProps.value.size}`]: mergedProps.value.size
|
|
287
|
+
}]),
|
|
288
|
+
ref_key: "labelRef",
|
|
289
|
+
ref: labelRef
|
|
290
|
+
}, [
|
|
291
|
+
shouldShowAsterisk.value && mergedProps.value.asteriskPlacement === "left" ? (openBlock(), createElementBlock("span", _hoisted_1, " *\xA0 ")) : createCommentVNode("v-if", true),
|
|
292
|
+
renderSlot(_ctx.$slots, "label", {}, () => [createElementVNode("span", null, toDisplayString(__props.label), 1)]),
|
|
293
|
+
shouldShowAsterisk.value && mergedProps.value.asteriskPlacement === "right" ? (openBlock(), createElementBlock("span", _hoisted_2, " \xA0* ")) : createCommentVNode("v-if", true)
|
|
294
|
+
], 2)]),
|
|
295
|
+
_: 3
|
|
296
|
+
}, 16, [
|
|
297
|
+
"span",
|
|
298
|
+
"class",
|
|
299
|
+
"style"
|
|
300
|
+
])) : createCommentVNode("v-if", true), createVNode(col_default, mergeProps({
|
|
301
|
+
span: mergedProps.value.labelAlign === "top" || !__props.label && !unref(slots).label ? 24 : 18,
|
|
302
|
+
class: ["px-form-item-content-wrapper", { "px-form-item-content-wrapper__auto": mergedProps.value.labelAutoWidth }]
|
|
303
|
+
}, mergedProps.value.contentProps), {
|
|
304
|
+
default: withCtx(() => [createElementVNode("div", { class: normalizeClass(["px-form-item-content", { [`px-form-item-content__${mergedProps.value.size}`]: mergedProps.value.size }]) }, [renderSlot(_ctx.$slots, "default"), shouldShowAsterisk.value && mergedProps.value.asteriskPlacement === "end" ? (openBlock(), createElementBlock("span", _hoisted_3, " \xA0* ")) : createCommentVNode("v-if", true)], 2), createElementVNode("div", _hoisted_4, [tipMessage.value.message || unref(slots).tip ? (openBlock(), createElementBlock("div", {
|
|
305
|
+
key: 0,
|
|
306
|
+
class: normalizeClass(["px-form-item-tip", { [`px-form-item-tip__${tipMessage.value.level}`]: tipMessage.value.level }])
|
|
307
|
+
}, [renderSlot(_ctx.$slots, "tip", {
|
|
308
|
+
message: tipMessage.value.message,
|
|
309
|
+
level: tipMessage.value.level
|
|
310
|
+
}, () => [createTextVNode(toDisplayString(tipMessage.value.message), 1)])], 2)) : createCommentVNode("v-if", true), unref(slots).extra ? (openBlock(), createElementBlock("div", _hoisted_5, [renderSlot(_ctx.$slots, "extra")])) : createCommentVNode("v-if", true)])]),
|
|
311
|
+
_: 3
|
|
312
|
+
}, 16, ["span", "class"])]),
|
|
313
|
+
_: 3
|
|
314
|
+
}, 16);
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
export { form_item_default as t };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Ref, ToRefs } from 'vue';
|
|
2
|
+
import type { ColProps } from '../col/type';
|
|
3
|
+
import type { RuleItem, RuleLevel } from '../form/type';
|
|
4
|
+
import type { RowProps } from '../row/type';
|
|
5
|
+
import type { LooseRequired } from '../share/type';
|
|
6
|
+
export type FormItemProps = {
|
|
7
|
+
/**
|
|
8
|
+
* @property {string} [field]
|
|
9
|
+
* @version 0.0.3
|
|
10
|
+
*/
|
|
11
|
+
field?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @property {string} [label]
|
|
14
|
+
* @version 0.0.3
|
|
15
|
+
*/
|
|
16
|
+
label?: string;
|
|
17
|
+
/**
|
|
18
|
+
* @property {RuleItem | RuleItem[]} [rule]
|
|
19
|
+
* @version 0.0.3
|
|
20
|
+
*/
|
|
21
|
+
rule?: RuleItem | RuleItem[];
|
|
22
|
+
/**
|
|
23
|
+
* @property {boolean} [disabled]
|
|
24
|
+
* @version 0.0.3
|
|
25
|
+
*/
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* @property {boolean} [readonly]
|
|
29
|
+
* @version 0.0.3
|
|
30
|
+
*/
|
|
31
|
+
readonly?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* @property {'left' | 'right' | 'top'} [labelAlign]
|
|
34
|
+
* @version 0.0.3
|
|
35
|
+
*/
|
|
36
|
+
labelAlign?: 'left' | 'right' | 'top';
|
|
37
|
+
/**
|
|
38
|
+
* @property {boolean} [showAsterisk]
|
|
39
|
+
* @version 0.0.3
|
|
40
|
+
*/
|
|
41
|
+
showAsterisk?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* @property {'left' | 'right' | 'end'} [asteriskPlacement]
|
|
44
|
+
* @version 0.0.3
|
|
45
|
+
*/
|
|
46
|
+
asteriskPlacement?: 'left' | 'right' | 'end';
|
|
47
|
+
/**
|
|
48
|
+
* @property {RowProps} [rowProps]
|
|
49
|
+
* @version 0.0.3
|
|
50
|
+
*/
|
|
51
|
+
rowProps?: RowProps;
|
|
52
|
+
/**
|
|
53
|
+
* @property {ColProps} [labelProps]
|
|
54
|
+
* @version 0.0.3
|
|
55
|
+
*/
|
|
56
|
+
labelProps?: ColProps;
|
|
57
|
+
/**
|
|
58
|
+
* @property {ColProps} [contentProps]
|
|
59
|
+
* @version 0.0.3
|
|
60
|
+
*/
|
|
61
|
+
contentProps?: ColProps;
|
|
62
|
+
};
|
|
63
|
+
export type FormItemSlots = {
|
|
64
|
+
/**
|
|
65
|
+
* @slot tip
|
|
66
|
+
* @param {string} message
|
|
67
|
+
* @param {RuleLevel} level
|
|
68
|
+
* @version 0.0.3
|
|
69
|
+
*/
|
|
70
|
+
tip: {};
|
|
71
|
+
/**
|
|
72
|
+
* @slot extra
|
|
73
|
+
* @version 0.0.3
|
|
74
|
+
*/
|
|
75
|
+
extra: {};
|
|
76
|
+
/**
|
|
77
|
+
* @slot label
|
|
78
|
+
* @version 0.0.3
|
|
79
|
+
*/
|
|
80
|
+
label: {};
|
|
81
|
+
/**
|
|
82
|
+
* @slot default
|
|
83
|
+
* @version 0.0.3
|
|
84
|
+
*/
|
|
85
|
+
default: {};
|
|
86
|
+
};
|
|
87
|
+
export type FormItemProvide = {
|
|
88
|
+
changeHandler: () => Promise<void>;
|
|
89
|
+
blurHandler: () => Promise<void>;
|
|
90
|
+
inputHandler: () => Promise<void>;
|
|
91
|
+
status: Ref<RuleLevel>;
|
|
92
|
+
} & ToRefs<LooseRequired<{
|
|
93
|
+
size: 'small' | 'medium' | 'large' | undefined;
|
|
94
|
+
disabled?: boolean;
|
|
95
|
+
readonly?: boolean;
|
|
96
|
+
}>>;
|
package/es/grid/index.js
CHANGED
|
@@ -1,77 +1,58 @@
|
|
|
1
1
|
import './css.js'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return openBlock(), createElementBlock(
|
|
58
|
-
"div",
|
|
59
|
-
{
|
|
60
|
-
class: "pixelium px-grid",
|
|
61
|
-
style: normalizeStyle({
|
|
62
|
-
gridTemplateColumns: `repeat(${columnComputed.value}, minmax(0, 1fr))`,
|
|
63
|
-
gap: gutterComputed.value ? `${gutterComputed.value.y}px ${gutterComputed.value.x}px` : void 0
|
|
64
|
-
})
|
|
65
|
-
},
|
|
66
|
-
[
|
|
67
|
-
renderSlot(_ctx.$slots, "default")
|
|
68
|
-
],
|
|
69
|
-
4
|
|
70
|
-
/* STYLE */
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
|
-
}
|
|
2
|
+
import { g as A, w as Qn } from "../vendor.js";
|
|
3
|
+
import { r as GRID_UPDATE } from "../share/const/event-bus-key.js";
|
|
4
|
+
import { t as emitParentUpdate } from "../share/hook/use-index-of-children.js";
|
|
5
|
+
import { o as GRID_PROVIDE } from "../share/const/provide-key.js";
|
|
6
|
+
import { t as useScreenWidth } from "../share/hook/use-screen-width.js";
|
|
7
|
+
import { computed, createElementBlock, defineComponent, normalizeStyle, openBlock, provide, ref, renderSlot } from "vue";
|
|
8
|
+
var grid_default = /* @__PURE__ */ defineComponent({
|
|
9
|
+
name: "Grid",
|
|
10
|
+
__name: "index",
|
|
11
|
+
props: {
|
|
12
|
+
column: { default: 24 },
|
|
13
|
+
gutter: { default: 0 }
|
|
14
|
+
},
|
|
15
|
+
setup(__props) {
|
|
16
|
+
const props = __props;
|
|
17
|
+
const [widthType] = useScreenWidth();
|
|
18
|
+
const gutterComputed = computed(() => {
|
|
19
|
+
if (A(props.gutter)) return {
|
|
20
|
+
x: props.gutter,
|
|
21
|
+
y: props.gutter
|
|
22
|
+
};
|
|
23
|
+
if ("x" in props.gutter || "y" in props.gutter) return {
|
|
24
|
+
x: props.gutter.x || 0,
|
|
25
|
+
y: props.gutter.y || 0
|
|
26
|
+
};
|
|
27
|
+
const currentGutter = props.gutter[widthType.value];
|
|
28
|
+
if (A(currentGutter)) return {
|
|
29
|
+
x: currentGutter,
|
|
30
|
+
y: currentGutter
|
|
31
|
+
};
|
|
32
|
+
return Qn({
|
|
33
|
+
x: 0,
|
|
34
|
+
y: 0
|
|
35
|
+
}, currentGutter);
|
|
36
|
+
});
|
|
37
|
+
const columnComputed = computed(() => {
|
|
38
|
+
if (A(props.column)) return props.column;
|
|
39
|
+
return props.column[widthType.value] || 24;
|
|
40
|
+
});
|
|
41
|
+
provide(GRID_PROVIDE, {
|
|
42
|
+
column: columnComputed,
|
|
43
|
+
gutter: gutterComputed,
|
|
44
|
+
itemsStat: ref([])
|
|
45
|
+
});
|
|
46
|
+
emitParentUpdate(GRID_UPDATE);
|
|
47
|
+
return (_ctx, _cache) => {
|
|
48
|
+
return openBlock(), createElementBlock("div", {
|
|
49
|
+
class: "pixelium px-grid",
|
|
50
|
+
style: normalizeStyle({
|
|
51
|
+
gridTemplateColumns: `repeat(${columnComputed.value}, minmax(0, 1fr))`,
|
|
52
|
+
gap: gutterComputed.value ? `${gutterComputed.value.y}px ${gutterComputed.value.x}px` : void 0
|
|
53
|
+
})
|
|
54
|
+
}, [renderSlot(_ctx.$slots, "default")], 4);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
74
57
|
});
|
|
75
|
-
export {
|
|
76
|
-
_sfc_main as _
|
|
77
|
-
};
|
|
58
|
+
export { grid_default as t };
|
package/es/grid-item/css.js
CHANGED
package/es/grid-item/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ type __VLS_Slots = {} & {
|
|
|
4
4
|
default?: (props: typeof __VLS_1) => any;
|
|
5
5
|
};
|
|
6
6
|
declare const __VLS_component: import("vue").DefineComponent<GridItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<GridItemProps> & Readonly<{}>, {
|
|
7
|
-
offset: number | import("
|
|
7
|
+
offset: number | import("..").ValueWithDeviceWidth<number>;
|
|
8
8
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
9
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
10
10
|
export default _default;
|