@oslokommune/punkt-react 19.12.3 → 19.14.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 +16 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/select/Select.d.ts +3 -18
- package/dist/components/table/Table.d.ts +5 -8
- package/dist/components/table/TableDataCell.d.ts +3 -5
- package/dist/punkt-react.cjs +1 -1
- package/dist/punkt-react.js +1722 -1708
- package/dist/shared-types/index.d.ts +4 -1
- package/dist/shared-types/select.d.ts +57 -0
- package/dist/shared-types/table.d.ts +51 -0
- package/package.json +3 -3
- package/src/components/index.ts +3 -0
- package/src/components/select/Select.tsx +13 -26
- package/src/components/table/Table.tsx +8 -10
- package/src/components/table/TableBody.tsx +1 -1
- package/src/components/table/TableDataCell.tsx +3 -4
- package/dist/components/table/TableData.d.ts +0 -7
- package/src/components/table/TableData.tsx +0 -15
|
@@ -50,7 +50,10 @@ 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';
|
|
55
|
+
export { TABLE_SKINS, TABLE_DEFAULTS } from './table';
|
|
56
|
+
export type { TPktTableSkin, IPktTableBase, ITableSpecProps, IPktTableDataCellBase, ITableDataCellSpecProps, ITableSectionSpecProps, } from './table';
|
|
54
57
|
export type { TPktSearchInputAppearance, TPktSearchInputMethod, IPktSearchInputSuggestion, IPktSearchInput, } from './searchinput';
|
|
55
58
|
export { UPLOAD_STRATEGIES, FILE_UPLOAD_ITEM_RENDERERS, PREVIEW_UPLOAD_STATUS } from './fileupload';
|
|
56
59
|
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
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* table.ts
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for pkt-table and its sub-components.
|
|
5
|
+
* Used by React and typed component specs. There is no Elements version —
|
|
6
|
+
* outside React the table is used as plain HTML with the `pkt-table` CSS classes.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Visual skins for pkt-table — shared runtime source for types, specs, and Preview.
|
|
10
|
+
*/
|
|
11
|
+
export declare const TABLE_SKINS: readonly ['basic', 'zebra-blue'];
|
|
12
|
+
export type TPktTableSkin = (typeof TABLE_SKINS)[number];
|
|
13
|
+
/**
|
|
14
|
+
* Table props shared by React and typed component specs.
|
|
15
|
+
*/
|
|
16
|
+
export interface IPktTableBase {
|
|
17
|
+
compact?: boolean;
|
|
18
|
+
skin?: TPktTableSkin;
|
|
19
|
+
responsiveView?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Documented Table props (subset of `IPktTableBase`).
|
|
23
|
+
* Used for typed component specs in documentation.
|
|
24
|
+
*/
|
|
25
|
+
export type ITableSpecProps = Pick<IPktTableBase, 'compact' | 'skin' | 'responsiveView'>;
|
|
26
|
+
/**
|
|
27
|
+
* Default values for pkt-table. Single source of truth.
|
|
28
|
+
*/
|
|
29
|
+
export declare const TABLE_DEFAULTS: {
|
|
30
|
+
readonly compact: false;
|
|
31
|
+
readonly skin: 'basic';
|
|
32
|
+
readonly responsiveView: true;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Table data cell props shared by React and typed component specs.
|
|
36
|
+
*
|
|
37
|
+
* @remarks `dataLabel` is rendered as `data-label` and shown next to the cell content
|
|
38
|
+
* when the table is responsive. Without it, the cell has no label on small screens.
|
|
39
|
+
*/
|
|
40
|
+
export interface IPktTableDataCellBase {
|
|
41
|
+
dataLabel?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Documented TableDataCell props (subset of `IPktTableDataCellBase`).
|
|
45
|
+
* Used for typed component specs in documentation.
|
|
46
|
+
*/
|
|
47
|
+
export type ITableDataCellSpecProps = Pick<IPktTableDataCellBase, 'dataLabel'>;
|
|
48
|
+
/**
|
|
49
|
+
* Header, body, row and header cell have no props of their own beyond native HTML attributes.
|
|
50
|
+
*/
|
|
51
|
+
export type ITableSectionSpecProps = Record<never, never>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.14.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": "7540b380894153213d8b712e82bcc1c6f824e7ad"
|
|
105
105
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -46,6 +46,9 @@ export { PktTableDataCell } from './table/TableDataCell'
|
|
|
46
46
|
export { PktTableHeader } from './table/TableHeader'
|
|
47
47
|
export { PktTableHeaderCell } from './table/TableHeaderCell'
|
|
48
48
|
export { PktTableRow } from './table/TableRow'
|
|
49
|
+
export type { IPktTable } from './table/Table'
|
|
50
|
+
export type { IPktTableDataCell } from './table/TableDataCell'
|
|
51
|
+
export type { TPktTableSkin } from 'shared-types'
|
|
49
52
|
export { PktTabs } from './tabs/Tabs'
|
|
50
53
|
export { PktTabItem } from './tabs/TabItem'
|
|
51
54
|
export { PktTag } from './tag/Tag'
|
|
@@ -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,
|
|
@@ -2,25 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import type { HTMLAttributes, ReactNode } from 'react'
|
|
5
|
+
import { TABLE_DEFAULTS, type IPktTableBase, type TPktTableSkin } from 'shared-types'
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
/** @deprecated Bruk `TPktTableSkin`. */
|
|
8
|
+
export type TTableSkin = TPktTableSkin
|
|
7
9
|
|
|
8
|
-
interface
|
|
9
|
-
compact?: boolean
|
|
10
|
-
skin?: 'basic' | 'zebra-blue'
|
|
11
|
-
responsiveView?: boolean
|
|
12
|
-
className?: string
|
|
10
|
+
export interface IPktTable extends IPktTableBase, HTMLAttributes<HTMLTableElement> {
|
|
13
11
|
children: ReactNode
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
export const PktTable = ({
|
|
17
15
|
className,
|
|
18
|
-
compact =
|
|
19
|
-
skin =
|
|
20
|
-
responsiveView =
|
|
16
|
+
compact = TABLE_DEFAULTS.compact,
|
|
17
|
+
skin = TABLE_DEFAULTS.skin,
|
|
18
|
+
responsiveView = TABLE_DEFAULTS.responsiveView,
|
|
21
19
|
children,
|
|
22
20
|
...props
|
|
23
|
-
}:
|
|
21
|
+
}: IPktTable) => {
|
|
24
22
|
return (
|
|
25
23
|
<table
|
|
26
24
|
data-testid="pkt-table"
|
|
@@ -9,7 +9,7 @@ interface ITableBodyProps extends HTMLAttributes<HTMLTableSectionElement> {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export const PktTableBody = ({ id, children, className, ...props }: ITableBodyProps) => (
|
|
12
|
-
<tbody id={id} className={classNames(className, 'pkt-table__body', {})} {...props}
|
|
12
|
+
<tbody id={id} className={classNames(className, 'pkt-table__body', {})} role="rowgroup" {...props} >
|
|
13
13
|
{children}
|
|
14
14
|
</tbody>
|
|
15
15
|
)
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import type { HTMLAttributes, ReactNode } from 'react'
|
|
5
|
+
import type { IPktTableDataCellBase } from 'shared-types'
|
|
5
6
|
|
|
6
|
-
interface
|
|
7
|
-
className?: string
|
|
7
|
+
export interface IPktTableDataCell extends IPktTableDataCellBase, HTMLAttributes<HTMLTableCellElement> {
|
|
8
8
|
children?: ReactNode
|
|
9
|
-
dataLabel?: string
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
export const PktTableDataCell = ({ children, className, dataLabel, ...props }:
|
|
11
|
+
export const PktTableDataCell = ({ children, className, dataLabel, ...props }: IPktTableDataCell) => (
|
|
13
12
|
<td
|
|
14
13
|
className={classNames(className, 'pkt-table__data-cell', {})}
|
|
15
14
|
data-label={dataLabel}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
interface TableDataProps extends HTMLAttributes<HTMLTableCellElement> {
|
|
3
|
-
className?: string;
|
|
4
|
-
children: ReactNode | ReactNode[];
|
|
5
|
-
}
|
|
6
|
-
export declare const PktTableData: ({ children, className, ...props }: TableDataProps) => import("react").JSX.Element;
|
|
7
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import classNames from 'classnames'
|
|
4
|
-
import type { HTMLAttributes, ReactNode } from 'react'
|
|
5
|
-
|
|
6
|
-
interface TableDataProps extends HTMLAttributes<HTMLTableCellElement> {
|
|
7
|
-
className?: string
|
|
8
|
-
children: ReactNode | ReactNode[]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const PktTableData = ({ children, className, ...props }: TableDataProps) => (
|
|
12
|
-
<td className={classNames(className, 'pkt-table__th')} {...props} role="cell">
|
|
13
|
-
{children}
|
|
14
|
-
</td>
|
|
15
|
-
)
|