@oslokommune/punkt-react 20.1.3 → 20.1.4

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": "@oslokommune/punkt-react",
3
- "version": "20.1.3",
3
+ "version": "20.1.4",
4
4
  "description": "React komponentbibliotek til Punkt, designsystem for Oslo kommune",
5
5
  "homepage": "https://punkt.oslo.kommune.no",
6
6
  "author": "Team Designsystem, Oslo kommune",
@@ -102,5 +102,5 @@
102
102
  "url": "https://github.com/oslokommune/punkt/issues"
103
103
  },
104
104
  "license": "MIT",
105
- "gitHead": "0c893c54ea9c8fb6f5f3ff07d753586292f98039"
105
+ "gitHead": "3f146720edddb4d65cc1904790938c0858e9072a"
106
106
  }
@@ -176,6 +176,19 @@ describe('PktCombobox', () => {
176
176
  const disabledOption = container.querySelector('[data-value="cherry"]')
177
177
  expect(disabledOption?.getAttribute('data-disabled')).toBe('true')
178
178
  })
179
+
180
+ test('shows empty list banner when there are no options', () => {
181
+ const { container } = createComboboxTest()
182
+
183
+ const banner = container.querySelector('.pkt-listbox__banner--empty')
184
+ expect(banner).toHaveTextContent('Tom liste')
185
+ })
186
+
187
+ test('hides empty list banner when listbox.empty is an empty string', () => {
188
+ const { container } = createComboboxTest({ strings: { listbox: { empty: '' } } })
189
+
190
+ expect(container.querySelector('.pkt-listbox__banner--empty')).not.toBeInTheDocument()
191
+ })
179
192
  })
180
193
 
181
194
  describe('Value handling', () => {
@@ -41,6 +41,7 @@ export const Listbox = ({ state }: IListboxProps) => {
41
41
  const showMaxBanner = multiple && selectedCount > 0 && maxlength != null && maxlength > 0
42
42
  const showNewOptionBanner = allowUserInput && addValueText && !maxIsReached
43
43
  const showUserMessage = !!userInfoMessage
44
+ const showEmptyBanner = !!s.listbox.empty && options.length === 0 && filteredOptions.length === 0 && !showUserMessage
44
45
 
45
46
  const listboxClasses = ['pkt-listbox', isOpen && 'pkt-listbox__open', 'pkt-txt-16-light'].filter(Boolean).join(' ')
46
47
 
@@ -104,7 +105,7 @@ export const Listbox = ({ state }: IListboxProps) => {
104
105
  </div>
105
106
  )}
106
107
 
107
- {options.length === 0 && filteredOptions.length === 0 && !showUserMessage && (
108
+ {showEmptyBanner && (
108
109
  <div className="pkt-listbox__banner pkt-listbox__banner--empty">
109
110
  <PktIcon className="pkt-listbox__banner-icon" name="exclamation-mark-circle" />
110
111
  {s.listbox.empty}