|
1 | 1 | import type { JSX } from '@stencil/core'; |
2 | | -import { alertTypeOptions, alertVariantOptions, setState, validateHasCloser, validateLabel, watchBoolean, watchValidator } from '../../schema'; |
| 2 | +import { setState, validateAlertType, validateAlertVariant, validateHasCloser, validateLabel, watchBoolean } from '../../schema'; |
3 | 3 | import { Component, Element, h, Prop, State, Watch } from '@stencil/core'; |
4 | 4 | import { watchHeadingLevel } from '../heading/validation'; |
5 | | -import type { AlertAPI, AlertStates, AlertType, AlertVariant, HasCloserPropType, HeadingLevel, KoliBriAlertEventCallbacks, LabelPropType } from '../../schema'; |
| 5 | +import type { |
| 6 | + AlertAPI, |
| 7 | + AlertStates, |
| 8 | + AlertTypePropType, |
| 9 | + AlertVariantPropType, |
| 10 | + HasCloserPropType, |
| 11 | + HeadingLevel, |
| 12 | + KoliBriAlertEventCallbacks, |
| 13 | + LabelPropType, |
| 14 | +} from '../../schema'; |
6 | 15 | import KolAlertFc, { type KolAlertFcProps } from '../../functional-components/Alert'; |
7 | 16 | import { dispatchDomEvent, KolEvent } from '../../utils/events'; |
8 | 17 |
|
@@ -78,12 +87,12 @@ export class KolAlertWc implements AlertAPI { |
78 | 87 | /** |
79 | 88 | * Defines either the type of the component or of the components interactive element. |
80 | 89 | */ |
81 | | - @Prop() public _type?: AlertType = 'default'; |
| 90 | + @Prop() public _type?: AlertTypePropType = 'default'; |
82 | 91 |
|
83 | 92 | /** |
84 | 93 | * Defines which variant should be used for presentation. |
85 | 94 | */ |
86 | | - @Prop() public _variant?: AlertVariant = 'msg'; |
| 95 | + @Prop() public _variant?: AlertVariantPropType = 'msg'; |
87 | 96 |
|
88 | 97 | @State() public state: AlertStates = { |
89 | 98 | _level: 0, |
@@ -137,25 +146,13 @@ export class KolAlertWc implements AlertAPI { |
137 | 146 | } |
138 | 147 |
|
139 | 148 | @Watch('_type') |
140 | | - public validateType(value?: AlertType): void { |
141 | | - watchValidator( |
142 | | - this, |
143 | | - '_type', |
144 | | - (value?) => typeof value === 'string' && alertTypeOptions.includes(value), |
145 | | - new Set(`String {${alertTypeOptions.join(', ')}`), |
146 | | - value, |
147 | | - ); |
| 149 | + public validateType(value?: AlertTypePropType): void { |
| 150 | + validateAlertType(this, value); |
148 | 151 | } |
149 | 152 |
|
150 | 153 | @Watch('_variant') |
151 | | - public validateVariant(value?: AlertVariant): void { |
152 | | - watchValidator( |
153 | | - this, |
154 | | - '_variant', |
155 | | - (value?) => typeof value === 'string' && alertVariantOptions.includes(value), |
156 | | - new Set(`AlertVariant {${alertVariantOptions.join(', ')}`), |
157 | | - value, |
158 | | - ); |
| 154 | + public validateVariant(value?: AlertVariantPropType): void { |
| 155 | + validateAlertVariant(this, value); |
159 | 156 | } |
160 | 157 |
|
161 | 158 | public componentWillLoad(): void { |
|
0 commit comments