@sondor-technology/sondor-components 1.0.1-develop.13 → 1.0.1-develop.15
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/dist/components/alert/alert.constants.d.ts +3 -0
- package/dist/components/alert/alert.constants.d.ts.map +1 -0
- package/dist/components/alert/alert.constants.js +2 -0
- package/dist/components/alert/alert.constants.js.map +1 -0
- package/dist/components/alert/alert.d.ts +4 -3
- package/dist/components/alert/alert.d.ts.map +1 -1
- package/dist/components/alert/alert.js +21 -11
- package/dist/components/alert/alert.js.map +1 -0
- package/dist/components/badge/badge.constants.d.ts +3 -0
- package/dist/components/badge/badge.constants.d.ts.map +1 -0
- package/dist/components/badge/badge.constants.js +2 -0
- package/dist/components/badge/badge.constants.js.map +1 -0
- package/dist/components/badge/badge.d.ts +1 -1
- package/dist/components/badge/badge.d.ts.map +1 -1
- package/dist/components/badge/badge.js +3 -2
- package/dist/components/badge/badge.js.map +1 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -1
- package/dist/components/breadcrumb/breadcrumb.js +2 -1
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -0
- package/dist/components/button/button.constants.d.ts +7 -0
- package/dist/components/button/button.constants.d.ts.map +1 -0
- package/dist/components/button/button.constants.js +4 -0
- package/dist/components/button/button.constants.js.map +1 -0
- package/dist/components/button/button.d.ts +8 -4
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +181 -137
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button-group/button-group.d.ts +1 -0
- package/dist/components/button-group/button-group.d.ts.map +1 -1
- package/dist/components/button-group/button-group.js +17 -21
- package/dist/components/button-group/button-group.js.map +1 -0
- package/dist/components/calendar/calendar.d.ts +36 -0
- package/dist/components/calendar/calendar.d.ts.map +1 -0
- package/dist/components/calendar/calendar.js +439 -0
- package/dist/components/calendar/calendar.js.map +1 -0
- package/dist/components/checkbox/checkbox.constants.d.ts +3 -0
- package/dist/components/checkbox/checkbox.constants.d.ts.map +1 -0
- package/dist/components/checkbox/checkbox.constants.js +2 -0
- package/dist/components/checkbox/checkbox.constants.js.map +1 -0
- package/dist/components/checkbox/checkbox.d.ts +5 -1
- package/dist/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/components/checkbox/checkbox.js +21 -5
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/code-block/code-block.d.ts +7 -7
- package/dist/components/code-block/code-block.d.ts.map +1 -1
- package/dist/components/code-block/code-block.js +130 -66
- package/dist/components/code-block/code-block.js.map +1 -0
- package/dist/components/content-card/content-card.d.ts.map +1 -1
- package/dist/components/content-card/content-card.js +10 -15
- package/dist/components/content-card/content-card.js.map +1 -0
- package/dist/components/cron-builder/cron-builder.d.ts +34 -0
- package/dist/components/cron-builder/cron-builder.d.ts.map +1 -0
- package/dist/components/cron-builder/cron-builder.js +456 -0
- package/dist/components/cron-builder/cron-builder.js.map +1 -0
- package/dist/components/divider/divider.constants.d.ts +5 -0
- package/dist/components/divider/divider.constants.d.ts.map +1 -0
- package/dist/components/divider/divider.constants.js +3 -0
- package/dist/components/divider/divider.constants.js.map +1 -0
- package/dist/components/divider/divider.d.ts +4 -2
- package/dist/components/divider/divider.d.ts.map +1 -1
- package/dist/components/divider/divider.js +18 -9
- package/dist/components/divider/divider.js.map +1 -0
- package/dist/components/drawer/drawer.d.ts +7 -4
- package/dist/components/drawer/drawer.d.ts.map +1 -1
- package/dist/components/drawer/drawer.js +73 -30
- package/dist/components/drawer/drawer.js.map +1 -0
- package/dist/components/field/field.d.ts +2 -2
- package/dist/components/field/field.d.ts.map +1 -1
- package/dist/components/field/field.js +8 -9
- package/dist/components/field/field.js.map +1 -0
- package/dist/components/footer/footer.d.ts +8 -1
- package/dist/components/footer/footer.d.ts.map +1 -1
- package/dist/components/footer/footer.js +42 -12
- package/dist/components/footer/footer.js.map +1 -0
- package/dist/components/form/form-step.js +1 -0
- package/dist/components/form/form-step.js.map +1 -0
- package/dist/components/form/form.d.ts +3 -0
- package/dist/components/form/form.d.ts.map +1 -1
- package/dist/components/form/form.js +109 -69
- package/dist/components/form/form.js.map +1 -0
- package/dist/components/grid/grid-row.d.ts +3 -3
- package/dist/components/grid/grid-row.d.ts.map +1 -1
- package/dist/components/grid/grid-row.js +36 -22
- package/dist/components/grid/grid-row.js.map +1 -0
- package/dist/components/grid/grid.d.ts +2 -2
- package/dist/components/grid/grid.d.ts.map +1 -1
- package/dist/components/grid/grid.js +5 -2
- package/dist/components/grid/grid.js.map +1 -0
- package/dist/components/icon/icon-paths.d.ts +161 -86
- package/dist/components/icon/icon-paths.d.ts.map +1 -1
- package/dist/components/icon/icon-paths.js +176 -106
- package/dist/components/icon/icon-paths.js.map +1 -0
- package/dist/components/icon/icon.d.ts +1 -1
- package/dist/components/icon/icon.d.ts.map +1 -1
- package/dist/components/icon/icon.js +6 -5
- package/dist/components/icon/icon.js.map +1 -0
- package/dist/components/input/input.d.ts +10 -0
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/input/input.js +59 -43
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/link/link.d.ts +6 -6
- package/dist/components/link/link.d.ts.map +1 -1
- package/dist/components/link/link.js +42 -19
- package/dist/components/link/link.js.map +1 -0
- package/dist/components/metadata/metadata.d.ts +3 -3
- package/dist/components/metadata/metadata.d.ts.map +1 -1
- package/dist/components/metadata/metadata.js +23 -20
- package/dist/components/metadata/metadata.js.map +1 -0
- package/dist/components/modal/modal.d.ts +4 -16
- package/dist/components/modal/modal.d.ts.map +1 -1
- package/dist/components/modal/modal.js +99 -62
- package/dist/components/modal/modal.js.map +1 -0
- package/dist/components/page-layout/page-layout.d.ts +4 -3
- package/dist/components/page-layout/page-layout.d.ts.map +1 -1
- package/dist/components/page-layout/page-layout.js +95 -68
- package/dist/components/page-layout/page-layout.js.map +1 -0
- package/dist/components/pin-input/pin-input.d.ts +33 -0
- package/dist/components/pin-input/pin-input.d.ts.map +1 -0
- package/dist/components/pin-input/pin-input.js +253 -0
- package/dist/components/pin-input/pin-input.js.map +1 -0
- package/dist/components/popover/popover.d.ts +26 -0
- package/dist/components/popover/popover.d.ts.map +1 -0
- package/dist/components/popover/popover.js +196 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/radio/radio.d.ts +8 -0
- package/dist/components/radio/radio.d.ts.map +1 -1
- package/dist/components/radio/radio.js +8 -12
- package/dist/components/radio/radio.js.map +1 -0
- package/dist/components/radio-group/radio-group.d.ts +6 -1
- package/dist/components/radio-group/radio-group.d.ts.map +1 -1
- package/dist/components/radio-group/radio-group.js +44 -18
- package/dist/components/radio-group/radio-group.js.map +1 -0
- package/dist/components/router/router.d.ts +5 -7
- package/dist/components/router/router.d.ts.map +1 -1
- package/dist/components/router/router.js +54 -38
- package/dist/components/router/router.js.map +1 -0
- package/dist/components/select/select.d.ts +5 -4
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/select/select.js +40 -9
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/skeleton/skeleton.d.ts +3 -2
- package/dist/components/skeleton/skeleton.d.ts.map +1 -1
- package/dist/components/skeleton/skeleton.js +10 -13
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/switch/switch.d.ts +12 -0
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/switch/switch.js +28 -22
- package/dist/components/switch/switch.js.map +1 -0
- package/dist/components/table/data-table.d.ts +3 -25
- package/dist/components/table/data-table.d.ts.map +1 -1
- package/dist/components/table/data-table.js +211 -146
- package/dist/components/table/data-table.js.map +1 -0
- package/dist/components/table/table.d.ts +3 -3
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +39 -20
- package/dist/components/table/table.js.map +1 -0
- package/dist/components/tabs/tab-panel.d.ts +3 -1
- package/dist/components/tabs/tab-panel.d.ts.map +1 -1
- package/dist/components/tabs/tab-panel.js +21 -11
- package/dist/components/tabs/tab-panel.js.map +1 -0
- package/dist/components/tabs/tab.d.ts +5 -1
- package/dist/components/tabs/tab.d.ts.map +1 -1
- package/dist/components/tabs/tab.js +46 -28
- package/dist/components/tabs/tab.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +4 -0
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/components/tabs/tabs.js +76 -13
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/components/textarea/textarea.d.ts +13 -0
- package/dist/components/textarea/textarea.d.ts.map +1 -1
- package/dist/components/textarea/textarea.js +59 -13
- package/dist/components/textarea/textarea.js.map +1 -0
- package/dist/components/theme-toggle/theme-toggle.constants.d.ts +3 -0
- package/dist/components/theme-toggle/theme-toggle.constants.d.ts.map +1 -0
- package/dist/components/theme-toggle/theme-toggle.constants.js +2 -0
- package/dist/components/theme-toggle/theme-toggle.constants.js.map +1 -0
- package/dist/components/theme-toggle/theme-toggle.d.ts +3 -2
- package/dist/components/theme-toggle/theme-toggle.d.ts.map +1 -1
- package/dist/components/theme-toggle/theme-toggle.js +46 -19
- package/dist/components/theme-toggle/theme-toggle.js.map +1 -0
- package/dist/components/time-picker/time-picker.d.ts +38 -0
- package/dist/components/time-picker/time-picker.d.ts.map +1 -0
- package/dist/components/time-picker/time-picker.js +280 -0
- package/dist/components/time-picker/time-picker.js.map +1 -0
- package/dist/components/toggle-group/toggle-button.d.ts +23 -0
- package/dist/components/toggle-group/toggle-button.d.ts.map +1 -0
- package/dist/components/toggle-group/toggle-button.js +115 -0
- package/dist/components/toggle-group/toggle-button.js.map +1 -0
- package/dist/components/toggle-group/toggle-group.d.ts +32 -0
- package/dist/components/toggle-group/toggle-group.d.ts.map +1 -0
- package/dist/components/toggle-group/toggle-group.js +150 -0
- package/dist/components/toggle-group/toggle-group.js.map +1 -0
- package/dist/components/tooltip/tooltip.d.ts +33 -0
- package/dist/components/tooltip/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip/tooltip.js +293 -0
- package/dist/components/tooltip/tooltip.js.map +1 -0
- package/dist/components/vertical-nav/vertical-nav-group.d.ts +5 -2
- package/dist/components/vertical-nav/vertical-nav-group.d.ts.map +1 -1
- package/dist/components/vertical-nav/vertical-nav-group.js +50 -14
- package/dist/components/vertical-nav/vertical-nav-group.js.map +1 -0
- package/dist/components/vertical-nav/vertical-nav-item.d.ts +3 -2
- package/dist/components/vertical-nav/vertical-nav-item.d.ts.map +1 -1
- package/dist/components/vertical-nav/vertical-nav-item.js +30 -8
- package/dist/components/vertical-nav/vertical-nav-item.js.map +1 -0
- package/dist/styles/index.css +49 -17
- package/dist/styles/reset.js +1 -0
- package/dist/styles/reset.js.map +1 -0
- package/package.json +30 -1
- package/src/components/alert/alert.constants.ts +2 -0
- package/src/components/alert/alert.ts +24 -15
- package/src/components/badge/badge.constants.ts +2 -0
- package/src/components/badge/badge.ts +3 -4
- package/src/components/breadcrumb/breadcrumb.ts +2 -2
- package/src/components/button/button.constants.ts +8 -0
- package/src/components/button/button.ts +184 -144
- package/src/components/button-group/button-group.ts +18 -22
- package/src/components/calendar/calendar.ts +444 -0
- package/src/components/checkbox/checkbox.constants.ts +2 -0
- package/src/components/checkbox/checkbox.ts +33 -18
- package/src/components/code-block/code-block.ts +151 -84
- package/src/components/content-card/content-card.ts +10 -16
- package/src/components/cron-builder/cron-builder.ts +452 -0
- package/src/components/divider/divider.constants.ts +5 -0
- package/src/components/divider/divider.ts +22 -11
- package/src/components/drawer/drawer.ts +79 -34
- package/src/components/field/field.ts +9 -11
- package/src/components/footer/footer.ts +43 -12
- package/src/components/form/form.ts +121 -84
- package/src/components/grid/grid-row.ts +45 -32
- package/src/components/grid/grid.ts +7 -4
- package/src/components/icon/icon-paths.ts +175 -106
- package/src/components/icon/icon.ts +6 -6
- package/src/components/input/input.ts +59 -45
- package/src/components/link/link.ts +45 -21
- package/src/components/metadata/metadata.ts +26 -24
- package/src/components/modal/modal.ts +108 -74
- package/src/components/page-layout/page-layout.ts +97 -72
- package/src/components/pin-input/pin-input.ts +249 -0
- package/src/components/popover/popover.ts +192 -0
- package/src/components/radio/radio.ts +8 -13
- package/src/components/radio-group/radio-group.ts +45 -21
- package/src/components/router/router.ts +73 -50
- package/src/components/select/select.ts +41 -80
- package/src/components/skeleton/skeleton.ts +14 -14
- package/src/components/switch/switch.ts +31 -25
- package/src/components/table/data-table.ts +248 -177
- package/src/components/table/table.ts +52 -29
- package/src/components/tabs/tab-panel.ts +25 -13
- package/src/components/tabs/tab.ts +58 -33
- package/src/components/tabs/tabs.ts +77 -15
- package/src/components/textarea/textarea.ts +63 -15
- package/src/components/theme-toggle/theme-toggle.constants.ts +2 -0
- package/src/components/theme-toggle/theme-toggle.ts +47 -22
- package/src/components/time-picker/time-picker.ts +272 -0
- package/src/components/toggle-group/toggle-button.ts +104 -0
- package/src/components/toggle-group/toggle-group.ts +148 -0
- package/src/components/tooltip/tooltip.ts +286 -0
- package/src/components/vertical-nav/vertical-nav-group.ts +57 -18
- package/src/components/vertical-nav/vertical-nav-item.ts +35 -12
- package/src/styles/globals.css +27 -4
- package/src/styles/theme.css +40 -32
- package/tsconfig.json +2 -1
- package/dist/components/card/card.d.ts +0 -11
- package/dist/components/card/card.d.ts.map +0 -1
- package/dist/components/card/card.js +0 -54
- package/src/components/card/card.ts +0 -53
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import {LitElement, html, css, PropertyValues} from "lit";
|
|
2
|
+
import {customElement, property, state} from "lit/decorators.js";
|
|
3
|
+
import {resetStyles} from "../../styles/reset";
|
|
4
|
+
|
|
5
|
+
@customElement("st-cron-builder")
|
|
6
|
+
export class StCronBuilder extends LitElement {
|
|
7
|
+
static formAssociated = true;
|
|
8
|
+
private _internals: ElementInternals;
|
|
9
|
+
|
|
10
|
+
@property({type: String, reflect: true}) name = "";
|
|
11
|
+
@property({type: String}) value = "";
|
|
12
|
+
@property({type: Boolean, reflect: true}) required = false;
|
|
13
|
+
|
|
14
|
+
@state() private _frequency = "weekly";
|
|
15
|
+
@state() private _time = "12:00";
|
|
16
|
+
@state() private _days = "1,3,5";
|
|
17
|
+
@state() private _monthDay = "1";
|
|
18
|
+
@state() private _date = "";
|
|
19
|
+
|
|
20
|
+
@state() private _customCron = "0 * * * *";
|
|
21
|
+
@state() private _customCronError = "";
|
|
22
|
+
@state() private _customCronText = "";
|
|
23
|
+
|
|
24
|
+
private _defaultValue = "";
|
|
25
|
+
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
this._internals = this.attachInternals();
|
|
29
|
+
|
|
30
|
+
const today = new Date();
|
|
31
|
+
const pad = (n: number) => n.toString().padStart(2, "0");
|
|
32
|
+
this._date = `${today.getFullYear()}-${pad(today.getMonth() + 1)}-${pad(today.getDate())}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static styles = [
|
|
36
|
+
resetStyles,
|
|
37
|
+
css`
|
|
38
|
+
:host {
|
|
39
|
+
display: block;
|
|
40
|
+
background: var(--st-color-surface);
|
|
41
|
+
border: 1px solid var(--st-color-border);
|
|
42
|
+
border-radius: var(--st-radius-lg);
|
|
43
|
+
padding: var(--st-spacing-lg);
|
|
44
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.builder-grid {
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
gap: var(--st-spacing-lg);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.row {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
gap: var(--st-spacing-xs);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
label {
|
|
60
|
+
font-size: var(--st-font-size-sm);
|
|
61
|
+
font-weight: 600;
|
|
62
|
+
color: var(--st-color-text);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.helper-text {
|
|
66
|
+
font-size: var(--st-font-size-xs);
|
|
67
|
+
color: var(--st-color-text-muted);
|
|
68
|
+
margin-top: 4px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.cron-segments {
|
|
72
|
+
display: flex;
|
|
73
|
+
gap: 4px;
|
|
74
|
+
margin-top: var(--st-spacing-xs);
|
|
75
|
+
margin-bottom: var(--st-spacing-xs);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.segment-badge {
|
|
79
|
+
flex: 1;
|
|
80
|
+
text-align: center;
|
|
81
|
+
font-size: 11px;
|
|
82
|
+
padding: 4px;
|
|
83
|
+
background: var(--st-color-surface-muted, #f1f5f9);
|
|
84
|
+
border-radius: var(--st-radius-sm);
|
|
85
|
+
color: var(--st-color-text-muted);
|
|
86
|
+
border: 1px solid var(--st-color-border);
|
|
87
|
+
transition: all 0.2s;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.segment-badge.active {
|
|
91
|
+
background: var(--st-color-primary, #eff6ff);
|
|
92
|
+
color: var(--st-color-surface);
|
|
93
|
+
border-color: var(--st-color-primary);
|
|
94
|
+
font-weight: 600;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.success-text {
|
|
98
|
+
color: var(--st-color-success, #16a34a);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.error-text {
|
|
102
|
+
color: var(--st-color-danger, #dc2626);
|
|
103
|
+
font-weight: 500;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.output-preview {
|
|
107
|
+
margin-top: var(--st-spacing-md);
|
|
108
|
+
padding: var(--st-spacing-md);
|
|
109
|
+
background: var(--st-color-surface-muted, #f8fafc);
|
|
110
|
+
border-radius: var(--st-radius-md);
|
|
111
|
+
border: 1px dashed var(--st-color-border);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.output-preview code {
|
|
115
|
+
font-family: monospace;
|
|
116
|
+
color: var(--st-color-primary);
|
|
117
|
+
font-weight: bold;
|
|
118
|
+
font-size: var(--st-font-size-lg);
|
|
119
|
+
}
|
|
120
|
+
`,
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
override firstUpdated() {
|
|
124
|
+
this._generateOutput();
|
|
125
|
+
this._defaultValue = this.value;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private _translateCron(cron: string): {valid: boolean; text: string} {
|
|
129
|
+
const parts = cron.trim().split(/\s+/);
|
|
130
|
+
|
|
131
|
+
if (parts.length !== 5) {
|
|
132
|
+
return {
|
|
133
|
+
valid: false,
|
|
134
|
+
text: `A cron expression must contain exactly 5 segments (currently ${parts.length}).`,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const types = ["Minute", "Hour", "Day of Month", "Month", "Day of Week"];
|
|
139
|
+
|
|
140
|
+
const bounds = [
|
|
141
|
+
{min: 0, max: 59}, // Minute
|
|
142
|
+
{min: 0, max: 23}, // Hour
|
|
143
|
+
{min: 1, max: 31}, // DOM
|
|
144
|
+
{min: 1, max: 12}, // Month
|
|
145
|
+
{min: 0, max: 7}, // DOW
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
for (let i = 0; i < 5; i++) {
|
|
149
|
+
const part = parts[i];
|
|
150
|
+
const type = types[i];
|
|
151
|
+
const bound = bounds[i];
|
|
152
|
+
|
|
153
|
+
// Prevent consecutive or hanging symbols like 1- or */
|
|
154
|
+
if (/(^[\/\-\,])|([\/\-\,]$)|([\/\-\,]{2,})/.test(part)) {
|
|
155
|
+
return {valid: false, text: `Invalid formatting in ${type} segment.`};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// First 3 segments (min, hour, dom) cannot have letters
|
|
159
|
+
if (i < 3 && /[A-Za-z]/.test(part)) {
|
|
160
|
+
return {valid: false, text: `${type} cannot contain letters.`};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Last 2 segments can only have specific valid keywords
|
|
164
|
+
if (/[A-Za-z]/.test(part)) {
|
|
165
|
+
const words = part.match(/[A-Za-z]+/g) || [];
|
|
166
|
+
const validWords =
|
|
167
|
+
i === 3
|
|
168
|
+
? ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"]
|
|
169
|
+
: ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
|
|
170
|
+
|
|
171
|
+
for (const word of words) {
|
|
172
|
+
if (!validWords.includes(word.toUpperCase())) {
|
|
173
|
+
return {valid: false, text: `"${word}" is not a valid ${type}.`};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const numbers = part.match(/\d+/g);
|
|
179
|
+
if (numbers) {
|
|
180
|
+
for (const numStr of numbers) {
|
|
181
|
+
const num = parseInt(numStr, 10);
|
|
182
|
+
if (num < bound.min || num > bound.max) {
|
|
183
|
+
return {
|
|
184
|
+
valid: false,
|
|
185
|
+
text: `${type} values must be between ${bound.min} and ${bound.max}.`,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const [min, hour, dom, mon, dow] = parts;
|
|
193
|
+
let desc = "Runs ";
|
|
194
|
+
|
|
195
|
+
if (min === "*") desc += "every minute";
|
|
196
|
+
else if (min.startsWith("*/")) desc += `every ${min.substring(2)} minutes`;
|
|
197
|
+
else desc += `at minute ${min}`;
|
|
198
|
+
|
|
199
|
+
if (hour !== "*") {
|
|
200
|
+
if (hour.startsWith("*/")) desc += `, past every ${hour.substring(2)} hours`;
|
|
201
|
+
else desc += `, past hour ${hour}`;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (dom !== "*") {
|
|
205
|
+
if (dom.startsWith("*/")) desc += `, every ${dom.substring(2)} days`;
|
|
206
|
+
else desc += `, on day ${dom} of the month`;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (mon !== "*") {
|
|
210
|
+
if (mon.startsWith("*/")) desc += `, every ${mon.substring(2)} months`;
|
|
211
|
+
else desc += `, in month ${mon}`;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (dow !== "*") {
|
|
215
|
+
const days = [
|
|
216
|
+
"Sunday",
|
|
217
|
+
"Monday",
|
|
218
|
+
"Tuesday",
|
|
219
|
+
"Wednesday",
|
|
220
|
+
"Thursday",
|
|
221
|
+
"Friday",
|
|
222
|
+
"Saturday",
|
|
223
|
+
"Sunday",
|
|
224
|
+
];
|
|
225
|
+
let dayStr = dow;
|
|
226
|
+
|
|
227
|
+
if (dow.length === 1 && /[0-7]/.test(dow)) {
|
|
228
|
+
dayStr = days[parseInt(dow, 10)];
|
|
229
|
+
} else if (dow.includes("-") && /[0-7]-[0-7]/.test(dow)) {
|
|
230
|
+
dayStr = dow
|
|
231
|
+
.split("-")
|
|
232
|
+
.map((d) => days[parseInt(d, 10)])
|
|
233
|
+
.join(" through ");
|
|
234
|
+
}
|
|
235
|
+
desc += `, on ${dayStr}`;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return {valid: true, text: desc + "."};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
private _generateOutput() {
|
|
242
|
+
let output = "";
|
|
243
|
+
this._customCronError = "";
|
|
244
|
+
this._customCronText = "";
|
|
245
|
+
this._internals.setValidity({});
|
|
246
|
+
|
|
247
|
+
if (this._frequency === "custom") {
|
|
248
|
+
const analysis = this._translateCron(this._customCron);
|
|
249
|
+
|
|
250
|
+
if (!analysis.valid) {
|
|
251
|
+
this._customCronError = analysis.text;
|
|
252
|
+
this._internals.setValidity({customError: true}, analysis.text);
|
|
253
|
+
} else {
|
|
254
|
+
this._customCronText = analysis.text;
|
|
255
|
+
}
|
|
256
|
+
output = this._customCron;
|
|
257
|
+
} else if (this._frequency === "one-off") {
|
|
258
|
+
output = `${this._date}T${this._time}`;
|
|
259
|
+
} else {
|
|
260
|
+
const [hh, mm] = this._time.split(":");
|
|
261
|
+
const minute = mm ? parseInt(mm, 10).toString() : "0";
|
|
262
|
+
const hour = hh ? parseInt(hh, 10).toString() : "0";
|
|
263
|
+
|
|
264
|
+
switch (this._frequency) {
|
|
265
|
+
case "daily":
|
|
266
|
+
output = `${minute} ${hour} * * *`;
|
|
267
|
+
break;
|
|
268
|
+
case "weekly":
|
|
269
|
+
const safeDays = this._days || "1";
|
|
270
|
+
output = `${minute} ${hour} * * ${safeDays}`;
|
|
271
|
+
break;
|
|
272
|
+
case "monthly":
|
|
273
|
+
output = `${minute} ${hour} ${this._monthDay} * *`;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
this.value = output;
|
|
279
|
+
this._internals.setFormValue(output);
|
|
280
|
+
this.dispatchEvent(new Event("change", {bubbles: true, composed: true}));
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private _handleCustomCronInput(e: any) {
|
|
284
|
+
const inputEl = e.target;
|
|
285
|
+
const sanitized = inputEl.value.replace(/[^0-9A-Za-z\s\*\/\-\,]/g, "");
|
|
286
|
+
|
|
287
|
+
if (inputEl.value !== sanitized) {
|
|
288
|
+
inputEl.value = sanitized;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
this._customCron = sanitized;
|
|
292
|
+
this._generateOutput();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private _handleFrequencyChange(e: any) {
|
|
296
|
+
this._frequency = e.target.value;
|
|
297
|
+
this._generateOutput();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
public checkValidity() {
|
|
301
|
+
return this._internals.checkValidity();
|
|
302
|
+
}
|
|
303
|
+
public reportValidity() {
|
|
304
|
+
return this._internals.reportValidity();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
formResetCallback() {
|
|
308
|
+
this.value = this._defaultValue;
|
|
309
|
+
this._frequency = "weekly";
|
|
310
|
+
this._generateOutput();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
render() {
|
|
314
|
+
const frequencyOptions = [
|
|
315
|
+
{label: "One-Off Execution", value: "one-off"},
|
|
316
|
+
{label: "Daily", value: "daily"},
|
|
317
|
+
{label: "Weekly", value: "weekly"},
|
|
318
|
+
{label: "Monthly", value: "monthly"},
|
|
319
|
+
{label: "Custom Cron", value: "custom"},
|
|
320
|
+
];
|
|
321
|
+
|
|
322
|
+
const monthDayOptions = Array.from({length: 31}, (_, i) => ({
|
|
323
|
+
label: `${i + 1}${i === 0 ? "st" : i === 1 ? "nd" : i === 2 ? "rd" : "th"}`,
|
|
324
|
+
value: String(i + 1),
|
|
325
|
+
}));
|
|
326
|
+
|
|
327
|
+
// Calculate which segment the user is currently typing in
|
|
328
|
+
const activeSegmentIndex = Math.min(this._customCron.trimStart().split(/\s+/).length - 1, 4);
|
|
329
|
+
|
|
330
|
+
return html`
|
|
331
|
+
<div class="builder-grid">
|
|
332
|
+
<div class="row">
|
|
333
|
+
<st-select
|
|
334
|
+
label="Schedule Type"
|
|
335
|
+
.options=${frequencyOptions}
|
|
336
|
+
.value=${this._frequency}
|
|
337
|
+
@change=${this._handleFrequencyChange}
|
|
338
|
+
></st-select>
|
|
339
|
+
</div>
|
|
340
|
+
|
|
341
|
+
${this._frequency === "weekly"
|
|
342
|
+
? html`
|
|
343
|
+
<div class="row">
|
|
344
|
+
<label>Run on days</label>
|
|
345
|
+
<st-toggle-group
|
|
346
|
+
multiple
|
|
347
|
+
.value=${this._days}
|
|
348
|
+
@change=${(e: any) => {
|
|
349
|
+
this._days = e.target.value;
|
|
350
|
+
this._generateOutput();
|
|
351
|
+
}}
|
|
352
|
+
>
|
|
353
|
+
<st-toggle-button value="1">Mon</st-toggle-button>
|
|
354
|
+
<st-toggle-button value="2">Tue</st-toggle-button>
|
|
355
|
+
<st-toggle-button value="3">Wed</st-toggle-button>
|
|
356
|
+
<st-toggle-button value="4">Thu</st-toggle-button>
|
|
357
|
+
<st-toggle-button value="5">Fri</st-toggle-button>
|
|
358
|
+
<st-toggle-button value="6">Sat</st-toggle-button>
|
|
359
|
+
<st-toggle-button value="0">Sun</st-toggle-button>
|
|
360
|
+
</st-toggle-group>
|
|
361
|
+
</div>
|
|
362
|
+
`
|
|
363
|
+
: ""}
|
|
364
|
+
${this._frequency === "monthly"
|
|
365
|
+
? html`
|
|
366
|
+
<div class="row">
|
|
367
|
+
<st-select
|
|
368
|
+
label="Run on day of month"
|
|
369
|
+
.options=${monthDayOptions}
|
|
370
|
+
.value=${this._monthDay}
|
|
371
|
+
@change=${(e: any) => {
|
|
372
|
+
this._monthDay = e.target.value;
|
|
373
|
+
this._generateOutput();
|
|
374
|
+
}}
|
|
375
|
+
></st-select>
|
|
376
|
+
</div>
|
|
377
|
+
`
|
|
378
|
+
: ""}
|
|
379
|
+
${this._frequency === "one-off"
|
|
380
|
+
? html`
|
|
381
|
+
<div class="row">
|
|
382
|
+
<label>Execution Date</label>
|
|
383
|
+
<st-calendar
|
|
384
|
+
.value=${this._date}
|
|
385
|
+
@change=${(e: any) => {
|
|
386
|
+
this._date = e.target.value;
|
|
387
|
+
this._generateOutput();
|
|
388
|
+
}}
|
|
389
|
+
></st-calendar>
|
|
390
|
+
</div>
|
|
391
|
+
`
|
|
392
|
+
: ""}
|
|
393
|
+
${this._frequency === "custom"
|
|
394
|
+
? html`
|
|
395
|
+
<div class="row">
|
|
396
|
+
<st-input
|
|
397
|
+
label="Raw Cron Expression"
|
|
398
|
+
placeholder="*/15 * * * *"
|
|
399
|
+
.value=${this._customCron}
|
|
400
|
+
.error=${this._customCronError}
|
|
401
|
+
?invalid=${!!this._customCronError}
|
|
402
|
+
@input=${this._handleCustomCronInput}
|
|
403
|
+
></st-input>
|
|
404
|
+
<div class="cron-segments" aria-hidden="true">
|
|
405
|
+
${["Minute", "Hour", "Day", "Month", "Weekday"].map(
|
|
406
|
+
(label, i) => html`
|
|
407
|
+
<div class="segment-badge ${activeSegmentIndex === i ? "active" : ""}">
|
|
408
|
+
${label}
|
|
409
|
+
</div>
|
|
410
|
+
`,
|
|
411
|
+
)}
|
|
412
|
+
</div>
|
|
413
|
+
|
|
414
|
+
${this._customCronText && !this._customCronError
|
|
415
|
+
? html`
|
|
416
|
+
<div class="helper-text success-text">
|
|
417
|
+
<strong>Schedule:</strong> ${this._customCronText}
|
|
418
|
+
</div>
|
|
419
|
+
`
|
|
420
|
+
: ""}
|
|
421
|
+
</div>
|
|
422
|
+
`
|
|
423
|
+
: ""}
|
|
424
|
+
${this._frequency !== "custom"
|
|
425
|
+
? html`
|
|
426
|
+
<div class="row">
|
|
427
|
+
<st-time-picker
|
|
428
|
+
label="Execution Time"
|
|
429
|
+
.value=${this._time}
|
|
430
|
+
@change=${(e: any) => {
|
|
431
|
+
this._time = e.target.value;
|
|
432
|
+
this._generateOutput();
|
|
433
|
+
}}
|
|
434
|
+
></st-time-picker>
|
|
435
|
+
</div>
|
|
436
|
+
`
|
|
437
|
+
: ""}
|
|
438
|
+
|
|
439
|
+
<div class="output-preview">
|
|
440
|
+
<div class="helper-text">Generated Payload</div>
|
|
441
|
+
<code>${this.value}</code>
|
|
442
|
+
</div>
|
|
443
|
+
</div>
|
|
444
|
+
`;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
declare global {
|
|
449
|
+
interface HTMLElementTagNameMap {
|
|
450
|
+
"st-cron-builder": StCronBuilder;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
2
|
import { customElement, property } from 'lit/decorators.js';
|
|
3
3
|
import { resetStyles } from '../../styles/reset.js';
|
|
4
|
+
import { DividerColor, DividerDirection } from './divider.constants.js';
|
|
4
5
|
|
|
5
6
|
@customElement('st-divider')
|
|
6
7
|
export class StDivider extends LitElement {
|
|
7
|
-
@property({ type: String, reflect: true }) direction:
|
|
8
|
+
@property({ type: String, reflect: true }) direction: DividerDirection = 'horizontal';
|
|
8
9
|
@property({ type: String }) thickness = '1px';
|
|
9
10
|
@property({ type: String }) margin = '0';
|
|
10
|
-
@property({ type: String, reflect: true }) color:
|
|
11
|
+
@property({ type: String, reflect: true }) color: DividerColor = 'border';
|
|
11
12
|
|
|
12
13
|
static styles = [
|
|
13
14
|
resetStyles,
|
|
@@ -43,22 +44,32 @@ export class StDivider extends LitElement {
|
|
|
43
44
|
`
|
|
44
45
|
];
|
|
45
46
|
|
|
47
|
+
connectedCallback() {
|
|
48
|
+
super.connectedCallback();
|
|
49
|
+
// Semantic role belongs on the host element
|
|
50
|
+
if (!this.hasAttribute('role')) {
|
|
51
|
+
this.setAttribute('role', 'separator');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
46
55
|
updated(changedProperties: Map<string, any>) {
|
|
47
56
|
super.updated(changedProperties);
|
|
48
57
|
|
|
49
58
|
// Sync properties to CSS variables for dynamic adjustment
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
if (changedProperties.has('thickness') || changedProperties.has('margin')) {
|
|
60
|
+
this.style.setProperty('--divider-thickness', this.thickness);
|
|
61
|
+
this.style.setProperty('--divider-margin', this.margin);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Keep native ARIA attributes perfectly synced with our Lit properties
|
|
65
|
+
if (changedProperties.has('direction')) {
|
|
66
|
+
this.setAttribute('aria-orientation', this.direction);
|
|
67
|
+
}
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
render() {
|
|
55
|
-
//
|
|
56
|
-
return html
|
|
57
|
-
<div
|
|
58
|
-
role="separator"
|
|
59
|
-
aria-orientation="${this.direction === 'horizontal' ? 'horizontal' : 'vertical'}"
|
|
60
|
-
></div>
|
|
61
|
-
`;
|
|
71
|
+
// The host element itself is the structural divider. No inner DOM bloat needed.
|
|
72
|
+
return html``;
|
|
62
73
|
}
|
|
63
74
|
}
|
|
64
75
|
|