@oslokommune/punkt-react 19.6.0 → 19.8.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 +13 -0
- package/dist/components/combobox/types.d.ts +3 -36
- package/dist/components/messagebox/Messagebox.d.ts +2 -5
- package/dist/punkt-react.cjs +1 -1
- package/dist/punkt-react.js +2215 -2196
- package/dist/shared-types/combobox.d.ts +73 -5
- package/dist/shared-types/index.d.ts +6 -2
- package/dist/shared-types/messagebox.d.ts +32 -0
- package/dist/shared-types/size.d.ts +3 -3
- package/dist/shared-types/skin.d.ts +1 -4
- package/package.json +2 -2
- package/src/components/combobox/Combobox.tsx +1 -1
- package/src/components/combobox/ComboboxTags.tsx +1 -2
- package/src/components/combobox/types.ts +12 -44
- package/src/components/combobox/useComboboxState.ts +16 -19
- package/src/components/messagebox/Messagebox.test.tsx +1 -1
- package/src/components/messagebox/Messagebox.tsx +9 -8
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
* combobox.ts
|
|
3
3
|
*
|
|
4
4
|
* Type definitions for the combobox and listbox components.
|
|
5
|
-
* Used by both Elements and React implementations
|
|
6
|
-
*
|
|
5
|
+
* Used by both Elements and React implementations,
|
|
6
|
+
* the shared combobox helper functions, and typed component specs.
|
|
7
7
|
*/
|
|
8
|
+
import type { IFormFieldErrorProps, IFormFieldLabelProps, IHelptextProps, ITagOptionalRequiredProps } from './form-field';
|
|
9
|
+
import type { TPktInputSize } from './size';
|
|
8
10
|
/**
|
|
9
11
|
* Tag skin colors available for combobox option tags.
|
|
10
12
|
* Matches the TTagSkin values from the tag component.
|
|
11
13
|
*/
|
|
12
|
-
export
|
|
14
|
+
export declare const COMBOBOX_TAG_SKINS: readonly ['blue', 'blue-dark', 'blue-light', 'green', 'red', 'yellow', 'beige', 'gray', 'grey'];
|
|
15
|
+
export type TPktComboboxTagSkin = (typeof COMBOBOX_TAG_SKINS)[number];
|
|
13
16
|
/**
|
|
14
17
|
* Represents a single option in a combobox or listbox.
|
|
15
18
|
*/
|
|
@@ -27,8 +30,73 @@ export interface IPktComboboxOption {
|
|
|
27
30
|
/**
|
|
28
31
|
* How the selected value is displayed in the combobox input.
|
|
29
32
|
*/
|
|
30
|
-
export
|
|
33
|
+
export declare const COMBOBOX_DISPLAY_VALUES: readonly ['label', 'value', 'prefixAndValue'];
|
|
34
|
+
export type TPktComboboxDisplayValue = (typeof COMBOBOX_DISPLAY_VALUES)[number];
|
|
31
35
|
/**
|
|
32
36
|
* Placement of selected value tags in multiple selection mode.
|
|
33
37
|
*/
|
|
34
|
-
export
|
|
38
|
+
export declare const COMBOBOX_TAG_PLACEMENTS: readonly ['inside', 'outside'];
|
|
39
|
+
export type TPktComboboxTagPlacement = (typeof COMBOBOX_TAG_PLACEMENTS)[number];
|
|
40
|
+
/**
|
|
41
|
+
* Combobox props shared by React, Elements, and typed component specs.
|
|
42
|
+
*
|
|
43
|
+
* @remarks Both frameworks extend this with `Omit<>` and widen a few props:
|
|
44
|
+
* - React widens `helptext`, `helptextDropdown` and `errorMessage` to `ReactNode`.
|
|
45
|
+
* - Elements widens string/number props to `| null` (Lit uses `null` for an unset attribute,
|
|
46
|
+
* see `PktInputElement`) and `useWrapper` to `Booleanish`. Elements omits `form`, which is
|
|
47
|
+
* a getter returning the associated `HTMLFormElement`, not the form id.
|
|
48
|
+
*
|
|
49
|
+
* `hasFieldset` and `counter` are tri-state: `null` means the component derives the value.
|
|
50
|
+
*/
|
|
51
|
+
export interface IPktComboboxBase extends IFormFieldLabelProps, IHelptextProps, IFormFieldErrorProps, ITagOptionalRequiredProps {
|
|
52
|
+
id?: string;
|
|
53
|
+
name?: string;
|
|
54
|
+
form?: string;
|
|
55
|
+
ariaDescribedby?: string;
|
|
56
|
+
placeholder?: string;
|
|
57
|
+
required?: boolean;
|
|
58
|
+
value?: string | string[];
|
|
59
|
+
defaultValue?: string | string[];
|
|
60
|
+
options?: IPktComboboxOption[];
|
|
61
|
+
defaultOptions?: IPktComboboxOption[];
|
|
62
|
+
multiple?: boolean;
|
|
63
|
+
maxlength?: number;
|
|
64
|
+
typeahead?: boolean;
|
|
65
|
+
includeSearch?: boolean;
|
|
66
|
+
allowUserInput?: boolean;
|
|
67
|
+
searchPlaceholder?: string;
|
|
68
|
+
displayValueAs?: TPktComboboxDisplayValue;
|
|
69
|
+
tagPlacement?: TPktComboboxTagPlacement;
|
|
70
|
+
inputSize?: TPktInputSize;
|
|
71
|
+
fullwidth?: boolean;
|
|
72
|
+
inline?: boolean;
|
|
73
|
+
useWrapper?: boolean;
|
|
74
|
+
hasFieldset?: boolean | null;
|
|
75
|
+
counter?: boolean | null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Documented Combobox props (subset of `IPktComboboxBase`).
|
|
79
|
+
* Used for typed component specs in documentation.
|
|
80
|
+
*/
|
|
81
|
+
export type IComboboxSpecProps = Pick<IPktComboboxBase, 'name' | 'form' | 'ariaDescribedby' | 'id' | 'label' | 'placeholder' | 'multiple' | 'tagPlacement' | 'maxlength' | 'typeahead' | 'includeSearch' | 'allowUserInput' | 'searchPlaceholder' | 'displayValueAs' | 'inputSize' | 'value' | 'helptext' | 'helptextDropdown' | 'helptextDropdownButton' | 'disabled' | 'hasError' | 'errorMessage' | 'required' | 'requiredTag' | 'requiredText' | 'optionalTag' | 'optionalText' | 'tagText' | 'fullwidth' | 'defaultOptions' | 'options' | 'inline' | 'useWrapper' | 'hasFieldset' | 'counter' | 'defaultValue'>;
|
|
82
|
+
/**
|
|
83
|
+
* Default values for pkt-combobox. Single source of truth for both frameworks.
|
|
84
|
+
* Array defaults (`options`, `defaultOptions`) are intentionally absent — a shared array
|
|
85
|
+
* instance would be mutated across component instances.
|
|
86
|
+
*/
|
|
87
|
+
export declare const COMBOBOX_DEFAULTS: {
|
|
88
|
+
readonly multiple: false;
|
|
89
|
+
readonly typeahead: false;
|
|
90
|
+
readonly includeSearch: false;
|
|
91
|
+
readonly allowUserInput: false;
|
|
92
|
+
readonly displayValueAs: 'label';
|
|
93
|
+
readonly inputSize: 'medium';
|
|
94
|
+
readonly disabled: false;
|
|
95
|
+
readonly hasError: false;
|
|
96
|
+
readonly required: false;
|
|
97
|
+
readonly requiredTag: false;
|
|
98
|
+
readonly optionalTag: false;
|
|
99
|
+
readonly fullwidth: false;
|
|
100
|
+
readonly inline: false;
|
|
101
|
+
readonly useWrapper: true;
|
|
102
|
+
};
|
|
@@ -20,6 +20,7 @@ export type { TIconSizeClass, IPktIconBase, IIconSpecProps } from './icon';
|
|
|
20
20
|
export { LAYOUT_DIRECTIONS } from './layout';
|
|
21
21
|
export type { TLayout, TVerticalPosition, THorizontalPosition, TPosition, TPositionWithCenter, } from './layout';
|
|
22
22
|
export type { THTMLButtonType, TSelectionMode } from './form';
|
|
23
|
+
export { INPUT_SIZES } from './size';
|
|
23
24
|
export type { TPktInputSize, TSize3, TSize5, TSize7 } from './size';
|
|
24
25
|
export { ACCORDION_SKINS } from './accordion';
|
|
25
26
|
export type { TAccordionSkin, IPktAccordionBase, IPktAccordionItemBase, IAccordionSpecProps, IAccordionItemSpecProps, IAccordionVisualProps, } from './accordion';
|
|
@@ -33,7 +34,9 @@ export type { TBreadcrumbsNavigationType, IBreadcrumb, IBreadcrumbItem, IBreadcr
|
|
|
33
34
|
export type { IRenderLink, TRenderLink } from './render-link';
|
|
34
35
|
export type { IPktStringsProps } from '../shared-strings';
|
|
35
36
|
export type { IHelptextProps, ITagOptionalRequiredProps, IFormFieldLabelProps, IFormFieldErrorProps, IFormFieldCommonProps, TFormFieldCommonSpecKeys, } from './form-field';
|
|
36
|
-
export type {
|
|
37
|
+
export type { TTagSkin } from './skin';
|
|
38
|
+
export { MESSAGEBOX_SKINS, MESSAGEBOX_DEFAULTS } from './messagebox';
|
|
39
|
+
export type { TMessageboxSkin, IPktMessageboxBase, IMessageboxSpecProps } from './messagebox';
|
|
37
40
|
export { CALENDAR_DEFAULTS } from './calendar';
|
|
38
41
|
export type { IPktCalendarBase, ICalendarSpecProps, IDateConstraints, ICalendarGridDimensions, IGridCellPosition, TDateRangeMap, ISelectionState, ISelectionOptions, } from './calendar';
|
|
39
42
|
export type { IDatepickerStrings } from './datepicker';
|
|
@@ -41,7 +44,8 @@ export { defaultSingleStrings, defaultRangeStrings } from './datepicker';
|
|
|
41
44
|
export type { ITimepickerStrings } from './timepicker';
|
|
42
45
|
export { defaultTimepickerStrings } from './timepicker';
|
|
43
46
|
export type { TProgressbarRole, TProgressbarSkin, TProgressbarStatusPlacement, TProgressbarStatusType, TProgressbarTitlePosition, } from './progressbar';
|
|
44
|
-
export
|
|
47
|
+
export { COMBOBOX_TAG_SKINS, COMBOBOX_DISPLAY_VALUES, COMBOBOX_TAG_PLACEMENTS, COMBOBOX_DEFAULTS, } from './combobox';
|
|
48
|
+
export type { IPktComboboxOption, TPktComboboxTagSkin, TPktComboboxDisplayValue, TPktComboboxTagPlacement, IPktComboboxBase, IComboboxSpecProps, } from './combobox';
|
|
45
49
|
export type { IPktSelectOption, TSelectOption } from './select';
|
|
46
50
|
export type { TPktSearchInputAppearance, TPktSearchInputMethod, IPktSearchInputSuggestion, IPktSearchInput, } from './searchinput';
|
|
47
51
|
export { UPLOAD_STRATEGIES, FILE_UPLOAD_ITEM_RENDERERS, PREVIEW_UPLOAD_STATUS, } from './fileupload';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* messagebox.ts
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for pkt-messagebox.
|
|
5
|
+
* Used by React, Elements, and typed component specs.
|
|
6
|
+
*/
|
|
7
|
+
/** Messagebox skin variants — shared runtime source for types, specs, and Preview. */
|
|
8
|
+
export declare const MESSAGEBOX_SKINS: readonly ['beige', 'blue', 'red', 'green'];
|
|
9
|
+
export type TMessageboxSkin = (typeof MESSAGEBOX_SKINS)[number];
|
|
10
|
+
/**
|
|
11
|
+
* Messagebox props shared by React and Elements.
|
|
12
|
+
*
|
|
13
|
+
* @remarks React widens `title` to `ReactNode` and adds `onClose`.
|
|
14
|
+
* Elements dispatches a `close` event instead (and `on-close` for legacy Vue setups).
|
|
15
|
+
*/
|
|
16
|
+
export interface IPktMessageboxBase {
|
|
17
|
+
skin?: TMessageboxSkin;
|
|
18
|
+
title?: string;
|
|
19
|
+
compact?: boolean;
|
|
20
|
+
closable?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Documented Messagebox props (subset of `IPktMessageboxBase`).
|
|
24
|
+
* Used for typed component specs in documentation.
|
|
25
|
+
*/
|
|
26
|
+
export type IMessageboxSpecProps = Pick<IPktMessageboxBase, 'title' | 'skin' | 'compact' | 'closable'>;
|
|
27
|
+
/** Default values for pkt-messagebox. Single source of truth for both frameworks. */
|
|
28
|
+
export declare const MESSAGEBOX_DEFAULTS: {
|
|
29
|
+
readonly skin: 'beige';
|
|
30
|
+
readonly compact: false;
|
|
31
|
+
readonly closable: false;
|
|
32
|
+
};
|
|
@@ -17,7 +17,7 @@ export type TSize5 = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
|
|
|
17
17
|
*/
|
|
18
18
|
export type TSize7 = 'xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge';
|
|
19
19
|
/**
|
|
20
|
-
* Sizes used in our input components
|
|
20
|
+
* Sizes used in our input components — shared runtime source for types, specs, and Preview.
|
|
21
21
|
*/
|
|
22
|
-
export declare const
|
|
23
|
-
export type TPktInputSize = (typeof
|
|
22
|
+
export declare const INPUT_SIZES: readonly ['xsmall', 'small', 'medium'];
|
|
23
|
+
export type TPktInputSize = (typeof INPUT_SIZES)[number];
|
|
@@ -8,10 +8,7 @@
|
|
|
8
8
|
export { ALERT_SKINS, type TAlertSkin } from './alert';
|
|
9
9
|
export { ACCORDION_SKINS, type TAccordionSkin } from './accordion';
|
|
10
10
|
export { CARD_SKINS, type TCardSkin } from './card';
|
|
11
|
-
|
|
12
|
-
* Messagebox component skin variants
|
|
13
|
-
*/
|
|
14
|
-
export type TMessageboxSkin = 'beige' | 'blue' | 'red' | 'green';
|
|
11
|
+
export { MESSAGEBOX_SKINS, type TMessageboxSkin } from './messagebox';
|
|
15
12
|
/**
|
|
16
13
|
* Tag component skin variants
|
|
17
14
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.8.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",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
102
102
|
},
|
|
103
103
|
"license": "MIT",
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "aac1152f60412d31e67493d4813afebe5dcea8bb"
|
|
105
105
|
}
|
|
@@ -44,7 +44,7 @@ export const PktCombobox = forwardRef<HTMLDivElement, IPktCombobox>((props, ref)
|
|
|
44
44
|
tagText={state.tagText}
|
|
45
45
|
useWrapper={state.useWrapper}
|
|
46
46
|
inline={state.inline}
|
|
47
|
-
size={
|
|
47
|
+
size={state.inputSize}
|
|
48
48
|
counter={state.hasCounter}
|
|
49
49
|
counterCurrent={state.values.length}
|
|
50
50
|
counterMaxLength={state.maxlength}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { useEffect, useRef, type MouseEvent, type KeyboardEvent } from 'react'
|
|
4
4
|
import { findOptionByValue, getOptionDisplayText } from 'shared-utils/combobox'
|
|
5
|
-
import type { TPktComboboxDisplayValue } from 'shared-types/combobox'
|
|
6
5
|
import { PktTag } from '../tag/Tag'
|
|
7
6
|
import type { IComboboxState } from './types'
|
|
8
7
|
|
|
@@ -104,7 +103,7 @@ export const SingleValueDisplay = ({ state }: ISingleValueDisplayProps) => {
|
|
|
104
103
|
const option = findOptionByValue(options, values[0])
|
|
105
104
|
if (!option) return null
|
|
106
105
|
|
|
107
|
-
const displayText = getOptionDisplayText(option, displayValueAs
|
|
106
|
+
const displayText = getOptionDisplayText(option, displayValueAs)
|
|
108
107
|
|
|
109
108
|
return <span className="pkt-combobox__value">{displayText}</span>
|
|
110
109
|
}
|
|
@@ -12,52 +12,20 @@ import type {
|
|
|
12
12
|
ReactNode,
|
|
13
13
|
RefObject,
|
|
14
14
|
} from 'react'
|
|
15
|
-
import type {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
maxlength?: number
|
|
27
|
-
typeahead?: boolean
|
|
28
|
-
includeSearch?: boolean
|
|
29
|
-
allowUserInput?: boolean
|
|
30
|
-
displayValueAs?: TPktComboboxDisplayValue
|
|
31
|
-
tagPlacement?: TPktComboboxTagPlacement
|
|
32
|
-
searchPlaceholder?: string
|
|
33
|
-
|
|
34
|
-
// Form
|
|
35
|
-
name?: string
|
|
36
|
-
form?: string
|
|
37
|
-
ariaDescribedby?: string
|
|
38
|
-
id?: string
|
|
39
|
-
disabled?: boolean
|
|
40
|
-
required?: boolean
|
|
41
|
-
placeholder?: string
|
|
42
|
-
|
|
43
|
-
// InputWrapper props
|
|
44
|
-
label?: string
|
|
15
|
+
import type {
|
|
16
|
+
IPktComboboxBase,
|
|
17
|
+
IPktComboboxOption,
|
|
18
|
+
TPktComboboxDisplayValue,
|
|
19
|
+
TPktComboboxTagPlacement,
|
|
20
|
+
} from 'shared-types/combobox'
|
|
21
|
+
|
|
22
|
+
export interface IPktCombobox
|
|
23
|
+
extends
|
|
24
|
+
Omit<IPktComboboxBase, 'helptext' | 'helptextDropdown' | 'errorMessage'>,
|
|
25
|
+
IPktStringsProps<'combobox' | 'listbox' | 'forms' | 'validation'> {
|
|
45
26
|
helptext?: string | ReactNode
|
|
46
27
|
helptextDropdown?: string | ReactNode
|
|
47
|
-
helptextDropdownButton?: string
|
|
48
|
-
hasError?: boolean
|
|
49
28
|
errorMessage?: string | ReactNode
|
|
50
|
-
fullwidth?: boolean
|
|
51
|
-
requiredTag?: boolean
|
|
52
|
-
requiredText?: string
|
|
53
|
-
optionalTag?: boolean
|
|
54
|
-
optionalText?: string
|
|
55
|
-
tagText?: string
|
|
56
|
-
useWrapper?: boolean
|
|
57
|
-
inline?: boolean
|
|
58
|
-
counter?: boolean
|
|
59
|
-
hasFieldset?: boolean
|
|
60
|
-
inputSize?: 'small' | 'medium' | 'xsmall'
|
|
61
29
|
|
|
62
30
|
// Events
|
|
63
31
|
onChange?: ChangeEventHandler<HTMLInputElement>
|
|
@@ -119,7 +87,7 @@ export interface IComboboxState {
|
|
|
119
87
|
optionalText?: string
|
|
120
88
|
requiredTag: boolean
|
|
121
89
|
requiredText?: string
|
|
122
|
-
tagText?: string
|
|
90
|
+
tagText?: string | null
|
|
123
91
|
useWrapper: boolean
|
|
124
92
|
inline: boolean
|
|
125
93
|
inputSize: 'small' | 'medium' | 'xsmall'
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
useRef,
|
|
12
12
|
useState,
|
|
13
13
|
} from 'react'
|
|
14
|
-
import
|
|
14
|
+
import { COMBOBOX_DEFAULTS, type IPktComboboxOption } from 'shared-types/combobox'
|
|
15
15
|
import {
|
|
16
16
|
findOptionByValue,
|
|
17
17
|
getOptionDisplayText,
|
|
@@ -54,32 +54,32 @@ export function useComboboxState(props: IPktCombobox, ref: React.ForwardedRef<HT
|
|
|
54
54
|
defaultValue,
|
|
55
55
|
options: optionsProp,
|
|
56
56
|
defaultOptions,
|
|
57
|
-
multiple =
|
|
57
|
+
multiple = COMBOBOX_DEFAULTS.multiple,
|
|
58
58
|
maxlength,
|
|
59
|
-
typeahead =
|
|
60
|
-
includeSearch =
|
|
61
|
-
allowUserInput =
|
|
62
|
-
displayValueAs =
|
|
59
|
+
typeahead = COMBOBOX_DEFAULTS.typeahead,
|
|
60
|
+
includeSearch = COMBOBOX_DEFAULTS.includeSearch,
|
|
61
|
+
allowUserInput = COMBOBOX_DEFAULTS.allowUserInput,
|
|
62
|
+
displayValueAs = COMBOBOX_DEFAULTS.displayValueAs,
|
|
63
63
|
tagPlacement,
|
|
64
64
|
searchPlaceholder,
|
|
65
65
|
placeholder,
|
|
66
|
-
disabled =
|
|
67
|
-
required =
|
|
68
|
-
fullwidth =
|
|
69
|
-
hasError =
|
|
66
|
+
disabled = COMBOBOX_DEFAULTS.disabled,
|
|
67
|
+
required = COMBOBOX_DEFAULTS.required,
|
|
68
|
+
fullwidth = COMBOBOX_DEFAULTS.fullwidth,
|
|
69
|
+
hasError = COMBOBOX_DEFAULTS.hasError,
|
|
70
70
|
errorMessage,
|
|
71
71
|
helptext,
|
|
72
72
|
helptextDropdown,
|
|
73
73
|
helptextDropdownButton,
|
|
74
|
-
optionalTag =
|
|
74
|
+
optionalTag = COMBOBOX_DEFAULTS.optionalTag,
|
|
75
75
|
optionalText,
|
|
76
|
-
requiredTag =
|
|
76
|
+
requiredTag = COMBOBOX_DEFAULTS.requiredTag,
|
|
77
77
|
requiredText,
|
|
78
78
|
tagText,
|
|
79
|
-
useWrapper =
|
|
80
|
-
inline =
|
|
79
|
+
useWrapper = COMBOBOX_DEFAULTS.useWrapper,
|
|
80
|
+
inline = COMBOBOX_DEFAULTS.inline,
|
|
81
81
|
counter,
|
|
82
|
-
inputSize =
|
|
82
|
+
inputSize = COMBOBOX_DEFAULTS.inputSize,
|
|
83
83
|
name,
|
|
84
84
|
form,
|
|
85
85
|
ariaDescribedby,
|
|
@@ -427,10 +427,7 @@ export function useComboboxState(props: IPktCombobox, ref: React.ForwardedRef<HT
|
|
|
427
427
|
// The two modes resolve displayValueAs through different helpers.
|
|
428
428
|
newMessageValue = hasTextInput
|
|
429
429
|
? getSingleValueForInput(valueFromOptions || '', options, displayValueAs)
|
|
430
|
-
: getOptionDisplayText(
|
|
431
|
-
findOptionByValue(options, valueFromOptions),
|
|
432
|
-
displayValueAs as TPktComboboxDisplayValue,
|
|
433
|
-
)
|
|
430
|
+
: getOptionDisplayText(findOptionByValue(options, valueFromOptions), displayValueAs)
|
|
434
431
|
}
|
|
435
432
|
// Multi with room
|
|
436
433
|
else if (isMultiple && !isMaxItemsReached) {
|
|
@@ -13,7 +13,7 @@ describe('Messagebox', () => {
|
|
|
13
13
|
it('render with defaults', async () => {
|
|
14
14
|
const { messageBox } = render(<PktMessagebox />)
|
|
15
15
|
|
|
16
|
-
expect(messageBox.className).toEqual('pkt-messagebox')
|
|
16
|
+
expect(messageBox.className).toEqual('pkt-messagebox pkt-messagebox--beige')
|
|
17
17
|
})
|
|
18
18
|
|
|
19
19
|
it('render with skin', async () => {
|
|
@@ -3,28 +3,29 @@
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import { createRef, FC, HTMLAttributes, ReactNode, useCallback, useState } from 'react'
|
|
5
5
|
import type { IPktStringsProps } from 'shared-strings'
|
|
6
|
-
import type
|
|
6
|
+
import { MESSAGEBOX_DEFAULTS, type IPktMessageboxBase, type TMessageboxSkin } from 'shared-types'
|
|
7
7
|
|
|
8
8
|
import { usePktStrings } from '../../hooks/usePktStrings'
|
|
9
9
|
import { PktIcon } from '../icon/Icon'
|
|
10
10
|
|
|
11
11
|
export type { TMessageboxSkin }
|
|
12
12
|
|
|
13
|
-
export interface IPktMessagebox
|
|
14
|
-
|
|
13
|
+
export interface IPktMessagebox
|
|
14
|
+
extends
|
|
15
|
+
Omit<IPktMessageboxBase, 'title'>,
|
|
16
|
+
Omit<HTMLAttributes<HTMLDivElement>, 'title'>,
|
|
17
|
+
IPktStringsProps<'generic'> {
|
|
15
18
|
title?: ReactNode
|
|
16
|
-
compact?: boolean
|
|
17
|
-
closable?: boolean
|
|
18
19
|
onClose?: () => void
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export const PktMessagebox: FC<IPktMessagebox> = ({
|
|
22
23
|
children,
|
|
23
24
|
className,
|
|
24
|
-
skin,
|
|
25
|
+
skin = MESSAGEBOX_DEFAULTS.skin,
|
|
25
26
|
title,
|
|
26
|
-
compact,
|
|
27
|
-
closable,
|
|
27
|
+
compact = MESSAGEBOX_DEFAULTS.compact,
|
|
28
|
+
closable = MESSAGEBOX_DEFAULTS.closable,
|
|
28
29
|
onClose,
|
|
29
30
|
strings,
|
|
30
31
|
...props
|