@oslokommune/punkt-react 19.10.2 → 19.12.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/CHANGELOG.md +18 -0
- package/dist/punkt-react.cjs +1 -1
- package/dist/punkt-react.js +261 -257
- package/dist/shared-types/accordion.d.ts +3 -1
- package/dist/shared-types/index.d.ts +1 -1
- package/dist/shared-utils/scroll-lock/index.d.ts +3 -1
- package/package.json +3 -3
- package/src/components/accordion/Accordion.test.tsx +37 -3
- package/src/components/accordion/AccordionItem.tsx +2 -1
- package/src/components/combobox/Combobox.selection.test.tsx +12 -0
- package/src/components/combobox/ComboboxTags.tsx +3 -3
- package/src/components/consent/Consent.tsx +3 -1
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
* bruk `IAccordionVisualProps` for delte visuelle props (`skin`, `compact`).
|
|
10
10
|
*/
|
|
11
11
|
/** Accordion skin varianter — delt runtime source for types, specs, og Preview. */
|
|
12
|
-
export declare const ACCORDION_SKINS: readonly ['borderless', 'outlined', 'beige', 'blue', 'plus-minus'];
|
|
12
|
+
export declare const ACCORDION_SKINS: readonly ['borderless', 'outlined', 'gray', 'beige', 'blue', 'plus-minus'];
|
|
13
13
|
export type TAccordionSkin = (typeof ACCORDION_SKINS)[number];
|
|
14
|
+
/** Skins uten mørk variant. Radene får `data-mode="light"` og beholder lys modus. */
|
|
15
|
+
export declare const ACCORDION_LIGHT_ONLY_SKINS: readonly TAccordionSkin[];
|
|
14
16
|
/** Visual props delt med pkt-accordion og pkt-accordion-item. */
|
|
15
17
|
export type IAccordionVisualProps = {
|
|
16
18
|
skin?: TAccordionSkin;
|
|
@@ -26,7 +26,7 @@ export type { TLayout, TVerticalPosition, THorizontalPosition, TPosition, TPosit
|
|
|
26
26
|
export type { THTMLButtonType, TSelectionMode } from './form';
|
|
27
27
|
export { INPUT_SIZES } from './size';
|
|
28
28
|
export type { TPktInputSize, TSize3, TSize5, TSize7 } from './size';
|
|
29
|
-
export { ACCORDION_SKINS } from './accordion';
|
|
29
|
+
export { ACCORDION_LIGHT_ONLY_SKINS, ACCORDION_SKINS } from './accordion';
|
|
30
30
|
export type { TAccordionSkin, IPktAccordionBase, IPktAccordionItemBase, IAccordionSpecProps, IAccordionItemSpecProps, IAccordionVisualProps, } from './accordion';
|
|
31
31
|
export { BUTTON_SIZES, BUTTON_SKINS, BUTTON_COLORS, BUTTON_VARIANTS, BUTTON_STATES } from './button';
|
|
32
32
|
export type { TPktButtonSize, TPktButtonSkin, TPktButtonColor, TPktButtonVariant, TPktButtonState, IPktButtonBase, IButtonSpecProps, } from './button';
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* Strategy: an iOS-safe `position: fixed` lock — `overflow: hidden` alone is
|
|
6
6
|
* ignored by iOS Safari. The current scroll position is saved, the body is
|
|
7
7
|
* pinned, scrollbar width is reserved to avoid a layout shift, and the scroll
|
|
8
|
-
* position is restored on release.
|
|
8
|
+
* position is restored on release. The restore is always instant, so a page
|
|
9
|
+
* with `scroll-behavior: smooth` does not animate from the top back to where
|
|
10
|
+
* it was when the overlay closes.
|
|
9
11
|
*
|
|
10
12
|
* Reference-counted so several open overlays don't unlock the page when one of
|
|
11
13
|
* them closes. Each caller holds a token (see {@link createScrollLockToken}) so
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.12.0",
|
|
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",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@eslint/eslintrc": "^3.3.5",
|
|
42
42
|
"@eslint/js": "^10.0.1",
|
|
43
43
|
"@oslokommune/punkt-assets": "^19.0.4",
|
|
44
|
-
"@oslokommune/punkt-css": "^19.
|
|
44
|
+
"@oslokommune/punkt-css": "^19.12.0",
|
|
45
45
|
"@testing-library/jest-dom": "^6.9.1",
|
|
46
46
|
"@testing-library/react": "^16.3.2",
|
|
47
47
|
"@testing-library/user-event": "^14.6.1",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
102
102
|
},
|
|
103
103
|
"license": "MIT",
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "fff01ab9619d3c18548f18f239eccc7f841e1160"
|
|
105
105
|
}
|
|
@@ -127,6 +127,42 @@ describe('PktAccordion', () => {
|
|
|
127
127
|
expect(container.querySelector('[name="chevron-thin-down"]')).toBeInTheDocument()
|
|
128
128
|
expect(container.querySelector('.pkt-accordion-item__icon--plus')).not.toBeInTheDocument()
|
|
129
129
|
})
|
|
130
|
+
|
|
131
|
+
test.each(['beige', 'blue'] as const)('sets data-mode="light" on %s rows', (skin) => {
|
|
132
|
+
const { container } = render(
|
|
133
|
+
<PktAccordion skin={skin}>
|
|
134
|
+
<PktAccordionItem title="Title" id="item1">
|
|
135
|
+
Content
|
|
136
|
+
</PktAccordionItem>
|
|
137
|
+
</PktAccordion>,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
expect(container.querySelector('details')).toHaveAttribute('data-mode', 'light')
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
test.each(['borderless', 'outlined', 'gray', 'plus-minus'] as const)('does not set data-mode on %s rows', (skin) => {
|
|
144
|
+
const { container } = render(
|
|
145
|
+
<PktAccordion skin={skin}>
|
|
146
|
+
<PktAccordionItem title="Title" id="item1">
|
|
147
|
+
Content
|
|
148
|
+
</PktAccordionItem>
|
|
149
|
+
</PktAccordion>,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
expect(container.querySelector('details')).not.toHaveAttribute('data-mode')
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
test('item skin decides data-mode over accordion skin', () => {
|
|
156
|
+
const { container } = render(
|
|
157
|
+
<PktAccordion skin="beige">
|
|
158
|
+
<PktAccordionItem title="Title" id="item1" skin="gray">
|
|
159
|
+
Content
|
|
160
|
+
</PktAccordionItem>
|
|
161
|
+
</PktAccordion>,
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
expect(container.querySelector('details')).not.toHaveAttribute('data-mode')
|
|
165
|
+
})
|
|
130
166
|
})
|
|
131
167
|
|
|
132
168
|
describe('PktAccordionItem', () => {
|
|
@@ -236,9 +272,7 @@ describe('PktAccordionItem', () => {
|
|
|
236
272
|
expect(icon).toBeInTheDocument()
|
|
237
273
|
expect(icon).toHaveAttribute('name', 'chevron-thin-down')
|
|
238
274
|
expect(icon).toHaveClass('pkt-accordion-item__icon')
|
|
239
|
-
await waitFor(() =>
|
|
240
|
-
expect(icon?.querySelector('svg')).toHaveAttribute('aria-hidden', 'true'),
|
|
241
|
-
)
|
|
275
|
+
await waitFor(() => expect(icon?.querySelector('svg')).toHaveAttribute('aria-hidden', 'true'))
|
|
242
276
|
})
|
|
243
277
|
})
|
|
244
278
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import { forwardRef, type MouseEvent, type ReactNode, type SyntheticEvent, useState } from 'react'
|
|
4
|
-
import type
|
|
4
|
+
import { ACCORDION_LIGHT_ONLY_SKINS, type IPktAccordionItemBase, type TAccordionSkin } from 'shared-types'
|
|
5
5
|
|
|
6
6
|
import { PktIcon } from '../icon/Icon'
|
|
7
7
|
import { useAccordionContext } from './Accordion'
|
|
@@ -84,6 +84,7 @@ export const PktAccordionItem = forwardRef<HTMLDetailsElement, IPktAccordionItem
|
|
|
84
84
|
onClick={handleClick}
|
|
85
85
|
name={actualName}
|
|
86
86
|
onToggle={handleToggle}
|
|
87
|
+
data-mode={actualSkin && ACCORDION_LIGHT_ONLY_SKINS.includes(actualSkin) ? 'light' : undefined}
|
|
87
88
|
>
|
|
88
89
|
<summary className="pkt-accordion-item__title" id={`pkt-accordion-item-summary-${id}`}>
|
|
89
90
|
{title}
|
|
@@ -260,6 +260,18 @@ describe('PktCombobox', () => {
|
|
|
260
260
|
expect(tag).toBeInTheDocument()
|
|
261
261
|
})
|
|
262
262
|
|
|
263
|
+
test('uses the blue tag skin when the option has no tagSkinColor', () => {
|
|
264
|
+
const { container } = createComboboxTest({
|
|
265
|
+
multiple: true,
|
|
266
|
+
defaultValue: ['apple'],
|
|
267
|
+
options: getDefaultOptions(),
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
const tag = container.querySelector('.pkt-tag')
|
|
271
|
+
expect(tag).toHaveClass('pkt-tag--blue')
|
|
272
|
+
expect(tag).not.toHaveClass('pkt-tag--blue-dark')
|
|
273
|
+
})
|
|
274
|
+
|
|
263
275
|
test('renders checkboxes for multi-select options', () => {
|
|
264
276
|
const { container } = createComboboxTest({
|
|
265
277
|
multiple: true,
|
|
@@ -30,7 +30,7 @@ export const ComboboxTags = ({ state, outside = false }: IComboboxTagsProps) =>
|
|
|
30
30
|
if (disabled) {
|
|
31
31
|
return (
|
|
32
32
|
<li key={val} role="listitem">
|
|
33
|
-
<PktTag skin={tagSkinColor || 'blue
|
|
33
|
+
<PktTag skin={tagSkinColor || 'blue'}>
|
|
34
34
|
<span className="pkt-combobox__value">{displayText}</span>
|
|
35
35
|
</PktTag>
|
|
36
36
|
</li>
|
|
@@ -41,7 +41,7 @@ export const ComboboxTags = ({ state, outside = false }: IComboboxTagsProps) =>
|
|
|
41
41
|
if (outside) {
|
|
42
42
|
return (
|
|
43
43
|
<li key={val} role="listitem">
|
|
44
|
-
<PktTag skin={tagSkinColor || 'blue
|
|
44
|
+
<PktTag skin={tagSkinColor || 'blue'} closeTag onClose={() => handleTagRemove(val)}>
|
|
45
45
|
<span className="pkt-combobox__value">{displayText}</span>
|
|
46
46
|
</PktTag>
|
|
47
47
|
</li>
|
|
@@ -60,7 +60,7 @@ export const ComboboxTags = ({ state, outside = false }: IComboboxTagsProps) =>
|
|
|
60
60
|
ref={(el: HTMLButtonElement | null) => {
|
|
61
61
|
tagElementsRef.current[index] = el
|
|
62
62
|
}}
|
|
63
|
-
skin={tagSkinColor || 'blue
|
|
63
|
+
skin={tagSkinColor || 'blue'}
|
|
64
64
|
closeTag
|
|
65
65
|
tabIndex={focusedTagIndex === index ? 0 : -1}
|
|
66
66
|
onClose={() => handleTagRemove(val)}
|
|
@@ -118,7 +118,9 @@ export const PktConsent = forwardRef<HTMLElement, IPktConsent>(function PktConse
|
|
|
118
118
|
|
|
119
119
|
const triggerInitRef = useRef<() => void>(() => {})
|
|
120
120
|
|
|
121
|
-
const language = (
|
|
121
|
+
const language = (
|
|
122
|
+
Object.prototype.hasOwnProperty.call(consentStrings.i18n, i18nLanguage) ? i18nLanguage : 'nb'
|
|
123
|
+
) as keyof typeof consentStrings.i18n
|
|
122
124
|
const resolvedTriggerText = triggerText ?? consentStrings.i18n[language].contentPresentation.buttons.settings
|
|
123
125
|
|
|
124
126
|
useEffect(() => {
|