@kernel4632/kima 0.0.0-stage → 0.6.0
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/LICENSE +21 -0
- package/README.md +166 -2
- package/dist/THIRD_PARTY_NOTICES.txt +2676 -0
- package/dist/kima-elements-core.js +53209 -0
- package/dist/kima-elements.js +126371 -0
- package/dist/kima-theme.js +1583 -0
- package/dist/kima.js +141 -0
- package/dist/style.css +2 -0
- package/dist/vue/_virtual/_plugin-vue_export-helper.js +7 -0
- package/dist/vue/components/advanced-input/calendar.ce.js +216 -0
- package/dist/vue/components/advanced-input/date-range-picker.ce.js +224 -0
- package/dist/vue/components/advanced-input/editable.ce.js +160 -0
- package/dist/vue/components/advanced-input/mention.ce.js +181 -0
- package/dist/vue/components/advanced-input/range-slider.ce.js +111 -0
- package/dist/vue/components/advanced-input/time-range-picker.ce.js +120 -0
- package/dist/vue/components/advanced-input/transfer.ce.js +192 -0
- package/dist/vue/components/content/chart.ce.js +282 -0
- package/dist/vue/components/content/code-editor.ce.js +309 -0
- package/dist/vue/components/content/equation.ce.js +69 -0
- package/dist/vue/components/content/heatmap.ce.js +148 -0
- package/dist/vue/components/content/rich-text-editor.ce.js +319 -0
- package/dist/vue/components/core/badge.ce.js +66 -0
- package/dist/vue/components/core/button-group.ce.js +142 -0
- package/dist/vue/components/core/button.ce.js +73 -0
- package/dist/vue/components/core/card.ce.js +73 -0
- package/dist/vue/components/core/cascader.ce.js +329 -0
- package/dist/vue/components/core/checkbox.ce.js +116 -0
- package/dist/vue/components/core/code-block.ce.js +108 -0
- package/dist/vue/components/core/combobox.ce.js +354 -0
- package/dist/vue/components/core/date-picker.ce.js +433 -0
- package/dist/vue/components/core/dialog.ce.js +118 -0
- package/dist/vue/components/core/divider.ce.js +49 -0
- package/dist/vue/components/core/drawer.ce.js +235 -0
- package/dist/vue/components/core/empty-state.ce.js +58 -0
- package/dist/vue/components/core/icon-button.ce.js +93 -0
- package/dist/vue/components/core/icon.ce.js +42 -0
- package/dist/vue/components/core/layout.ce.js +68 -0
- package/dist/vue/components/core/menu.ce.js +178 -0
- package/dist/vue/components/core/notification.ce.js +158 -0
- package/dist/vue/components/core/pagination.ce.js +158 -0
- package/dist/vue/components/core/progress.ce.js +49 -0
- package/dist/vue/components/core/select.ce.js +325 -0
- package/dist/vue/components/core/slider.ce.js +116 -0
- package/dist/vue/components/core/switch.ce.js +100 -0
- package/dist/vue/components/core/tabs.ce.js +193 -0
- package/dist/vue/components/core/text-field.ce.js +194 -0
- package/dist/vue/components/core/time-picker.ce.js +486 -0
- package/dist/vue/components/core/tooltip.ce.js +125 -0
- package/dist/vue/components/core/tree.ce.js +248 -0
- package/dist/vue/components/core/virtual-scroll.ce.js +176 -0
- package/dist/vue/components/data/copy-button.ce.js +75 -0
- package/dist/vue/components/data/image-preview.ce.js +226 -0
- package/dist/vue/components/data/infinite-scroll.ce.js +126 -0
- package/dist/vue/components/data/long-text.ce.js +70 -0
- package/dist/vue/components/data/relative-time.ce.js +77 -0
- package/dist/vue/components/data/ring-progress.ce.js +87 -0
- package/dist/vue/components/data/table.ce.js +491 -0
- package/dist/vue/components/data/virtual-table.ce.js +178 -0
- package/dist/vue/components/data/virtual-tree.ce.js +213 -0
- package/dist/vue/components/display/alert.ce.js +101 -0
- package/dist/vue/components/display/avatar-group.ce.js +65 -0
- package/dist/vue/components/display/avatar.ce.js +84 -0
- package/dist/vue/components/display/blockquote.ce.js +44 -0
- package/dist/vue/components/display/countdown.ce.js +77 -0
- package/dist/vue/components/display/descriptions.ce.js +43 -0
- package/dist/vue/components/display/highlight.ce.js +48 -0
- package/dist/vue/components/display/image.ce.js +146 -0
- package/dist/vue/components/display/list.ce.js +68 -0
- package/dist/vue/components/display/result.ce.js +57 -0
- package/dist/vue/components/display/skeleton.ce.js +67 -0
- package/dist/vue/components/display/spinner.ce.js +42 -0
- package/dist/vue/components/display/statistic.ce.js +71 -0
- package/dist/vue/components/display/timeline.ce.js +59 -0
- package/dist/vue/components/form-completion/angle-slider.ce.js +103 -0
- package/dist/vue/components/form-completion/color-picker.ce.js +286 -0
- package/dist/vue/components/form-completion/date-field.ce.js +131 -0
- package/dist/vue/components/form-completion/dynamic-input.ce.js +158 -0
- package/dist/vue/components/form-completion/form.ce.js +248 -0
- package/dist/vue/components/form-completion/json-input.ce.js +114 -0
- package/dist/vue/components/form-completion/masked-input.ce.js +88 -0
- package/dist/vue/components/form-completion/period-picker.ce.js +147 -0
- package/dist/vue/components/form-completion/time-field.ce.js +120 -0
- package/dist/vue/components/form-completion/upload-manager.ce.js +223 -0
- package/dist/vue/components/foundation/banner.ce.js +106 -0
- package/dist/vue/components/foundation/error-state.ce.js +108 -0
- package/dist/vue/components/foundation/field-group.ce.js +146 -0
- package/dist/vue/components/foundation/flex.ce.js +60 -0
- package/dist/vue/components/foundation/grid.ce.js +52 -0
- package/dist/vue/components/foundation/input-group.ce.js +34 -0
- package/dist/vue/components/foundation/page-header.ce.js +55 -0
- package/dist/vue/components/foundation/time-display.ce.js +129 -0
- package/dist/vue/components/foundation/typography.ce.js +71 -0
- package/dist/vue/components/input/checkbox-group.ce.js +93 -0
- package/dist/vue/components/input/field.ce.js +74 -0
- package/dist/vue/components/input/file-upload.ce.js +142 -0
- package/dist/vue/components/input/number-field.ce.js +103 -0
- package/dist/vue/components/input/pin-input.ce.js +112 -0
- package/dist/vue/components/input/radio-group.ce.js +96 -0
- package/dist/vue/components/input/rating.ce.js +115 -0
- package/dist/vue/components/input/tags-input.ce.js +153 -0
- package/dist/vue/components/input/textarea.ce.js +180 -0
- package/dist/vue/components/input/toggle.ce.js +58 -0
- package/dist/vue/components/interaction/chip.ce.js +95 -0
- package/dist/vue/components/interaction/command.ce.js +161 -0
- package/dist/vue/components/interaction/context-menu.ce.js +113 -0
- package/dist/vue/components/interaction/hover-card.ce.js +92 -0
- package/dist/vue/components/interaction/loading-overlay.ce.js +70 -0
- package/dist/vue/components/interaction/menubar.ce.js +134 -0
- package/dist/vue/components/interaction/multi-select.ce.js +264 -0
- package/dist/vue/components/interaction/popconfirm.ce.js +95 -0
- package/dist/vue/components/interaction/popover.ce.js +83 -0
- package/dist/vue/components/interaction/tree-select.ce.js +195 -0
- package/dist/vue/components/navigation/accordion.ce.js +114 -0
- package/dist/vue/components/navigation/anchor.ce.js +125 -0
- package/dist/vue/components/navigation/back-top.ce.js +67 -0
- package/dist/vue/components/navigation/breadcrumb.ce.js +48 -0
- package/dist/vue/components/navigation/carousel.ce.js +114 -0
- package/dist/vue/components/navigation/collapsible.ce.js +57 -0
- package/dist/vue/components/navigation/link.ce.js +62 -0
- package/dist/vue/components/navigation/navigation-menu.ce.js +91 -0
- package/dist/vue/components/navigation/overflow-list.ce.js +67 -0
- package/dist/vue/components/navigation/scroll-area.ce.js +47 -0
- package/dist/vue/components/navigation/splitter.ce.js +131 -0
- package/dist/vue/components/navigation/stepper.ce.js +74 -0
- package/dist/vue/components/navigation/toolbar.ce.js +93 -0
- package/dist/vue/components/navigation/visually-hidden.ce.js +16 -0
- package/dist/vue/components/shell/app-shell.ce.js +87 -0
- package/dist/vue/components/shell/config-provider.ce.js +110 -0
- package/dist/vue/components/shell/marquee.ce.js +92 -0
- package/dist/vue/components/shell/masonry.ce.js +50 -0
- package/dist/vue/components/shell/sidebar.ce.js +125 -0
- package/dist/vue/components/utility/affix.ce.js +64 -0
- package/dist/vue/components/utility/alert-dialog.ce.js +124 -0
- package/dist/vue/components/utility/animated-number.ce.js +66 -0
- package/dist/vue/components/utility/float-button.ce.js +104 -0
- package/dist/vue/components/utility/listbox.ce.js +81 -0
- package/dist/vue/components/utility/loading-bar.ce.js +85 -0
- package/dist/vue/components/utility/log-viewer.ce.js +124 -0
- package/dist/vue/components/utility/notification-queue.ce.js +109 -0
- package/dist/vue/components/utility/progress-group.ce.js +59 -0
- package/dist/vue/components/utility/qr-code.ce.js +62 -0
- package/dist/vue/components/utility/tag-group.ce.js +124 -0
- package/dist/vue/components/utility/tour.ce.js +214 -0
- package/dist/vue/components/utility/virtual-select.ce.js +207 -0
- package/dist/vue/components/utility/watermark.ce.js +44 -0
- package/dist/vue/internal/menu-items.js +184 -0
- package/dist/vue/internal/navigation-items.js +110 -0
- package/dist/vue/utils/code-highlight.js +142 -0
- package/dist/vue/utils/config.js +47 -0
- package/dist/vue/utils/content-motion.js +37 -0
- package/dist/vue/utils/content.js +83 -0
- package/dist/vue/utils/display-status.js +31 -0
- package/dist/vue/utils/foundation.js +65 -0
- package/dist/vue/utils/input-state.js +38 -0
- package/dist/vue/utils/interaction.js +103 -0
- package/dist/vue/utils/local-date.js +48 -0
- package/dist/vue/utils/motion.js +80 -0
- package/dist/vue/utils/native-slots.js +30 -0
- package/dist/vue/utils/navigation.js +44 -0
- package/dist/vue/utils/notifications.js +60 -0
- package/dist/vue/utils/qr.js +20 -0
- package/dist/vue/utils/remote-options.js +65 -0
- package/dist/vue/utils/ripple.js +20 -0
- package/dist/vue/utils/scoped-slots.js +22 -0
- package/dist/vue/utils/shell.js +43 -0
- package/dist/vue/utils/theme.js +50 -0
- package/dist/vue/utils/utility-choice.js +56 -0
- package/package.json +99 -4
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { useRipple as e } from "../../utils/ripple.js";
|
|
2
|
+
import t from "../../_virtual/_plugin-vue_export-helper.js";
|
|
3
|
+
import { useInputState as n } from "../../utils/input-state.js";
|
|
4
|
+
import { civilDate as r, dateKey as i, formatDate as a, monthKey as o, normalizeDate as s, parseDate as c, shiftDay as l, shiftMonth as u, todayKey as d } from "../../utils/local-date.js";
|
|
5
|
+
import { useContentMotion as f } from "../../utils/content-motion.js";
|
|
6
|
+
/* empty css */
|
|
7
|
+
import { Fragment as p, computed as m, createCommentVNode as h, createElementBlock as g, createElementVNode as _, nextTick as v, normalizeClass as y, openBlock as b, ref as x, renderList as S, toDisplayString as C, unref as w, useId as T, watch as E, watchEffect as D, withModifiers as O } from "vue";
|
|
8
|
+
// src/components/advanced-input/calendar.ce.vue
|
|
9
|
+
var ee = ["aria-label"], te = { class: "kima-calendar__head" }, ne = ["disabled"], re = ["disabled"], k = {
|
|
10
|
+
role: "row",
|
|
11
|
+
class: "kima-calendar__row"
|
|
12
|
+
}, A = ["aria-selected"], j = [
|
|
13
|
+
"data-date",
|
|
14
|
+
"aria-label",
|
|
15
|
+
"aria-current",
|
|
16
|
+
"disabled",
|
|
17
|
+
"tabindex",
|
|
18
|
+
"onFocus",
|
|
19
|
+
"onClick",
|
|
20
|
+
"onKeydown"
|
|
21
|
+
], M = [
|
|
22
|
+
"name",
|
|
23
|
+
"value",
|
|
24
|
+
"required",
|
|
25
|
+
"disabled"
|
|
26
|
+
], N = /*#__PURE__*/ t({
|
|
27
|
+
__name: "calendar.ce",
|
|
28
|
+
props: {
|
|
29
|
+
modelValue: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: null
|
|
32
|
+
},
|
|
33
|
+
viewDate: String,
|
|
34
|
+
min: String,
|
|
35
|
+
max: String,
|
|
36
|
+
disabledDates: {
|
|
37
|
+
type: Array,
|
|
38
|
+
default: () => []
|
|
39
|
+
},
|
|
40
|
+
firstDay: {
|
|
41
|
+
type: Number,
|
|
42
|
+
default: 1
|
|
43
|
+
},
|
|
44
|
+
locale: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "zh-CN"
|
|
47
|
+
},
|
|
48
|
+
label: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: "日历"
|
|
51
|
+
},
|
|
52
|
+
name: String,
|
|
53
|
+
required: Boolean,
|
|
54
|
+
disabled: Boolean,
|
|
55
|
+
rangeStart: String,
|
|
56
|
+
rangeEnd: String,
|
|
57
|
+
hideNavigation: Boolean,
|
|
58
|
+
rangeMode: Boolean
|
|
59
|
+
},
|
|
60
|
+
emits: [
|
|
61
|
+
"update:modelValue",
|
|
62
|
+
"change",
|
|
63
|
+
"update:viewDate"
|
|
64
|
+
],
|
|
65
|
+
setup(t, { expose: N, emit: P }) {
|
|
66
|
+
let F = t, I = P, L = x(null), R = x(null), z = x(null), { local: B, update: V } = n(F, I, L, s);
|
|
67
|
+
e(L);
|
|
68
|
+
let H = `kima-calendar-${T()}`, U = x(d()), W = x(o(s(F.viewDate) || B.value || U.value)), G = x(B.value || U.value), K = m(() => (Math.floor(F.firstDay) % 7 + 7) % 7);
|
|
69
|
+
function q(e) {
|
|
70
|
+
return F.disabled || !!(s(F.min) && e < F.min || s(F.max) && e > F.max || F.disabledDates.includes(e));
|
|
71
|
+
}
|
|
72
|
+
let J = m(() => {
|
|
73
|
+
let e = (c(W.value).getDay() - K.value + 7) % 7;
|
|
74
|
+
return Array.from({ length: 42 }, (t, n) => {
|
|
75
|
+
let r = l(W.value, n - e);
|
|
76
|
+
return {
|
|
77
|
+
value: r,
|
|
78
|
+
day: Number(r.slice(-2)),
|
|
79
|
+
outside: r.slice(0, 7) !== W.value.slice(0, 7),
|
|
80
|
+
disabled: q(r)
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}), ie = m(() => Array.from({ length: 6 }, (e, t) => J.value.slice(t * 7, t * 7 + 7)));
|
|
84
|
+
f(z, () => W.value);
|
|
85
|
+
let ae = m(() => a(W.value, F.locale, {
|
|
86
|
+
month: "long",
|
|
87
|
+
year: "numeric"
|
|
88
|
+
})), oe = m(() => Array.from({ length: 7 }, (e, t) => a(i(r(2023, 0, 1 + K.value + t)), F.locale, { weekday: "short" }))), Y = m(() => J.value.find((e) => e.value === G.value && !e.disabled)?.value || J.value.find((e) => !e.outside && !e.disabled)?.value || J.value.find((e) => !e.disabled)?.value);
|
|
89
|
+
E(() => F.viewDate, (e) => {
|
|
90
|
+
s(e) && (W.value = o(e));
|
|
91
|
+
}), E(() => F.modelValue, (e) => {
|
|
92
|
+
s(e) && (G.value = e, F.viewDate || (W.value = o(e)));
|
|
93
|
+
}), D(() => {
|
|
94
|
+
R.value?.setCustomValidity(B.value && q(B.value) ? "日期不可用" : "");
|
|
95
|
+
}, { flush: "post" });
|
|
96
|
+
function X(e) {
|
|
97
|
+
W.value = o(e), I("update:viewDate", W.value);
|
|
98
|
+
}
|
|
99
|
+
function Z(e) {
|
|
100
|
+
let t = u(W.value, e), n = l(u(t, 1), -1);
|
|
101
|
+
return !(F.min && n < F.min || F.max && t > F.max);
|
|
102
|
+
}
|
|
103
|
+
function Q(e) {
|
|
104
|
+
!F.disabled && Z(e) && X(u(W.value, e));
|
|
105
|
+
}
|
|
106
|
+
async function $(e, t = 1) {
|
|
107
|
+
F.min && e < F.min && (e = F.min), F.max && e > F.max && (e = F.max);
|
|
108
|
+
for (let n = 0; n < 3660 && q(e); n += 1) {
|
|
109
|
+
let n = l(e, t);
|
|
110
|
+
if (F.min && n < F.min || F.max && n > F.max) return;
|
|
111
|
+
e = n;
|
|
112
|
+
}
|
|
113
|
+
q(e) || (G.value = e, e.slice(0, 7) !== W.value.slice(0, 7) && X(e), await v(), L.value?.querySelector(`[data-date="${e}"]`)?.focus());
|
|
114
|
+
}
|
|
115
|
+
function se(e, t) {
|
|
116
|
+
if (e.isComposing) return;
|
|
117
|
+
let n = {
|
|
118
|
+
ArrowLeft: -1,
|
|
119
|
+
ArrowRight: 1,
|
|
120
|
+
ArrowUp: -7,
|
|
121
|
+
ArrowDown: 7
|
|
122
|
+
}, r;
|
|
123
|
+
if (e.key in n) r = l(t.value, n[e.key]);
|
|
124
|
+
else if (["PageUp", "PageDown"].includes(e.key)) r = u(t.value, (e.key === "PageUp" ? -1 : 1) * (e.shiftKey ? 12 : 1));
|
|
125
|
+
else if (["Home", "End"].includes(e.key)) {
|
|
126
|
+
let n = (c(t.value).getDay() - K.value + 7) % 7;
|
|
127
|
+
r = l(t.value, e.key === "Home" ? -n : 6 - n);
|
|
128
|
+
}
|
|
129
|
+
r && (e.preventDefault(), $(r, r < t.value ? -1 : 1));
|
|
130
|
+
}
|
|
131
|
+
function ce(e) {
|
|
132
|
+
e.disabled || (G.value = e.value, V(e.value));
|
|
133
|
+
}
|
|
134
|
+
return N({
|
|
135
|
+
focus: () => $(Y.value || W.value),
|
|
136
|
+
navigate: Q
|
|
137
|
+
}), (e, n) => (b(), g("section", {
|
|
138
|
+
ref_key: "root",
|
|
139
|
+
ref: L,
|
|
140
|
+
class: "kima-calendar",
|
|
141
|
+
"aria-label": t.label
|
|
142
|
+
}, [
|
|
143
|
+
_("header", te, [
|
|
144
|
+
t.hideNavigation ? h("", !0) : (b(), g("button", {
|
|
145
|
+
key: 0,
|
|
146
|
+
class: "kima-calendar__nav",
|
|
147
|
+
type: "button",
|
|
148
|
+
"aria-label": "上一月",
|
|
149
|
+
disabled: t.disabled || !Z(-1),
|
|
150
|
+
onClick: n[0] ||= (e) => Q(-1)
|
|
151
|
+
}, "‹", 8, ne)),
|
|
152
|
+
_("h2", {
|
|
153
|
+
id: H,
|
|
154
|
+
"aria-live": "polite"
|
|
155
|
+
}, C(ae.value), 1),
|
|
156
|
+
t.hideNavigation ? h("", !0) : (b(), g("button", {
|
|
157
|
+
key: 1,
|
|
158
|
+
class: "kima-calendar__nav",
|
|
159
|
+
type: "button",
|
|
160
|
+
"aria-label": "下一月",
|
|
161
|
+
disabled: t.disabled || !Z(1),
|
|
162
|
+
onClick: n[1] ||= (e) => Q(1)
|
|
163
|
+
}, "›", 8, re))
|
|
164
|
+
]),
|
|
165
|
+
_("div", {
|
|
166
|
+
ref_key: "grid",
|
|
167
|
+
ref: z,
|
|
168
|
+
role: "grid",
|
|
169
|
+
"aria-labelledby": H,
|
|
170
|
+
class: "kima-calendar__grid"
|
|
171
|
+
}, [_("div", k, [(b(!0), g(p, null, S(oe.value, (e, t) => (b(), g("span", {
|
|
172
|
+
key: t,
|
|
173
|
+
role: "columnheader"
|
|
174
|
+
}, C(e), 1))), 128))]), (b(!0), g(p, null, S(ie.value, (e, n) => (b(), g("div", {
|
|
175
|
+
key: n,
|
|
176
|
+
role: "row",
|
|
177
|
+
class: "kima-calendar__row"
|
|
178
|
+
}, [(b(!0), g(p, null, S(e, (e) => (b(), g("div", {
|
|
179
|
+
key: e.value,
|
|
180
|
+
role: "gridcell",
|
|
181
|
+
"aria-selected": !t.rangeMode && e.value === w(B) || e.value === t.rangeStart || e.value === t.rangeEnd || !!(t.rangeStart && t.rangeEnd && e.value >= t.rangeStart && e.value <= t.rangeEnd)
|
|
182
|
+
}, [_("button", {
|
|
183
|
+
type: "button",
|
|
184
|
+
"data-date": e.value,
|
|
185
|
+
"aria-label": w(a)(e.value, t.locale, { dateStyle: "full" }),
|
|
186
|
+
"aria-current": e.value === U.value ? "date" : void 0,
|
|
187
|
+
disabled: e.disabled,
|
|
188
|
+
tabindex: e.value === Y.value ? 0 : -1,
|
|
189
|
+
class: y(["kima-calendar__day", {
|
|
190
|
+
"is-outside": e.outside,
|
|
191
|
+
"is-today": e.value === U.value,
|
|
192
|
+
"is-selected": !t.rangeMode && e.value === w(B) || e.value === t.rangeStart || e.value === t.rangeEnd,
|
|
193
|
+
"is-range": t.rangeStart && t.rangeEnd && e.value >= t.rangeStart && e.value <= t.rangeEnd
|
|
194
|
+
}]),
|
|
195
|
+
onFocus: (t) => G.value = e.value,
|
|
196
|
+
onClick: (t) => ce(e),
|
|
197
|
+
onKeydown: (t) => se(t, e)
|
|
198
|
+
}, C(e.day), 43, j)], 8, A))), 128))]))), 128))], 512),
|
|
199
|
+
_("input", {
|
|
200
|
+
ref_key: "native",
|
|
201
|
+
ref: R,
|
|
202
|
+
class: "kima-calendar__native",
|
|
203
|
+
type: "text",
|
|
204
|
+
name: t.name,
|
|
205
|
+
value: w(B) || "",
|
|
206
|
+
required: t.required,
|
|
207
|
+
disabled: t.disabled,
|
|
208
|
+
tabindex: "-1",
|
|
209
|
+
"aria-hidden": "true",
|
|
210
|
+
onInput: n[2] ||= O(() => {}, ["stop"]),
|
|
211
|
+
onInvalid: n[3] ||= O((e) => $(Y.value || W.value), ["prevent"])
|
|
212
|
+
}, null, 40, M)
|
|
213
|
+
], 8, ee));
|
|
214
|
+
}
|
|
215
|
+
}, [["__scopeId", "data-v-43a5d854"]]);
|
|
216
|
+
export { N as default };
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { useRipple as e } from "../../utils/ripple.js";
|
|
2
|
+
import t from "../../_virtual/_plugin-vue_export-helper.js";
|
|
3
|
+
import n from "../core/button.ce.js";
|
|
4
|
+
import { useInputState as r } from "../../utils/input-state.js";
|
|
5
|
+
import { monthKey as i, normalizeDate as a, shiftDay as o, shiftMonth as s, todayKey as c } from "../../utils/local-date.js";
|
|
6
|
+
import l from "./calendar.ce.js";
|
|
7
|
+
/* empty css */
|
|
8
|
+
import { computed as u, createCommentVNode as d, createElementBlock as f, createElementVNode as p, createTextVNode as m, createVNode as h, openBlock as g, ref as _, toDisplayString as v, unref as y, watchEffect as b, withCtx as x, withModifiers as S } from "vue";
|
|
9
|
+
// src/components/advanced-input/date-range-picker.ce.vue
|
|
10
|
+
var C = ["aria-disabled"], w = { class: "kima-date-range-picker__fields" }, T = [
|
|
11
|
+
"aria-label",
|
|
12
|
+
"name",
|
|
13
|
+
"value",
|
|
14
|
+
"min",
|
|
15
|
+
"max",
|
|
16
|
+
"required",
|
|
17
|
+
"disabled"
|
|
18
|
+
], E = [
|
|
19
|
+
"aria-label",
|
|
20
|
+
"name",
|
|
21
|
+
"value",
|
|
22
|
+
"min",
|
|
23
|
+
"max",
|
|
24
|
+
"required",
|
|
25
|
+
"disabled"
|
|
26
|
+
], D = { class: "kima-date-range-picker__navigation" }, O = { class: "kima-date-range-picker__months" }, k = {
|
|
27
|
+
key: 0,
|
|
28
|
+
role: "alert"
|
|
29
|
+
}, A = {
|
|
30
|
+
class: "kima-date-range-picker__status",
|
|
31
|
+
role: "status"
|
|
32
|
+
}, j = /*#__PURE__*/ t({
|
|
33
|
+
__name: "date-range-picker.ce",
|
|
34
|
+
props: {
|
|
35
|
+
modelValue: {
|
|
36
|
+
type: Array,
|
|
37
|
+
default: () => [null, null]
|
|
38
|
+
},
|
|
39
|
+
name: String,
|
|
40
|
+
startName: String,
|
|
41
|
+
endName: String,
|
|
42
|
+
startLabel: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: "开始日期"
|
|
45
|
+
},
|
|
46
|
+
endLabel: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: "结束日期"
|
|
49
|
+
},
|
|
50
|
+
min: String,
|
|
51
|
+
max: String,
|
|
52
|
+
disabledDates: {
|
|
53
|
+
type: Array,
|
|
54
|
+
default: () => []
|
|
55
|
+
},
|
|
56
|
+
required: Boolean,
|
|
57
|
+
disabled: Boolean,
|
|
58
|
+
locale: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: "zh-CN"
|
|
61
|
+
},
|
|
62
|
+
firstDay: {
|
|
63
|
+
type: Number,
|
|
64
|
+
default: 1
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
emits: ["update:modelValue", "change"],
|
|
68
|
+
setup(t, { emit: j }) {
|
|
69
|
+
let M = t, N = j, P = _(null), F = _(null), I = _(null);
|
|
70
|
+
function L(e) {
|
|
71
|
+
return [a(e?.[0]), a(e?.[1])];
|
|
72
|
+
}
|
|
73
|
+
let { local: R, update: z } = r(M, N, P, L);
|
|
74
|
+
e(P);
|
|
75
|
+
let B = _(i(R.value[0] || c())), V = u(() => s(B.value, 1)), H = u(() => [M.startName || (M.name ? `${M.name}[start]` : void 0), M.endName || (M.name ? `${M.name}[end]` : void 0)]), U = u(() => {
|
|
76
|
+
let [e, t] = R.value;
|
|
77
|
+
return e && t && t < e ? "结束日期不能早于开始日期" : e && t && M.disabledDates.some((n) => n >= e && n <= t) ? "范围包含不可用日期" : e && M.disabledDates.includes(e) || t && M.disabledDates.includes(t) ? "日期不可用" : "";
|
|
78
|
+
});
|
|
79
|
+
b(() => {
|
|
80
|
+
F.value?.setCustomValidity(U.value), I.value?.setCustomValidity(U.value);
|
|
81
|
+
}, { flush: "post" });
|
|
82
|
+
function W(e) {
|
|
83
|
+
if (!a(e)) return;
|
|
84
|
+
let [t, n] = R.value;
|
|
85
|
+
z(!t || n ? [e, null] : e < t ? [e, t] : [t, e]);
|
|
86
|
+
}
|
|
87
|
+
function G(e, t) {
|
|
88
|
+
let n = [...R.value];
|
|
89
|
+
n[e] = a(t), z(n), e === 0 && n[0] && (B.value = i(n[0]));
|
|
90
|
+
}
|
|
91
|
+
function K(e) {
|
|
92
|
+
let t = s(B.value, e), n = o(s(t, 2), -1);
|
|
93
|
+
return !(M.min && n < M.min || M.max && t > M.max);
|
|
94
|
+
}
|
|
95
|
+
function q(e) {
|
|
96
|
+
K(e) && (B.value = s(B.value, e));
|
|
97
|
+
}
|
|
98
|
+
function J(e) {
|
|
99
|
+
B.value = s(e, -1);
|
|
100
|
+
}
|
|
101
|
+
return (e, r) => (g(), f("div", {
|
|
102
|
+
ref_key: "root",
|
|
103
|
+
ref: P,
|
|
104
|
+
class: "kima-date-range-picker",
|
|
105
|
+
role: "group",
|
|
106
|
+
"aria-label": "日期范围",
|
|
107
|
+
"aria-disabled": t.disabled || void 0
|
|
108
|
+
}, [
|
|
109
|
+
p("div", w, [
|
|
110
|
+
p("input", {
|
|
111
|
+
ref_key: "startInput",
|
|
112
|
+
ref: F,
|
|
113
|
+
class: "kima-date-range-picker__input",
|
|
114
|
+
type: "date",
|
|
115
|
+
"aria-label": t.startLabel,
|
|
116
|
+
name: y(R)[0] ? H.value[0] : void 0,
|
|
117
|
+
value: y(R)[0] || "",
|
|
118
|
+
min: t.min,
|
|
119
|
+
max: t.max,
|
|
120
|
+
required: t.required,
|
|
121
|
+
disabled: t.disabled,
|
|
122
|
+
onInput: r[0] ||= S((e) => G(0, e.target.value), ["stop"]),
|
|
123
|
+
onChange: r[1] ||= S(() => {}, ["stop"])
|
|
124
|
+
}, null, 40, T),
|
|
125
|
+
r[8] ||= p("span", { "aria-hidden": "true" }, "→", -1),
|
|
126
|
+
p("input", {
|
|
127
|
+
ref_key: "endInput",
|
|
128
|
+
ref: I,
|
|
129
|
+
class: "kima-date-range-picker__input",
|
|
130
|
+
type: "date",
|
|
131
|
+
"aria-label": t.endLabel,
|
|
132
|
+
name: y(R)[1] ? H.value[1] : void 0,
|
|
133
|
+
value: y(R)[1] || "",
|
|
134
|
+
min: y(R)[0] || t.min,
|
|
135
|
+
max: t.max,
|
|
136
|
+
required: t.required,
|
|
137
|
+
disabled: t.disabled,
|
|
138
|
+
onInput: r[2] ||= S((e) => G(1, e.target.value), ["stop"]),
|
|
139
|
+
onChange: r[3] ||= S(() => {}, ["stop"])
|
|
140
|
+
}, null, 40, E)
|
|
141
|
+
]),
|
|
142
|
+
p("div", D, [
|
|
143
|
+
h(n, {
|
|
144
|
+
variant: "text",
|
|
145
|
+
disabled: t.disabled || !K(-1),
|
|
146
|
+
onClick: r[4] ||= (e) => q(-1)
|
|
147
|
+
}, {
|
|
148
|
+
default: x(() => [...r[9] ||= [m("上一月", -1)]]),
|
|
149
|
+
_: 1
|
|
150
|
+
}, 8, ["disabled"]),
|
|
151
|
+
h(n, {
|
|
152
|
+
variant: "text",
|
|
153
|
+
disabled: t.disabled || !K(1),
|
|
154
|
+
onClick: r[5] ||= (e) => q(1)
|
|
155
|
+
}, {
|
|
156
|
+
default: x(() => [...r[10] ||= [m("下一月", -1)]]),
|
|
157
|
+
_: 1
|
|
158
|
+
}, 8, ["disabled"]),
|
|
159
|
+
h(n, {
|
|
160
|
+
variant: "text",
|
|
161
|
+
disabled: t.disabled || !y(R).some(Boolean),
|
|
162
|
+
onClick: r[6] ||= (e) => y(z)([null, null])
|
|
163
|
+
}, {
|
|
164
|
+
default: x(() => [...r[11] ||= [m("清空范围", -1)]]),
|
|
165
|
+
_: 1
|
|
166
|
+
}, 8, ["disabled"])
|
|
167
|
+
]),
|
|
168
|
+
p("div", O, [h(l, {
|
|
169
|
+
"view-date": B.value,
|
|
170
|
+
"model-value": null,
|
|
171
|
+
"range-start": y(R)[0],
|
|
172
|
+
"range-end": y(R)[1],
|
|
173
|
+
min: t.min,
|
|
174
|
+
max: t.max,
|
|
175
|
+
"disabled-dates": t.disabledDates,
|
|
176
|
+
disabled: t.disabled,
|
|
177
|
+
"first-day": t.firstDay,
|
|
178
|
+
locale: t.locale,
|
|
179
|
+
"range-mode": "",
|
|
180
|
+
"hide-navigation": "",
|
|
181
|
+
"onUpdate:modelValue": W,
|
|
182
|
+
"onUpdate:viewDate": r[7] ||= (e) => B.value = e
|
|
183
|
+
}, null, 8, [
|
|
184
|
+
"view-date",
|
|
185
|
+
"range-start",
|
|
186
|
+
"range-end",
|
|
187
|
+
"min",
|
|
188
|
+
"max",
|
|
189
|
+
"disabled-dates",
|
|
190
|
+
"disabled",
|
|
191
|
+
"first-day",
|
|
192
|
+
"locale"
|
|
193
|
+
]), h(l, {
|
|
194
|
+
"view-date": V.value,
|
|
195
|
+
"model-value": null,
|
|
196
|
+
"range-start": y(R)[0],
|
|
197
|
+
"range-end": y(R)[1],
|
|
198
|
+
min: t.min,
|
|
199
|
+
max: t.max,
|
|
200
|
+
"disabled-dates": t.disabledDates,
|
|
201
|
+
disabled: t.disabled,
|
|
202
|
+
"first-day": t.firstDay,
|
|
203
|
+
locale: t.locale,
|
|
204
|
+
"range-mode": "",
|
|
205
|
+
"hide-navigation": "",
|
|
206
|
+
"onUpdate:modelValue": W,
|
|
207
|
+
"onUpdate:viewDate": J
|
|
208
|
+
}, null, 8, [
|
|
209
|
+
"view-date",
|
|
210
|
+
"range-start",
|
|
211
|
+
"range-end",
|
|
212
|
+
"min",
|
|
213
|
+
"max",
|
|
214
|
+
"disabled-dates",
|
|
215
|
+
"disabled",
|
|
216
|
+
"first-day",
|
|
217
|
+
"locale"
|
|
218
|
+
])]),
|
|
219
|
+
U.value ? (g(), f("p", k, v(U.value), 1)) : d("", !0),
|
|
220
|
+
p("span", A, v(y(R)[0] && !y(R)[1] ? "请选择结束日期" : ""), 1)
|
|
221
|
+
], 8, C));
|
|
222
|
+
}
|
|
223
|
+
}, [["__scopeId", "data-v-8bcd6e19"]]);
|
|
224
|
+
export { j as default };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { useRipple as e } from "../../utils/ripple.js";
|
|
2
|
+
import t from "../../_virtual/_plugin-vue_export-helper.js";
|
|
3
|
+
import n from "../core/button.ce.js";
|
|
4
|
+
import { presenceTransition as r } from "../../utils/motion.js";
|
|
5
|
+
import { useInputState as i } from "../../utils/input-state.js";
|
|
6
|
+
/* empty css */
|
|
7
|
+
import { Transition as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, createVNode as d, mergeProps as f, nextTick as p, onBeforeUnmount as m, openBlock as h, ref as g, resolveDynamicComponent as _, toDisplayString as v, unref as y, vShow as b, watch as x, withCtx as S, withDirectives as C } from "vue";
|
|
8
|
+
// src/components/advanced-input/editable.ce.vue
|
|
9
|
+
var w = ["aria-busy"], T = [
|
|
10
|
+
"disabled",
|
|
11
|
+
"aria-readonly",
|
|
12
|
+
"aria-label",
|
|
13
|
+
"inert"
|
|
14
|
+
], E = ["inert", "aria-hidden"], D = { class: "kima-editable__actions" }, O = {
|
|
15
|
+
key: 0,
|
|
16
|
+
role: "alert"
|
|
17
|
+
}, k = [
|
|
18
|
+
"name",
|
|
19
|
+
"value",
|
|
20
|
+
"disabled"
|
|
21
|
+
], A = /*#__PURE__*/ t({
|
|
22
|
+
__name: "editable.ce",
|
|
23
|
+
props: {
|
|
24
|
+
modelValue: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: ""
|
|
27
|
+
},
|
|
28
|
+
name: String,
|
|
29
|
+
label: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: "编辑内容"
|
|
32
|
+
},
|
|
33
|
+
placeholder: String,
|
|
34
|
+
multiline: Boolean,
|
|
35
|
+
disabled: Boolean,
|
|
36
|
+
readonly: Boolean,
|
|
37
|
+
required: Boolean,
|
|
38
|
+
saveHandler: Function
|
|
39
|
+
},
|
|
40
|
+
emits: [
|
|
41
|
+
"update:modelValue",
|
|
42
|
+
"change",
|
|
43
|
+
"save",
|
|
44
|
+
"cancel",
|
|
45
|
+
"error",
|
|
46
|
+
"update:editing"
|
|
47
|
+
],
|
|
48
|
+
setup(t, { expose: A, emit: j }) {
|
|
49
|
+
let M = t, N = j, P = g(null), F = g(null), I = g(null), L = g(!1), R = g(M.modelValue), z = g(!1), B = g(""), V = 0, { local: H, update: U } = i(M, N, P, (e) => String(e || ""), (e) => {
|
|
50
|
+
V += 1, z.value = !1, L.value = !1, R.value = e, B.value = "";
|
|
51
|
+
});
|
|
52
|
+
e(P), x(() => M.modelValue, (e) => {
|
|
53
|
+
L.value || (R.value = e || "");
|
|
54
|
+
});
|
|
55
|
+
async function W() {
|
|
56
|
+
M.disabled || M.readonly || z.value || (R.value = H.value, B.value = "", L.value = !0, N("update:editing", !0), await p(), L.value && (I.value?.focus(), I.value?.select?.()));
|
|
57
|
+
}
|
|
58
|
+
async function G() {
|
|
59
|
+
await p(), L.value || F.value?.focus();
|
|
60
|
+
}
|
|
61
|
+
async function K() {
|
|
62
|
+
if (z.value || M.disabled || M.readonly || !I.value?.reportValidity()) return;
|
|
63
|
+
let e = ++V, t = R.value;
|
|
64
|
+
z.value = !0, B.value = "";
|
|
65
|
+
try {
|
|
66
|
+
if (M.saveHandler && await M.saveHandler(t), e !== V) return;
|
|
67
|
+
U(t), N("save", t), L.value = !1, N("update:editing", !1), G();
|
|
68
|
+
} catch (t) {
|
|
69
|
+
if (e !== V) return;
|
|
70
|
+
B.value = t?.message || String(t), N("error", t), await p(), I.value?.focus();
|
|
71
|
+
} finally {
|
|
72
|
+
e === V && (z.value = !1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function q() {
|
|
76
|
+
z.value || (V += 1, R.value = H.value, B.value = "", L.value = !1, N("cancel"), N("update:editing", !1), G());
|
|
77
|
+
}
|
|
78
|
+
function J(e) {
|
|
79
|
+
e.isComposing || e.keyCode === 229 || (e.key === "Escape" ? (e.preventDefault(), q()) : e.key === "Enter" && (!M.multiline || e.ctrlKey || e.metaKey) && (e.preventDefault(), K()));
|
|
80
|
+
}
|
|
81
|
+
return m(() => {
|
|
82
|
+
V += 1;
|
|
83
|
+
}), A({
|
|
84
|
+
edit: W,
|
|
85
|
+
save: K,
|
|
86
|
+
cancel: q,
|
|
87
|
+
focus: () => F.value?.focus()
|
|
88
|
+
}), (e, i) => (h(), c("div", {
|
|
89
|
+
ref_key: "root",
|
|
90
|
+
ref: P,
|
|
91
|
+
class: "kima-editable",
|
|
92
|
+
"aria-busy": z.value || void 0
|
|
93
|
+
}, [
|
|
94
|
+
d(a, f({ name: "kima-fade" }, y(r)), {
|
|
95
|
+
default: S(() => [C(l("button", {
|
|
96
|
+
ref_key: "display",
|
|
97
|
+
ref: F,
|
|
98
|
+
class: "kima-editable__display",
|
|
99
|
+
type: "button",
|
|
100
|
+
disabled: t.disabled,
|
|
101
|
+
"aria-readonly": t.readonly || void 0,
|
|
102
|
+
"aria-label": `${t.label}: ${y(H) || t.placeholder || ""}`,
|
|
103
|
+
inert: L.value,
|
|
104
|
+
onClick: W
|
|
105
|
+
}, v(y(H) || t.placeholder || "编辑"), 9, T), [[b, !L.value]])]),
|
|
106
|
+
_: 1
|
|
107
|
+
}, 16),
|
|
108
|
+
d(a, f({ name: "kima-content" }, y(r)), {
|
|
109
|
+
default: S(() => [C(l("div", {
|
|
110
|
+
class: "kima-editable__editor",
|
|
111
|
+
inert: !L.value,
|
|
112
|
+
"aria-hidden": !L.value || void 0
|
|
113
|
+
}, [
|
|
114
|
+
(h(), o(_(t.multiline ? "textarea" : "input"), {
|
|
115
|
+
ref_key: "editor",
|
|
116
|
+
ref: I,
|
|
117
|
+
value: R.value,
|
|
118
|
+
class: "kima-editable__input",
|
|
119
|
+
"aria-label": t.label,
|
|
120
|
+
required: t.required,
|
|
121
|
+
readonly: z.value,
|
|
122
|
+
disabled: t.disabled,
|
|
123
|
+
onInput: i[0] ||= (e) => R.value = e.target.value,
|
|
124
|
+
onKeydown: J
|
|
125
|
+
}, null, 40, [
|
|
126
|
+
"value",
|
|
127
|
+
"aria-label",
|
|
128
|
+
"required",
|
|
129
|
+
"readonly",
|
|
130
|
+
"disabled"
|
|
131
|
+
])),
|
|
132
|
+
l("div", D, [d(n, {
|
|
133
|
+
loading: z.value,
|
|
134
|
+
disabled: t.disabled,
|
|
135
|
+
onClick: K
|
|
136
|
+
}, {
|
|
137
|
+
default: S(() => [...i[1] ||= [u("保存", -1)]]),
|
|
138
|
+
_: 1
|
|
139
|
+
}, 8, ["loading", "disabled"]), d(n, {
|
|
140
|
+
variant: "text",
|
|
141
|
+
disabled: z.value || t.disabled,
|
|
142
|
+
onClick: q
|
|
143
|
+
}, {
|
|
144
|
+
default: S(() => [...i[2] ||= [u("取消", -1)]]),
|
|
145
|
+
_: 1
|
|
146
|
+
}, 8, ["disabled"])]),
|
|
147
|
+
B.value ? (h(), c("p", O, v(B.value), 1)) : s("", !0)
|
|
148
|
+
], 8, E), [[b, L.value]])]),
|
|
149
|
+
_: 1
|
|
150
|
+
}, 16),
|
|
151
|
+
l("input", {
|
|
152
|
+
type: "hidden",
|
|
153
|
+
name: t.name,
|
|
154
|
+
value: y(H),
|
|
155
|
+
disabled: t.disabled
|
|
156
|
+
}, null, 8, k)
|
|
157
|
+
], 8, w));
|
|
158
|
+
}
|
|
159
|
+
}, [["__scopeId", "data-v-91cd5b33"]]);
|
|
160
|
+
export { A as default };
|