@oslokommune/punkt-react 16.6.1 → 16.7.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": "@oslokommune/punkt-react",
3
- "version": "16.6.1",
3
+ "version": "16.7.0",
4
4
  "description": "React komponentbibliotek til Punkt, et designsystem laget av Oslo Origo",
5
5
  "homepage": "https://punkt.oslo.kommune.no",
6
6
  "author": "Team Designsystem, Oslo Origo",
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@lit-labs/ssr-dom-shim": "^1.2.1",
41
41
  "@lit/react": "^1.0.7",
42
- "@oslokommune/punkt-elements": "^16.6.1",
42
+ "@oslokommune/punkt-elements": "^16.7.0",
43
43
  "classnames": "^2.5.1",
44
44
  "prettier": "^3.3.3",
45
45
  "react-hook-form": "^7.53.0"
@@ -50,7 +50,7 @@
50
50
  "@eslint/eslintrc": "^3.3.3",
51
51
  "@eslint/js": "^9.37.0",
52
52
  "@oslokommune/punkt-assets": "^16.0.0",
53
- "@oslokommune/punkt-css": "^16.5.1",
53
+ "@oslokommune/punkt-css": "^16.7.0",
54
54
  "@testing-library/jest-dom": "^6.5.0",
55
55
  "@testing-library/react": "^16.0.1",
56
56
  "@testing-library/user-event": "^14.5.2",
@@ -109,5 +109,5 @@
109
109
  "url": "https://github.com/oslokommune/punkt/issues"
110
110
  },
111
111
  "license": "MIT",
112
- "gitHead": "a56b9180a633f3fa8b16e9b37c56ffc8255f9b4e"
112
+ "gitHead": "782a591e43ea062ca4ef23fe5415aca5f2d523b5"
113
113
  }
@@ -363,172 +363,179 @@ export const PktHeaderService = forwardRef(
363
363
  )}
364
364
  </div>
365
365
 
366
- <div className="pkt-header-service__content">
367
- <div
368
- className={classNames('pkt-header-service__slot-container', openMenu === 'slot' && 'is-open')}
369
- onBlur={(e) => handleFocusOut(e, 'slot')}
370
- ref={slotContainerRef}
371
- >
372
- {isTablet && children && (
373
- <PktButton
374
- skin="secondary"
375
- variant={slotMenuVariant}
376
- iconName="menu"
377
- size={isMobile ? 'small' : 'medium'}
378
- state={openMenu === 'slot' ? 'active' : 'normal'}
379
- onClick={() => handleMenuToggle('slot')}
380
- aria-expanded={openMenu === 'slot'}
381
- aria-controls="mobile-slot-menu"
382
- aria-label="Åpne meny"
383
- >
384
- {slotMenuText}
385
- </PktButton>
386
- )}
366
+ {!!children ||
367
+ showSearch ||
368
+ (isTablet && logOut && (logOutButtonPlacement === 'header' || logOutButtonPlacement === 'both')) ? (
369
+ <div className="pkt-header-service__content">
387
370
  <div
388
- className={classNames('pkt-header-service__slot-content', alignSlotRight && 'align-right')}
389
- id="mobile-slot-menu"
390
- role={isTablet ? 'menu' : undefined}
391
- aria-label={isTablet ? 'Meny' : undefined}
392
- ref={slotContentRef}
371
+ className={classNames('pkt-header-service__slot-container', openMenu === 'slot' && 'is-open')}
372
+ onBlur={(e) => handleFocusOut(e, 'slot')}
373
+ ref={slotContainerRef}
393
374
  >
394
- <div className="pkt-contents">{children}</div>
375
+ {isTablet && children && (
376
+ <PktButton
377
+ skin="secondary"
378
+ variant={slotMenuVariant}
379
+ iconName="menu"
380
+ size={isMobile ? 'small' : 'medium'}
381
+ state={openMenu === 'slot' ? 'active' : 'normal'}
382
+ onClick={() => handleMenuToggle('slot')}
383
+ aria-expanded={openMenu === 'slot'}
384
+ aria-controls="mobile-slot-menu"
385
+ aria-label="Åpne meny"
386
+ >
387
+ {slotMenuText}
388
+ </PktButton>
389
+ )}
390
+ <div
391
+ className={classNames('pkt-header-service__slot-content', alignSlotRight && 'align-right')}
392
+ id="mobile-slot-menu"
393
+ role={isTablet ? 'menu' : undefined}
394
+ aria-label={isTablet ? 'Meny' : undefined}
395
+ ref={slotContentRef}
396
+ >
397
+ <div className="pkt-contents">{children}</div>
398
+ </div>
395
399
  </div>
396
- </div>
397
400
 
398
- {showSearch && (
399
- <>
400
- {isTablet ? (
401
- <div
402
- className={classNames('pkt-header-service__search-container', openMenu === 'search' && 'is-open')}
403
- onBlur={(e) => handleFocusOut(e, 'search')}
404
- ref={searchContainerRef}
405
- >
406
- <PktButton
407
- skin="secondary"
408
- variant="icon-only"
409
- iconName="magnifying-glass-big"
410
- size={isMobile ? 'small' : 'medium'}
411
- onClick={() => handleMenuToggle('search')}
412
- state={openMenu === 'search' ? 'active' : 'normal'}
413
- aria-expanded={openMenu === 'search'}
414
- aria-controls="mobile-search-menu"
415
- aria-label="Åpne søkefelt"
416
- >
417
- Søk
418
- </PktButton>
401
+ {showSearch && (
402
+ <>
403
+ {isTablet ? (
419
404
  <div
420
- className={classNames(
421
- 'pkt-header-service__mobile-menu',
422
- openMenu === 'search' && 'is-open',
423
- alignSearchRight && 'align-right',
424
- )}
425
- ref={searchMenuRef}
405
+ className={classNames('pkt-header-service__search-container', openMenu === 'search' && 'is-open')}
406
+ onBlur={(e) => handleFocusOut(e, 'search')}
407
+ ref={searchContainerRef}
426
408
  >
427
- {openMenu === 'search' && (
428
- <PktTextinput
429
- id="mobile-search-menu"
430
- className="pkt-header-service__search-input"
431
- type="search"
432
- label="Søk"
433
- useWrapper={false}
434
- placeholder={searchPlaceholder}
435
- value={searchValue}
436
- autoFocus
437
- fullwidth={true}
438
- onChange={(e: ChangeEvent<HTMLInputElement>) => onSearchChange?.(e.target.value)}
439
- onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {
440
- if (e.key === 'Enter') {
441
- onSearch?.((e.target as HTMLInputElement).value)
442
- }
443
- }}
444
- />
445
- )}
409
+ <PktButton
410
+ skin="secondary"
411
+ variant="icon-only"
412
+ iconName="magnifying-glass-big"
413
+ size={isMobile ? 'small' : 'medium'}
414
+ onClick={() => handleMenuToggle('search')}
415
+ state={openMenu === 'search' ? 'active' : 'normal'}
416
+ aria-expanded={openMenu === 'search'}
417
+ aria-controls="mobile-search-menu"
418
+ aria-label="Åpne søkefelt"
419
+ >
420
+ Søk
421
+ </PktButton>
422
+ <div
423
+ className={classNames(
424
+ 'pkt-header-service__mobile-menu',
425
+ openMenu === 'search' && 'is-open',
426
+ alignSearchRight && 'align-right',
427
+ )}
428
+ ref={searchMenuRef}
429
+ >
430
+ {openMenu === 'search' && (
431
+ <PktTextinput
432
+ id="mobile-search-menu"
433
+ className="pkt-header-service__search-input"
434
+ type="search"
435
+ label="Søk"
436
+ useWrapper={false}
437
+ placeholder={searchPlaceholder}
438
+ value={searchValue}
439
+ autoFocus
440
+ fullwidth={true}
441
+ onChange={(e: ChangeEvent<HTMLInputElement>) => onSearchChange?.(e.target.value)}
442
+ onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {
443
+ if (e.key === 'Enter') {
444
+ onSearch?.((e.target as HTMLInputElement).value)
445
+ }
446
+ }}
447
+ />
448
+ )}
449
+ </div>
446
450
  </div>
447
- </div>
448
- ) : (
449
- <PktTextinput
450
- id="header-service-search"
451
- className="pkt-header-service__search-input"
452
- type="search"
453
- label="Søk"
454
- useWrapper={false}
455
- placeholder={searchPlaceholder}
456
- value={searchValue}
457
- onChange={(e: ChangeEvent<HTMLInputElement>) => onSearchChange?.(e.target.value)}
458
- onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {
459
- if (e.key === 'Enter') {
460
- onSearch?.((e.target as HTMLInputElement).value)
461
- }
462
- }}
463
- />
464
- )}
465
- </>
466
- )}
467
-
468
- {isTablet && logOut && (logOutButtonPlacement === 'header' || logOutButtonPlacement === 'both') && (
469
- <PktButton
470
- skin="secondary"
471
- size={isMobile ? 'small' : 'medium'}
472
- variant="icon-only"
473
- iconName="exit"
474
- onClick={logOut}
475
- >
476
- Logg ut
477
- </PktButton>
478
- )}
479
- </div>
451
+ ) : (
452
+ <PktTextinput
453
+ id="header-service-search"
454
+ className="pkt-header-service__search-input"
455
+ type="search"
456
+ label="Søk"
457
+ useWrapper={false}
458
+ placeholder={searchPlaceholder}
459
+ value={searchValue}
460
+ onChange={(e: ChangeEvent<HTMLInputElement>) => onSearchChange?.(e.target.value)}
461
+ onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {
462
+ if (e.key === 'Enter') {
463
+ onSearch?.((e.target as HTMLInputElement).value)
464
+ }
465
+ }}
466
+ />
467
+ )}
468
+ </>
469
+ )}
480
470
 
481
- <div className="pkt-header-service__user">
482
- {user && (
483
- <div
484
- className="pkt-header-service__user-container"
485
- onBlur={(e) => handleFocusOut(e, 'user')}
486
- ref={userContainerRef}
487
- >
471
+ {isTablet && logOut && (logOutButtonPlacement === 'header' || logOutButtonPlacement === 'both') && (
488
472
  <PktButton
489
- className={classNames(
490
- 'pkt-header-service__user-button',
491
- isMobile && 'pkt-header-service__user-button--mobile',
492
- )}
493
473
  skin="secondary"
494
474
  size={isMobile ? 'small' : 'medium'}
495
- state={openMenu === 'user' ? 'active' : 'normal'}
496
- variant="icons-right-and-left"
497
- iconName="user"
498
- secondIconName={openMenu === 'user' ? 'chevron-thin-up' : 'chevron-thin-down'}
499
- onClick={() => handleMenuToggle('user')}
475
+ variant="icon-only"
476
+ iconName="exit"
477
+ onClick={logOut}
500
478
  >
501
- <span className="pkt-sr-only">Brukermeny: </span>
502
- {representing?.name || user.name}
479
+ Logg ut
503
480
  </PktButton>
504
- {openMenu === 'user' && user && (
505
- <div
481
+ )}
482
+ </div>
483
+ ) : null}
484
+
485
+ {(user ||
486
+ (!isMobile && logOut && (logOutButtonPlacement === 'header' || logOutButtonPlacement === 'both'))) && (
487
+ <div className="pkt-header-service__user">
488
+ {user && (
489
+ <div
490
+ className="pkt-header-service__user-container"
491
+ onBlur={(e) => handleFocusOut(e, 'user')}
492
+ ref={userContainerRef}
493
+ >
494
+ <PktButton
506
495
  className={classNames(
507
- isMobile ? 'pkt-header-service__mobile-menu' : 'pkt-header-service__user-menu',
508
- 'is-open',
496
+ 'pkt-header-service__user-button',
497
+ isMobile && 'pkt-header-service__user-button--mobile',
509
498
  )}
499
+ skin="secondary"
500
+ size={isMobile ? 'small' : 'medium'}
501
+ state={openMenu === 'user' ? 'active' : 'normal'}
502
+ variant="icons-right-and-left"
503
+ iconName="user"
504
+ secondIconName={openMenu === 'user' ? 'chevron-thin-up' : 'chevron-thin-down'}
505
+ onClick={() => handleMenuToggle('user')}
510
506
  >
511
- <PktHeaderUserMenu
512
- user={user}
513
- formattedLastLoggedIn={formattedLastLoggedIn}
514
- representing={representing}
515
- userMenu={userMenu}
516
- canChangeRepresentation={canChangeRepresentation}
517
- changeRepresentation={changeRepresentation}
518
- logoutOnClick={
519
- logOutButtonPlacement === 'userMenu' || logOutButtonPlacement === 'both' ? logOut : undefined
520
- }
521
- />
522
- </div>
523
- )}
524
- </div>
525
- )}
526
- {!isMobile && logOut && (logOutButtonPlacement === 'header' || logOutButtonPlacement === 'both') && (
527
- <PktButton skin="tertiary" size="medium" variant="icon-right" iconName="exit" onClick={logOut}>
528
- Logg ut
529
- </PktButton>
530
- )}
531
- </div>
507
+ <span className="pkt-sr-only">Brukermeny: </span>
508
+ {representing?.name || user.name}
509
+ </PktButton>
510
+ {openMenu === 'user' && user && (
511
+ <div
512
+ className={classNames(
513
+ isMobile ? 'pkt-header-service__mobile-menu' : 'pkt-header-service__user-menu',
514
+ 'is-open',
515
+ )}
516
+ >
517
+ <PktHeaderUserMenu
518
+ user={user}
519
+ formattedLastLoggedIn={formattedLastLoggedIn}
520
+ representing={representing}
521
+ userMenu={userMenu}
522
+ canChangeRepresentation={canChangeRepresentation}
523
+ changeRepresentation={changeRepresentation}
524
+ logoutOnClick={
525
+ logOutButtonPlacement === 'userMenu' || logOutButtonPlacement === 'both' ? logOut : undefined
526
+ }
527
+ />
528
+ </div>
529
+ )}
530
+ </div>
531
+ )}
532
+ {!isMobile && logOut && (logOutButtonPlacement === 'header' || logOutButtonPlacement === 'both') && (
533
+ <PktButton skin="tertiary" size="medium" variant="icon-right" iconName="exit" onClick={logOut}>
534
+ Logg ut
535
+ </PktButton>
536
+ )}
537
+ </div>
538
+ )}
532
539
  </header>
533
540
  )
534
541
 
@@ -43,5 +43,6 @@ export { PktTabItem } from './tabs/TabItem'
43
43
  export { PktTag } from './tag/Tag'
44
44
  export { PktTextarea } from './textarea/Textarea'
45
45
  export { PktTextinput } from './textinput/Textinput'
46
+ export { PktTimepicker } from './timepicker/Timepicker'
46
47
  export * from './interfaces'
47
48
  export * from './types'
@@ -26,3 +26,4 @@ export type { IPktTab } from './tabs/Tabs'
26
26
  export type { IPktTag } from './tag/Tag'
27
27
  export type { IPktTextarea } from './textarea/Textarea'
28
28
  export type { IPktTextinput } from './textinput/Textinput'
29
+ export type { IPktTimepicker } from './timepicker/types'