@leaflink/stash 44.0.0-beta.5 → 44.0.0-beta.6

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/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 S, nextTick as Y, resolveComponent as y, openBlock as c, createElementBlock as V, Fragment as j, renderList as q, normalizeClass as L, createBlock as f, mergeProps as g, resolveDynamicComponent as k, createSlots as J, withCtx as b, normalizeProps as O, guardReactiveProps as R, createElementVNode as v, createCommentVNode as U, createVNode as D, createTextVNode as A, toDisplayString as M } from "vue";
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 N } from "./constants.js";
6
- import { t as H } from "./locale.js";
7
- import { persistentStorage as w } from "./storage.js";
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 = S({}), t = S();
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: H("ll.apply"),
114
- clearText: H("ll.clear"),
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: N.LOAD });
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 = N.APPLY } = {}) {
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 w.get("filter-values");
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
- w.set("filter-values", G(l));
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(j, null, q(o.schema, (e, a) => {
245
- var _, F, T, C, x, P, B, E;
246
- return c(), V(j, null, [
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, "align-bottom tw-flex": e.type === "ll-checkbox" }]),
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, g({ key: 0 }, e.attributes, {
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, g({
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, g({
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(k(e.type), g({ key: 3 }, e.attributes, {
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]) && ((E = i.validation) == null ? void 0 : E.getError(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(k(e.slots.selected), O(R(n.props)), null, 16))
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(k(e.slots.option), O(R(n.props)), null, 16))
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
- v("span", {
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
- v("span", {
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
- v("div", {
316
- class: L(["align-right align-bottom button-grid col-span-4 md:col-span-12 tw-flex", l.$style["filter-button-group"]])
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: "",
@@ -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"],"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AAAA,sBACpEjB,EAA6Da,EAA7C5B,EAAO,MAAM,MAAM,GAAAiC,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 <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=\"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,IAAmBC,EAAI,CA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,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 u, mergeProps as f, withCtx as d, createVNode as m, normalizeClass as r, createElementVNode as p, renderSlot as _ } from "vue";
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(n) {
19
- const e = n, s = o(() => e.to ? "router-link" : e.href ? "a" : "div"), l = o(() => e.to ? {
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(u(s.value), f(l.value, {
25
- class: ["tw-flex", { "tw-flex-column tw-items-center": e.stacked }]
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, {
@@ -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-column 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/ListView.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import W from "lodash-es/cloneDeep";
2
- import { resolveComponent as d, openBlock as a, createElementBlock as o, normalizeClass as r, createElementVNode as u, createVNode as p, toDisplayString as b, createCommentVNode as n, createBlock as h, withCtx as m, createTextVNode as T, renderSlot as f, TransitionGroup as F, resolveDirective as O, withDirectives as E, computed as q, withKeys as Y, normalizeStyle as J, Fragment as Q, renderList as X, mergeProps as Z, resolveDynamicComponent as $ } from "vue";
2
+ import { resolveComponent as d, openBlock as a, createElementBlock as o, normalizeClass as r, createElementVNode as u, createVNode as p, toDisplayString as _, createCommentVNode as n, createBlock as h, withCtx as m, createTextVNode as T, renderSlot as f, TransitionGroup as F, resolveDirective as O, withDirectives as E, computed as q, withKeys as Y, normalizeStyle as J, Fragment as Q, renderList as X, mergeProps as Z, resolveDynamicComponent as $ } from "vue";
3
3
  import ee from "./useSearch.js";
4
- import { CSS_VARS as L, LLLV_CHANGE_TRIGGERS as w } from "./constants.js";
4
+ import { CSS_VARS as L, LLLV_CHANGE_TRIGGERS as b } from "./constants.js";
5
5
  import V from "./sticky.js";
6
6
  import { t as y } from "./locale.js";
7
7
  import { persistentStorage as A } from "./storage.js";
@@ -127,15 +127,15 @@ const de = "_checkbox_7isy5_185", he = "_actions_7isy5_189", ue = {
127
127
  }
128
128
  }, ge = {
129
129
  key: 0,
130
- class: "align-middle tw-flex tw-flex-1 tw-justify-between"
130
+ class: "tw-flex tw-flex-1 tw-items-center tw-justify-between"
131
131
  }, fe = {
132
132
  key: 0,
133
- class: "text-small"
133
+ class: "tw-text-xs"
134
134
  }, pe = {
135
135
  key: 1,
136
136
  class: "lg:hidden tw-ml-1.5"
137
137
  };
138
- function Se(e, l, s, _, i, t) {
138
+ function Se(e, l, s, w, i, t) {
139
139
  const c = d("ll-checkbox"), g = d("ll-button");
140
140
  return a(), o("div", {
141
141
  class: r([
@@ -147,8 +147,8 @@ function Se(e, l, s, _, i, t) {
147
147
  ])
148
148
  }, [
149
149
  u("div", {
150
- class: r(["align-middle tw-flex", {
151
- "align-justify": !s.hideBulkActionOptions
150
+ class: r(["tw-flex tw-items-center", {
151
+ "tw-justify-between": !s.hideBulkActionOptions
152
152
  }])
153
153
  }, [
154
154
  p(c, {
@@ -160,7 +160,7 @@ function Se(e, l, s, _, i, t) {
160
160
  "onUpdate:checked": t.onSelectPage
161
161
  }, null, 8, ["class", "checked", "indeterminate", "label", "onUpdate:checked"]),
162
162
  s.totalSelectedCount && !s.hideBulkActionOptions ? (a(), o("div", ge, [
163
- s.hideNumberOfTotalSelected ? n("", !0) : (a(), o("div", fe, b(t.numberOfTotalSelectedText), 1)),
163
+ s.hideNumberOfTotalSelected ? n("", !0) : (a(), o("div", fe, _(t.numberOfTotalSelectedText), 1)),
164
164
  u("div", {
165
165
  class: r({ "tw-ml-3": !s.hideNumberOfTotalSelected })
166
166
  }, [
@@ -170,7 +170,7 @@ function Se(e, l, s, _, i, t) {
170
170
  onClick: t.selectAll
171
171
  }, {
172
172
  default: m(() => [
173
- T(b(t.selectAllCountText), 1)
173
+ T(_(t.selectAllCountText), 1)
174
174
  ]),
175
175
  _: 1
176
176
  }, 8, ["onClick"])) : (a(), h(g, {
@@ -179,13 +179,13 @@ function Se(e, l, s, _, i, t) {
179
179
  onClick: t.clearSelected
180
180
  }, {
181
181
  default: m(() => [
182
- T(b(t.clearSelectedText), 1)
182
+ T(_(t.clearSelectedText), 1)
183
183
  ]),
184
184
  _: 1
185
185
  }, 8, ["onClick"]))
186
186
  ], 2)
187
187
  ])) : s.hideBulkActionOptions && s.totalSelectedCount ? (a(), o("div", pe, [
188
- u("h4", null, b(t.numItemsSelectedText), 1)
188
+ u("h4", null, _(t.numItemsSelectedText), 1)
189
189
  ])) : n("", !0)
190
190
  ], 2),
191
191
  s.totalSelectedCount && !s.hideBulkActionOptions ? (a(), o("div", {
@@ -198,9 +198,9 @@ function Se(e, l, s, _, i, t) {
198
198
  }
199
199
  const ye = {
200
200
  $style: ue
201
- }, _e = /* @__PURE__ */ k(me, [["render", Se], ["__cssModules", ye]]), be = {
201
+ }, we = /* @__PURE__ */ k(me, [["render", Se], ["__cssModules", ye]]), _e = {
202
202
  "empty-state": "_empty-state_lwdra_176"
203
- }, we = {
203
+ }, be = {
204
204
  name: "loading-manager",
205
205
  components: {
206
206
  EmptyState: oe,
@@ -218,7 +218,7 @@ const ye = {
218
218
  }
219
219
  }
220
220
  };
221
- function ke(e, l, s, _, i, t) {
221
+ function ke(e, l, s, w, i, t) {
222
222
  const c = d("Loading"), g = d("EmptyState");
223
223
  return s.loading ? (a(), h(c, {
224
224
  key: 0,
@@ -239,8 +239,8 @@ function ke(e, l, s, _, i, t) {
239
239
  }, null, 8, ["class", "text"]));
240
240
  }
241
241
  const Ce = {
242
- $style: be
243
- }, Te = /* @__PURE__ */ k(we, [["render", ke], ["__cssModules", Ce]]), Ie = {
242
+ $style: _e
243
+ }, Te = /* @__PURE__ */ k(be, [["render", ke], ["__cssModules", Ce]]), Ie = {
244
244
  "main-header": "_main-header_12ll3_176",
245
245
  "expanded-content-wrapper": "_expanded-content-wrapper_12ll3_192",
246
246
  "expanded-content-header": "_expanded-content-header_12ll3_202",
@@ -303,7 +303,7 @@ const Ce = {
303
303
  }
304
304
  }
305
305
  }, ve = { class: "tw-flex-auto" }, Be = { ref: "actionsContainer" };
306
- function Ae(e, l, s, _, i, t) {
306
+ function Ae(e, l, s, w, i, t) {
307
307
  const c = d("Icon"), g = d("ll-button"), I = d("Expand"), x = O("sticky");
308
308
  return a(), o("div", {
309
309
  class: r([
@@ -315,7 +315,7 @@ function Ae(e, l, s, _, i, t) {
315
315
  ])
316
316
  }, [
317
317
  u("header", {
318
- class: r(["align-middle tw-flex", [e.$style["main-header"], { "tw-cursor-pointer": s.isCollapsible }]]),
318
+ class: r(["tw-flex tw-items-center", [e.$style["main-header"], { "tw-cursor-pointer": s.isCollapsible }]]),
319
319
  onClick: l[0] || (l[0] = (...C) => t.onHeaderClick && t.onHeaderClick(...C))
320
320
  }, [
321
321
  s.isCollapsible ? (a(), h(g, {
@@ -448,7 +448,7 @@ const Pe = {
448
448
  }
449
449
  }
450
450
  };
451
- function Le(e, l, s, _, i, t) {
451
+ function Le(e, l, s, w, i, t) {
452
452
  const c = d("ll-icon");
453
453
  return a(), o("div", {
454
454
  class: r(["tw-cursor-pointer", { "tw-bg-blue-100": t.isSorted }]),
@@ -501,7 +501,7 @@ const Ve = {
501
501
  }, He = {
502
502
  name: "ll-list-view",
503
503
  components: {
504
- BulkActions: _e,
504
+ BulkActions: we,
505
505
  Filters: re,
506
506
  Paginate: ne,
507
507
  LoadingManager: Te,
@@ -771,8 +771,8 @@ const Ve = {
771
771
  if (this.isServerSide)
772
772
  e = this.results;
773
773
  else {
774
- const { endIndex: l, totalCount: s, results: _, startIndex: i } = this;
775
- e = _.slice(i, Math.min(l, s));
774
+ const { endIndex: l, totalCount: s, results: w, startIndex: i } = this;
775
+ e = w.slice(i, Math.min(l, s));
776
776
  }
777
777
  return this.$emit("updateResults", e), e;
778
778
  },
@@ -817,8 +817,8 @@ const Ve = {
817
817
  },
818
818
  numberOfFilters() {
819
819
  return Object.keys(this.filters).reduce((e, l) => {
820
- const s = this.filters[l].filterBy, _ = typeof s[0] == "boolean", i = this.filters[l].filterType === "ll-checkbox", t = !this.filters[l].filterType.length, c = this.filters[l].filterType === "ll-input-options" && s[0] === "";
821
- return t || c ? e : _ || typeof s[0] == "string" ? e + (s[0] || !i ? 1 : 0) : e + (s.length || 0);
820
+ const s = this.filters[l].filterBy, w = typeof s[0] == "boolean", i = this.filters[l].filterType === "ll-checkbox", t = !this.filters[l].filterType.length, c = this.filters[l].filterType === "ll-input-options" && s[0] === "";
821
+ return t || c ? e : w || typeof s[0] == "string" ? e + (s[0] || !i ? 1 : 0) : e + (s.length || 0);
822
822
  }, 0);
823
823
  },
824
824
  isSelectBarVisible() {
@@ -932,9 +932,9 @@ const Ve = {
932
932
  return this.sortTerm ? se(e, this.sorts[this.sortTerm]) : e;
933
933
  },
934
934
  change({ trigger: e = "" } = {}) {
935
- const { currentPage: l, filters: s, isFiltered: _, pageSize: i, searchTerm: t, sortTerm: c } = this, g = {
935
+ const { currentPage: l, filters: s, isFiltered: w, pageSize: i, searchTerm: t, sortTerm: c } = this, g = {
936
936
  filters: s,
937
- isFiltered: _,
937
+ isFiltered: w,
938
938
  page: {
939
939
  number: l,
940
940
  previousNumber: this.previousPage,
@@ -958,7 +958,7 @@ const Ve = {
958
958
  */
959
959
  reset() {
960
960
  if (this.$emit("change:reset"), this.searchTerm = "", this.setPage({ pageNumber: 1 }), this.isServerSide) {
961
- this.change({ trigger: w.RESET });
961
+ this.change({ trigger: b.RESET });
962
962
  return;
963
963
  }
964
964
  this.processResults();
@@ -976,7 +976,7 @@ const Ve = {
976
976
  * by Filters.
977
977
  */
978
978
  onSearch() {
979
- this.$refs.llFilters.applyFilters({ trigger: w.SEARCH });
979
+ this.$refs.llFilters.applyFilters({ trigger: b.SEARCH });
980
980
  },
981
981
  /**
982
982
  * Event handler for when the user:
@@ -988,7 +988,7 @@ const Ve = {
988
988
  * @param {string} [options.trigger] - what caused the changes
989
989
  * @returns {Promise<void>}
990
990
  */
991
- async onFilter({ trigger: e = w.APPLY } = {}) {
991
+ async onFilter({ trigger: e = b.APPLY } = {}) {
992
992
  if (this.setPage({ pageNumber: 1 }), this.change({ trigger: e }), this.trackSearch(this.searchTerm), this.trackFilters(this.filters), this.selectedItems = [], !this.isServerSide) {
993
993
  try {
994
994
  this.isFiltering = !0, await this.processResults({ trigger: e });
@@ -1018,7 +1018,7 @@ const Ve = {
1018
1018
  * @param {string} term The updated sort term
1019
1019
  */
1020
1020
  onSort(e) {
1021
- e !== this.sortTerm && (this.sortTerm = e, this.$emit("change:sort", e), this.trackSort(e), this.clearSelected(), this.setPage({ pageNumber: 1 }), this.change({ trigger: w.SORT }));
1021
+ e !== this.sortTerm && (this.sortTerm = e, this.$emit("change:sort", e), this.trackSort(e), this.clearSelected(), this.setPage({ pageNumber: 1 }), this.change({ trigger: b.SORT }));
1022
1022
  },
1023
1023
  /**
1024
1024
  * Sets current page for the Paginator.
@@ -1027,7 +1027,7 @@ const Ve = {
1027
1027
  * @param {boolean} data.forceChange - flag to force the change
1028
1028
  */
1029
1029
  setPage({ pageNumber: e, forceChange: l = !1 } = {}) {
1030
- this.previousPage = this.currentPage, this.currentPage = e, this.isServerSide || this.$emit("change:page", e), l && this.change({ trigger: w.PAGE });
1030
+ this.previousPage = this.currentPage, this.currentPage = e, this.isServerSide || this.$emit("change:page", e), l && this.change({ trigger: b.PAGE });
1031
1031
  },
1032
1032
  /**
1033
1033
  * Set the scroll position to the top of the list view.
@@ -1069,11 +1069,11 @@ const Ve = {
1069
1069
  return e.reduce((l, s) => this.isItemDisabled(s) ? l : [...l, s], []);
1070
1070
  }
1071
1071
  }
1072
- }, Me = { class: "ll-grid ll-grid-cols-4 md:ll-grid-cols-8 lg:ll-grid-cols-12" }, je = ["disabled"], Ge = { class: "align-right align-bottom button-grid col-span-1 lg:col-span-3" }, Ue = {
1072
+ }, Me = { class: "ll-grid ll-grid-cols-4 md:ll-grid-cols-8 lg:ll-grid-cols-12" }, je = ["disabled"], Ge = { class: "button-grid col-span-1 lg:col-span-3 tw-items-end tw-justify-end" }, Ue = {
1073
1073
  key: 0,
1074
- class: "text-small"
1074
+ class: "tw-text-xs"
1075
1075
  };
1076
- function Ke(e, l, s, _, i, t) {
1076
+ function Ke(e, l, s, w, i, t) {
1077
1077
  const c = d("Icon"), g = d("Button"), I = d("Input"), x = d("Badge"), C = d("Filters"), z = d("Expand"), H = d("Dropdown"), M = d("Checkbox"), j = d("BulkActions"), G = d("Paginate"), U = O("sticky");
1078
1078
  return a(), o("div", null, [
1079
1079
  t.showPrimaryControls || t.showSecondaryControls ? (a(), o("div", {
@@ -1129,7 +1129,7 @@ function Ke(e, l, s, _, i, t) {
1129
1129
  }, 8, ["modelValue", "class", "hint-text", "label", "placeholder", "onChange"])) : n("", !0),
1130
1130
  s.filterSchema.length ? (a(), o("div", {
1131
1131
  key: 1,
1132
- class: r(["col-span-1 align-bottom tw-flex", [
1132
+ class: r(["col-span-1 tw-flex tw-items-end", [
1133
1133
  e.$style["filter-toggle-btn"],
1134
1134
  { [e.$style["filter-toggle-btn-with-hint-text"]]: !!t.internalSearchSchema.hintText }
1135
1135
  ]])
@@ -1153,7 +1153,7 @@ function Ke(e, l, s, _, i, t) {
1153
1153
  key: 1,
1154
1154
  name: "filter-line"
1155
1155
  })),
1156
- T(" " + b(i.filterText), 1)
1156
+ T(" " + _(i.filterText), 1)
1157
1157
  ]),
1158
1158
  _: 1
1159
1159
  }, 8, ["disabled", "onClick"])
@@ -1203,7 +1203,7 @@ function Ke(e, l, s, _, i, t) {
1203
1203
  key: 1,
1204
1204
  class: r(["tw-mb-1.5", t.shouldShowTotal ? e.$style["total-sort"] : "tw-text-right"])
1205
1205
  }, [
1206
- t.shouldShowTotal ? (a(), o("div", Ue, b(t.total), 1)) : n("", !0),
1206
+ t.shouldShowTotal ? (a(), o("div", Ue, _(t.total), 1)) : n("", !0),
1207
1207
  Object.keys(s.sorts).length ? (a(), h(H, {
1208
1208
  key: 1,
1209
1209
  class: r(e.$style.dropdown),
@@ -1218,15 +1218,15 @@ function Ke(e, l, s, _, i, t) {
1218
1218
  }, [
1219
1219
  (a(!0), o(Q, null, X(Object.keys(s.sorts), (S, K) => (a(), o("li", {
1220
1220
  key: K,
1221
- class: r([{ "is-selected": S === i.sortTerm }, "dropdown__item tw-rounded"])
1221
+ class: r([{ "tw-bg-blue-100 tw-text-ice-700": S === i.sortTerm }, "dropdown__item tw-rounded"])
1222
1222
  }, [
1223
1223
  p(g, {
1224
1224
  inline: "",
1225
- class: r(["align-middle", e.$style["sort-option"]]),
1225
+ class: r(["tw-items-center", e.$style["sort-option"]]),
1226
1226
  onClick: (qe) => t.onSort(S)
1227
1227
  }, {
1228
1228
  default: m(() => [
1229
- T(b(S) + " ", 1),
1229
+ T(_(S) + " ", 1),
1230
1230
  S === i.sortTerm ? (a(), h(c, {
1231
1231
  key: 0,
1232
1232
  name: "check",
@@ -1334,7 +1334,7 @@ const We = {
1334
1334
  $style: ze
1335
1335
  }, is = /* @__PURE__ */ k(He, [["render", Ke], ["__cssModules", We]]);
1336
1336
  export {
1337
- _e as BulkActions,
1337
+ we as BulkActions,
1338
1338
  ss as ListGroup,
1339
1339
  ls as ListHeader,
1340
1340
  Te as LoadingManager,