@cboxdk/cbox-ui 0.19.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -4
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1612,8 +1612,8 @@ declare function DatePicker(props: DatePickerProps): react_jsx_runtime.JSX.Eleme
|
|
|
1612
1612
|
* TimePicker — a time of day as `HH:MM` (24-hour, or `null`), in place of `<input type="time">`.
|
|
1613
1613
|
* The Combobox's trigger and a panel with a field to type in and the times at `step` minutes to
|
|
1614
1614
|
* pick from. Typing understands how people write a time ("930", "9.30", "21:30", "9pm", "9:30 am");
|
|
1615
|
-
* Enter takes what was typed even off the step, and the list follows it. Shown
|
|
1616
|
-
*
|
|
1615
|
+
* Enter takes what was typed even off the step, and the list follows it. Shown on a 24-hour clock
|
|
1616
|
+
* unless `hourCycle="h12"` asks for AM/PM; always stored in 24-hour.
|
|
1617
1617
|
*/
|
|
1618
1618
|
type TimePickerProps = Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid'> & {
|
|
1619
1619
|
/** The time as `HH:MM`, or `null`. */
|
|
@@ -1621,6 +1621,8 @@ type TimePickerProps = Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid'>
|
|
|
1621
1621
|
onChange: (value: string | null) => void;
|
|
1622
1622
|
/** Minutes between the times in the list. Default 15. */
|
|
1623
1623
|
step?: number;
|
|
1624
|
+
/** `h23` shows 21:30 (default), `h12` shows 9:30 PM. Typing understands both either way. */
|
|
1625
|
+
hourCycle?: HourCycle;
|
|
1624
1626
|
/** The earliest time, `HH:MM`. */
|
|
1625
1627
|
min?: string;
|
|
1626
1628
|
/** The latest time, `HH:MM`. */
|
|
@@ -1636,6 +1638,7 @@ type TimePickerProps = Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid'>
|
|
|
1636
1638
|
id?: string;
|
|
1637
1639
|
className?: string;
|
|
1638
1640
|
};
|
|
1641
|
+
type HourCycle = 'h23' | 'h12';
|
|
1639
1642
|
declare function TimePicker(props: TimePickerProps): react_jsx_runtime.JSX.Element;
|
|
1640
1643
|
/**
|
|
1641
1644
|
* DateTimePicker — a day and a time as `YYYY-MM-DDTHH:MM` in the reader's own clock (the value of
|
|
@@ -1653,6 +1656,8 @@ type DateTimePickerProps = Pick<AriaAttributes, 'aria-describedby' | 'aria-inval
|
|
|
1653
1656
|
defaultTime?: string;
|
|
1654
1657
|
/** Minutes between the times in the list. Default 15. */
|
|
1655
1658
|
step?: number;
|
|
1659
|
+
/** `h23` (default) or `h12`, as on TimePicker. */
|
|
1660
|
+
hourCycle?: HourCycle;
|
|
1656
1661
|
clearable?: boolean;
|
|
1657
1662
|
disabled?: boolean;
|
|
1658
1663
|
required?: boolean;
|
|
@@ -1660,7 +1665,7 @@ type DateTimePickerProps = Pick<AriaAttributes, 'aria-describedby' | 'aria-inval
|
|
|
1660
1665
|
id?: string;
|
|
1661
1666
|
className?: string;
|
|
1662
1667
|
};
|
|
1663
|
-
declare function DateTimePicker({ value, onChange, min, max, defaultTime, step, clearable, disabled, required, ariaLabel, id, className, ...aria }: DateTimePickerProps): react_jsx_runtime.JSX.Element;
|
|
1668
|
+
declare function DateTimePicker({ value, onChange, min, max, defaultTime, step, hourCycle, clearable, disabled, required, ariaLabel, id, className, ...aria }: DateTimePickerProps): react_jsx_runtime.JSX.Element;
|
|
1664
1669
|
/** `HH:MM` from how people write a time: "9", "930", "0930", "9:30", "9.30", "9h30", "21 30", "9pm", "9:30 am". */
|
|
1665
1670
|
declare function parseTime(text: string): string | null;
|
|
1666
1671
|
|
|
@@ -2141,4 +2146,4 @@ declare function Sparkline({ values, color, width, height }: {
|
|
|
2141
2146
|
height?: number;
|
|
2142
2147
|
}): react_jsx_runtime.JSX.Element | null;
|
|
2143
2148
|
|
|
2144
|
-
export { APP_HUES, AppContent, type AppKey, AppShell, Button, type ButtonProps, type ButtonSize, type ButtonVariant, CHART_PALETTE, CboxAppCatalog, type CboxAppCatalogProps, CboxAppIcon, type CboxAppIconProps, type CboxAppKey, type CboxAppLink, CboxBrand, type CboxBrandProps, type CboxIdContextValue, CboxIdProvider, CboxKnownApp, CboxLocalizationProvider, type CboxNotificationPreviewItem, type CboxNotificationsState, type CboxOrganization, CboxServiceMark, type CboxServiceMarkProps, CboxShell, type CboxShellProps, CboxSurfaces, type CboxSurfacesProps, type CboxTranslationValues, type CboxTranslator, type CboxUser, Checkbox, type CheckboxProps, Combobox, type ComboboxAvatar, type ComboboxGroup, type ComboboxOption, type ComboboxProps, type ContextItem, type ContextLevel, type ContextTone, CreateField, CreateForm, CreateRefField, CreateSubmit, DataPanel, DatePicker, type DatePickerProps, DateTimePicker, type DateTimePickerProps, Dialog, DialogClose, type DialogProps, type DialogSize, EmptyState, Field, type FieldControlProps, type FieldProps, Heading, type HelpArticle, type HelpState, type HelpStore, type InboxState, type InferUrlState, Input, type InputProps, KeyValue, KeyValueList, type ListPage, type NavArea, type NavPage, PageHeader, type PageIntent, PageShell, type PageTabSpec, PageTabs, type PageTabsProps, type PageWidth, type PaletteAction, type PaletteRecord, PanelBody, RadioGroup, type RadioGroupProps, type RadioOption, type RealtimeState, type RealtimeStatus, RowLink, type RowLinkProps, SHELL_ICONS, SectionHeader, Sheet, SheetClose, type SheetProps, type SheetSize, type Shell, type ShellAccount, type Link as ShellActionLink, type ShellApp, type ShellBanner, type ShellCatalogState, type ShellCreatable, type ShellCreate, type ShellCreateForm, type ShellCreated, type ShellHelp, type ShellHelpArticle, type ShellIcon, type ShellLinkComponent, type ShellNavigate, type ShellNotifications, type ShellOption, type ShellPreferenceChange, type ShellPreferences, type ShellRecordSearch, type ShellRenderCreate, type ShellTheme, Slider, type SliderProps, Sparkline, Spinner, type SpinnerProps, StatTile, StatusPill, type SupportUpdate, type SurfaceArgs, type SurfaceConfig, type SurfaceController, type SurfaceId, Switch, type SwitchBody, type SwitchProps, TagInput, type TagInputProps, Textarea, type TextareaProps, TimePicker, type TimePickerProps, type Transport, type UrlField, type UrlSchema, applyTheme, buildUrlSearch, buttonClassName, cn, contextTrail, createHelpStore, defineUrlSchema, environmentFor, groupItems, hueFor, initialsOf, interpolate, isLive, pageIntent, parseListPage, parseShellCatalog, parseTime, parseUrlSearch, quickEnvironments, settingsHref, switchBody, switchPayload, themeBootScript, urlBoolean, urlEnum, urlNumber, urlString, urlStringArray, useCboxId, useCboxIdOptional, useCboxLocalization, useCboxSurfaces, useCboxSurfacesOptional, useDialogClose, useFieldControl, useKnownAppCatalog, useSheetClose, useShellCreate, useShellHelp, useShellPageTitle, withQuery };
|
|
2149
|
+
export { APP_HUES, AppContent, type AppKey, AppShell, Button, type ButtonProps, type ButtonSize, type ButtonVariant, CHART_PALETTE, CboxAppCatalog, type CboxAppCatalogProps, CboxAppIcon, type CboxAppIconProps, type CboxAppKey, type CboxAppLink, CboxBrand, type CboxBrandProps, type CboxIdContextValue, CboxIdProvider, CboxKnownApp, CboxLocalizationProvider, type CboxNotificationPreviewItem, type CboxNotificationsState, type CboxOrganization, CboxServiceMark, type CboxServiceMarkProps, CboxShell, type CboxShellProps, CboxSurfaces, type CboxSurfacesProps, type CboxTranslationValues, type CboxTranslator, type CboxUser, Checkbox, type CheckboxProps, Combobox, type ComboboxAvatar, type ComboboxGroup, type ComboboxOption, type ComboboxProps, type ContextItem, type ContextLevel, type ContextTone, CreateField, CreateForm, CreateRefField, CreateSubmit, DataPanel, DatePicker, type DatePickerProps, DateTimePicker, type DateTimePickerProps, Dialog, DialogClose, type DialogProps, type DialogSize, EmptyState, Field, type FieldControlProps, type FieldProps, Heading, type HelpArticle, type HelpState, type HelpStore, type HourCycle, type InboxState, type InferUrlState, Input, type InputProps, KeyValue, KeyValueList, type ListPage, type NavArea, type NavPage, PageHeader, type PageIntent, PageShell, type PageTabSpec, PageTabs, type PageTabsProps, type PageWidth, type PaletteAction, type PaletteRecord, PanelBody, RadioGroup, type RadioGroupProps, type RadioOption, type RealtimeState, type RealtimeStatus, RowLink, type RowLinkProps, SHELL_ICONS, SectionHeader, Sheet, SheetClose, type SheetProps, type SheetSize, type Shell, type ShellAccount, type Link as ShellActionLink, type ShellApp, type ShellBanner, type ShellCatalogState, type ShellCreatable, type ShellCreate, type ShellCreateForm, type ShellCreated, type ShellHelp, type ShellHelpArticle, type ShellIcon, type ShellLinkComponent, type ShellNavigate, type ShellNotifications, type ShellOption, type ShellPreferenceChange, type ShellPreferences, type ShellRecordSearch, type ShellRenderCreate, type ShellTheme, Slider, type SliderProps, Sparkline, Spinner, type SpinnerProps, StatTile, StatusPill, type SupportUpdate, type SurfaceArgs, type SurfaceConfig, type SurfaceController, type SurfaceId, Switch, type SwitchBody, type SwitchProps, TagInput, type TagInputProps, Textarea, type TextareaProps, TimePicker, type TimePickerProps, type Transport, type UrlField, type UrlSchema, applyTheme, buildUrlSearch, buttonClassName, cn, contextTrail, createHelpStore, defineUrlSchema, environmentFor, groupItems, hueFor, initialsOf, interpolate, isLive, pageIntent, parseListPage, parseShellCatalog, parseTime, parseUrlSearch, quickEnvironments, settingsHref, switchBody, switchPayload, themeBootScript, urlBoolean, urlEnum, urlNumber, urlString, urlStringArray, useCboxId, useCboxIdOptional, useCboxLocalization, useCboxSurfaces, useCboxSurfacesOptional, useDialogClose, useFieldControl, useKnownAppCatalog, useSheetClose, useShellCreate, useShellHelp, useShellPageTitle, withQuery };
|
package/dist/index.js
CHANGED
|
@@ -6221,6 +6221,7 @@ function TimePicker(props) {
|
|
|
6221
6221
|
value,
|
|
6222
6222
|
onChange,
|
|
6223
6223
|
step = 15,
|
|
6224
|
+
hourCycle = "h23",
|
|
6224
6225
|
min,
|
|
6225
6226
|
max,
|
|
6226
6227
|
placeholder = t("Pick a time"),
|
|
@@ -6235,7 +6236,7 @@ function TimePicker(props) {
|
|
|
6235
6236
|
const id = props.id ?? field.id ?? reactId;
|
|
6236
6237
|
const listId = `${id}-times`;
|
|
6237
6238
|
const picked = parseTime(value ?? "");
|
|
6238
|
-
const format = useMemo(() => timeFormat(locale), [locale]);
|
|
6239
|
+
const format = useMemo(() => timeFormat(locale, hourCycle), [locale, hourCycle]);
|
|
6239
6240
|
const [open, setOpen] = useState(false);
|
|
6240
6241
|
const [query2, setQuery] = useState("");
|
|
6241
6242
|
const [highlight, setHighlight] = useState(-1);
|
|
@@ -6405,7 +6406,7 @@ function TimePicker(props) {
|
|
|
6405
6406
|
}
|
|
6406
6407
|
);
|
|
6407
6408
|
}
|
|
6408
|
-
function DateTimePicker({ value, onChange, min, max, defaultTime = "09:00", step, clearable = true, disabled, required, ariaLabel, id, className, ...aria }) {
|
|
6409
|
+
function DateTimePicker({ value, onChange, min, max, defaultTime = "09:00", step, hourCycle, clearable = true, disabled, required, ariaLabel, id, className, ...aria }) {
|
|
6409
6410
|
const { t } = useCboxLocalization();
|
|
6410
6411
|
const [day, time] = splitMoment(value);
|
|
6411
6412
|
const minDay = min?.slice(0, 10);
|
|
@@ -6435,6 +6436,7 @@ function DateTimePicker({ value, onChange, min, max, defaultTime = "09:00", step
|
|
|
6435
6436
|
...minTime !== void 0 ? { min: minTime } : {},
|
|
6436
6437
|
...maxTime !== void 0 ? { max: maxTime } : {},
|
|
6437
6438
|
...step !== void 0 ? { step } : {},
|
|
6439
|
+
...hourCycle !== void 0 ? { hourCycle } : {},
|
|
6438
6440
|
value: time,
|
|
6439
6441
|
ariaLabel: t("Time"),
|
|
6440
6442
|
clearable: false,
|
|
@@ -6471,11 +6473,12 @@ function today2() {
|
|
|
6471
6473
|
const now = /* @__PURE__ */ new Date();
|
|
6472
6474
|
return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
|
|
6473
6475
|
}
|
|
6474
|
-
function timeFormat(locale) {
|
|
6476
|
+
function timeFormat(locale, hourCycle) {
|
|
6477
|
+
const options = hourCycle === "h23" ? { hour: "2-digit", minute: "2-digit", hourCycle, timeZone: "UTC" } : { hour: "numeric", minute: "2-digit", hourCycle, timeZone: "UTC" };
|
|
6475
6478
|
try {
|
|
6476
|
-
return new Intl.DateTimeFormat(locale.replace("_", "-") || void 0,
|
|
6479
|
+
return new Intl.DateTimeFormat(locale.replace("_", "-") || void 0, options);
|
|
6477
6480
|
} catch {
|
|
6478
|
-
return new Intl.DateTimeFormat(void 0,
|
|
6481
|
+
return new Intl.DateTimeFormat(void 0, options);
|
|
6479
6482
|
}
|
|
6480
6483
|
}
|
|
6481
6484
|
function centerInList(id) {
|