@oslokommune/punkt-elements 19.6.0 → 19.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/CHANGELOG.md +5 -0
- package/dist/base-elements/input-element.d.ts +1 -0
- package/dist/combobox-BfdvXLBz.cjs +139 -0
- package/dist/{combobox-CWzWHBaw.js → combobox-CMpYhgln.js} +46 -422
- package/dist/components/combobox/combobox-base.d.ts +2 -2
- package/dist/components/combobox/combobox.d.ts +9 -26
- package/dist/components/input-wrapper/input-wrapper.d.ts +1 -0
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +7 -7
- package/dist/shared-types/combobox.d.ts +73 -5
- package/dist/shared-types/index.d.ts +3 -1
- package/dist/shared-types/size.d.ts +3 -3
- package/package.json +2 -2
- package/src/components/combobox/combobox-base.ts +14 -8
- package/src/components/combobox/combobox-value.ts +2 -2
- package/src/components/combobox/combobox.attributes.test.ts +3 -2
- package/src/components/combobox/combobox.ts +26 -26
- package/src/components/input-wrapper/input-wrapper.ts +1 -0
- package/dist/combobox-FCguoyDH.cjs +0 -139
|
@@ -1,40 +1,23 @@
|
|
|
1
1
|
import { PropertyValues } from 'lit';
|
|
2
|
-
import { IPktComboboxOption, TPktComboboxTagPlacement } from './combobox-types';
|
|
2
|
+
import { IPktComboboxOption, TPktComboboxTagPlacement, TPktComboboxDisplayValue } from './combobox-types';
|
|
3
|
+
import { IPktComboboxBase } from '../../shared-types/combobox';
|
|
3
4
|
import { ComboboxHandlers } from './combobox-handlers';
|
|
4
5
|
import { IPktStringsProps } from '../../shared-strings';
|
|
5
6
|
import { Booleanish } from '../../shared-types';
|
|
6
7
|
export type { IPktComboboxOption, TPktComboboxTagPlacement } from './combobox-types';
|
|
7
|
-
export interface IPktCombobox extends IPktStringsProps<'combobox' | 'listbox'> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
displayValueAs?: string;
|
|
12
|
-
errorMessage?: string;
|
|
13
|
-
fullwidth?: boolean;
|
|
14
|
-
hasError?: boolean;
|
|
8
|
+
export interface IPktCombobox extends Omit<IPktComboboxBase, 'form' | 'ariaDescribedby' | 'label' | 'helptext' | 'helptextDropdown' | 'helptextDropdownButton' | 'placeholder' | 'searchPlaceholder' | 'maxlength' | 'tagPlacement' | 'defaultValue' | 'useWrapper'>, IPktStringsProps<'combobox' | 'listbox'> {
|
|
9
|
+
ariaDescribedby?: string | null;
|
|
10
|
+
label?: string | null;
|
|
15
11
|
helptext?: string | null;
|
|
16
12
|
helptextDropdown?: string | null;
|
|
13
|
+
/** @deprecated Bruk `strings={{ forms: { readMore: '…' } }}` eller `setPktStrings()`. */
|
|
17
14
|
helptextDropdownButton?: string | null;
|
|
18
|
-
id?: string;
|
|
19
|
-
includeSearch?: boolean;
|
|
20
|
-
label?: string | null;
|
|
21
|
-
maxlength?: number | null;
|
|
22
|
-
minlength?: number | null;
|
|
23
|
-
multiple?: boolean;
|
|
24
|
-
name?: string;
|
|
25
|
-
optionalTag?: boolean;
|
|
26
|
-
optionalText?: string;
|
|
27
|
-
options?: IPktComboboxOption[];
|
|
28
|
-
defaultOptions?: IPktComboboxOption[];
|
|
29
15
|
placeholder?: string | null;
|
|
30
|
-
requiredTag?: boolean;
|
|
31
|
-
requiredText?: string;
|
|
32
16
|
searchPlaceholder?: string | null;
|
|
17
|
+
maxlength?: number | null;
|
|
18
|
+
minlength?: number | null;
|
|
33
19
|
tagPlacement?: TPktComboboxTagPlacement | null;
|
|
34
|
-
tagText?: string | null;
|
|
35
|
-
value?: string | string[];
|
|
36
20
|
defaultValue?: string | string[] | null;
|
|
37
|
-
hasFieldset?: boolean | null;
|
|
38
21
|
useWrapper?: Booleanish;
|
|
39
22
|
isOpen?: boolean;
|
|
40
23
|
}
|
|
@@ -46,7 +29,7 @@ export interface IPktCombobox extends IPktStringsProps<'combobox' | 'listbox'> {
|
|
|
46
29
|
export interface IPktComboboxAttributes {
|
|
47
30
|
'allow-user-input'?: boolean;
|
|
48
31
|
'default-options'?: IPktComboboxOption[];
|
|
49
|
-
'display-value-as'?:
|
|
32
|
+
'display-value-as'?: TPktComboboxDisplayValue;
|
|
50
33
|
'include-search'?: boolean;
|
|
51
34
|
'search-placeholder'?: string | null;
|
|
52
35
|
'tag-placement'?: TPktComboboxTagPlacement | null;
|
|
@@ -15,6 +15,7 @@ export declare class PktInputWrapper extends PktElementWithSlot<Props> {
|
|
|
15
15
|
label: string;
|
|
16
16
|
helptext: string | null;
|
|
17
17
|
helptextDropdown: string | null;
|
|
18
|
+
/** @deprecated Bruk `strings={{ forms: { readMore: '…' } }}` eller `setPktStrings()`. */
|
|
18
19
|
helptextDropdownButton: string | null;
|
|
19
20
|
counter: boolean;
|
|
20
21
|
counterCurrent: number;
|
package/dist/pkt-combobox.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./combobox-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./combobox-BfdvXLBz.cjs");exports.PktCombobox=e.n,exports.default=e.t;
|
package/dist/pkt-combobox.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "./combobox-
|
|
1
|
+
import { n as e, t } from "./combobox-CMpYhgln.js";
|
|
2
2
|
export { e as PktCombobox, t as default };
|
package/dist/pkt-index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./element-BOmr9YLv.cjs"),t=require("./consent-Dl-R0iC3.cjs"),n=require("./alert-IaZzEgyI.cjs"),r=require("./header-C4Uojzoy.cjs"),i=require("./card-CaLEuumN.cjs"),a=require("./checkbox-D69leWDh.cjs"),o=require("./icon-Dnv6LtPC.cjs"),s=require("./calendar-TcxvS-1_.cjs"),c=require("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./element-BOmr9YLv.cjs"),t=require("./consent-Dl-R0iC3.cjs"),n=require("./alert-IaZzEgyI.cjs"),r=require("./header-C4Uojzoy.cjs"),i=require("./card-CaLEuumN.cjs"),a=require("./checkbox-D69leWDh.cjs"),o=require("./icon-Dnv6LtPC.cjs"),s=require("./calendar-TcxvS-1_.cjs"),c=require("./combobox-BfdvXLBz.cjs"),l=require("./button-BNVTj7nB.cjs"),u=require("./accordion-5lSFQToJ.cjs"),d=require("./backlink-BRqhwUr2.cjs"),f=require("./breadcrumbs-DG4i5UCh.cjs"),p=require("./tag-B5dUg7AD.cjs"),m=require("./input-wrapper-J3mEKhvR.cjs"),h=require("./helptext-BCkwSz1m.cjs"),g=require("./fileupload-CMIFZWJ5.cjs"),_=require("./modal-BymjMIJi.cjs"),v=require("./progressbar-CIXNSwTy.cjs"),y=require("./datepicker-CWHYYj-H.cjs"),b=require("./footer-vy9NqT65.cjs"),x=require("./link-LO_5_La8.cjs"),S=require("./textinput-C2Tx-OrN.cjs"),C=require("./searchinput-CbClDE-d.cjs"),w=require("./header-menu-BfkCp8jw.cjs"),T=require("./heading-zoz-QZJ9.cjs"),E=require("./linkcard-UKsxADrP.cjs"),D=require("./loader-C_PH05aw.cjs"),O=require("./messagebox-JWKMJEFc.cjs"),k=require("./radiobutton-BPr22VmL.cjs"),A=require("./tabs-CjX-GWvM.cjs"),j=require("./textarea-H1Lt2o6K.cjs"),M=require("./select-CZYQ5Dmx.cjs"),N=require("./timepicker-DZG_gHIa.cjs");exports.PktAccordion=u.r,exports.PktAccordionItem=u.n,exports.PktAlert=n.n,exports.PktBackLink=d.n,exports.PktBreadcrumbs=f.t,exports.PktButton=l.n,exports.PktCalendar=s.n,exports.PktCard=i.n,exports.PktCheckbox=a.n,exports.PktCombobox=c.n,exports.PktConsent=t.n,exports.PktDateTags=y.a,exports.PktDatepicker=y.t,Object.defineProperty(exports,"PktFileUpload",{enumerable:!0,get:function(){return g.n}}),exports.PktFooter=b.n,exports.PktFooterSimple=b.t,exports.PktHeader=r.t,exports.PktHeaderGlobal=r.n,exports.PktHeaderMenu=w.n,exports.PktHeaderService=r.r,exports.PktHeaderUserMenu=r.i,exports.PktHeading=T.n,exports.PktHelptext=h.n,exports.PktIcon=o.n,exports.PktInputWrapper=m.n,exports.PktLink=x.n,exports.PktLinkCard=E.n,exports.PktLoader=D.n,exports.PktMessagebox=O.n,exports.PktModal=_.n,exports.PktProgressbar=v.n,exports.PktRadioButton=k.n,exports.PktRadiobutton=k.n,exports.PktSearchInput=C.n,exports.PktSelect=M.n,exports.PktTabItem=A.n,exports.PktTabs=A.r,exports.PktTag=p.n,exports.PktTextarea=j.n,exports.PktTextinput=S.n,exports.PktTimepicker=N.t,exports.getPktStrings=e.r,exports.pktStringsNb=e.s,exports.resetPktStrings=e.i,exports.setPktStrings=e.a,exports.subscribePktStrings=e.o;
|
package/dist/pkt-index.js
CHANGED
|
@@ -6,12 +6,12 @@ import { n as d } from "./card-CYKhPUNI.js";
|
|
|
6
6
|
import { n as f } from "./checkbox-Tq8ESzwH.js";
|
|
7
7
|
import { n as p } from "./icon-JigbxxF7.js";
|
|
8
8
|
import { n as m } from "./calendar-BLaRXUBl.js";
|
|
9
|
-
import { n as h } from "./
|
|
10
|
-
import { n as g
|
|
11
|
-
import { n as v } from "./
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { n as x } from "./
|
|
9
|
+
import { n as h } from "./combobox-CMpYhgln.js";
|
|
10
|
+
import { n as g } from "./button-B78im4wB.js";
|
|
11
|
+
import { n as _, r as v } from "./accordion-BJh6X1Ek.js";
|
|
12
|
+
import { n as y } from "./backlink-BslFewn-.js";
|
|
13
|
+
import { t as b } from "./breadcrumbs-Cr3GugPv.js";
|
|
14
|
+
import { n as x } from "./tag-Bns7Xj1O.js";
|
|
15
15
|
import { n as S } from "./input-wrapper-BoTugCvh.js";
|
|
16
16
|
import { n as C } from "./helptext-DCT_9dw1.js";
|
|
17
17
|
import { n as w } from "./fileupload-BQFJx1ok.js";
|
|
@@ -32,4 +32,4 @@ import { n as B, r as V } from "./tabs-B8blHQrL.js";
|
|
|
32
32
|
import { n as H } from "./textarea-C2oaRlfb.js";
|
|
33
33
|
import { n as U } from "./select-DYjKMmHa.js";
|
|
34
34
|
import { t as W } from "./timepicker-B8TwchA2.js";
|
|
35
|
-
export {
|
|
35
|
+
export { v as PktAccordion, _ as PktAccordionItem, o as PktAlert, y as PktBackLink, b as PktBreadcrumbs, g as PktButton, m as PktCalendar, d as PktCard, f as PktCheckbox, h as PktCombobox, a as PktConsent, D as PktDateTags, O as PktDatepicker, w as PktFileUpload, k as PktFooter, A as PktFooterSimple, u as PktHeader, c as PktHeaderGlobal, P as PktHeaderMenu, l as PktHeaderService, s as PktHeaderUserMenu, F as PktHeading, C as PktHelptext, p as PktIcon, S as PktInputWrapper, j as PktLink, I as PktLinkCard, L as PktLoader, R as PktMessagebox, T as PktModal, E as PktProgressbar, z as PktRadioButton, z as PktRadiobutton, N as PktSearchInput, U as PktSelect, B as PktTabItem, V as PktTabs, x as PktTag, H as PktTextarea, M as PktTextinput, W as PktTimepicker, r as getPktStrings, i as pktStringsNb, t as resetPktStrings, e as setPktStrings, n as subscribePktStrings };
|
|
@@ -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';
|
|
@@ -41,7 +42,8 @@ export { defaultSingleStrings, defaultRangeStrings } from './datepicker';
|
|
|
41
42
|
export type { ITimepickerStrings } from './timepicker';
|
|
42
43
|
export { defaultTimepickerStrings } from './timepicker';
|
|
43
44
|
export type { TProgressbarRole, TProgressbarSkin, TProgressbarStatusPlacement, TProgressbarStatusType, TProgressbarTitlePosition, } from './progressbar';
|
|
44
|
-
export
|
|
45
|
+
export { COMBOBOX_TAG_SKINS, COMBOBOX_DISPLAY_VALUES, COMBOBOX_TAG_PLACEMENTS, COMBOBOX_DEFAULTS, } from './combobox';
|
|
46
|
+
export type { IPktComboboxOption, TPktComboboxTagSkin, TPktComboboxDisplayValue, TPktComboboxTagPlacement, IPktComboboxBase, IComboboxSpecProps, } from './combobox';
|
|
45
47
|
export type { IPktSelectOption, TSelectOption } from './select';
|
|
46
48
|
export type { TPktSearchInputAppearance, TPktSearchInputMethod, IPktSearchInputSuggestion, IPktSearchInput, } from './searchinput';
|
|
47
49
|
export { UPLOAD_STRATEGIES, FILE_UPLOAD_ITEM_RENDERERS, PREVIEW_UPLOAD_STATUS, } from './fileupload';
|
|
@@ -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];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.7.0",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, designsystem for Oslo kommune",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo kommune",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": "^22.19.0 || ^24.0.0 || ^26.0.0"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "f5f319f536d0fcbd3943ed6e191d887112e3c192"
|
|
88
88
|
}
|
|
@@ -3,9 +3,13 @@ import { Ref, createRef } from 'lit/directives/ref.js'
|
|
|
3
3
|
import { PktInputElement } from '@/base-elements/input-element'
|
|
4
4
|
import { PktOptionsSlotController } from '@/controllers/pkt-options-controller'
|
|
5
5
|
import { isMaxSelectionReached } from 'shared-utils/combobox/option-utils'
|
|
6
|
-
import
|
|
6
|
+
import { COMBOBOX_DEFAULTS } from 'shared-types/combobox'
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
IPktComboboxOption,
|
|
10
|
+
TPktComboboxDisplayValue,
|
|
11
|
+
TPktComboboxTagPlacement,
|
|
12
|
+
} from './combobox-types'
|
|
9
13
|
import type { IPktStringsProps } from 'shared-strings'
|
|
10
14
|
import PktListbox from '../listbox'
|
|
11
15
|
import type { TComboboxMessageKey } from 'shared-utils/combobox'
|
|
@@ -24,15 +28,17 @@ export class ComboboxBase extends PktInputElement<IPktStringsProps<'combobox' |
|
|
|
24
28
|
@property({ type: String, reflect: true }) value: string | string[] = ''
|
|
25
29
|
@property({ type: Array }) options: IPktComboboxOption[] = []
|
|
26
30
|
@property({ type: Array, attribute: 'default-options' }) defaultOptions: IPktComboboxOption[] = []
|
|
27
|
-
@property({ type: Boolean, attribute: 'allow-user-input' }) allowUserInput: boolean =
|
|
28
|
-
|
|
29
|
-
@property({ type: Boolean
|
|
31
|
+
@property({ type: Boolean, attribute: 'allow-user-input' }) allowUserInput: boolean =
|
|
32
|
+
COMBOBOX_DEFAULTS.allowUserInput
|
|
33
|
+
@property({ type: Boolean }) typeahead: boolean = COMBOBOX_DEFAULTS.typeahead
|
|
34
|
+
@property({ type: Boolean, attribute: 'include-search' }) includeSearch: boolean =
|
|
35
|
+
COMBOBOX_DEFAULTS.includeSearch
|
|
30
36
|
@property({ type: String, attribute: 'search-placeholder' }) searchPlaceholder: string | null =
|
|
31
37
|
null
|
|
32
|
-
@property({ type: Boolean }) multiple: boolean =
|
|
38
|
+
@property({ type: Boolean }) multiple: boolean = COMBOBOX_DEFAULTS.multiple
|
|
33
39
|
@property({ type: Number }) maxlength: number | null = null
|
|
34
|
-
@property({ type: String, attribute: 'display-value-as' })
|
|
35
|
-
|
|
40
|
+
@property({ type: String, attribute: 'display-value-as' })
|
|
41
|
+
displayValueAs: TPktComboboxDisplayValue = COMBOBOX_DEFAULTS.displayValueAs
|
|
36
42
|
@property({ type: String, attribute: 'tag-placement' })
|
|
37
43
|
tagPlacement: TPktComboboxTagPlacement | null = null
|
|
38
44
|
// Internal use only — syncs to _isOptionsOpen in willUpdate(), but does not
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IPktComboboxOption
|
|
1
|
+
import type { IPktComboboxOption } from './combobox-types'
|
|
2
2
|
import {
|
|
3
3
|
findOptionByValue,
|
|
4
4
|
getOptionDisplayText,
|
|
@@ -87,7 +87,7 @@ export class ComboboxValue extends ComboboxBase {
|
|
|
87
87
|
? getSingleValueForInput(valueFromOptions || '', this.options, this.displayValueAs)
|
|
88
88
|
: getOptionDisplayText(
|
|
89
89
|
findOptionByValue(this.options, valueFromOptions),
|
|
90
|
-
this.displayValueAs
|
|
90
|
+
this.displayValueAs,
|
|
91
91
|
)
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@testing-library/jest-dom'
|
|
2
2
|
|
|
3
|
-
import spec from 'componentSpecs/combobox.
|
|
3
|
+
import spec from 'componentSpecs/combobox.spec'
|
|
4
4
|
import './combobox'
|
|
5
5
|
import { PktCombobox } from './combobox'
|
|
6
6
|
|
|
@@ -18,6 +18,7 @@ const cases: { attribute: string; property: keyof PktCombobox; set: string; expe
|
|
|
18
18
|
{ attribute: 'display-value-as', property: 'displayValueAs', set: 'value', expect: 'value' },
|
|
19
19
|
{ attribute: 'search-placeholder', property: 'searchPlaceholder', set: 'x', expect: 'x' },
|
|
20
20
|
{ attribute: 'tag-placement', property: 'tagPlacement', set: 'outside', expect: 'outside' },
|
|
21
|
+
{ attribute: 'aria-describedby', property: 'ariaDescribedby', set: 'x', expect: 'x' },
|
|
21
22
|
{ attribute: 'defaultvalue', property: 'defaultValue', set: 'x', expect: 'x' },
|
|
22
23
|
{ attribute: 'errormessage', property: 'errorMessage', set: 'x', expect: 'x' },
|
|
23
24
|
{ attribute: 'helptextdropdown', property: 'helptextDropdown', set: 'x', expect: 'x' },
|
|
@@ -71,7 +72,7 @@ describe('PktCombobox attributes', () => {
|
|
|
71
72
|
})
|
|
72
73
|
|
|
73
74
|
test('every renamed attribute in the component spec is declared', () => {
|
|
74
|
-
const renamed = Object.entries(spec.props)
|
|
75
|
+
const renamed = Object.entries(spec.props ?? {})
|
|
75
76
|
.filter(([name, prop]) => 'attribute' in prop && prop.attribute !== name)
|
|
76
77
|
.map(([, prop]) => (prop as { attribute: string }).attribute)
|
|
77
78
|
// input-size and data-testid come from the shared input wrapper, not combobox
|
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
TPktComboboxTagPlacement,
|
|
11
11
|
TPktComboboxDisplayValue,
|
|
12
12
|
} from './combobox-types'
|
|
13
|
+
import type { IPktComboboxBase } from 'shared-types/combobox'
|
|
13
14
|
import { findOptionByValue, findOptionIndex } from 'shared-utils/combobox/option-utils'
|
|
14
15
|
import { getSingleValueForInput } from 'shared-utils/combobox/input-utils'
|
|
15
16
|
import { slotUtils, optionStateUtils } from './combobox-utils'
|
|
@@ -29,37 +30,36 @@ import '../listbox'
|
|
|
29
30
|
// Re-export types for backward compatibility
|
|
30
31
|
export type { IPktComboboxOption, TPktComboboxTagPlacement } from './combobox-types'
|
|
31
32
|
|
|
32
|
-
export interface IPktCombobox
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
export interface IPktCombobox
|
|
34
|
+
extends
|
|
35
|
+
Omit<
|
|
36
|
+
IPktComboboxBase,
|
|
37
|
+
| 'form'
|
|
38
|
+
| 'ariaDescribedby'
|
|
39
|
+
| 'label'
|
|
40
|
+
| 'helptext'
|
|
41
|
+
| 'helptextDropdown'
|
|
42
|
+
| 'helptextDropdownButton'
|
|
43
|
+
| 'placeholder'
|
|
44
|
+
| 'searchPlaceholder'
|
|
45
|
+
| 'maxlength'
|
|
46
|
+
| 'tagPlacement'
|
|
47
|
+
| 'defaultValue'
|
|
48
|
+
| 'useWrapper'
|
|
49
|
+
>,
|
|
50
|
+
IPktStringsProps<'combobox' | 'listbox'> {
|
|
51
|
+
ariaDescribedby?: string | null
|
|
52
|
+
label?: string | null
|
|
40
53
|
helptext?: string | null
|
|
41
54
|
helptextDropdown?: string | null
|
|
55
|
+
/** @deprecated Bruk `strings={{ forms: { readMore: '…' } }}` eller `setPktStrings()`. */
|
|
42
56
|
helptextDropdownButton?: string | null
|
|
43
|
-
id?: string
|
|
44
|
-
includeSearch?: boolean
|
|
45
|
-
label?: string | null
|
|
46
|
-
maxlength?: number | null
|
|
47
|
-
minlength?: number | null
|
|
48
|
-
multiple?: boolean
|
|
49
|
-
name?: string
|
|
50
|
-
optionalTag?: boolean
|
|
51
|
-
optionalText?: string
|
|
52
|
-
options?: IPktComboboxOption[]
|
|
53
|
-
defaultOptions?: IPktComboboxOption[]
|
|
54
57
|
placeholder?: string | null
|
|
55
|
-
requiredTag?: boolean
|
|
56
|
-
requiredText?: string
|
|
57
58
|
searchPlaceholder?: string | null
|
|
59
|
+
maxlength?: number | null
|
|
60
|
+
minlength?: number | null
|
|
58
61
|
tagPlacement?: TPktComboboxTagPlacement | null
|
|
59
|
-
tagText?: string | null
|
|
60
|
-
value?: string | string[]
|
|
61
62
|
defaultValue?: string | string[] | null
|
|
62
|
-
hasFieldset?: boolean | null
|
|
63
63
|
useWrapper?: Booleanish
|
|
64
64
|
isOpen?: boolean
|
|
65
65
|
}
|
|
@@ -72,7 +72,7 @@ export interface IPktCombobox extends IPktStringsProps<'combobox' | 'listbox'> {
|
|
|
72
72
|
export interface IPktComboboxAttributes {
|
|
73
73
|
'allow-user-input'?: boolean
|
|
74
74
|
'default-options'?: IPktComboboxOption[]
|
|
75
|
-
'display-value-as'?:
|
|
75
|
+
'display-value-as'?: TPktComboboxDisplayValue
|
|
76
76
|
'include-search'?: boolean
|
|
77
77
|
'search-placeholder'?: string | null
|
|
78
78
|
'tag-placement'?: TPktComboboxTagPlacement | null
|
|
@@ -574,7 +574,7 @@ export class PktCombobox extends ComboboxHandlers implements IPktCombobox {
|
|
|
574
574
|
|
|
575
575
|
private renderValueTag(option: IPktComboboxOption | null) {
|
|
576
576
|
if (!option) return ''
|
|
577
|
-
const displayAs = this.displayValueAs
|
|
577
|
+
const displayAs = this.displayValueAs
|
|
578
578
|
switch (displayAs) {
|
|
579
579
|
case 'prefixAndValue':
|
|
580
580
|
return html`<span class="pkt-combobox__value">${option.prefix || ''} ${option.value}</span>`
|
|
@@ -52,6 +52,7 @@ export class PktInputWrapper extends PktElementWithSlot<Props> {
|
|
|
52
52
|
@property({ type: String }) label: string = ''
|
|
53
53
|
@property({ type: String }) helptext: string | null = null
|
|
54
54
|
@property({ type: String }) helptextDropdown: string | null = null
|
|
55
|
+
/** @deprecated Bruk `strings={{ forms: { readMore: '…' } }}` eller `setPktStrings()`. */
|
|
55
56
|
@property({ type: String }) helptextDropdownButton: string | null = null
|
|
56
57
|
@property({ type: Boolean }) counter: boolean = specs.props.counter.default
|
|
57
58
|
@property({ type: Number }) counterCurrent: number = 0
|