-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathpresets.ts
84 lines (77 loc) · 1.65 KB
/
presets.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { Presets } from "./organize";
const PRESET = {
// HTML
$CLASS: /^class$/,
$ID: /^id$/,
$NAME: /^name$/,
$DATA: /^data-/,
$SRC: /^src$/,
$FOR: /^for$/,
$TYPE: /^type$/,
$HREF: /^href$/,
$VALUE: /^value$/,
$TITLE: /^title$/,
$ALT: /^alt$/,
$ROLE: /^role$/,
$ARIA: /^aria-/,
// Angular
$ANGULAR_STRUCTURAL_DIRECTIVE: /^\*/,
$ANGULAR_TWO_WAY_BINDING: /^\[\(/,
$ANGULAR_ANIMATION: /^\@/,
$ANGULAR_ANIMATION_INPUT: /^\[@/,
$ANGULAR_INPUT: /^\[[^(@]/,
$ANGULAR_OUTPUT: /^\(/,
$ANGULAR_ELEMENT_REF: /^#/,
// Vue
$VUE_ATTRIBUTE: /^v-/,
};
const PRESET_GROUPS = {
/**
* Angular
*
* https://angular.io/
*/
$ANGULAR: [
PRESET.$CLASS,
PRESET.$ID,
PRESET.$ANGULAR_ELEMENT_REF,
PRESET.$ANGULAR_STRUCTURAL_DIRECTIVE,
PRESET.$ANGULAR_ANIMATION,
PRESET.$ANGULAR_ANIMATION_INPUT,
PRESET.$ANGULAR_TWO_WAY_BINDING,
PRESET.$ANGULAR_INPUT,
PRESET.$ANGULAR_OUTPUT,
],
/**
* Code Guide by @mdo
*
* https://codeguide.co/#html-attribute-order
*/
$CODE_GUIDE: [
PRESET.$CLASS,
PRESET.$ID,
PRESET.$NAME,
PRESET.$DATA,
PRESET.$SRC,
PRESET.$FOR,
PRESET.$TYPE,
PRESET.$HREF,
PRESET.$VALUE,
PRESET.$TITLE,
PRESET.$ALT,
PRESET.$ROLE,
PRESET.$ARIA,
],
$HTML: [PRESET.$CLASS, PRESET.$ID],
$VUE: [PRESET.$CLASS, PRESET.$ID, PRESET.$VUE_ATTRIBUTE],
};
const presets = {
...PRESET,
...PRESET_GROUPS,
};
const presetKeys: Record<string, string> = {};
Object.keys(presets).forEach((key) => (presetKeys[key] = key));
export const PRESETS: Presets = presets;
export const PRESET_KEYS = presetKeys as {
[K in keyof typeof presets]: K;
};