@celestia-island/hikari 0.4.4
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/README.md +54 -0
- package/package.json +63 -0
- package/src/DemoApp.vue +400 -0
- package/src/components/HkActionBar.tsx +15 -0
- package/src/components/HkAlert.scss +121 -0
- package/src/components/HkAlert.tsx +85 -0
- package/src/components/HkAvatar.tsx +29 -0
- package/src/components/HkBadge.scss +117 -0
- package/src/components/HkBadge.tsx +50 -0
- package/src/components/HkBreadcrumb.tsx +39 -0
- package/src/components/HkButton.scss +128 -0
- package/src/components/HkButton.tsx +74 -0
- package/src/components/HkCard.scss +49 -0
- package/src/components/HkCard.tsx +38 -0
- package/src/components/HkCheckbox.scss +102 -0
- package/src/components/HkCheckbox.tsx +85 -0
- package/src/components/HkCollapse.tsx +48 -0
- package/src/components/HkColorPicker.scss +148 -0
- package/src/components/HkColorPicker.tsx +204 -0
- package/src/components/HkConfirmDialog.scss +12 -0
- package/src/components/HkConfirmDialog.tsx +75 -0
- package/src/components/HkDateTimePicker.scss +361 -0
- package/src/components/HkDateTimePicker.tsx +424 -0
- package/src/components/HkDivider.scss +85 -0
- package/src/components/HkDivider.tsx +51 -0
- package/src/components/HkDraggableGrid.scss +132 -0
- package/src/components/HkDraggableGrid.tsx +291 -0
- package/src/components/HkDraggableList.scss +110 -0
- package/src/components/HkDraggableList.tsx +238 -0
- package/src/components/HkDrawer.scss +175 -0
- package/src/components/HkDrawer.tsx +171 -0
- package/src/components/HkEmptyState.scss +42 -0
- package/src/components/HkEmptyState.tsx +41 -0
- package/src/components/HkErrorBoundary.scss +64 -0
- package/src/components/HkErrorBoundary.tsx +82 -0
- package/src/components/HkGaugeRing.scss +4 -0
- package/src/components/HkGaugeRing.tsx +130 -0
- package/src/components/HkHoverRevealAction.scss +66 -0
- package/src/components/HkHoverRevealAction.tsx +77 -0
- package/src/components/HkIcon.tsx +43 -0
- package/src/components/HkIconButton.tsx +42 -0
- package/src/components/HkImageViewer.scss +33 -0
- package/src/components/HkImageViewer.tsx +250 -0
- package/src/components/HkInput.scss +172 -0
- package/src/components/HkInput.tsx +175 -0
- package/src/components/HkKbd.tsx +26 -0
- package/src/components/HkKeywordSearchModal.scss +148 -0
- package/src/components/HkKeywordSearchModal.tsx +308 -0
- package/src/components/HkListTransition.scss +131 -0
- package/src/components/HkListTransition.tsx +29 -0
- package/src/components/HkLocalePickerPopup.tsx +42 -0
- package/src/components/HkLogo.scss +36 -0
- package/src/components/HkLogo.tsx +93 -0
- package/src/components/HkMarkdownRenderer.scss +141 -0
- package/src/components/HkMarkdownRenderer.tsx +123 -0
- package/src/components/HkMediaControlBar.scss +65 -0
- package/src/components/HkMediaControlBar.tsx +115 -0
- package/src/components/HkMediaPlayer.scss +29 -0
- package/src/components/HkMediaPlayer.tsx +210 -0
- package/src/components/HkMediaSlider.scss +54 -0
- package/src/components/HkMediaSlider.tsx +81 -0
- package/src/components/HkMediaVisualizer.scss +7 -0
- package/src/components/HkMediaVisualizer.tsx +119 -0
- package/src/components/HkMinimap.scss +76 -0
- package/src/components/HkMinimap.tsx +255 -0
- package/src/components/HkModal.scss +318 -0
- package/src/components/HkModal.tsx +481 -0
- package/src/components/HkModalBreadcrumb.scss +55 -0
- package/src/components/HkModalBreadcrumb.tsx +113 -0
- package/src/components/HkMorphingTabs.scss +141 -0
- package/src/components/HkMorphingTabs.tsx +113 -0
- package/src/components/HkNavItem.scss +81 -0
- package/src/components/HkNavItem.tsx +157 -0
- package/src/components/HkNumberInput.scss +154 -0
- package/src/components/HkNumberInput.tsx +161 -0
- package/src/components/HkPasswordInput.scss +289 -0
- package/src/components/HkPasswordInput.tsx +533 -0
- package/src/components/HkPhaseTransition.scss +25 -0
- package/src/components/HkPhaseTransition.tsx +40 -0
- package/src/components/HkPopover.scss +82 -0
- package/src/components/HkPopover.tsx +410 -0
- package/src/components/HkPopupSelect.scss +136 -0
- package/src/components/HkPopupSelect.tsx +199 -0
- package/src/components/HkProgressBar.scss +106 -0
- package/src/components/HkProgressBar.tsx +61 -0
- package/src/components/HkProgressDialog.tsx +67 -0
- package/src/components/HkProgressRing.scss +56 -0
- package/src/components/HkProgressRing.tsx +82 -0
- package/src/components/HkRadio.scss +119 -0
- package/src/components/HkRadio.tsx +75 -0
- package/src/components/HkRollingNumber.scss +37 -0
- package/src/components/HkRollingNumber.tsx +97 -0
- package/src/components/HkScrollContainer.scss +101 -0
- package/src/components/HkScrollContainer.tsx +362 -0
- package/src/components/HkSearchInput.scss +132 -0
- package/src/components/HkSearchInput.tsx +117 -0
- package/src/components/HkSelect.scss +143 -0
- package/src/components/HkSelect.tsx +230 -0
- package/src/components/HkSelectionGrid.scss +177 -0
- package/src/components/HkSelectionGrid.tsx +99 -0
- package/src/components/HkSelectionWaterfall.scss +93 -0
- package/src/components/HkSelectionWaterfall.tsx +90 -0
- package/src/components/HkSidebar.scss +81 -0
- package/src/components/HkSidebar.tsx +45 -0
- package/src/components/HkSkeleton.scss +44 -0
- package/src/components/HkSkeleton.tsx +30 -0
- package/src/components/HkSkeletonList.tsx +35 -0
- package/src/components/HkSpinner.scss +67 -0
- package/src/components/HkSpinner.tsx +41 -0
- package/src/components/HkSplash.scss +60 -0
- package/src/components/HkSplash.tsx +40 -0
- package/src/components/HkSwitch.scss +157 -0
- package/src/components/HkSwitch.tsx +72 -0
- package/src/components/HkTable.scss +198 -0
- package/src/components/HkTable.tsx +246 -0
- package/src/components/HkTabs.scss +109 -0
- package/src/components/HkTabs.tsx +111 -0
- package/src/components/HkTag.scss +88 -0
- package/src/components/HkTag.tsx +44 -0
- package/src/components/HkTextarea.scss +72 -0
- package/src/components/HkTextarea.tsx +104 -0
- package/src/components/HkTimeline.scss +139 -0
- package/src/components/HkTimeline.tsx +95 -0
- package/src/components/HkToast.scss +168 -0
- package/src/components/HkToast.tsx +175 -0
- package/src/components/HkTooltip.scss +47 -0
- package/src/components/HkTooltip.tsx +108 -0
- package/src/components/HkTree.scss +188 -0
- package/src/components/HkTree.tsx +217 -0
- package/src/components/HkTrendChart.tsx +180 -0
- package/src/components/HkWindowedItem.scss +17 -0
- package/src/components/HkWindowedItem.tsx +107 -0
- package/src/components/HkZoomToolbar.scss +35 -0
- package/src/components/HkZoomToolbar.tsx +69 -0
- package/src/composables/useBreakpoint.ts +41 -0
- package/src/composables/useClipboard.ts +37 -0
- package/src/composables/useConfirm.ts +35 -0
- package/src/composables/useProgressDialog.ts +52 -0
- package/src/composables/useReportedTransition.ts +69 -0
- package/src/composables/useScrollWindow.ts +21 -0
- package/src/composables/useToast.ts +2 -0
- package/src/demo.scss +24 -0
- package/src/demo.ts +22 -0
- package/src/env.d.ts +6 -0
- package/src/i18n/context.ts +89 -0
- package/src/i18n/locales/ar/components.json +43 -0
- package/src/i18n/locales/ar/components.toml +40 -0
- package/src/i18n/locales/de/components.json +43 -0
- package/src/i18n/locales/de/components.toml +40 -0
- package/src/i18n/locales/en/components.json +43 -0
- package/src/i18n/locales/en/components.toml +40 -0
- package/src/i18n/locales/es/components.json +43 -0
- package/src/i18n/locales/es/components.toml +40 -0
- package/src/i18n/locales/fr/components.json +43 -0
- package/src/i18n/locales/fr/components.toml +40 -0
- package/src/i18n/locales/ja/components.json +43 -0
- package/src/i18n/locales/ja/components.toml +40 -0
- package/src/i18n/locales/ko/components.json +43 -0
- package/src/i18n/locales/ko/components.toml +40 -0
- package/src/i18n/locales/pt/components.json +43 -0
- package/src/i18n/locales/pt/components.toml +40 -0
- package/src/i18n/locales/ru/components.json +43 -0
- package/src/i18n/locales/ru/components.toml +40 -0
- package/src/i18n/locales/zh-Hans/components.json +43 -0
- package/src/i18n/locales/zh-Hans/components.toml +40 -0
- package/src/i18n/locales/zh-Hant/components.json +43 -0
- package/src/i18n/locales/zh-Hant/components.toml +40 -0
- package/src/index.ts +137 -0
- package/src/render.ts +18 -0
- package/src/runtime/animationBus.ts +278 -0
- package/src/runtime/cronBus.ts +25 -0
- package/src/runtime/index.ts +12 -0
- package/src/runtime/useAsyncData.ts +30 -0
- package/src/runtime/useBreakpoint.ts +62 -0
- package/src/runtime/useClipboard.ts +37 -0
- package/src/runtime/useConfirm.ts +35 -0
- package/src/runtime/useOverlay.ts +82 -0
- package/src/runtime/usePopupManager.ts +89 -0
- package/src/runtime/useToast.ts +140 -0
- package/src/styles/index.scss +10 -0
- package/src/theme/index.ts +5 -0
- package/src/theme/presets.ts +307 -0
- package/src/theme/theme.scss +17 -0
- package/src/theme/useBackgroundLuminance.ts +145 -0
- package/src/theme/useSolarTime.ts +101 -0
- package/src/theme/useTheme.ts +141 -0
- package/src/tokens.scss +26 -0
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import { computed, defineComponent, onBeforeUnmount, ref, Transition, watch, type PropType } from "vue";
|
|
2
|
+
import { ArrowLeft, Calendar, ChevronDown, ChevronLeft, ChevronRight, ChevronUp } from "lucide-vue-next";
|
|
3
|
+
|
|
4
|
+
import { useI18n } from "../i18n/context";
|
|
5
|
+
import "./HkDateTimePicker.scss";
|
|
6
|
+
import HPopover from "./HkPopover";
|
|
7
|
+
|
|
8
|
+
function startOfDay(d: Date): Date {
|
|
9
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function sameDay(a: Date, b: Date): boolean {
|
|
13
|
+
return a.getFullYear() === b.getFullYear()
|
|
14
|
+
&& a.getMonth() === b.getMonth()
|
|
15
|
+
&& a.getDate() === b.getDate();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function dayKeyOf(d: Date): string {
|
|
19
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type ViewKind = "days" | "months" | "years";
|
|
23
|
+
|
|
24
|
+
const MONTH_NAMES = [
|
|
25
|
+
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
|
26
|
+
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const MONTH_NAMES_LONG = [
|
|
30
|
+
"January", "February", "March", "April", "May", "June",
|
|
31
|
+
"July", "August", "September", "October", "November", "December",
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const WEEKDAY_NAMES = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
35
|
+
|
|
36
|
+
export default defineComponent({
|
|
37
|
+
name: "HkDateTimePicker",
|
|
38
|
+
props: {
|
|
39
|
+
modelValue: { type: Date, required: true },
|
|
40
|
+
min: { type: [Date, null] as unknown as PropType<Date | null>, default: null },
|
|
41
|
+
max: { type: [Date, null] as unknown as PropType<Date | null>, default: null },
|
|
42
|
+
markedDays: { type: Set as unknown as PropType<Set<string>>, default: () => new Set<string>() },
|
|
43
|
+
mode: { type: String as PropType<"inline" | "popup">, default: "inline" },
|
|
44
|
+
placement: { type: String, default: "bottom-start" },
|
|
45
|
+
offset: { type: Number, default: 6 },
|
|
46
|
+
confirmLabel: { type: String, default: undefined },
|
|
47
|
+
showTime: { type: Boolean, default: true },
|
|
48
|
+
},
|
|
49
|
+
emits: {
|
|
50
|
+
"update:modelValue": (_d: Date) => true,
|
|
51
|
+
open: () => true,
|
|
52
|
+
confirm: () => true,
|
|
53
|
+
},
|
|
54
|
+
setup(props, { emit, slots }) {
|
|
55
|
+
const { t } = useI18n();
|
|
56
|
+
const viewYear = ref(props.modelValue.getFullYear());
|
|
57
|
+
const viewMonth = ref(props.modelValue.getMonth());
|
|
58
|
+
const view = ref<ViewKind>("days");
|
|
59
|
+
const viewStack = ref<ViewKind[]>([]);
|
|
60
|
+
|
|
61
|
+
function drillTo(next: ViewKind) {
|
|
62
|
+
viewStack.value.push(view.value);
|
|
63
|
+
view.value = next;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function goBack() {
|
|
67
|
+
const prev = viewStack.value.pop();
|
|
68
|
+
view.value = prev ?? "days";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
watch(
|
|
72
|
+
() => props.modelValue,
|
|
73
|
+
(d) => {
|
|
74
|
+
if (d.getFullYear() !== viewYear.value || d.getMonth() !== viewMonth.value) {
|
|
75
|
+
viewYear.value = d.getFullYear();
|
|
76
|
+
viewMonth.value = d.getMonth();
|
|
77
|
+
}
|
|
78
|
+
view.value = "days";
|
|
79
|
+
viewStack.value = [];
|
|
80
|
+
},
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const monthName = computed(() =>
|
|
84
|
+
MONTH_NAMES_LONG[viewMonth.value],
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const yearBlockStart = computed(() =>
|
|
88
|
+
viewYear.value - (viewYear.value % 12),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const cells = computed(() => {
|
|
92
|
+
const first = new Date(viewYear.value, viewMonth.value, 1);
|
|
93
|
+
const start = new Date(first);
|
|
94
|
+
start.setDate(first.getDate() - first.getDay());
|
|
95
|
+
const out: Date[] = [];
|
|
96
|
+
for (let i = 0; i < 42; i++) {
|
|
97
|
+
const d = new Date(start);
|
|
98
|
+
d.setDate(start.getDate() + i);
|
|
99
|
+
out.push(d);
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const now = new Date();
|
|
105
|
+
|
|
106
|
+
function shiftMonth(delta: number) {
|
|
107
|
+
const d = new Date(viewYear.value, viewMonth.value + delta, 1);
|
|
108
|
+
viewYear.value = d.getFullYear();
|
|
109
|
+
viewMonth.value = d.getMonth();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function shiftYear(delta: number) {
|
|
113
|
+
viewYear.value = viewYear.value + delta;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function pickMonth(i: number) {
|
|
117
|
+
viewMonth.value = i;
|
|
118
|
+
goBack();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function pickYear(y: number) {
|
|
122
|
+
viewYear.value = y;
|
|
123
|
+
goBack();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function isDisabled(d: Date): boolean {
|
|
127
|
+
const day = startOfDay(d);
|
|
128
|
+
if (props.min && day < startOfDay(props.min)) return true;
|
|
129
|
+
if (props.max && day > startOfDay(props.max)) return true;
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function selectDay(d: Date) {
|
|
134
|
+
if (isDisabled(d)) return;
|
|
135
|
+
const next = new Date(
|
|
136
|
+
d.getFullYear(), d.getMonth(), d.getDate(),
|
|
137
|
+
props.modelValue.getHours(), props.modelValue.getMinutes(),
|
|
138
|
+
);
|
|
139
|
+
emit("update:modelValue", next);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function setHM(h: number, m: number) {
|
|
143
|
+
const cur = props.modelValue;
|
|
144
|
+
emit("update:modelValue", new Date(cur.getFullYear(), cur.getMonth(), cur.getDate(), h, m));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function bump(field: "h" | "m", delta: number) {
|
|
148
|
+
const cur = props.modelValue;
|
|
149
|
+
if (field === "h") setHM((cur.getHours() + delta + 24) % 24, cur.getMinutes());
|
|
150
|
+
else setHM(cur.getHours(), (cur.getMinutes() + delta + 60) % 60);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function jumpToday() {
|
|
154
|
+
const tgt = props.max && startOfDay(props.max) < startOfDay(now) ? props.max : now;
|
|
155
|
+
viewYear.value = tgt.getFullYear();
|
|
156
|
+
viewMonth.value = tgt.getMonth();
|
|
157
|
+
selectDay(tgt);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const pad = (n: number) => (n < 10 ? `0${n}` : String(n));
|
|
161
|
+
|
|
162
|
+
function stepper(label: string, value: number, onUp: () => void, onDown: () => void) {
|
|
163
|
+
return (
|
|
164
|
+
<div class="hk-dtp-step">
|
|
165
|
+
<button class="hk-dtp-step-btn" type="button" aria-label={`${label} +`} onClick={onUp}>
|
|
166
|
+
<ChevronUp size={13} />
|
|
167
|
+
</button>
|
|
168
|
+
<span class="hk-dtp-step-val">{pad(value)}</span>
|
|
169
|
+
<button class="hk-dtp-step-btn" type="button" aria-label={`${label} -`} onClick={onDown}>
|
|
170
|
+
<ChevronDown size={13} />
|
|
171
|
+
</button>
|
|
172
|
+
</div>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// ── Popup-mode state ────────────────────────────────────────────
|
|
177
|
+
const open = ref(false);
|
|
178
|
+
function toggleOpen() { open.value = !open.value; if (open.value) emit("open"); }
|
|
179
|
+
function onConfirm() { emit("confirm"); open.value = false; }
|
|
180
|
+
|
|
181
|
+
const triggerLabel = computed(() => {
|
|
182
|
+
const d = props.modelValue;
|
|
183
|
+
const month = MONTH_NAMES[d.getMonth()];
|
|
184
|
+
const day = d.getDate();
|
|
185
|
+
if (props.showTime) {
|
|
186
|
+
const h = pad(d.getHours());
|
|
187
|
+
const m = pad(d.getMinutes());
|
|
188
|
+
return `${month} ${day}, ${h}:${m}`;
|
|
189
|
+
}
|
|
190
|
+
return `${month} ${day}, ${d.getFullYear()}`;
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// ── Header ──────────────────────────────────────────────────────
|
|
194
|
+
|
|
195
|
+
function renderHeader() {
|
|
196
|
+
if (view.value === "years") {
|
|
197
|
+
return (
|
|
198
|
+
<div class="hk-dtp-header">
|
|
199
|
+
<div class="hk-dtp-header-side">
|
|
200
|
+
<button class="hk-dtp-back" type="button" aria-label={t("hk.dateTimePicker.back", "Back")} onClick={goBack}>
|
|
201
|
+
<ArrowLeft size={15} />
|
|
202
|
+
</button>
|
|
203
|
+
<button class="hk-dtp-nav" type="button" aria-label={t("hk.dateTimePicker.prevYears", "Previous years")} onClick={() => shiftYear(-12)}>
|
|
204
|
+
<ChevronLeft size={16} />
|
|
205
|
+
</button>
|
|
206
|
+
</div>
|
|
207
|
+
<div class="hk-dtp-title">{yearBlockStart.value}–{yearBlockStart.value + 11}</div>
|
|
208
|
+
<div class="hk-dtp-header-side" data-side="right">
|
|
209
|
+
<button class="hk-dtp-nav" type="button" aria-label={t("hk.dateTimePicker.nextYears", "Next years")} onClick={() => shiftYear(12)}>
|
|
210
|
+
<ChevronRight size={16} />
|
|
211
|
+
</button>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (view.value === "months") {
|
|
218
|
+
return (
|
|
219
|
+
<div class="hk-dtp-header">
|
|
220
|
+
<div class="hk-dtp-header-side">
|
|
221
|
+
<button class="hk-dtp-back" type="button" aria-label={t("hk.dateTimePicker.back", "Back")} onClick={goBack}>
|
|
222
|
+
<ArrowLeft size={15} />
|
|
223
|
+
</button>
|
|
224
|
+
</div>
|
|
225
|
+
<div class="hk-dtp-title">
|
|
226
|
+
<button class="hk-dtp-title-btn" type="button" onClick={() => drillTo("years")}>
|
|
227
|
+
{viewYear.value}
|
|
228
|
+
</button>
|
|
229
|
+
</div>
|
|
230
|
+
<div class="hk-dtp-header-side" data-side="right" />
|
|
231
|
+
</div>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return (
|
|
236
|
+
<div class="hk-dtp-header">
|
|
237
|
+
<div class="hk-dtp-header-side">
|
|
238
|
+
<button class="hk-dtp-nav" type="button" aria-label={t("hk.dateTimePicker.prevMonth", "Previous month")} onClick={() => shiftMonth(-1)}>
|
|
239
|
+
<ChevronLeft size={16} />
|
|
240
|
+
</button>
|
|
241
|
+
</div>
|
|
242
|
+
<div class="hk-dtp-title">
|
|
243
|
+
<button class="hk-dtp-title-btn" type="button" onClick={() => drillTo("months")}>{monthName.value}</button>
|
|
244
|
+
<button class="hk-dtp-title-btn" type="button" onClick={() => drillTo("years")}>{viewYear.value}</button>
|
|
245
|
+
</div>
|
|
246
|
+
<div class="hk-dtp-header-side" data-side="right">
|
|
247
|
+
<button class="hk-dtp-nav" type="button" aria-label={t("hk.dateTimePicker.nextMonth", "Next month")} onClick={() => shiftMonth(1)}>
|
|
248
|
+
<ChevronRight size={16} />
|
|
249
|
+
</button>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function renderContent() {
|
|
256
|
+
if (view.value === "months") {
|
|
257
|
+
return (
|
|
258
|
+
<div class="hk-dtp-grid" data-variant="pick">
|
|
259
|
+
{MONTH_NAMES.map((name, i) => {
|
|
260
|
+
const selected = viewYear.value === props.modelValue.getFullYear() && i === props.modelValue.getMonth();
|
|
261
|
+
const isNow = viewYear.value === now.getFullYear() && i === now.getMonth();
|
|
262
|
+
return (
|
|
263
|
+
<button
|
|
264
|
+
key={i}
|
|
265
|
+
type="button"
|
|
266
|
+
class={[
|
|
267
|
+
"hk-dtp-cell",
|
|
268
|
+
selected ? "is-selected" : "",
|
|
269
|
+
isNow ? "is-today" : "",
|
|
270
|
+
].filter(Boolean).join(" ")}
|
|
271
|
+
data-variant="pick"
|
|
272
|
+
onClick={() => pickMonth(i)}
|
|
273
|
+
>
|
|
274
|
+
{name}
|
|
275
|
+
</button>
|
|
276
|
+
);
|
|
277
|
+
})}
|
|
278
|
+
</div>
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (view.value === "years") {
|
|
283
|
+
return (
|
|
284
|
+
<div class="hk-dtp-grid" data-variant="pick">
|
|
285
|
+
{Array.from({ length: 12 }, (_, k) => yearBlockStart.value + k).map((y) => {
|
|
286
|
+
const selected = y === props.modelValue.getFullYear();
|
|
287
|
+
const isNow = y === now.getFullYear();
|
|
288
|
+
return (
|
|
289
|
+
<button
|
|
290
|
+
key={y}
|
|
291
|
+
type="button"
|
|
292
|
+
class={[
|
|
293
|
+
"hk-dtp-cell",
|
|
294
|
+
selected ? "is-selected" : "",
|
|
295
|
+
isNow ? "is-today" : "",
|
|
296
|
+
].filter(Boolean).join(" ")}
|
|
297
|
+
data-variant="pick"
|
|
298
|
+
onClick={() => pickYear(y)}
|
|
299
|
+
>
|
|
300
|
+
{y}
|
|
301
|
+
</button>
|
|
302
|
+
);
|
|
303
|
+
})}
|
|
304
|
+
</div>
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// days
|
|
309
|
+
return (
|
|
310
|
+
<>
|
|
311
|
+
<div class="hk-dtp-weekdays">
|
|
312
|
+
{WEEKDAY_NAMES.map((w, i) => (
|
|
313
|
+
<span key={i} class="hk-dtp-wd">{w}</span>
|
|
314
|
+
))}
|
|
315
|
+
</div>
|
|
316
|
+
<div class="hk-dtp-grid">
|
|
317
|
+
{cells.value.map((d, i) => {
|
|
318
|
+
const outOfMonth = d.getMonth() !== viewMonth.value;
|
|
319
|
+
const disabled = isDisabled(d);
|
|
320
|
+
const selected = sameDay(d, props.modelValue);
|
|
321
|
+
const isToday = sameDay(d, now);
|
|
322
|
+
const marked = props.markedDays.has(dayKeyOf(d));
|
|
323
|
+
return (
|
|
324
|
+
<button
|
|
325
|
+
key={i}
|
|
326
|
+
type="button"
|
|
327
|
+
class={[
|
|
328
|
+
"hk-dtp-cell",
|
|
329
|
+
outOfMonth ? "is-out" : "",
|
|
330
|
+
disabled ? "is-disabled" : "",
|
|
331
|
+
selected ? "is-selected" : "",
|
|
332
|
+
isToday ? "is-today" : "",
|
|
333
|
+
].filter(Boolean).join(" ")}
|
|
334
|
+
disabled={disabled}
|
|
335
|
+
onClick={() => selectDay(d)}
|
|
336
|
+
>
|
|
337
|
+
<span class="hk-dtp-cell-num">{d.getDate()}</span>
|
|
338
|
+
{marked && !selected && <span class="hk-dtp-cell-dot" />}
|
|
339
|
+
</button>
|
|
340
|
+
);
|
|
341
|
+
})}
|
|
342
|
+
</div>
|
|
343
|
+
</>
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function renderBody() {
|
|
348
|
+
return (
|
|
349
|
+
<div class="hk-dtp-stage">
|
|
350
|
+
<Transition name="hk-dtp-pane">
|
|
351
|
+
<div key={view.value} class="hk-dtp-pane">
|
|
352
|
+
{renderHeader()}
|
|
353
|
+
{renderContent()}
|
|
354
|
+
{view.value === "days" && (
|
|
355
|
+
<div class="hk-dtp-time">
|
|
356
|
+
{props.showTime ? (
|
|
357
|
+
<>
|
|
358
|
+
{stepper(t("hk.dateTimePicker.hour", "Hour"), props.modelValue.getHours(), () => bump("h", 1), () => bump("h", -1))}
|
|
359
|
+
<span class="hk-dtp-time-sep">:</span>
|
|
360
|
+
{stepper(t("hk.dateTimePicker.minute", "Minute"), props.modelValue.getMinutes(), () => bump("m", 1), () => bump("m", -1))}
|
|
361
|
+
</>
|
|
362
|
+
) : null}
|
|
363
|
+
<button class="hk-dtp-today" type="button" onClick={jumpToday}>
|
|
364
|
+
{t("hk.dateTimePicker.today", "Today")}
|
|
365
|
+
</button>
|
|
366
|
+
</div>
|
|
367
|
+
)}
|
|
368
|
+
</div>
|
|
369
|
+
</Transition>
|
|
370
|
+
</div>
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return () => {
|
|
375
|
+
const body = (
|
|
376
|
+
<div class="hk-dtp" role="group" aria-label={t("hk.dateTimePicker.pickDate", "Pick a date and time")}>
|
|
377
|
+
{renderBody()}
|
|
378
|
+
{props.mode === "popup" && props.confirmLabel && (
|
|
379
|
+
<div class="hk-dtp-popup-foot">
|
|
380
|
+
<button class="hk-dtp-popup-confirm" type="button" onClick={onConfirm}>
|
|
381
|
+
{props.confirmLabel}
|
|
382
|
+
</button>
|
|
383
|
+
</div>
|
|
384
|
+
)}
|
|
385
|
+
</div>
|
|
386
|
+
);
|
|
387
|
+
|
|
388
|
+
if (props.mode !== "popup") {
|
|
389
|
+
return body;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return (
|
|
393
|
+
<HPopover
|
|
394
|
+
modelValue={open.value}
|
|
395
|
+
onUpdate:modelValue={(v: boolean) => { open.value = v; }}
|
|
396
|
+
>
|
|
397
|
+
{{
|
|
398
|
+
trigger: () => (
|
|
399
|
+
<div class="hk-dtp-trigger-wrap" onClick={toggleOpen}>
|
|
400
|
+
{slots.trigger
|
|
401
|
+
? slots.trigger({ open: open.value })
|
|
402
|
+
: (
|
|
403
|
+
<button class="hk-dtp-trigger" type="button" aria-expanded={open.value}>
|
|
404
|
+
<Calendar size={14} class="hk-dtp-trigger-icon" />
|
|
405
|
+
<span class="hk-dtp-trigger-val">{triggerLabel.value}</span>
|
|
406
|
+
<ChevronDown
|
|
407
|
+
size={14}
|
|
408
|
+
class={["hk-dtp-trigger-chev", open.value ? "is-open" : ""].filter(Boolean).join(" ")}
|
|
409
|
+
/>
|
|
410
|
+
</button>
|
|
411
|
+
)}
|
|
412
|
+
</div>
|
|
413
|
+
),
|
|
414
|
+
default: () => (
|
|
415
|
+
<div class="hk-dtp-popup">
|
|
416
|
+
{body}
|
|
417
|
+
</div>
|
|
418
|
+
),
|
|
419
|
+
}}
|
|
420
|
+
</HPopover>
|
|
421
|
+
);
|
|
422
|
+
};
|
|
423
|
+
},
|
|
424
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
.hk-divider {
|
|
2
|
+
--hk-divider-color: var(--hi-color-border, rgba(0, 0, 0, 0.12));
|
|
3
|
+
flex-shrink: 0;
|
|
4
|
+
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 0;
|
|
7
|
+
border-top: 1px solid var(--hk-divider-color);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.hk-divider-vertical {
|
|
11
|
+
width: 0;
|
|
12
|
+
height: auto;
|
|
13
|
+
align-self: stretch;
|
|
14
|
+
border-top: none;
|
|
15
|
+
border-left: 1px solid var(--hk-divider-color);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.hk-divider-faint {
|
|
19
|
+
--hk-divider-color: var(--hi-color-border, rgba(0, 0, 0, 0.06));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.hk-divider-input {
|
|
23
|
+
--hk-divider-color: var(--hi-color-border, rgba(0, 0, 0, 0.15));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.hk-divider-dashed.hk-divider-vertical {
|
|
27
|
+
border-left-style: dashed;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.hk-divider-dashed:not(.hk-divider-vertical) {
|
|
31
|
+
border-top-style: dashed;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.hk-divider-spacing-xs {
|
|
35
|
+
--hk-divider-space: var(--hi-space-2, 0.125rem);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.hk-divider-spacing-sm {
|
|
39
|
+
--hk-divider-space: var(--hi-space-4, 0.25rem);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.hk-divider-spacing-md {
|
|
43
|
+
--hk-divider-space: var(--hi-space-6, 0.375rem);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.hk-divider-spacing-lg {
|
|
47
|
+
--hk-divider-space: var(--hi-space-8, 0.5rem);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.hk-divider-spacing-xl {
|
|
51
|
+
--hk-divider-space: var(--hi-space-12, 0.75rem);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.hk-divider[class*="hk-divider-spacing-"]:not(.hk-divider-vertical) {
|
|
55
|
+
margin-block: var(--hk-divider-space);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.hk-divider-vertical[class*="hk-divider-spacing-"] {
|
|
59
|
+
margin-inline: var(--hk-divider-space);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.hk-divider-vertical.hk-divider-length-xs {
|
|
63
|
+
align-self: center;
|
|
64
|
+
height: var(--hi-space-8, 0.5rem);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.hk-divider-vertical.hk-divider-length-sm {
|
|
68
|
+
align-self: center;
|
|
69
|
+
height: var(--hi-space-12, 0.75rem);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.hk-divider-vertical.hk-divider-length-md {
|
|
73
|
+
align-self: center;
|
|
74
|
+
height: var(--hi-space-16, 1rem);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.hk-divider-vertical.hk-divider-length-lg {
|
|
78
|
+
align-self: center;
|
|
79
|
+
height: var(--hi-space-24, 1.5rem);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.hk-divider-vertical.hk-divider-length-xl {
|
|
83
|
+
align-self: center;
|
|
84
|
+
height: var(--hi-space-32, 2rem);
|
|
85
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { defineComponent, type PropType } from "vue";
|
|
2
|
+
|
|
3
|
+
import "./HkDivider.scss";
|
|
4
|
+
|
|
5
|
+
type DividerOrientation = "horizontal" | "vertical";
|
|
6
|
+
type DividerTone = "faint" | "subtle" | "input";
|
|
7
|
+
type DividerVariant = "solid" | "dashed";
|
|
8
|
+
type DividerSpacing = "none" | "xs" | "sm" | "md" | "lg" | "xl";
|
|
9
|
+
type DividerLength = "stretch" | "xs" | "sm" | "md" | "lg" | "xl";
|
|
10
|
+
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
name: "HkDivider",
|
|
13
|
+
props: {
|
|
14
|
+
orientation: {
|
|
15
|
+
type: String as PropType<DividerOrientation>,
|
|
16
|
+
default: "horizontal",
|
|
17
|
+
},
|
|
18
|
+
tone: {
|
|
19
|
+
type: String as PropType<DividerTone>,
|
|
20
|
+
default: "subtle",
|
|
21
|
+
},
|
|
22
|
+
variant: {
|
|
23
|
+
type: String as PropType<DividerVariant>,
|
|
24
|
+
default: "solid",
|
|
25
|
+
},
|
|
26
|
+
spacing: {
|
|
27
|
+
type: String as PropType<DividerSpacing>,
|
|
28
|
+
default: "none",
|
|
29
|
+
},
|
|
30
|
+
length: {
|
|
31
|
+
type: String as PropType<DividerLength>,
|
|
32
|
+
default: "stretch",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
setup(props) {
|
|
36
|
+
return () => (
|
|
37
|
+
<div
|
|
38
|
+
class={[
|
|
39
|
+
"hk-divider",
|
|
40
|
+
props.orientation === "vertical" && "hk-divider-vertical",
|
|
41
|
+
props.variant === "dashed" && "hk-divider-dashed",
|
|
42
|
+
props.tone === "faint" && "hk-divider-faint",
|
|
43
|
+
props.tone === "input" && "hk-divider-input",
|
|
44
|
+
props.spacing !== "none" && `hk-divider-spacing-${props.spacing}`,
|
|
45
|
+
props.length !== "stretch" && `hk-divider-length-${props.length}`,
|
|
46
|
+
]}
|
|
47
|
+
aria-hidden="true"
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
.hk-draggable-grid {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 0.5rem;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.hk-draggable-grid-row {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-wrap: nowrap;
|
|
10
|
+
gap: 0.5rem;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.hk-draggable-grid-row-phantom {
|
|
14
|
+
min-height: 44px;
|
|
15
|
+
border: 1px dashed var(--hi-color-primary, #58a6ff);
|
|
16
|
+
border-radius: 4px;
|
|
17
|
+
background: rgb(from var(--hi-color-primary, #58a6ff) r g b / 0.04);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.hk-draggable-grid-cell {
|
|
21
|
+
flex: 0 0 calc((100% - (var(--hk-grid-cols, 3) - 1) * 0.5rem) / var(--hk-grid-cols, 3));
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: 0.5rem;
|
|
25
|
+
min-height: 44px;
|
|
26
|
+
padding: 0.5rem 0.625rem;
|
|
27
|
+
border-radius: 4px;
|
|
28
|
+
background: var(--hi-color-bg-subtle, #21262d);
|
|
29
|
+
border: 1px solid var(--hi-color-border, #30363d);
|
|
30
|
+
transition:
|
|
31
|
+
transform 150ms cubic-bezier(0.16, 1, 0.3, 1),
|
|
32
|
+
opacity 150ms cubic-bezier(0.16, 1, 0.3, 1),
|
|
33
|
+
border-color 150ms ease,
|
|
34
|
+
background 150ms ease,
|
|
35
|
+
box-shadow 150ms ease;
|
|
36
|
+
user-select: none;
|
|
37
|
+
-webkit-user-select: none;
|
|
38
|
+
transform-origin: center;
|
|
39
|
+
|
|
40
|
+
&:hover {
|
|
41
|
+
border-color: var(--hi-color-text-tertiary, #8b949e);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&[data-dragging] {
|
|
45
|
+
opacity: 0.35;
|
|
46
|
+
transform: scale(0.96);
|
|
47
|
+
border-style: dashed;
|
|
48
|
+
border-color: var(--hi-color-primary, #58a6ff);
|
|
49
|
+
background: rgb(from var(--hi-color-primary, #58a6ff) r g b / 0.04);
|
|
50
|
+
cursor: grabbing;
|
|
51
|
+
z-index: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&[data-placeholder="before"] {
|
|
55
|
+
box-shadow: inset 2px 0 0 0 var(--hi-color-primary, #58a6ff);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&[data-locked] {
|
|
59
|
+
opacity: 0.65;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.hk-draggable-grid[data-dragging] & {
|
|
63
|
+
&:hover {
|
|
64
|
+
border-color: var(--hi-color-border, #30363d);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.hk-draggable-grid-row[data-placeholder-row="after"] {
|
|
70
|
+
box-shadow: inset -2px 0 0 0 var(--hi-color-primary, #58a6ff);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.hk-draggable-grid-cell-placeholder-target {
|
|
74
|
+
border: none;
|
|
75
|
+
background: transparent;
|
|
76
|
+
min-height: 44px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.hk-draggable-grid-handle {
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
width: 20px;
|
|
84
|
+
flex-shrink: 0;
|
|
85
|
+
color: var(--hi-color-text-tertiary, #8b949e);
|
|
86
|
+
cursor: grab;
|
|
87
|
+
touch-action: none;
|
|
88
|
+
|
|
89
|
+
&:active {
|
|
90
|
+
cursor: grabbing;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&[data-hidden] {
|
|
94
|
+
visibility: hidden;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.hk-draggable-grid-content {
|
|
99
|
+
flex: 1;
|
|
100
|
+
min-width: 0;
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
gap: 0.5rem;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.hk-draggable-grid-ghost {
|
|
107
|
+
position: fixed;
|
|
108
|
+
top: 0;
|
|
109
|
+
left: 0;
|
|
110
|
+
margin: 0;
|
|
111
|
+
transform: translate3d(0, 0, 0) scale(1.02);
|
|
112
|
+
opacity: 0.85;
|
|
113
|
+
box-shadow:
|
|
114
|
+
0 8px 24px rgb(0 0 0 / 28%),
|
|
115
|
+
0 2px 6px rgb(0 0 0 / 18%);
|
|
116
|
+
border-radius: 4px;
|
|
117
|
+
background: var(--hi-color-bg-elevated, #161b22);
|
|
118
|
+
backdrop-filter: blur(2px);
|
|
119
|
+
pointer-events: none;
|
|
120
|
+
z-index: 9999;
|
|
121
|
+
will-change: transform;
|
|
122
|
+
|
|
123
|
+
> .hk-draggable-grid-cell {
|
|
124
|
+
margin: 0;
|
|
125
|
+
border-color: transparent;
|
|
126
|
+
background: transparent;
|
|
127
|
+
box-shadow: none;
|
|
128
|
+
transform: none;
|
|
129
|
+
opacity: 1;
|
|
130
|
+
width: 100%;
|
|
131
|
+
}
|
|
132
|
+
}
|