@firstnoodle-ui/bui 0.0.26 → 0.0.28
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/LICENSE +21 -21
- package/dist/bui.css +1 -1
- package/dist/components/calendar-view/CalendarView.vue.d.ts +21 -0
- package/dist/components/calendar-view/components/DateButton.vue.d.ts +10 -0
- package/dist/components/calendar-view/components/DecadeView.vue.d.ts +12 -0
- package/dist/components/calendar-view/components/MonthView.vue.d.ts +17 -0
- package/dist/components/calendar-view/components/YearView.vue.d.ts +13 -0
- package/dist/components/calendar-view/composables/useCalendar.d.ts +44 -0
- package/dist/components/calendar-view/index.d.ts +1 -0
- package/dist/components/calendar-view/utils/enums.d.ts +29 -0
- package/dist/components/calendar-view/utils/index.d.ts +23 -0
- package/dist/components/calendar-view/utils/types.d.ts +12 -0
- package/dist/components/calendar-view/utils/utils/calendar.d.ts +22 -0
- package/dist/components/calendar-view/utils/utils/date.d.ts +15 -0
- package/dist/components/calendar-view/utils/utils/format.d.ts +18 -0
- package/dist/components/calendar-view/utils/utils/time.d.ts +35 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/notification-badge/NotificationBadge.vue.d.ts +5 -0
- package/dist/components/notification-badge/index.d.ts +1 -0
- package/dist/components/select-list/components/option-group/OptionGroup.vue.d.ts +1 -0
- package/dist/components/select-list/components/select-list-option/SelectListOption.vue.d.ts +1 -0
- package/dist/components/select-list/types.d.ts +1 -0
- package/dist/components/types.d.ts +1 -1
- package/dist/index.mjs +7056 -6465
- package/dist/utils/capitalizeFirstLetter.d.ts +1 -0
- package/package.json +4 -3
- package/src/components/application-wrapper/ApplicationWrapper.vue +8 -0
- package/src/components/application-wrapper/index.ts +1 -0
- package/src/components/aside-section-label/AsideSectionLabel.vue +16 -0
- package/src/components/aside-section-label/index.ts +1 -0
- package/src/components/button/Button.vue +246 -0
- package/src/components/button/NotificationBadge.vue +15 -0
- package/src/components/button/components/button-label/ButtonLabel.vue +9 -0
- package/src/components/button/components/button-label/index.ts +1 -0
- package/src/components/button/components/index.ts +3 -0
- package/src/components/button/components/left-group/LeftGroup.vue +5 -0
- package/src/components/button/components/left-group/index.ts +1 -0
- package/src/components/button/components/notification-badge/NotificationBadge.vue +17 -0
- package/src/components/button/components/notification-badge/index.ts +1 -0
- package/src/components/button/index.ts +1 -0
- package/src/components/button-group/ButtonGroup.vue +97 -0
- package/src/components/button-group/index.ts +1 -0
- package/src/components/calendar-view/CalendarView.vue +106 -0
- package/src/components/calendar-view/components/DateButton.vue +23 -0
- package/src/components/calendar-view/components/DecadeView.vue +50 -0
- package/src/components/calendar-view/components/MonthView.vue +72 -0
- package/src/components/calendar-view/components/NavButton.vue +16 -0
- package/src/components/calendar-view/components/YearView.vue +52 -0
- package/src/components/calendar-view/composables/useCalendar.ts +138 -0
- package/src/components/calendar-view/index.ts +1 -0
- package/src/components/calendar-view/utils/enums.ts +31 -0
- package/src/components/calendar-view/utils/index.ts +240 -0
- package/src/components/calendar-view/utils/types.ts +13 -0
- package/src/components/calendar-view/utils/utils/calendar.ts +70 -0
- package/src/components/calendar-view/utils/utils/date.ts +130 -0
- package/src/components/calendar-view/utils/utils/format.ts +61 -0
- package/src/components/calendar-view/utils/utils/time.ts +70 -0
- package/src/components/checkbox/Checkbox.vue +51 -0
- package/src/components/checkbox/CircleIndicator.vue +26 -0
- package/src/components/checkbox/DefaultIndicator.vue +19 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/collapse/Collapse.vue +114 -0
- package/src/components/collapse/index.ts +1 -0
- package/src/components/confirm-cancel/ConfirmCancel.vue +66 -0
- package/src/components/confirm-cancel/index.ts +1 -0
- package/src/components/confirm-cancel/types.ts +18 -0
- package/src/components/content-slider/ContentSlider.vue +79 -0
- package/src/components/content-slider/index.ts +1 -0
- package/src/components/data-point/DataPoint.vue +5 -0
- package/src/components/data-point/index.ts +1 -0
- package/src/components/delete-button/DeleteButton.vue +19 -0
- package/src/components/delete-button/index.ts +1 -0
- package/src/components/dialog/Dialog.vue +70 -0
- package/src/components/dialog/index.ts +1 -0
- package/src/components/fade-in-up/FadeInUp.vue +17 -0
- package/src/components/fade-in-up/index.ts +1 -0
- package/src/components/filter-chip/FilterChip.vue +28 -0
- package/src/components/filter-chip/index.ts +1 -0
- package/src/components/first-paint/FirstPaint.vue +21 -0
- package/src/components/first-paint/index.ts +1 -0
- package/src/components/first-paint/style.scss +23 -0
- package/src/components/flexbox/Flexbox.vue +51 -0
- package/src/components/flexbox/index.ts +1 -0
- package/src/components/horizontal-layout/Aside.vue +114 -0
- package/src/components/horizontal-layout/HorizontalLayout.vue +118 -0
- package/src/components/horizontal-layout/index.ts +2 -0
- package/src/components/icon/Icon.vue +1263 -0
- package/src/components/icon/index.ts +1 -0
- package/src/components/icon/utils/combine-svgs.cjs +55 -0
- package/src/components/icon/utils/combined-svgs.txt +1150 -0
- package/src/components/icon/utils/svgs/admin.svg +16 -0
- package/src/components/icon/utils/svgs/arrow-deviate.svg +3 -0
- package/src/components/icon/utils/svgs/arrow-down-plus.svg +4 -0
- package/src/components/icon/utils/svgs/arrow-down.svg +3 -0
- package/src/components/icon/utils/svgs/arrow-from.svg +3 -0
- package/src/components/icon/utils/svgs/arrow-left.svg +3 -0
- package/src/components/icon/utils/svgs/arrow-move.svg +15 -0
- package/src/components/icon/utils/svgs/arrow-right.svg +3 -0
- package/src/components/icon/utils/svgs/arrow-sub.svg +3 -0
- package/src/components/icon/utils/svgs/arrow-trend.svg +15 -0
- package/src/components/icon/utils/svgs/arrow-up-plus.svg +4 -0
- package/src/components/icon/utils/svgs/arrow-up.svg +3 -0
- package/src/components/icon/utils/svgs/authority.svg +5 -0
- package/src/components/icon/utils/svgs/beams.svg +5 -0
- package/src/components/icon/utils/svgs/bell.svg +15 -0
- package/src/components/icon/utils/svgs/bold.svg +3 -0
- package/src/components/icon/utils/svgs/box.svg +5 -0
- package/src/components/icon/utils/svgs/building.svg +15 -0
- package/src/components/icon/utils/svgs/bullet-list.svg +8 -0
- package/src/components/icon/utils/svgs/calendar.svg +21 -0
- package/src/components/icon/utils/svgs/camera.svg +5 -0
- package/src/components/icon/utils/svgs/categories.svg +3 -0
- package/src/components/icon/utils/svgs/check-circled.svg +16 -0
- package/src/components/icon/utils/svgs/check-outline.svg +15 -0
- package/src/components/icon/utils/svgs/check.svg +3 -0
- package/src/components/icon/utils/svgs/chevron-down.svg +3 -0
- package/src/components/icon/utils/svgs/chevron-left-double.svg +4 -0
- package/src/components/icon/utils/svgs/chevron-left.svg +3 -0
- package/src/components/icon/utils/svgs/chevron-right-double.svg +4 -0
- package/src/components/icon/utils/svgs/chevron-right.svg +3 -0
- package/src/components/icon/utils/svgs/chevron-up.svg +3 -0
- package/src/components/icon/utils/svgs/clock.svg +4 -0
- package/src/components/icon/utils/svgs/close-outline.svg +3 -0
- package/src/components/icon/utils/svgs/close.svg +3 -0
- package/src/components/icon/utils/svgs/columns.svg +3 -0
- package/src/components/icon/utils/svgs/conclusion.svg +17 -0
- package/src/components/icon/utils/svgs/copy.svg +16 -0
- package/src/components/icon/utils/svgs/crosshair.svg +15 -0
- package/src/components/icon/utils/svgs/dash.svg +3 -0
- package/src/components/icon/utils/svgs/dashboard.svg +3 -0
- package/src/components/icon/utils/svgs/delete.svg +4 -0
- package/src/components/icon/utils/svgs/delta.svg +3 -0
- package/src/components/icon/utils/svgs/download.svg +3 -0
- package/src/components/icon/utils/svgs/drag.svg +8 -0
- package/src/components/icon/utils/svgs/drilldown.svg +8 -0
- package/src/components/icon/utils/svgs/edit.svg +16 -0
- package/src/components/icon/utils/svgs/envelope.svg +3 -0
- package/src/components/icon/utils/svgs/error.svg +3 -0
- package/src/components/icon/utils/svgs/export-document.svg +16 -0
- package/src/components/icon/utils/svgs/filter.svg +6 -0
- package/src/components/icon/utils/svgs/filters.svg +4 -0
- package/src/components/icon/utils/svgs/flag.svg +3 -0
- package/src/components/icon/utils/svgs/folder.svg +15 -0
- package/src/components/icon/utils/svgs/frequency.svg +3 -0
- package/src/components/icon/utils/svgs/fullscreen-off.svg +3 -0
- package/src/components/icon/utils/svgs/fullscreen-on.svg +3 -0
- package/src/components/icon/utils/svgs/graduate.svg +3 -0
- package/src/components/icon/utils/svgs/hamburger.svg +5 -0
- package/src/components/icon/utils/svgs/handshake.svg +15 -0
- package/src/components/icon/utils/svgs/heading-1.svg +4 -0
- package/src/components/icon/utils/svgs/heading-2.svg +4 -0
- package/src/components/icon/utils/svgs/heading.svg +3 -0
- package/src/components/icon/utils/svgs/home.svg +3 -0
- package/src/components/icon/utils/svgs/id-card.svg +6 -0
- package/src/components/icon/utils/svgs/id.svg +4 -0
- package/src/components/icon/utils/svgs/indent-left.svg +7 -0
- package/src/components/icon/utils/svgs/indent-right.svg +7 -0
- package/src/components/icon/utils/svgs/information.svg +17 -0
- package/src/components/icon/utils/svgs/italics.svg +3 -0
- package/src/components/icon/utils/svgs/itenary.svg +11 -0
- package/src/components/icon/utils/svgs/keyboard.svg +11 -0
- package/src/components/icon/utils/svgs/lightning.svg +15 -0
- package/src/components/icon/utils/svgs/link.svg +4 -0
- package/src/components/icon/utils/svgs/list-collapse.svg +6 -0
- package/src/components/icon/utils/svgs/list-expand.svg +6 -0
- package/src/components/icon/utils/svgs/location.svg +4 -0
- package/src/components/icon/utils/svgs/lock-locked.svg +4 -0
- package/src/components/icon/utils/svgs/lock-unlocked.svg +4 -0
- package/src/components/icon/utils/svgs/magnifying-glass.svg +15 -0
- package/src/components/icon/utils/svgs/map.svg +3 -0
- package/src/components/icon/utils/svgs/megaphone.svg +3 -0
- package/src/components/icon/utils/svgs/message.svg +15 -0
- package/src/components/icon/utils/svgs/microscope.svg +3 -0
- package/src/components/icon/utils/svgs/moon.svg +3 -0
- package/src/components/icon/utils/svgs/new-document.svg +4 -0
- package/src/components/icon/utils/svgs/news.svg +15 -0
- package/src/components/icon/utils/svgs/numbered-list.svg +7 -0
- package/src/components/icon/utils/svgs/open-link.svg +16 -0
- package/src/components/icon/utils/svgs/options.svg +5 -0
- package/src/components/icon/utils/svgs/page.svg +7 -0
- package/src/components/icon/utils/svgs/paper-plane.svg +15 -0
- package/src/components/icon/utils/svgs/paper.svg +3 -0
- package/src/components/icon/utils/svgs/pen-and-paper.svg +4 -0
- package/src/components/icon/utils/svgs/phase.svg +15 -0
- package/src/components/icon/utils/svgs/photo.svg +4 -0
- package/src/components/icon/utils/svgs/pie-chart.svg +3 -0
- package/src/components/icon/utils/svgs/plus.svg +3 -0
- package/src/components/icon/utils/svgs/point-left.svg +3 -0
- package/src/components/icon/utils/svgs/point-up.svg +3 -0
- package/src/components/icon/utils/svgs/popup.svg +16 -0
- package/src/components/icon/utils/svgs/question.svg +17 -0
- package/src/components/icon/utils/svgs/radio-tower.svg +3 -0
- package/src/components/icon/utils/svgs/recycle.svg +3 -0
- package/src/components/icon/utils/svgs/redo.svg +3 -0
- package/src/components/icon/utils/svgs/refresh.svg +3 -0
- package/src/components/icon/utils/svgs/route.svg +3 -0
- package/src/components/icon/utils/svgs/rows.svg +3 -0
- package/src/components/icon/utils/svgs/scope.svg +7 -0
- package/src/components/icon/utils/svgs/settings.svg +16 -0
- package/src/components/icon/utils/svgs/share.svg +11 -0
- package/src/components/icon/utils/svgs/sign-in.svg +4 -0
- package/src/components/icon/utils/svgs/sign-up.svg +3 -0
- package/src/components/icon/utils/svgs/sort-down.svg +20 -0
- package/src/components/icon/utils/svgs/sort-up.svg +20 -0
- package/src/components/icon/utils/svgs/sort.svg +7 -0
- package/src/components/icon/utils/svgs/square-solid.svg +3 -0
- package/src/components/icon/utils/svgs/star-solid.svg +15 -0
- package/src/components/icon/utils/svgs/star.svg +15 -0
- package/src/components/icon/utils/svgs/stop-watch.svg +5 -0
- package/src/components/icon/utils/svgs/structure.svg +3 -0
- package/src/components/icon/utils/svgs/sun.svg +23 -0
- package/src/components/icon/utils/svgs/table.svg +3 -0
- package/src/components/icon/utils/svgs/tag.svg +15 -0
- package/src/components/icon/utils/svgs/team.svg +15 -0
- package/src/components/icon/utils/svgs/telescope.svg +15 -0
- package/src/components/icon/utils/svgs/trash.svg +6 -0
- package/src/components/icon/utils/svgs/triangle-angle.svg +3 -0
- package/src/components/icon/utils/svgs/triangle-side.svg +3 -0
- package/src/components/icon/utils/svgs/underline.svg +4 -0
- package/src/components/icon/utils/svgs/undo.svg +3 -0
- package/src/components/icon/utils/svgs/user.svg +16 -0
- package/src/components/icon/utils/svgs/venn.svg +3 -0
- package/src/components/icon/utils/svgs/video.svg +3 -0
- package/src/components/icon/utils/svgs/visibility-off-alt.svg +19 -0
- package/src/components/icon/utils/svgs/visibility-off.svg +3 -0
- package/src/components/icon/utils/svgs/visibility-on.svg +16 -0
- package/src/components/icon/utils/svgs/warning.svg +5 -0
- package/src/components/index.ts +45 -0
- package/src/components/input/Input.vue +118 -0
- package/src/components/input/index.ts +1 -0
- package/src/components/input-number/InputNumber.vue +112 -0
- package/src/components/input-number/StepButton.vue +23 -0
- package/src/components/input-number/index.ts +1 -0
- package/src/components/load-spinner/LoadSpinner.vue +13 -0
- package/src/components/load-spinner/index.ts +1 -0
- package/src/components/modal/Modal.vue +111 -0
- package/src/components/modal/index.ts +1 -0
- package/src/components/nav-item/NavItem.vue +62 -0
- package/src/components/nav-item/index.ts +1 -0
- package/src/components/notification/Notification.vue +53 -0
- package/src/components/notification/index.ts +1 -0
- package/src/components/notification-badge/NotificationBadge.vue +7 -0
- package/src/components/notification-badge/index.ts +1 -0
- package/src/components/pagination/Pagination.vue +65 -0
- package/src/components/pagination/index.ts +1 -0
- package/src/components/pop-confirm/PopConfirm.vue +90 -0
- package/src/components/pop-confirm/index.ts +1 -0
- package/src/components/pop-select/FooterButton.vue +5 -0
- package/src/components/pop-select/PopSelect.vue +346 -0
- package/src/components/pop-select/ResultFilters.vue +28 -0
- package/src/components/pop-select/enums.ts +7 -0
- package/src/components/pop-select/index.ts +2 -0
- package/src/components/pop-select/option.vue +51 -0
- package/src/components/popper/Popper.vue +239 -0
- package/src/components/popper/PopperContent.vue +5 -0
- package/src/components/popper/index.ts +2 -0
- package/src/components/popper/middleware.ts +19 -0
- package/src/components/screen-overlay/ScreenOverlay.vue +53 -0
- package/src/components/screen-overlay/index.ts +1 -0
- package/src/components/scrollbar/Bar.vue +106 -0
- package/src/components/scrollbar/ScrollBottomLoader.vue +25 -0
- package/src/components/scrollbar/Scrollbar.vue +219 -0
- package/src/components/scrollbar/enums.ts +23 -0
- package/src/components/scrollbar/index.ts +3 -0
- package/src/components/scrollbar/style.scss +77 -0
- package/src/components/scrollbar/types.ts +32 -0
- package/src/components/select-list/SelectList.vue +476 -0
- package/src/components/select-list/components/SelectListFilterChip.vue +34 -0
- package/src/components/select-list/components/index.ts +3 -0
- package/src/components/select-list/components/option-group/OptionGroup.vue +20 -0
- package/src/components/select-list/components/option-group/index.ts +1 -0
- package/src/components/select-list/components/select-list-option/SelectListOption.vue +83 -0
- package/src/components/select-list/components/select-list-option/index.ts +1 -0
- package/src/components/select-list/components/status-cards/error-card/ErrorCard.vue +17 -0
- package/src/components/select-list/components/status-cards/error-card/index.ts +1 -0
- package/src/components/select-list/components/status-cards/idle-card/IdleCard.vue +11 -0
- package/src/components/select-list/components/status-cards/idle-card/index.ts +1 -0
- package/src/components/select-list/components/status-cards/index.ts +4 -0
- package/src/components/select-list/components/status-cards/loading-card/LoadingCard.vue +10 -0
- package/src/components/select-list/components/status-cards/loading-card/index.ts +1 -0
- package/src/components/select-list/components/status-cards/no-match-card/NoMatchCard.vue +15 -0
- package/src/components/select-list/components/status-cards/no-match-card/index.ts +1 -0
- package/src/components/select-list/components/status-cards/status-card/StatusCard.vue +25 -0
- package/src/components/select-list/components/status-cards/status-card/index.ts +1 -0
- package/src/components/select-list/index.ts +5 -0
- package/src/components/select-list/types.ts +49 -0
- package/src/components/side-over/SideOver.vue +87 -0
- package/src/components/side-over/index.ts +1 -0
- package/src/components/status-select/StatusIndicator.vue +78 -0
- package/src/components/status-select/StatusSelect.vue +62 -0
- package/src/components/status-select/index.ts +1 -0
- package/src/components/switch/Switch.vue +52 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/tab/Tab.vue +65 -0
- package/src/components/tab/index.ts +1 -0
- package/src/components/tag/Tag.vue +34 -0
- package/src/components/tag/index.ts +1 -0
- package/src/components/text-editor/TextEditor.vue +399 -0
- package/src/components/text-editor/components/Dialog.vue +11 -0
- package/src/components/text-editor/components/FormattingButton.vue +46 -0
- package/src/components/text-editor/components/InsertLinkDialog.vue +81 -0
- package/src/components/text-editor/components/InsertTextDialog.vue +36 -0
- package/src/components/text-editor/components/index.ts +3 -0
- package/src/components/text-editor/index.ts +1 -0
- package/src/components/text-highlight/TextHighlight.vue +113 -0
- package/src/components/text-highlight/index.ts +1 -0
- package/src/components/text-viewer/TextViewer.vue +5 -0
- package/src/components/text-viewer/index.ts +1 -0
- package/src/components/toggle-button/ToggleButton.vue +105 -0
- package/src/components/toggle-button/index.ts +1 -0
- package/src/components/tooltip/Tooltip.vue +54 -0
- package/src/components/tooltip/index.ts +1 -0
- package/src/components/types.ts +232 -0
- package/src/components/vertical-layout/RunningSection.vue +54 -0
- package/src/components/vertical-layout/VerticalLayout.vue +37 -0
- package/src/components/vertical-layout/index.ts +3 -0
- package/src/components/vertical-layout/types.ts +2 -0
- package/src/components/window-frame/WindowFrame.vue +20 -0
- package/src/components/window-frame/index.ts +1 -0
- package/src/composables/index.ts +5 -0
- package/src/composables/useClickOutside.ts +48 -0
- package/src/composables/useEscapeKey.ts +12 -0
- package/src/composables/useMounted.ts +7 -0
- package/src/composables/useNextFrame.ts +10 -0
- package/src/composables/useTrapFocus.ts +61 -0
- package/src/index.ts +5 -0
- package/src/main.css +140 -0
- package/src/utils/array.ts +11 -0
- package/src/utils/capitalizeFirstLetter.ts +4 -0
- package/src/utils/clamp.ts +9 -0
- package/src/utils/debounce.ts +8 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/scrollIntoView.ts +25 -0
- package/src/utils/scrollbarWidth.ts +27 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { parseTimeUnit, TimeInMilliseconds, TimeUnit } from "./time.ts";
|
|
2
|
+
|
|
3
|
+
type StringOrDate = string | Date;
|
|
4
|
+
|
|
5
|
+
export const parseDate = (date: StringOrDate): Date => {
|
|
6
|
+
if (typeof date === "string") date = date.replace(/-/g, "\/");
|
|
7
|
+
|
|
8
|
+
const d = new Date(date);
|
|
9
|
+
const dateIsValid = !Number.isNaN(d.getTime()) && !d.toString().includes("Thu Jan 01 1970");
|
|
10
|
+
|
|
11
|
+
if (dateIsValid) {
|
|
12
|
+
return new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
|
|
13
|
+
}
|
|
14
|
+
throw new Error(`Invalid date [${date}]`);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const dateDelta = (date1: StringOrDate, date2: StringOrDate, timeUnit: TimeUnit): number | null => {
|
|
18
|
+
if (date1 == null || date2 == null) return null;
|
|
19
|
+
|
|
20
|
+
date1 = parseDate(date1);
|
|
21
|
+
date2 = parseDate(date2);
|
|
22
|
+
const unit: keyof typeof TimeUnit | null = parseTimeUnit(timeUnit);
|
|
23
|
+
|
|
24
|
+
if (!date1 || !date2 || !unit) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (unit === TimeUnit.MONTH || unit === TimeUnit.YEAR) {
|
|
28
|
+
throw new Error("Cannot calculate delta in months or years");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const deltaMilliseconds = date1.getTime() - date2.getTime();
|
|
32
|
+
|
|
33
|
+
return deltaMilliseconds / TimeInMilliseconds[unit];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const datesAreEqual = (date1: Date, date2: Date): boolean => {
|
|
37
|
+
date1 = parseDate(date1);
|
|
38
|
+
date2 = parseDate(date2);
|
|
39
|
+
|
|
40
|
+
if (!date1 || !date2) return false;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
date1.getUTCFullYear() === date2.getUTCFullYear()
|
|
44
|
+
&& date1.getUTCMonth() === date2.getUTCMonth()
|
|
45
|
+
&& date1.getUTCDate() === date2.getUTCDate()
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const dateIsAfter = (subjectDate: StringOrDate, targetDate: StringOrDate, includeTarget: boolean = false): boolean => {
|
|
50
|
+
subjectDate = parseDate(subjectDate);
|
|
51
|
+
targetDate = parseDate(targetDate);
|
|
52
|
+
|
|
53
|
+
return subjectDate.getTime() > targetDate.getTime() || (includeTarget && datesAreEqual(subjectDate, targetDate));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const dateIsBefore = (subjectDate: StringOrDate, targetDate: StringOrDate, includeTarget: boolean = false): boolean => {
|
|
57
|
+
subjectDate = parseDate(subjectDate);
|
|
58
|
+
targetDate = parseDate(targetDate);
|
|
59
|
+
|
|
60
|
+
return subjectDate.getTime() < targetDate.getTime() || (includeTarget && datesAreEqual(subjectDate, targetDate));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const dateIsBetween = (subjectDate: StringOrDate, startDate: StringOrDate, endDate: StringOrDate, includeStartAndEndDates: boolean = false): boolean => {
|
|
64
|
+
return dateIsAfter(subjectDate, startDate, includeStartAndEndDates) && dateIsBefore(subjectDate, endDate, includeStartAndEndDates);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const getDecade = (date: Date): number => {
|
|
68
|
+
date = parseDate(date);
|
|
69
|
+
return Math.floor(date.getUTCFullYear() / 10) * 10;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const getWeekNumber = (date: Date): number => {
|
|
73
|
+
const parsedDate = parseDate(date);
|
|
74
|
+
|
|
75
|
+
// Set to nearest Thursday: current date + 4 - current day number
|
|
76
|
+
// Make Sunday's day number 7
|
|
77
|
+
parsedDate.setUTCDate(parsedDate.getUTCDate() + 4 - (parsedDate.getUTCDay() || 7));
|
|
78
|
+
|
|
79
|
+
// Get first day of year
|
|
80
|
+
const yearStart = new Date(Date.UTC(parsedDate.getUTCFullYear(), 0, 1));
|
|
81
|
+
|
|
82
|
+
if (parsedDate && yearStart) {
|
|
83
|
+
;
|
|
84
|
+
// Calculate full weeks to nearest Thursday
|
|
85
|
+
const weekNumber = Math.ceil(((parsedDate.getTime() - yearStart.getTime()) / TimeInMilliseconds.DAY + 1) / 7);
|
|
86
|
+
return weekNumber;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return 0;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const moveDate = (date: StringOrDate, value: number, unit: TimeUnit): Date => {
|
|
93
|
+
const parsedDate = parseDate(date);
|
|
94
|
+
const parsedUnit = parseTimeUnit(unit);
|
|
95
|
+
|
|
96
|
+
if (parsedUnit === TimeUnit.MONTH) throw new Error("Cannot move date by month");
|
|
97
|
+
|
|
98
|
+
let unixTime = parsedDate.getTime();
|
|
99
|
+
unixTime += value * TimeInMilliseconds[parsedUnit as keyof typeof TimeInMilliseconds];
|
|
100
|
+
parsedDate.setTime(unixTime);
|
|
101
|
+
|
|
102
|
+
return parsedDate;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const printDate = (date: Date): void => {
|
|
106
|
+
// eslint-disable-next-line no-console
|
|
107
|
+
console.log(
|
|
108
|
+
date
|
|
109
|
+
.toISOString()
|
|
110
|
+
.substr(0, 16)
|
|
111
|
+
.replace("T", " "),
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const stringifyDate = (date: StringOrDate): string | null => {
|
|
116
|
+
const parsedDate = parseDate(date);
|
|
117
|
+
if (!parsedDate) return null;
|
|
118
|
+
|
|
119
|
+
return parsedDate.toISOString().substring(0, 10);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const stringifyDatetime = (date: StringOrDate): string | null => {
|
|
123
|
+
date = parseDate(date);
|
|
124
|
+
if (!date) return null;
|
|
125
|
+
|
|
126
|
+
return date
|
|
127
|
+
.toISOString()
|
|
128
|
+
.substring(0, 16)
|
|
129
|
+
.replace("T", " ");
|
|
130
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format a date string or object to a readable format (with optional day and time)
|
|
3
|
+
* (Mon) 04 Oct 2021 (23:59)
|
|
4
|
+
*/
|
|
5
|
+
const formatDateTimeReadable = (value: string | Date, includeDay: boolean = true, includeTime = false): string => {
|
|
6
|
+
const d = new Date(value);
|
|
7
|
+
const day = new Intl.DateTimeFormat("en-001", { weekday: "short" }).format(d);
|
|
8
|
+
const date = d.getDate().toString().padStart(2, "0");
|
|
9
|
+
const month = new Intl.DateTimeFormat("en-001", { month: "short" }).format(d);
|
|
10
|
+
const year = d.getFullYear();
|
|
11
|
+
const hours = d.getHours().toString().padStart(2, "0");
|
|
12
|
+
const minutes = d.getMinutes().toString().padStart(2, "0");
|
|
13
|
+
|
|
14
|
+
let result = `${date} ${month} ${year}`;
|
|
15
|
+
|
|
16
|
+
includeDay && (result = `${day} ${result}`);
|
|
17
|
+
includeTime && (result = `${result} ${hours}:${minutes}`);
|
|
18
|
+
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const readableDate = (value: string | Date): string => formatDateTimeReadable(value, false, false);
|
|
23
|
+
export const readableDateWithDay = (value: string | Date): string => formatDateTimeReadable(value, true, false);
|
|
24
|
+
export const readableDateTime = (value: string | Date): string => formatDateTimeReadable(value, false, true);
|
|
25
|
+
export const readableDateTimeWithDay = (value: string | Date): string => formatDateTimeReadable(value, true, true);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Format a date string or object to the default Database date format withoptional time
|
|
29
|
+
* 2021-10-04 (12:59)
|
|
30
|
+
*/
|
|
31
|
+
const formatDateTimeDB = (value: string | Date, includeTime = false): string => {
|
|
32
|
+
const d = new Date(value);
|
|
33
|
+
const year = d.getFullYear();
|
|
34
|
+
const month = (d.getMonth() + 1).toString().padStart(2, "0");
|
|
35
|
+
const date = d.getDate().toString().padStart(2, "0");
|
|
36
|
+
const hours = d.getHours().toString().padStart(2, "0");
|
|
37
|
+
const minutes = d.getMinutes().toString().padStart(2, "0");
|
|
38
|
+
|
|
39
|
+
let result = `${year}-${month}-${date}`;
|
|
40
|
+
includeTime && (result = `${result} ${hours}:${minutes}`);
|
|
41
|
+
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const dbDate = (value: string | Date): string => formatDateTimeDB(value, false);
|
|
46
|
+
export const dbDateTime = (value: string | Date): string => formatDateTimeDB(value, true);
|
|
47
|
+
|
|
48
|
+
export const formatDate = {
|
|
49
|
+
readableDate,
|
|
50
|
+
readableDateWithDay,
|
|
51
|
+
readableDateTime,
|
|
52
|
+
readableDateTimeWithDay,
|
|
53
|
+
dbDate,
|
|
54
|
+
dbDateTime,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const dateFormat = ["nnDate", "nnDateWithDay", "nnDateTime", "nnDateTimeWithDay", "dbDate", "dbDateTime"] as const;
|
|
58
|
+
export type DateFormat = (typeof dateFormat)[number];
|
|
59
|
+
|
|
60
|
+
export const readableDateFormat = ["readableDate", "readableDateWithDay", "readableDateTime", "readableDateTimeWithDay"] as const;
|
|
61
|
+
export type ReadableDateFormat = (typeof readableDateFormat)[number];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export enum TimeUnit {
|
|
2
|
+
MILLISECOND = "MILLISECOND",
|
|
3
|
+
SECOND = "SECOND",
|
|
4
|
+
MINUTE = "MINUTE",
|
|
5
|
+
HOUR = "HOUR",
|
|
6
|
+
DAY = "DAY",
|
|
7
|
+
WEEK = "WEEK",
|
|
8
|
+
MONTH = "MONTH",
|
|
9
|
+
YEAR = "YEAR",
|
|
10
|
+
DECADE = "DECADE",
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const TimeUnitAcronym = {
|
|
14
|
+
MS: TimeUnit.MILLISECOND,
|
|
15
|
+
S: TimeUnit.SECOND,
|
|
16
|
+
M: TimeUnit.MINUTE,
|
|
17
|
+
H: TimeUnit.HOUR,
|
|
18
|
+
D: TimeUnit.DAY,
|
|
19
|
+
W: TimeUnit.WEEK,
|
|
20
|
+
MTH: TimeUnit.MONTH,
|
|
21
|
+
Y: TimeUnit.YEAR,
|
|
22
|
+
DC: TimeUnit.DECADE,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const TimeInMilliseconds = {
|
|
26
|
+
[TimeUnit.MILLISECOND]: 1,
|
|
27
|
+
[TimeUnit.SECOND]: 1000,
|
|
28
|
+
[TimeUnit.MINUTE]: 60000,
|
|
29
|
+
[TimeUnit.HOUR]: 3600000,
|
|
30
|
+
[TimeUnit.DAY]: 86400000,
|
|
31
|
+
[TimeUnit.WEEK]: 604800000,
|
|
32
|
+
[TimeUnit.YEAR]: 3.154e+10,
|
|
33
|
+
[TimeUnit.DECADE]: 3.154e+10 * 10,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const parseTimeUnit = (unit: TimeUnit | string): TimeUnit => {
|
|
37
|
+
if (Object.keys(TimeUnitAcronym).includes(unit)) {
|
|
38
|
+
return (TimeUnitAcronym as any)[unit] as TimeUnit;
|
|
39
|
+
}
|
|
40
|
+
if (Object.keys(TimeUnit).includes(unit)) {
|
|
41
|
+
return unit as TimeUnit;
|
|
42
|
+
}
|
|
43
|
+
throw new Error(`Invalid time unit [${unit}}]`);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const validateFormat = (timeString: string): boolean => {
|
|
47
|
+
// eslint-disable-next-line regexp/no-unused-capturing-group
|
|
48
|
+
return /^([012]|[01]\d|2[0-3]):[0-5]\d$/.test(timeString);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const timeToDecimal = (timeString: string): number | null => {
|
|
52
|
+
if (!timeString) return null;
|
|
53
|
+
if (!timeString.includes(":")) throw new Error(`Invalid time format [${timeString}]. Must be in HH:MM format`);
|
|
54
|
+
if (!validateFormat(timeString)) throw new Error(`Invalid time format [${timeString}]. Must be in HH:MM format`);
|
|
55
|
+
const [hours, minutes] = timeString.split(":");
|
|
56
|
+
return Number.parseInt(hours) + Number.parseInt(minutes) / 60;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const convertToMilliseconds = (value: number, unit: TimeUnit) => {
|
|
60
|
+
if (typeof value !== "number") throw new Error("Value must be a number");
|
|
61
|
+
const parsedUnit = parseTimeUnit(unit);
|
|
62
|
+
return value * (TimeInMilliseconds[parsedUnit as keyof typeof TimeInMilliseconds] || 1);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const convert = (value: number, from: TimeUnit, to: TimeUnit): number => {
|
|
66
|
+
const parsedFrom = parseTimeUnit(from);
|
|
67
|
+
const parsedTo = parseTimeUnit(to);
|
|
68
|
+
const fromMilliseconds = convertToMilliseconds(value, parsedFrom);
|
|
69
|
+
return fromMilliseconds / (TimeInMilliseconds[parsedTo as keyof typeof TimeInMilliseconds] || 1);
|
|
70
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { TCheckboxType } from "../types";
|
|
3
|
+
import CircleIndicator from "./CircleIndicator.vue";
|
|
4
|
+
import DefaultIndicator from "./DefaultIndicator.vue";
|
|
5
|
+
|
|
6
|
+
const { checked, type = "default", indeterminate = false, disabled = false } = defineProps<{
|
|
7
|
+
label?: string;
|
|
8
|
+
type?: TCheckboxType;
|
|
9
|
+
checked: boolean;
|
|
10
|
+
indeterminate?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}>();
|
|
13
|
+
|
|
14
|
+
const emit = defineEmits(["click"]);
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<div
|
|
19
|
+
class="group flex items-center space-x-2"
|
|
20
|
+
:class="{
|
|
21
|
+
'border-action': checked && !disabled,
|
|
22
|
+
'border-default': !checked && !disabled,
|
|
23
|
+
'border-subtle cursor-default': disabled,
|
|
24
|
+
'cursor-pointer': !disabled,
|
|
25
|
+
}"
|
|
26
|
+
@click.stop.prevent="!disabled && emit('click')"
|
|
27
|
+
>
|
|
28
|
+
<DefaultIndicator
|
|
29
|
+
v-if="type === 'default'"
|
|
30
|
+
:value="checked"
|
|
31
|
+
:disabled="disabled"
|
|
32
|
+
:indeterminate="indeterminate"
|
|
33
|
+
/>
|
|
34
|
+
<CircleIndicator
|
|
35
|
+
v-else
|
|
36
|
+
:value="checked"
|
|
37
|
+
:disabled="disabled"
|
|
38
|
+
:indeterminate="indeterminate"
|
|
39
|
+
/>
|
|
40
|
+
<span
|
|
41
|
+
v-if="label"
|
|
42
|
+
class="block text-sm leading-tight select-none"
|
|
43
|
+
:class="{
|
|
44
|
+
'hover:underline': !disabled,
|
|
45
|
+
'text-tertiary': disabled,
|
|
46
|
+
}"
|
|
47
|
+
>
|
|
48
|
+
{{ label }}
|
|
49
|
+
</span>
|
|
50
|
+
</div>
|
|
51
|
+
</template>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { BIcon } from "../";
|
|
4
|
+
|
|
5
|
+
const { value, disabled = false, indeterminate = false } = defineProps<{ value: boolean; indeterminate?: boolean; disabled?: boolean }>();
|
|
6
|
+
|
|
7
|
+
const icon = computed(() => {
|
|
8
|
+
if (indeterminate) return "dash";
|
|
9
|
+
if (value) return "check";
|
|
10
|
+
return null;
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<button
|
|
16
|
+
class="group inline-flex items-center justify-center w-6 h-6 rounded-full border focus:outline-hidden focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-black dark:focus-visible:outline-white"
|
|
17
|
+
:class="{
|
|
18
|
+
'border-default bg-primary hover:bg-secondary hover:border-strong cursor-pointer': !disabled && !value,
|
|
19
|
+
'border-action bg-action text-white hover:bg-action-hover hover:border-action-hover cursor-pointer': !disabled && value,
|
|
20
|
+
'border-default bg-tertiary text-white cursor-default': disabled && value,
|
|
21
|
+
'border-default bg-secondary hover:bg-secondary': disabled && !value,
|
|
22
|
+
}"
|
|
23
|
+
>
|
|
24
|
+
<BIcon v-if="icon" :name="icon" class="text-white" />
|
|
25
|
+
</button>
|
|
26
|
+
</template>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const { value, disabled = false, indeterminate = false } = defineProps<{ value: boolean; disabled?: boolean; indeterminate?: boolean }>();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<button
|
|
7
|
+
class="flex items-center justify-center w-4 h-4 border rounded focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-black dark:focus-visible:outline-white"
|
|
8
|
+
:class="{
|
|
9
|
+
'border-action bg-action hover:bg-action-hover hover:border-action-hover cursor-pointer': (value || indeterminate) && !disabled,
|
|
10
|
+
'bg-primary border-default hover:border-strong hover:bg-secondary cursor-pointer': !value && !indeterminate && !disabled,
|
|
11
|
+
'cursor-default border-default bg-tertiary': disabled,
|
|
12
|
+
}"
|
|
13
|
+
>
|
|
14
|
+
<div v-if="indeterminate" class="w-2 bg-white" style="height: 2px" />
|
|
15
|
+
<svg v-else-if="value" width="10" height="8" viewBox="0 0 10 8" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
16
|
+
<path d="M8.41166 0.5L10 2.0417L4.01353 7.5L0 3.57411L1.60557 2.04932L4.02897 4.39988L8.41166 0.5Z" fill="white" />
|
|
17
|
+
</svg>
|
|
18
|
+
</button>
|
|
19
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BCheckbox } from "./Checkbox.vue";
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
3
|
+
import { BButton } from "../";
|
|
4
|
+
|
|
5
|
+
const props = withDefaults(
|
|
6
|
+
defineProps<{
|
|
7
|
+
alignment?: "left" | "right";
|
|
8
|
+
borderClassOpen?: string;
|
|
9
|
+
borderClassClosed?: string;
|
|
10
|
+
headerBgClass?: string;
|
|
11
|
+
id?: string | number;
|
|
12
|
+
open?: boolean;
|
|
13
|
+
sticky?: boolean;
|
|
14
|
+
}>(),
|
|
15
|
+
{
|
|
16
|
+
alignment: "right",
|
|
17
|
+
borderClassOpen: "border-strong",
|
|
18
|
+
borderClassClosed: "border-default",
|
|
19
|
+
headerBgClass: "bg-primary",
|
|
20
|
+
id: "",
|
|
21
|
+
open: false,
|
|
22
|
+
sticky: false,
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const emit = defineEmits(["toggle"]);
|
|
27
|
+
|
|
28
|
+
const buttonRef = ref<HTMLButtonElement>();
|
|
29
|
+
const headerRef = ref<HTMLHeadElement>();
|
|
30
|
+
const isSticky = ref(false);
|
|
31
|
+
|
|
32
|
+
const borderClass = computed(() => props.open ? props.borderClassOpen : props.borderClassClosed);
|
|
33
|
+
const styles = computed(() => {
|
|
34
|
+
return isSticky.value
|
|
35
|
+
? {
|
|
36
|
+
top: "-1px",
|
|
37
|
+
paddingTop: "1px",
|
|
38
|
+
}
|
|
39
|
+
: {};
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
watch(
|
|
43
|
+
() => props.open,
|
|
44
|
+
(newValue) => {
|
|
45
|
+
if (!newValue) isSticky.value = false;
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
watch(isSticky, (newValue) => {
|
|
50
|
+
if (newValue) buttonRef.value!.blur();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const observer = ref<IntersectionObserver | null>(null);
|
|
54
|
+
onMounted(() => {
|
|
55
|
+
if (props.sticky) {
|
|
56
|
+
observer.value = new IntersectionObserver(
|
|
57
|
+
([e]) => {
|
|
58
|
+
if (props.open) {
|
|
59
|
+
isSticky.value = e.intersectionRatio < 1;
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
threshold: [1],
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
observer.value.observe(headerRef.value!);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
onBeforeUnmount(() => {
|
|
71
|
+
if (observer.value) {
|
|
72
|
+
observer.value.disconnect();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<template>
|
|
78
|
+
<section class="w-full">
|
|
79
|
+
<header
|
|
80
|
+
ref="headerRef"
|
|
81
|
+
class="w-full border-b"
|
|
82
|
+
:style="styles"
|
|
83
|
+
:class="[
|
|
84
|
+
{
|
|
85
|
+
'shadow-sm-xs border-strong sticky z-10': isSticky,
|
|
86
|
+
'relative': !isSticky,
|
|
87
|
+
},
|
|
88
|
+
borderClass,
|
|
89
|
+
headerBgClass,
|
|
90
|
+
]"
|
|
91
|
+
>
|
|
92
|
+
<div class="flex items-center w-full h-10">
|
|
93
|
+
<div v-if="alignment === 'left'" class="relative flex-1 min-w-0 flex items-center text-sm">
|
|
94
|
+
<slot name="header" :sticky="isSticky" />
|
|
95
|
+
</div>
|
|
96
|
+
<div class="flex-none w-8 h-8 flex items-center justify-center">
|
|
97
|
+
<BButton
|
|
98
|
+
v-if="$slots.content"
|
|
99
|
+
small
|
|
100
|
+
variant="textSubtle"
|
|
101
|
+
:icon="open ? 'chevron-down-small' : 'chevron-right-small'"
|
|
102
|
+
@click="emit('toggle', id)"
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
105
|
+
<div v-if="alignment === 'right'" class="relative flex-1 min-w-0 flex items-center text-sm">
|
|
106
|
+
<slot name="header" :sticky="isSticky" />
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</header>
|
|
110
|
+
<main v-if="open" class="relative">
|
|
111
|
+
<slot name="content" />
|
|
112
|
+
</main>
|
|
113
|
+
</section>
|
|
114
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BCollapse } from "./Collapse.vue";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { ConfirmCancelProps } from "./types";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
import { BButton, BFlexbox } from "../";
|
|
5
|
+
|
|
6
|
+
const props = withDefaults(
|
|
7
|
+
defineProps<ConfirmCancelProps>(),
|
|
8
|
+
{
|
|
9
|
+
order: "confirm-first",
|
|
10
|
+
cancelButtonIsText: false,
|
|
11
|
+
cancelDisabled: false,
|
|
12
|
+
cancelLabel: "Cancel",
|
|
13
|
+
cancelVariant: "outline",
|
|
14
|
+
confirmDisabled: false,
|
|
15
|
+
confirmLabel: "Confirm",
|
|
16
|
+
confirmVariant: "fill",
|
|
17
|
+
fillContainer: false,
|
|
18
|
+
loading: false,
|
|
19
|
+
small: false,
|
|
20
|
+
vertical: false,
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const emit = defineEmits(["confirm", "cancel"]);
|
|
25
|
+
|
|
26
|
+
const confirmFirst = computed(() => props.order === "confirm-first");
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<BFlexbox :col="vertical" class="gap-2">
|
|
31
|
+
<BButton
|
|
32
|
+
v-if="confirmFirst"
|
|
33
|
+
:small="small"
|
|
34
|
+
stop-propagation
|
|
35
|
+
:icon="confirmIcon"
|
|
36
|
+
:label="confirmLabel"
|
|
37
|
+
:variant="confirmVariant"
|
|
38
|
+
:disabled="confirmDisabled"
|
|
39
|
+
:loading="loading"
|
|
40
|
+
:class="{ 'flex-1': fillContainer }"
|
|
41
|
+
@click="emit('confirm')"
|
|
42
|
+
/>
|
|
43
|
+
<BButton
|
|
44
|
+
:variant="cancelVariant"
|
|
45
|
+
stop-propagation
|
|
46
|
+
:disabled="cancelDisabled"
|
|
47
|
+
:small="small"
|
|
48
|
+
:icon="cancelIcon"
|
|
49
|
+
:label="cancelLabel"
|
|
50
|
+
:class="{ 'flex-1': fillContainer }"
|
|
51
|
+
@click="emit('cancel')"
|
|
52
|
+
/>
|
|
53
|
+
<BButton
|
|
54
|
+
v-if="!confirmFirst"
|
|
55
|
+
:small="small"
|
|
56
|
+
stop-propagation
|
|
57
|
+
:icon="confirmIcon"
|
|
58
|
+
:label="confirmLabel"
|
|
59
|
+
:variant="confirmVariant"
|
|
60
|
+
:disabled="confirmDisabled"
|
|
61
|
+
:loading="loading"
|
|
62
|
+
:class="{ 'flex-1': fillContainer }"
|
|
63
|
+
@click="emit('confirm')"
|
|
64
|
+
/>
|
|
65
|
+
</BFlexbox>
|
|
66
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BConfirmCancel } from "./ConfirmCancel.vue";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ButtonVariant, TIcon } from "../types";
|
|
2
|
+
|
|
3
|
+
export type ConfirmCancelProps = {
|
|
4
|
+
order?: "confirm-first" | "confirm-last";
|
|
5
|
+
cancelButtonIsText?: boolean;
|
|
6
|
+
cancelDisabled?: boolean;
|
|
7
|
+
cancelIcon?: TIcon;
|
|
8
|
+
cancelLabel?: string;
|
|
9
|
+
cancelVariant?: ButtonVariant;
|
|
10
|
+
confirmDisabled?: boolean;
|
|
11
|
+
confirmIcon?: TIcon;
|
|
12
|
+
confirmLabel?: string;
|
|
13
|
+
confirmVariant?: ButtonVariant;
|
|
14
|
+
fillContainer?: boolean;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
small?: boolean;
|
|
17
|
+
vertical?: boolean;
|
|
18
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, nextTick, onMounted, ref } from "vue";
|
|
3
|
+
import { BButton } from "../../";
|
|
4
|
+
import { useNextFrame } from "../../composables";
|
|
5
|
+
|
|
6
|
+
const scrollPosition = ref(0);
|
|
7
|
+
const scrollStep = 120; // Change this value to adjust the scroll amount
|
|
8
|
+
|
|
9
|
+
const listContainer = ref<HTMLElement | null>(null);
|
|
10
|
+
const buttonList = ref<HTMLElement | null>(null);
|
|
11
|
+
|
|
12
|
+
const containerWidth = ref(listContainer.value ? listContainer.value.clientWidth : 0);
|
|
13
|
+
const contentWidth = ref(buttonList.value ? buttonList.value.scrollWidth : 0);
|
|
14
|
+
const scrollLeft = () => scrollPosition.value = Math.max(0, scrollPosition.value - scrollStep);
|
|
15
|
+
const scrollRight = () => {
|
|
16
|
+
scrollPosition.value = Math.min(contentWidth.value - containerWidth.value, scrollPosition.value + scrollStep);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const showLeftButton = computed(() => scrollPosition.value > 0);
|
|
20
|
+
const showRightButton = computed(() => {
|
|
21
|
+
return scrollPosition.value < contentWidth.value - containerWidth.value;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const { nextFrame } = useNextFrame();
|
|
25
|
+
const update = () => {
|
|
26
|
+
nextTick(() => {
|
|
27
|
+
nextFrame(() => {
|
|
28
|
+
containerWidth.value = listContainer.value ? listContainer.value.clientWidth : 0;
|
|
29
|
+
contentWidth.value = buttonList.value ? buttonList.value.scrollWidth : 0;
|
|
30
|
+
if (containerWidth.value >= contentWidth.value) {
|
|
31
|
+
scrollPosition.value = 0;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
onMounted(update);
|
|
37
|
+
defineExpose({ update });
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<div ref="listContainer" class="relative flex-1 flex items-center py-1 overflow-hidden whitespace-nowrap">
|
|
42
|
+
<aside
|
|
43
|
+
v-if="showLeftButton"
|
|
44
|
+
class="absolute w-16 left-0 z-10 h-full flex items-center"
|
|
45
|
+
style="background: linear-gradient(90deg, rgba(255,255,255,1) 0%, rgba(255,255,255,1) 10%, rgba(255,255,255,0) 100%)"
|
|
46
|
+
>
|
|
47
|
+
<BButton
|
|
48
|
+
small
|
|
49
|
+
icon="chevron-left"
|
|
50
|
+
variant="outline"
|
|
51
|
+
class="shadow-sm"
|
|
52
|
+
@click="scrollLeft"
|
|
53
|
+
/>
|
|
54
|
+
</aside>
|
|
55
|
+
|
|
56
|
+
<main
|
|
57
|
+
ref="buttonList"
|
|
58
|
+
class="flex items-center gap-2 snap-x scroll-px-2 transition-transform duration-300"
|
|
59
|
+
:style="{ transform: `translateX(-${scrollPosition}px)` }"
|
|
60
|
+
>
|
|
61
|
+
<slot />
|
|
62
|
+
</main>
|
|
63
|
+
|
|
64
|
+
<aside
|
|
65
|
+
v-if="showRightButton"
|
|
66
|
+
class="absolute w-16 right-0 z-10 h-full flex items-center justify-end pl-2"
|
|
67
|
+
style="background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 90%, rgba(255,255,255,1) 100%)"
|
|
68
|
+
>
|
|
69
|
+
<BButton
|
|
70
|
+
v-if="showRightButton"
|
|
71
|
+
small
|
|
72
|
+
icon="chevron-right"
|
|
73
|
+
variant="outline"
|
|
74
|
+
class="shadow-sm"
|
|
75
|
+
@click="scrollRight"
|
|
76
|
+
/>
|
|
77
|
+
</aside>
|
|
78
|
+
</div>
|
|
79
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BContentSlider } from "./ContentSlider.vue";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BDataPoint } from "./DataPoint.vue";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { BIcon } from "../icon";
|
|
3
|
+
|
|
4
|
+
defineEmits(["click"]);
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<button
|
|
9
|
+
class="
|
|
10
|
+
flex items-center justify-center w-4 h-4 rounded-full
|
|
11
|
+
hover:bg-black/15 focus-visible:bg-black/15 active:bg-black/25
|
|
12
|
+
dark:hover:bg-white/15 dark:focus-visible:bg-white/15 dark:active:bg-white/25
|
|
13
|
+
text-primary
|
|
14
|
+
cursor-pointer"
|
|
15
|
+
@click.stop.prevent="$emit('click')"
|
|
16
|
+
>
|
|
17
|
+
<BIcon name="close" />
|
|
18
|
+
</button>
|
|
19
|
+
</template>
|