@phoenix-cg/v-filters 0.1.15 → 0.1.17
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/.browserslistrc +3 -3
- package/.eslintrc.js +26 -26
- package/README.md +39 -39
- package/babel.config.js +3 -3
- package/dist/v-filters.common.js +50 -7
- package/dist/v-filters.common.js.map +1 -1
- package/dist/v-filters.umd.js +50 -7
- package/dist/v-filters.umd.js.map +1 -1
- package/dist/v-filters.umd.min.js +1 -1
- package/dist/v-filters.umd.min.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +45 -45
- package/postcss.config.js +24 -24
- package/public/index.html +17 -17
- package/src/App.vue +28 -28
- package/src/components/VFilters.vue +283 -278
- package/src/export.js +2 -2
- package/src/main.js +8 -8
- package/tests/unit/example.spec.js +12 -12
- package/vue.config.js +6 -6
package/.browserslistrc
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
> 1%
|
|
2
|
-
last 2 versions
|
|
3
|
-
not dead
|
|
1
|
+
> 1%
|
|
2
|
+
last 2 versions
|
|
3
|
+
not dead
|
package/.eslintrc.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
env: {
|
|
4
|
-
node: true
|
|
5
|
-
},
|
|
6
|
-
extends: ["plugin:vue/essential", "eslint:recommended"],
|
|
7
|
-
parserOptions: {
|
|
8
|
-
parser: "babel-eslint"
|
|
9
|
-
},
|
|
10
|
-
rules: {
|
|
11
|
-
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
|
|
12
|
-
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
|
|
13
|
-
'quotes': ['error', 'single']
|
|
14
|
-
},
|
|
15
|
-
overrides: [
|
|
16
|
-
{
|
|
17
|
-
files: [
|
|
18
|
-
"**/__tests__/*.{j,t}s?(x)",
|
|
19
|
-
"**/tests/unit/**/*.spec.{j,t}s?(x)"
|
|
20
|
-
],
|
|
21
|
-
env: {
|
|
22
|
-
jest: true
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: {
|
|
4
|
+
node: true
|
|
5
|
+
},
|
|
6
|
+
extends: ["plugin:vue/essential", "eslint:recommended"],
|
|
7
|
+
parserOptions: {
|
|
8
|
+
parser: "babel-eslint"
|
|
9
|
+
},
|
|
10
|
+
rules: {
|
|
11
|
+
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
|
|
12
|
+
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
|
|
13
|
+
'quotes': ['error', 'single']
|
|
14
|
+
},
|
|
15
|
+
overrides: [
|
|
16
|
+
{
|
|
17
|
+
files: [
|
|
18
|
+
"**/__tests__/*.{j,t}s?(x)",
|
|
19
|
+
"**/tests/unit/**/*.spec.{j,t}s?(x)"
|
|
20
|
+
],
|
|
21
|
+
env: {
|
|
22
|
+
jest: true
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
};
|
package/README.md
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
# v-filters
|
|
2
|
-
|
|
3
|
-
## Project setup
|
|
4
|
-
```
|
|
5
|
-
npm install @phoenix-cg/v-filters
|
|
6
|
-
```
|
|
7
|
-
|
|
8
|
-
## Props
|
|
9
|
-
|
|
10
|
-
| Props | Description | Default value |
|
|
11
|
-
|--------------------|----------------------------------------------------------------------------------------------------------------------------------|----------------|
|
|
12
|
-
| componentsMap | [Object], required. Object with components name mapping to field types | none |
|
|
13
|
-
| fieldComponentName | [String] Component for field rendering. Should has "title" prop and a slot for field component | v-filter-field |
|
|
14
|
-
| fields | [Array], required. Array with fields | none |
|
|
15
|
-
| showWords | [Array] Array with words to put before found result count. First element should be in future tense and a last one in past tense. | [] |
|
|
16
|
-
| notFoundTitle | [String] Will be shown in button if count is 0 | '' |
|
|
17
|
-
| declensionWords | [Array] Array of words to put after found result count. | [] |
|
|
18
|
-
| count | [Number] Found count | 0 |
|
|
19
|
-
| showParams | [Boolean] If true current filters state will be reflected in page query params. | true |
|
|
20
|
-
| isResultShown | [Boolean] If true action button title will be constructed in past tense | false |
|
|
21
|
-
| humanLink | [String] Human link feature | '' |
|
|
22
|
-
| editedOutside | [Boolean] If true reset button will be shown even if the v-filters itself is untouched. | false |
|
|
23
|
-
| immediate | [Boolean] If true action button will not be shown and show-result event will fire immediately after change | false |
|
|
24
|
-
|
|
25
|
-
## Slots
|
|
26
|
-
|
|
27
|
-
| Slot | Description | Scope |
|
|
28
|
-
|---------------|-----------------------------------------|--------------------------------------------------------|
|
|
29
|
-
| before-fields | Slot to place anything before fields | none |
|
|
30
|
-
| after-fields | Slot to place anything after fields | none |
|
|
31
|
-
| actions | Slot for actions. Displays after fields | { showResult, resetFilters, count, immediate, edited } |
|
|
32
|
-
| actions-after | Slot for actions. Displays after fields | { showResult, resetFilters, count, immediate, edited } |
|
|
33
|
-
|
|
34
|
-
## Events
|
|
35
|
-
|
|
36
|
-
| Event | Description | Payload |
|
|
37
|
-
|---------------|---------------------|-----------------------------------------|
|
|
38
|
-
| request-count | Request count event | flatFilters: { ..., name: [1, 2] ,... } |
|
|
39
|
-
| show-result | Show result event | flatFilters: { ..., name: [1, 2],... } |
|
|
1
|
+
# v-filters
|
|
2
|
+
|
|
3
|
+
## Project setup
|
|
4
|
+
```
|
|
5
|
+
npm install @phoenix-cg/v-filters
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Props
|
|
9
|
+
|
|
10
|
+
| Props | Description | Default value |
|
|
11
|
+
|--------------------|----------------------------------------------------------------------------------------------------------------------------------|----------------|
|
|
12
|
+
| componentsMap | [Object], required. Object with components name mapping to field types | none |
|
|
13
|
+
| fieldComponentName | [String] Component for field rendering. Should has "title" prop and a slot for field component | v-filter-field |
|
|
14
|
+
| fields | [Array], required. Array with fields | none |
|
|
15
|
+
| showWords | [Array] Array with words to put before found result count. First element should be in future tense and a last one in past tense. | [] |
|
|
16
|
+
| notFoundTitle | [String] Will be shown in button if count is 0 | '' |
|
|
17
|
+
| declensionWords | [Array] Array of words to put after found result count. | [] |
|
|
18
|
+
| count | [Number] Found count | 0 |
|
|
19
|
+
| showParams | [Boolean] If true current filters state will be reflected in page query params. | true |
|
|
20
|
+
| isResultShown | [Boolean] If true action button title will be constructed in past tense | false |
|
|
21
|
+
| humanLink | [String] Human link feature | '' |
|
|
22
|
+
| editedOutside | [Boolean] If true reset button will be shown even if the v-filters itself is untouched. | false |
|
|
23
|
+
| immediate | [Boolean] If true action button will not be shown and show-result event will fire immediately after change | false |
|
|
24
|
+
|
|
25
|
+
## Slots
|
|
26
|
+
|
|
27
|
+
| Slot | Description | Scope |
|
|
28
|
+
|---------------|-----------------------------------------|--------------------------------------------------------|
|
|
29
|
+
| before-fields | Slot to place anything before fields | none |
|
|
30
|
+
| after-fields | Slot to place anything after fields | none |
|
|
31
|
+
| actions | Slot for actions. Displays after fields | { showResult, resetFilters, count, immediate, edited } |
|
|
32
|
+
| actions-after | Slot for actions. Displays after fields | { showResult, resetFilters, count, immediate, edited } |
|
|
33
|
+
|
|
34
|
+
## Events
|
|
35
|
+
|
|
36
|
+
| Event | Description | Payload |
|
|
37
|
+
|---------------|---------------------|-----------------------------------------|
|
|
38
|
+
| request-count | Request count event | flatFilters: { ..., name: [1, 2] ,... } |
|
|
39
|
+
| show-result | Show result event | flatFilters: { ..., name: [1, 2],... } |
|
|
40
40
|
| reset-filters | Reset filters event | none |
|
package/babel.config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
presets: ["@vue/cli-plugin-babel/preset"],
|
|
3
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
presets: ["@vue/cli-plugin-babel/preset"],
|
|
3
|
+
};
|
package/dist/v-filters.common.js
CHANGED
|
@@ -539,6 +539,39 @@ $({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') },
|
|
|
539
539
|
});
|
|
540
540
|
|
|
541
541
|
|
|
542
|
+
/***/ }),
|
|
543
|
+
|
|
544
|
+
/***/ "25f0":
|
|
545
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
546
|
+
|
|
547
|
+
"use strict";
|
|
548
|
+
|
|
549
|
+
var redefine = __webpack_require__("6eeb");
|
|
550
|
+
var anObject = __webpack_require__("825a");
|
|
551
|
+
var fails = __webpack_require__("d039");
|
|
552
|
+
var flags = __webpack_require__("ad6d");
|
|
553
|
+
|
|
554
|
+
var TO_STRING = 'toString';
|
|
555
|
+
var RegExpPrototype = RegExp.prototype;
|
|
556
|
+
var nativeToString = RegExpPrototype[TO_STRING];
|
|
557
|
+
|
|
558
|
+
var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
|
|
559
|
+
// FF44- RegExp#toString has a wrong name
|
|
560
|
+
var INCORRECT_NAME = nativeToString.name != TO_STRING;
|
|
561
|
+
|
|
562
|
+
// `RegExp.prototype.toString` method
|
|
563
|
+
// https://tc39.es/ecma262/#sec-regexp.prototype.tostring
|
|
564
|
+
if (NOT_GENERIC || INCORRECT_NAME) {
|
|
565
|
+
redefine(RegExp.prototype, TO_STRING, function toString() {
|
|
566
|
+
var R = anObject(this);
|
|
567
|
+
var p = String(R.source);
|
|
568
|
+
var rf = R.flags;
|
|
569
|
+
var f = String(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? flags.call(R) : rf);
|
|
570
|
+
return '/' + p + '/' + f;
|
|
571
|
+
}, { unsafe: true });
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
|
|
542
575
|
/***/ }),
|
|
543
576
|
|
|
544
577
|
/***/ "2a62":
|
|
@@ -4345,7 +4378,7 @@ if (typeof window !== 'undefined') {
|
|
|
4345
4378
|
// Indicate to webpack that this file can be concatenated
|
|
4346
4379
|
/* harmony default export */ var setPublicPath = (null);
|
|
4347
4380
|
|
|
4348
|
-
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"
|
|
4381
|
+
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"585bd80c-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/VFilters.vue?vue&type=template&id=6d42a410&
|
|
4349
4382
|
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"v-filters"},[_c('div',{staticClass:"v-filters_fields"},[_vm._t("before-fields"),_vm._l((_vm.fields),function(field){return _c(_vm.fieldComponentName,{key:field._name,tag:"component",attrs:{"title":field.title}},[_c(_vm.componentsMap[field._type],_vm._b({key:_vm.fieldKey,tag:"component",on:{"input":function($event){return _vm.handleFieldChange(field._name)}},model:{value:(_vm.filters[field._name]),callback:function ($$v) {_vm.$set(_vm.filters, field._name, $$v)},expression:"filters[field._name]"}},'component',field._fieldProps || {},false))],1)}),_vm._t("after-fields"),_vm._t("actions",[_c(_vm.fieldComponentName,{tag:"component"},[(!_vm.immediate)?_c('button',{staticClass:"v-button v-filters_button",on:{"click":_vm.showResult}},[_vm._v(" "+_vm._s(_vm.actionTitle)+" ")]):_vm._e(),(_vm.edited)?_c('button',{staticClass:"v-button v-filters_button __reset",on:{"click":_vm.resetFilters}},[_vm._v(" Сбросить параметры ")]):_vm._e()])],null,{
|
|
4350
4383
|
showResult: _vm.showResult,
|
|
4351
4384
|
resetFilters: _vm.resetFilters,
|
|
@@ -4362,7 +4395,7 @@ var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._sel
|
|
|
4362
4395
|
var staticRenderFns = []
|
|
4363
4396
|
|
|
4364
4397
|
|
|
4365
|
-
// CONCATENATED MODULE: ./src/components/VFilters.vue?vue&type=template&id=
|
|
4398
|
+
// CONCATENATED MODULE: ./src/components/VFilters.vue?vue&type=template&id=6d42a410&
|
|
4366
4399
|
|
|
4367
4400
|
// EXTERNAL MODULE: ./node_modules/core-js/modules/es.object.keys.js
|
|
4368
4401
|
var es_object_keys = __webpack_require__("b64b");
|
|
@@ -4556,6 +4589,9 @@ var es_string_includes = __webpack_require__("2532");
|
|
|
4556
4589
|
// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.map.js
|
|
4557
4590
|
var es_array_map = __webpack_require__("d81d");
|
|
4558
4591
|
|
|
4592
|
+
// EXTERNAL MODULE: ./node_modules/core-js/modules/es.regexp.to-string.js
|
|
4593
|
+
var es_regexp_to_string = __webpack_require__("25f0");
|
|
4594
|
+
|
|
4559
4595
|
// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.reduce.js
|
|
4560
4596
|
var es_array_reduce = __webpack_require__("13d5");
|
|
4561
4597
|
|
|
@@ -5061,6 +5097,8 @@ _curry2(function equals(a, b) {
|
|
|
5061
5097
|
|
|
5062
5098
|
|
|
5063
5099
|
|
|
5100
|
+
|
|
5101
|
+
|
|
5064
5102
|
//
|
|
5065
5103
|
//
|
|
5066
5104
|
//
|
|
@@ -5201,7 +5239,8 @@ var VFiltersvue_type_script_lang_js_unserialize = function unserialize(input) {
|
|
|
5201
5239
|
return {
|
|
5202
5240
|
filters: {},
|
|
5203
5241
|
editedInside: false,
|
|
5204
|
-
editedFields: []
|
|
5242
|
+
editedFields: [],
|
|
5243
|
+
inited: false
|
|
5205
5244
|
};
|
|
5206
5245
|
},
|
|
5207
5246
|
computed: {
|
|
@@ -5228,7 +5267,7 @@ var VFiltersvue_type_script_lang_js_unserialize = function unserialize(input) {
|
|
|
5228
5267
|
var filtersValue = _this.filters[name];
|
|
5229
5268
|
var wrappedValue = getType(filtersValue) === 'Object' ? [filtersValue] : filtersValue;
|
|
5230
5269
|
filters[name] = wrappedValue.map(function (value) {
|
|
5231
|
-
return value._id || value;
|
|
5270
|
+
return value._id && value._id.toString() || value;
|
|
5232
5271
|
});
|
|
5233
5272
|
}
|
|
5234
5273
|
});
|
|
@@ -5243,7 +5282,6 @@ var VFiltersvue_type_script_lang_js_unserialize = function unserialize(input) {
|
|
|
5243
5282
|
var _this2 = this;
|
|
5244
5283
|
|
|
5245
5284
|
var params = query || this.getUrlParams();
|
|
5246
|
-
var editedInside = false;
|
|
5247
5285
|
this.fields.forEach(function (field) {
|
|
5248
5286
|
var value = field._type === 'range' ? field.value : [];
|
|
5249
5287
|
var valueNotArray = ['select', 'tab'].includes(field._type);
|
|
@@ -5307,7 +5345,7 @@ var VFiltersvue_type_script_lang_js_unserialize = function unserialize(input) {
|
|
|
5307
5345
|
_this2.$set(_this2.filters, field._name, value);
|
|
5308
5346
|
});
|
|
5309
5347
|
this.setUrlParams(isReset);
|
|
5310
|
-
this.editedInside =
|
|
5348
|
+
this.editedInside = this.editedFields.length > 0;
|
|
5311
5349
|
this.doAction();
|
|
5312
5350
|
},
|
|
5313
5351
|
resetFilters: function resetFilters(isOutside) {
|
|
@@ -5323,7 +5361,12 @@ var VFiltersvue_type_script_lang_js_unserialize = function unserialize(input) {
|
|
|
5323
5361
|
}
|
|
5324
5362
|
},
|
|
5325
5363
|
doAction: function doAction() {
|
|
5326
|
-
this.
|
|
5364
|
+
if (!this.inited && !this.immediate) {
|
|
5365
|
+
this.showResult();
|
|
5366
|
+
this.inited = true;
|
|
5367
|
+
} else {
|
|
5368
|
+
this.immediate ? this.showResult() : this.requestCount();
|
|
5369
|
+
}
|
|
5327
5370
|
},
|
|
5328
5371
|
requestCount: function requestCount() {
|
|
5329
5372
|
this.$emit('request-count', this.flatFilters);
|