@oslokommune/punkt-react 13.6.15 → 13.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 +41 -0
- package/dist/index.d.ts +38 -74
- package/dist/punkt-react.es.js +5358 -35971
- package/dist/punkt-react.umd.js +418 -548
- package/package.json +11 -15
- package/src/components/accordion/Accordion.test.tsx +1 -1
- package/src/components/accordion/Accordion.tsx +1 -1
- package/src/components/accordion/AccordionItem.tsx +6 -5
- package/src/components/alert/Alert.tsx +2 -1
- package/src/components/breadcrumbs/Breadcrumbs.test.tsx +16 -4
- package/src/components/breadcrumbs/Breadcrumbs.tsx +3 -2
- package/src/components/button/Button.tsx +3 -2
- package/src/components/checkbox/Checkbox.tsx +4 -3
- package/src/components/datepicker/Datepicker.test.tsx +393 -0
- package/src/components/footer/Footer.tsx +6 -5
- package/src/components/footerSimple/FooterSimple.tsx +4 -3
- package/src/components/icon/Icon.test.tsx +6 -19
- package/src/components/index.ts +0 -2
- package/src/components/input/Input.tsx +4 -3
- package/src/components/radio/RadioButton.tsx +3 -2
- package/src/components/searchinput/SearchInput.tsx +3 -3
- package/src/components/stepper/Stepper.tsx +6 -6
- package/src/components/table/Table.tsx +2 -1
- package/src/components/table/TableBody.tsx +2 -1
- package/src/components/table/TableData.tsx +2 -1
- package/src/components/table/TableDataCell.tsx +2 -1
- package/src/components/table/TableHeader.tsx +2 -1
- package/src/components/table/TableHeaderCell.tsx +2 -1
- package/src/components/table/TableRow.tsx +2 -1
- package/src/components/tag/Tag.tsx +2 -1
- package/src/components/preview/Preview.tsx +0 -274
- package/src/components/preview/PreviewCode.tsx +0 -118
- package/src/components/preview/PreviewPropEditor.tsx +0 -266
- package/src/components/preview/PreviewSpecs.tsx +0 -125
- package/src/components/preview/PreviewWithJson.tsx +0 -519
- package/src/components/preview/preview-types.ts +0 -42
- package/src/components/preview/preview-utils.ts +0 -226
- package/src/components/preview/previewJson/accordion.json +0 -84
- package/src/components/preview/previewJson/alert.json +0 -27
- package/src/components/preview/previewJson/backlink.json +0 -14
- package/src/components/preview/previewJson/breadcrumbs.json +0 -17
- package/src/components/preview/previewJson/button.json +0 -28
- package/src/components/preview/previewJson/card.json +0 -41
- package/src/components/preview/previewJson/checkbox.json +0 -21
- package/src/components/preview/previewJson/combobox.json +0 -24
- package/src/components/preview/previewJson/consent.json +0 -14
- package/src/components/preview/previewJson/datepicker.json +0 -14
- package/src/components/preview/previewJson/footer-simple.json +0 -17
- package/src/components/preview/previewJson/footer.json +0 -29
- package/src/components/preview/previewJson/header.json +0 -34
- package/src/components/preview/previewJson/icon.json +0 -13
- package/src/components/preview/previewJson/input-wrapper.json +0 -39
- package/src/components/preview/previewJson/link.json +0 -28
- package/src/components/preview/previewJson/linkcard.json +0 -30
- package/src/components/preview/previewJson/loader.json +0 -28
- package/src/components/preview/previewJson/messagebox.json +0 -28
- package/src/components/preview/previewJson/modal.json +0 -65
- package/src/components/preview/previewJson/progressbar.json +0 -16
- package/src/components/preview/previewJson/radiobutton.json +0 -21
- package/src/components/preview/previewJson/searchinput.json +0 -20
- package/src/components/preview/previewJson/select.json +0 -73
- package/src/components/preview/previewJson/steps.json +0 -72
- package/src/components/preview/previewJson/table.json +0 -130
- package/src/components/preview/previewJson/tabs.json +0 -33
- package/src/components/preview/previewJson/tag.json +0 -26
- package/src/components/preview/previewJson/textarea.json +0 -18
- package/src/components/preview/previewJson/textinput.json +0 -18
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import * as prettier from 'prettier/standalone'
|
|
2
|
-
import * as parserHtml from 'prettier/parser-html'
|
|
3
|
-
import { TPreviewTreeNode, TSpecs, TPropObject } from './preview-types'
|
|
4
|
-
|
|
5
|
-
// Konverterer f.eks. PktButton til pkt-button
|
|
6
|
-
export function toKebabCase(str: string) {
|
|
7
|
-
if (!str) return ''
|
|
8
|
-
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Fjerner ugyldige tegn fra kode
|
|
12
|
-
// Hjelper f.eks. med å unngå parsing-feil i Prettier
|
|
13
|
-
export function sanitizeCode(code: string) {
|
|
14
|
-
return code.replace(/[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD]/g, '')
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Bygger kode for HTML/CSS
|
|
18
|
-
export async function buildHtmlCode(html: string): Promise<string> {
|
|
19
|
-
return await prettier.format(html, {
|
|
20
|
-
parser: 'html',
|
|
21
|
-
plugins: [parserHtml as any],
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Finner spesifikasjons-nøkkelen for en node
|
|
26
|
-
export function getSpecKeyForNode(node: any, previewSpec: any): string | undefined {
|
|
27
|
-
if (!node || !previewSpec) return undefined
|
|
28
|
-
if (node.type === previewSpec.type) return previewSpec.spec
|
|
29
|
-
if (Array.isArray(previewSpec.children)) {
|
|
30
|
-
const childDef = previewSpec.children.find((c: any) => c.type === node.type)
|
|
31
|
-
if (childDef?.spec) return childDef.spec
|
|
32
|
-
}
|
|
33
|
-
// Fallback: bruk node.type som spec key hvis den finnes i specs
|
|
34
|
-
return node.type
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Legger til specs-strenger per node i preview-JSON
|
|
38
|
-
export function attachSpecStrings(node: TPreviewTreeNode, previewSpec: TSpecs): TPreviewTreeNode {
|
|
39
|
-
if (!node || typeof node !== 'object') return node
|
|
40
|
-
|
|
41
|
-
// Finn riktig previewSpec for denne node-typen
|
|
42
|
-
let nodeSpec = previewSpec
|
|
43
|
-
if (node.type !== previewSpec.type && Array.isArray(previewSpec.children)) {
|
|
44
|
-
nodeSpec = previewSpec.children.find((c) => c.type === node.type) || previewSpec
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Legg til spesifikasjons-strengen hvis den finnes og er en streng
|
|
48
|
-
const specString = nodeSpec && typeof nodeSpec.spec === 'string' ? nodeSpec.spec : undefined
|
|
49
|
-
|
|
50
|
-
// Prosesser barn rekursivt
|
|
51
|
-
let children = node.children
|
|
52
|
-
if (Array.isArray(children)) {
|
|
53
|
-
children = children.map((child) => attachSpecStrings(child, nodeSpec))
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
...node,
|
|
58
|
-
...(specString ? { spec: specString } : {}),
|
|
59
|
-
...(children ? { children } : {}),
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Normaliserer barn for å sikre konsekvent struktur
|
|
64
|
-
export function normalizeChildren(children: any): any[] {
|
|
65
|
-
if (Array.isArray(children)) {
|
|
66
|
-
return children.map((child, i) => {
|
|
67
|
-
if (child && typeof child === 'object') {
|
|
68
|
-
if (child.type === 'text') {
|
|
69
|
-
return {
|
|
70
|
-
...child,
|
|
71
|
-
id: child.id ?? `child-${i}`,
|
|
72
|
-
children: typeof child.children === 'string' ? child.children : '',
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return child.id ? child : { ...child, id: child?.id || `child-${i}` }
|
|
76
|
-
}
|
|
77
|
-
return child
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
if (typeof children === 'string' && children.trim() !== '') {
|
|
81
|
-
return [{ type: 'text', children, id: `text-0` }]
|
|
82
|
-
}
|
|
83
|
-
return []
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Finner tillatte barn av en node fra spesifikasjonen
|
|
87
|
-
export function getAllowedChildren(previewSpec: any): any[] {
|
|
88
|
-
if (!previewSpec) return []
|
|
89
|
-
if (Array.isArray(previewSpec.children)) return previewSpec.children
|
|
90
|
-
if (previewSpec.children && typeof previewSpec.children === 'object') return [previewSpec.children]
|
|
91
|
-
return []
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Oppdaterer et trestruktur-objekt immutabelt basert på en gitt sti og ny verdi.
|
|
95
|
-
export function updateTree(tree: any, path: (string | number)[], value: any): any {
|
|
96
|
-
if (path.length === 0) return value
|
|
97
|
-
const [head, ...rest] = path
|
|
98
|
-
if (Array.isArray(tree)) {
|
|
99
|
-
const newArr = [...tree]
|
|
100
|
-
newArr[head as number] = updateTree(tree[head as number], rest, value)
|
|
101
|
-
return newArr
|
|
102
|
-
} else {
|
|
103
|
-
if (head === 'children' && rest.length === 0) {
|
|
104
|
-
if (typeof value === 'string') {
|
|
105
|
-
// Pakk inn som tekst-node hvis forelderen ikke allerede er en tekst-node
|
|
106
|
-
if (tree.type !== 'text') {
|
|
107
|
-
return { ...tree, children: [{ type: 'text', children: value, id: `text-${Date.now()}` }] }
|
|
108
|
-
}
|
|
109
|
-
// Hvis forelder er en tekst-node, oppdater bare children-feltet med ren tekst
|
|
110
|
-
return { ...tree, children: value }
|
|
111
|
-
}
|
|
112
|
-
if (Array.isArray(value)) {
|
|
113
|
-
return { ...tree, children: value }
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return {
|
|
117
|
-
...tree,
|
|
118
|
-
[head]: updateTree(tree[head], rest, value),
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Formatter et JSON-streng med innrykk
|
|
124
|
-
export function formatAsIndentedJson(obj: any, indent: number = 0): string {
|
|
125
|
-
const pad = ' '.repeat(indent)
|
|
126
|
-
return JSON.stringify(obj, null, 2)
|
|
127
|
-
.split('\n')
|
|
128
|
-
.map((line, i) => (i === 0 ? line : pad + line))
|
|
129
|
-
.join('\n')
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Kodevisning: Bygger attributter for både Elements og React
|
|
133
|
-
function buildAttributes(node: TPreviewTreeNode, specs: TSpecs, indent: number, mode: 'react' | 'elements'): string {
|
|
134
|
-
const props = node.props || {}
|
|
135
|
-
const attrEntries = Object.entries(props).filter(([k, v]) => v !== undefined && v !== null && k !== 'children')
|
|
136
|
-
const startString = ' '.repeat(indent + 2)
|
|
137
|
-
return attrEntries
|
|
138
|
-
.map(([k, v]) => {
|
|
139
|
-
const specKey = node.spec || node.type
|
|
140
|
-
const propSpec = specs[specKey]?.props?.[k] || {}
|
|
141
|
-
if (typeof v === 'object' && v !== null && v.displayAsFalse) {
|
|
142
|
-
if (v.value) return startString + k
|
|
143
|
-
return startString + (mode === 'react' ? `${k}={false}` : `${k}="false"`)
|
|
144
|
-
}
|
|
145
|
-
if (typeof v === 'boolean') {
|
|
146
|
-
if (v) return startString + k
|
|
147
|
-
if ((propSpec as TPropObject).displayAsFalse)
|
|
148
|
-
return startString + (mode === 'react' ? `${k}={false}` : `${k}="false"`)
|
|
149
|
-
return ''
|
|
150
|
-
}
|
|
151
|
-
if (mode === 'react') {
|
|
152
|
-
return startString + (typeof v === 'object' ? `${k}={${formatAsIndentedJson(v, indent + 2)}}` : `${k}="${v}"`)
|
|
153
|
-
}
|
|
154
|
-
// elements
|
|
155
|
-
return typeof v === 'object' ? `${startString}${k}='${formatAsIndentedJson(v, indent + 2)}'` : `${k}="${v}"`
|
|
156
|
-
})
|
|
157
|
-
.filter(Boolean)
|
|
158
|
-
.join('\n')
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Kodevisning: Bygger children for både Elements og React
|
|
162
|
-
function buildChildren(
|
|
163
|
-
node: TPreviewTreeNode,
|
|
164
|
-
specs: TSpecs,
|
|
165
|
-
indent: number,
|
|
166
|
-
builder: (n: TPreviewTreeNode, s: TSpecs, i: number, r: boolean) => string,
|
|
167
|
-
): { childrenArr: string[]; children: string; hasChildren: boolean } {
|
|
168
|
-
const childrenArr = Array.isArray(node.children)
|
|
169
|
-
? node.children.map((c) => builder(c, specs, indent + 2, node.type !== 'option'))
|
|
170
|
-
: node.children
|
|
171
|
-
? [builder(node.children, specs, indent + 2, node.type !== 'option')]
|
|
172
|
-
: []
|
|
173
|
-
const filtered = childrenArr.filter((c) => (typeof c === 'string' ? c.trim() !== '' : true))
|
|
174
|
-
const children = filtered.join('')
|
|
175
|
-
const hasChildren = filtered.some((c) => (typeof c === 'string' ? c.trim() !== '' : !!c))
|
|
176
|
-
return { childrenArr: filtered, children, hasChildren }
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Bygger kode for Punkt Elements
|
|
180
|
-
export function buildElementsCode(
|
|
181
|
-
node: TPreviewTreeNode,
|
|
182
|
-
specs: TSpecs,
|
|
183
|
-
indent = 0,
|
|
184
|
-
renderStringWithSpan: boolean = true,
|
|
185
|
-
): string {
|
|
186
|
-
if (typeof node === 'string') return node
|
|
187
|
-
if (!node || !node.type) return ''
|
|
188
|
-
if (node.type === 'text' && !renderStringWithSpan) {
|
|
189
|
-
return typeof node.children === 'string' ? node.children : ''
|
|
190
|
-
}
|
|
191
|
-
const spec = specs[node.type] || {}
|
|
192
|
-
const tag = node.type === 'text' ? 'span' : spec.name || toKebabCase(node.type)
|
|
193
|
-
if (!tag) return ''
|
|
194
|
-
const attrs = buildAttributes(node, specs, indent, 'elements')
|
|
195
|
-
const { children } = buildChildren(node, specs, indent, buildElementsCode)
|
|
196
|
-
const space = ' '.repeat(indent)
|
|
197
|
-
if (children) {
|
|
198
|
-
return `${space}<${tag}${attrs ? '\n' + space + attrs : ''}>\n${children}\n${space}</${tag}>`
|
|
199
|
-
}
|
|
200
|
-
return `${space}<${tag}${attrs ? '\n' + space + attrs + '\n' + space : ''}></${tag}>`
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Bygger kode for Punkt React
|
|
204
|
-
export function buildReactCode(
|
|
205
|
-
node: TPreviewTreeNode,
|
|
206
|
-
specs: TSpecs,
|
|
207
|
-
indent = 0,
|
|
208
|
-
renderStringWithSpan: boolean = true,
|
|
209
|
-
): string {
|
|
210
|
-
if (typeof node === 'string' && (node as string).trim() !== '') {
|
|
211
|
-
return '\n' + ' '.repeat(indent) + node
|
|
212
|
-
}
|
|
213
|
-
if (!node || !node.type) return ''
|
|
214
|
-
if (node.type === 'text' && !renderStringWithSpan) {
|
|
215
|
-
return typeof node.children === 'string' ? '\n' + ' '.repeat(indent) + node.children : ''
|
|
216
|
-
}
|
|
217
|
-
const tag = node.type === 'text' ? 'span' : node.type
|
|
218
|
-
if (!tag) return ''
|
|
219
|
-
const attrs = buildAttributes(node, specs, indent, 'react')
|
|
220
|
-
const { children, hasChildren } = buildChildren(node, specs, indent, buildReactCode)
|
|
221
|
-
const space = ' '.repeat(indent)
|
|
222
|
-
if (hasChildren) {
|
|
223
|
-
return `\n${space}<${tag}${attrs ? '\n' + attrs : ''}>${children}\n${space}</${tag}>`
|
|
224
|
-
}
|
|
225
|
-
return `\n${space}<${tag}${attrs ? '\n' + attrs + '\n' + space : ''} />`
|
|
226
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "AccordionPreview",
|
|
3
|
-
"type": "PktAccordion",
|
|
4
|
-
"spec": "accordion",
|
|
5
|
-
"previewProps": ["skin", "compact"],
|
|
6
|
-
"children": [
|
|
7
|
-
{
|
|
8
|
-
"name": "AccordionItem",
|
|
9
|
-
"type": "PktAccordionItem",
|
|
10
|
-
"spec": "accordionItem",
|
|
11
|
-
"defaults": {
|
|
12
|
-
"title": "Accordion $n",
|
|
13
|
-
"id": "accordion-item-$n"
|
|
14
|
-
},
|
|
15
|
-
"children": [
|
|
16
|
-
{
|
|
17
|
-
"name": "Innhold",
|
|
18
|
-
"type": "text"
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
"preview": {
|
|
24
|
-
"type": "PktAccordion",
|
|
25
|
-
"props": {
|
|
26
|
-
"skin": "outlined"
|
|
27
|
-
},
|
|
28
|
-
"children": [
|
|
29
|
-
{
|
|
30
|
-
"type": "PktAccordionItem",
|
|
31
|
-
"props": {
|
|
32
|
-
"title": "Hva er åpningstidene?",
|
|
33
|
-
"id": "apningstid",
|
|
34
|
-
"isOpen": true
|
|
35
|
-
},
|
|
36
|
-
"children": [
|
|
37
|
-
{
|
|
38
|
-
"type": "text",
|
|
39
|
-
"children": "Vi åpner om morgenen når vi føler oss klar for det, og stenger når middagen er klar!"
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"type": "PktAccordionItem",
|
|
45
|
-
"props": {
|
|
46
|
-
"title": "Hva er dresscode?",
|
|
47
|
-
"id": "dresscode"
|
|
48
|
-
},
|
|
49
|
-
"children": [
|
|
50
|
-
{
|
|
51
|
-
"type": "text",
|
|
52
|
-
"children": "Vi sier som i Texas: No shirt? No shoes? No service!"
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"type": "PktAccordionItem",
|
|
58
|
-
"props": {
|
|
59
|
-
"title": "Kan jeg ta med mat og drikke?",
|
|
60
|
-
"id": "mat-og-drikke"
|
|
61
|
-
},
|
|
62
|
-
"children": [
|
|
63
|
-
{
|
|
64
|
-
"type": "text",
|
|
65
|
-
"children": "Bare hvis vi får smake!"
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
"type": "PktAccordionItem",
|
|
71
|
-
"props": {
|
|
72
|
-
"title": "Kan jeg ta med kjæledyr?",
|
|
73
|
-
"id": "kjaeledyr"
|
|
74
|
-
},
|
|
75
|
-
"children": [
|
|
76
|
-
{
|
|
77
|
-
"type": "text",
|
|
78
|
-
"children": "Vi tillater kun pelsdyr som mjauer!"
|
|
79
|
-
}
|
|
80
|
-
]
|
|
81
|
-
}
|
|
82
|
-
]
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "AlertPreview",
|
|
3
|
-
"type": "PktAlert",
|
|
4
|
-
"spec": "alert",
|
|
5
|
-
"previewProps": ["title", "skin", "compact", "closeAlert"],
|
|
6
|
-
"children": [
|
|
7
|
-
{
|
|
8
|
-
"name": "Innhold",
|
|
9
|
-
"type": "text"
|
|
10
|
-
}
|
|
11
|
-
],
|
|
12
|
-
"preview": {
|
|
13
|
-
"type": "PktAlert",
|
|
14
|
-
"props": {
|
|
15
|
-
"title": "Dette er en alert",
|
|
16
|
-
"skin": "info",
|
|
17
|
-
"compact": false,
|
|
18
|
-
"closeAlert": false
|
|
19
|
-
},
|
|
20
|
-
"children": [
|
|
21
|
-
{
|
|
22
|
-
"type": "text",
|
|
23
|
-
"children": "Dette er innholdet i meldingen."
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "BackLinkPreview",
|
|
3
|
-
"type": "PktBackLink",
|
|
4
|
-
"spec": "backlink",
|
|
5
|
-
"previewProps": ["href", "text", "ariaLabel"],
|
|
6
|
-
"preview": {
|
|
7
|
-
"type": "PktBackLink",
|
|
8
|
-
"props": {
|
|
9
|
-
"href": "/",
|
|
10
|
-
"text": "Tilbake til søknaden",
|
|
11
|
-
"ariaLabel": "Gå tilbake til forrige steg"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "BreadcrumbsPreview",
|
|
3
|
-
"type": "PktBreadcrumbs",
|
|
4
|
-
"spec": "breadcrumbs",
|
|
5
|
-
"previewProps": ["breadcrumbs"],
|
|
6
|
-
"preview": {
|
|
7
|
-
"type": "PktBreadcrumbs",
|
|
8
|
-
"props": {
|
|
9
|
-
"breadcrumbs": [
|
|
10
|
-
{ "text": "Hjem", "href": "/" },
|
|
11
|
-
{ "text": "Produkter", "href": "/produkter" },
|
|
12
|
-
{ "text": "Detaljer", "href": "/produkter/123" }
|
|
13
|
-
],
|
|
14
|
-
"navigationType": "anchor"
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ButtonPreview",
|
|
3
|
-
"type": "PktButton",
|
|
4
|
-
"spec": "button",
|
|
5
|
-
"previewProps": ["skin", "size", "iconName"],
|
|
6
|
-
"children": [
|
|
7
|
-
{
|
|
8
|
-
"name": "Innhold",
|
|
9
|
-
"type": "text"
|
|
10
|
-
}
|
|
11
|
-
],
|
|
12
|
-
"preview": {
|
|
13
|
-
"type": "PktButton",
|
|
14
|
-
"props": {
|
|
15
|
-
"skin": "primary",
|
|
16
|
-
"size": "large",
|
|
17
|
-
"variant": "icon-left",
|
|
18
|
-
"iconName": "heart",
|
|
19
|
-
"disabled": false
|
|
20
|
-
},
|
|
21
|
-
"children": [
|
|
22
|
-
{
|
|
23
|
-
"type": "text",
|
|
24
|
-
"children": "Dette er en knapp"
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "CardPreview",
|
|
3
|
-
"type": "PktCard",
|
|
4
|
-
"spec": "card",
|
|
5
|
-
"previewProps": ["heading", "subheading", "skin", "layout"],
|
|
6
|
-
"children": [
|
|
7
|
-
{
|
|
8
|
-
"name": "Innhold",
|
|
9
|
-
"type": "text"
|
|
10
|
-
}
|
|
11
|
-
],
|
|
12
|
-
"preview": {
|
|
13
|
-
"type": "PktCard",
|
|
14
|
-
"props": {
|
|
15
|
-
"heading": "Card heading",
|
|
16
|
-
"subheading": "Card subheading",
|
|
17
|
-
"skin": "outlined",
|
|
18
|
-
"layout": "vertical",
|
|
19
|
-
"tags": [
|
|
20
|
-
{
|
|
21
|
-
"text": "Tag 1",
|
|
22
|
-
"skin": "blue"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"text": "Tag 2",
|
|
26
|
-
"skin": "green"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"image": {
|
|
30
|
-
"src": "https://placecats.com/neo_banana/300/200",
|
|
31
|
-
"alt": "Bilde av politiet"
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"children": [
|
|
35
|
-
{
|
|
36
|
-
"type": "text",
|
|
37
|
-
"children": "<p>Dette er innholdet i kortet</p>"
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "CheckboxPreview",
|
|
3
|
-
"type": "PktCheckbox",
|
|
4
|
-
"spec": "checkbox",
|
|
5
|
-
"previewProps": ["label", "checkHelptext", "checked", "hasTile", "isSwitch"],
|
|
6
|
-
"preview": {
|
|
7
|
-
"type": "PktCheckbox",
|
|
8
|
-
"props": {
|
|
9
|
-
"id": "checkbox-1",
|
|
10
|
-
"name": "gruppe1",
|
|
11
|
-
"label": "Godta vilkår",
|
|
12
|
-
"checkHelptext": "Dette er hjelpetekst for checkboxen.",
|
|
13
|
-
"value": "vilkar",
|
|
14
|
-
"defaultChecked": false,
|
|
15
|
-
"checked": false,
|
|
16
|
-
"disabled": false,
|
|
17
|
-
"hasError": false,
|
|
18
|
-
"isSwitch": false
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ComboboxPreview",
|
|
3
|
-
"type": "PktCombobox",
|
|
4
|
-
"spec": "combobox",
|
|
5
|
-
"previewProps": ["label", "helptext", "multiple", "typeahead", "allowUserInput"],
|
|
6
|
-
"preview": {
|
|
7
|
-
"type": "PktCombobox",
|
|
8
|
-
"props": {
|
|
9
|
-
"label": "Velg bydel",
|
|
10
|
-
"placeholder": "Søk eller velg…",
|
|
11
|
-
"multiple": false,
|
|
12
|
-
"typeahead": true,
|
|
13
|
-
"allowUserInput": true,
|
|
14
|
-
"value": "bgr",
|
|
15
|
-
"options": [
|
|
16
|
-
{ "value": "bfr", "label": "Frogner" },
|
|
17
|
-
{ "value": "bgo", "label": "Gamle Oslo" },
|
|
18
|
-
{ "value": "bgr", "label": "Grorud" },
|
|
19
|
-
{ "value": "bxx", "label": "Andre bydeler" }
|
|
20
|
-
],
|
|
21
|
-
"useWrapper": true
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ConsentPreview",
|
|
3
|
-
"type": "PktConsent",
|
|
4
|
-
"spec": "consent",
|
|
5
|
-
"previewProps": ["triggerType", "triggerText"],
|
|
6
|
-
"preview": {
|
|
7
|
-
"type": "PktConsent",
|
|
8
|
-
"props": {
|
|
9
|
-
"triggerType": "button",
|
|
10
|
-
"triggerText": "Endre samtykke",
|
|
11
|
-
"devMode": true
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "DatepickerPreview",
|
|
3
|
-
"type": "PktDatepicker",
|
|
4
|
-
"spec": "datepicker",
|
|
5
|
-
"previewProps": ["label", "helptext", "currentmonth", "multiple", "range"],
|
|
6
|
-
"preview": {
|
|
7
|
-
"type": "PktDatepicker",
|
|
8
|
-
"props": {
|
|
9
|
-
"label": "Velg dato",
|
|
10
|
-
"multiple": true,
|
|
11
|
-
"useWrapper": true
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "FooterSimplePreview",
|
|
3
|
-
"type": "PktFooterSimple",
|
|
4
|
-
"spec": "footer-simple",
|
|
5
|
-
"previewProps": ["personvernOgInfoLink", "tilgjengelighetLink", "includeConsent"],
|
|
6
|
-
"preview": {
|
|
7
|
-
"type": "PktFooterSimple",
|
|
8
|
-
"props": {
|
|
9
|
-
"personvernOgInfoLink": "/personvern-og-informasjon",
|
|
10
|
-
"tilgjengelighetLink": "/tilgjengelighet",
|
|
11
|
-
"links": [
|
|
12
|
-
{ "href": "/om", "text": "Om oss", "external": false },
|
|
13
|
-
{ "href": "https://oslo.kommune.no", "text": "Oslo kommune", "external": true }
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "FooterPreview",
|
|
3
|
-
"type": "PktFooter",
|
|
4
|
-
"spec": "footer",
|
|
5
|
-
"previewProps": ["personvernOgInfoLink", "tilgjengelighetLink", "includeConsent"],
|
|
6
|
-
"preview": {
|
|
7
|
-
"type": "PktFooter",
|
|
8
|
-
"props": {
|
|
9
|
-
"includeConsent": false,
|
|
10
|
-
"googleAnalyticsId": "",
|
|
11
|
-
"hotjarId": "",
|
|
12
|
-
"columnOne": {
|
|
13
|
-
"title": "Om oss",
|
|
14
|
-
"links": [
|
|
15
|
-
{ "href": "/om", "text": "Om oss", "external": false },
|
|
16
|
-
{ "href": "/kontakt", "text": "Kontakt", "external": false },
|
|
17
|
-
{ "href": "https://oslo.kommune.no", "text": "Oslo kommune", "external": true }
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
|
-
"columnTwo": {
|
|
21
|
-
"title": "Tjenester",
|
|
22
|
-
"links": [
|
|
23
|
-
{ "href": "/tjenester", "text": "Tjenester", "external": false },
|
|
24
|
-
{ "href": "/hjelp", "text": "Hjelp", "external": false }
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "HeaderPreview",
|
|
3
|
-
"type": "PktHeader",
|
|
4
|
-
"spec": "header",
|
|
5
|
-
"previewProps": ["logoLink", "serviceName", "showLogOutButton"],
|
|
6
|
-
"preview": {
|
|
7
|
-
"type": "PktHeader",
|
|
8
|
-
"props": {
|
|
9
|
-
"logoLink": "https://www.oslo.kommune.no/",
|
|
10
|
-
"serviceName": "Min tjeneste",
|
|
11
|
-
"fixed": false,
|
|
12
|
-
"scrollToHide": false,
|
|
13
|
-
"user": {
|
|
14
|
-
"name": "Ola Nordmann",
|
|
15
|
-
"shortname": "ON",
|
|
16
|
-
"lastLoggedIn": "2025-06-27 14:30"
|
|
17
|
-
},
|
|
18
|
-
"userMenu": [
|
|
19
|
-
{ "iconName": "user", "title": "Min profil", "target": "/profil" },
|
|
20
|
-
{ "iconName": "cogwheel", "title": "Innstillinger", "target": "/innstillinger" }
|
|
21
|
-
],
|
|
22
|
-
"userMenuFooter": [{ "title": "Logg ut", "target": "/logout" }],
|
|
23
|
-
"userOptions": [{ "iconName": "sound-on", "title": "Varsler", "target": "/varsler" }],
|
|
24
|
-
"representing": {
|
|
25
|
-
"name": "Oslo kommune",
|
|
26
|
-
"shortname": "OK",
|
|
27
|
-
"orgNumber": "123456789"
|
|
28
|
-
},
|
|
29
|
-
"canChangeRepresentation": false,
|
|
30
|
-
"showLogOutButton": true,
|
|
31
|
-
"showMenuButton": false
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "InputWrapperPreview",
|
|
3
|
-
"type": "PktInputWrapper",
|
|
4
|
-
"spec": "input-wrapper",
|
|
5
|
-
"previewProps": [
|
|
6
|
-
"label",
|
|
7
|
-
"helptext",
|
|
8
|
-
"errorMessage",
|
|
9
|
-
"hasError",
|
|
10
|
-
"required",
|
|
11
|
-
"requiredTag",
|
|
12
|
-
"requiredText",
|
|
13
|
-
"optionalTag",
|
|
14
|
-
"optionalText",
|
|
15
|
-
"fullwidth"
|
|
16
|
-
],
|
|
17
|
-
"children": [
|
|
18
|
-
{
|
|
19
|
-
"name": "Innhold",
|
|
20
|
-
"type": "text"
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
"preview": {
|
|
24
|
-
"type": "PktInputWrapper",
|
|
25
|
-
"props": {
|
|
26
|
-
"label": "Feltetikett",
|
|
27
|
-
"helptext": "Dette er hjelpetekst.",
|
|
28
|
-
"errorMessage": "",
|
|
29
|
-
"hasError": false,
|
|
30
|
-
"required": false,
|
|
31
|
-
"requiredTag": false,
|
|
32
|
-
"requiredText": "",
|
|
33
|
-
"optionalTag": false,
|
|
34
|
-
"optionalText": "",
|
|
35
|
-
"fullwidth": false
|
|
36
|
-
},
|
|
37
|
-
"children": "Her kan du skrive inn tekst"
|
|
38
|
-
}
|
|
39
|
-
}
|