@oslokommune/punkt-react 19.12.1 → 19.13.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 +8 -0
- package/dist/components/select/Select.d.ts +3 -18
- package/dist/punkt-react.cjs +1 -1
- package/dist/punkt-react.js +1677 -1667
- package/dist/shared-types/index.d.ts +2 -1
- package/dist/shared-types/select.d.ts +57 -0
- package/package.json +3 -3
- package/src/components/select/Select.tsx +13 -26
|
@@ -50,7 +50,8 @@ export { defaultTimepickerStrings } from './timepicker';
|
|
|
50
50
|
export type { TProgressbarRole, TProgressbarSkin, TProgressbarStatusPlacement, TProgressbarStatusType, TProgressbarTitlePosition, } from './progressbar';
|
|
51
51
|
export { COMBOBOX_TAG_SKINS, COMBOBOX_DISPLAY_VALUES, COMBOBOX_TAG_PLACEMENTS, COMBOBOX_DEFAULTS, } from './combobox';
|
|
52
52
|
export type { IPktComboboxOption, TPktComboboxTagSkin, TPktComboboxDisplayValue, TPktComboboxTagPlacement, IPktComboboxBase, IComboboxSpecProps, } from './combobox';
|
|
53
|
-
export
|
|
53
|
+
export { SELECT_DEFAULTS } from './select';
|
|
54
|
+
export type { IPktSelectOption, TSelectOption, IPktSelectBase, ISelectSpecProps } from './select';
|
|
54
55
|
export type { TPktSearchInputAppearance, TPktSearchInputMethod, IPktSearchInputSuggestion, IPktSearchInput, } from './searchinput';
|
|
55
56
|
export { UPLOAD_STRATEGIES, FILE_UPLOAD_ITEM_RENDERERS, PREVIEW_UPLOAD_STATUS } from './fileupload';
|
|
56
57
|
export type { TUploadStrategy as TFileUploadStrategy, TFileUploadItemRenderer, TPreviewUploadStatus, TFilesChangedReason, TFileValidator, TTransferProgress, IFileItem, IFileTransfer, IFileValidateDetail, ITransferCancelledDetail, IFilesChangedDetail, IFileUploadSpecProps, IPktFileUploadBase, } from './fileupload';
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* select.ts
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for pkt-select.
|
|
5
|
+
* Used by React, Elements, and typed component specs.
|
|
6
|
+
*/
|
|
7
|
+
import type { IPktStringsProps } from '../shared-strings';
|
|
8
|
+
import type { IFormFieldErrorProps, IFormFieldLabelProps, IHelptextProps, ITagOptionalRequiredProps } from './form-field';
|
|
9
|
+
import type { TPktInputSize } from './size';
|
|
1
10
|
/**
|
|
2
11
|
* Shape of a single option in a `<pkt-select>` / `<PktSelect>` component.
|
|
3
12
|
* Lives in shared-types so both `@oslokommune/punkt-elements` and
|
|
@@ -11,3 +20,51 @@ export interface IPktSelectOption {
|
|
|
11
20
|
hidden?: boolean;
|
|
12
21
|
}
|
|
13
22
|
export type TSelectOption = IPktSelectOption;
|
|
23
|
+
/**
|
|
24
|
+
* Select props shared by React, Elements, and typed component specs.
|
|
25
|
+
*
|
|
26
|
+
* @remarks React requires `id` and `label`, widens `helptext`, `helptextDropdown` and
|
|
27
|
+
* `errorMessage` to `ReactNode`, keeps the native `<select>` type for `value` (string, number
|
|
28
|
+
* or string array) and omits `options`. Elements widens `label`, `ariaDescribedby`, `ariaLabelledby`
|
|
29
|
+
* and `helptextDropdownButton` to `| null` (Lit uses `null` for an unset attribute),
|
|
30
|
+
* `useWrapper` to `Booleanish`, and omits `form`, which is a getter returning the associated
|
|
31
|
+
* `HTMLFormElement`, not the form id.
|
|
32
|
+
*
|
|
33
|
+
* `hasFieldset` is tri-state: `null` means the component derives the value (always `false`
|
|
34
|
+
* for select).
|
|
35
|
+
*/
|
|
36
|
+
export interface IPktSelectBase extends IFormFieldLabelProps, IHelptextProps, IFormFieldErrorProps, ITagOptionalRequiredProps, IPktStringsProps<'forms' | 'validation'> {
|
|
37
|
+
id?: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
form?: string;
|
|
40
|
+
value?: string;
|
|
41
|
+
options?: IPktSelectOption[];
|
|
42
|
+
required?: boolean;
|
|
43
|
+
ariaDescribedby?: string;
|
|
44
|
+
ariaLabelledby?: string;
|
|
45
|
+
inline?: boolean;
|
|
46
|
+
fullwidth?: boolean;
|
|
47
|
+
useWrapper?: boolean;
|
|
48
|
+
hasFieldset?: boolean | null;
|
|
49
|
+
inputSize?: TPktInputSize;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Documented Select props (subset of `IPktSelectBase`).
|
|
53
|
+
* Used for typed component specs in documentation.
|
|
54
|
+
*/
|
|
55
|
+
export type ISelectSpecProps = Pick<IPktSelectBase, 'label' | 'required' | 'requiredTag' | 'requiredText' | 'optionalTag' | 'optionalText' | 'tagText' | 'hasError' | 'errorMessage' | 'helptext' | 'helptextDropdown' | 'helptextDropdownButton' | 'name' | 'form' | 'id' | 'value' | 'options' | 'disabled' | 'inline' | 'useWrapper' | 'fullwidth' | 'ariaDescribedby' | 'ariaLabelledby' | 'inputSize' | 'hasFieldset'>;
|
|
56
|
+
/**
|
|
57
|
+
* Default values for pkt-select. Single source of truth for both frameworks.
|
|
58
|
+
* `hasFieldset` is intentionally absent — `null` lets the component derive it.
|
|
59
|
+
*/
|
|
60
|
+
export declare const SELECT_DEFAULTS: {
|
|
61
|
+
readonly disabled: false;
|
|
62
|
+
readonly required: false;
|
|
63
|
+
readonly hasError: false;
|
|
64
|
+
readonly requiredTag: false;
|
|
65
|
+
readonly optionalTag: false;
|
|
66
|
+
readonly inline: false;
|
|
67
|
+
readonly fullwidth: false;
|
|
68
|
+
readonly useWrapper: true;
|
|
69
|
+
readonly inputSize: 'medium';
|
|
70
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.13.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.13.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": "d8c349f200dd685cc1911a6baf5ce43012cee404"
|
|
105
105
|
}
|
|
@@ -5,34 +5,21 @@ import { ForwardedRef, forwardRef, ReactNode, SelectHTMLAttributes } from 'react
|
|
|
5
5
|
import { PktInputWrapper } from '../inputwrapper/InputWrapper'
|
|
6
6
|
import { describedByIds } from 'shared-utils/forms/described-by'
|
|
7
7
|
import { useGeneratedId } from '../../hooks/useGeneratedId'
|
|
8
|
-
import type
|
|
8
|
+
import { SELECT_DEFAULTS, type IPktSelectBase } from 'shared-types'
|
|
9
9
|
|
|
10
10
|
export type { IPktSelectOption, TSelectOption } from 'shared-types/select'
|
|
11
11
|
|
|
12
12
|
export interface IPktSelectProps
|
|
13
|
-
extends
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
extends
|
|
14
|
+
Omit<IPktSelectBase, 'helptext' | 'helptextDropdown' | 'errorMessage' | 'value' | 'options'>,
|
|
15
|
+
Omit<SelectHTMLAttributes<HTMLSelectElement>, keyof IPktSelectBase> {
|
|
16
16
|
children?: ReactNode | ReactNode[]
|
|
17
|
-
disabled?: boolean
|
|
18
17
|
errorMessage?: string | ReactNode | ReactNode[]
|
|
19
|
-
hasError?: boolean
|
|
20
18
|
helptext?: string | ReactNode | ReactNode[]
|
|
21
19
|
helptextDropdown?: string | ReactNode | ReactNode[]
|
|
22
|
-
helptextDropdownButton?: string
|
|
23
20
|
id: string
|
|
24
|
-
inline?: boolean
|
|
25
|
-
fullwidth?: boolean
|
|
26
21
|
label: string
|
|
27
|
-
|
|
28
|
-
optionalTag?: boolean
|
|
29
|
-
optionalText?: string
|
|
30
|
-
requiredTag?: boolean
|
|
31
|
-
requiredText?: string
|
|
32
|
-
tagText?: string | null
|
|
33
|
-
useWrapper?: boolean
|
|
34
|
-
hasFieldset?: boolean
|
|
35
|
-
inputSize?: 'small' | 'medium' | 'xsmall'
|
|
22
|
+
value?: SelectHTMLAttributes<HTMLSelectElement>['value']
|
|
36
23
|
/** @deprecated Var aldri implementert — bruk children med `<option>`-elementer. */
|
|
37
24
|
options?: never
|
|
38
25
|
}
|
|
@@ -44,25 +31,25 @@ export const PktSelect = forwardRef(
|
|
|
44
31
|
ariaLabelledby,
|
|
45
32
|
children,
|
|
46
33
|
className,
|
|
47
|
-
disabled =
|
|
34
|
+
disabled = SELECT_DEFAULTS.disabled,
|
|
48
35
|
errorMessage,
|
|
49
|
-
hasError =
|
|
36
|
+
hasError = SELECT_DEFAULTS.hasError,
|
|
50
37
|
helptext,
|
|
51
38
|
helptextDropdown,
|
|
52
39
|
helptextDropdownButton,
|
|
53
40
|
id: idProp,
|
|
54
|
-
inline =
|
|
55
|
-
fullwidth =
|
|
41
|
+
inline = SELECT_DEFAULTS.inline,
|
|
42
|
+
fullwidth = SELECT_DEFAULTS.fullwidth,
|
|
56
43
|
label,
|
|
57
44
|
name,
|
|
58
|
-
optionalTag =
|
|
45
|
+
optionalTag = SELECT_DEFAULTS.optionalTag,
|
|
59
46
|
optionalText,
|
|
60
|
-
requiredTag =
|
|
47
|
+
requiredTag = SELECT_DEFAULTS.requiredTag,
|
|
61
48
|
requiredText,
|
|
62
49
|
tagText,
|
|
63
|
-
useWrapper =
|
|
50
|
+
useWrapper = SELECT_DEFAULTS.useWrapper,
|
|
64
51
|
hasFieldset,
|
|
65
|
-
inputSize =
|
|
52
|
+
inputSize = SELECT_DEFAULTS.inputSize,
|
|
66
53
|
strings,
|
|
67
54
|
...props
|
|
68
55
|
}: IPktSelectProps,
|