@ks-digital/designsystem-angular 0.0.1-alpha.25 → 0.0.1-alpha.28
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/__internals/index.d.ts +54 -0
- package/alert/index.d.ts +17 -0
- package/button/index.d.ts +29 -0
- package/card/index.d.ts +22 -0
- package/details/index.d.ts +26 -0
- package/fesm2022/ks-digital-designsystem-angular-__internals.mjs +50 -0
- package/fesm2022/ks-digital-designsystem-angular-__internals.mjs.map +1 -0
- package/fesm2022/ks-digital-designsystem-angular-alert.mjs +35 -0
- package/fesm2022/ks-digital-designsystem-angular-alert.mjs.map +1 -0
- package/fesm2022/ks-digital-designsystem-angular-button.mjs +63 -0
- package/fesm2022/ks-digital-designsystem-angular-button.mjs.map +1 -0
- package/fesm2022/ks-digital-designsystem-angular-card.mjs +70 -0
- package/fesm2022/ks-digital-designsystem-angular-card.mjs.map +1 -0
- package/fesm2022/ks-digital-designsystem-angular-details.mjs +100 -0
- package/fesm2022/ks-digital-designsystem-angular-details.mjs.map +1 -0
- package/fesm2022/ks-digital-designsystem-angular-forms.mjs +408 -0
- package/fesm2022/ks-digital-designsystem-angular-forms.mjs.map +1 -0
- package/fesm2022/ks-digital-designsystem-angular-paragraph.mjs +24 -0
- package/fesm2022/ks-digital-designsystem-angular-paragraph.mjs.map +1 -0
- package/fesm2022/ks-digital-designsystem-angular-popover.mjs +165 -0
- package/fesm2022/ks-digital-designsystem-angular-popover.mjs.map +1 -0
- package/fesm2022/ks-digital-designsystem-angular-search.mjs +181 -0
- package/fesm2022/ks-digital-designsystem-angular-search.mjs.map +1 -0
- package/fesm2022/ks-digital-designsystem-angular-spinner.mjs +89 -0
- package/fesm2022/ks-digital-designsystem-angular-spinner.mjs.map +1 -0
- package/fesm2022/ks-digital-designsystem-angular-validation-message.mjs +25 -0
- package/fesm2022/ks-digital-designsystem-angular-validation-message.mjs.map +1 -0
- package/fesm2022/ks-digital-designsystem-angular.mjs +7 -0
- package/fesm2022/ks-digital-designsystem-angular.mjs.map +1 -0
- package/forms/index.d.ts +100 -0
- package/index.d.ts +2 -0
- package/package.json +59 -20
- package/paragraph/index.d.ts +8 -0
- package/popover/index.d.ts +25 -0
- package/search/index.d.ts +84 -0
- package/spinner/index.d.ts +25 -0
- package/validation-message/index.d.ts +8 -0
- package/.storybook/customTheme.ts +0 -15
- package/.storybook/default-args.ts +0 -18
- package/.storybook/main.ts +0 -27
- package/.storybook/manager.ts +0 -10
- package/.storybook/preview-head.html +0 -16
- package/.storybook/preview.ts +0 -70
- package/.storybook/themes.ts +0 -9
- package/.storybook/tsconfig.json +0 -16
- package/.storybook/vite.config.mts +0 -5
- package/eslint.config.mjs +0 -28
- package/ng-package.json +0 -9
- package/project.json +0 -81
- package/src/components/alert/alert.mdx +0 -46
- package/src/components/alert/alert.spec.ts +0 -33
- package/src/components/alert/alert.stories.ts +0 -138
- package/src/components/alert/alert.ts +0 -46
- package/src/components/alert/index.ts +0 -1
- package/src/components/button/button.mdx +0 -40
- package/src/components/button/button.spec.ts +0 -86
- package/src/components/button/button.stories.ts +0 -123
- package/src/components/button/button.ts +0 -60
- package/src/components/button/index.ts +0 -1
- package/src/components/card/card-block.ts +0 -10
- package/src/components/card/card.mdx +0 -100
- package/src/components/card/card.spec.ts +0 -70
- package/src/components/card/card.stories.ts +0 -101
- package/src/components/card/card.ts +0 -44
- package/src/components/card/index.ts +0 -2
- package/src/components/checkbox/README.md +0 -13
- package/src/components/checkbox/checkbox.mdx +0 -50
- package/src/components/checkbox/checkbox.spec.ts +0 -21
- package/src/components/checkbox/checkbox.stories.ts +0 -182
- package/src/components/checkbox/index.ts +0 -0
- package/src/components/colors.ts +0 -36
- package/src/components/common-inputs.ts +0 -30
- package/src/components/details/controlled-details.ts +0 -63
- package/src/components/details/details-content.ts +0 -7
- package/src/components/details/details-summary.ts +0 -7
- package/src/components/details/details.mdx +0 -89
- package/src/components/details/details.spec.ts +0 -56
- package/src/components/details/details.stories.ts +0 -129
- package/src/components/details/details.ts +0 -69
- package/src/components/details/index.ts +0 -3
- package/src/components/field/field-counter.ts +0 -56
- package/src/components/field/field-description.ts +0 -10
- package/src/components/field/field-error.ts +0 -13
- package/src/components/field/field-observer.ts +0 -121
- package/src/components/field/field-state.ts +0 -21
- package/src/components/field/field.mdx +0 -40
- package/src/components/field/field.spec.ts +0 -131
- package/src/components/field/field.stories.ts +0 -98
- package/src/components/field/field.ts +0 -70
- package/src/components/field/index.ts +0 -3
- package/src/components/fieldset/fieldset-description.ts +0 -8
- package/src/components/fieldset/fieldset-legend.ts +0 -11
- package/src/components/fieldset/fieldset.spec.ts +0 -80
- package/src/components/fieldset/fieldset.ts +0 -11
- package/src/components/fieldset/index.ts +0 -3
- package/src/components/input/index.ts +0 -1
- package/src/components/input/input.mdx +0 -11
- package/src/components/input/input.spec.ts +0 -25
- package/src/components/input/input.stories.ts +0 -72
- package/src/components/input/input.ts +0 -67
- package/src/components/label/index.ts +0 -1
- package/src/components/label/label.ts +0 -17
- package/src/components/paragraph/index.ts +0 -1
- package/src/components/paragraph/paragraph.ts +0 -10
- package/src/components/popover/controlled-popover.ts +0 -62
- package/src/components/popover/index.ts +0 -1
- package/src/components/popover/popover.mdx +0 -81
- package/src/components/popover/popover.spec.ts +0 -143
- package/src/components/popover/popover.stories.ts +0 -63
- package/src/components/popover/popover.ts +0 -186
- package/src/components/radio/radio.mdx +0 -117
- package/src/components/radio/radio.stories.ts +0 -226
- package/src/components/search/index.ts +0 -4
- package/src/components/search/search-button.ts +0 -35
- package/src/components/search/search-clear.ts +0 -57
- package/src/components/search/search-input.ts +0 -18
- package/src/components/search/search.mdx +0 -56
- package/src/components/search/search.spec.ts +0 -48
- package/src/components/search/search.stories.ts +0 -205
- package/src/components/search/search.ts +0 -50
- package/src/components/spinner/index.ts +0 -1
- package/src/components/spinner/spinner.mdx +0 -24
- package/src/components/spinner/spinner.spec.ts +0 -13
- package/src/components/spinner/spinner.stories.ts +0 -54
- package/src/components/spinner/spinner.ts +0 -62
- package/src/components/switch/switch.mdx +0 -82
- package/src/components/switch/switch.stories.ts +0 -94
- package/src/components/textarea/textarea.mdx +0 -14
- package/src/components/textarea/textarea.stories.ts +0 -52
- package/src/components/validation-message/index.ts +0 -1
- package/src/components/validation-message/validation-message.ts +0 -11
- package/src/index.ts +0 -14
- package/src/test-setup.ts +0 -12
- package/src/utils/log-if-devmode.ts +0 -13
- package/src/utils/random-id.ts +0 -3
- package/tsconfig.json +0 -34
- package/tsconfig.lib.json +0 -28
- package/tsconfig.lib.prod.json +0 -9
- package/tsconfig.spec.json +0 -30
- package/vite.config.mts +0 -35
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { afterNextRender, Component, contentChild } from '@angular/core'
|
|
2
|
-
import { logIfDevMode } from '../../utils/log-if-devmode'
|
|
3
|
-
import { CommonInputs } from '../common-inputs'
|
|
4
|
-
import { SearchInput } from './search-input'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Search Component
|
|
8
|
-
*
|
|
9
|
-
* Use to contain the search input and buttons.
|
|
10
|
-
* Only `SearchInput` is required, while `SearchClear` and `SearchButton` are optional.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* <div ksd-search>
|
|
14
|
-
* <input ksd-search-input />
|
|
15
|
-
* <button ksd-search-clear></button>
|
|
16
|
-
* <button ksd-search-button></button>
|
|
17
|
-
* </div>
|
|
18
|
-
*/
|
|
19
|
-
@Component({
|
|
20
|
-
selector: 'ksd-search',
|
|
21
|
-
template: `
|
|
22
|
-
<ng-content select="[ksd-search-input]" />
|
|
23
|
-
<ng-content select="[ksd-search-clear]" />
|
|
24
|
-
<ng-content select="[ksd-search-button]" />
|
|
25
|
-
`,
|
|
26
|
-
host: {
|
|
27
|
-
class: 'ds-search',
|
|
28
|
-
},
|
|
29
|
-
hostDirectives: [
|
|
30
|
-
{
|
|
31
|
-
directive: CommonInputs,
|
|
32
|
-
inputs: ['data-size', 'data-color'],
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
})
|
|
36
|
-
export class Search {
|
|
37
|
-
private readonly input = contentChild(SearchInput)
|
|
38
|
-
|
|
39
|
-
constructor() {
|
|
40
|
-
afterNextRender(() => {
|
|
41
|
-
if (!this.input()) {
|
|
42
|
-
logIfDevMode({
|
|
43
|
-
component: 'Search',
|
|
44
|
-
message:
|
|
45
|
-
'Missing required elements: ksd-search-input must be provided as child. Check imports and markup.',
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Spinner } from './spinner'
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Meta, Primary, Controls, Canvas } from '@storybook/addon-docs/blocks'
|
|
2
|
-
|
|
3
|
-
import * as SpinnerStories from './spinner.stories'
|
|
4
|
-
|
|
5
|
-
<Meta of={SpinnerStories} />
|
|
6
|
-
|
|
7
|
-
# Spinner
|
|
8
|
-
|
|
9
|
-
`Spinner` brukes for å indikere at en handling pågår. Dette kan være når vi venter på at et skjema skal sendes inn.
|
|
10
|
-
|
|
11
|
-
<Primary />
|
|
12
|
-
<Controls />
|
|
13
|
-
|
|
14
|
-
## Størrelser
|
|
15
|
-
|
|
16
|
-
Du kan justere størrelsen på `Spinner` etter hvor den skal plasseres.
|
|
17
|
-
Størrelsen vil være mindre i knapper, men større dersom den er ved et skjemafelt.
|
|
18
|
-
|
|
19
|
-
<Canvas of={SpinnerStories.Sizes} />
|
|
20
|
-
|
|
21
|
-
## Tilgjengelighet
|
|
22
|
-
|
|
23
|
-
Når brukeren har `prefers-reduced-motion` satt til `reduce` vil spinneren ha en animasjon på 6 sekunder.
|
|
24
|
-
Animasjonen er ikke dekorativ, og vi skrur den derfor ikke av.
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/angular'
|
|
2
|
-
import { Spinner } from './spinner'
|
|
3
|
-
|
|
4
|
-
it('should render a spinner with title "loading"', async () => {
|
|
5
|
-
await render(
|
|
6
|
-
`
|
|
7
|
-
<ksd-spinner aria-label="Loading">
|
|
8
|
-
`,
|
|
9
|
-
{ imports: [Spinner] },
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
expect(screen.getByLabelText('Loading')).toBeInTheDocument()
|
|
13
|
-
})
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
argsToTemplate,
|
|
3
|
-
moduleMetadata,
|
|
4
|
-
type Meta,
|
|
5
|
-
type StoryObj,
|
|
6
|
-
} from '@storybook/angular'
|
|
7
|
-
import { CommonArgs } from '../../../.storybook/default-args'
|
|
8
|
-
import { Spinner } from './spinner'
|
|
9
|
-
|
|
10
|
-
type SpinnerArgs = CommonArgs
|
|
11
|
-
|
|
12
|
-
const meta: Meta<SpinnerArgs> = {
|
|
13
|
-
component: Spinner,
|
|
14
|
-
title: 'Komponenter/Loaders/Spinner',
|
|
15
|
-
decorators: [
|
|
16
|
-
moduleMetadata({
|
|
17
|
-
imports: [Spinner],
|
|
18
|
-
}),
|
|
19
|
-
],
|
|
20
|
-
}
|
|
21
|
-
export default meta
|
|
22
|
-
type Story = StoryObj<SpinnerArgs>
|
|
23
|
-
|
|
24
|
-
export const Preview: Story = {
|
|
25
|
-
args: {
|
|
26
|
-
'data-size': 'md',
|
|
27
|
-
'data-color': undefined,
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
render: (args) => ({
|
|
31
|
-
props: args,
|
|
32
|
-
template: `
|
|
33
|
-
<ksd-spinner ${argsToTemplate(args)} data-size="xl" />
|
|
34
|
-
`,
|
|
35
|
-
}),
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const Sizes: Story = {
|
|
39
|
-
args: {
|
|
40
|
-
...Preview.args,
|
|
41
|
-
'data-size': undefined,
|
|
42
|
-
},
|
|
43
|
-
render: (args) => ({
|
|
44
|
-
props: args,
|
|
45
|
-
template: `
|
|
46
|
-
<ksd-spinner aria-label="Laster" ${argsToTemplate(args)} data-size="2xs" />
|
|
47
|
-
<ksd-spinner aria-label="Laster" ${argsToTemplate(args)} data-size="xs" />
|
|
48
|
-
<ksd-spinner aria-label="Laster" ${argsToTemplate(args)} data-size="sm" />
|
|
49
|
-
<ksd-spinner aria-label="Laster" ${argsToTemplate(args)} data-size="md" />
|
|
50
|
-
<ksd-spinner aria-label="Laster" ${argsToTemplate(args)} data-size="lg" />
|
|
51
|
-
<ksd-spinner aria-label="Laster" ${argsToTemplate(args)} data-size="xl" />
|
|
52
|
-
`,
|
|
53
|
-
}),
|
|
54
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @angular-eslint/no-input-rename */
|
|
2
|
-
import { booleanAttribute, Component, input } from '@angular/core'
|
|
3
|
-
import { Size } from '../common-inputs'
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'ksd-spinner',
|
|
7
|
-
styles: `
|
|
8
|
-
:host {
|
|
9
|
-
display: contents;
|
|
10
|
-
}
|
|
11
|
-
`,
|
|
12
|
-
template: `
|
|
13
|
-
<svg
|
|
14
|
-
class="ds-spinner"
|
|
15
|
-
role="img"
|
|
16
|
-
viewBox="0 0 50 50"
|
|
17
|
-
[attr.data-size]="dataSize()"
|
|
18
|
-
[attr.data-color]="dataColor()"
|
|
19
|
-
>
|
|
20
|
-
<circle
|
|
21
|
-
class="ds-spinner__background"
|
|
22
|
-
cx="25"
|
|
23
|
-
cy="25"
|
|
24
|
-
r="20"
|
|
25
|
-
fill="none"
|
|
26
|
-
stroke-width="5"
|
|
27
|
-
/>
|
|
28
|
-
<circle
|
|
29
|
-
class="ds-spinner__circle"
|
|
30
|
-
cx="25"
|
|
31
|
-
cy="25"
|
|
32
|
-
r="20"
|
|
33
|
-
fill="none"
|
|
34
|
-
stroke-width="5"
|
|
35
|
-
/>
|
|
36
|
-
</svg>
|
|
37
|
-
`,
|
|
38
|
-
})
|
|
39
|
-
export class Spinner {
|
|
40
|
-
/**
|
|
41
|
-
* Aria-label for the spinner
|
|
42
|
-
*/
|
|
43
|
-
readonly ariaLabel = input<string>(undefined, { alias: 'aria-label' })
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Aria-label for the spinner
|
|
47
|
-
*/
|
|
48
|
-
readonly dataSize = input<Size>(undefined, { alias: 'data-size' })
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Aria-label for the spinner
|
|
52
|
-
*/
|
|
53
|
-
readonly dataColor = input<Size>(undefined, { alias: 'data-color' })
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Aria-hidden for the spinner
|
|
57
|
-
*/
|
|
58
|
-
readonly ariaHidden = input(undefined, {
|
|
59
|
-
transform: booleanAttribute,
|
|
60
|
-
alias: 'aria-hidden',
|
|
61
|
-
})
|
|
62
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Meta, Primary, Controls, Canvas } from '@storybook/addon-docs/blocks'
|
|
2
|
-
|
|
3
|
-
import * as SwitchStories from './switch.stories'
|
|
4
|
-
|
|
5
|
-
<Meta of={SwitchStories} />
|
|
6
|
-
|
|
7
|
-
# Switch
|
|
8
|
-
|
|
9
|
-
`Switch` brukes til å gi brukeren et valg mellom to alternativer. Bryteren kan enten slås av eller på og skal alltid være innstilt med et standardvalg
|
|
10
|
-
|
|
11
|
-
<Primary />
|
|
12
|
-
<Controls />
|
|
13
|
-
|
|
14
|
-
## Bruk
|
|
15
|
-
|
|
16
|
-
```html
|
|
17
|
-
<ksd-field>
|
|
18
|
-
<ksd-label>Min switch</ksd-label>
|
|
19
|
-
<input ksd-input type="checkbox" role="switch" />
|
|
20
|
-
</ksd-field>
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Kodeeksempler
|
|
24
|
-
|
|
25
|
-
**Gruppering**
|
|
26
|
-
|
|
27
|
-
Bruk `Fieldset`for å gruppere fler `Switch`-komponenter sammen
|
|
28
|
-
|
|
29
|
-
<Canvas of={SwitchStories.Grouped} />
|
|
30
|
-
|
|
31
|
-
**Høyre justering**
|
|
32
|
-
|
|
33
|
-
Plasser `label` etter `input` for å plassere `Switch` til høyre side av ledeteksten hvis du trenger det.
|
|
34
|
-
|
|
35
|
-
<Canvas of={SwitchStories.RightAligned} />
|
|
36
|
-
|
|
37
|
-
## Retningslinjer
|
|
38
|
-
|
|
39
|
-
`Switch`skal være et valg mellom to alternativer. Vi bruker `Switch` til innstillinger, ikke i skjema.
|
|
40
|
-
|
|
41
|
-
**Passer til:**
|
|
42
|
-
|
|
43
|
-
- aktivere eller deaktivere funksjoner/tilstander med en gang
|
|
44
|
-
- slå varsler av og på
|
|
45
|
-
|
|
46
|
-
**Passer ikke til:**
|
|
47
|
-
|
|
48
|
-
- å bruke i stedet for `Checkbox` eller `Radio` i et skjema
|
|
49
|
-
- situasjoner der brukerne må lagre informasjon før en endring får effekt
|
|
50
|
-
- endre visning av innhold mellom to kategorier
|
|
51
|
-
|
|
52
|
-
**Bruk heller**
|
|
53
|
-
|
|
54
|
-
- `Checkbox` hvis du skal tilby brukerne flere valg, der de skal velge ett eller flere alternativer
|
|
55
|
-
- `Radio` hvis brukerne skal få flere valg, men bare skal velge ett
|
|
56
|
-
- `Chip til å filtrere innhold
|
|
57
|
-
|
|
58
|
-
## Tekst
|
|
59
|
-
|
|
60
|
-
Teksten til en `Switch` må være kort og presis, ofte betyr det bare ett eller to ord. Det skal gi mening når du sier ledeteksten høyt og legger til av/på etterpå. Unngå tekst med flere ord og mellomrom.
|
|
61
|
-
|
|
62
|
-
Hvis du har flere `Switch` i en gruppe, må du passe på at du er konsekvent med hvordan du formulerer tekstene til hver av dem også, ikke formulerer dem forskjellig.
|
|
63
|
-
|
|
64
|
-
Teksten skal beskrive hva funksjonen gjelder, ikke om den er på eller av. Hvis statusen skrives inn i labelen, kan det bli forvirrende og vanskelig å vite hvilken tilstand switchen faktisk er i.
|
|
65
|
-
|
|
66
|
-
**Eksempel 1**
|
|
67
|
-
|
|
68
|
-
- Riktig: Varsle på epost (Av/på)
|
|
69
|
-
- Feil: Skru av varsel på epost (Av/på)
|
|
70
|
-
|
|
71
|
-
**Eksempel 2**
|
|
72
|
-
|
|
73
|
-
- Riktig: Flymodus (Av/på)
|
|
74
|
-
- Feil: Skru på flymodus (Av/på)
|
|
75
|
-
|
|
76
|
-
**Plassering av tekst**
|
|
77
|
-
|
|
78
|
-
Som regel er det høyre som er den beste plasseringen for tekst, unntaket er når `Switch er fast plassert på høyre side i grensesnittet er det best at teksten er på venstre side. Slik at alle knappene blir justert etter samme vertikale
|
|
79
|
-
|
|
80
|
-
## Tilgjengelighet
|
|
81
|
-
|
|
82
|
-
Vi bruker `role="switch"` for å fortelle skjermlesere at dette er en vippebryter. Dette gjør at skjermlesere kan gi brukeren informasjon om at dette er en vippebryter og at den kan skrus av og på. Det er ikke lagt på `aria-checked` siden dette er ikke nødvendig når bryteren er en input med `type="checkbox".
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
argsToTemplate,
|
|
3
|
-
moduleMetadata,
|
|
4
|
-
type Meta,
|
|
5
|
-
type StoryObj,
|
|
6
|
-
} from '@storybook/angular'
|
|
7
|
-
import { CommonArgs } from '../../../.storybook/default-args'
|
|
8
|
-
import { Field } from '../field/field'
|
|
9
|
-
import { FieldDescription } from '../field/field-description'
|
|
10
|
-
import { Fieldset } from '../fieldset/fieldset'
|
|
11
|
-
import { FieldsetDescription } from '../fieldset/fieldset-description'
|
|
12
|
-
import { FieldsetLegend } from '../fieldset/fieldset-legend'
|
|
13
|
-
import { Input } from '../input/input'
|
|
14
|
-
import { Label } from '../label/label'
|
|
15
|
-
import { ValidationMessage } from '../validation-message'
|
|
16
|
-
|
|
17
|
-
type SwitchArgs = CommonArgs & {
|
|
18
|
-
readonly: boolean
|
|
19
|
-
disabled: boolean
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const meta: Meta<SwitchArgs> = {
|
|
23
|
-
component: Input,
|
|
24
|
-
title: 'Komponenter/Switch',
|
|
25
|
-
decorators: [
|
|
26
|
-
moduleMetadata({
|
|
27
|
-
imports: [
|
|
28
|
-
Label,
|
|
29
|
-
Field,
|
|
30
|
-
Input,
|
|
31
|
-
FieldDescription,
|
|
32
|
-
Fieldset,
|
|
33
|
-
FieldsetLegend,
|
|
34
|
-
FieldsetDescription,
|
|
35
|
-
ValidationMessage,
|
|
36
|
-
],
|
|
37
|
-
}),
|
|
38
|
-
],
|
|
39
|
-
}
|
|
40
|
-
export default meta
|
|
41
|
-
type Story = StoryObj<SwitchArgs>
|
|
42
|
-
|
|
43
|
-
export const Preview: Story = {
|
|
44
|
-
args: {
|
|
45
|
-
readonly: false,
|
|
46
|
-
disabled: false,
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
render: (args) => ({
|
|
50
|
-
props: args,
|
|
51
|
-
template: `
|
|
52
|
-
<ksd-field>
|
|
53
|
-
<ksd-label>Min switch</ksd-label>
|
|
54
|
-
<input ksd-input role="switch" type="checkbox" ${argsToTemplate(args)} role="switch"/>
|
|
55
|
-
</ksd-field>
|
|
56
|
-
`,
|
|
57
|
-
}),
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export const Grouped: Story = {
|
|
61
|
-
render: () => ({
|
|
62
|
-
template: `
|
|
63
|
-
<fieldset ksd-fieldset>
|
|
64
|
-
<legend ksd-fieldset-legend> Skru av/på lys </legend>
|
|
65
|
-
<ksd-field>
|
|
66
|
-
<ksd-label>Stue</ksd-label>
|
|
67
|
-
<input ksd-input type="checkbox" role="switch" checked=${true} />
|
|
68
|
-
</ksd-field>
|
|
69
|
-
<ksd-field>
|
|
70
|
-
<ksd-label>Kjøkken</ksd-label>
|
|
71
|
-
<input ksd-input type="checkbox" role="switch"/>
|
|
72
|
-
</ksd-field>
|
|
73
|
-
<ksd-field>
|
|
74
|
-
<ksd-label>Bad</ksd-label>
|
|
75
|
-
<input ksd-input type="checkbox" role="switch"/>
|
|
76
|
-
</ksd-field>
|
|
77
|
-
<ksd-field>
|
|
78
|
-
<ksd-label>Soverom</ksd-label>
|
|
79
|
-
<input ksd-input type="checkbox" role="switch" />
|
|
80
|
-
</ksd-field>
|
|
81
|
-
</fieldset>`,
|
|
82
|
-
}),
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export const RightAligned: Story = {
|
|
86
|
-
render: () => ({
|
|
87
|
-
template: `
|
|
88
|
-
<ksd-field>
|
|
89
|
-
<input ksd-input role="switch" type="checkbox" role="switch"/>
|
|
90
|
-
<ksd-label>Min switch</ksd-label>
|
|
91
|
-
</ksd-field>
|
|
92
|
-
`,
|
|
93
|
-
}),
|
|
94
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Meta, Primary, Controls, Story } from '@storybook/addon-docs/blocks'
|
|
2
|
-
|
|
3
|
-
import * as TextareaStories from './textarea.stories'
|
|
4
|
-
|
|
5
|
-
<Meta of={TextareaStories} />
|
|
6
|
-
|
|
7
|
-
# Textarea
|
|
8
|
-
|
|
9
|
-
`Textarea` brukes når brukeren skal kunne skrive inn tekst som går over flere linjer.
|
|
10
|
-
|
|
11
|
-
<Primary />
|
|
12
|
-
<Controls />
|
|
13
|
-
|
|
14
|
-
## Bruk
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
argsToTemplate,
|
|
3
|
-
moduleMetadata,
|
|
4
|
-
type Meta,
|
|
5
|
-
type StoryObj,
|
|
6
|
-
} from '@storybook/angular'
|
|
7
|
-
import { CommonArgs } from '../../../.storybook/default-args'
|
|
8
|
-
import { Field } from '../field/field'
|
|
9
|
-
import { Input } from '../input/input'
|
|
10
|
-
import { Label } from '../label/label'
|
|
11
|
-
|
|
12
|
-
type TextareaArgs = CommonArgs & {
|
|
13
|
-
readonly: boolean
|
|
14
|
-
disabled: boolean
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const meta: Meta<TextareaArgs> = {
|
|
18
|
-
component: Input,
|
|
19
|
-
title: 'Komponenter/Textarea',
|
|
20
|
-
decorators: [
|
|
21
|
-
moduleMetadata({
|
|
22
|
-
imports: [Label, Field, Input],
|
|
23
|
-
}),
|
|
24
|
-
],
|
|
25
|
-
}
|
|
26
|
-
export default meta
|
|
27
|
-
type Story = StoryObj<TextareaArgs>
|
|
28
|
-
|
|
29
|
-
export const Preview: Story = {
|
|
30
|
-
args: {
|
|
31
|
-
readonly: false,
|
|
32
|
-
disabled: false,
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
render: (args) => ({
|
|
36
|
-
props: args,
|
|
37
|
-
template: `
|
|
38
|
-
<div style="
|
|
39
|
-
display: flex;
|
|
40
|
-
flex-direction: column;
|
|
41
|
-
gap: var(--ds-size-2);
|
|
42
|
-
max-width: 100%;
|
|
43
|
-
width: 20rem
|
|
44
|
-
" >
|
|
45
|
-
<ksd-field>
|
|
46
|
-
<ksd-label>Label</ksd-label>
|
|
47
|
-
<textarea ksd-input type="text" ${argsToTemplate(args)}></textarea>
|
|
48
|
-
</ksd-field>
|
|
49
|
-
</div>
|
|
50
|
-
`,
|
|
51
|
-
}),
|
|
52
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ValidationMessage } from './validation-message'
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Directive } from '@angular/core'
|
|
2
|
-
|
|
3
|
-
@Directive({
|
|
4
|
-
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
5
|
-
selector: '[ksd-validation-message]',
|
|
6
|
-
host: {
|
|
7
|
-
class: 'ds-validation-message',
|
|
8
|
-
'data-field': 'validation',
|
|
9
|
-
},
|
|
10
|
-
})
|
|
11
|
-
export class ValidationMessage {}
|
package/src/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from './components/alert'
|
|
2
|
-
export * from './components/button'
|
|
3
|
-
export * from './components/card'
|
|
4
|
-
export * from './components/common-inputs'
|
|
5
|
-
export * from './components/details'
|
|
6
|
-
export * from './components/field'
|
|
7
|
-
export * from './components/fieldset'
|
|
8
|
-
export * from './components/input'
|
|
9
|
-
export * from './components/label'
|
|
10
|
-
export * from './components/paragraph'
|
|
11
|
-
export * from './components/popover'
|
|
12
|
-
export * from './components/search'
|
|
13
|
-
export * from './components/spinner'
|
|
14
|
-
export * from './components/validation-message'
|
package/src/test-setup.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import '@analogjs/vitest-angular/setup-zone'
|
|
2
|
-
|
|
3
|
-
import { getTestBed } from '@angular/core/testing'
|
|
4
|
-
import {
|
|
5
|
-
BrowserTestingModule,
|
|
6
|
-
platformBrowserTesting,
|
|
7
|
-
} from '@angular/platform-browser/testing'
|
|
8
|
-
|
|
9
|
-
getTestBed().initTestEnvironment(BrowserTestingModule, platformBrowserTesting())
|
|
10
|
-
|
|
11
|
-
// Need jest-dom for matchers like expect.toHaveAttribute
|
|
12
|
-
import '@testing-library/jest-dom'
|
package/src/utils/random-id.ts
DELETED
package/tsconfig.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2022",
|
|
4
|
-
"forceConsistentCasingInFileNames": true,
|
|
5
|
-
"strict": true,
|
|
6
|
-
"noImplicitOverride": true,
|
|
7
|
-
"noPropertyAccessFromIndexSignature": true,
|
|
8
|
-
"noImplicitReturns": true,
|
|
9
|
-
"noFallthroughCasesInSwitch": true
|
|
10
|
-
},
|
|
11
|
-
"files": [],
|
|
12
|
-
"include": [],
|
|
13
|
-
"references": [
|
|
14
|
-
{
|
|
15
|
-
"path": "./tsconfig.lib.json"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"path": "./tsconfig.spec.json"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"path": "./.storybook/tsconfig.json"
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
"extends": "../../tsconfig.base.json",
|
|
25
|
-
"angularCompilerOptions": {
|
|
26
|
-
"enableI18nLegacyMessageIdFormat": false,
|
|
27
|
-
"strictInputAccessModifiers": true,
|
|
28
|
-
"strictInjectionParameters": true,
|
|
29
|
-
"strictTemplates": true,
|
|
30
|
-
"extendedDiagnostics": {
|
|
31
|
-
"defaultCategory": "error"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
package/tsconfig.lib.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"declarationMap": true,
|
|
7
|
-
"inlineSources": true,
|
|
8
|
-
"types": []
|
|
9
|
-
},
|
|
10
|
-
"include": ["src/**/*.ts", "src/typings.d.ts"],
|
|
11
|
-
"exclude": [
|
|
12
|
-
"vite.config.ts",
|
|
13
|
-
"vite.config.mts",
|
|
14
|
-
"vitest.config.ts",
|
|
15
|
-
"vitest.config.mts",
|
|
16
|
-
"src/**/*.spec.ts",
|
|
17
|
-
"src/test-setup.ts",
|
|
18
|
-
"jest.config.ts",
|
|
19
|
-
"src/**/*.test.ts",
|
|
20
|
-
"src/**/*.test.tsx",
|
|
21
|
-
"src/**/*.spec.tsx",
|
|
22
|
-
"src/**/*.test.js",
|
|
23
|
-
"src/**/*.spec.js",
|
|
24
|
-
"src/**/*.test.jsx",
|
|
25
|
-
"src/**/*.spec.jsx",
|
|
26
|
-
"src/test-setup.ts"
|
|
27
|
-
]
|
|
28
|
-
}
|
package/tsconfig.lib.prod.json
DELETED
package/tsconfig.spec.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"types": [
|
|
6
|
-
"vitest/globals",
|
|
7
|
-
"vitest/importMeta",
|
|
8
|
-
"vite/client",
|
|
9
|
-
"node",
|
|
10
|
-
"vitest",
|
|
11
|
-
"@testing-library/jest-dom"
|
|
12
|
-
]
|
|
13
|
-
},
|
|
14
|
-
"include": [
|
|
15
|
-
"vite.config.ts",
|
|
16
|
-
"vite.config.mts",
|
|
17
|
-
"vitest.config.ts",
|
|
18
|
-
"vitest.config.mts",
|
|
19
|
-
"src/**/*.test.ts",
|
|
20
|
-
"src/**/*.spec.ts",
|
|
21
|
-
"src/**/*.test.tsx",
|
|
22
|
-
"src/**/*.spec.tsx",
|
|
23
|
-
"src/**/*.test.js",
|
|
24
|
-
"src/**/*.spec.js",
|
|
25
|
-
"src/**/*.test.jsx",
|
|
26
|
-
"src/**/*.spec.jsx",
|
|
27
|
-
"src/**/*.d.ts"
|
|
28
|
-
],
|
|
29
|
-
"files": ["src/test-setup.ts"]
|
|
30
|
-
}
|
package/vite.config.mts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/// <reference types='vitest' />
|
|
2
|
-
import angular from '@analogjs/vite-plugin-angular'
|
|
3
|
-
import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin'
|
|
4
|
-
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'
|
|
5
|
-
import * as path from 'path'
|
|
6
|
-
import { defineConfig } from 'vite'
|
|
7
|
-
import dts from 'vite-plugin-dts'
|
|
8
|
-
|
|
9
|
-
export default defineConfig(() => ({
|
|
10
|
-
root: __dirname,
|
|
11
|
-
cacheDir: '../../node_modules/.vite/packages/angular',
|
|
12
|
-
plugins: [
|
|
13
|
-
angular({
|
|
14
|
-
inlineStylesExtension: 'scss',
|
|
15
|
-
}),
|
|
16
|
-
nxViteTsPaths(),
|
|
17
|
-
nxCopyAssetsPlugin(['*.md']),
|
|
18
|
-
dts({
|
|
19
|
-
entryRoot: 'src',
|
|
20
|
-
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
|
|
21
|
-
}),
|
|
22
|
-
],
|
|
23
|
-
test: {
|
|
24
|
-
watch: false,
|
|
25
|
-
globals: true,
|
|
26
|
-
environment: 'jsdom',
|
|
27
|
-
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
28
|
-
setupFiles: ['src/test-setup.ts'],
|
|
29
|
-
reporters: ['default'],
|
|
30
|
-
coverage: {
|
|
31
|
-
reportsDirectory: '../../coverage/packages/angular',
|
|
32
|
-
provider: 'v8' as const,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
}))
|