@datum-cloud/datum-ui 0.6.1 → 0.8.0
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 +10 -0
- package/dist/action-row-DnhBhMtt.mjs +22 -0
- package/dist/app-navigation/index.mjs +2 -2
- package/dist/{app-navigation-84ro28PU.mjs → app-navigation-rSOfo1KV.mjs} +169 -106
- package/dist/autocomplete/index.mjs +1 -1
- package/dist/autocomplete-DdbTQe6u.mjs +141 -0
- package/dist/autosearch/index.mjs +100 -92
- package/dist/avatar-stack/index.mjs +1 -1
- package/dist/{avatar-stack-oVr8tsU7.mjs → avatar-stack-CDhlA1Nm.mjs} +1 -1
- package/dist/calendar/index.mjs +1 -1
- package/dist/{calendar-DEkCw7I1.mjs → calendar-C-Hbf74r.mjs} +4 -4
- package/dist/{calendar-date-picker-CDT-8Ha8.mjs → calendar-date-picker-BaykEs6j.mjs} +324 -240
- package/dist/code-editor/index.mjs +1 -1
- package/dist/components/base/date-picker/index.d.ts +4 -0
- package/dist/components/base/date-picker/index.d.ts.map +1 -0
- package/dist/components/base/date-picker/types.d.ts +7 -0
- package/dist/components/base/date-picker/types.d.ts.map +1 -0
- package/dist/components/base/date-picker/use-date-constraints.d.ts +8 -0
- package/dist/components/base/date-picker/use-date-constraints.d.ts.map +1 -0
- package/dist/components/base/index.d.ts +3 -0
- package/dist/components/base/index.d.ts.map +1 -1
- package/dist/components/base/mobile-sheet/context.d.ts +13 -0
- package/dist/components/base/mobile-sheet/context.d.ts.map +1 -0
- package/dist/components/base/mobile-sheet/index.d.ts +3 -0
- package/dist/components/base/mobile-sheet/index.d.ts.map +1 -0
- package/dist/components/base/mobile-sheet/mobile-sheet.d.ts +14 -0
- package/dist/components/base/mobile-sheet/mobile-sheet.d.ts.map +1 -0
- package/dist/components/base/option-picker/index.d.ts +5 -0
- package/dist/components/base/option-picker/index.d.ts.map +1 -0
- package/dist/components/base/option-picker/option-list.d.ts +3 -0
- package/dist/components/base/option-picker/option-list.d.ts.map +1 -0
- package/dist/components/base/option-picker/types.d.ts +71 -0
- package/dist/components/base/option-picker/types.d.ts.map +1 -0
- package/dist/components/base/option-picker/use-option-picker.d.ts +4 -0
- package/dist/components/base/option-picker/use-option-picker.d.ts.map +1 -0
- package/dist/components/base/responsive-dropdown/index.d.ts +2 -0
- package/dist/components/base/responsive-dropdown/index.d.ts.map +1 -0
- package/dist/components/base/responsive-dropdown/responsive-dropdown.d.ts +25 -0
- package/dist/components/base/responsive-dropdown/responsive-dropdown.d.ts.map +1 -0
- package/dist/components/base/responsive-popover/index.d.ts +2 -0
- package/dist/components/base/responsive-popover/index.d.ts.map +1 -0
- package/dist/components/base/responsive-popover/responsive-popover.d.ts +46 -0
- package/dist/components/base/responsive-popover/responsive-popover.d.ts.map +1 -0
- package/dist/components/base/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/features/app-navigation/app-navigation.d.ts +5 -3
- package/dist/components/features/app-navigation/app-navigation.d.ts.map +1 -1
- package/dist/components/features/autocomplete/autocomplete.d.ts +2 -2
- package/dist/components/features/autocomplete/autocomplete.d.ts.map +1 -1
- package/dist/components/features/autocomplete/autocomplete.types.d.ts +7 -16
- package/dist/components/features/autocomplete/autocomplete.types.d.ts.map +1 -1
- package/dist/components/features/autocomplete/trigger.d.ts +20 -0
- package/dist/components/features/autocomplete/trigger.d.ts.map +1 -0
- package/dist/components/features/autosearch/autosearch.d.ts +1 -1
- package/dist/components/features/autosearch/autosearch.d.ts.map +1 -1
- package/dist/components/features/autosearch/autosearch.types.d.ts +4 -0
- package/dist/components/features/autosearch/autosearch.types.d.ts.map +1 -1
- package/dist/components/features/calendar-date-picker/calendar-date-picker.d.ts +3 -37
- package/dist/components/features/calendar-date-picker/calendar-date-picker.d.ts.map +1 -1
- package/dist/components/features/calendar-date-picker/calendar-header.d.ts +13 -0
- package/dist/components/features/calendar-date-picker/calendar-header.d.ts.map +1 -0
- package/dist/components/features/calendar-date-picker/calendar-presets.d.ts +9 -0
- package/dist/components/features/calendar-date-picker/calendar-presets.d.ts.map +1 -0
- package/dist/components/features/calendar-date-picker/date-trigger.d.ts +24 -0
- package/dist/components/features/calendar-date-picker/date-trigger.d.ts.map +1 -0
- package/dist/components/features/calendar-date-picker/index.d.ts +2 -1
- package/dist/components/features/calendar-date-picker/index.d.ts.map +1 -1
- package/dist/components/features/calendar-date-picker/types.d.ts +42 -0
- package/dist/components/features/calendar-date-picker/types.d.ts.map +1 -0
- package/dist/components/features/calendar-date-picker/use-calendar-date-picker.d.ts +48 -0
- package/dist/components/features/calendar-date-picker/use-calendar-date-picker.d.ts.map +1 -0
- package/dist/components/features/data-table/components/row-actions.d.ts +1 -1
- package/dist/components/features/data-table/components/row-actions.d.ts.map +1 -1
- package/dist/components/features/data-table/filters/checkbox-filter.d.ts +1 -1
- package/dist/components/features/data-table/filters/checkbox-filter.d.ts.map +1 -1
- package/dist/components/features/data-table/filters/select-filter.d.ts +1 -1
- package/dist/components/features/data-table/filters/select-filter.d.ts.map +1 -1
- package/dist/components/features/data-table/types.d.ts +11 -12
- package/dist/components/features/data-table/types.d.ts.map +1 -1
- package/dist/components/features/date-time-picker/date-time-picker.d.ts +1 -1
- package/dist/components/features/date-time-picker/date-time-picker.d.ts.map +1 -1
- package/dist/components/features/date-time-picker/types.d.ts +23 -0
- package/dist/components/features/date-time-picker/types.d.ts.map +1 -1
- package/dist/components/features/form/components/form-combobox.d.ts +7 -44
- package/dist/components/features/form/components/form-combobox.d.ts.map +1 -1
- package/dist/components/features/form/components/form-dialog.d.ts +2 -1
- package/dist/components/features/form/components/form-dialog.d.ts.map +1 -1
- package/dist/components/features/form/components/form-field.d.ts +1 -1
- package/dist/components/features/form/components/form-field.d.ts.map +1 -1
- package/dist/components/features/form/types/index.d.ts +4 -0
- package/dist/components/features/form/types/index.d.ts.map +1 -1
- package/dist/components/features/index.d.ts +2 -0
- package/dist/components/features/index.d.ts.map +1 -1
- package/dist/components/features/more-actions/action-row.d.ts +9 -0
- package/dist/components/features/more-actions/action-row.d.ts.map +1 -0
- package/dist/components/features/more-actions/index.d.ts +3 -1
- package/dist/components/features/more-actions/index.d.ts.map +1 -1
- package/dist/components/features/more-actions/more-actions.d.ts +8 -14
- package/dist/components/features/more-actions/more-actions.d.ts.map +1 -1
- package/dist/components/features/more-actions/types.d.ts +24 -0
- package/dist/components/features/more-actions/types.d.ts.map +1 -0
- package/dist/components/features/multi-select/index.d.ts +3 -0
- package/dist/components/features/multi-select/index.d.ts.map +1 -0
- package/dist/components/features/multi-select/multi-select.d.ts +147 -0
- package/dist/components/features/multi-select/multi-select.d.ts.map +1 -0
- package/dist/components/features/page-title/page-title.d.ts.map +1 -1
- package/dist/components/features/rich-text-editor/index.d.ts +4 -0
- package/dist/components/features/rich-text-editor/index.d.ts.map +1 -0
- package/dist/components/features/rich-text-editor/rich-text-content.d.ts +3 -0
- package/dist/components/features/rich-text-editor/rich-text-content.d.ts.map +1 -0
- package/dist/components/features/rich-text-editor/rich-text-editor.d.ts +28 -0
- package/dist/components/features/rich-text-editor/rich-text-editor.d.ts.map +1 -0
- package/dist/components/features/rich-text-editor/toolbar/bold-toolbar.d.ts +2 -0
- package/dist/components/features/rich-text-editor/toolbar/bold-toolbar.d.ts.map +1 -0
- package/dist/components/features/rich-text-editor/toolbar/italic-toolbar.d.ts +2 -0
- package/dist/components/features/rich-text-editor/toolbar/italic-toolbar.d.ts.map +1 -0
- package/dist/components/features/rich-text-editor/toolbar/link-toolbar.d.ts +2 -0
- package/dist/components/features/rich-text-editor/toolbar/link-toolbar.d.ts.map +1 -0
- package/dist/components/features/rich-text-editor/toolbar/strike-toolbar.d.ts +2 -0
- package/dist/components/features/rich-text-editor/toolbar/strike-toolbar.d.ts.map +1 -0
- package/dist/components/features/rich-text-editor/toolbar/toolbar-button.d.ts +17 -0
- package/dist/components/features/rich-text-editor/toolbar/toolbar-button.d.ts.map +1 -0
- package/dist/components/features/rich-text-editor/toolbar/toolbar.d.ts +6 -0
- package/dist/components/features/rich-text-editor/toolbar/toolbar.d.ts.map +1 -0
- package/dist/components/features/rich-text-editor/toolbar/underline-toolbar.d.ts +2 -0
- package/dist/components/features/rich-text-editor/toolbar/underline-toolbar.d.ts.map +1 -0
- package/dist/components/features/rich-text-editor/types.d.ts +20 -0
- package/dist/components/features/rich-text-editor/types.d.ts.map +1 -0
- package/dist/components/features/tag-input/tag-input.d.ts +12 -1
- package/dist/components/features/tag-input/tag-input.d.ts.map +1 -1
- package/dist/components/features/task-queue/core/task-queue-dropdown.d.ts.map +1 -1
- package/dist/components/features/time-picker/time-picker.d.ts +1 -17
- package/dist/components/features/time-picker/time-picker.d.ts.map +1 -1
- package/dist/components/features/time-picker/types.d.ts +20 -18
- package/dist/components/features/time-picker/types.d.ts.map +1 -1
- package/dist/components/features/time-picker/use-time-slots.d.ts +10 -0
- package/dist/components/features/time-picker/use-time-slots.d.ts.map +1 -0
- package/dist/components/features/time-range-picker/components/absolute-range-panel.d.ts.map +1 -1
- package/dist/components/features/time-range-picker/time-range-picker.d.ts.map +1 -1
- package/dist/data-table/index.mjs +60 -175
- package/dist/date-picker/index.mjs +2 -2
- package/dist/date-time-picker/index.mjs +1 -1
- package/dist/{date-time-picker-BomrW07W.mjs → date-time-picker-DKOxrhmc.mjs} +64 -49
- package/dist/dropdown/index.mjs +109 -1
- package/dist/dropzone/index.mjs +1 -1
- package/dist/empty-content/index.mjs +1 -1
- package/dist/form/adapters/conform/index.mjs +2 -2
- package/dist/form/adapters/rhf/index.mjs +2 -2
- package/dist/form/index.mjs +2 -2
- package/dist/form/stepper/index.mjs +3 -3
- package/dist/{form-B3rQ4CH9.mjs → form-CCNN9VtJ.mjs} +27 -30
- package/dist/grid/index.mjs +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.mjs +4 -3
- package/dist/hooks/use-breakpoint.d.ts +9 -0
- package/dist/hooks/use-breakpoint.d.ts.map +1 -0
- package/dist/index.mjs +49 -42
- package/dist/input-number/index.mjs +1 -1
- package/dist/loader-overlay/index.mjs +1 -1
- package/dist/map/index.mjs +1 -1
- package/dist/{map-CWIQ-eql.mjs → map-qo7bY_g_.mjs} +83 -4
- package/dist/mobile-sheet/index.mjs +2 -0
- package/dist/mobile-sheet-BxMvkzAj.mjs +61 -0
- package/dist/more-actions/index.mjs +3 -2
- package/dist/more-actions-Ca5qqd0H.mjs +49 -0
- package/dist/multi-select/index.mjs +2 -0
- package/dist/multi-select-DM_dxnSV.mjs +235 -0
- package/dist/page-title/index.mjs +1 -1
- package/dist/{page-title-ChsnpBiH.mjs → page-title-ChLiv6gB.mjs} +3 -2
- package/dist/popover/index.mjs +1 -1
- package/dist/radio-group/index.mjs +1 -1
- package/dist/responsive-dropdown/index.mjs +2 -0
- package/dist/responsive-dropdown-IFroDgKn.mjs +53 -0
- package/dist/responsive-popover/index.mjs +2 -0
- package/dist/responsive-popover-D-t9bxSN.mjs +61 -0
- package/dist/rich-text-editor/index.mjs +2 -0
- package/dist/rich-text-editor-CQH_U4T5.mjs +293 -0
- package/dist/select/index.mjs +1 -1
- package/dist/sheet/index.mjs +2 -2
- package/dist/{sheet-BzXksqYY.mjs → sheet-LhUgozvg.mjs} +1 -1
- package/dist/sidebar/index.mjs +1 -1
- package/dist/{sidebar-BnhnjvfO.mjs → sidebar-B8LQJiNI.mjs} +3 -3
- package/dist/skeleton/index.mjs +1 -1
- package/dist/{skeleton-D1MUhAVo.mjs → skeleton-D4HOEiOZ.mjs} +1 -1
- package/dist/spinner/index.mjs +1 -1
- package/dist/stepper/index.mjs +1 -1
- package/dist/styles/canela.css +23 -0
- package/dist/styles/fonts/CanelaText-Regular.ttf +0 -0
- package/dist/styles/tokens/figma-tokens.css +4 -0
- package/dist/switch/index.mjs +1 -1
- package/dist/table/index.mjs +1 -1
- package/dist/tag-input/index.mjs +1 -1
- package/dist/{tag-input-T9cUX9-G.mjs → tag-input-Bf4GMptp.mjs} +29 -14
- package/dist/task-queue/index.mjs +1 -1
- package/dist/{task-queue-dropdown-Wcbj-f0V.mjs → task-queue-dropdown-D-LncEWm.mjs} +39 -39
- package/dist/textarea/index.mjs +1 -1
- package/dist/theme/index.mjs +1 -1
- package/dist/time-picker/index.mjs +1 -1
- package/dist/time-picker-BZF5jbF6.mjs +99 -0
- package/dist/{to-api-format-Bh3c01gr.mjs → to-api-format-CgKcC9SK.mjs} +144 -119
- package/dist/toast/index.mjs +2 -2
- package/dist/{toast-DpxlFNNx.mjs → toast-DDdLgY53.mjs} +1 -1
- package/dist/tooltip/index.mjs +1 -1
- package/dist/{tooltip-Cruvl5F6.mjs → tooltip-a7NTDCWw.mjs} +74 -17
- package/dist/transfer/index.mjs +1 -1
- package/dist/{types-BZNk3q65.mjs → types-CKIe2WlV.mjs} +2 -2
- package/dist/typography/index.mjs +1 -1
- package/dist/use-breakpoint-DGcVmB3c.mjs +36 -0
- package/dist/{use-copy-to-clipboard-uNeeVHC4.mjs → use-copy-to-clipboard-D7KyLIAt.mjs} +1 -1
- package/dist/use-date-constraints-R3H4lIoT.mjs +41 -0
- package/dist/use-option-picker-BXQOfyrK.mjs +215 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.mjs +2 -1
- package/dist/utils/timezone.d.ts +19 -0
- package/dist/utils/timezone.d.ts.map +1 -0
- package/dist/utils-BwB1mIdZ.mjs +35 -0
- package/dist/visually-hidden/index.mjs +1 -1
- package/package.json +61 -6
- package/dist/autocomplete-CkYJueBL.mjs +0 -293
- package/dist/combobox/index.mjs +0 -2
- package/dist/combobox-B-C9lJeD.mjs +0 -97
- package/dist/components/features/combobox/combobox.d.ts +0 -27
- package/dist/components/features/combobox/combobox.d.ts.map +0 -1
- package/dist/components/features/combobox/index.d.ts +0 -3
- package/dist/components/features/combobox/index.d.ts.map +0 -1
- package/dist/components/features/combobox/types.d.ts +0 -84
- package/dist/components/features/combobox/types.d.ts.map +0 -1
- package/dist/dropdown-DZiAt-jS.mjs +0 -110
- package/dist/dropdown-menu-lALvDnab.mjs +0 -85
- package/dist/more-actions-ILnEZq_E.mjs +0 -52
- package/dist/time-picker-BoF7pZZ2.mjs +0 -43
- /package/dist/{adapter-context-rWveHhDd.mjs → adapter-context-NyGTDZYq.mjs} +0 -0
- /package/dist/{col-1T0Q3SlH.mjs → col-DISdGlqY.mjs} +0 -0
- /package/dist/{dropzone-ogtpQ4fy.mjs → dropzone-Bt0plEuw.mjs} +0 -0
- /package/dist/{empty-content-C63GPJ5d.mjs → empty-content-CBh5bbtJ.mjs} +0 -0
- /package/dist/{form-context-Ccxm-wqL.mjs → form-context-CeKyvO-A.mjs} +0 -0
- /package/dist/{hooks-D8r2M2U6.mjs → hooks-DQXVwbrs.mjs} +0 -0
- /package/dist/{input-number-a7uydAsw.mjs → input-number-Diu-C6d5.mjs} +0 -0
- /package/dist/{loader-overlay-BTFdkp7W.mjs → loader-overlay-C2WDla6V.mjs} +0 -0
- /package/dist/{map-leaflet-imports-CRSKA79m.mjs → map-leaflet-imports-yWwH4CHB.mjs} +0 -0
- /package/dist/{popover-FJAcbYoH.mjs → popover-JOuXJOZ2.mjs} +0 -0
- /package/dist/{radio-group-CiITR0LO.mjs → radio-group-70UjJBb5.mjs} +0 -0
- /package/dist/{select-CiLR_DiQ.mjs → select-zxwykvQn.mjs} +0 -0
- /package/dist/{sheet-Di3b-oPu.mjs → sheet-DVEToCVY.mjs} +0 -0
- /package/dist/{skeleton-BKl4mfJt.mjs → skeleton-D2xuJdE1.mjs} +0 -0
- /package/dist/{spinner-OyOf9-Yu.mjs → spinner-CgPI3DDi.mjs} +0 -0
- /package/dist/{stepper-DvIOp0hh.mjs → stepper-Beb-zbdL.mjs} +0 -0
- /package/dist/{switch-DQJQhPIQ.mjs → switch-DcSF42Kc.mjs} +0 -0
- /package/dist/{table-Cdsh-39-.mjs → table-DWGT4cqh.mjs} +0 -0
- /package/dist/{textarea-BwD-MmTV.mjs → textarea-BoChBcFz.mjs} +0 -0
- /package/dist/{themes-DG1md8FI.mjs → themes-CAiN4b6G.mjs} +0 -0
- /package/dist/{toast-BWnN5fax.mjs → toast-D5XD7goD.mjs} +0 -0
- /package/dist/{transfer-46C-rFFW.mjs → transfer-CoGPwOc6.mjs} +0 -0
- /package/dist/{typography-ClB8k55E.mjs → typography-TRKP_CLT.mjs} +0 -0
- /package/dist/{use-display-touched-I39aXEBD.mjs → use-display-touched-C-afz17j.mjs} +0 -0
- /package/dist/{visuallyhidden-BLUsJpYH.mjs → visuallyhidden-BHOPczmW.mjs} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
|
+
import { endOfDay, startOfDay } from "date-fns";
|
|
3
|
+
//#region src/components/base/date-picker/use-date-constraints.ts
|
|
4
|
+
function useDateConstraints({ minDate, maxDate, disablePast, disableFuture }) {
|
|
5
|
+
const today = useMemo(() => /* @__PURE__ */ new Date(), []);
|
|
6
|
+
const effectiveMinDate = useMemo(() => {
|
|
7
|
+
let min = minDate;
|
|
8
|
+
if (disablePast) {
|
|
9
|
+
const todayStart = startOfDay(today);
|
|
10
|
+
min = min ? min > todayStart ? min : todayStart : todayStart;
|
|
11
|
+
}
|
|
12
|
+
return min;
|
|
13
|
+
}, [
|
|
14
|
+
minDate,
|
|
15
|
+
disablePast,
|
|
16
|
+
today
|
|
17
|
+
]);
|
|
18
|
+
const effectiveMaxDate = useMemo(() => {
|
|
19
|
+
let max = maxDate;
|
|
20
|
+
if (disableFuture) {
|
|
21
|
+
const todayEnd = endOfDay(today);
|
|
22
|
+
max = max ? max < todayEnd ? max : todayEnd : todayEnd;
|
|
23
|
+
}
|
|
24
|
+
return max;
|
|
25
|
+
}, [
|
|
26
|
+
maxDate,
|
|
27
|
+
disableFuture,
|
|
28
|
+
today
|
|
29
|
+
]);
|
|
30
|
+
return {
|
|
31
|
+
effectiveMinDate,
|
|
32
|
+
effectiveMaxDate,
|
|
33
|
+
isDateDisabled: useCallback((date) => {
|
|
34
|
+
if (effectiveMinDate && date < effectiveMinDate) return true;
|
|
35
|
+
if (effectiveMaxDate && date > effectiveMaxDate) return true;
|
|
36
|
+
return false;
|
|
37
|
+
}, [effectiveMinDate, effectiveMaxDate])
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { useDateConstraints as t };
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { a as CommandInput, i as CommandGroup, o as CommandItem, r as CommandEmpty, s as CommandList, t as Command } from "./command-DqHWukGK.mjs";
|
|
2
|
+
import { t as LoaderOverlay } from "./loader-overlay-C2WDla6V.mjs";
|
|
3
|
+
import { CheckIcon } from "lucide-react";
|
|
4
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
7
|
+
//#region src/components/base/option-picker/types.ts
|
|
8
|
+
/**
|
|
9
|
+
* Detect whether an options prop is grouped.
|
|
10
|
+
*
|
|
11
|
+
* Treats empty arrays as flat (zero-option lists do not need group headings).
|
|
12
|
+
*/
|
|
13
|
+
function isGroupedOptions(options) {
|
|
14
|
+
if (options.length === 0) return false;
|
|
15
|
+
return "options" in options[0];
|
|
16
|
+
}
|
|
17
|
+
/** Internal helper — flatten grouped or flat options into a single array. */
|
|
18
|
+
function flattenOptions(options) {
|
|
19
|
+
return isGroupedOptions(options) ? options.flatMap((g) => g.options) : options;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/components/base/option-picker/option-list.tsx
|
|
23
|
+
function defaultRenderOption(option, isSelected) {
|
|
24
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
|
|
25
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
26
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
27
|
+
className: "truncate",
|
|
28
|
+
children: option.label
|
|
29
|
+
}), option.description && /* @__PURE__ */ jsx("span", {
|
|
30
|
+
className: "text-muted-foreground truncate text-xs",
|
|
31
|
+
children: option.description
|
|
32
|
+
})]
|
|
33
|
+
}), isSelected && /* @__PURE__ */ jsx(CheckIcon, { className: "text-primary ml-auto size-4 shrink-0" })] });
|
|
34
|
+
}
|
|
35
|
+
function OptionList({ picker, searchPlaceholder, disableSearch, emptyContent, renderOption, header, footer, loading, virtualize, itemSize = 36, listClassName }) {
|
|
36
|
+
const { filteredOptions, search, setSearch, isSelected, toggle, creatableValue } = picker;
|
|
37
|
+
const grouped = isGroupedOptions(filteredOptions);
|
|
38
|
+
const row = renderOption ?? defaultRenderOption;
|
|
39
|
+
const canVirtualize = virtualize && !grouped;
|
|
40
|
+
return /* @__PURE__ */ jsxs(Command, {
|
|
41
|
+
shouldFilter: false,
|
|
42
|
+
children: [
|
|
43
|
+
header,
|
|
44
|
+
!disableSearch && /* @__PURE__ */ jsx(CommandInput, {
|
|
45
|
+
className: "!text-xs placeholder:text-xs",
|
|
46
|
+
placeholder: searchPlaceholder,
|
|
47
|
+
value: search,
|
|
48
|
+
onValueChange: setSearch
|
|
49
|
+
}),
|
|
50
|
+
/* @__PURE__ */ jsxs(CommandList, {
|
|
51
|
+
ref: picker.listRef,
|
|
52
|
+
className: listClassName,
|
|
53
|
+
children: [
|
|
54
|
+
loading && /* @__PURE__ */ jsx(LoaderOverlay, {}),
|
|
55
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: emptyContent ?? "No results found." }),
|
|
56
|
+
grouped ? filteredOptions.map((group) => /* @__PURE__ */ jsx(CommandGroup, {
|
|
57
|
+
heading: group.label,
|
|
58
|
+
children: group.options.map((option) => /* @__PURE__ */ jsx(CommandItem, {
|
|
59
|
+
value: option.value,
|
|
60
|
+
disabled: option.disabled,
|
|
61
|
+
onSelect: () => toggle(option.value),
|
|
62
|
+
children: row(option, isSelected(option.value))
|
|
63
|
+
}, option.value))
|
|
64
|
+
}, group.label)) : canVirtualize ? /* @__PURE__ */ jsx(VirtualCommandGroup, {
|
|
65
|
+
options: filteredOptions,
|
|
66
|
+
isSelected,
|
|
67
|
+
toggle,
|
|
68
|
+
renderOption: row,
|
|
69
|
+
listRef: picker.listRef,
|
|
70
|
+
itemSize
|
|
71
|
+
}) : /* @__PURE__ */ jsx(CommandGroup, { children: filteredOptions.map((option) => /* @__PURE__ */ jsx(CommandItem, {
|
|
72
|
+
value: option.value,
|
|
73
|
+
disabled: option.disabled,
|
|
74
|
+
onSelect: () => toggle(option.value),
|
|
75
|
+
children: row(option, isSelected(option.value))
|
|
76
|
+
}, option.value)) }),
|
|
77
|
+
creatableValue && /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsx(CommandItem, {
|
|
78
|
+
value: `__create_${creatableValue}`,
|
|
79
|
+
onSelect: () => toggle(creatableValue),
|
|
80
|
+
children: /* @__PURE__ */ jsxs("span", { children: [
|
|
81
|
+
"Use \"",
|
|
82
|
+
creatableValue,
|
|
83
|
+
"\""
|
|
84
|
+
] })
|
|
85
|
+
}) })
|
|
86
|
+
]
|
|
87
|
+
}),
|
|
88
|
+
footer
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function VirtualCommandGroup({ options, isSelected, toggle, renderOption, listRef, itemSize }) {
|
|
93
|
+
const virtualizer = useVirtualizer({
|
|
94
|
+
count: options.length,
|
|
95
|
+
getScrollElement: () => listRef.current,
|
|
96
|
+
estimateSize: () => itemSize,
|
|
97
|
+
overscan: 8
|
|
98
|
+
});
|
|
99
|
+
return /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsx("div", {
|
|
100
|
+
style: {
|
|
101
|
+
height: virtualizer.getTotalSize(),
|
|
102
|
+
position: "relative"
|
|
103
|
+
},
|
|
104
|
+
children: virtualizer.getVirtualItems().map((virtualRow) => {
|
|
105
|
+
const option = options[virtualRow.index];
|
|
106
|
+
return /* @__PURE__ */ jsx("div", {
|
|
107
|
+
style: {
|
|
108
|
+
position: "absolute",
|
|
109
|
+
top: 0,
|
|
110
|
+
left: 0,
|
|
111
|
+
width: "100%",
|
|
112
|
+
transform: `translateY(${virtualRow.start}px)`
|
|
113
|
+
},
|
|
114
|
+
children: /* @__PURE__ */ jsx(CommandItem, {
|
|
115
|
+
value: option.value,
|
|
116
|
+
disabled: option.disabled,
|
|
117
|
+
onSelect: () => toggle(option.value),
|
|
118
|
+
children: renderOption(option, isSelected(option.value))
|
|
119
|
+
})
|
|
120
|
+
}, option.value);
|
|
121
|
+
})
|
|
122
|
+
}) });
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/components/base/option-picker/use-option-picker.ts
|
|
126
|
+
function useOptionPicker(args) {
|
|
127
|
+
const { options, multiple, value, defaultValue, onValueChange, onSearchChange, creatable = false, closeOnSelect = true, onOpenChange } = args;
|
|
128
|
+
const [internalValue, setInternalValue] = useState(() => {
|
|
129
|
+
if (value !== void 0) return Array.isArray(value) ? value : [value];
|
|
130
|
+
if (defaultValue !== void 0) return Array.isArray(defaultValue) ? defaultValue : [defaultValue];
|
|
131
|
+
return [];
|
|
132
|
+
});
|
|
133
|
+
const selection = useMemo(() => {
|
|
134
|
+
if (value === void 0) return internalValue;
|
|
135
|
+
return Array.isArray(value) ? value : [value];
|
|
136
|
+
}, [value, internalValue]);
|
|
137
|
+
const selectionSet = useMemo(() => new Set(selection), [selection]);
|
|
138
|
+
const [search, setSearchState] = useState("");
|
|
139
|
+
const setSearch = useCallback((next) => {
|
|
140
|
+
setSearchState(next);
|
|
141
|
+
onSearchChange?.(next);
|
|
142
|
+
}, [onSearchChange]);
|
|
143
|
+
const isSelected = useCallback((v) => selectionSet.has(v), [selectionSet]);
|
|
144
|
+
const toggle = useCallback((v) => {
|
|
145
|
+
if (multiple) {
|
|
146
|
+
const next = selectionSet.has(v) ? selection.filter((x) => x !== v) : [...selection, v];
|
|
147
|
+
if (value === void 0) setInternalValue(next);
|
|
148
|
+
onValueChange?.(next);
|
|
149
|
+
} else {
|
|
150
|
+
if (value === void 0) setInternalValue([v]);
|
|
151
|
+
onValueChange?.(v);
|
|
152
|
+
if (closeOnSelect) onOpenChange(false);
|
|
153
|
+
}
|
|
154
|
+
}, [
|
|
155
|
+
multiple,
|
|
156
|
+
selection,
|
|
157
|
+
selectionSet,
|
|
158
|
+
value,
|
|
159
|
+
onValueChange,
|
|
160
|
+
closeOnSelect,
|
|
161
|
+
onOpenChange
|
|
162
|
+
]);
|
|
163
|
+
const clear = useCallback(() => {
|
|
164
|
+
if (!multiple) return;
|
|
165
|
+
if (value === void 0) setInternalValue([]);
|
|
166
|
+
onValueChange?.([]);
|
|
167
|
+
}, [
|
|
168
|
+
multiple,
|
|
169
|
+
value,
|
|
170
|
+
onValueChange
|
|
171
|
+
]);
|
|
172
|
+
const filteredOptions = useMemo(() => {
|
|
173
|
+
if (onSearchChange || !search) return options;
|
|
174
|
+
const q = search.toLowerCase().trim();
|
|
175
|
+
if (!q) return options;
|
|
176
|
+
if (isGroupedOptions(options)) return options.map((g) => ({
|
|
177
|
+
label: g.label,
|
|
178
|
+
options: g.options.filter((o) => o.label.toLowerCase().includes(q))
|
|
179
|
+
})).filter((g) => g.options.length > 0);
|
|
180
|
+
return options.filter((o) => o.label.toLowerCase().includes(q));
|
|
181
|
+
}, [
|
|
182
|
+
options,
|
|
183
|
+
search,
|
|
184
|
+
onSearchChange
|
|
185
|
+
]);
|
|
186
|
+
const hasMatches = useMemo(() => {
|
|
187
|
+
if (isGroupedOptions(filteredOptions)) return filteredOptions.some((g) => g.options.length > 0);
|
|
188
|
+
return filteredOptions.length > 0;
|
|
189
|
+
}, [filteredOptions]);
|
|
190
|
+
const creatableValue = useMemo(() => {
|
|
191
|
+
if (!creatable || multiple) return null;
|
|
192
|
+
const trimmed = search.trim();
|
|
193
|
+
if (!trimmed) return null;
|
|
194
|
+
return flattenOptions(options).some((o) => o.label.toLowerCase() === trimmed.toLowerCase()) ? null : trimmed;
|
|
195
|
+
}, [
|
|
196
|
+
creatable,
|
|
197
|
+
multiple,
|
|
198
|
+
search,
|
|
199
|
+
options
|
|
200
|
+
]);
|
|
201
|
+
return {
|
|
202
|
+
search,
|
|
203
|
+
setSearch,
|
|
204
|
+
filteredOptions,
|
|
205
|
+
hasMatches,
|
|
206
|
+
isSelected,
|
|
207
|
+
toggle,
|
|
208
|
+
clear,
|
|
209
|
+
hasSelection: selection.length > 0,
|
|
210
|
+
creatableValue,
|
|
211
|
+
listRef: useRef(null)
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
//#endregion
|
|
215
|
+
export { OptionList as n, useOptionPicker as t };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/utils/index.mjs
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a date to start of day in the specified timezone, then to a UTC
|
|
3
|
+
* timestamp in seconds.
|
|
4
|
+
*
|
|
5
|
+
* @param date - The date to convert.
|
|
6
|
+
* @param timezone - The IANA timezone to interpret the date in (e.g. `'America/New_York'`).
|
|
7
|
+
* @returns Unix timestamp in seconds (UTC).
|
|
8
|
+
*/
|
|
9
|
+
export declare function toUTCTimestampStartOfDay(date: Date, timezone: string): number;
|
|
10
|
+
/**
|
|
11
|
+
* Convert a date to end of day in the specified timezone, then to a UTC
|
|
12
|
+
* timestamp in seconds.
|
|
13
|
+
*
|
|
14
|
+
* @param date - The date to convert.
|
|
15
|
+
* @param timezone - The IANA timezone to interpret the date in.
|
|
16
|
+
* @returns Unix timestamp in seconds (UTC).
|
|
17
|
+
*/
|
|
18
|
+
export declare function toUTCTimestampEndOfDay(date: Date, timezone: string): number;
|
|
19
|
+
//# sourceMappingURL=timezone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../src/utils/timezone.ts"],"names":[],"mappings":"AASA;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK7E;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK3E"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { endOfDay, startOfDay } from "date-fns";
|
|
2
|
+
import { fromZonedTime, toZonedTime } from "date-fns-tz";
|
|
3
|
+
//#region src/utils/timezone.ts
|
|
4
|
+
/**
|
|
5
|
+
* Timezone-aware conversion utilities for date filters.
|
|
6
|
+
*
|
|
7
|
+
* Handles conversion between a user's timezone and UTC for accurate
|
|
8
|
+
* time-range queries (e.g. log/metric filtering, date-based search).
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Convert a date to start of day in the specified timezone, then to a UTC
|
|
12
|
+
* timestamp in seconds.
|
|
13
|
+
*
|
|
14
|
+
* @param date - The date to convert.
|
|
15
|
+
* @param timezone - The IANA timezone to interpret the date in (e.g. `'America/New_York'`).
|
|
16
|
+
* @returns Unix timestamp in seconds (UTC).
|
|
17
|
+
*/
|
|
18
|
+
function toUTCTimestampStartOfDay(date, timezone) {
|
|
19
|
+
const utcDate = fromZonedTime(startOfDay(toZonedTime(date, timezone)), timezone);
|
|
20
|
+
return Math.floor(utcDate.getTime() / 1e3);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Convert a date to end of day in the specified timezone, then to a UTC
|
|
24
|
+
* timestamp in seconds.
|
|
25
|
+
*
|
|
26
|
+
* @param date - The date to convert.
|
|
27
|
+
* @param timezone - The IANA timezone to interpret the date in.
|
|
28
|
+
* @returns Unix timestamp in seconds (UTC).
|
|
29
|
+
*/
|
|
30
|
+
function toUTCTimestampEndOfDay(date, timezone) {
|
|
31
|
+
const utcDate = fromZonedTime(endOfDay(toZonedTime(date, timezone)), timezone);
|
|
32
|
+
return Math.floor(utcDate.getTime() / 1e3);
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { toUTCTimestampStartOfDay as n, toUTCTimestampEndOfDay as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as VisuallyHidden } from "../visuallyhidden-
|
|
1
|
+
import { t as VisuallyHidden } from "../visuallyhidden-BHOPczmW.mjs";
|
|
2
2
|
export { VisuallyHidden };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datum-cloud/datum-ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"url": "https://github.com/datum-cloud/datum-ui"
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"style": "./dist/styles/root.css",
|
|
20
20
|
"default": "./dist/styles/root.css"
|
|
21
21
|
},
|
|
22
|
+
"./styles/canela": {
|
|
23
|
+
"style": "./dist/styles/canela.css",
|
|
24
|
+
"default": "./dist/styles/canela.css"
|
|
25
|
+
},
|
|
22
26
|
"./theme": {
|
|
23
27
|
"source": "./src/components/themes/index.ts",
|
|
24
28
|
"types": "./dist/components/themes/index.d.ts",
|
|
@@ -139,6 +143,21 @@
|
|
|
139
143
|
"types": "./dist/components/base/radio-group/index.d.ts",
|
|
140
144
|
"default": "./dist/radio-group/index.mjs"
|
|
141
145
|
},
|
|
146
|
+
"./responsive-dropdown": {
|
|
147
|
+
"source": "./src/components/base/responsive-dropdown/index.ts",
|
|
148
|
+
"types": "./dist/components/base/responsive-dropdown/index.d.ts",
|
|
149
|
+
"default": "./dist/responsive-dropdown/index.mjs"
|
|
150
|
+
},
|
|
151
|
+
"./responsive-popover": {
|
|
152
|
+
"source": "./src/components/base/responsive-popover/index.ts",
|
|
153
|
+
"types": "./dist/components/base/responsive-popover/index.d.ts",
|
|
154
|
+
"default": "./dist/responsive-popover/index.mjs"
|
|
155
|
+
},
|
|
156
|
+
"./rich-text-editor": {
|
|
157
|
+
"source": "./src/components/features/rich-text-editor/index.ts",
|
|
158
|
+
"types": "./dist/components/features/rich-text-editor/index.d.ts",
|
|
159
|
+
"default": "./dist/rich-text-editor/index.mjs"
|
|
160
|
+
},
|
|
142
161
|
"./select": {
|
|
143
162
|
"source": "./src/components/base/select/index.ts",
|
|
144
163
|
"types": "./dist/components/base/select/index.d.ts",
|
|
@@ -209,11 +228,6 @@
|
|
|
209
228
|
"types": "./dist/components/features/autosearch/index.d.ts",
|
|
210
229
|
"default": "./dist/autosearch/index.mjs"
|
|
211
230
|
},
|
|
212
|
-
"./combobox": {
|
|
213
|
-
"source": "./src/components/features/combobox/index.ts",
|
|
214
|
-
"types": "./dist/components/features/combobox/index.d.ts",
|
|
215
|
-
"default": "./dist/combobox/index.mjs"
|
|
216
|
-
},
|
|
217
231
|
"./avatar-stack": {
|
|
218
232
|
"source": "./src/components/features/avatar-stack/index.ts",
|
|
219
233
|
"types": "./dist/components/features/avatar-stack/index.d.ts",
|
|
@@ -284,6 +298,11 @@
|
|
|
284
298
|
"types": "./dist/exports/map.d.ts",
|
|
285
299
|
"default": "./dist/map/index.mjs"
|
|
286
300
|
},
|
|
301
|
+
"./mobile-sheet": {
|
|
302
|
+
"source": "./src/components/base/mobile-sheet/index.ts",
|
|
303
|
+
"types": "./dist/components/base/mobile-sheet/index.d.ts",
|
|
304
|
+
"default": "./dist/mobile-sheet/index.mjs"
|
|
305
|
+
},
|
|
287
306
|
"./more-actions": {
|
|
288
307
|
"source": "./src/components/features/more-actions/index.ts",
|
|
289
308
|
"types": "./dist/components/features/more-actions/index.d.ts",
|
|
@@ -348,6 +367,11 @@
|
|
|
348
367
|
"source": "./src/components/features/transfer/index.ts",
|
|
349
368
|
"types": "./dist/components/features/transfer/index.d.ts",
|
|
350
369
|
"default": "./dist/transfer/index.mjs"
|
|
370
|
+
},
|
|
371
|
+
"./multi-select": {
|
|
372
|
+
"source": "./src/components/features/multi-select/index.ts",
|
|
373
|
+
"types": "./dist/components/features/multi-select/index.d.ts",
|
|
374
|
+
"default": "./dist/multi-select/index.mjs"
|
|
351
375
|
}
|
|
352
376
|
},
|
|
353
377
|
"main": "./dist/index.mjs",
|
|
@@ -368,6 +392,12 @@
|
|
|
368
392
|
"@stepperize/react": ">=4",
|
|
369
393
|
"@tanstack/react-table": ">=8",
|
|
370
394
|
"@tanstack/react-virtual": ">=3",
|
|
395
|
+
"@tiptap/extension-character-count": ">=3",
|
|
396
|
+
"@tiptap/extension-link": ">=3",
|
|
397
|
+
"@tiptap/extension-placeholder": ">=3",
|
|
398
|
+
"@tiptap/extension-underline": ">=3",
|
|
399
|
+
"@tiptap/react": ">=3",
|
|
400
|
+
"@tiptap/starter-kit": ">=3",
|
|
371
401
|
"date-fns": ">=4",
|
|
372
402
|
"date-fns-tz": ">=3",
|
|
373
403
|
"js-yaml": "^4.1.0",
|
|
@@ -420,6 +450,24 @@
|
|
|
420
450
|
"@tanstack/react-virtual": {
|
|
421
451
|
"optional": true
|
|
422
452
|
},
|
|
453
|
+
"@tiptap/extension-character-count": {
|
|
454
|
+
"optional": true
|
|
455
|
+
},
|
|
456
|
+
"@tiptap/extension-link": {
|
|
457
|
+
"optional": true
|
|
458
|
+
},
|
|
459
|
+
"@tiptap/extension-placeholder": {
|
|
460
|
+
"optional": true
|
|
461
|
+
},
|
|
462
|
+
"@tiptap/extension-underline": {
|
|
463
|
+
"optional": true
|
|
464
|
+
},
|
|
465
|
+
"@tiptap/react": {
|
|
466
|
+
"optional": true
|
|
467
|
+
},
|
|
468
|
+
"@tiptap/starter-kit": {
|
|
469
|
+
"optional": true
|
|
470
|
+
},
|
|
423
471
|
"date-fns": {
|
|
424
472
|
"optional": true
|
|
425
473
|
},
|
|
@@ -503,6 +551,7 @@
|
|
|
503
551
|
"class-variance-authority": "^0.7.1",
|
|
504
552
|
"clsx": "^2.1.1",
|
|
505
553
|
"cmdk": "^1",
|
|
554
|
+
"isomorphic-dompurify": "^3.8.0",
|
|
506
555
|
"tailwind-merge": "^3.5.0",
|
|
507
556
|
"tw-animate-css": "^1"
|
|
508
557
|
},
|
|
@@ -519,6 +568,12 @@
|
|
|
519
568
|
"@testing-library/jest-dom": "^6",
|
|
520
569
|
"@testing-library/react": "^16",
|
|
521
570
|
"@testing-library/user-event": "^14",
|
|
571
|
+
"@tiptap/extension-character-count": "^3.22.3",
|
|
572
|
+
"@tiptap/extension-link": "^3.22.3",
|
|
573
|
+
"@tiptap/extension-placeholder": "^3.22.3",
|
|
574
|
+
"@tiptap/extension-underline": "^3.22.3",
|
|
575
|
+
"@tiptap/react": "^3.22.3",
|
|
576
|
+
"@tiptap/starter-kit": "^3.22.3",
|
|
522
577
|
"@types/js-yaml": "^4.0.9",
|
|
523
578
|
"@types/leaflet": "^1.9.21",
|
|
524
579
|
"@types/leaflet-draw": "^1.0.13",
|