@opentinyvue/vue-autocomplete 2.21.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 ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 - present TinyVue Authors.
4
+ Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/index.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) 2022 - present TinyVue Authors.
3
+ * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license.
6
+ *
7
+ * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8
+ * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9
+ * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10
+ *
11
+ */
12
+ import Autocomplete from './src/index';
13
+ export default Autocomplete;
package/lib/index.js ADDED
@@ -0,0 +1,124 @@
1
+ function _extends() {
2
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
3
+ for (var e = 1; e < arguments.length; e++) {
4
+ var t = arguments[e];
5
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
6
+ }
7
+ return n;
8
+ }, _extends.apply(null, arguments);
9
+ }
10
+ import { defineComponent, $prefix, $setup, $props } from "@opentinyvue/vue-common";
11
+ import PcTemplate from "./pc.js";
12
+ import "@opentinyvue/vue-theme/autocomplete/index.css";
13
+ var template = function template2(mode) {
14
+ var _process$env;
15
+ typeof process === "object" ? (_process$env = process.env) == null ? void 0 : _process$env.TINY_MODE : null;
16
+ return PcTemplate;
17
+ };
18
+ var $constants = {
19
+ WARP_CLS: ".tiny-autocomplete-suggestion__wrap",
20
+ ITEM_CLS: ".tiny-autocomplete-suggestion__list li"
21
+ };
22
+ var autoCompleteProps = _extends({}, $props, {
23
+ _constants: {
24
+ type: Object,
25
+ default: function _default() {
26
+ return $constants;
27
+ }
28
+ },
29
+ autofocus: Boolean,
30
+ clearable: {
31
+ type: Boolean,
32
+ default: function _default2() {
33
+ return false;
34
+ }
35
+ },
36
+ customItem: String,
37
+ debounce: {
38
+ type: Number,
39
+ default: function _default3() {
40
+ return 300;
41
+ }
42
+ },
43
+ disabled: Boolean,
44
+ fetchSuggestions: Function,
45
+ hideLoading: Boolean,
46
+ highlightFirstItem: {
47
+ type: Boolean,
48
+ default: function _default4() {
49
+ return false;
50
+ }
51
+ },
52
+ label: String,
53
+ maxlength: Number,
54
+ minlength: Number,
55
+ modelValue: String,
56
+ name: String,
57
+ placeholder: String,
58
+ placement: {
59
+ type: String,
60
+ default: function _default5() {
61
+ return "bottom-start";
62
+ }
63
+ },
64
+ popperAppendToBody: {
65
+ type: Boolean,
66
+ default: function _default6() {
67
+ return true;
68
+ }
69
+ },
70
+ popperClass: String,
71
+ popperOptions: Object,
72
+ prefixIcon: [String, Object],
73
+ selectWhenUnmatched: {
74
+ type: Boolean,
75
+ default: function _default7() {
76
+ return false;
77
+ }
78
+ },
79
+ size: String,
80
+ suffixIcon: [String, Object],
81
+ triggerOnFocus: {
82
+ type: Boolean,
83
+ default: function _default8() {
84
+ return true;
85
+ }
86
+ },
87
+ valueKey: {
88
+ type: String,
89
+ default: function _default9() {
90
+ return "value";
91
+ }
92
+ },
93
+ displayOnly: {
94
+ type: Boolean,
95
+ default: false
96
+ },
97
+ validateEvent: {
98
+ type: Boolean,
99
+ default: void 0
100
+ }
101
+ });
102
+ var Autocomplete = defineComponent({
103
+ name: $prefix + "Autocomplete",
104
+ props: autoCompleteProps,
105
+ setup: function setup(props, context) {
106
+ return $setup({
107
+ props,
108
+ context,
109
+ template
110
+ });
111
+ }
112
+ });
113
+ var version = "2.21.0";
114
+ Autocomplete.model = {
115
+ prop: "modelValue",
116
+ event: "update:modelValue"
117
+ };
118
+ Autocomplete.install = function(Vue) {
119
+ Vue.component(Autocomplete.name, Autocomplete);
120
+ };
121
+ Autocomplete.version = version;
122
+ export {
123
+ Autocomplete as default
124
+ };
package/lib/pc.js ADDED
@@ -0,0 +1,218 @@
1
+ import { renderless, api } from '@opentinyvue/vue-renderless/autocomplete/vue';
2
+ import { defineComponent, directive, props, setup } from '@opentinyvue/vue-common';
3
+ import Scrollbar from '@opentinyvue/vue-scrollbar';
4
+ import Input from '@opentinyvue/vue-input';
5
+ import Clickoutside from '@opentinyvue/vue-renderless/common/deps/clickoutside';
6
+ import { IconLoadingShadow } from '@opentinyvue/vue-icon';
7
+
8
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
9
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
10
+ if (render) {
11
+ options.render = render;
12
+ options.staticRenderFns = staticRenderFns;
13
+ options._compiled = true;
14
+ }
15
+ var hook;
16
+ if (injectStyles) {
17
+ hook = injectStyles;
18
+ }
19
+ if (hook) {
20
+ if (options.functional) {
21
+ options._injectStyles = hook;
22
+ var originalRender = options.render;
23
+ options.render = function renderWithStyleInjection(h, context) {
24
+ hook.call(context);
25
+ return originalRender(h, context);
26
+ };
27
+ } else {
28
+ var existing = options.beforeCreate;
29
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
30
+ }
31
+ }
32
+ return {
33
+ exports: scriptExports,
34
+ options
35
+ };
36
+ }
37
+
38
+ var __vue2_script = defineComponent({
39
+ components: {
40
+ TinyInput: Input,
41
+ TinyScrollbar: Scrollbar,
42
+ IconLoadingShadow: IconLoadingShadow()
43
+ },
44
+ directives: directive({
45
+ Clickoutside
46
+ }),
47
+ props: [].concat(props, ["valueKey", "popperClass", "tabindex", "popperOptions", "placeholder", "clearable", "disabled", "name", "size", "modelValue", "maxlength", "minlength", "autofocus", "fetchSuggestions", "triggerOnFocus", "customItem", "selectWhenUnmatched", "prefixIcon", "suffixIcon", "label", "debounce", "placement", "hideLoading", "popperAppendToBody", "highlightFirstItem", "displayOnly", "validateEvent"]),
48
+ emits: ["update:modelValue", "focus", "blur", "clear", "select", "created"],
49
+ setup: function setup$1(props2, context) {
50
+ return setup({
51
+ props: props2,
52
+ context,
53
+ renderless,
54
+ api
55
+ });
56
+ }
57
+ });
58
+ var render = function render2() {
59
+ var _vm = this;
60
+ var _h = _vm.$createElement;
61
+ var _c = _vm._self._c || _h;
62
+ return _c("div", {
63
+ directives: [{
64
+ name: "clickoutside",
65
+ rawName: "v-clickoutside",
66
+ value: _vm.close,
67
+ expression: "close"
68
+ }],
69
+ class: ["tiny-autocomplete", {
70
+ "show-auto-width": _vm.state.showAutoWidth
71
+ }],
72
+ attrs: {
73
+ "aria-haspopup": "listbox",
74
+ "role": "combobox",
75
+ "aria-expanded": _vm.state.suggestionVisible,
76
+ "aria-owns": _vm.state.id
77
+ }
78
+ }, [_c("tiny-input", _vm._b({
79
+ directives: [{
80
+ name: "clickoutside",
81
+ rawName: "v-clickoutside",
82
+ value: _vm.handleBlur,
83
+ expression: "handleBlur"
84
+ }],
85
+ ref: "input",
86
+ attrs: {
87
+ "tabindex": _vm.tabindex,
88
+ "display-only": _vm.displayOnly,
89
+ "front-clear-icon": "",
90
+ "validate-event": false
91
+ },
92
+ on: {
93
+ "update:modelValue": _vm.handleChange,
94
+ "focus": _vm.handleFocus,
95
+ "clear": _vm.handleClear,
96
+ "keydown": [function($event) {
97
+ if (!$event.type.indexOf("key") && _vm._k($event.keyCode, "up", 38, $event.key, ["Up", "ArrowUp"])) return null;
98
+ $event.preventDefault();
99
+ return _vm.highlight(_vm.state.highlightedIndex - 1);
100
+ }, function($event) {
101
+ if (!$event.type.indexOf("key") && _vm._k($event.keyCode, "down", 40, $event.key, ["Down", "ArrowDown"])) return null;
102
+ $event.preventDefault();
103
+ return _vm.highlight(_vm.state.highlightedIndex + 1);
104
+ }, function($event) {
105
+ if (!$event.type.indexOf("key") && _vm._k($event.keyCode, "enter", 13, $event.key, "Enter")) return null;
106
+ return _vm.handleKeyEnter.apply(null, arguments);
107
+ }, function($event) {
108
+ if (!$event.type.indexOf("key") && _vm._k($event.keyCode, "tab", 9, $event.key, "Tab")) return null;
109
+ return _vm.close.apply(null, arguments);
110
+ }]
111
+ },
112
+ scopedSlots: _vm._u([_vm.slots.prepend ? {
113
+ key: "prepend",
114
+ fn: function fn() {
115
+ return [_vm._t("prepend")];
116
+ },
117
+ proxy: true
118
+ } : null, _vm.slots.append ? {
119
+ key: "append",
120
+ fn: function fn() {
121
+ return [_vm._t("append")];
122
+ },
123
+ proxy: true
124
+ } : null, _vm.slots.prefix ? {
125
+ key: "prefix",
126
+ fn: function fn() {
127
+ return [_vm._t("prefix")];
128
+ },
129
+ proxy: true
130
+ } : null, _vm.slots.suffix ? {
131
+ key: "suffix",
132
+ fn: function fn() {
133
+ return [_vm._t("suffix")];
134
+ },
135
+ proxy: true
136
+ } : null], null, true)
137
+ }, "tiny-input", _vm.f(_vm.$props, _vm.$attrs), false)), _c("transition", {
138
+ attrs: {
139
+ "name": "tiny-zoom-in-top"
140
+ },
141
+ on: {
142
+ "after-leave": _vm.doDestroy
143
+ }
144
+ }, [_c("div", {
145
+ directives: [{
146
+ name: "show",
147
+ rawName: "v-show",
148
+ value: _vm.hideLoading ? _vm.suggestionState.showPopper && !_vm.state.loading : _vm.suggestionState.showPopper,
149
+ expression: "hideLoading ? suggestionState.showPopper && !state.loading : suggestionState.showPopper"
150
+ }],
151
+ ref: "popper",
152
+ staticClass: "tiny-autocomplete-suggestion tiny-popper",
153
+ class: [_vm.popperClass ? _vm.popperClass : "", {
154
+ "is-loading": !_vm.hideLoading && _vm.state.loading
155
+ }],
156
+ style: {
157
+ width: _vm.suggestionState.dropdownWidth
158
+ },
159
+ attrs: {
160
+ "role": "region"
161
+ }
162
+ }, [_c("tiny-scrollbar", {
163
+ attrs: {
164
+ "tag": "ul",
165
+ "wrap-class": "tiny-autocomplete-suggestion__wrap",
166
+ "view-class": "tiny-autocomplete-suggestion__list"
167
+ }
168
+ }, [_vm._t("panel", function() {
169
+ return [!_vm.hideLoading && _vm.state.loading ? _c("li", {
170
+ staticClass: "tiny-autocomplete-suggestion__list-item tiny-autocomplete-suggestion__list-loading",
171
+ attrs: {
172
+ "role": "loading"
173
+ }
174
+ }, [_c("icon-loading-shadow")], 1) : _vm._l(_vm.state.suggestions, function(item, index) {
175
+ return _c("li", {
176
+ key: index,
177
+ staticClass: "tiny-autocomplete-suggestion__list-item",
178
+ class: {
179
+ highlighted: _vm.state.highlightedIndex === index,
180
+ selected: _vm.modelValue === item[_vm.valueKey]
181
+ },
182
+ attrs: {
183
+ "id": _vm.state.id + "-item-" + index,
184
+ "role": "option",
185
+ "aria-selected": _vm.state.highlightedIndex === index
186
+ },
187
+ on: {
188
+ "click": function click($event) {
189
+ return _vm.select(item);
190
+ }
191
+ }
192
+ }, [_vm._t("default", function() {
193
+ return [_vm._v(" " + _vm._s(item[_vm.valueKey]) + " ")];
194
+ }, {
195
+ "slotScope": item
196
+ })], 2);
197
+ })];
198
+ }, {
199
+ "loading": !_vm.hideLoading && _vm.state.loading,
200
+ "list": _vm.state.suggestions,
201
+ "highlighted": _vm.state.highlightedIndex,
202
+ "id": _vm.state.id,
203
+ "select": _vm.select
204
+ })], 2)], 1)])], 1);
205
+ };
206
+ var staticRenderFns = [];
207
+ var __cssModules = {};
208
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
209
+ function __vue2_injectStyles(context) {
210
+ for (var o in __cssModules) {
211
+ this[o] = __cssModules[o];
212
+ }
213
+ }
214
+ var pc = /* @__PURE__ */ function() {
215
+ return __component__.exports;
216
+ }();
217
+
218
+ export { pc as default };
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@opentinyvue/vue-autocomplete",
3
+ "type": "module",
4
+ "version": "2.21.0",
5
+ "description": "",
6
+ "license": "MIT",
7
+ "sideEffects": false,
8
+ "main": "./lib/index.js",
9
+ "module": "./lib/index.js",
10
+ "dependencies": {
11
+ "@opentinyvue/vue-common": "~2.21.0",
12
+ "@opentinyvue/vue-icon": "~2.21.0",
13
+ "@opentinyvue/vue-input": "~2.21.0",
14
+ "@opentinyvue/vue-renderless": "~3.21.0",
15
+ "@opentinyvue/vue-scrollbar": "~2.21.0",
16
+ "@opentinyvue/vue-theme": "~3.21.0"
17
+ },
18
+ "types": "index.d.ts",
19
+ "scripts": {
20
+ "build": "pnpm -w build:ui $npm_package_name",
21
+ "//postversion": "pnpm build"
22
+ }
23
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,73 @@
1
+ export declare const autoCompleteProps: {
2
+ _constants: {
3
+ type: ObjectConstructor;
4
+ default: () => {
5
+ WARP_CLS: string;
6
+ ITEM_CLS: string;
7
+ };
8
+ };
9
+ autofocus: BooleanConstructor;
10
+ clearable: {
11
+ type: BooleanConstructor;
12
+ default: () => boolean;
13
+ };
14
+ customItem: StringConstructor;
15
+ debounce: {
16
+ type: NumberConstructor;
17
+ default: () => number;
18
+ };
19
+ disabled: BooleanConstructor;
20
+ fetchSuggestions: FunctionConstructor;
21
+ hideLoading: BooleanConstructor;
22
+ highlightFirstItem: {
23
+ type: BooleanConstructor;
24
+ default: () => boolean;
25
+ };
26
+ label: StringConstructor;
27
+ maxlength: NumberConstructor;
28
+ minlength: NumberConstructor;
29
+ modelValue: StringConstructor;
30
+ name: StringConstructor;
31
+ placeholder: StringConstructor;
32
+ placement: {
33
+ type: StringConstructor;
34
+ default: () => string;
35
+ };
36
+ popperAppendToBody: {
37
+ type: BooleanConstructor;
38
+ default: () => boolean;
39
+ };
40
+ popperClass: StringConstructor;
41
+ popperOptions: ObjectConstructor;
42
+ prefixIcon: (StringConstructor | ObjectConstructor)[];
43
+ selectWhenUnmatched: {
44
+ type: BooleanConstructor;
45
+ default: () => boolean;
46
+ };
47
+ size: StringConstructor;
48
+ suffixIcon: (StringConstructor | ObjectConstructor)[];
49
+ triggerOnFocus: {
50
+ type: BooleanConstructor;
51
+ default: () => boolean;
52
+ };
53
+ valueKey: {
54
+ type: StringConstructor;
55
+ default: () => string;
56
+ };
57
+ displayOnly: {
58
+ type: BooleanConstructor;
59
+ default: boolean;
60
+ };
61
+ validateEvent: {
62
+ type: BooleanConstructor;
63
+ default: undefined;
64
+ };
65
+ tiny_mode: StringConstructor;
66
+ tiny_mode_root: BooleanConstructor;
67
+ tiny_template: (ObjectConstructor | FunctionConstructor)[];
68
+ tiny_renderless: FunctionConstructor;
69
+ tiny_theme: StringConstructor;
70
+ tiny_chart_theme: ObjectConstructor;
71
+ };
72
+ declare const _default: any;
73
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;