yc-agent-ui 1.2.8 → 1.2.10
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/es/components/data-table/src/data-table.vue.d.ts +2 -2
- package/es/components/drawer-form/index.d.ts +6 -6
- package/es/components/drawer-form/src/index.vue.d.ts +2 -2
- package/es/components/form/index.d.ts +28 -28
- package/es/components/form/src/form-content.vue.d.ts +7 -7
- package/es/components/form/src/index.vue.d.ts +10 -10
- package/es/components/form-item/index.d.ts +31 -31
- package/es/components/form-item/src/index.vue.d.ts +10 -10
- package/es/components/page/index.d.ts +725 -725
- package/es/components/page/src/index.vue.d.ts +242 -242
- package/es/components/search/index.d.ts +190 -190
- package/es/components/search/src/index.vue.d.ts +64 -64
- package/es/components/table/index.d.ts +18 -18
- package/es/components/table/src/index.vue.d.ts +2 -2
- package/es/components/virtual-table/index.d.ts +10 -10
- package/es/components/virtual-table/src/index.vue.d.ts +3 -3
- package/es/components/yc-ai-chat/src/bubble.vue.d.ts +1 -1
- package/es/components/yc-ai-chat/src/file-card.vue.d.ts +1 -1
- package/es/components/yc-ai-chat/src/sender.vue.d.ts +1 -1
- package/es/components/yc-ai-chat/src/sidebar.vue.d.ts +1 -1
- package/es/components/yc-coss-table/src/coss-table.vue.d.ts +3 -3
- package/es/components/yc-coss-table/src/table.vue.d.ts +1 -1
- package/es/components/yc-date-picker/src/date-picker.vue.d.ts +1 -1
- package/es/components/yc-display-cards/index.d.ts +218 -3
- package/es/components/yc-display-cards/src/card-renderer.vue.d.ts +16 -0
- package/es/components/yc-display-cards/src/elements/action-bar.vue.d.ts +12 -0
- package/es/components/yc-display-cards/src/elements/card-shell.vue.d.ts +24 -0
- package/es/components/yc-display-cards/src/elements/choice-group.vue.d.ts +14 -0
- package/es/components/yc-display-cards/src/elements/data-table.vue.d.ts +10 -0
- package/es/components/yc-display-cards/src/elements/field-control.vue.d.ts +22 -0
- package/es/components/yc-display-cards/src/elements/field-utils.d.ts +16 -0
- package/es/components/yc-display-cards/src/elements/form-field.vue.d.ts +18 -0
- package/es/components/yc-display-cards/src/elements/inline-alert.vue.d.ts +14 -0
- package/es/components/yc-display-cards/src/elements/input.vue.d.ts +20 -0
- package/es/components/yc-display-cards/src/elements/kv-list.vue.d.ts +8 -0
- package/es/components/yc-display-cards/src/elements/metric-grid.vue.d.ts +7 -0
- package/es/components/yc-display-cards/src/elements/status-tag.vue.d.ts +6 -0
- package/es/components/yc-display-cards/src/elements/switch.vue.d.ts +10 -0
- package/es/components/yc-display-cards/src/elements/upload.vue.d.ts +17 -0
- package/es/components/yc-display-cards/src/elements/use-card-form.d.ts +23 -0
- package/es/components/yc-display-cards/src/form-card.vue.d.ts +5 -2
- package/es/components/yc-display-cards/src/table-card.vue.d.ts +1 -2
- package/es/components/yc-display-cards/src/types.d.ts +179 -10
- package/es/components/yc-feedback/src/banner.vue.d.ts +1 -1
- package/es/components/yc-feedback/src/key-value-list.vue.d.ts +1 -1
- package/es/components/yc-input/src/input.vue.d.ts +1 -1
- package/es/components/yc-input/src/money-input.vue.d.ts +1 -1
- package/es/components/yc-input/src/textarea.vue.d.ts +2 -2
- package/es/components/yc-plus-page/src/header-filter-cell.vue.d.ts +8 -8
- package/es/components/yc-plus-page/src/index.vue.d.ts +741 -741
- package/es/components/yc-plus-tree/src/index.vue.d.ts +1 -1
- package/es/components/yc-property-table/src/property-table.vue.d.ts +2 -2
- package/es/components/yc-questionnaire/src/index.vue.d.ts +1 -1
- package/es/hooks/usePlusFormReset.d.ts +18 -18
- package/es/index.css +29 -23
- package/es/index.mjs +3 -1
- package/es/packages/components/index.mjs +3 -1
- package/es/packages/components/yc-display-cards/capability.mjs +57 -1
- package/es/packages/components/yc-display-cards/index.mjs +31 -1
- package/es/packages/components/yc-display-cards/src/card-renderer.vue.mjs +6 -0
- package/es/packages/components/yc-display-cards/src/card-renderer2.vue.mjs +295 -0
- package/es/packages/components/yc-display-cards/src/detail-card.vue.mjs +1 -1
- package/es/packages/components/yc-display-cards/src/detail-card2.vue.mjs +28 -94
- package/es/packages/components/yc-display-cards/src/elements/action-bar.vue.mjs +6 -0
- package/es/packages/components/yc-display-cards/src/elements/action-bar2.vue.mjs +38 -0
- package/es/packages/components/yc-display-cards/src/elements/card-shell.vue.mjs +6 -0
- package/es/packages/components/yc-display-cards/src/elements/card-shell2.vue.mjs +85 -0
- package/es/packages/components/yc-display-cards/src/elements/choice-group.vue.mjs +6 -0
- package/es/packages/components/yc-display-cards/src/elements/choice-group2.vue.mjs +57 -0
- package/es/packages/components/yc-display-cards/src/elements/data-table.vue.mjs +6 -0
- package/es/packages/components/yc-display-cards/src/elements/data-table2.vue.mjs +184 -0
- package/es/packages/components/yc-display-cards/src/elements/field-control.vue.mjs +5 -0
- package/es/packages/components/yc-display-cards/src/elements/field-control2.vue.mjs +92 -0
- package/es/packages/components/yc-display-cards/src/elements/field-utils.mjs +121 -0
- package/es/packages/components/yc-display-cards/src/elements/form-field.vue.mjs +6 -0
- package/es/packages/components/yc-display-cards/src/elements/form-field2.vue.mjs +68 -0
- package/es/packages/components/yc-display-cards/src/elements/inline-alert.vue.mjs +6 -0
- package/es/packages/components/yc-display-cards/src/elements/inline-alert2.vue.mjs +29 -0
- package/es/packages/components/yc-display-cards/src/elements/input.vue.mjs +6 -0
- package/es/packages/components/yc-display-cards/src/elements/input2.vue.mjs +142 -0
- package/es/packages/components/yc-display-cards/src/elements/kv-list.vue.mjs +6 -0
- package/es/packages/components/yc-display-cards/src/elements/kv-list2.vue.mjs +63 -0
- package/es/packages/components/yc-display-cards/src/elements/metric-grid.vue.mjs +6 -0
- package/es/packages/components/yc-display-cards/src/elements/metric-grid2.vue.mjs +97 -0
- package/es/packages/components/yc-display-cards/src/elements/status-tag.vue.mjs +6 -0
- package/es/packages/components/yc-display-cards/src/elements/status-tag2.vue.mjs +25 -0
- package/es/packages/components/yc-display-cards/src/elements/switch.vue.mjs +6 -0
- package/es/packages/components/yc-display-cards/src/elements/switch2.vue.mjs +35 -0
- package/es/packages/components/yc-display-cards/src/elements/upload.vue.mjs +6 -0
- package/es/packages/components/yc-display-cards/src/elements/upload2.vue.mjs +196 -0
- package/es/packages/components/yc-display-cards/src/elements/use-card-form.mjs +80 -0
- package/es/packages/components/yc-display-cards/src/form-card.vue.mjs +1 -1
- package/es/packages/components/yc-display-cards/src/form-card2.vue.mjs +169 -1140
- package/es/packages/components/yc-display-cards/src/metrics-card.vue.mjs +1 -1
- package/es/packages/components/yc-display-cards/src/metrics-card2.vue.mjs +19 -114
- package/es/packages/components/yc-display-cards/src/table-card.vue.mjs +1 -1
- package/es/packages/components/yc-display-cards/src/table-card2.vue.mjs +50 -232
- package/es/packages/components/yc-status-dialog/src/index.vue.mjs +1 -1
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/index.css +20 -14
- package/index.js +2223 -2378
- package/index.min.css +19 -13
- package/index.min.js +37 -43
- package/index.min.mjs +36 -42
- package/index.mjs +2203 -2377
- package/lib/components/data-table/src/data-table.vue.d.ts +2 -2
- package/lib/components/drawer-form/index.d.ts +6 -6
- package/lib/components/drawer-form/src/index.vue.d.ts +2 -2
- package/lib/components/form/index.d.ts +28 -28
- package/lib/components/form/src/form-content.vue.d.ts +7 -7
- package/lib/components/form/src/index.vue.d.ts +10 -10
- package/lib/components/form-item/index.d.ts +31 -31
- package/lib/components/form-item/src/index.vue.d.ts +10 -10
- package/lib/components/page/index.d.ts +725 -725
- package/lib/components/page/src/index.vue.d.ts +242 -242
- package/lib/components/search/index.d.ts +190 -190
- package/lib/components/search/src/index.vue.d.ts +64 -64
- package/lib/components/table/index.d.ts +18 -18
- package/lib/components/table/src/index.vue.d.ts +2 -2
- package/lib/components/virtual-table/index.d.ts +10 -10
- package/lib/components/virtual-table/src/index.vue.d.ts +3 -3
- package/lib/components/yc-ai-chat/src/bubble.vue.d.ts +1 -1
- package/lib/components/yc-ai-chat/src/file-card.vue.d.ts +1 -1
- package/lib/components/yc-ai-chat/src/sender.vue.d.ts +1 -1
- package/lib/components/yc-ai-chat/src/sidebar.vue.d.ts +1 -1
- package/lib/components/yc-coss-table/src/coss-table.vue.d.ts +3 -3
- package/lib/components/yc-coss-table/src/table.vue.d.ts +1 -1
- package/lib/components/yc-date-picker/src/date-picker.vue.d.ts +1 -1
- package/lib/components/yc-display-cards/index.d.ts +218 -3
- package/lib/components/yc-display-cards/src/card-renderer.vue.d.ts +16 -0
- package/lib/components/yc-display-cards/src/elements/action-bar.vue.d.ts +12 -0
- package/lib/components/yc-display-cards/src/elements/card-shell.vue.d.ts +24 -0
- package/lib/components/yc-display-cards/src/elements/choice-group.vue.d.ts +14 -0
- package/lib/components/yc-display-cards/src/elements/data-table.vue.d.ts +10 -0
- package/lib/components/yc-display-cards/src/elements/field-control.vue.d.ts +22 -0
- package/lib/components/yc-display-cards/src/elements/field-utils.d.ts +16 -0
- package/lib/components/yc-display-cards/src/elements/form-field.vue.d.ts +18 -0
- package/lib/components/yc-display-cards/src/elements/inline-alert.vue.d.ts +14 -0
- package/lib/components/yc-display-cards/src/elements/input.vue.d.ts +20 -0
- package/lib/components/yc-display-cards/src/elements/kv-list.vue.d.ts +8 -0
- package/lib/components/yc-display-cards/src/elements/metric-grid.vue.d.ts +7 -0
- package/lib/components/yc-display-cards/src/elements/status-tag.vue.d.ts +6 -0
- package/lib/components/yc-display-cards/src/elements/switch.vue.d.ts +10 -0
- package/lib/components/yc-display-cards/src/elements/upload.vue.d.ts +17 -0
- package/lib/components/yc-display-cards/src/elements/use-card-form.d.ts +23 -0
- package/lib/components/yc-display-cards/src/form-card.vue.d.ts +5 -2
- package/lib/components/yc-display-cards/src/table-card.vue.d.ts +1 -2
- package/lib/components/yc-display-cards/src/types.d.ts +179 -10
- package/lib/components/yc-feedback/src/banner.vue.d.ts +1 -1
- package/lib/components/yc-feedback/src/key-value-list.vue.d.ts +1 -1
- package/lib/components/yc-input/src/input.vue.d.ts +1 -1
- package/lib/components/yc-input/src/money-input.vue.d.ts +1 -1
- package/lib/components/yc-input/src/textarea.vue.d.ts +2 -2
- package/lib/components/yc-plus-page/src/header-filter-cell.vue.d.ts +8 -8
- package/lib/components/yc-plus-page/src/index.vue.d.ts +741 -741
- package/lib/components/yc-plus-tree/src/index.vue.d.ts +1 -1
- package/lib/components/yc-property-table/src/property-table.vue.d.ts +2 -2
- package/lib/components/yc-questionnaire/src/index.vue.d.ts +1 -1
- package/lib/hooks/usePlusFormReset.d.ts +18 -18
- package/lib/index.css +30 -24
- package/lib/index.js +28 -7
- package/lib/packages/components/index.js +28 -7
- package/lib/packages/components/yc-display-cards/capability.js +56 -0
- package/lib/packages/components/yc-display-cards/index.js +49 -0
- package/lib/packages/components/yc-display-cards/src/card-renderer.vue.js +10 -0
- package/lib/packages/components/yc-display-cards/src/card-renderer2.vue.js +299 -0
- package/lib/packages/components/yc-display-cards/src/detail-card.vue.js +1 -1
- package/lib/packages/components/yc-display-cards/src/detail-card2.vue.js +27 -93
- package/lib/packages/components/yc-display-cards/src/elements/action-bar.vue.js +10 -0
- package/lib/packages/components/yc-display-cards/src/elements/action-bar2.vue.js +42 -0
- package/lib/packages/components/yc-display-cards/src/elements/card-shell.vue.js +10 -0
- package/lib/packages/components/yc-display-cards/src/elements/card-shell2.vue.js +89 -0
- package/lib/packages/components/yc-display-cards/src/elements/choice-group.vue.js +10 -0
- package/lib/packages/components/yc-display-cards/src/elements/choice-group2.vue.js +61 -0
- package/lib/packages/components/yc-display-cards/src/elements/data-table.vue.js +10 -0
- package/lib/packages/components/yc-display-cards/src/elements/data-table2.vue.js +188 -0
- package/lib/packages/components/yc-display-cards/src/elements/field-control.vue.js +9 -0
- package/lib/packages/components/yc-display-cards/src/elements/field-control2.vue.js +96 -0
- package/lib/packages/components/yc-display-cards/src/elements/field-utils.js +134 -0
- package/lib/packages/components/yc-display-cards/src/elements/form-field.vue.js +10 -0
- package/lib/packages/components/yc-display-cards/src/elements/form-field2.vue.js +72 -0
- package/lib/packages/components/yc-display-cards/src/elements/inline-alert.vue.js +10 -0
- package/lib/packages/components/yc-display-cards/src/elements/inline-alert2.vue.js +33 -0
- package/lib/packages/components/yc-display-cards/src/elements/input.vue.js +10 -0
- package/lib/packages/components/yc-display-cards/src/elements/input2.vue.js +146 -0
- package/lib/packages/components/yc-display-cards/src/elements/kv-list.vue.js +10 -0
- package/lib/packages/components/yc-display-cards/src/elements/kv-list2.vue.js +67 -0
- package/lib/packages/components/yc-display-cards/src/elements/metric-grid.vue.js +10 -0
- package/lib/packages/components/yc-display-cards/src/elements/metric-grid2.vue.js +101 -0
- package/lib/packages/components/yc-display-cards/src/elements/status-tag.vue.js +10 -0
- package/lib/packages/components/yc-display-cards/src/elements/status-tag2.vue.js +29 -0
- package/lib/packages/components/yc-display-cards/src/elements/switch.vue.js +10 -0
- package/lib/packages/components/yc-display-cards/src/elements/switch2.vue.js +39 -0
- package/lib/packages/components/yc-display-cards/src/elements/upload.vue.js +10 -0
- package/lib/packages/components/yc-display-cards/src/elements/upload2.vue.js +200 -0
- package/lib/packages/components/yc-display-cards/src/elements/use-card-form.js +82 -0
- package/lib/packages/components/yc-display-cards/src/form-card.vue.js +1 -1
- package/lib/packages/components/yc-display-cards/src/form-card2.vue.js +168 -1139
- package/lib/packages/components/yc-display-cards/src/metrics-card.vue.js +1 -1
- package/lib/packages/components/yc-display-cards/src/metrics-card2.vue.js +18 -113
- package/lib/packages/components/yc-display-cards/src/table-card.vue.js +1 -1
- package/lib/packages/components/yc-display-cards/src/table-card2.vue.js +49 -231
- package/lib/packages/components/yc-status-dialog/src/index.vue.js +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/locale/en.js +1 -1
- package/locale/en.min.js +1 -1
- package/locale/en.min.mjs +1 -1
- package/locale/en.mjs +1 -1
- package/locale/ja.js +1 -1
- package/locale/ja.min.js +1 -1
- package/locale/ja.min.mjs +1 -1
- package/locale/ja.mjs +1 -1
- package/locale/ko.js +1 -1
- package/locale/ko.min.js +1 -1
- package/locale/ko.min.mjs +1 -1
- package/locale/ko.mjs +1 -1
- package/locale/zh-cn.js +1 -1
- package/locale/zh-cn.min.js +1 -1
- package/locale/zh-cn.min.mjs +1 -1
- package/locale/zh-cn.mjs +1 -1
- package/locale/zh-tw.js +1 -1
- package/locale/zh-tw.min.js +1 -1
- package/locale/zh-tw.min.mjs +1 -1
- package/locale/zh-tw.mjs +1 -1
- package/package.json +1 -2
- package/theme-chalk/index.css +20 -14
- package/theme-chalk/plus-dialog.css +1 -1
- package/theme-chalk/plus-yc-status-dialog.css +1 -1
- package/theme-chalk/src/dialog.scss +0 -6
- package/theme-chalk/src/index.scss +1 -2
- package/theme-chalk/src/yc-status-dialog.scss +2 -2
- package/es/_virtual/_commonjsHelpers.mjs +0 -7
- package/es/_virtual/toastify.mjs +0 -3
- package/es/components/yc-display-cards/src/toast.d.ts +0 -4
- package/es/node_modules/.pnpm/toastify-js@1.12.0/node_modules/toastify-js/src/toastify.mjs +0 -456
- package/es/packages/components/yc-display-cards/src/toast.mjs +0 -35
- package/lib/_virtual/_commonjsHelpers.js +0 -10
- package/lib/_virtual/toastify.js +0 -5
- package/lib/components/yc-display-cards/src/toast.d.ts +0 -4
- package/lib/node_modules/.pnpm/toastify-js@1.12.0/node_modules/toastify-js/src/toastify.js +0 -460
- package/lib/packages/components/yc-display-cards/src/toast.js +0 -37
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, watch, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode, vModelText, createCommentVNode, Fragment, renderList, normalizeStyle, toDisplayString } from 'vue';
|
|
2
|
+
|
|
3
|
+
const _hoisted_1 = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "yc-data-table__search"
|
|
6
|
+
};
|
|
7
|
+
const _hoisted_2 = { class: "yc-data-table__scroll" };
|
|
8
|
+
const _hoisted_3 = {
|
|
9
|
+
key: 0,
|
|
10
|
+
class: "yc-data-table__table"
|
|
11
|
+
};
|
|
12
|
+
const _hoisted_4 = {
|
|
13
|
+
key: 1,
|
|
14
|
+
class: "yc-data-table__empty"
|
|
15
|
+
};
|
|
16
|
+
const _hoisted_5 = {
|
|
17
|
+
key: 1,
|
|
18
|
+
class: "yc-data-table__pager"
|
|
19
|
+
};
|
|
20
|
+
const _hoisted_6 = ["disabled"];
|
|
21
|
+
const _hoisted_7 = { class: "yc-data-table__page" };
|
|
22
|
+
const _hoisted_8 = ["disabled"];
|
|
23
|
+
var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
24
|
+
...{ name: "YcCardTable" },
|
|
25
|
+
__name: "data-table",
|
|
26
|
+
props: {
|
|
27
|
+
columns: { default: () => [] },
|
|
28
|
+
rows: { default: () => [] },
|
|
29
|
+
maxRows: { default: 10 },
|
|
30
|
+
bordered: { type: Boolean, default: false }
|
|
31
|
+
},
|
|
32
|
+
setup(__props) {
|
|
33
|
+
const props = __props;
|
|
34
|
+
const query = ref("");
|
|
35
|
+
const page = ref(1);
|
|
36
|
+
const normalizedColumns = computed(() => {
|
|
37
|
+
if (props.columns.length > 0) return props.columns;
|
|
38
|
+
const first = props.rows[0];
|
|
39
|
+
if (!first || typeof first !== "object") return [];
|
|
40
|
+
return Object.keys(first).map((key) => ({ key, label: key }));
|
|
41
|
+
});
|
|
42
|
+
const filteredRows = computed(() => {
|
|
43
|
+
const keyword = query.value.trim().toLowerCase();
|
|
44
|
+
if (!keyword) return props.rows;
|
|
45
|
+
return props.rows.filter(
|
|
46
|
+
(row) => normalizedColumns.value.some((col) => formatCell(row, col).toLowerCase().includes(keyword))
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
const pageCount = computed(
|
|
50
|
+
() => Math.max(1, Math.ceil(filteredRows.value.length / props.maxRows))
|
|
51
|
+
);
|
|
52
|
+
const showControls = computed(() => props.rows.length > props.maxRows);
|
|
53
|
+
const visibleRows = computed(() => {
|
|
54
|
+
if (!showControls.value) return filteredRows.value;
|
|
55
|
+
const start = (page.value - 1) * props.maxRows;
|
|
56
|
+
return filteredRows.value.slice(start, start + props.maxRows);
|
|
57
|
+
});
|
|
58
|
+
watch(query, () => {
|
|
59
|
+
page.value = 1;
|
|
60
|
+
});
|
|
61
|
+
watch(pageCount, (count) => {
|
|
62
|
+
if (page.value > count) page.value = count;
|
|
63
|
+
});
|
|
64
|
+
function stepPage(delta) {
|
|
65
|
+
page.value = Math.min(pageCount.value, Math.max(1, page.value + delta));
|
|
66
|
+
}
|
|
67
|
+
function formatCell(row, col) {
|
|
68
|
+
const raw = row == null ? void 0 : row[col.key];
|
|
69
|
+
if (raw === void 0 || raw === null || raw === "") return "\u2014";
|
|
70
|
+
const text = typeof raw === "object" ? JSON.stringify(raw) : String(raw);
|
|
71
|
+
return col.unit ? `${text} ${col.unit}` : text;
|
|
72
|
+
}
|
|
73
|
+
return (_ctx, _cache) => {
|
|
74
|
+
return openBlock(), createElementBlock(
|
|
75
|
+
"div",
|
|
76
|
+
{
|
|
77
|
+
class: normalizeClass(["yc-data-table", { "is-bordered": __props.bordered }])
|
|
78
|
+
},
|
|
79
|
+
[
|
|
80
|
+
showControls.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
81
|
+
withDirectives(createElementVNode(
|
|
82
|
+
"input",
|
|
83
|
+
{
|
|
84
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => query.value = $event),
|
|
85
|
+
type: "search",
|
|
86
|
+
class: "yc-data-table__search-input",
|
|
87
|
+
placeholder: "\u641C\u7D22\u8868\u683C",
|
|
88
|
+
"aria-label": "\u641C\u7D22\u8868\u683C"
|
|
89
|
+
},
|
|
90
|
+
null,
|
|
91
|
+
512
|
|
92
|
+
/* NEED_PATCH */
|
|
93
|
+
), [
|
|
94
|
+
[vModelText, query.value]
|
|
95
|
+
])
|
|
96
|
+
])) : createCommentVNode("v-if", true),
|
|
97
|
+
createElementVNode("div", _hoisted_2, [
|
|
98
|
+
normalizedColumns.value.length && __props.rows.length ? (openBlock(), createElementBlock("table", _hoisted_3, [
|
|
99
|
+
createElementVNode("thead", null, [
|
|
100
|
+
createElementVNode("tr", null, [
|
|
101
|
+
(openBlock(true), createElementBlock(
|
|
102
|
+
Fragment,
|
|
103
|
+
null,
|
|
104
|
+
renderList(normalizedColumns.value, (col) => {
|
|
105
|
+
var _a;
|
|
106
|
+
return openBlock(), createElementBlock(
|
|
107
|
+
"th",
|
|
108
|
+
{
|
|
109
|
+
key: col.key,
|
|
110
|
+
style: normalizeStyle({ textAlign: (_a = col.align) != null ? _a : "left" })
|
|
111
|
+
},
|
|
112
|
+
toDisplayString(col.label),
|
|
113
|
+
5
|
|
114
|
+
/* TEXT, STYLE */
|
|
115
|
+
);
|
|
116
|
+
}),
|
|
117
|
+
128
|
|
118
|
+
/* KEYED_FRAGMENT */
|
|
119
|
+
))
|
|
120
|
+
])
|
|
121
|
+
]),
|
|
122
|
+
createElementVNode("tbody", null, [
|
|
123
|
+
(openBlock(true), createElementBlock(
|
|
124
|
+
Fragment,
|
|
125
|
+
null,
|
|
126
|
+
renderList(visibleRows.value, (row, idx) => {
|
|
127
|
+
return openBlock(), createElementBlock("tr", { key: idx }, [
|
|
128
|
+
(openBlock(true), createElementBlock(
|
|
129
|
+
Fragment,
|
|
130
|
+
null,
|
|
131
|
+
renderList(normalizedColumns.value, (col) => {
|
|
132
|
+
var _a;
|
|
133
|
+
return openBlock(), createElementBlock(
|
|
134
|
+
"td",
|
|
135
|
+
{
|
|
136
|
+
key: col.key,
|
|
137
|
+
style: normalizeStyle({ textAlign: (_a = col.align) != null ? _a : "left" })
|
|
138
|
+
},
|
|
139
|
+
toDisplayString(formatCell(row, col)),
|
|
140
|
+
5
|
|
141
|
+
/* TEXT, STYLE */
|
|
142
|
+
);
|
|
143
|
+
}),
|
|
144
|
+
128
|
|
145
|
+
/* KEYED_FRAGMENT */
|
|
146
|
+
))
|
|
147
|
+
]);
|
|
148
|
+
}),
|
|
149
|
+
128
|
|
150
|
+
/* KEYED_FRAGMENT */
|
|
151
|
+
))
|
|
152
|
+
])
|
|
153
|
+
])) : (openBlock(), createElementBlock("div", _hoisted_4, "\u6682\u65E0\u53EF\u5C55\u793A\u7684\u8868\u683C\u6570\u636E"))
|
|
154
|
+
]),
|
|
155
|
+
showControls.value ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
156
|
+
createElementVNode("button", {
|
|
157
|
+
type: "button",
|
|
158
|
+
class: "yc-data-table__page-btn",
|
|
159
|
+
disabled: page.value <= 1,
|
|
160
|
+
onClick: _cache[1] || (_cache[1] = ($event) => stepPage(-1))
|
|
161
|
+
}, " \u4E0A\u4E00\u9875 ", 8, _hoisted_6),
|
|
162
|
+
createElementVNode(
|
|
163
|
+
"span",
|
|
164
|
+
_hoisted_7,
|
|
165
|
+
toDisplayString(page.value) + " / " + toDisplayString(pageCount.value) + " \xB7 " + toDisplayString(filteredRows.value.length) + " \u6761 ",
|
|
166
|
+
1
|
|
167
|
+
/* TEXT */
|
|
168
|
+
),
|
|
169
|
+
createElementVNode("button", {
|
|
170
|
+
type: "button",
|
|
171
|
+
class: "yc-data-table__page-btn",
|
|
172
|
+
disabled: page.value >= pageCount.value,
|
|
173
|
+
onClick: _cache[2] || (_cache[2] = ($event) => stepPage(1))
|
|
174
|
+
}, " \u4E0B\u4E00\u9875 ", 8, _hoisted_8)
|
|
175
|
+
])) : createCommentVNode("v-if", true)
|
|
176
|
+
],
|
|
177
|
+
2
|
|
178
|
+
/* CLASS */
|
|
179
|
+
);
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { defineComponent, computed, openBlock, createBlock, withCtx } from 'vue';
|
|
2
|
+
import ChoiceGroup from './choice-group.vue.mjs';
|
|
3
|
+
import { resolveFieldKind, normalizeOptions } from './field-utils.mjs';
|
|
4
|
+
import FormField from './form-field.vue.mjs';
|
|
5
|
+
import Input from './input.vue.mjs';
|
|
6
|
+
import Switch from './switch.vue.mjs';
|
|
7
|
+
import Upload from './upload.vue.mjs';
|
|
8
|
+
|
|
9
|
+
var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
10
|
+
...{ name: "YcCardFieldControl" },
|
|
11
|
+
__name: "field-control",
|
|
12
|
+
props: {
|
|
13
|
+
field: {},
|
|
14
|
+
modelValue: { default: void 0 },
|
|
15
|
+
options: { default: void 0 },
|
|
16
|
+
loadingOptions: { type: Boolean, default: false },
|
|
17
|
+
disabled: { type: Boolean, default: false },
|
|
18
|
+
error: { default: "" },
|
|
19
|
+
hint: { default: "" },
|
|
20
|
+
uploadFile: { type: Function, default: void 0 }
|
|
21
|
+
},
|
|
22
|
+
emits: ["update:modelValue", "blur", "focus", "upload-error"],
|
|
23
|
+
setup(__props, { emit: __emit }) {
|
|
24
|
+
const props = __props;
|
|
25
|
+
const emit = __emit;
|
|
26
|
+
const kind = computed(() => resolveFieldKind(props.field));
|
|
27
|
+
const label = computed(() => props.field.label || props.field.name);
|
|
28
|
+
const resolvedOptions = computed(() => {
|
|
29
|
+
var _a;
|
|
30
|
+
return (_a = props.options) != null ? _a : normalizeOptions(props.field);
|
|
31
|
+
});
|
|
32
|
+
const placeholder = computed(
|
|
33
|
+
() => props.field.placeholder || (kind.value === "select" ? `\u8BF7\u9009\u62E9${label.value}` : `\u8BF7\u8F93\u5165${label.value}`)
|
|
34
|
+
);
|
|
35
|
+
const inputKind = computed(() => {
|
|
36
|
+
if (kind.value === "number") return props.field.type === "integer" ? "integer" : "number";
|
|
37
|
+
return kind.value;
|
|
38
|
+
});
|
|
39
|
+
function update(value) {
|
|
40
|
+
emit("update:modelValue", value);
|
|
41
|
+
}
|
|
42
|
+
return (_ctx, _cache) => {
|
|
43
|
+
return openBlock(), createBlock(FormField, {
|
|
44
|
+
label: label.value,
|
|
45
|
+
required: __props.field.required,
|
|
46
|
+
hint: __props.hint,
|
|
47
|
+
error: __props.error,
|
|
48
|
+
"full-row": kind.value === "textarea" || kind.value === "image" || kind.value === "file"
|
|
49
|
+
}, {
|
|
50
|
+
default: withCtx(() => [
|
|
51
|
+
kind.value === "radio" || kind.value === "checkbox" ? (openBlock(), createBlock(ChoiceGroup, {
|
|
52
|
+
key: 0,
|
|
53
|
+
"model-value": __props.modelValue,
|
|
54
|
+
options: resolvedOptions.value,
|
|
55
|
+
multiple: kind.value === "checkbox",
|
|
56
|
+
disabled: __props.disabled,
|
|
57
|
+
"onUpdate:modelValue": update
|
|
58
|
+
}, null, 8, ["model-value", "options", "multiple", "disabled"])) : kind.value === "switch" ? (openBlock(), createBlock(Switch, {
|
|
59
|
+
key: 1,
|
|
60
|
+
"model-value": Boolean(__props.modelValue),
|
|
61
|
+
disabled: __props.disabled,
|
|
62
|
+
"onUpdate:modelValue": update
|
|
63
|
+
}, null, 8, ["model-value", "disabled"])) : kind.value === "image" || kind.value === "file" ? (openBlock(), createBlock(Upload, {
|
|
64
|
+
key: 2,
|
|
65
|
+
"model-value": Array.isArray(__props.modelValue) ? __props.modelValue : [],
|
|
66
|
+
accept: kind.value,
|
|
67
|
+
disabled: __props.disabled,
|
|
68
|
+
"upload-file": __props.uploadFile,
|
|
69
|
+
"onUpdate:modelValue": update,
|
|
70
|
+
onError: _cache[0] || (_cache[0] = ($event) => emit("upload-error", $event))
|
|
71
|
+
}, null, 8, ["model-value", "accept", "disabled", "upload-file"])) : (openBlock(), createBlock(Input, {
|
|
72
|
+
key: 3,
|
|
73
|
+
"model-value": __props.modelValue,
|
|
74
|
+
kind: inputKind.value,
|
|
75
|
+
placeholder: placeholder.value,
|
|
76
|
+
options: resolvedOptions.value,
|
|
77
|
+
loading: __props.loadingOptions,
|
|
78
|
+
disabled: __props.disabled,
|
|
79
|
+
invalid: Boolean(__props.error),
|
|
80
|
+
"onUpdate:modelValue": update,
|
|
81
|
+
onFocus: _cache[1] || (_cache[1] = ($event) => emit("focus")),
|
|
82
|
+
onBlur: _cache[2] || (_cache[2] = ($event) => emit("blur"))
|
|
83
|
+
}, null, 8, ["model-value", "kind", "placeholder", "options", "loading", "disabled", "invalid"]))
|
|
84
|
+
]),
|
|
85
|
+
_: 1
|
|
86
|
+
/* STABLE */
|
|
87
|
+
}, 8, ["label", "required", "hint", "error", "full-row"]);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
function isPlainObject(value) {
|
|
2
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
function isBlankValue(value) {
|
|
5
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
6
|
+
return value === void 0 || value === null || String(value).trim() === "";
|
|
7
|
+
}
|
|
8
|
+
function toOptionValue(raw) {
|
|
9
|
+
return typeof raw === "string" || typeof raw === "number" || typeof raw === "boolean" ? raw : String(raw);
|
|
10
|
+
}
|
|
11
|
+
function normalizeOptions(field) {
|
|
12
|
+
var _a;
|
|
13
|
+
const options = [];
|
|
14
|
+
if (Array.isArray(field.options)) {
|
|
15
|
+
for (const item of field.options) {
|
|
16
|
+
if (typeof item === "string" || typeof item === "number") {
|
|
17
|
+
options.push({ label: String(item), value: item });
|
|
18
|
+
} else if (isPlainObject(item) && item.value !== void 0 && item.value !== null) {
|
|
19
|
+
options.push({ label: String((_a = item.label) != null ? _a : item.value), value: toOptionValue(item.value) });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (!options.length && Array.isArray(field.enum)) {
|
|
24
|
+
for (const item of field.enum) {
|
|
25
|
+
options.push({ label: String(item), value: toOptionValue(item) });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return options;
|
|
29
|
+
}
|
|
30
|
+
function extractOptions(data, labelKey, valueKey) {
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
32
|
+
const rows = Array.isArray(data) ? data : isPlainObject(data) ? (_a = extractRows(data)) != null ? _a : [] : [];
|
|
33
|
+
const options = [];
|
|
34
|
+
for (const row of rows) {
|
|
35
|
+
if (typeof row === "string" || typeof row === "number") {
|
|
36
|
+
options.push({ label: String(row), value: row });
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (!isPlainObject(row)) continue;
|
|
40
|
+
const rawValue = (_f = (_e = (_d = (_c = (_b = valueKey ? row[valueKey] : void 0) != null ? _b : row.id) != null ? _c : row.value) != null ? _d : row.code) != null ? _e : row.key) != null ? _f : row.name;
|
|
41
|
+
if (rawValue === void 0 || rawValue === null) continue;
|
|
42
|
+
const rawLabel = (_j = (_i = (_h = (_g = labelKey ? row[labelKey] : void 0) != null ? _g : row.name) != null ? _h : row.label) != null ? _i : row.title) != null ? _j : rawValue;
|
|
43
|
+
options.push({ label: String(rawLabel), value: toOptionValue(rawValue) });
|
|
44
|
+
}
|
|
45
|
+
return options;
|
|
46
|
+
}
|
|
47
|
+
function extractRows(obj) {
|
|
48
|
+
for (const key of ["data", "rows", "items", "list", "records"]) {
|
|
49
|
+
if (Array.isArray(obj[key])) return obj[key];
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
function resolveFieldKind(field) {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
const widget = field.widget;
|
|
56
|
+
if (widget === "radio" || widget === "checkbox") return widget;
|
|
57
|
+
if (widget === "image" || widget === "file") return widget;
|
|
58
|
+
if (widget === "date" || widget === "datetime") return widget;
|
|
59
|
+
if (widget === "phone" || widget === "tel") return "phone";
|
|
60
|
+
if (widget === "email") return "email";
|
|
61
|
+
if (widget === "textarea") return "textarea";
|
|
62
|
+
if (widget === "switch" || field.type === "boolean") return "switch";
|
|
63
|
+
if (widget === "select" || field.options_operation || ((_a = field.options) == null ? void 0 : _a.length) || ((_b = field.enum) == null ? void 0 : _b.length)) {
|
|
64
|
+
return "select";
|
|
65
|
+
}
|
|
66
|
+
if (widget === "number" || field.type === "number" || field.type === "integer") return "number";
|
|
67
|
+
return "text";
|
|
68
|
+
}
|
|
69
|
+
function isUploadField(field) {
|
|
70
|
+
const kind = resolveFieldKind(field);
|
|
71
|
+
return kind === "image" || kind === "file";
|
|
72
|
+
}
|
|
73
|
+
function validateFieldValue(field, value) {
|
|
74
|
+
const label = field.label || field.name;
|
|
75
|
+
if (isBlankValue(value)) {
|
|
76
|
+
if (!field.required) return "";
|
|
77
|
+
return isUploadField(field) ? `\u8BF7\u5148\u4E0A\u4F20\u300C${label}\u300D` : `\u8BF7\u5148\u586B\u5199\u300C${label}\u300D`;
|
|
78
|
+
}
|
|
79
|
+
const kind = resolveFieldKind(field);
|
|
80
|
+
const text = String(value).trim();
|
|
81
|
+
if (kind === "phone") {
|
|
82
|
+
const normalized = text.replace(/[\s-]/g, "");
|
|
83
|
+
if (!/^1[3-9]\d{9}$/.test(normalized) && !/^0\d{2,3}\d{7,8}$/.test(normalized)) {
|
|
84
|
+
return `\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u300C${label}\u300D\uFF0811\u4F4D\u624B\u673A\u53F7\u6216\u56FA\u8BDD\uFF09`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (kind === "email" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(text)) {
|
|
88
|
+
return `\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u300C${label}\u300D\u90AE\u7BB1\u683C\u5F0F`;
|
|
89
|
+
}
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
function attachmentsOf(value) {
|
|
93
|
+
return Array.isArray(value) ? value.filter((item) => isPlainObject(item) && "fileName" in item) : [];
|
|
94
|
+
}
|
|
95
|
+
function displayFieldValue(field, value, options = normalizeOptions(field)) {
|
|
96
|
+
if (isUploadField(field)) {
|
|
97
|
+
const files = attachmentsOf(value);
|
|
98
|
+
return files.length ? `\u5DF2\u4E0A\u4F20 ${files.length} \u4E2A\u9644\u4EF6\uFF08${files.map((file) => file.fileName).join("\u3001")}\uFF09` : "";
|
|
99
|
+
}
|
|
100
|
+
const labelOf = (raw) => {
|
|
101
|
+
const option = options.find((opt) => opt.value === raw);
|
|
102
|
+
return !option || option.label === String(raw) ? String(raw) : `${option.label}\uFF08${String(raw)}\uFF09`;
|
|
103
|
+
};
|
|
104
|
+
if (Array.isArray(value)) return value.map(labelOf).join("\u3001");
|
|
105
|
+
if (typeof value === "boolean") return value ? "\u662F" : "\u5426";
|
|
106
|
+
return labelOf(value);
|
|
107
|
+
}
|
|
108
|
+
function buildReplyText(prefix, fields, values, optionsOf = normalizeOptions) {
|
|
109
|
+
const lines = [];
|
|
110
|
+
for (const field of fields) {
|
|
111
|
+
const value = values[field.name];
|
|
112
|
+
if (isBlankValue(value)) continue;
|
|
113
|
+
lines.push(`${field.label || field.name}\uFF1A${displayFieldValue(field, value, optionsOf(field))}`);
|
|
114
|
+
}
|
|
115
|
+
return [`${prefix}\uFF1A`, ...lines].join("\n");
|
|
116
|
+
}
|
|
117
|
+
function collectAttachments(fields, values) {
|
|
118
|
+
return fields.filter(isUploadField).flatMap((field) => attachmentsOf(values[field.name]));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export { attachmentsOf, buildReplyText, collectAttachments, displayFieldValue, extractOptions, extractRows, isBlankValue, isPlainObject, isUploadField, normalizeOptions, resolveFieldKind, validateFieldValue };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { defineComponent, openBlock, createElementBlock, normalizeClass, createCommentVNode, createTextVNode, toDisplayString, renderSlot } from 'vue';
|
|
2
|
+
|
|
3
|
+
const _hoisted_1 = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "yc-form-field__label"
|
|
6
|
+
};
|
|
7
|
+
const _hoisted_2 = {
|
|
8
|
+
key: 0,
|
|
9
|
+
class: "yc-form-field__required"
|
|
10
|
+
};
|
|
11
|
+
const _hoisted_3 = {
|
|
12
|
+
key: 1,
|
|
13
|
+
class: "yc-form-field__hint"
|
|
14
|
+
};
|
|
15
|
+
const _hoisted_4 = {
|
|
16
|
+
key: 1,
|
|
17
|
+
class: "yc-form-field__error"
|
|
18
|
+
};
|
|
19
|
+
var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
20
|
+
...{ name: "YcCardField" },
|
|
21
|
+
__name: "form-field",
|
|
22
|
+
props: {
|
|
23
|
+
label: { default: "" },
|
|
24
|
+
required: { type: Boolean, default: false },
|
|
25
|
+
hint: { default: "" },
|
|
26
|
+
error: { default: "" },
|
|
27
|
+
fullRow: { type: Boolean, default: false }
|
|
28
|
+
},
|
|
29
|
+
setup(__props) {
|
|
30
|
+
return (_ctx, _cache) => {
|
|
31
|
+
return openBlock(), createElementBlock(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
class: normalizeClass(["yc-form-field", { "is-full-row": __props.fullRow }])
|
|
35
|
+
},
|
|
36
|
+
[
|
|
37
|
+
__props.label ? (openBlock(), createElementBlock("label", _hoisted_1, [
|
|
38
|
+
__props.required ? (openBlock(), createElementBlock("span", _hoisted_2, "*")) : createCommentVNode("v-if", true),
|
|
39
|
+
createTextVNode(
|
|
40
|
+
" " + toDisplayString(__props.label) + " ",
|
|
41
|
+
1
|
|
42
|
+
/* TEXT */
|
|
43
|
+
),
|
|
44
|
+
__props.hint ? (openBlock(), createElementBlock(
|
|
45
|
+
"span",
|
|
46
|
+
_hoisted_3,
|
|
47
|
+
toDisplayString(__props.hint),
|
|
48
|
+
1
|
|
49
|
+
/* TEXT */
|
|
50
|
+
)) : createCommentVNode("v-if", true)
|
|
51
|
+
])) : createCommentVNode("v-if", true),
|
|
52
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true),
|
|
53
|
+
__props.error ? (openBlock(), createElementBlock(
|
|
54
|
+
"span",
|
|
55
|
+
_hoisted_4,
|
|
56
|
+
toDisplayString(__props.error),
|
|
57
|
+
1
|
|
58
|
+
/* TEXT */
|
|
59
|
+
)) : createCommentVNode("v-if", true)
|
|
60
|
+
],
|
|
61
|
+
2
|
|
62
|
+
/* CLASS */
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineComponent, openBlock, createElementBlock, normalizeClass, renderSlot, createTextVNode, toDisplayString } from 'vue';
|
|
2
|
+
|
|
3
|
+
const _hoisted_1 = ["role"];
|
|
4
|
+
var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
|
+
...{ name: "YcCardAlert" },
|
|
6
|
+
__name: "inline-alert",
|
|
7
|
+
props: {
|
|
8
|
+
text: {},
|
|
9
|
+
tone: { default: "info" }
|
|
10
|
+
},
|
|
11
|
+
setup(__props) {
|
|
12
|
+
return (_ctx, _cache) => {
|
|
13
|
+
return openBlock(), createElementBlock("div", {
|
|
14
|
+
class: normalizeClass(["yc-inline-alert", `is-${__props.tone}`]),
|
|
15
|
+
role: __props.tone === "error" ? "alert" : "status"
|
|
16
|
+
}, [
|
|
17
|
+
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
18
|
+
createTextVNode(
|
|
19
|
+
toDisplayString(__props.text),
|
|
20
|
+
1
|
|
21
|
+
/* TEXT */
|
|
22
|
+
)
|
|
23
|
+
], true)
|
|
24
|
+
], 10, _hoisted_1);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, createElementVNode, toDisplayString, Fragment, renderList } from 'vue';
|
|
2
|
+
|
|
3
|
+
const _hoisted_1 = ["value", "disabled"];
|
|
4
|
+
const _hoisted_2 = { value: "" };
|
|
5
|
+
const _hoisted_3 = ["value"];
|
|
6
|
+
const _hoisted_4 = ["value", "disabled", "placeholder"];
|
|
7
|
+
const _hoisted_5 = ["type", "inputmode", "step", "maxlength", "value", "disabled", "placeholder"];
|
|
8
|
+
var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
9
|
+
...{ name: "YcCardInput" },
|
|
10
|
+
__name: "input",
|
|
11
|
+
props: {
|
|
12
|
+
modelValue: { default: void 0 },
|
|
13
|
+
kind: { default: "text" },
|
|
14
|
+
placeholder: { default: "" },
|
|
15
|
+
options: { default: () => [] },
|
|
16
|
+
loading: { type: Boolean, default: false },
|
|
17
|
+
disabled: { type: Boolean, default: false },
|
|
18
|
+
invalid: { type: Boolean, default: false }
|
|
19
|
+
},
|
|
20
|
+
emits: ["update:modelValue", "blur", "focus"],
|
|
21
|
+
setup(__props, { emit: __emit }) {
|
|
22
|
+
const props = __props;
|
|
23
|
+
const emit = __emit;
|
|
24
|
+
const textValue = computed(() => {
|
|
25
|
+
const value = props.modelValue;
|
|
26
|
+
if (value === void 0 || value === null) return "";
|
|
27
|
+
if (props.kind === "datetime") return String(value).replace(" ", "T").slice(0, 16);
|
|
28
|
+
if (props.kind === "date") return String(value).slice(0, 10);
|
|
29
|
+
return String(value);
|
|
30
|
+
});
|
|
31
|
+
const inputType = computed(() => {
|
|
32
|
+
switch (props.kind) {
|
|
33
|
+
case "phone":
|
|
34
|
+
return "tel";
|
|
35
|
+
case "email":
|
|
36
|
+
return "email";
|
|
37
|
+
case "number":
|
|
38
|
+
case "integer":
|
|
39
|
+
return "number";
|
|
40
|
+
case "date":
|
|
41
|
+
return "date";
|
|
42
|
+
case "datetime":
|
|
43
|
+
return "datetime-local";
|
|
44
|
+
default:
|
|
45
|
+
return "text";
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const inputMode = computed(() => {
|
|
49
|
+
switch (props.kind) {
|
|
50
|
+
case "phone":
|
|
51
|
+
return "tel";
|
|
52
|
+
case "email":
|
|
53
|
+
return "email";
|
|
54
|
+
case "integer":
|
|
55
|
+
return "numeric";
|
|
56
|
+
case "number":
|
|
57
|
+
return "decimal";
|
|
58
|
+
default:
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
function handleInput(event) {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
const raw = (_b = (_a = event.target) == null ? void 0 : _a.value) != null ? _b : "";
|
|
65
|
+
if (props.kind === "number" || props.kind === "integer") {
|
|
66
|
+
if (raw.trim() === "") return emit("update:modelValue", void 0);
|
|
67
|
+
const num = Number(raw);
|
|
68
|
+
return emit("update:modelValue", Number.isNaN(num) ? raw : num);
|
|
69
|
+
}
|
|
70
|
+
if (props.kind === "date" || props.kind === "datetime") {
|
|
71
|
+
return emit(
|
|
72
|
+
"update:modelValue",
|
|
73
|
+
raw ? props.kind === "datetime" ? raw.replace("T", " ") : raw : void 0
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
emit("update:modelValue", raw);
|
|
77
|
+
}
|
|
78
|
+
function handleSelect(event) {
|
|
79
|
+
var _a, _b;
|
|
80
|
+
const raw = (_b = (_a = event.target) == null ? void 0 : _a.value) != null ? _b : "";
|
|
81
|
+
if (raw === "") return emit("update:modelValue", void 0);
|
|
82
|
+
const matched = props.options.find((opt) => String(opt.value) === raw);
|
|
83
|
+
emit("update:modelValue", matched ? matched.value : raw);
|
|
84
|
+
}
|
|
85
|
+
return (_ctx, _cache) => {
|
|
86
|
+
return __props.kind === "select" ? (openBlock(), createElementBlock("select", {
|
|
87
|
+
key: 0,
|
|
88
|
+
value: __props.modelValue === void 0 || __props.modelValue === null ? "" : String(__props.modelValue),
|
|
89
|
+
disabled: __props.disabled,
|
|
90
|
+
class: normalizeClass(["yc-input is-select", { "is-invalid": __props.invalid }]),
|
|
91
|
+
onFocus: _cache[0] || (_cache[0] = ($event) => emit("focus")),
|
|
92
|
+
onChange: handleSelect,
|
|
93
|
+
onBlur: _cache[1] || (_cache[1] = ($event) => emit("blur"))
|
|
94
|
+
}, [
|
|
95
|
+
createElementVNode(
|
|
96
|
+
"option",
|
|
97
|
+
_hoisted_2,
|
|
98
|
+
toDisplayString(__props.loading ? "\u52A0\u8F7D\u9009\u9879\u4E2D\u2026" : __props.placeholder),
|
|
99
|
+
1
|
|
100
|
+
/* TEXT */
|
|
101
|
+
),
|
|
102
|
+
(openBlock(true), createElementBlock(
|
|
103
|
+
Fragment,
|
|
104
|
+
null,
|
|
105
|
+
renderList(__props.options, (opt) => {
|
|
106
|
+
return openBlock(), createElementBlock("option", {
|
|
107
|
+
key: String(opt.value),
|
|
108
|
+
value: String(opt.value)
|
|
109
|
+
}, toDisplayString(opt.label), 9, _hoisted_3);
|
|
110
|
+
}),
|
|
111
|
+
128
|
|
112
|
+
/* KEYED_FRAGMENT */
|
|
113
|
+
))
|
|
114
|
+
], 42, _hoisted_1)) : __props.kind === "textarea" ? (openBlock(), createElementBlock("textarea", {
|
|
115
|
+
key: 1,
|
|
116
|
+
rows: "3",
|
|
117
|
+
value: textValue.value,
|
|
118
|
+
disabled: __props.disabled,
|
|
119
|
+
placeholder: __props.placeholder,
|
|
120
|
+
class: normalizeClass(["yc-input is-textarea", { "is-invalid": __props.invalid }]),
|
|
121
|
+
onFocus: _cache[2] || (_cache[2] = ($event) => emit("focus")),
|
|
122
|
+
onInput: handleInput,
|
|
123
|
+
onBlur: _cache[3] || (_cache[3] = ($event) => emit("blur"))
|
|
124
|
+
}, null, 42, _hoisted_4)) : (openBlock(), createElementBlock("input", {
|
|
125
|
+
key: 2,
|
|
126
|
+
type: inputType.value,
|
|
127
|
+
inputmode: inputMode.value,
|
|
128
|
+
step: __props.kind === "integer" ? "1" : __props.kind === "number" ? "any" : void 0,
|
|
129
|
+
maxlength: __props.kind === "phone" ? 20 : void 0,
|
|
130
|
+
value: textValue.value,
|
|
131
|
+
disabled: __props.disabled,
|
|
132
|
+
placeholder: __props.placeholder,
|
|
133
|
+
class: normalizeClass(["yc-input", { "is-invalid": __props.invalid }]),
|
|
134
|
+
onFocus: _cache[4] || (_cache[4] = ($event) => emit("focus")),
|
|
135
|
+
onInput: handleInput,
|
|
136
|
+
onBlur: _cache[5] || (_cache[5] = ($event) => emit("blur"))
|
|
137
|
+
}, null, 42, _hoisted_5));
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
export { _sfc_main as default };
|