fds-vue-core 9.0.0 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fds-vue-core",
3
- "version": "9.0.0",
3
+ "version": "9.1.0",
4
4
  "description": "FDS Vue Core Component Library",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -39,6 +39,10 @@ const meta: Meta<typeof FdsSearchSelect> = {
39
39
  control: { type: 'boolean' },
40
40
  description: 'Allows divider rows to be selectable',
41
41
  },
42
+ keepDividerOrder: {
43
+ control: { type: 'boolean' },
44
+ description: 'Keeps explicit divider groups in the given order instead of sorting them by label',
45
+ },
42
46
  showLoadMore: {
43
47
  control: { type: 'boolean' },
44
48
  description: 'Shows load-more action row at the end of list',
@@ -684,6 +688,26 @@ export const SingleSelectWithSelectableDivider: Story = {
684
688
  },
685
689
  }
686
690
 
691
+ export const KeepDividerOrder: Story = {
692
+ args: {
693
+ items: [
694
+ { id: 'shown', name: 'Visas i App och Portal', isDivider: true },
695
+ { id: 1, name: 'Hälsoundersökning' },
696
+ { id: 2, name: 'Vaccination' },
697
+ { id: 'hidden', name: 'Visas ej i App och Portal', isDivider: true },
698
+ { id: 3, name: 'Hörseltest' },
699
+ { id: 'scheduling', name: 'Schemaläggning: Visas som fysiskt besök', isDivider: true },
700
+ { id: 4, name: 'Syntest' },
701
+ ],
702
+ keepDividerOrder: true,
703
+ itemKey: 'id',
704
+ searchFields: ['name'],
705
+ label: 'Tjänstetyp',
706
+ searchContext: { context: 'tjänstetyper', linkWord: 'av' },
707
+ noResultPrompt: 'Inga resultat hittades',
708
+ },
709
+ }
710
+
687
711
  export const MultipleWithLoadMore: Story = {
688
712
  args: {
689
713
  items: largeHierarchicalItems,
@@ -34,6 +34,7 @@ const props = withDefaults(defineProps<FdsSearchSelectProProps>(), {
34
34
  itemKey: undefined,
35
35
  dividerField: 'isDivider',
36
36
  dividerSelectable: false,
37
+ keepDividerOrder: false,
37
38
  autoDividerBy: undefined,
38
39
  levelField: 'level',
39
40
  showSelectedToggle: false,
@@ -29,6 +29,8 @@ export interface FdsSearchSelectProProps extends Omit</* @vue-ignore */ HTMLAttr
29
29
  dividerField?: string
30
30
  /** Allows divider rows/group headers to be selectable as regular options. */
31
31
  dividerSelectable?: boolean
32
+ /** Keeps explicit divider groups in the order given in `items` instead of sorting them by label. */
33
+ keepDividerOrder?: boolean
32
34
  /** Field name used to auto-insert divider groups from raw items (for example region). */
33
35
  autoDividerBy?: string
34
36
  /** Field name containing hierarchy level number (defaults to `level`). */
@@ -190,7 +190,7 @@ export const useSearchSelectProItems = ({
190
190
  if (!groupField) {
191
191
  const dividerField = props.dividerField ?? 'isDivider'
192
192
  const hasExplicitDividers = baseItems.some((item) => item[dividerField] === true || item.type === 'divider')
193
- if (!hasExplicitDividers) return baseItems
193
+ if (!hasExplicitDividers || props.keepDividerOrder) return baseItems
194
194
 
195
195
  const locale = resolvedLocale.value
196
196
  return reorderExplicitDividerGroups(baseItems, locale)