@citruslime/ui 4.1.0-beta.11 → 4.1.0-beta.13

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.
@@ -1739,6 +1739,7 @@ const messages = {
1739
1739
  onOrBefore: "On or before",
1740
1740
  onOrAfter: "On or after",
1741
1741
  selectAll: "Select all",
1742
+ clearAll: "Clear all",
1742
1743
  allEntriesSelected: "All entries selected",
1743
1744
  page: "Page",
1744
1745
  pageSize: "Page Size",
@@ -5271,6 +5272,11 @@ const defaultSelectAllListValue = computed(() => ({
5271
5272
  name: i18n.global.t("grid.selectAll"),
5272
5273
  value: ""
5273
5274
  }));
5275
+ const defaultClearAllListValue = computed(() => ({
5276
+ id: -3,
5277
+ name: i18n.global.t("grid.clearAll"),
5278
+ value: ""
5279
+ }));
5274
5280
  const booleanListEntries = computed(() => [
5275
5281
  defaultEmptyListValue,
5276
5282
  {
@@ -5328,14 +5334,25 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
5328
5334
  const isStringColumn = computed(() => props.column.type === "string" || props.column.type === "slot" && props.column.slotType === "string");
5329
5335
  const numericFormat = computed(() => props.column.format === NumberFormat.INTEGER ? NumberFormat.DECIMAL : props.column.format ?? NumberFormat.DECIMAL);
5330
5336
  const booleanValueAsSelectItem = computed(() => booleanListEntries.value.find((x) => x.value === currentFilterValue.value.toString()) ?? null);
5331
- const listEntriesAsSelectItems = computed(() => [
5332
- props.column.listMode === "multi" ? defaultSelectAllListValue.value : defaultEmptyListValue,
5333
- ...props.column.listEntries?.map((x, i) => ({
5337
+ const listEntriesAsSelectItems = computed(() => {
5338
+ const baseItems = [
5339
+ props.column.listMode === "multi" ? defaultSelectAllListValue.value : defaultEmptyListValue,
5340
+ ...props.column.listMode === "multi" && props.filter?.length && props.filter.length > 0 ? [defaultClearAllListValue.value] : []
5341
+ ];
5342
+ const selectedFilterValues = props.filter?.filter((f) => f.filterOperation === FilterOperation.OR_EQUAL).map((f) => f.filterValue) ?? [];
5343
+ const allListEntries = props.column.listEntries?.map((x, i) => ({
5334
5344
  id: i,
5335
5345
  name: t2(x.translationKey),
5336
5346
  value: x.value.toString()
5337
- })) ?? []
5338
- ]);
5347
+ })) ?? [];
5348
+ const selectedListEntries = allListEntries.filter((entry) => selectedFilterValues.includes(entry.value));
5349
+ const unselectedListEntries = allListEntries.filter((entry) => !selectedFilterValues.includes(entry.value));
5350
+ return [
5351
+ ...baseItems,
5352
+ ...selectedListEntries,
5353
+ ...unselectedListEntries
5354
+ ];
5355
+ });
5339
5356
  const currentFilterValueAsSelectItems = computed(() => {
5340
5357
  if (props.column.listMode !== "multi") {
5341
5358
  const item = listEntriesAsSelectItems.value.find((x) => x.value === currentFilterValue.value && x.id === selectedListEntryId.value) ?? listEntriesAsSelectItems.value.find((x) => x.value === currentFilterValue.value) ?? null;
@@ -5539,7 +5556,8 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
5539
5556
  const filterable = computed(() => isFilterable(props.column));
5540
5557
  function setOrEqualFilters(value) {
5541
5558
  const selectAllCurrentlySelected = value.some((x) => x.id === defaultSelectAllListValue.value.id);
5542
- if (value.length === 0 || selectAllCurrentlySelected === false && selectAllCurrentlyHighlighted.value) {
5559
+ const clearAllCurrentlySelected = value.some((x) => x.id === defaultClearAllListValue.value.id);
5560
+ if (value.length === 0 || selectAllCurrentlySelected === false && selectAllCurrentlyHighlighted.value || clearAllCurrentlySelected) {
5543
5561
  setOrEqualFiltersImpl([defaultSelectAllListValue.value.value]);
5544
5562
  } else if (selectAllCurrentlySelected && selectAllCurrentlyHighlighted.value === false) {
5545
5563
  setOrEqualFiltersImpl(listEntriesAsSelectItems.value.map((x) => x.value));
@@ -5564,6 +5582,9 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
5564
5582
  if (hasNextValue === false && hasPreviousValue) {
5565
5583
  nextValue = "";
5566
5584
  }
5585
+ if (nextValue === previousValue) {
5586
+ return;
5587
+ }
5567
5588
  const updateFilter = hasNextValue || hasPreviousValue;
5568
5589
  if (updateFilter) {
5569
5590
  if (internalFilter.value) {
@@ -5792,7 +5813,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
5792
5813
  };
5793
5814
  }
5794
5815
  });
5795
- const clUiGridFilterInput = /* @__PURE__ */ _export_sfc(_sfc_main$G, [["__scopeId", "data-v-a9b5c9ab"]]);
5816
+ const clUiGridFilterInput = /* @__PURE__ */ _export_sfc(_sfc_main$G, [["__scopeId", "data-v-0de4e508"]]);
5796
5817
  const _hoisted_1$y = { key: 1 };
5797
5818
  const _sfc_main$F = /* @__PURE__ */ defineComponent({
5798
5819
  __name: "cl-ui-grid-filter",