@oslokommune/punkt-react 19.16.2 → 19.17.1
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 +14 -0
- package/dist/components/consent/Consent.js +2 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/inputwrapper/InputWrapper.d.ts +2 -25
- package/dist/components/inputwrapper/InputWrapper.js +84 -83
- package/dist/punkt-react.cjs +1 -1
- package/dist/shared-types/index.d.ts +2 -0
- package/dist/shared-types/input-wrapper.d.ts +59 -0
- package/dist/shared-types/input-wrapper.js +17 -0
- package/package.json +2 -2
- package/src/components/consent/Consent.tsx +2 -2
- package/src/components/index.ts +1 -0
- package/src/components/inputwrapper/InputWrapper.tsx +17 -35
|
@@ -38,6 +38,8 @@ export type { TBreadcrumbsNavigationType, IBreadcrumb, IBreadcrumbItem, IBreadcr
|
|
|
38
38
|
export type { IRenderLink, TRenderLink } from './render-link';
|
|
39
39
|
export type { IPktStringsProps } from '../shared-strings';
|
|
40
40
|
export type { IHelptextProps, ITagOptionalRequiredProps, IFormFieldLabelProps, IFormFieldErrorProps, IFormFieldCommonProps, TFormFieldCommonSpecKeys, } from './form-field';
|
|
41
|
+
export { COUNTER_POSITIONS, INPUT_WRAPPER_DEFAULTS } from './input-wrapper';
|
|
42
|
+
export type { TPktCounterPosition, IPktInputWrapperBase, IInputWrapperSpecProps, } from './input-wrapper';
|
|
41
43
|
export type { TTagSkin } from './skin';
|
|
42
44
|
export { MESSAGEBOX_SKINS, MESSAGEBOX_DEFAULTS } from './messagebox';
|
|
43
45
|
export type { TMessageboxSkin, IPktMessageboxBase, IMessageboxSpecProps } from './messagebox';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* input-wrapper.ts
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for pkt-input-wrapper.
|
|
5
|
+
* Used by React, Elements, and typed component specs.
|
|
6
|
+
*/
|
|
7
|
+
import type { IFormFieldCommonProps } from './form-field';
|
|
8
|
+
import type { TLayout } from './layout';
|
|
9
|
+
import type { TPktInputSize } from './size';
|
|
10
|
+
/**
|
|
11
|
+
* Counter placement relative to the wrapped field — shared runtime source for types, specs, and Preview.
|
|
12
|
+
*/
|
|
13
|
+
export declare const COUNTER_POSITIONS: readonly ['top', 'bottom'];
|
|
14
|
+
export type TPktCounterPosition = (typeof COUNTER_POSITIONS)[number];
|
|
15
|
+
/**
|
|
16
|
+
* Input wrapper props shared by React, Elements, and typed component specs.
|
|
17
|
+
*
|
|
18
|
+
* @remarks React requires `forId` and `label`, and widens `helptext`, `helptextDropdown` and
|
|
19
|
+
* `errorMessage` to `ReactNode`. Elements widens `helptext`, `helptextDropdown`,
|
|
20
|
+
* `helptextDropdownButton` and `role` to `| null` (Lit uses `null` for an unset attribute),
|
|
21
|
+
* and `useWrapper` to `Booleanish`.
|
|
22
|
+
*/
|
|
23
|
+
export interface IPktInputWrapperBase extends IFormFieldCommonProps<'forms' | 'validation'> {
|
|
24
|
+
forId?: string;
|
|
25
|
+
ariaDescribedby?: string;
|
|
26
|
+
counter?: boolean;
|
|
27
|
+
counterCurrent?: number;
|
|
28
|
+
counterMaxLength?: number;
|
|
29
|
+
counterPosition?: TPktCounterPosition;
|
|
30
|
+
inline?: boolean;
|
|
31
|
+
hasFieldset?: boolean;
|
|
32
|
+
layout?: TLayout;
|
|
33
|
+
useWrapper?: boolean;
|
|
34
|
+
role?: string;
|
|
35
|
+
size?: TPktInputSize;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Documented InputWrapper props (subset of `IPktInputWrapperBase`).
|
|
39
|
+
* Used for typed component specs in documentation.
|
|
40
|
+
*/
|
|
41
|
+
export type IInputWrapperSpecProps = Pick<IPktInputWrapperBase, 'forId' | 'label' | 'helptext' | 'helptextDropdown' | 'helptextDropdownButton' | 'ariaDescribedby' | 'counter' | 'counterCurrent' | 'counterMaxLength' | 'counterPosition' | 'optionalTag' | 'optionalText' | 'requiredTag' | 'requiredText' | 'tagText' | 'hasError' | 'errorMessage' | 'disabled' | 'inline' | 'hasFieldset' | 'layout' | 'useWrapper' | 'role' | 'size'>;
|
|
42
|
+
/**
|
|
43
|
+
* Default values for pkt-input-wrapper. Single source of truth for both frameworks.
|
|
44
|
+
* `forId` is intentionally absent — each instance generates its own id when unset.
|
|
45
|
+
*/
|
|
46
|
+
export declare const INPUT_WRAPPER_DEFAULTS: {
|
|
47
|
+
readonly counter: false;
|
|
48
|
+
readonly counterCurrent: 0;
|
|
49
|
+
readonly counterPosition: 'bottom';
|
|
50
|
+
readonly optionalTag: false;
|
|
51
|
+
readonly requiredTag: false;
|
|
52
|
+
readonly hasError: false;
|
|
53
|
+
readonly disabled: false;
|
|
54
|
+
readonly inline: false;
|
|
55
|
+
readonly hasFieldset: false;
|
|
56
|
+
readonly layout: 'vertical';
|
|
57
|
+
readonly useWrapper: true;
|
|
58
|
+
readonly size: 'medium';
|
|
59
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region ../../shared-types/input-wrapper.ts
|
|
2
|
+
var e = {
|
|
3
|
+
counter: !1,
|
|
4
|
+
counterCurrent: 0,
|
|
5
|
+
counterPosition: "bottom",
|
|
6
|
+
optionalTag: !1,
|
|
7
|
+
requiredTag: !1,
|
|
8
|
+
hasError: !1,
|
|
9
|
+
disabled: !1,
|
|
10
|
+
inline: !1,
|
|
11
|
+
hasFieldset: !1,
|
|
12
|
+
layout: "vertical",
|
|
13
|
+
useWrapper: !0,
|
|
14
|
+
size: "medium"
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { e as INPUT_WRAPPER_DEFAULTS };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.17.1",
|
|
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": "
|
|
105
|
+
"gitHead": "fd4bf55becbedfdf8ee1de536d4f3e8a3b50c134"
|
|
106
106
|
}
|
|
@@ -42,14 +42,14 @@ const loadConsentScript = (): Promise<void> => {
|
|
|
42
42
|
return
|
|
43
43
|
}
|
|
44
44
|
const script = document.createElement('script')
|
|
45
|
-
script.src = 'https://cdn.web.oslo.kommune.no/cb/cb-
|
|
45
|
+
script.src = 'https://cdn.web.oslo.kommune.no/cb/cb-v2.0.0.js'
|
|
46
46
|
script.id = 'oslo-consent-script'
|
|
47
47
|
script.onload = () => resolve()
|
|
48
48
|
script.onerror = reject
|
|
49
49
|
document.head.appendChild(script)
|
|
50
50
|
|
|
51
51
|
const styles = document.createElement('link')
|
|
52
|
-
styles.href = 'https://cdn.web.oslo.kommune.no/cb/cb-
|
|
52
|
+
styles.href = 'https://cdn.web.oslo.kommune.no/cb/cb-v2.0.0.css'
|
|
53
53
|
styles.type = 'text/css'
|
|
54
54
|
styles.rel = 'stylesheet'
|
|
55
55
|
styles.id = 'oslo-consent-styles'
|
package/src/components/index.ts
CHANGED
|
@@ -26,6 +26,7 @@ export { PktHelptext } from './helptext/Helptext'
|
|
|
26
26
|
export { PktIcon } from './icon/Icon'
|
|
27
27
|
export { PktInput } from './input/Input'
|
|
28
28
|
export { PktInputWrapper } from './inputwrapper/InputWrapper'
|
|
29
|
+
export type { IPktInputWrapper } from './inputwrapper/InputWrapper'
|
|
29
30
|
export { PktLink } from './link/Link'
|
|
30
31
|
export { PktLinkCard } from './linkcard/LinkCard'
|
|
31
32
|
export { PktLoader } from './loader/Loader'
|
|
@@ -5,43 +5,25 @@ import { type FocusEventHandler, ForwardedRef, forwardRef, type ReactNode, RefAt
|
|
|
5
5
|
import { useFocusModality } from '../../hooks/useFocusModality'
|
|
6
6
|
import { useGeneratedId } from '../../hooks/useGeneratedId'
|
|
7
7
|
import { usePktStrings } from '../../hooks/usePktStrings'
|
|
8
|
-
import { formatString
|
|
8
|
+
import { formatString } from 'shared-strings'
|
|
9
9
|
import { counterStatusId, isCounterExceeded } from 'shared-utils/forms/described-by'
|
|
10
|
+
import { uuidish } from 'shared-utils/utils'
|
|
11
|
+
import { INPUT_WRAPPER_DEFAULTS, type IPktInputWrapperBase } from 'shared-types'
|
|
10
12
|
import type { TLayout } from 'shared-types'
|
|
13
|
+
|
|
11
14
|
import { PktAlert } from '../alert/Alert'
|
|
12
15
|
import { PktHelptext } from '../helptext/Helptext'
|
|
13
16
|
|
|
14
|
-
export interface IPktInputWrapper
|
|
17
|
+
export interface IPktInputWrapper
|
|
18
|
+
extends Omit<IPktInputWrapperBase, 'helptext' | 'helptextDropdown' | 'errorMessage'>, RefAttributes<HTMLElement> {
|
|
15
19
|
id?: string
|
|
16
20
|
forId: string
|
|
17
21
|
label: string
|
|
18
22
|
helptext?: string | ReactNode
|
|
19
23
|
helptextDropdown?: string | ReactNode
|
|
20
|
-
/** @deprecated Bruk `strings={{ forms: { readMore: '…' } }}` eller `setPktStrings()`. */
|
|
21
|
-
helptextDropdownButton?: string
|
|
22
|
-
counter?: boolean
|
|
23
|
-
counterCurrent?: number
|
|
24
|
-
counterMaxLength?: number
|
|
25
|
-
optionalTag?: boolean
|
|
26
|
-
/** @deprecated Bruk `strings={{ forms: { optional: '…' } }}` eller `setPktStrings()`. */
|
|
27
|
-
optionalText?: string
|
|
28
|
-
requiredTag?: boolean
|
|
29
|
-
/** @deprecated Bruk `strings={{ forms: { required: '…' } }}` eller `setPktStrings()`. */
|
|
30
|
-
requiredText?: string
|
|
31
|
-
tagText?: string | null
|
|
32
|
-
hasError?: boolean
|
|
33
24
|
errorMessage?: string | ReactNode
|
|
34
|
-
disabled?: boolean
|
|
35
|
-
inline?: boolean
|
|
36
|
-
ariaDescribedby?: string
|
|
37
|
-
useWrapper?: boolean
|
|
38
25
|
children?: ReactNode
|
|
39
26
|
className?: string
|
|
40
|
-
hasFieldset?: boolean
|
|
41
|
-
layout?: TLayout
|
|
42
|
-
role?: string
|
|
43
|
-
counterPosition?: 'top' | 'bottom'
|
|
44
|
-
size?: 'small' | 'medium' | 'xsmall'
|
|
45
27
|
onFocus?: FocusEventHandler<HTMLDivElement>
|
|
46
28
|
onBlur?: FocusEventHandler<HTMLDivElement>
|
|
47
29
|
}
|
|
@@ -56,26 +38,26 @@ export const PktInputWrapper = forwardRef(
|
|
|
56
38
|
helptextDropdown,
|
|
57
39
|
helptextDropdownButton,
|
|
58
40
|
counter,
|
|
59
|
-
counterCurrent =
|
|
41
|
+
counterCurrent = INPUT_WRAPPER_DEFAULTS.counterCurrent,
|
|
60
42
|
counterMaxLength,
|
|
61
|
-
optionalTag =
|
|
43
|
+
optionalTag = INPUT_WRAPPER_DEFAULTS.optionalTag,
|
|
62
44
|
optionalText,
|
|
63
|
-
requiredTag =
|
|
45
|
+
requiredTag = INPUT_WRAPPER_DEFAULTS.requiredTag,
|
|
64
46
|
requiredText,
|
|
65
47
|
tagText = null,
|
|
66
|
-
hasError =
|
|
48
|
+
hasError = INPUT_WRAPPER_DEFAULTS.hasError,
|
|
67
49
|
errorMessage,
|
|
68
|
-
disabled =
|
|
69
|
-
inline =
|
|
50
|
+
disabled = INPUT_WRAPPER_DEFAULTS.disabled,
|
|
51
|
+
inline = INPUT_WRAPPER_DEFAULTS.inline,
|
|
70
52
|
ariaDescribedby,
|
|
71
|
-
useWrapper =
|
|
53
|
+
useWrapper = INPUT_WRAPPER_DEFAULTS.useWrapper,
|
|
72
54
|
children,
|
|
73
55
|
className = '',
|
|
74
|
-
hasFieldset =
|
|
75
|
-
layout =
|
|
56
|
+
hasFieldset = INPUT_WRAPPER_DEFAULTS.hasFieldset,
|
|
57
|
+
layout = INPUT_WRAPPER_DEFAULTS.layout,
|
|
76
58
|
role,
|
|
77
|
-
counterPosition =
|
|
78
|
-
size =
|
|
59
|
+
counterPosition = INPUT_WRAPPER_DEFAULTS.counterPosition,
|
|
60
|
+
size = INPUT_WRAPPER_DEFAULTS.size,
|
|
79
61
|
strings,
|
|
80
62
|
onFocus,
|
|
81
63
|
onBlur,
|