Skip to content

Commit 93a254f

Browse files
committed
feat: centralize remaining prop definitions
1 parent d964722 commit 93a254f

File tree

17 files changed

+220
-94
lines changed

17 files changed

+220
-94
lines changed
Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
import type { HeadingLevel } from '../../schema';
2-
import { headingLevelOptions, watchValidator } from '../../schema';
2+
import { validateLevel } from '../../schema';
33

44
import type { Generic } from 'adopted-style-sheets';
55

66
export const watchHeadingLevel = (component: Generic.Element.Component, value?: HeadingLevel): void => {
7-
watchValidator(
8-
component,
9-
'_level',
10-
(value?: HeadingLevel): boolean => {
11-
return typeof value === 'number' && headingLevelOptions.includes(value);
12-
},
13-
new Set([`Number {${headingLevelOptions.join(', ')}`]),
14-
value,
15-
{
16-
// TODO: options not in the validator
17-
defaultValue: 1,
18-
required: true,
19-
},
20-
);
7+
validateLevel(component, value);
218
};

packages/components/src/schema/components/combobox.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
import type { Generic } from 'adopted-style-sheets';
22

33
import type {
4-
MsgPropType,
54
PropAccessKey,
65
PropDisabled,
6+
PropHasValue,
77
PropHideLabel,
88
PropHideMsg,
9+
PropHint,
910
PropHorizontalIcons,
1011
PropId,
1112
PropLabelWithExpertSlot,
1213
PropMsg,
1314
PropName,
15+
PropPlaceholder,
1416
PropRequired,
1517
PropShortKey,
1618
PropSuggestions,
1719
PropSyncValueBySelector,
1820
PropTouched,
1921
} from '../props';
20-
import type { InputTypeOnDefault, KoliBriHIcons, Stringified, W3CInputValue } from '../types';
22+
import type { InputTypeOnDefault, KoliBriHIcons, W3CInputValue } from '../types';
2123

2224
type RequiredProps = PropLabelWithExpertSlot & PropSuggestions;
2325
type OptionalProps = {
24-
hint: string;
25-
msg: Stringified<MsgPropType>;
2626
on: InputTypeOnDefault;
2727
placeholder: string;
2828
value: string;
@@ -35,27 +35,30 @@ type OptionalProps = {
3535
PropRequired &
3636
PropShortKey &
3737
PropSyncValueBySelector &
38-
PropTouched;
38+
PropTouched &
39+
PropHint &
40+
PropMsg &
41+
PropPlaceholder;
3942

4043
type RequiredStates = {
41-
hasValue: boolean;
4244
suggestions: W3CInputValue[];
4345
value: string;
4446
} & PropId &
47+
PropHasValue &
4548
PropHideMsg &
4649
PropLabelWithExpertSlot;
4750
type OptionalStates = {
48-
hint: string;
4951
on: InputTypeOnDefault;
50-
placeholder: string;
5152
} & PropAccessKey &
5253
PropDisabled &
5354
PropHideLabel &
55+
PropHint &
5456
KoliBriHIcons &
5557
PropId &
5658
PropName &
5759
PropRequired &
5860
PropMsg &
61+
PropPlaceholder &
5962
PropShortKey &
6063
PropTouched;
6164

packages/components/src/schema/components/input-checkbox.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import type { Generic } from 'adopted-style-sheets';
22

33
import type {
4-
MsgPropType,
4+
PropAccessKey,
55
PropChecked,
66
PropDisabled,
7-
PropHideMsg,
87
PropHideLabel,
8+
PropHideMsg,
9+
PropHint,
910
PropIndeterminate,
1011
PropLabelAlign,
1112
PropLabelWithExpertSlot,
1213
PropMsg,
1314
PropName,
1415
PropRequired,
16+
PropShortKey,
1517
PropSyncValueBySelector,
1618
PropTouched,
17-
PropShortKey,
18-
PropAccessKey,
1919
PropVariantInputCheckbox,
2020
} from '../props';
2121
import type { AnyIconFontClass, InputTypeOnDefault, StencilUnknown, Stringified } from '../types';
@@ -45,9 +45,7 @@ export type InputCheckboxIconsState = {
4545

4646
type RequiredProps = PropLabelWithExpertSlot;
4747
type OptionalProps = {
48-
hint: string;
4948
icons: Stringified<InputCheckboxIconsProp>;
50-
msg: Stringified<MsgPropType>;
5149
on: InputTypeOnDefault;
5250
value: StencilUnknown;
5351
} & PropAccessKey &
@@ -62,7 +60,9 @@ type OptionalProps = {
6260
PropSyncValueBySelector &
6361
PropTouched &
6462
PropLabelAlign &
65-
PropVariantInputCheckbox;
63+
PropVariantInputCheckbox &
64+
PropHint &
65+
PropMsg;
6666

6767
type RequiredStates = {
6868
icons: InputCheckboxIconsState;
@@ -74,11 +74,11 @@ type RequiredStates = {
7474
PropLabelWithExpertSlot &
7575
PropVariantInputCheckbox;
7676
type OptionalStates = {
77-
hint: string;
7877
on: InputTypeOnDefault;
7978
} & PropAccessKey &
8079
PropDisabled &
8180
PropHideLabel &
81+
PropHint &
8282
PropMsg &
8383
PropName &
8484
PropRequired &

packages/components/src/schema/components/input-date.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ import type {
44
MsgPropType,
55
PropAccessKey,
66
PropDisabled,
7+
PropHasValue,
78
PropHideLabel,
89
PropHideMsg,
10+
PropHint,
911
PropId,
1012
PropLabelWithExpertSlot,
1113
PropMsg,
1214
PropName,
15+
PropPlaceholder,
1316
PropReadOnly,
1417
PropRequired,
1518
PropShortKey,
@@ -31,29 +34,29 @@ type OptionalProps = {
3134

3235
type RequiredStates = {
3336
autoComplete: InputTypeOnOff;
34-
hasValue: boolean;
3537
suggestions: W3CInputValue[];
3638
} & PropLabelWithExpertSlot &
39+
PropHasValue &
3740
PropHideMsg &
3841
PropId &
3942
PropTypeInputDate;
4043

4144
type OptionalStates = {
42-
hint: string;
4345
max: Iso8601;
4446
min: Iso8601;
4547
on: InputTypeOnDefault;
46-
placeholder: string;
4748
smartButton: ButtonProps;
4849
step: number;
4950
value: Iso8601 | null;
5051
} & PropAccessKey &
5152
PropSyncValueBySelector &
5253
PropDisabled &
5354
PropHideLabel &
55+
PropHint &
5456
KoliBriHIcons &
5557
PropMsg &
5658
PropName &
59+
PropPlaceholder &
5760
PropReadOnly &
5861
PropRequired &
5962
PropShortKey &

packages/components/src/schema/components/input-email.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import type { Generic } from 'adopted-style-sheets';
22

33
import type {
4-
MsgPropType,
54
PropAccessKey,
5+
PropCurrentLength,
66
PropDisabled,
77
PropHasCounter,
8+
PropHasValue,
89
PropHideLabel,
910
PropHideMsg,
11+
PropHint,
1012
PropHorizontalIcons,
1113
PropId,
1214
PropLabelWithExpertSlot,
15+
PropMaxLength,
1316
PropMsg,
1417
PropMultiple,
1518
PropName,
19+
PropPlaceholder,
1620
PropReadOnly,
1721
PropRequired,
1822
PropShortKey,
@@ -26,12 +30,8 @@ import type { ButtonProps } from './button';
2630
type RequiredProps = PropLabelWithExpertSlot;
2731
type OptionalProps = {
2832
autoComplete: InputTypeOnOff;
29-
hint: string;
30-
maxLength: number;
31-
msg: Stringified<MsgPropType>;
3233
on: InputTypeOnDefault;
3334
pattern: string;
34-
placeholder: string;
3535
smartButton: Stringified<ButtonProps>;
3636
value: string;
3737
} & PropAccessKey &
@@ -47,33 +47,37 @@ type OptionalProps = {
4747
PropShortKey &
4848
PropSuggestions &
4949
PropSyncValueBySelector &
50-
PropTouched;
50+
PropTouched &
51+
PropHint &
52+
PropMaxLength &
53+
PropMsg &
54+
PropPlaceholder;
5155

5256
type RequiredStates = {
5357
autoComplete: InputTypeOnOff;
54-
hasValue: boolean;
5558
suggestions: W3CInputValue[];
56-
} & PropId &
59+
} & PropHasValue &
60+
PropId &
5761
PropHideMsg &
5862
PropLabelWithExpertSlot;
5963

6064
type OptionalStates = {
61-
currentLength: number;
62-
hint: string;
63-
maxLength: number;
6465
on: InputTypeOnDefault;
6566
pattern: string;
66-
placeholder: string;
6767
smartButton: ButtonProps;
6868
value: string;
6969
} & PropAccessKey &
70+
PropCurrentLength &
7071
PropDisabled &
7172
PropHasCounter &
7273
PropHideLabel &
74+
PropHint &
7375
KoliBriHIcons &
76+
PropMaxLength &
7477
PropMsg &
7578
PropMultiple &
7679
PropName &
80+
PropPlaceholder &
7781
PropReadOnly &
7882
PropRequired &
7983
PropShortKey &

packages/components/src/schema/components/input-password.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import type { Generic } from 'adopted-style-sheets';
22

33
import type {
4-
MsgPropType,
54
PropAccessKey,
5+
PropCurrentLength,
66
PropDisabled,
77
PropHasCounter,
8+
PropHasValue,
89
PropHideLabel,
910
PropHideMsg,
11+
PropHint,
1012
PropHorizontalIcons,
1113
PropId,
1214
PropLabelWithExpertSlot,
15+
PropMaxLength,
1316
PropMsg,
1417
PropName,
18+
PropPlaceholder,
1519
PropReadOnly,
1620
PropRequired,
1721
PropShortKey,
@@ -25,14 +29,10 @@ import type { ButtonProps } from './button';
2529
type RequiredProps = PropLabelWithExpertSlot;
2630
type OptionalProps = {
2731
autoComplete: InputTypeOnOff;
28-
hint: string;
29-
maxLength: number;
3032
on: InputTypeOnDefault;
3133
pattern: string;
32-
placeholder: string;
3334
smartButton: Stringified<ButtonProps>;
3435
value: string;
35-
msg: Stringified<MsgPropType>;
3636
} & PropAccessKey &
3737
PropPasswordVariant &
3838
PropDisabled &
@@ -45,31 +45,35 @@ type OptionalProps = {
4545
PropRequired &
4646
PropShortKey &
4747
PropSyncValueBySelector &
48-
PropTouched;
48+
PropTouched &
49+
PropHint &
50+
PropMaxLength &
51+
PropMsg &
52+
PropPlaceholder;
4953

5054
type RequiredStates = {
5155
autoComplete: InputTypeOnOff;
52-
hasValue: boolean;
5356
} & PropId &
57+
PropHasValue &
5458
PropHideMsg &
5559
PropLabelWithExpertSlot;
5660
type OptionalStates = {
57-
currentLength: number;
58-
hint: string;
59-
maxLength: number;
6061
on: InputTypeOnDefault;
6162
pattern: string;
62-
placeholder: string;
6363
smartButton: ButtonProps;
6464
value: string | null;
6565
} & PropAccessKey &
66+
PropCurrentLength &
6667
PropPasswordVariant &
6768
PropDisabled &
6869
PropHasCounter &
6970
PropHideLabel &
71+
PropHint &
7072
KoliBriHIcons &
73+
PropMaxLength &
7174
PropMsg &
7275
PropName &
76+
PropPlaceholder &
7377
PropReadOnly &
7478
PropRequired &
7579
PropShortKey &

0 commit comments

Comments
 (0)