@ox0/ui 3.10.1 → 3.11.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
interface ChevronProps {
|
|
2
|
-
readonly direction?: "down" | "up";
|
|
2
|
+
readonly direction?: "down" | "up" | "left" | "right";
|
|
3
3
|
/** Rendered size in px. @default 16 */
|
|
4
4
|
readonly size?: number;
|
|
5
5
|
}
|
|
@@ -10,5 +10,7 @@ export declare function Checkmark({ size }: Pick<ChevronProps, "size">): import(
|
|
|
10
10
|
export declare function MenuGlyph({ size }: {
|
|
11
11
|
readonly size?: number | string;
|
|
12
12
|
}): import("react").JSX.Element;
|
|
13
|
+
/** Internal — a calendar (Lucide `calendar` geometry), for date fields. */
|
|
14
|
+
export declare function CalendarGlyph({ size }: Pick<ChevronProps, "size">): import("react").JSX.Element;
|
|
13
15
|
export {};
|
|
14
16
|
//# sourceMappingURL=chevron.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chevron.d.ts","sourceRoot":"","sources":["../../src/components/chevron.tsx"],"names":[],"mappings":"AAGA,UAAU,YAAY;IACpB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"chevron.d.ts","sourceRoot":"","sources":["../../src/components/chevron.tsx"],"names":[],"mappings":"AAGA,UAAU,YAAY;IACpB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,CAAA;IACrD,uCAAuC;IACvC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACvB;AASD,wBAAgB,OAAO,CAAC,EAAE,SAAkB,EAAE,IAAS,EAAE,EAAE,YAAY,+BAgBtE;AAED,0EAA0E;AAC1E,wBAAgB,SAAS,CAAC,EAAE,IAAS,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,+BAgBlE;AAED,sEAAsE;AACtE,wBAAgB,SAAS,CAAC,EAAE,IAAS,EAAE,EAAE;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,+BAgB3E;AAED,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,EAAE,IAAS,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,+BAkBtE"}
|
|
@@ -31,7 +31,8 @@ export interface DateFieldProps extends LayoutItemProps {
|
|
|
31
31
|
readonly isRequired?: boolean;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* A date entered as month, day and year segments in the user's locale order
|
|
34
|
+
* A date entered as month, day and year segments in the user's locale order,
|
|
35
|
+
* or picked from a calendar (the button at the end, or Alt+↓ from a segment).
|
|
35
36
|
* It draws its own placeholders ("mm/dd/yyyy"), so an empty field looks empty
|
|
36
37
|
* in every browser, unlike `<input type="date">`.
|
|
37
38
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-field.d.ts","sourceRoot":"","sources":["../../src/components/date-field.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"date-field.d.ts","sourceRoot":"","sources":["../../src/components/date-field.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAA;AA0BpF,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,uBAAuB,CAAA;AAoB3E,MAAM,WAAW,cAAe,SAAQ,eAAe;IACrD,qFAAqF;IACrF,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAA;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,CAAA;IAChC,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAA;IACjC;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC,uFAAuF;IACvF,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IAClD,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;IACtD,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;IACvD,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,2CAA2C;IAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EACxB,SAAS,EACT,SAAS,EACT,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,EAAE,EACF,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,OAAO,EACP,KAAK,EACL,GAAG,SAAS,EACb,EAAE,cAAc,GAAG,SAAS,CAkK5B"}
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,9 @@ import { isFocusVisible as hooks_isFocusVisible, useControllableState, useMediaQ
|
|
|
4
4
|
import { Ox0I18nProvider, toDateTimeAttribute, useDateFormat, useMessage } from "@ox0/i18n";
|
|
5
5
|
import { createPortal } from "react-dom";
|
|
6
6
|
import { FloatingFocusManager, FloatingPortal, autoUpdate, flip, offset as react_offset, shift, size as react_size, useClick, useDismiss, useFloating, useInteractions, useListNavigation, useMergeRefs, useRole } from "@floating-ui/react";
|
|
7
|
-
import { DismissButton, HiddenSelect, Overlay, mergeProps, useButton, useDateField, useDateSegment, useFocusRing, useListBox, useListBoxSection, useObjectRef, useOption, usePopover, useSelect } from "react-aria";
|
|
8
|
-
import { Item, Section, useDateFieldState, useListState, useSelectState } from "react-stately";
|
|
9
|
-
import { createCalendar, parseDate } from "@internationalized/date";
|
|
7
|
+
import { DismissButton, HiddenSelect, Overlay, mergeProps, useButton, useCalendar, useCalendarCell, useCalendarGrid, useDateField, useDatePicker, useDateSegment, useDialog, useFocusRing, useListBox, useListBoxSection, useObjectRef, useOption, usePopover, useSelect } from "react-aria";
|
|
8
|
+
import { Item, Section, useCalendarState, useDateFieldState, useDatePickerState, useListState, useSelectState } from "react-stately";
|
|
9
|
+
import { GregorianCalendar, createCalendar, getLocalTimeZone, getWeeksInMonth, isToday, parseDate, toCalendar, toCalendarDate } from "@internationalized/date";
|
|
10
10
|
import { IntlContext } from "react-intl";
|
|
11
11
|
import { breakpoints, createTheme, readThemePreference, writeThemePreference } from "@ox0/tokens";
|
|
12
12
|
import "@ox0/tokens/styles.css";
|
|
@@ -1771,7 +1771,7 @@ label:hover > .control-TGnWDN[aria-invalid="true"]:not(:disabled) {
|
|
|
1771
1771
|
font-variant-numeric: tabular-nums;
|
|
1772
1772
|
height: var(--ox0-control-height-md);
|
|
1773
1773
|
min-inline-size: 0;
|
|
1774
|
-
padding-inline: calc(var(--ox0-space-md) - 2px);
|
|
1774
|
+
padding-inline: calc(var(--ox0-space-md) - 2px) var(--ox0-space-2xs);
|
|
1775
1775
|
transition: border-color var(--ox0-duration-fast) var(--ox0-ease-crisp),
|
|
1776
1776
|
box-shadow var(--ox0-duration-fast) var(--ox0-ease-crisp);
|
|
1777
1777
|
white-space: nowrap;
|
|
@@ -1803,6 +1803,48 @@ label:hover > .control-TGnWDN[aria-invalid="true"]:not(:disabled) {
|
|
|
1803
1803
|
cursor: not-allowed;
|
|
1804
1804
|
}
|
|
1805
1805
|
|
|
1806
|
+
.segments-p4Fzoj {
|
|
1807
|
+
flex: auto;
|
|
1808
|
+
align-items: center;
|
|
1809
|
+
min-inline-size: 0;
|
|
1810
|
+
display: flex;
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1813
|
+
.calendarButton-dSeheH {
|
|
1814
|
+
block-size: calc(var(--ox0-control-height-md) - 8px);
|
|
1815
|
+
border-radius: var(--ox0-radius-xs);
|
|
1816
|
+
color: var(--ox0-color-muted);
|
|
1817
|
+
cursor: pointer;
|
|
1818
|
+
inline-size: calc(var(--ox0-control-height-md) - 8px);
|
|
1819
|
+
background: none;
|
|
1820
|
+
border: none;
|
|
1821
|
+
outline: none;
|
|
1822
|
+
flex: none;
|
|
1823
|
+
justify-content: center;
|
|
1824
|
+
align-items: center;
|
|
1825
|
+
margin-inline-start: var(--ox0-space-xs);
|
|
1826
|
+
padding: 0;
|
|
1827
|
+
display: inline-flex;
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
.calendarButton-dSeheH:hover {
|
|
1831
|
+
background: var(--ox0-color-surface-sunken);
|
|
1832
|
+
color: var(--ox0-color-foreground);
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
.calendarButton-dSeheH:focus-visible {
|
|
1836
|
+
box-shadow: 0 0 0 2px var(--ox0-color-accent);
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
.calendarButton-dSeheH:disabled {
|
|
1840
|
+
color: var(--ox0-color-disabled);
|
|
1841
|
+
cursor: not-allowed;
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
.calendarButton-dSeheH:disabled:hover {
|
|
1845
|
+
background: none;
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1806
1848
|
.segment-qBeSFi {
|
|
1807
1849
|
border-radius: var(--ox0-radius-xs);
|
|
1808
1850
|
box-sizing: content-box;
|
|
@@ -1834,6 +1876,122 @@ label:hover > .control-TGnWDN[aria-invalid="true"]:not(:disabled) {
|
|
|
1834
1876
|
color: var(--ox0-color-danger-text);
|
|
1835
1877
|
font-size: var(--ox0-font-size-sm);
|
|
1836
1878
|
}
|
|
1879
|
+
|
|
1880
|
+
.popover-nvxR3G {
|
|
1881
|
+
background: var(--ox0-color-surface-raised);
|
|
1882
|
+
border: 1px solid var(--ox0-color-border);
|
|
1883
|
+
border-radius: var(--ox0-radius-md);
|
|
1884
|
+
box-shadow: var(--ox0-shadow-popover);
|
|
1885
|
+
color: var(--ox0-color-foreground);
|
|
1886
|
+
font-family: var(--ox0-font-sans);
|
|
1887
|
+
font-size: var(--ox0-font-size-sm);
|
|
1888
|
+
padding: var(--ox0-space-sm);
|
|
1889
|
+
z-index: var(--ox0-z-popover);
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
.dialog-MW5_dI {
|
|
1893
|
+
outline: none;
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
.calendarHeader-Rrza1b {
|
|
1897
|
+
align-items: center;
|
|
1898
|
+
gap: var(--ox0-space-xs);
|
|
1899
|
+
justify-content: space-between;
|
|
1900
|
+
margin-block-end: var(--ox0-space-xs);
|
|
1901
|
+
display: flex;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
.calendarTitle-8q_D1C {
|
|
1905
|
+
font-size: var(--ox0-font-size-md);
|
|
1906
|
+
font-weight: var(--ox0-font-weight-medium);
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
.calendarNav-FPYc8j {
|
|
1910
|
+
border-radius: var(--ox0-radius-sm);
|
|
1911
|
+
block-size: 2rem;
|
|
1912
|
+
color: var(--ox0-color-muted);
|
|
1913
|
+
cursor: pointer;
|
|
1914
|
+
background: none;
|
|
1915
|
+
border: none;
|
|
1916
|
+
outline: none;
|
|
1917
|
+
justify-content: center;
|
|
1918
|
+
align-items: center;
|
|
1919
|
+
inline-size: 2rem;
|
|
1920
|
+
padding: 0;
|
|
1921
|
+
display: inline-flex;
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
.calendarNav-FPYc8j:hover {
|
|
1925
|
+
background: var(--ox0-color-surface-sunken);
|
|
1926
|
+
color: var(--ox0-color-foreground);
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
.calendarNav-FPYc8j:focus-visible {
|
|
1930
|
+
box-shadow: 0 0 0 2px var(--ox0-color-accent);
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
.calendarNav-FPYc8j:disabled {
|
|
1934
|
+
color: var(--ox0-color-disabled);
|
|
1935
|
+
cursor: not-allowed;
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
.calendarGrid-SU1p6b {
|
|
1939
|
+
border-collapse: collapse;
|
|
1940
|
+
font-variant-numeric: tabular-nums;
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
.weekday-GJhqXA {
|
|
1944
|
+
block-size: 2rem;
|
|
1945
|
+
color: var(--ox0-color-muted);
|
|
1946
|
+
font-size: var(--ox0-font-size-xs);
|
|
1947
|
+
font-weight: var(--ox0-font-weight-medium);
|
|
1948
|
+
text-align: center;
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
.calendarCellSlot-fhQnSm {
|
|
1952
|
+
padding: 1px;
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
.calendarCell-mNQcbP {
|
|
1956
|
+
border-radius: var(--ox0-radius-sm);
|
|
1957
|
+
cursor: pointer;
|
|
1958
|
+
outline: none;
|
|
1959
|
+
justify-content: center;
|
|
1960
|
+
align-items: center;
|
|
1961
|
+
block-size: 2.25rem;
|
|
1962
|
+
inline-size: 2.25rem;
|
|
1963
|
+
display: flex;
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
.calendarCell-mNQcbP[hidden] {
|
|
1967
|
+
display: none;
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
.calendarCell-mNQcbP:hover {
|
|
1971
|
+
background: var(--ox0-color-surface-sunken);
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
.calendarCell-mNQcbP[data-today] {
|
|
1975
|
+
box-shadow: inset 0 0 0 1px var(--ox0-color-border-strong);
|
|
1976
|
+
font-weight: var(--ox0-font-weight-medium);
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
.calendarCell-mNQcbP[data-selected] {
|
|
1980
|
+
background: var(--ox0-color-accent);
|
|
1981
|
+
color: var(--ox0-color-on-accent);
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
.calendarCell-mNQcbP:focus-visible {
|
|
1985
|
+
box-shadow: 0 0 0 2px var(--ox0-color-focus-ring),
|
|
1986
|
+
inset 0 0 0 1px var(--ox0-color-accent);
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
.calendarCell-mNQcbP[data-disabled] {
|
|
1990
|
+
color: var(--ox0-color-disabled);
|
|
1991
|
+
cursor: not-allowed;
|
|
1992
|
+
background: none;
|
|
1993
|
+
text-decoration: line-through;
|
|
1994
|
+
}
|
|
1837
1995
|
`,
|
|
1838
1996
|
""
|
|
1839
1997
|
]);
|
|
@@ -1843,11 +2001,22 @@ label:hover > .control-TGnWDN[aria-invalid="true"]:not(:disabled) {
|
|
|
1843
2001
|
focusVisible: "focusVisible-O_oNxe",
|
|
1844
2002
|
invalid: "invalid-G42Ug_",
|
|
1845
2003
|
disabled: "disabled-eefMMd",
|
|
2004
|
+
segments: "segments-p4Fzoj",
|
|
2005
|
+
calendarButton: "calendarButton-dSeheH",
|
|
1846
2006
|
segment: "segment-qBeSFi",
|
|
1847
2007
|
placeholder: "placeholder-n53Bc3",
|
|
1848
2008
|
literal: "literal-L0lCHh",
|
|
1849
2009
|
description: "description-iyjYjF",
|
|
1850
|
-
error: "error-fBRnM3"
|
|
2010
|
+
error: "error-fBRnM3",
|
|
2011
|
+
popover: "popover-nvxR3G",
|
|
2012
|
+
dialog: "dialog-MW5_dI",
|
|
2013
|
+
calendarHeader: "calendarHeader-Rrza1b",
|
|
2014
|
+
calendarTitle: "calendarTitle-8q_D1C",
|
|
2015
|
+
calendarNav: "calendarNav-FPYc8j",
|
|
2016
|
+
calendarGrid: "calendarGrid-SU1p6b",
|
|
2017
|
+
weekday: "weekday-GJhqXA",
|
|
2018
|
+
calendarCellSlot: "calendarCellSlot-fhQnSm",
|
|
2019
|
+
calendarCell: "calendarCell-mNQcbP"
|
|
1851
2020
|
};
|
|
1852
2021
|
const __rspack_default_export = ___CSS_LOADER_EXPORT___;
|
|
1853
2022
|
__webpack_require__.d(__webpack_exports__, {}, {
|
|
@@ -6366,6 +6535,12 @@ const RouterContext = createContext(null);
|
|
|
6366
6535
|
function useRouter() {
|
|
6367
6536
|
return useContext(RouterContext);
|
|
6368
6537
|
}
|
|
6538
|
+
const CHEVRON_PATHS = {
|
|
6539
|
+
down: "m6 9 6 6 6-6",
|
|
6540
|
+
up: "m18 15-6-6-6 6",
|
|
6541
|
+
left: "m15 18-6-6 6-6",
|
|
6542
|
+
right: "m9 18 6-6-6-6"
|
|
6543
|
+
};
|
|
6369
6544
|
function Chevron({ direction = "down", size = 16 }) {
|
|
6370
6545
|
return /*#__PURE__*/ jsx("svg", {
|
|
6371
6546
|
"aria-hidden": "true",
|
|
@@ -6378,7 +6553,7 @@ function Chevron({ direction = "down", size = 16 }) {
|
|
|
6378
6553
|
viewBox: "0 0 24 24",
|
|
6379
6554
|
width: size,
|
|
6380
6555
|
children: /*#__PURE__*/ jsx("path", {
|
|
6381
|
-
d:
|
|
6556
|
+
d: CHEVRON_PATHS[direction]
|
|
6382
6557
|
})
|
|
6383
6558
|
});
|
|
6384
6559
|
}
|
|
@@ -6414,6 +6589,34 @@ function MenuGlyph({ size = 16 }) {
|
|
|
6414
6589
|
})
|
|
6415
6590
|
});
|
|
6416
6591
|
}
|
|
6592
|
+
function CalendarGlyph({ size = 16 }) {
|
|
6593
|
+
return /*#__PURE__*/ jsxs("svg", {
|
|
6594
|
+
"aria-hidden": "true",
|
|
6595
|
+
fill: "none",
|
|
6596
|
+
height: size,
|
|
6597
|
+
stroke: "currentColor",
|
|
6598
|
+
strokeLinecap: "round",
|
|
6599
|
+
strokeLinejoin: "round",
|
|
6600
|
+
strokeWidth: 2,
|
|
6601
|
+
viewBox: "0 0 24 24",
|
|
6602
|
+
width: size,
|
|
6603
|
+
children: [
|
|
6604
|
+
/*#__PURE__*/ jsx("path", {
|
|
6605
|
+
d: "M8 2v4M16 2v4"
|
|
6606
|
+
}),
|
|
6607
|
+
/*#__PURE__*/ jsx("rect", {
|
|
6608
|
+
height: "18",
|
|
6609
|
+
rx: "2",
|
|
6610
|
+
width: "18",
|
|
6611
|
+
x: "3",
|
|
6612
|
+
y: "4"
|
|
6613
|
+
}),
|
|
6614
|
+
/*#__PURE__*/ jsx("path", {
|
|
6615
|
+
d: "M3 10h18"
|
|
6616
|
+
})
|
|
6617
|
+
]
|
|
6618
|
+
});
|
|
6619
|
+
}
|
|
6417
6620
|
const drawer_module_0 = __webpack_require__("../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/css-loader/index.js??ruleSet[1].rules[1].oneOf[4].use[1]!builtin:lightningcss-loader??ruleSet[1].rules[1].oneOf[4].use[2]!./src/components/drawer.module.css");
|
|
6418
6621
|
var drawer_module_options = {};
|
|
6419
6622
|
drawer_module_options.styleTagTransform = styleTagTransform_default();
|
|
@@ -13334,7 +13537,7 @@ date_field_module_options.insertStyleElement = insertStyleElement_default();
|
|
|
13334
13537
|
injectStylesIntoStyleTag_default()(date_field_module_0.A, date_field_module_options);
|
|
13335
13538
|
const date_field_module = date_field_module_0.A && date_field_module_0.A.locals ? date_field_module_0.A.locals : void 0;
|
|
13336
13539
|
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
13337
|
-
function
|
|
13540
|
+
function date_field_toCalendarDate(value) {
|
|
13338
13541
|
if (void 0 === value) return;
|
|
13339
13542
|
if (null === value || !ISO_DATE.test(value)) return null;
|
|
13340
13543
|
try {
|
|
@@ -13345,17 +13548,19 @@ function toCalendarDate(value) {
|
|
|
13345
13548
|
}
|
|
13346
13549
|
function DateField({ ariaLabel, autoFocus, defaultValue, description, errorMessage, id, isDisabled, isInvalid, isReadOnly, isRequired, label, maxValue, minValue, name, onBlur, onChange, onFocus, value, ...restProps }) {
|
|
13347
13550
|
const { style: layoutStyle } = useLayoutItem(restProps);
|
|
13348
|
-
const
|
|
13349
|
-
const
|
|
13551
|
+
const intl = useContext(IntlContext);
|
|
13552
|
+
const locale = intl?.locale ?? "en-US";
|
|
13553
|
+
const timeZone = intl?.timeZone ?? getLocalTimeZone();
|
|
13554
|
+
const calendarValue = useMemo(()=>date_field_toCalendarDate(value), [
|
|
13350
13555
|
value
|
|
13351
13556
|
]);
|
|
13352
|
-
const calendarDefault = useMemo(()=>
|
|
13557
|
+
const calendarDefault = useMemo(()=>date_field_toCalendarDate(defaultValue), [
|
|
13353
13558
|
defaultValue
|
|
13354
13559
|
]);
|
|
13355
|
-
const calendarMin = useMemo(()=>
|
|
13560
|
+
const calendarMin = useMemo(()=>date_field_toCalendarDate(minValue) ?? void 0, [
|
|
13356
13561
|
minValue
|
|
13357
13562
|
]);
|
|
13358
|
-
const calendarMax = useMemo(()=>
|
|
13563
|
+
const calendarMax = useMemo(()=>date_field_toCalendarDate(maxValue) ?? void 0, [
|
|
13359
13564
|
maxValue
|
|
13360
13565
|
]);
|
|
13361
13566
|
const dateProps = {
|
|
@@ -13364,6 +13569,7 @@ function DateField({ ariaLabel, autoFocus, defaultValue, description, errorMessa
|
|
|
13364
13569
|
defaultValue: calendarDefault,
|
|
13365
13570
|
description,
|
|
13366
13571
|
errorMessage,
|
|
13572
|
+
granularity: "day",
|
|
13367
13573
|
id,
|
|
13368
13574
|
isDisabled,
|
|
13369
13575
|
isInvalid: isInvalid || null != errorMessage ? true : void 0,
|
|
@@ -13375,25 +13581,56 @@ function DateField({ ariaLabel, autoFocus, defaultValue, description, errorMessa
|
|
|
13375
13581
|
name,
|
|
13376
13582
|
onBlur,
|
|
13377
13583
|
onFocus,
|
|
13378
|
-
onChange: onChange ? (date)=>onChange(date ? date
|
|
13584
|
+
onChange: onChange ? (date)=>onChange(date ? toIsoDate(date) : null) : void 0,
|
|
13379
13585
|
validationBehavior: "aria",
|
|
13380
13586
|
value: calendarValue
|
|
13381
13587
|
};
|
|
13382
|
-
const
|
|
13588
|
+
const pickerState = useDatePickerState({
|
|
13383
13589
|
...dateProps,
|
|
13590
|
+
shouldCloseOnSelect: true
|
|
13591
|
+
});
|
|
13592
|
+
const groupRef = useRef(null);
|
|
13593
|
+
const { buttonProps: calendarButtonAria, calendarProps, descriptionProps, dialogProps, errorMessageProps, fieldProps: pickerFieldProps, groupProps, labelProps } = useDatePicker(dateProps, pickerState, groupRef);
|
|
13594
|
+
const fieldState = useDateFieldState({
|
|
13595
|
+
...pickerFieldProps,
|
|
13384
13596
|
createCalendar: createCalendar,
|
|
13385
13597
|
locale
|
|
13386
13598
|
});
|
|
13387
|
-
const
|
|
13599
|
+
const fieldRef = useRef(null);
|
|
13388
13600
|
const inputRef = useRef(null);
|
|
13389
|
-
const {
|
|
13390
|
-
...
|
|
13391
|
-
inputRef
|
|
13392
|
-
|
|
13601
|
+
const { fieldProps, inputProps } = useDateField({
|
|
13602
|
+
...pickerFieldProps,
|
|
13603
|
+
inputRef,
|
|
13604
|
+
name
|
|
13605
|
+
}, fieldState, fieldRef);
|
|
13606
|
+
const buttonRef = useRef(null);
|
|
13607
|
+
const { buttonProps: calendarButtonProps } = useButton({
|
|
13608
|
+
...calendarButtonAria,
|
|
13609
|
+
isDisabled: isDisabled || isReadOnly
|
|
13610
|
+
}, buttonRef);
|
|
13393
13611
|
const { focusProps, isFocusVisible } = useFocusRing({
|
|
13394
13612
|
within: true
|
|
13395
13613
|
});
|
|
13396
|
-
const
|
|
13614
|
+
const returnFocusRef = useRef(null);
|
|
13615
|
+
const invalid = pickerState.isInvalid;
|
|
13616
|
+
const { floatingStyles, context, refs: { setFloating, setReference } } = useFloating({
|
|
13617
|
+
open: pickerState.isOpen,
|
|
13618
|
+
onOpenChange: pickerState.setOpen,
|
|
13619
|
+
placement: "bottom-start",
|
|
13620
|
+
middleware: [
|
|
13621
|
+
react_offset(4),
|
|
13622
|
+
flip({
|
|
13623
|
+
padding: 8
|
|
13624
|
+
}),
|
|
13625
|
+
shift({
|
|
13626
|
+
padding: 8
|
|
13627
|
+
})
|
|
13628
|
+
],
|
|
13629
|
+
whileElementsMounted: autoUpdate
|
|
13630
|
+
});
|
|
13631
|
+
const { getFloatingProps } = useInteractions([
|
|
13632
|
+
useDismiss(context)
|
|
13633
|
+
]);
|
|
13397
13634
|
return /*#__PURE__*/ jsxs("div", {
|
|
13398
13635
|
className: date_field_module.root,
|
|
13399
13636
|
style: layoutStyle,
|
|
@@ -13404,8 +13641,14 @@ function DateField({ ariaLabel, autoFocus, defaultValue, description, errorMessa
|
|
|
13404
13641
|
children: label
|
|
13405
13642
|
}) : null,
|
|
13406
13643
|
/*#__PURE__*/ jsxs("div", {
|
|
13407
|
-
...mergeProps(
|
|
13408
|
-
|
|
13644
|
+
...mergeProps(groupProps, focusProps),
|
|
13645
|
+
onFocusCapture: (event)=>{
|
|
13646
|
+
if (event.target instanceof HTMLElement) returnFocusRef.current = event.target;
|
|
13647
|
+
},
|
|
13648
|
+
ref: (node)=>{
|
|
13649
|
+
groupRef.current = node;
|
|
13650
|
+
setReference(node);
|
|
13651
|
+
},
|
|
13409
13652
|
className: [
|
|
13410
13653
|
date_field_module.control,
|
|
13411
13654
|
invalid ? date_field_module.invalid : null,
|
|
@@ -13413,14 +13656,28 @@ function DateField({ ariaLabel, autoFocus, defaultValue, description, errorMessa
|
|
|
13413
13656
|
isDisabled ? date_field_module.disabled : null
|
|
13414
13657
|
].filter(Boolean).join(" "),
|
|
13415
13658
|
children: [
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
|
|
13419
|
-
|
|
13659
|
+
/*#__PURE__*/ jsx("div", {
|
|
13660
|
+
...fieldProps,
|
|
13661
|
+
ref: fieldRef,
|
|
13662
|
+
className: date_field_module.segments,
|
|
13663
|
+
children: fieldState.segments.map((segment, i)=>/*#__PURE__*/ jsx(Segment, {
|
|
13664
|
+
segment: segment,
|
|
13665
|
+
state: fieldState
|
|
13666
|
+
}, i))
|
|
13667
|
+
}),
|
|
13420
13668
|
/*#__PURE__*/ jsx("input", {
|
|
13421
13669
|
...inputProps,
|
|
13422
13670
|
ref: inputRef,
|
|
13423
13671
|
type: "hidden"
|
|
13672
|
+
}),
|
|
13673
|
+
/*#__PURE__*/ jsx("button", {
|
|
13674
|
+
...calendarButtonProps,
|
|
13675
|
+
ref: buttonRef,
|
|
13676
|
+
className: date_field_module.calendarButton,
|
|
13677
|
+
type: "button",
|
|
13678
|
+
children: /*#__PURE__*/ jsx(CalendarGlyph, {
|
|
13679
|
+
size: 16
|
|
13680
|
+
})
|
|
13424
13681
|
})
|
|
13425
13682
|
]
|
|
13426
13683
|
}),
|
|
@@ -13433,10 +13690,150 @@ function DateField({ ariaLabel, autoFocus, defaultValue, description, errorMessa
|
|
|
13433
13690
|
...errorMessageProps,
|
|
13434
13691
|
className: date_field_module.error,
|
|
13435
13692
|
children: errorMessage
|
|
13693
|
+
}) : null,
|
|
13694
|
+
pickerState.isOpen ? /*#__PURE__*/ jsx(FloatingPortal, {
|
|
13695
|
+
root: themeRoot(context.elements.domReference),
|
|
13696
|
+
children: /*#__PURE__*/ jsx(FloatingFocusManager, {
|
|
13697
|
+
context: context,
|
|
13698
|
+
initialFocus: -1,
|
|
13699
|
+
modal: false,
|
|
13700
|
+
returnFocus: returnFocusRef,
|
|
13701
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
13702
|
+
ref: setFloating,
|
|
13703
|
+
className: date_field_module.popover,
|
|
13704
|
+
style: floatingStyles,
|
|
13705
|
+
...getFloatingProps(),
|
|
13706
|
+
children: /*#__PURE__*/ jsx(CalendarDialog, {
|
|
13707
|
+
calendarProps: calendarProps,
|
|
13708
|
+
dialogProps: dialogProps,
|
|
13709
|
+
locale: locale,
|
|
13710
|
+
timeZone: timeZone
|
|
13711
|
+
})
|
|
13712
|
+
})
|
|
13713
|
+
})
|
|
13436
13714
|
}) : null
|
|
13437
13715
|
]
|
|
13438
13716
|
});
|
|
13439
13717
|
}
|
|
13718
|
+
function toIsoDate(date) {
|
|
13719
|
+
return toCalendar(toCalendarDate(date), new GregorianCalendar()).toString();
|
|
13720
|
+
}
|
|
13721
|
+
function CalendarDialog({ calendarProps, dialogProps, locale, timeZone }) {
|
|
13722
|
+
const ref = useRef(null);
|
|
13723
|
+
const { dialogProps: domDialogProps } = useDialog(dialogProps, ref);
|
|
13724
|
+
return /*#__PURE__*/ jsx("div", {
|
|
13725
|
+
...domDialogProps,
|
|
13726
|
+
ref: ref,
|
|
13727
|
+
className: date_field_module.dialog,
|
|
13728
|
+
children: /*#__PURE__*/ jsx(Calendar, {
|
|
13729
|
+
...calendarProps,
|
|
13730
|
+
locale: locale,
|
|
13731
|
+
timeZone: timeZone
|
|
13732
|
+
})
|
|
13733
|
+
});
|
|
13734
|
+
}
|
|
13735
|
+
function Calendar({ locale, timeZone, ...props }) {
|
|
13736
|
+
const state = useCalendarState({
|
|
13737
|
+
...props,
|
|
13738
|
+
createCalendar: createCalendar,
|
|
13739
|
+
locale
|
|
13740
|
+
});
|
|
13741
|
+
const { calendarProps, nextButtonProps, prevButtonProps, title } = useCalendar(props, state);
|
|
13742
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
13743
|
+
...calendarProps,
|
|
13744
|
+
className: date_field_module.calendar,
|
|
13745
|
+
children: [
|
|
13746
|
+
/*#__PURE__*/ jsxs("div", {
|
|
13747
|
+
className: date_field_module.calendarHeader,
|
|
13748
|
+
children: [
|
|
13749
|
+
/*#__PURE__*/ jsx(CalendarNavButton, {
|
|
13750
|
+
...prevButtonProps,
|
|
13751
|
+
direction: "left"
|
|
13752
|
+
}),
|
|
13753
|
+
/*#__PURE__*/ jsx("span", {
|
|
13754
|
+
"aria-hidden": "true",
|
|
13755
|
+
className: date_field_module.calendarTitle,
|
|
13756
|
+
children: title
|
|
13757
|
+
}),
|
|
13758
|
+
/*#__PURE__*/ jsx(CalendarNavButton, {
|
|
13759
|
+
...nextButtonProps,
|
|
13760
|
+
direction: "right"
|
|
13761
|
+
})
|
|
13762
|
+
]
|
|
13763
|
+
}),
|
|
13764
|
+
/*#__PURE__*/ jsx(CalendarGrid, {
|
|
13765
|
+
locale: locale,
|
|
13766
|
+
state: state,
|
|
13767
|
+
timeZone: timeZone
|
|
13768
|
+
})
|
|
13769
|
+
]
|
|
13770
|
+
});
|
|
13771
|
+
}
|
|
13772
|
+
function CalendarNavButton({ direction, ...props }) {
|
|
13773
|
+
const ref = useRef(null);
|
|
13774
|
+
const { buttonProps } = useButton(props, ref);
|
|
13775
|
+
return /*#__PURE__*/ jsx("button", {
|
|
13776
|
+
...buttonProps,
|
|
13777
|
+
ref: ref,
|
|
13778
|
+
className: date_field_module.calendarNav,
|
|
13779
|
+
type: "button",
|
|
13780
|
+
children: /*#__PURE__*/ jsx(Chevron, {
|
|
13781
|
+
direction: direction,
|
|
13782
|
+
size: 16
|
|
13783
|
+
})
|
|
13784
|
+
});
|
|
13785
|
+
}
|
|
13786
|
+
function CalendarGrid({ locale, state, timeZone }) {
|
|
13787
|
+
const { gridProps, headerProps, weekDays } = useCalendarGrid({}, state);
|
|
13788
|
+
const weeks = getWeeksInMonth(state.visibleRange.start, locale);
|
|
13789
|
+
return /*#__PURE__*/ jsxs("table", {
|
|
13790
|
+
...gridProps,
|
|
13791
|
+
className: date_field_module.calendarGrid,
|
|
13792
|
+
children: [
|
|
13793
|
+
/*#__PURE__*/ jsx("thead", {
|
|
13794
|
+
...headerProps,
|
|
13795
|
+
children: /*#__PURE__*/ jsx("tr", {
|
|
13796
|
+
children: weekDays.map((day, i)=>/*#__PURE__*/ jsx("th", {
|
|
13797
|
+
className: date_field_module.weekday,
|
|
13798
|
+
children: day
|
|
13799
|
+
}, i))
|
|
13800
|
+
})
|
|
13801
|
+
}),
|
|
13802
|
+
/*#__PURE__*/ jsx("tbody", {
|
|
13803
|
+
children: Array.from({
|
|
13804
|
+
length: weeks
|
|
13805
|
+
}, (_, week)=>/*#__PURE__*/ jsx("tr", {
|
|
13806
|
+
children: state.getDatesInWeek(week).map((date, i)=>date ? /*#__PURE__*/ jsx(CalendarCell, {
|
|
13807
|
+
date: date,
|
|
13808
|
+
state: state,
|
|
13809
|
+
timeZone: timeZone
|
|
13810
|
+
}, date.toString()) : /*#__PURE__*/ jsx("td", {}, i))
|
|
13811
|
+
}, week))
|
|
13812
|
+
})
|
|
13813
|
+
]
|
|
13814
|
+
});
|
|
13815
|
+
}
|
|
13816
|
+
function CalendarCell({ date, state, timeZone }) {
|
|
13817
|
+
const ref = useRef(null);
|
|
13818
|
+
const { buttonProps, cellProps, formattedDate, isDisabled, isOutsideVisibleRange, isSelected, isUnavailable } = useCalendarCell({
|
|
13819
|
+
date
|
|
13820
|
+
}, state, ref);
|
|
13821
|
+
return /*#__PURE__*/ jsx("td", {
|
|
13822
|
+
...cellProps,
|
|
13823
|
+
className: date_field_module.calendarCellSlot,
|
|
13824
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
13825
|
+
...buttonProps,
|
|
13826
|
+
ref: ref,
|
|
13827
|
+
className: date_field_module.calendarCell,
|
|
13828
|
+
"data-disabled": isDisabled || isUnavailable || void 0,
|
|
13829
|
+
"data-outside": isOutsideVisibleRange || void 0,
|
|
13830
|
+
"data-selected": isSelected || void 0,
|
|
13831
|
+
"data-today": isToday(date, timeZone) || void 0,
|
|
13832
|
+
hidden: isOutsideVisibleRange,
|
|
13833
|
+
children: formattedDate
|
|
13834
|
+
})
|
|
13835
|
+
});
|
|
13836
|
+
}
|
|
13440
13837
|
function Segment({ segment, state }) {
|
|
13441
13838
|
const ref = useRef(null);
|
|
13442
13839
|
const { segmentProps } = useDateSegment(segment, state, ref);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ox0/ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/esturcke/ox0-platform.git",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"@internationalized/date": "^3.12.4",
|
|
26
26
|
"react-aria": "^3.52.1",
|
|
27
27
|
"react-stately": "^3.50.0",
|
|
28
|
+
"@ox0/hooks": "0.3.0",
|
|
28
29
|
"@ox0/i18n": "0.4.0",
|
|
29
|
-
"@ox0/tokens": "0.7.0"
|
|
30
|
-
"@ox0/hooks": "0.3.0"
|
|
30
|
+
"@ox0/tokens": "0.7.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": "^19.0.0",
|