@leaflink/stash 44.0.0-beta.5 → 44.0.0-beta.7
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/dist/ActionsDropdown.js +11 -11
- package/dist/ActionsDropdown.js.map +1 -1
- package/dist/Alert.js +7 -7
- package/dist/Alert.js.map +1 -1
- package/dist/AppNavigationItem.js +11 -11
- package/dist/AppNavigationItem.js.map +1 -1
- package/dist/Carousel.js +258 -246
- package/dist/Carousel.js.map +1 -1
- package/dist/DataViewSortButton.js +22 -22
- package/dist/DataViewSortButton.js.map +1 -1
- package/dist/DatePicker.js +2 -5
- package/dist/DatePicker.js.map +1 -1
- package/dist/DescriptionListTerm.js +7 -7
- package/dist/DescriptionListTerm.js.map +1 -1
- package/dist/Dialog.js.map +1 -1
- package/dist/Divider.js +8 -8
- package/dist/Divider.js.map +1 -1
- package/dist/Dropdown.js +15 -15
- package/dist/Dropdown.js.map +1 -1
- package/dist/Expand.js +1 -1
- package/dist/{Expand.vue_vue_type_script_setup_true_lang-5fe03d51.js → Expand.vue_vue_type_script_setup_true_lang-b6a57ae9.js} +4 -4
- package/dist/{Expand.vue_vue_type_script_setup_true_lang-5fe03d51.js.map → Expand.vue_vue_type_script_setup_true_lang-b6a57ae9.js.map} +1 -1
- package/dist/FileUpload.js +29 -29
- package/dist/FileUpload.js.map +1 -1
- package/dist/FilterSelect.js +25 -25
- package/dist/FilterSelect.js.map +1 -1
- package/dist/Filters.js +26 -26
- package/dist/Filters.js.map +1 -1
- package/dist/IconLabel.js +5 -5
- package/dist/IconLabel.js.map +1 -1
- package/dist/ListView.js +84 -84
- package/dist/ListView.js.map +1 -1
- package/dist/Modals.js +13 -13
- package/dist/Modals.js.map +1 -1
- package/dist/PageNavigation.js +3 -3
- package/dist/PageNavigation.js.map +1 -1
- package/dist/QuickAction.js +22 -19
- package/dist/QuickAction.js.map +1 -1
- package/dist/Radio.js +26 -16
- package/dist/Radio.js.map +1 -1
- package/dist/RadioGroup.js +135 -106
- package/dist/RadioGroup.js.map +1 -1
- package/dist/RadioNew.js +118 -91
- package/dist/RadioNew.js.map +1 -1
- package/dist/Select.js +6 -6
- package/dist/Select.js.map +1 -1
- package/dist/Tab.js +2 -2
- package/dist/{Tab.vue_vue_type_script_setup_true_lang-4a40f015.js → Tab.vue_vue_type_script_setup_true_lang-69d1b046.js} +2 -2
- package/dist/{Tab.vue_vue_type_script_setup_true_lang-4a40f015.js.map → Tab.vue_vue_type_script_setup_true_lang-69d1b046.js.map} +1 -1
- package/dist/Table.js +2 -2
- package/dist/{Table.keys-1ebe4ecb.js → Table.keys-75e99266.js} +11 -11
- package/dist/{Table.keys-1ebe4ecb.js.map → Table.keys-75e99266.js.map} +1 -1
- package/dist/TableCell.js +1 -1
- package/dist/TableCell.js.map +1 -1
- package/dist/TableHeaderCell.js +1 -1
- package/dist/TableHeaderRow.js +1 -1
- package/dist/TableRow.js +38 -37
- package/dist/TableRow.js.map +1 -1
- package/dist/Tabs.js +2 -2
- package/dist/{Tabs.vue_used_vue_type_style_index_0_lang.module-0af1e1cf.js → Tabs.vue_used_vue_type_style_index_0_lang.module-2a131332.js} +25 -25
- package/dist/Tabs.vue_used_vue_type_style_index_0_lang.module-2a131332.js.map +1 -0
- package/dist/components.css +1 -1
- package/dist/constants.d.ts +7 -7
- package/dist/constants.js +21 -21
- package/dist/constants.js.map +1 -1
- package/dist/tailwind-base.js +9 -2
- package/dist/tailwind-base.js.map +1 -1
- package/dist/utils/helpers.js +37 -37
- package/dist/utils/helpers.js.map +1 -1
- package/package.json +2 -2
- package/tailwind-base.ts +3 -1
- package/dist/Tabs.vue_used_vue_type_style_index_0_lang.module-0af1e1cf.js.map +0 -1
package/dist/FilterSelect.js
CHANGED
|
@@ -26,31 +26,31 @@ const F = { class: "tw-flex tw-flex-wrap tw-gap-1.5" }, D = ["id"], O = ["for"],
|
|
|
26
26
|
get() {
|
|
27
27
|
return e.modelValue;
|
|
28
28
|
},
|
|
29
|
-
set(
|
|
30
|
-
c("update:modelValue",
|
|
29
|
+
set(t) {
|
|
30
|
+
c("update:modelValue", t);
|
|
31
31
|
}
|
|
32
32
|
}), n = p({
|
|
33
33
|
get() {
|
|
34
34
|
return e.options.length === e.modelValue.length;
|
|
35
35
|
},
|
|
36
|
-
set(
|
|
37
|
-
c("update:modelValue",
|
|
36
|
+
set(t) {
|
|
37
|
+
c("update:modelValue", t ? e.options.map((a) => a.value) : []);
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
|
-
function i(
|
|
41
|
-
return `${e.name}--${
|
|
40
|
+
function i(t) {
|
|
41
|
+
return `${e.name}--${t.value}`;
|
|
42
42
|
}
|
|
43
|
-
function g(
|
|
44
|
-
return e.modelValue.includes(
|
|
43
|
+
function g(t) {
|
|
44
|
+
return e.modelValue.includes(t.value);
|
|
45
45
|
}
|
|
46
|
-
function
|
|
47
|
-
const a = o.value.filter((
|
|
48
|
-
a.length === o.value.length && a.push(
|
|
46
|
+
function w(t) {
|
|
47
|
+
const a = o.value.filter((l) => l !== t);
|
|
48
|
+
a.length === o.value.length && a.push(t), o.value = a;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function k() {
|
|
51
51
|
n.value = !n.value;
|
|
52
52
|
}
|
|
53
|
-
return (
|
|
53
|
+
return (t, a) => (r(), $(N, {
|
|
54
54
|
class: "stash-filter-select",
|
|
55
55
|
fieldset: "",
|
|
56
56
|
label: e.label
|
|
@@ -62,8 +62,8 @@ const F = { class: "tw-flex tw-flex-wrap tw-gap-1.5" }, D = ["id"], O = ["for"],
|
|
|
62
62
|
}, [
|
|
63
63
|
f(s("input", {
|
|
64
64
|
id: `${e.name}--all`,
|
|
65
|
-
"onUpdate:modelValue": a[0] || (a[0] = (
|
|
66
|
-
class: "sr-only",
|
|
65
|
+
"onUpdate:modelValue": a[0] || (a[0] = (l) => n.value = l),
|
|
66
|
+
class: "tw-sr-only",
|
|
67
67
|
tabindex: "-1",
|
|
68
68
|
type: "checkbox",
|
|
69
69
|
value: "all"
|
|
@@ -76,7 +76,7 @@ const F = { class: "tw-flex tw-flex-wrap tw-gap-1.5" }, D = ["id"], O = ["for"],
|
|
|
76
76
|
_(y, {
|
|
77
77
|
"is-selected": n.value,
|
|
78
78
|
tabindex: "0",
|
|
79
|
-
onKeypress: h(
|
|
79
|
+
onKeypress: h(k, ["enter"])
|
|
80
80
|
}, {
|
|
81
81
|
default: u(() => [
|
|
82
82
|
b(x(C(E)("ll.all")), 1)
|
|
@@ -85,29 +85,29 @@ const F = { class: "tw-flex tw-flex-wrap tw-gap-1.5" }, D = ["id"], O = ["for"],
|
|
|
85
85
|
}, 8, ["is-selected", "onKeypress"])
|
|
86
86
|
], 8, O)
|
|
87
87
|
])) : K("", !0),
|
|
88
|
-
(r(!0), d(A, null, B(e.options, (
|
|
89
|
-
key: i(
|
|
88
|
+
(r(!0), d(A, null, B(e.options, (l) => (r(), d("div", {
|
|
89
|
+
key: i(l)
|
|
90
90
|
}, [
|
|
91
91
|
f(s("input", {
|
|
92
|
-
id: i(
|
|
92
|
+
id: i(l),
|
|
93
93
|
"onUpdate:modelValue": a[1] || (a[1] = (m) => o.value = m),
|
|
94
|
-
class: "sr-only",
|
|
94
|
+
class: "tw-sr-only",
|
|
95
95
|
tabindex: "-1",
|
|
96
96
|
type: "checkbox",
|
|
97
|
-
value:
|
|
97
|
+
value: l.value
|
|
98
98
|
}, null, 8, U), [
|
|
99
99
|
[v, o.value]
|
|
100
100
|
]),
|
|
101
101
|
s("label", {
|
|
102
|
-
for: i(
|
|
102
|
+
for: i(l)
|
|
103
103
|
}, [
|
|
104
104
|
_(y, {
|
|
105
|
-
"is-selected": g(
|
|
105
|
+
"is-selected": g(l),
|
|
106
106
|
tabindex: "0",
|
|
107
|
-
onKeypress: h((m) =>
|
|
107
|
+
onKeypress: h((m) => w(l.value), ["enter"])
|
|
108
108
|
}, {
|
|
109
109
|
default: u(() => [
|
|
110
|
-
b(x(
|
|
110
|
+
b(x(l.label), 1)
|
|
111
111
|
]),
|
|
112
112
|
_: 2
|
|
113
113
|
}, 1032, ["is-selected", "onKeypress"])
|
package/dist/FilterSelect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterSelect.js","sources":["../src/components/FilterSelect/FilterSelect.vue"],"sourcesContent":["<script lang=\"ts\">\n export * from './FilterSelect.types';\n</script>\n\n<script lang=\"ts\" setup>\n import { computed } from 'vue';\n\n import { t } from '../../locale';\n import Field from '../Field/Field.vue';\n import FilterChip from '../FilterChip/FilterChip.vue';\n import { FilterSelectModelValue, FilterSelectOption } from './FilterSelect.types';\n\n export interface FilterSelectProps {\n /**\n * The name attribute for the `<input>` elements. It is also used as a unique field to differentiate FilterSelect instances.\n */\n name: string;\n\n label: string;\n\n options: FilterSelectOption[];\n\n modelValue: FilterSelectModelValue;\n\n /**\n * When true, this prop adds an \"All\" option for selecting all options.\n */\n canSelectAll?: boolean;\n }\n\n const props = withDefaults(defineProps<FilterSelectProps>(), {\n canSelectAll: false,\n });\n\n const emit =\n defineEmits<{\n (e: 'update:modelValue', value: FilterSelectModelValue): void;\n }>();\n\n /**\n * @see: https://vuejs.org/guide/components/v-model.html#component-v-model\n */\n const selected = computed({\n get() {\n return props.modelValue;\n },\n set(value) {\n emit('update:modelValue', value);\n },\n });\n\n const isAllSelected = computed({\n get() {\n return props.options.length === props.modelValue.length;\n },\n set(isChecked) {\n emit('update:modelValue', isChecked ? props.options.map((option) => option.value) : []);\n },\n });\n\n function getOptionId(option: FilterSelectOption) {\n return `${props.name}--${option.value}`;\n }\n\n function isOptionSelected(option: FilterSelectOption) {\n return props.modelValue.includes(option.value);\n }\n\n function onEnter(enteredValue: FilterSelectOption['value']) {\n const newSelected = selected.value.filter((value) => value !== enteredValue);\n\n if (newSelected.length === selected.value.length) {\n newSelected.push(enteredValue);\n }\n\n selected.value = newSelected;\n }\n\n function onEnterAll() {\n isAllSelected.value = !isAllSelected.value;\n }\n</script>\n\n<template>\n <Field class=\"stash-filter-select\" fieldset :label=\"props.label\">\n <div class=\"tw-flex tw-flex-wrap tw-gap-1.5\">\n <div v-if=\"props.canSelectAll\" :key=\"`${props.name}--all`\">\n <input\n :id=\"`${props.name}--all`\"\n v-model=\"isAllSelected\"\n class=\"sr-only\"\n tabindex=\"-1\"\n type=\"checkbox\"\n value=\"all\"\n />\n <label :for=\"`${props.name}--all`\">\n <FilterChip :is-selected=\"isAllSelected\" tabindex=\"0\" @keypress.enter=\"onEnterAll\">\n {{ t('ll.all') }}\n </FilterChip>\n </label>\n </div>\n <div v-for=\"option in props.options\" :key=\"getOptionId(option)\">\n <input\n :id=\"getOptionId(option)\"\n v-model=\"selected\"\n class=\"sr-only\"\n tabindex=\"-1\"\n type=\"checkbox\"\n :value=\"option.value\"\n />\n <label :for=\"getOptionId(option)\">\n <FilterChip :is-selected=\"isOptionSelected(option)\" tabindex=\"0\" @keypress.enter=\"onEnter(option.value)\">\n {{ option.label }}\n </FilterChip>\n </label>\n </div>\n </div>\n </Field>\n</template>\n"],"names":["selected","computed","props","value","emit","isAllSelected","isChecked","option","getOptionId","isOptionSelected","onEnter","enteredValue","newSelected","onEnterAll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;iBA0CQA,IAAWC,EAAS;AAAA,MACxB,MAAM;AACJ,eAAOC,EAAM;AAAA,MACf;AAAA,MACA,IAAIC,GAAO;AACT,QAAAC,EAAK,qBAAqBD,CAAK;AAAA,MACjC;AAAA,IAAA,CACD,GAEKE,IAAgBJ,EAAS;AAAA,MAC7B,MAAM;AACJ,eAAOC,EAAM,QAAQ,WAAWA,EAAM,WAAW;AAAA,MACnD;AAAA,MACA,IAAII,GAAW;AACR,QAAAF,EAAA,qBAAqBE,IAAYJ,EAAM,QAAQ,IAAI,CAACK,MAAWA,EAAO,KAAK,IAAI,CAAE,CAAA;AAAA,MACxF;AAAA,IAAA,CACD;AAED,aAASC,EAAYD,GAA4B;AAC/C,aAAO,GAAGL,EAAM,IAAI,KAAKK,EAAO,KAAK;AAAA,IACvC;AAEA,aAASE,EAAiBF,GAA4B;AACpD,aAAOL,EAAM,WAAW,SAASK,EAAO,KAAK;AAAA,IAC/C;AAEA,aAASG,EAAQC,GAA2C;AAC1D,YAAMC,IAAcZ,EAAS,MAAM,OAAO,CAACG,MAAUA,MAAUQ,CAAY;AAE3E,MAAIC,EAAY,WAAWZ,EAAS,MAAM,UACxCY,EAAY,KAAKD,CAAY,GAG/BX,EAAS,QAAQY;AAAA,IACnB;AAEA,aAASC,IAAa;AACN,MAAAR,EAAA,QAAQ,CAACA,EAAc;AAAA,IACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"FilterSelect.js","sources":["../src/components/FilterSelect/FilterSelect.vue"],"sourcesContent":["<script lang=\"ts\">\n export * from './FilterSelect.types';\n</script>\n\n<script lang=\"ts\" setup>\n import { computed } from 'vue';\n\n import { t } from '../../locale';\n import Field from '../Field/Field.vue';\n import FilterChip from '../FilterChip/FilterChip.vue';\n import { FilterSelectModelValue, FilterSelectOption } from './FilterSelect.types';\n\n export interface FilterSelectProps {\n /**\n * The name attribute for the `<input>` elements. It is also used as a unique field to differentiate FilterSelect instances.\n */\n name: string;\n\n label: string;\n\n options: FilterSelectOption[];\n\n modelValue: FilterSelectModelValue;\n\n /**\n * When true, this prop adds an \"All\" option for selecting all options.\n */\n canSelectAll?: boolean;\n }\n\n const props = withDefaults(defineProps<FilterSelectProps>(), {\n canSelectAll: false,\n });\n\n const emit =\n defineEmits<{\n (e: 'update:modelValue', value: FilterSelectModelValue): void;\n }>();\n\n /**\n * @see: https://vuejs.org/guide/components/v-model.html#component-v-model\n */\n const selected = computed({\n get() {\n return props.modelValue;\n },\n set(value) {\n emit('update:modelValue', value);\n },\n });\n\n const isAllSelected = computed({\n get() {\n return props.options.length === props.modelValue.length;\n },\n set(isChecked) {\n emit('update:modelValue', isChecked ? props.options.map((option) => option.value) : []);\n },\n });\n\n function getOptionId(option: FilterSelectOption) {\n return `${props.name}--${option.value}`;\n }\n\n function isOptionSelected(option: FilterSelectOption) {\n return props.modelValue.includes(option.value);\n }\n\n function onEnter(enteredValue: FilterSelectOption['value']) {\n const newSelected = selected.value.filter((value) => value !== enteredValue);\n\n if (newSelected.length === selected.value.length) {\n newSelected.push(enteredValue);\n }\n\n selected.value = newSelected;\n }\n\n function onEnterAll() {\n isAllSelected.value = !isAllSelected.value;\n }\n</script>\n\n<template>\n <Field class=\"stash-filter-select\" fieldset :label=\"props.label\">\n <div class=\"tw-flex tw-flex-wrap tw-gap-1.5\">\n <div v-if=\"props.canSelectAll\" :key=\"`${props.name}--all`\">\n <input\n :id=\"`${props.name}--all`\"\n v-model=\"isAllSelected\"\n class=\"tw-sr-only\"\n tabindex=\"-1\"\n type=\"checkbox\"\n value=\"all\"\n />\n <label :for=\"`${props.name}--all`\">\n <FilterChip :is-selected=\"isAllSelected\" tabindex=\"0\" @keypress.enter=\"onEnterAll\">\n {{ t('ll.all') }}\n </FilterChip>\n </label>\n </div>\n <div v-for=\"option in props.options\" :key=\"getOptionId(option)\">\n <input\n :id=\"getOptionId(option)\"\n v-model=\"selected\"\n class=\"tw-sr-only\"\n tabindex=\"-1\"\n type=\"checkbox\"\n :value=\"option.value\"\n />\n <label :for=\"getOptionId(option)\">\n <FilterChip :is-selected=\"isOptionSelected(option)\" tabindex=\"0\" @keypress.enter=\"onEnter(option.value)\">\n {{ option.label }}\n </FilterChip>\n </label>\n </div>\n </div>\n </Field>\n</template>\n"],"names":["selected","computed","props","value","emit","isAllSelected","isChecked","option","getOptionId","isOptionSelected","onEnter","enteredValue","newSelected","onEnterAll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;iBA0CQA,IAAWC,EAAS;AAAA,MACxB,MAAM;AACJ,eAAOC,EAAM;AAAA,MACf;AAAA,MACA,IAAIC,GAAO;AACT,QAAAC,EAAK,qBAAqBD,CAAK;AAAA,MACjC;AAAA,IAAA,CACD,GAEKE,IAAgBJ,EAAS;AAAA,MAC7B,MAAM;AACJ,eAAOC,EAAM,QAAQ,WAAWA,EAAM,WAAW;AAAA,MACnD;AAAA,MACA,IAAII,GAAW;AACR,QAAAF,EAAA,qBAAqBE,IAAYJ,EAAM,QAAQ,IAAI,CAACK,MAAWA,EAAO,KAAK,IAAI,CAAE,CAAA;AAAA,MACxF;AAAA,IAAA,CACD;AAED,aAASC,EAAYD,GAA4B;AAC/C,aAAO,GAAGL,EAAM,IAAI,KAAKK,EAAO,KAAK;AAAA,IACvC;AAEA,aAASE,EAAiBF,GAA4B;AACpD,aAAOL,EAAM,WAAW,SAASK,EAAO,KAAK;AAAA,IAC/C;AAEA,aAASG,EAAQC,GAA2C;AAC1D,YAAMC,IAAcZ,EAAS,MAAM,OAAO,CAACG,MAAUA,MAAUQ,CAAY;AAE3E,MAAIC,EAAY,WAAWZ,EAAS,MAAM,UACxCY,EAAY,KAAKD,CAAY,GAG/BX,EAAS,QAAQY;AAAA,IACnB;AAEA,aAASC,IAAa;AACN,MAAAR,EAAA,QAAQ,CAACA,EAAc;AAAA,IACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/Filters.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import G from "lodash-es/cloneDeep";
|
|
2
2
|
import z from "lodash-es/merge";
|
|
3
|
-
import { toRefs as W, ref as
|
|
3
|
+
import { toRefs as W, ref as E, nextTick as Y, resolveComponent as y, openBlock as c, createElementBlock as V, Fragment as S, renderList as q, normalizeClass as L, createBlock as f, mergeProps as k, resolveDynamicComponent as v, createSlots as J, withCtx as b, normalizeProps as O, guardReactiveProps as R, createElementVNode as g, createCommentVNode as U, createVNode as D, createTextVNode as A, toDisplayString as M } from "vue";
|
|
4
4
|
import K from "./useValidation.js";
|
|
5
|
-
import { LLLV_CHANGE_TRIGGERS as
|
|
6
|
-
import { t as
|
|
7
|
-
import { persistentStorage as
|
|
5
|
+
import { LLLV_CHANGE_TRIGGERS as w } from "./constants.js";
|
|
6
|
+
import { t as N } from "./locale.js";
|
|
7
|
+
import { persistentStorage as H } from "./storage.js";
|
|
8
8
|
import Q from "./Button.js";
|
|
9
9
|
import X from "./Checkbox.js";
|
|
10
10
|
import Z from "./DatePicker.js";
|
|
@@ -94,7 +94,7 @@ const ie = {
|
|
|
94
94
|
},
|
|
95
95
|
emits: ["change", "submit", "reset"],
|
|
96
96
|
setup(l) {
|
|
97
|
-
const { validationSchema: r } = W(l), o = r.value(), i =
|
|
97
|
+
const { validationSchema: r } = W(l), o = r.value(), i = E({}), t = E();
|
|
98
98
|
function s() {
|
|
99
99
|
if ((o == null ? void 0 : o.toString()) !== "[object Object]")
|
|
100
100
|
return;
|
|
@@ -110,8 +110,8 @@ const ie = {
|
|
|
110
110
|
},
|
|
111
111
|
data() {
|
|
112
112
|
return {
|
|
113
|
-
applyText:
|
|
114
|
-
clearText:
|
|
113
|
+
applyText: N("ll.apply"),
|
|
114
|
+
clearText: N("ll.clear"),
|
|
115
115
|
filters: {},
|
|
116
116
|
filterValues: {},
|
|
117
117
|
forceRenderCount: 0
|
|
@@ -161,7 +161,7 @@ const ie = {
|
|
|
161
161
|
}
|
|
162
162
|
},
|
|
163
163
|
async created() {
|
|
164
|
-
this.initFilterValues(), await Y(), this.initValidation(), this.applyFilters({ trigger:
|
|
164
|
+
this.initFilterValues(), await Y(), this.initValidation(), this.applyFilters({ trigger: w.LOAD });
|
|
165
165
|
},
|
|
166
166
|
methods: {
|
|
167
167
|
initFilterValues() {
|
|
@@ -178,7 +178,7 @@ const ie = {
|
|
|
178
178
|
* @param {object} [options] - optional parameters
|
|
179
179
|
* @param {string} [options.trigger] - the action that triggered this function call
|
|
180
180
|
*/
|
|
181
|
-
async applyFilters({ trigger: l =
|
|
181
|
+
async applyFilters({ trigger: l = w.APPLY } = {}) {
|
|
182
182
|
this.validation && (await this.validation.validate(), this.validation.hasErrors) || (this.disablePersistency || this.persistFilterValues(this.filterValues), this.$emit("submit", { trigger: l }));
|
|
183
183
|
},
|
|
184
184
|
resetFilters() {
|
|
@@ -226,14 +226,14 @@ const ie = {
|
|
|
226
226
|
* @returns {any}
|
|
227
227
|
*/
|
|
228
228
|
getPersistentFilterValues() {
|
|
229
|
-
return
|
|
229
|
+
return H.get("filter-values");
|
|
230
230
|
},
|
|
231
231
|
/**
|
|
232
232
|
* Clone new filterValues to remove reactivity, and save them to localStorage.
|
|
233
233
|
* @param {object} newValues - the filterValues to be persisted in localStorage
|
|
234
234
|
*/
|
|
235
235
|
persistFilterValues(l) {
|
|
236
|
-
|
|
236
|
+
H.set("filter-values", G(l));
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
}, se = { class: "ll-grid ll-grid-cols-4 md:ll-grid-cols-12" }, re = ["data-test"], ae = ["innerHTML"], ne = ["innerHTML"];
|
|
@@ -241,20 +241,20 @@ function ce(l, r, o, i, t, s) {
|
|
|
241
241
|
var u;
|
|
242
242
|
const p = y("ll-select"), d = y("ll-checkbox"), m = y("ll-radio"), h = y("ll-button");
|
|
243
243
|
return c(), V("div", se, [
|
|
244
|
-
(c(!0), V(
|
|
245
|
-
var _, F, T, C, x, P, B,
|
|
246
|
-
return c(), V(
|
|
244
|
+
(c(!0), V(S, null, q(o.schema, (e, a) => {
|
|
245
|
+
var _, F, T, C, x, P, B, j;
|
|
246
|
+
return c(), V(S, null, [
|
|
247
247
|
e.hidden ? U("", !0) : (c(), V("div", {
|
|
248
248
|
key: `${a} ${t.forceRenderCount}`,
|
|
249
|
-
class: L(["field-wrapper col-span-4 md:col-span-3", { "hidden-sm-only": !e.type, "
|
|
249
|
+
class: L(["field-wrapper col-span-4 md:col-span-3", { "hidden-sm-only": !e.type, "tw-flex tw-items-end": e.type === "ll-checkbox" }]),
|
|
250
250
|
"data-test": `filter|${e.fieldToFilter}`
|
|
251
251
|
}, [
|
|
252
|
-
e.type === "ll-select" ? (c(), f(p,
|
|
252
|
+
e.type === "ll-select" ? (c(), f(p, k({ key: 0 }, e.attributes, {
|
|
253
253
|
error: ((_ = i.validation) == null ? void 0 : _.fields[e.fieldToFilter]) && ((F = i.validation) == null ? void 0 : F.getError(e.fieldToFilter)),
|
|
254
254
|
label: e.label,
|
|
255
255
|
"model-value": t.filterValues[a],
|
|
256
256
|
"onUpdate:modelValue": (n) => s.onSelectInput(n, e, a)
|
|
257
|
-
}), null, 16, ["error", "label", "model-value", "onUpdate:modelValue"])) : e.type === "ll-checkbox" ? (c(), f(d,
|
|
257
|
+
}), null, 16, ["error", "label", "model-value", "onUpdate:modelValue"])) : e.type === "ll-checkbox" ? (c(), f(d, k({
|
|
258
258
|
key: 1,
|
|
259
259
|
checked: t.filterValues[a],
|
|
260
260
|
"onUpdate:checked": (n) => t.filterValues[a] = n
|
|
@@ -262,7 +262,7 @@ function ce(l, r, o, i, t, s) {
|
|
|
262
262
|
"error-text": ((T = i.validation) == null ? void 0 : T.fields[e.fieldToFilter]) && ((C = i.validation) == null ? void 0 : C.getError(e.fieldToFilter)),
|
|
263
263
|
label: e.label,
|
|
264
264
|
"onUpdate:checked": (n) => s.onChange(e, t.filterValues, a)
|
|
265
|
-
}), null, 16, ["checked", "onUpdate:checked", "error-text", "label"])) : e.type === "ll-radio" ? (c(), f(m,
|
|
265
|
+
}), null, 16, ["checked", "onUpdate:checked", "error-text", "label"])) : e.type === "ll-radio" ? (c(), f(m, k({
|
|
266
266
|
key: 2,
|
|
267
267
|
checked: t.filterValues[a],
|
|
268
268
|
"onUpdate:checked": (n) => t.filterValues[a] = n
|
|
@@ -270,30 +270,30 @@ function ce(l, r, o, i, t, s) {
|
|
|
270
270
|
"error-text": ((x = i.validation) == null ? void 0 : x.fields[e.fieldToFilter]) && ((P = i.validation) == null ? void 0 : P.getError(e.fieldToFilter)),
|
|
271
271
|
label: e.label,
|
|
272
272
|
"onUpdate:checked": (n) => s.onChange(e, t.filterValues, a)
|
|
273
|
-
}), null, 16, ["checked", "onUpdate:checked", "error-text", "label"])) : e.type ? (c(), f(
|
|
273
|
+
}), null, 16, ["checked", "onUpdate:checked", "error-text", "label"])) : e.type ? (c(), f(v(e.type), k({ key: 3 }, e.attributes, {
|
|
274
274
|
modelValue: t.filterValues[a],
|
|
275
275
|
"onUpdate:modelValue": [(n) => t.filterValues[a] = n, (n) => s.onChange(e, t.filterValues, a)],
|
|
276
|
-
"error-text": ((B = i.validation) == null ? void 0 : B.fields[e.fieldToFilter]) && ((
|
|
276
|
+
"error-text": ((B = i.validation) == null ? void 0 : B.fields[e.fieldToFilter]) && ((j = i.validation) == null ? void 0 : j.getError(e.fieldToFilter)),
|
|
277
277
|
label: e.label
|
|
278
278
|
}), J({ _: 2 }, [
|
|
279
279
|
e.slots && e.slots.selected ? {
|
|
280
280
|
name: "selected",
|
|
281
281
|
fn: b(({ option: n }) => [
|
|
282
|
-
(c(), f(
|
|
282
|
+
(c(), f(v(e.slots.selected), O(R(n.props)), null, 16))
|
|
283
283
|
]),
|
|
284
284
|
key: "0"
|
|
285
285
|
} : void 0,
|
|
286
286
|
e.slots && e.slots.option ? {
|
|
287
287
|
name: "option",
|
|
288
288
|
fn: b(({ option: n }) => [
|
|
289
|
-
(c(), f(
|
|
289
|
+
(c(), f(v(e.slots.option), O(R(n.props)), null, 16))
|
|
290
290
|
]),
|
|
291
291
|
key: "1"
|
|
292
292
|
} : void 0,
|
|
293
293
|
e.slots && e.slots.prepend ? {
|
|
294
294
|
name: "prepend",
|
|
295
295
|
fn: b(() => [
|
|
296
|
-
|
|
296
|
+
g("span", {
|
|
297
297
|
innerHTML: e.slots.prepend
|
|
298
298
|
}, null, 8, ae)
|
|
299
299
|
]),
|
|
@@ -302,7 +302,7 @@ function ce(l, r, o, i, t, s) {
|
|
|
302
302
|
e.slots && e.slots.append ? {
|
|
303
303
|
name: "append",
|
|
304
304
|
fn: b(() => [
|
|
305
|
-
|
|
305
|
+
g("span", {
|
|
306
306
|
innerHTML: e.slots.append
|
|
307
307
|
}, null, 8, ne)
|
|
308
308
|
]),
|
|
@@ -312,8 +312,8 @@ function ce(l, r, o, i, t, s) {
|
|
|
312
312
|
], 10, re))
|
|
313
313
|
], 64);
|
|
314
314
|
}), 256)),
|
|
315
|
-
|
|
316
|
-
class: L(["
|
|
315
|
+
g("div", {
|
|
316
|
+
class: L(["button-grid col-span-4 md:col-span-12 tw-flex tw-items-end tw-justify-end", l.$style["filter-button-group"]])
|
|
317
317
|
}, [
|
|
318
318
|
D(h, {
|
|
319
319
|
secondary: "",
|
package/dist/Filters.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Filters.js","sources":["../src/components/Filters/Filters.vue"],"sourcesContent":["<script>\n import cloneDeep from 'lodash-es/cloneDeep';\n import merge from 'lodash-es/merge';\n import { nextTick, ref, toRefs } from 'vue';\n\n import useValidation from '../../composables/useValidation/useValidation';\n import { LLLV_CHANGE_TRIGGERS } from '../../constants';\n import { t } from '../../locale';\n import { persistentStorage } from '../../storage';\n import Button from '../Button/Button.vue';\n import Checkbox from '../Checkbox/Checkbox.vue';\n import DatePicker from '../DatePicker/DatePicker.vue';\n import Input from '../Input/Input.vue';\n import InputOptions from '../InputOptions/InputOptions.vue';\n import Radio from '../Radio/Radio.vue';\n import Select from '../Select/Select.vue';\n\n export default {\n name: 'll-filters',\n\n components: {\n 'll-button': Button,\n 'll-checkbox': Checkbox,\n 'll-input': Input,\n 'll-input-options': InputOptions,\n 'll-radio': Radio,\n 'll-select': Select,\n DatePicker,\n },\n\n props: {\n /**\n * Whether to disable the Apply button\n */\n disableApply: Boolean,\n /**\n * Whether to disable the Clear button\n */\n disableClear: Boolean,\n /**\n * Whether to disable the sticky filters\n * If disabled, a default pre-selected value(s) can be added to\n * the filter component's attributes\n */\n disablePersistency: Boolean,\n /**\n * Filters schema\n */\n schema: {\n type: Array,\n default: () => [],\n },\n /**\n * Validation schema function that returns an object\n */\n validationSchema: {\n type: Function,\n default: () => () => undefined,\n },\n },\n\n emits: ['change', 'submit', 'reset'],\n\n setup(props) {\n const { validationSchema: getValidationSchema } = toRefs(props);\n const validationSchema = getValidationSchema.value();\n const validationValues = ref({});\n\n // Without ref, `this.validation` will always evaluate to its initial value of `undefined` due to lack of reactivity.\n const validation = ref();\n\n function initValidation() {\n if (validationSchema?.toString() !== '[object Object]') {\n return;\n }\n\n validationValues.value = Object.keys(validationSchema).reduce((values, fieldName) => {\n values[fieldName] = undefined;\n\n return values;\n }, {});\n\n const validationRules = Object.entries(validationSchema).reduce((rules, [fieldName, fieldRules]) => {\n rules[fieldName] = fieldRules.map((fieldRule) => {\n return fieldRule(validationValues);\n });\n\n return rules;\n }, {});\n\n validation.value = useValidation({ rules: validationRules, values: validationValues });\n validation.value.validate();\n }\n\n return {\n validation,\n validationValues,\n initValidation,\n };\n },\n\n data() {\n return {\n applyText: t('ll.apply'),\n clearText: t('ll.clear'),\n filters: {},\n filterValues: {},\n forceRenderCount: 0,\n };\n },\n\n watch: {\n filterValues: {\n /**\n * Maps filters to a partcular object structure:\n * @param {IFilterSchemaItem} newFilterValues all selected filters\n * @returns {IFilter}\n */\n handler: function (newFilterValues) {\n const filters = Object.keys(newFilterValues).reduce((acc, i) => {\n const schema = this.schema[i];\n\n if (!schema || !schema.fieldToFilter) {\n return acc;\n }\n\n const item = newFilterValues[i];\n\n // Ignore empty string or undefined/null filter values\n if (item === '' || item == null) {\n return acc;\n }\n\n const trackBy = schema.attributes.trackBy || 'id';\n const isObject = typeof item === 'object';\n const isCustomFilterComponent = typeof schema.type === 'object';\n // TODO: remove handling of schema.attributes.multiple when we remove the vue-multiselect version of Select\n const isMultiple =\n (isCustomFilterComponent && schema.attributes.multiple) ||\n (!isCustomFilterComponent &&\n schema.type.includes('ll-select') &&\n (schema.attributes.multiple || !schema.attributes.single));\n const filterBy = isMultiple\n ? // local storage might have item stored as an object from the old Select\n (Array.isArray(item) ? item : [item]).map((v) => v[trackBy])\n : isObject\n ? [item[trackBy]]\n : [item];\n\n const groupedWith = schema.groupedWith;\n\n if (groupedWith) {\n filterBy[0] = {\n index: groupedWith,\n value: newFilterValues[groupedWith],\n };\n filterBy.push({\n index: Number(i),\n value: newFilterValues[i],\n });\n }\n\n filterBy.length &&\n (acc[schema.fieldToFilter] = {\n // don't add to `filters` if no filterBy\n filterBy,\n filterType: schema.type, // Informs the applied filter count\n isMultiple,\n ...('fn' in schema && { customFilter: schema.fn }),\n });\n\n return acc;\n }, {});\n\n this.filters = filters;\n this.$emit('change', filters);\n },\n\n deep: true,\n immediate: true,\n },\n\n filters() {\n if (this.validation) {\n this.updateValidationValues();\n }\n },\n },\n\n async created() {\n // initFilterValues updates the filterValues so using await nextTick() forces the code\n // after it to wait until nextTick is done, at which point the filterValues will\n // be done initializing. Otherwise, applyFilters sometimes applies the wrong\n // filters because filterValues is not done updating.\n this.initFilterValues();\n await nextTick();\n this.initValidation();\n this.applyFilters({ trigger: LLLV_CHANGE_TRIGGERS.LOAD });\n },\n\n methods: {\n initFilterValues() {\n if (this.disablePersistency) {\n this.filterValues = this.getDefaultFilterValues();\n\n return;\n }\n\n this.filterValues = this.getPersistentFilterValues() || this.getDefaultFilterValues();\n },\n\n /**\n * Apply the selected filters and save them to localStorage.\n * ListView calls this method using a ref to Filters.\n * The trigger option is used in ListView.\n * @param {object} [options] - optional parameters\n * @param {string} [options.trigger] - the action that triggered this function call\n */\n async applyFilters({ trigger = LLLV_CHANGE_TRIGGERS.APPLY } = {}) {\n if (this.validation) {\n await this.validation.validate();\n\n if (this.validation.hasErrors) {\n return;\n }\n }\n\n if (!this.disablePersistency) {\n this.persistFilterValues(this.filterValues);\n }\n\n this.$emit('submit', { trigger });\n },\n\n resetFilters() {\n this.filterValues = this.getDefaultFilterValues();\n\n this.forceRenderCount++;\n\n if (!this.disablePersistency) {\n this.persistFilterValues(this.filterValues);\n }\n\n // Emit after filters are updated\n this.$nextTick(() => {\n this.$emit('reset');\n });\n },\n\n /**\n * Returns pre-defined filter values to become the default values\n */\n getDefaultFilterValues() {\n return this.schema.reduce((acc, item, filterIndex) => {\n if (item.type === 'll-checkbox') {\n acc[filterIndex] = item.attributes.checked || false;\n } else if (Object.prototype.hasOwnProperty.call(item.attributes, 'modelValue')) {\n acc[filterIndex] = item.attributes.modelValue;\n }\n\n return acc;\n }, {});\n },\n\n /**\n * Intended for external use, when filter values need to be set for the user\n */\n setFilterValues(newValues) {\n this.filterValues = merge({}, this.filterValues, newValues);\n this.forceRenderCount++;\n },\n\n updateValidationValues() {\n const validatable = Object.keys(this.validationSchema());\n\n this.schema.forEach((fieldSchema, filterIndex) => {\n const fieldToFilter = fieldSchema.fieldToFilter;\n const validate = validatable.includes(fieldToFilter);\n\n if (validate) {\n const filter = this.filters[fieldToFilter];\n\n /**\n * Get all validatable fields.\n * Use parsed value of filters that are set,\n * otherwise fall back to `filterValue` value if not set.\n */\n const filterValue = filter\n ? filter.isMultiple\n ? filter.filterBy\n : filter.filterBy[0]\n : this.filterValues[filterIndex];\n\n this.validationValues[fieldToFilter] = filterValue;\n }\n });\n },\n\n /**\n * Change handler for filter fields\n */\n onChange(filter, filterValues, filterIndex) {\n if (filter.on?.change) {\n // Maps to `on.change` handlers in the filter schema.\n filter.on.change(filterValues, filterIndex);\n }\n },\n\n /**\n * Select input event handler for filter fields\n */\n onSelectInput(newValue, filter, filterIndex) {\n if (newValue === undefined) {\n delete this.filterValues[filterIndex]; // prevent undefined filterValues which cause an empty result list\n } else {\n this.filterValues[filterIndex] = newValue;\n }\n\n this.onChange(filter, this.filterValues, filterIndex);\n },\n\n /**\n * Get filter values from local storage.\n * @returns {any}\n */\n getPersistentFilterValues() {\n return persistentStorage.get('filter-values');\n },\n\n /**\n * Clone new filterValues to remove reactivity, and save them to localStorage.\n * @param {object} newValues - the filterValues to be persisted in localStorage\n */\n persistFilterValues(newValues) {\n persistentStorage.set('filter-values', cloneDeep(newValues));\n },\n },\n };\n</script>\n\n<template>\n <div class=\"ll-grid ll-grid-cols-4 md:ll-grid-cols-12\">\n <template v-for=\"(filter, filterIndex) in schema\">\n <div\n v-if=\"!filter.hidden\"\n :key=\"`${filterIndex} ${forceRenderCount}`\"\n class=\"field-wrapper col-span-4 md:col-span-3\"\n :class=\"{ 'hidden-sm-only': !filter.type, 'align-bottom tw-flex': filter.type === 'll-checkbox' }\"\n :data-test=\"`filter|${filter.fieldToFilter}`\"\n >\n <!-- Filter component -->\n <ll-select\n v-if=\"filter.type === 'll-select'\"\n v-bind=\"filter.attributes\"\n :error=\"validation?.fields[filter.fieldToFilter] && validation?.getError(filter.fieldToFilter)\"\n :label=\"filter.label\"\n :model-value=\"filterValues[filterIndex]\"\n @update:model-value=\"(newValue) => onSelectInput(newValue, filter, filterIndex)\"\n />\n <ll-checkbox\n v-else-if=\"filter.type === 'll-checkbox'\"\n v-model:checked=\"filterValues[filterIndex]\"\n v-bind=\"filter.attributes\"\n :error-text=\"validation?.fields[filter.fieldToFilter] && validation?.getError(filter.fieldToFilter)\"\n :label=\"filter.label\"\n @update:checked=\"onChange(filter, filterValues, filterIndex)\"\n />\n <ll-radio\n v-else-if=\"filter.type === 'll-radio'\"\n v-model:checked=\"filterValues[filterIndex]\"\n v-bind=\"filter.attributes\"\n :error-text=\"validation?.fields[filter.fieldToFilter] && validation?.getError(filter.fieldToFilter)\"\n :label=\"filter.label\"\n @update:checked=\"onChange(filter, filterValues, filterIndex)\"\n />\n <component\n v-bind=\"filter.attributes\"\n :is=\"filter.type\"\n v-else-if=\"filter.type\"\n v-model=\"filterValues[filterIndex]\"\n :error-text=\"validation?.fields[filter.fieldToFilter] && validation?.getError(filter.fieldToFilter)\"\n :label=\"filter.label\"\n @update:model-value=\"onChange(filter, filterValues, filterIndex)\"\n >\n <template v-if=\"filter.slots && filter.slots.selected\" #selected=\"{ option }\">\n <component :is=\"filter.slots.selected\" v-bind=\"option.props\" />\n </template>\n <template v-if=\"filter.slots && filter.slots.option\" #option=\"{ option }\">\n <component :is=\"filter.slots.option\" v-bind=\"option.props\" />\n </template>\n <template v-if=\"filter.slots && filter.slots.prepend\" #prepend>\n <span v-html=\"filter.slots.prepend\"></span>\n </template>\n <template v-if=\"filter.slots && filter.slots.append\" #append>\n <span v-html=\"filter.slots.append\"></span>\n </template>\n </component>\n </div>\n </template>\n <div\n class=\"align-right align-bottom button-grid col-span-4 md:col-span-12 tw-flex\"\n :class=\"$style['filter-button-group']\"\n >\n <ll-button secondary data-test=\"button|reset-filters\" :disabled=\"disableClear\" @click=\"resetFilters\">\n {{ clearText }}\n </ll-button>\n <ll-button\n primary\n data-test=\"button|apply-filters\"\n :disabled=\"disableApply || validation?.hasErrors\"\n @click=\"applyFilters\"\n >\n {{ applyText }}\n </ll-button>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\" module>\n .filter-button-group {\n @include breakpoint('sm-only') {\n display: flex;\n flex-direction: column-reverse;\n }\n\n button {\n @include breakpoint('sm-only') {\n width: 100% !important;\n }\n\n &:nth-child(2) {\n @include breakpoint('sm-only') {\n margin-bottom: space(2);\n }\n }\n }\n }\n</style>\n"],"names":["_sfc_main","Button","Checkbox","Input","InputOptions","Radio","Select","DatePicker","props","getValidationSchema","toRefs","validationSchema","validationValues","ref","validation","initValidation","values","fieldName","validationRules","rules","fieldRules","fieldRule","useValidation","t","newFilterValues","filters","acc","schema","item","trackBy","isObject","isCustomFilterComponent","isMultiple","filterBy","v","groupedWith","nextTick","LLLV_CHANGE_TRIGGERS","trigger","filterIndex","newValues","merge","validatable","fieldSchema","fieldToFilter","filter","filterValue","filterValues","_a","newValue","persistentStorage","cloneDeep","_hoisted_1","_openBlock","_createElementBlock","_Fragment","_renderList","$props","$data","_normalizeClass","_createBlock","_component_ll_select","_mergeProps","$setup","_b","$options","_component_ll_checkbox","$event","_c","_d","_component_ll_radio","_e","_f","_resolveDynamicComponent","_g","_h","_withCtx","option","_normalizeProps","_guardReactiveProps","_createElementVNode","_ctx","_createVNode","_component_ll_button"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AiC,EAAAC,EAAUF,EAAO,KAAK,CAAA,GAAA,MAAA,EAAA;AAAA;;;YAE3ChC,EAAO,SAASA,EAAO,MAAM;oBAAU;AAAA,oBACrD,MAA2C;AAAA,gBAA3CmC,EAA2C,QAAA;AAAA,kBAArC,WAAQnC,EAAO,MAAM;AAAA;;;;YAEbA,EAAO,SAASA,EAAO,MAAM;oBAAS;AAAA,oBACpD,MAA0C;AAAA,gBAA1CmC,EAA0C,QAAA;AAAA,kBAApC,WAAQnC,EAAO,MAAM;AAAA;;;;;;;;IAKnCmC,EAeM,OAAA;AAAA,MAdJ,OAAKrB,EAAA,CAAC,0EACEsB,EAAM,OAAA,qBAAA,CAAA,CAAA;AAAA;MAEdC,EAEYC,GAAA;AAAA,QAFD,WAAA;AAAA,QAAU,aAAU;AAAA,QAAwB,UAAU1B,EAAY;AAAA,QAAG,SAAOQ,EAAY;AAAA;mBACjG,MAAe;AAAA,cAAZP,EAAS,SAAA,GAAA,CAAA;AAAA;;;MAEdwB,EAOYC,GAAA;AAAA,QANV,SAAA;AAAA,QACA,aAAU;AAAA,QACT,UAAU1B,EAAA,kBAAgBT,IAAAe,EAAA,eAAA,gBAAAf,EAAY;AAAA,QACtC,SAAOiB,EAAY;AAAA;mBAEpB,MAAe;AAAA,cAAZP,EAAS,SAAA,GAAA,CAAA;AAAA;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Filters.js","sources":["../src/components/Filters/Filters.vue"],"sourcesContent":["<script>\n import cloneDeep from 'lodash-es/cloneDeep';\n import merge from 'lodash-es/merge';\n import { nextTick, ref, toRefs } from 'vue';\n\n import useValidation from '../../composables/useValidation/useValidation';\n import { LLLV_CHANGE_TRIGGERS } from '../../constants';\n import { t } from '../../locale';\n import { persistentStorage } from '../../storage';\n import Button from '../Button/Button.vue';\n import Checkbox from '../Checkbox/Checkbox.vue';\n import DatePicker from '../DatePicker/DatePicker.vue';\n import Input from '../Input/Input.vue';\n import InputOptions from '../InputOptions/InputOptions.vue';\n import Radio from '../Radio/Radio.vue';\n import Select from '../Select/Select.vue';\n\n export default {\n name: 'll-filters',\n\n components: {\n 'll-button': Button,\n 'll-checkbox': Checkbox,\n 'll-input': Input,\n 'll-input-options': InputOptions,\n 'll-radio': Radio,\n 'll-select': Select,\n DatePicker,\n },\n\n props: {\n /**\n * Whether to disable the Apply button\n */\n disableApply: Boolean,\n /**\n * Whether to disable the Clear button\n */\n disableClear: Boolean,\n /**\n * Whether to disable the sticky filters\n * If disabled, a default pre-selected value(s) can be added to\n * the filter component's attributes\n */\n disablePersistency: Boolean,\n /**\n * Filters schema\n */\n schema: {\n type: Array,\n default: () => [],\n },\n /**\n * Validation schema function that returns an object\n */\n validationSchema: {\n type: Function,\n default: () => () => undefined,\n },\n },\n\n emits: ['change', 'submit', 'reset'],\n\n setup(props) {\n const { validationSchema: getValidationSchema } = toRefs(props);\n const validationSchema = getValidationSchema.value();\n const validationValues = ref({});\n\n // Without ref, `this.validation` will always evaluate to its initial value of `undefined` due to lack of reactivity.\n const validation = ref();\n\n function initValidation() {\n if (validationSchema?.toString() !== '[object Object]') {\n return;\n }\n\n validationValues.value = Object.keys(validationSchema).reduce((values, fieldName) => {\n values[fieldName] = undefined;\n\n return values;\n }, {});\n\n const validationRules = Object.entries(validationSchema).reduce((rules, [fieldName, fieldRules]) => {\n rules[fieldName] = fieldRules.map((fieldRule) => {\n return fieldRule(validationValues);\n });\n\n return rules;\n }, {});\n\n validation.value = useValidation({ rules: validationRules, values: validationValues });\n validation.value.validate();\n }\n\n return {\n validation,\n validationValues,\n initValidation,\n };\n },\n\n data() {\n return {\n applyText: t('ll.apply'),\n clearText: t('ll.clear'),\n filters: {},\n filterValues: {},\n forceRenderCount: 0,\n };\n },\n\n watch: {\n filterValues: {\n /**\n * Maps filters to a partcular object structure:\n * @param {IFilterSchemaItem} newFilterValues all selected filters\n * @returns {IFilter}\n */\n handler: function (newFilterValues) {\n const filters = Object.keys(newFilterValues).reduce((acc, i) => {\n const schema = this.schema[i];\n\n if (!schema || !schema.fieldToFilter) {\n return acc;\n }\n\n const item = newFilterValues[i];\n\n // Ignore empty string or undefined/null filter values\n if (item === '' || item == null) {\n return acc;\n }\n\n const trackBy = schema.attributes.trackBy || 'id';\n const isObject = typeof item === 'object';\n const isCustomFilterComponent = typeof schema.type === 'object';\n // TODO: remove handling of schema.attributes.multiple when we remove the vue-multiselect version of Select\n const isMultiple =\n (isCustomFilterComponent && schema.attributes.multiple) ||\n (!isCustomFilterComponent &&\n schema.type.includes('ll-select') &&\n (schema.attributes.multiple || !schema.attributes.single));\n const filterBy = isMultiple\n ? // local storage might have item stored as an object from the old Select\n (Array.isArray(item) ? item : [item]).map((v) => v[trackBy])\n : isObject\n ? [item[trackBy]]\n : [item];\n\n const groupedWith = schema.groupedWith;\n\n if (groupedWith) {\n filterBy[0] = {\n index: groupedWith,\n value: newFilterValues[groupedWith],\n };\n filterBy.push({\n index: Number(i),\n value: newFilterValues[i],\n });\n }\n\n filterBy.length &&\n (acc[schema.fieldToFilter] = {\n // don't add to `filters` if no filterBy\n filterBy,\n filterType: schema.type, // Informs the applied filter count\n isMultiple,\n ...('fn' in schema && { customFilter: schema.fn }),\n });\n\n return acc;\n }, {});\n\n this.filters = filters;\n this.$emit('change', filters);\n },\n\n deep: true,\n immediate: true,\n },\n\n filters() {\n if (this.validation) {\n this.updateValidationValues();\n }\n },\n },\n\n async created() {\n // initFilterValues updates the filterValues so using await nextTick() forces the code\n // after it to wait until nextTick is done, at which point the filterValues will\n // be done initializing. Otherwise, applyFilters sometimes applies the wrong\n // filters because filterValues is not done updating.\n this.initFilterValues();\n await nextTick();\n this.initValidation();\n this.applyFilters({ trigger: LLLV_CHANGE_TRIGGERS.LOAD });\n },\n\n methods: {\n initFilterValues() {\n if (this.disablePersistency) {\n this.filterValues = this.getDefaultFilterValues();\n\n return;\n }\n\n this.filterValues = this.getPersistentFilterValues() || this.getDefaultFilterValues();\n },\n\n /**\n * Apply the selected filters and save them to localStorage.\n * ListView calls this method using a ref to Filters.\n * The trigger option is used in ListView.\n * @param {object} [options] - optional parameters\n * @param {string} [options.trigger] - the action that triggered this function call\n */\n async applyFilters({ trigger = LLLV_CHANGE_TRIGGERS.APPLY } = {}) {\n if (this.validation) {\n await this.validation.validate();\n\n if (this.validation.hasErrors) {\n return;\n }\n }\n\n if (!this.disablePersistency) {\n this.persistFilterValues(this.filterValues);\n }\n\n this.$emit('submit', { trigger });\n },\n\n resetFilters() {\n this.filterValues = this.getDefaultFilterValues();\n\n this.forceRenderCount++;\n\n if (!this.disablePersistency) {\n this.persistFilterValues(this.filterValues);\n }\n\n // Emit after filters are updated\n this.$nextTick(() => {\n this.$emit('reset');\n });\n },\n\n /**\n * Returns pre-defined filter values to become the default values\n */\n getDefaultFilterValues() {\n return this.schema.reduce((acc, item, filterIndex) => {\n if (item.type === 'll-checkbox') {\n acc[filterIndex] = item.attributes.checked || false;\n } else if (Object.prototype.hasOwnProperty.call(item.attributes, 'modelValue')) {\n acc[filterIndex] = item.attributes.modelValue;\n }\n\n return acc;\n }, {});\n },\n\n /**\n * Intended for external use, when filter values need to be set for the user\n */\n setFilterValues(newValues) {\n this.filterValues = merge({}, this.filterValues, newValues);\n this.forceRenderCount++;\n },\n\n updateValidationValues() {\n const validatable = Object.keys(this.validationSchema());\n\n this.schema.forEach((fieldSchema, filterIndex) => {\n const fieldToFilter = fieldSchema.fieldToFilter;\n const validate = validatable.includes(fieldToFilter);\n\n if (validate) {\n const filter = this.filters[fieldToFilter];\n\n /**\n * Get all validatable fields.\n * Use parsed value of filters that are set,\n * otherwise fall back to `filterValue` value if not set.\n */\n const filterValue = filter\n ? filter.isMultiple\n ? filter.filterBy\n : filter.filterBy[0]\n : this.filterValues[filterIndex];\n\n this.validationValues[fieldToFilter] = filterValue;\n }\n });\n },\n\n /**\n * Change handler for filter fields\n */\n onChange(filter, filterValues, filterIndex) {\n if (filter.on?.change) {\n // Maps to `on.change` handlers in the filter schema.\n filter.on.change(filterValues, filterIndex);\n }\n },\n\n /**\n * Select input event handler for filter fields\n */\n onSelectInput(newValue, filter, filterIndex) {\n if (newValue === undefined) {\n delete this.filterValues[filterIndex]; // prevent undefined filterValues which cause an empty result list\n } else {\n this.filterValues[filterIndex] = newValue;\n }\n\n this.onChange(filter, this.filterValues, filterIndex);\n },\n\n /**\n * Get filter values from local storage.\n * @returns {any}\n */\n getPersistentFilterValues() {\n return persistentStorage.get('filter-values');\n },\n\n /**\n * Clone new filterValues to remove reactivity, and save them to localStorage.\n * @param {object} newValues - the filterValues to be persisted in localStorage\n */\n persistFilterValues(newValues) {\n persistentStorage.set('filter-values', cloneDeep(newValues));\n },\n },\n };\n</script>\n\n<template>\n <div class=\"ll-grid ll-grid-cols-4 md:ll-grid-cols-12\">\n <template v-for=\"(filter, filterIndex) in schema\">\n <div\n v-if=\"!filter.hidden\"\n :key=\"`${filterIndex} ${forceRenderCount}`\"\n class=\"field-wrapper col-span-4 md:col-span-3\"\n :class=\"{ 'hidden-sm-only': !filter.type, 'tw-flex tw-items-end': filter.type === 'll-checkbox' }\"\n :data-test=\"`filter|${filter.fieldToFilter}`\"\n >\n <!-- Filter component -->\n <ll-select\n v-if=\"filter.type === 'll-select'\"\n v-bind=\"filter.attributes\"\n :error=\"validation?.fields[filter.fieldToFilter] && validation?.getError(filter.fieldToFilter)\"\n :label=\"filter.label\"\n :model-value=\"filterValues[filterIndex]\"\n @update:model-value=\"(newValue) => onSelectInput(newValue, filter, filterIndex)\"\n />\n <ll-checkbox\n v-else-if=\"filter.type === 'll-checkbox'\"\n v-model:checked=\"filterValues[filterIndex]\"\n v-bind=\"filter.attributes\"\n :error-text=\"validation?.fields[filter.fieldToFilter] && validation?.getError(filter.fieldToFilter)\"\n :label=\"filter.label\"\n @update:checked=\"onChange(filter, filterValues, filterIndex)\"\n />\n <ll-radio\n v-else-if=\"filter.type === 'll-radio'\"\n v-model:checked=\"filterValues[filterIndex]\"\n v-bind=\"filter.attributes\"\n :error-text=\"validation?.fields[filter.fieldToFilter] && validation?.getError(filter.fieldToFilter)\"\n :label=\"filter.label\"\n @update:checked=\"onChange(filter, filterValues, filterIndex)\"\n />\n <component\n v-bind=\"filter.attributes\"\n :is=\"filter.type\"\n v-else-if=\"filter.type\"\n v-model=\"filterValues[filterIndex]\"\n :error-text=\"validation?.fields[filter.fieldToFilter] && validation?.getError(filter.fieldToFilter)\"\n :label=\"filter.label\"\n @update:model-value=\"onChange(filter, filterValues, filterIndex)\"\n >\n <template v-if=\"filter.slots && filter.slots.selected\" #selected=\"{ option }\">\n <component :is=\"filter.slots.selected\" v-bind=\"option.props\" />\n </template>\n <template v-if=\"filter.slots && filter.slots.option\" #option=\"{ option }\">\n <component :is=\"filter.slots.option\" v-bind=\"option.props\" />\n </template>\n <template v-if=\"filter.slots && filter.slots.prepend\" #prepend>\n <!-- eslint-disable-next-line vue/no-v-html -->\n <span v-html=\"filter.slots.prepend\"></span>\n </template>\n <template v-if=\"filter.slots && filter.slots.append\" #append>\n <!-- eslint-disable-next-line vue/no-v-html -->\n <span v-html=\"filter.slots.append\"></span>\n </template>\n </component>\n </div>\n </template>\n <div\n class=\"button-grid col-span-4 md:col-span-12 tw-flex tw-items-end tw-justify-end\"\n :class=\"$style['filter-button-group']\"\n >\n <ll-button secondary data-test=\"button|reset-filters\" :disabled=\"disableClear\" @click=\"resetFilters\">\n {{ clearText }}\n </ll-button>\n <ll-button\n primary\n data-test=\"button|apply-filters\"\n :disabled=\"disableApply || validation?.hasErrors\"\n @click=\"applyFilters\"\n >\n {{ applyText }}\n </ll-button>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\" module>\n .filter-button-group {\n @include breakpoint('sm-only') {\n display: flex;\n flex-direction: column-reverse;\n }\n\n button {\n @include breakpoint('sm-only') {\n width: 100% !important;\n }\n\n &:nth-child(2) {\n @include breakpoint('sm-only') {\n margin-bottom: space(2);\n }\n }\n }\n }\n</style>\n"],"names":["_sfc_main","Button","Checkbox","Input","InputOptions","Radio","Select","DatePicker","props","getValidationSchema","toRefs","validationSchema","validationValues","ref","validation","initValidation","values","fieldName","validationRules","rules","fieldRules","fieldRule","useValidation","t","newFilterValues","filters","acc","schema","item","trackBy","isObject","isCustomFilterComponent","isMultiple","filterBy","v","groupedWith","nextTick","LLLV_CHANGE_TRIGGERS","trigger","filterIndex","newValues","merge","validatable","fieldSchema","fieldToFilter","filter","filterValue","filterValues","_a","newValue","persistentStorage","cloneDeep","_hoisted_1","_openBlock","_createElementBlock","_Fragment","_renderList","$props","$data","_normalizeClass","_createBlock","_component_ll_select","_mergeProps","$setup","_b","$options","_component_ll_checkbox","$event","_c","_d","_component_ll_radio","_e","_f","_resolveDynamicComponent","_g","_h","_withCtx","option","_normalizeProps","_guardReactiveProps","_createElementVNode","_ctx","_createVNode","_component_ll_button"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiBOA,KAAU;AAAA,EACb,MAAM;AAAA,EAEN,YAAY;AAAA,IACV,aAAaC;AAAA,IACb,eAAeC;AAAA,IACf,YAAYC;AAAA,IACZ,oBAAoBC;AAAA,IACpB,YAAYC;AAAA,IACZ,aAAaC;AAAA,IACb,YAAAC;AAAA,EACD;AAAA,EAED,OAAO;AAAA;AAAA;AAAA;AAAA,IAIL,cAAc;AAAA;AAAA;AAAA;AAAA,IAId,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMd,oBAAoB;AAAA;AAAA;AAAA;AAAA,IAIpB,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,SAAS,MAAM,CAAE;AAAA,IAClB;AAAA;AAAA;AAAA;AAAA,IAID,kBAAkB;AAAA,MAChB,MAAM;AAAA,MACN,SAAS,MAAM,MAAA;AAAA;AAAA,IAChB;AAAA,EACF;AAAA,EAED,OAAO,CAAC,UAAU,UAAU,OAAO;AAAA,EAEnC,MAAMC,GAAO;AACX,UAAM,EAAE,kBAAkBC,EAAoB,IAAIC,EAAOF,CAAK,GACxDG,IAAmBF,EAAoB,SACvCG,IA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AAAe,EAAA,eAAA,gBAAAf,EAAY;AAAA,QACtC,SAAOiB,EAAY;AAAA;mBAEpB,MAAe;AAAA,cAAZP,EAAS,SAAA,GAAA,CAAA;AAAA;;;;;;;;;"}
|
package/dist/IconLabel.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as a, computed as o, openBlock as c, createBlock as i, resolveDynamicComponent as
|
|
1
|
+
import { defineComponent as a, computed as o, openBlock as c, createBlock as i, resolveDynamicComponent as f, mergeProps as u, withCtx as d, createVNode as m, normalizeClass as r, createElementVNode as p, renderSlot as _ } from "vue";
|
|
2
2
|
import w from "./Icon.js";
|
|
3
3
|
import { _ as v } from "./_plugin-vue_export-helper-dad06003.js";
|
|
4
4
|
import "lodash-es/uniqueId";
|
|
@@ -15,14 +15,14 @@ const h = /* @__PURE__ */ a({
|
|
|
15
15
|
stacked: { type: Boolean, default: !1 },
|
|
16
16
|
truncate: { type: Boolean, default: !1 }
|
|
17
17
|
},
|
|
18
|
-
setup(
|
|
19
|
-
const e =
|
|
18
|
+
setup(s) {
|
|
19
|
+
const e = s, n = o(() => e.to ? "router-link" : e.href ? "a" : "div"), l = o(() => e.to ? {
|
|
20
20
|
to: e.to
|
|
21
21
|
} : e.href ? {
|
|
22
22
|
href: e.href
|
|
23
23
|
} : {});
|
|
24
|
-
return (t, b) => (c(), i(
|
|
25
|
-
class: ["tw-flex", { "tw-flex-
|
|
24
|
+
return (t, b) => (c(), i(f(n.value), u(l.value, {
|
|
25
|
+
class: ["tw-flex", { "tw-flex-col tw-items-center": e.stacked }]
|
|
26
26
|
}), {
|
|
27
27
|
default: d(() => [
|
|
28
28
|
m(w, {
|
package/dist/IconLabel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconLabel.js","sources":["../src/components/IconLabel/IconLabel.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed } from 'vue';\n\n import { StashCommonColor } from '../../../types/colors';\n import { IconName } from '../Icon/Icon.types';\n import Icon from '../Icon/Icon.vue';\n\n export interface IconLabelProps {\n /**\n * Name of the icon to use. All design system icons are supported.\n */\n icon: IconName;\n\n /**\n * Color to apply to the icon. Common Stash colors are supported (default, 100 & 700 shades).\n */\n color?: StashCommonColor;\n\n /**\n * Valid hyperlink.\n */\n href?: string;\n\n /**\n * Valid vue-router route.\n */\n to?: string | object;\n\n /**\n * If true, renders the label below the icon instead of to the right\n */\n stacked?: boolean;\n\n /**\n * If true, truncates overflowing text with an ellipsis when it's unable to wrap\n */\n truncate?: boolean;\n }\n\n const props = withDefaults(defineProps<IconLabelProps>(), {\n color: undefined,\n href: undefined,\n to: undefined,\n stacked: false,\n truncate: false,\n });\n\n defineOptions({\n name: 'll-icon-label',\n });\n\n const is = computed(() => {\n if (props.to) {\n return 'router-link';\n }\n\n if (props.href) {\n return 'a';\n }\n\n return 'div';\n });\n\n const attributes = computed(() => {\n if (props.to) {\n return {\n to: props.to,\n };\n }\n\n if (props.href) {\n return {\n href: props.href,\n };\n }\n\n return {};\n });\n</script>\n\n<template>\n <component :is=\"is\" v-bind=\"attributes\" class=\"tw-flex\" :class=\"{ 'tw-flex-
|
|
1
|
+
{"version":3,"file":"IconLabel.js","sources":["../src/components/IconLabel/IconLabel.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed } from 'vue';\n\n import { StashCommonColor } from '../../../types/colors';\n import { IconName } from '../Icon/Icon.types';\n import Icon from '../Icon/Icon.vue';\n\n export interface IconLabelProps {\n /**\n * Name of the icon to use. All design system icons are supported.\n */\n icon: IconName;\n\n /**\n * Color to apply to the icon. Common Stash colors are supported (default, 100 & 700 shades).\n */\n color?: StashCommonColor;\n\n /**\n * Valid hyperlink.\n */\n href?: string;\n\n /**\n * Valid vue-router route.\n */\n to?: string | object;\n\n /**\n * If true, renders the label below the icon instead of to the right\n */\n stacked?: boolean;\n\n /**\n * If true, truncates overflowing text with an ellipsis when it's unable to wrap\n */\n truncate?: boolean;\n }\n\n const props = withDefaults(defineProps<IconLabelProps>(), {\n color: undefined,\n href: undefined,\n to: undefined,\n stacked: false,\n truncate: false,\n });\n\n defineOptions({\n name: 'll-icon-label',\n });\n\n const is = computed(() => {\n if (props.to) {\n return 'router-link';\n }\n\n if (props.href) {\n return 'a';\n }\n\n return 'div';\n });\n\n const attributes = computed(() => {\n if (props.to) {\n return {\n to: props.to,\n };\n }\n\n if (props.href) {\n return {\n href: props.href,\n };\n }\n\n return {};\n });\n</script>\n\n<template>\n <component :is=\"is\" v-bind=\"attributes\" class=\"tw-flex\" :class=\"{ 'tw-flex-col tw-items-center': props.stacked }\">\n <Icon :name=\"props.icon\" size=\"dense\" :class=\"[$style.icon, { [`text-${color}`]: !!color }]\" />\n\n <div\n :class=\"{\n 'tw-ml-1.5 tw-flex-1': !props.stacked,\n 'text-xs tw-mt-1.5 tw-leading-3': props.stacked,\n 'tw-truncate': truncate,\n }\"\n >\n <!-- @slot Label text -->\n <slot></slot>\n </div>\n </component>\n</template>\n\n<style module>\n .icon {\n margin-top: -1px;\n }\n</style>\n"],"names":["is","computed","props","attributes"],"mappings":";;;;;;;;;;;;;;;;;;iBAmDQA,IAAKC,EAAS,MACdC,EAAM,KACD,gBAGLA,EAAM,OACD,MAGF,KACR,GAEKC,IAAaF,EAAS,MACtBC,EAAM,KACD;AAAA,MACL,IAAIA,EAAM;AAAA,IAAA,IAIVA,EAAM,OACD;AAAA,MACL,MAAMA,EAAM;AAAA,IAAA,IAIT,EACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|