@fangzhongya/fang-ui 0.0.36 → 0.0.37

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.
@@ -20,23 +20,23 @@ $input-select: 'input-select';
20
20
  }
21
21
  }
22
22
  &.is-disabled {
23
- .#{$input-selects}-select-icon {
23
+ .#{$input-select}-select-icon {
24
24
  cursor: not-allowed;
25
25
  }
26
26
  }
27
27
  &-popper {
28
28
  padding: 6px 0 !important;
29
- .#{$input-selects}-select {
29
+ .#{$input-select}-select {
30
30
  max-height: 274px;
31
31
  height: 100%;
32
32
  overflow-y: auto;
33
- .#{$input-selects}-select-ul {
33
+ .#{$input-select}-select-ul {
34
34
  list-style: none;
35
35
  margin: 6px 0;
36
36
  padding: 0;
37
37
  box-sizing: border-box;
38
38
  }
39
- .#{$input-selects}-select-li {
39
+ .#{$input-select}-select-li {
40
40
  padding: 0 32px 0 20px;
41
41
  position: relative;
42
42
  white-space: nowrap;
@@ -1,7 +1,222 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const index_vue_vue_type_script_setup_true_lang = require("./index2.cjs");
4
- ;/* empty css */
5
- const _pluginVue_exportHelper = require("../../../_virtual/_plugin-vue_export-helper.cjs");
6
- const SrcVue = /* @__PURE__ */ _pluginVue_exportHelper.default(index_vue_vue_type_script_setup_true_lang.default, [["__scopeId", "data-v-98c7f863"]]);
7
- exports.default = SrcVue;
3
+ const vue = require("vue");
4
+ const data = require("./data.cjs");
5
+ const index$3 = require("element-plus/es/components/input/index");
6
+ const index$2 = require("element-plus/es/components/popover/index");
7
+ const index = require("../../../hooks/inherit/index.cjs");
8
+ const use = require("../../common/use.cjs");
9
+ const index$1 = require("../../../hooks/cssname/index.cjs");
10
+ const getCss = require("@fangzhongya/utils/css/getCss");
11
+ const _hoisted_1 = ["onClick"];
12
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
13
+ ...{ inheritAttrs: false },
14
+ __name: "index",
15
+ props: data.dataProps,
16
+ emits: data.dataEmits,
17
+ setup(__props, { expose: __expose, emit: __emit }) {
18
+ const attrs = index.useInherit(vue.useAttrs());
19
+ const slots = vue.useSlots();
20
+ const cs = index$1.useCssName("input-select");
21
+ const props = __props;
22
+ const emit = __emit;
23
+ const visible = vue.ref(false);
24
+ const width = vue.ref(200);
25
+ const refInput = vue.ref();
26
+ const isfocus = vue.ref(false);
27
+ const isFiletr = vue.ref(false);
28
+ const value = vue.computed({
29
+ get() {
30
+ let v = props.modelValue;
31
+ return v;
32
+ },
33
+ set(value2) {
34
+ emit("update:modelValue", value2);
35
+ }
36
+ });
37
+ const options = vue.computed(() => {
38
+ if (props.filterable && value.value && isFiletr.value) {
39
+ return props.options.filter((o) => {
40
+ return (use.useVueValue(o, props.prop) + "").includes(
41
+ value.value || ""
42
+ );
43
+ });
44
+ }
45
+ return props.options;
46
+ });
47
+ const isclear = vue.computed(() => {
48
+ if (props.readonly) {
49
+ return false;
50
+ }
51
+ if (props.clearable && value.value && isfocus.value) {
52
+ return true;
53
+ }
54
+ return false;
55
+ });
56
+ function setWidth() {
57
+ if (refInput.value && refInput.value.ref) {
58
+ width.value = getCss.getCss(refInput.value.ref, "width");
59
+ }
60
+ }
61
+ function onClickSelect(item) {
62
+ if (!item.disabled) {
63
+ value.value = use.useVueValue(item, props.prop);
64
+ emit("change", value.value, item);
65
+ visible.value = false;
66
+ isFiletr.value = false;
67
+ }
68
+ }
69
+ function getSelected(item) {
70
+ const v = use.useVueValue(item, props.prop);
71
+ if (v === value.value) {
72
+ return "selected";
73
+ } else {
74
+ return;
75
+ }
76
+ }
77
+ function onInput(v, ...arr) {
78
+ emit("input", v, ...arr);
79
+ if (props.filterable) {
80
+ isFiletr.value = true;
81
+ visible.value = true;
82
+ }
83
+ }
84
+ let timeout;
85
+ function onBlur(...arr) {
86
+ emit("blur", ...arr);
87
+ timeout = setTimeout(() => {
88
+ isfocus.value = false;
89
+ visible.value = false;
90
+ }, 200);
91
+ }
92
+ function clearBlur() {
93
+ clearTimeout(timeout);
94
+ }
95
+ function onFocus(...arr) {
96
+ isfocus.value = true;
97
+ clearBlur();
98
+ emit("focus", ...arr);
99
+ }
100
+ function onClear() {
101
+ clearBlur();
102
+ value.value = "";
103
+ refInput.value.focus();
104
+ }
105
+ function onClick() {
106
+ if (!props.readonly) {
107
+ isFiletr.value = false;
108
+ visible.value = !visible.value;
109
+ }
110
+ }
111
+ vue.onMounted(() => {
112
+ setWidth();
113
+ });
114
+ __expose({
115
+ ...data.dataExpose
116
+ });
117
+ return (_ctx, _cache) => {
118
+ return vue.openBlock(), vue.createBlock(vue.unref(index$2.ElPopover), {
119
+ trigger: "click",
120
+ "popper-class": vue.unref(cs).z("popper"),
121
+ visible: visible.value,
122
+ disabled: props.disabled || !(options.value && options.value.length > 0),
123
+ width: width.value
124
+ }, {
125
+ reference: vue.withCtx(() => [
126
+ vue.createElementVNode("div", vue.mergeProps({
127
+ class: [vue.unref(cs).z(), vue.unref(cs).is("disabled", props.disabled)]
128
+ }, vue.unref(attrs).root, { onClick }), [
129
+ vue.createVNode(vue.unref(index$3.ElInput), vue.mergeProps({
130
+ ref_key: "refInput",
131
+ ref: refInput,
132
+ modelValue: value.value,
133
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event)
134
+ }, vue.unref(attrs).assem, {
135
+ disabled: props.disabled,
136
+ readonly: props.readonly,
137
+ onInput,
138
+ onFocus,
139
+ onBlur,
140
+ clearable: false
141
+ }), vue.createSlots({
142
+ suffix: vue.withCtx(() => [
143
+ isclear.value ? (vue.openBlock(), vue.createElementBlock("span", {
144
+ key: 0,
145
+ class: vue.normalizeClass([vue.unref(cs).z("select-icon"), "clear"]),
146
+ onClick: vue.withModifiers(onClear, ["stop"])
147
+ }, _cache[1] || (_cache[1] = [
148
+ vue.createElementVNode("svg", {
149
+ viewBox: "0 0 1024 1024",
150
+ xmlns: "http://www.w3.org/2000/svg",
151
+ "data-v-ea893728": ""
152
+ }, [
153
+ vue.createElementVNode("path", {
154
+ fill: "currentColor",
155
+ d: "m466.752 512-90.496-90.496a32 32 0 0 1 45.248-45.248L512 466.752l90.496-90.496a32 32 0 1 1 45.248 45.248L557.248 512l90.496 90.496a32 32 0 1 1-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 0 1-45.248-45.248L466.752 512z"
156
+ }),
157
+ vue.createElementVNode("path", {
158
+ fill: "currentColor",
159
+ d: "M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896z"
160
+ })
161
+ ], -1)
162
+ ]), 2)) : vue.createCommentVNode("", true),
163
+ vue.renderSlot(_ctx.$slots, vue.unref(data.dataSlot).suffix),
164
+ vue.createElementVNode("span", {
165
+ class: vue.normalizeClass([
166
+ vue.unref(cs).z("select-icon"),
167
+ vue.unref(cs).is("reverse", visible.value)
168
+ ])
169
+ }, [
170
+ vue.renderSlot(_ctx.$slots, vue.unref(data.dataSlot).iconSelect, {}, () => [
171
+ _cache[2] || (_cache[2] = vue.createElementVNode("svg", {
172
+ viewBox: "0 0 1024 1024",
173
+ xmlns: "http://www.w3.org/2000/svg",
174
+ "data-v-ea893728": ""
175
+ }, [
176
+ vue.createElementVNode("path", {
177
+ fill: "currentColor",
178
+ d: "M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"
179
+ })
180
+ ], -1))
181
+ ])
182
+ ], 2)
183
+ ]),
184
+ _: 2
185
+ }, [
186
+ vue.renderList(Object.keys(vue.unref(slots)), (k, index2) => {
187
+ return {
188
+ name: k,
189
+ fn: vue.withCtx(() => [
190
+ vue.renderSlot(_ctx.$slots, k)
191
+ ])
192
+ };
193
+ })
194
+ ]), 1040, ["modelValue", "disabled", "readonly"])
195
+ ], 16)
196
+ ]),
197
+ default: vue.withCtx(() => [
198
+ vue.createElementVNode("div", {
199
+ class: vue.normalizeClass(vue.unref(cs).z("select"))
200
+ }, [
201
+ vue.createElementVNode("ul", {
202
+ class: vue.normalizeClass(vue.unref(cs).z("select-ul"))
203
+ }, [
204
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(options.value, (item) => {
205
+ return vue.openBlock(), vue.createElementBlock("li", {
206
+ class: vue.normalizeClass([
207
+ vue.unref(cs).z("select-li"),
208
+ vue.unref(cs).is("disabled", item?.disabled),
209
+ getSelected(item)
210
+ ]),
211
+ onClick: vue.withModifiers(($event) => onClickSelect(item), ["stop"])
212
+ }, vue.toDisplayString(vue.unref(use.useVueValue)(item, props.label)), 11, _hoisted_1);
213
+ }), 256))
214
+ ], 2)
215
+ ], 2)
216
+ ]),
217
+ _: 3
218
+ }, 8, ["popper-class", "visible", "disabled", "width"]);
219
+ };
220
+ }
221
+ });
222
+ exports.default = _sfc_main;