@cboxdk/cbox-ui 0.15.4 → 0.15.6
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 +2 -2
- package/dist/index.js +77 -85
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ReactNode, ComponentType, FormEvent, AnchorHTMLAttributes, ComponentProps, ButtonHTMLAttributes, InputHTMLAttributes, TextareaHTMLAttributes } from 'react';
|
|
3
|
+
import { ReactNode, ComponentType, FormEvent, AnchorHTMLAttributes, ComponentProps, AriaAttributes, ButtonHTMLAttributes, InputHTMLAttributes, TextareaHTMLAttributes } from 'react';
|
|
4
4
|
import { C as CboxThemeMode, a as CboxKnownApp } from './catalog-BroZWvws.js';
|
|
5
5
|
export { b as CboxAppCatalogState, c as CboxCatalogApp, d as authorizeHref, p as parseAppCatalog, r as readKnownAppCatalog, e as rememberAppCatalog, s as secureIconUrl, f as signInTarget } from './catalog-BroZWvws.js';
|
|
6
6
|
import { LucideIcon } from 'lucide-react';
|
|
@@ -1119,7 +1119,7 @@ type LinkComp = ComponentType<{
|
|
|
1119
1119
|
className?: string;
|
|
1120
1120
|
children: ReactNode;
|
|
1121
1121
|
}>;
|
|
1122
|
-
type CommonProps = {
|
|
1122
|
+
type CommonProps = Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid'> & {
|
|
1123
1123
|
/** Options or grouped options. Pass an array of either shape. */
|
|
1124
1124
|
items: ComboboxOption[] | ComboboxGroup[];
|
|
1125
1125
|
/** Placeholder shown in the trigger when no value is selected. */
|
package/dist/index.js
CHANGED
|
@@ -4624,50 +4624,33 @@ function CboxShell({ shell, children, navigate = defaultNavigate, LinkComponent
|
|
|
4624
4624
|
overlay === "apps-sheet" && /* @__PURE__ */ jsx(AppsSheet, { onClose: () => setOverlay("more") }),
|
|
4625
4625
|
overlay === "create" && /* @__PURE__ */ jsx(CreateSheet, { onClose: () => setOverlay(null) }, createKey ?? "tree")
|
|
4626
4626
|
] });
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
return /* @__PURE__ */ jsx(ShellContext.Provider, { value: api, children: /* @__PURE__ */ jsxs("div", { className: "cbx-shell is-mobile", "data-help-open": helpOpen, children: [
|
|
4630
|
-
skip,
|
|
4631
|
-
/* @__PURE__ */ jsxs("div", { className: "cbx-shell-column", children: [
|
|
4632
|
-
/* @__PURE__ */ jsxs("header", { className: "cbx-m-chrome", hidden: moreOpen, children: [
|
|
4633
|
-
/* @__PURE__ */ jsx(MobileTopBar, {}),
|
|
4634
|
-
/* @__PURE__ */ jsx(MobileAreaHead, {}),
|
|
4635
|
-
strips
|
|
4636
|
-
] }),
|
|
4637
|
-
/* @__PURE__ */ jsxs("main", { id: mainId, tabIndex: -1, className: "cbx-shell-main canvas-gradient", children: [
|
|
4638
|
-
moreOpen && /* @__PURE__ */ jsx(MoreScreen, { view: moreView, setView: setMoreView }),
|
|
4639
|
-
/* @__PURE__ */ jsx(MobilePage, { hidden: moreOpen, children })
|
|
4640
|
-
] })
|
|
4641
|
-
] }),
|
|
4642
|
-
/* @__PURE__ */ jsx(
|
|
4643
|
-
TabBar,
|
|
4644
|
-
{
|
|
4645
|
-
onMore: () => {
|
|
4646
|
-
setMoreView({ kind: "root" });
|
|
4647
|
-
setOverlay("more");
|
|
4648
|
-
}
|
|
4649
|
-
}
|
|
4650
|
-
),
|
|
4651
|
-
/* @__PURE__ */ jsx(HelpColumn, { docked: false, mobile: true }),
|
|
4652
|
-
overlays
|
|
4653
|
-
] }) });
|
|
4654
|
-
}
|
|
4655
|
-
return /* @__PURE__ */ jsx(ShellContext.Provider, { value: api, children: /* @__PURE__ */ jsxs("div", { className: "cbx-shell", "data-help-open": helpOpen, children: [
|
|
4627
|
+
const moreOpen = mobile && (overlay === "more" || overlay === "apps-sheet" || overlay === "context-sheet" && contextStep.underMore === true);
|
|
4628
|
+
return /* @__PURE__ */ jsx(ShellContext.Provider, { value: api, children: /* @__PURE__ */ jsxs("div", { className: `cbx-shell${mobile ? " is-mobile" : ""}`, "data-help-open": helpOpen, children: [
|
|
4656
4629
|
skip,
|
|
4657
|
-
/* @__PURE__ */ jsx(Rail, { brandAssetBase }),
|
|
4630
|
+
!mobile && /* @__PURE__ */ jsx(Rail, { brandAssetBase }),
|
|
4658
4631
|
/* @__PURE__ */ jsxs("div", { className: "cbx-shell-column", children: [
|
|
4659
|
-
/* @__PURE__ */
|
|
4632
|
+
mobile ? /* @__PURE__ */ jsxs("header", { className: "cbx-m-chrome", hidden: moreOpen, children: [
|
|
4633
|
+
/* @__PURE__ */ jsx(MobileTopBar, {}),
|
|
4634
|
+
/* @__PURE__ */ jsx(MobileAreaHead, {})
|
|
4635
|
+
] }) : /* @__PURE__ */ jsx(Header, {}),
|
|
4660
4636
|
envBanner !== null && /* @__PURE__ */ jsxs("div", { className: `cbx-banner cbx-banner-env cbx-env-${envBanner.tone ?? "neutral"}`, role: "status", children: [
|
|
4661
4637
|
/* @__PURE__ */ jsx(ToneSquare, { tone: envBanner.tone }),
|
|
4662
4638
|
/* @__PURE__ */ jsx("span", { className: "cbx-banner-text", children: t("{environment}. Not production, nothing here touches live customers.", { environment: envBanner.name }) })
|
|
4663
4639
|
] }),
|
|
4664
|
-
strips,
|
|
4640
|
+
/* @__PURE__ */ jsx("div", { hidden: moreOpen, children: strips }),
|
|
4665
4641
|
/* @__PURE__ */ jsxs("div", { className: "cbx-shell-body", children: [
|
|
4666
|
-
/* @__PURE__ */ jsx(Subnav, {}),
|
|
4667
|
-
/* @__PURE__ */
|
|
4642
|
+
!mobile && /* @__PURE__ */ jsx(Subnav, {}),
|
|
4643
|
+
/* @__PURE__ */ jsxs("main", { id: mainId, tabIndex: -1, className: "cbx-shell-main canvas-gradient", children: [
|
|
4644
|
+
moreOpen && /* @__PURE__ */ jsx(MoreScreen, { view: moreView, setView: setMoreView }),
|
|
4645
|
+
/* @__PURE__ */ jsx(MobilePage, { hidden: moreOpen, children })
|
|
4646
|
+
] })
|
|
4668
4647
|
] })
|
|
4669
4648
|
] }),
|
|
4670
|
-
/* @__PURE__ */ jsx(
|
|
4649
|
+
mobile && /* @__PURE__ */ jsx(TabBar, { onMore: () => {
|
|
4650
|
+
setMoreView({ kind: "root" });
|
|
4651
|
+
setOverlay("more");
|
|
4652
|
+
} }),
|
|
4653
|
+
/* @__PURE__ */ jsx(HelpColumn, { docked: !mobile && docked, mobile }),
|
|
4671
4654
|
overlays
|
|
4672
4655
|
] }) });
|
|
4673
4656
|
}
|
|
@@ -4937,8 +4920,52 @@ function CboxAppCatalog({ endpoint, currentAppKey, theme, className }) {
|
|
|
4937
4920
|
className
|
|
4938
4921
|
});
|
|
4939
4922
|
}
|
|
4923
|
+
var FieldContext = createContext(null);
|
|
4924
|
+
function useFieldControl() {
|
|
4925
|
+
const field = useContext(FieldContext);
|
|
4926
|
+
if (field === null) return {};
|
|
4927
|
+
return {
|
|
4928
|
+
id: field.controlId,
|
|
4929
|
+
...field.describedBy !== void 0 ? { "aria-describedby": field.describedBy } : {},
|
|
4930
|
+
...field.invalid ? { "aria-invalid": true } : {},
|
|
4931
|
+
...field.required ? { required: true } : {}
|
|
4932
|
+
};
|
|
4933
|
+
}
|
|
4934
|
+
function Field({ label, id: statedId, labelAction, hint, error, required = false, optional = false, className, children }) {
|
|
4935
|
+
const { t } = useCboxLocalization();
|
|
4936
|
+
const generated = useId();
|
|
4937
|
+
const base = statedId ?? generated;
|
|
4938
|
+
const controlId = statedId ?? `${generated}-control`;
|
|
4939
|
+
const hintId = `${base}-hint`;
|
|
4940
|
+
const errorId = `${base}-error`;
|
|
4941
|
+
const hasError = error !== void 0 && error !== null && error !== "";
|
|
4942
|
+
const describedBy = [hint !== void 0 ? hintId : null, hasError ? errorId : null].filter(Boolean).join(" ") || void 0;
|
|
4943
|
+
const context = useMemo(() => ({ controlId, describedBy, invalid: hasError, required }), [controlId, describedBy, hasError, required]);
|
|
4944
|
+
const labelElement = /* @__PURE__ */ jsxs("label", { className: "cbx-ui-label", htmlFor: controlId, children: [
|
|
4945
|
+
label,
|
|
4946
|
+
required && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4947
|
+
" ",
|
|
4948
|
+
/* @__PURE__ */ jsx("span", { className: "cbx-ui-label-required", "aria-hidden": "true", children: "*" }),
|
|
4949
|
+
/* @__PURE__ */ jsx("span", { className: "cbx-ui-sr-only", children: t("(required)") })
|
|
4950
|
+
] }),
|
|
4951
|
+
optional && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4952
|
+
" ",
|
|
4953
|
+
/* @__PURE__ */ jsx("span", { className: "cbx-ui-label-optional", children: t("(optional)") })
|
|
4954
|
+
] })
|
|
4955
|
+
] });
|
|
4956
|
+
return /* @__PURE__ */ jsx(FieldContext.Provider, { value: context, children: /* @__PURE__ */ jsxs("div", { className: cn("cbx-ui-field", className), children: [
|
|
4957
|
+
labelAction !== void 0 ? /* @__PURE__ */ jsxs("div", { className: "cbx-ui-field-head", children: [
|
|
4958
|
+
labelElement,
|
|
4959
|
+
labelAction
|
|
4960
|
+
] }) : labelElement,
|
|
4961
|
+
children,
|
|
4962
|
+
hint !== void 0 && /* @__PURE__ */ jsx("p", { id: hintId, className: "cbx-ui-hint", children: hint }),
|
|
4963
|
+
/* @__PURE__ */ jsx("p", { id: errorId, className: "cbx-ui-error", role: "alert", hidden: !hasError, children: hasError ? error : null })
|
|
4964
|
+
] }) });
|
|
4965
|
+
}
|
|
4940
4966
|
function Combobox(props) {
|
|
4941
4967
|
const { t } = useCboxLocalization();
|
|
4968
|
+
const field = useFieldControl();
|
|
4942
4969
|
const {
|
|
4943
4970
|
items,
|
|
4944
4971
|
placeholder = t("Select\u2026"),
|
|
@@ -4946,7 +4973,7 @@ function Combobox(props) {
|
|
|
4946
4973
|
emptyText = t("Nothing matches."),
|
|
4947
4974
|
footerLink,
|
|
4948
4975
|
disabled = false,
|
|
4949
|
-
required = false,
|
|
4976
|
+
required = field.required ?? false,
|
|
4950
4977
|
ariaLabel,
|
|
4951
4978
|
triggerClassName,
|
|
4952
4979
|
panelClassName,
|
|
@@ -4969,10 +4996,11 @@ function Combobox(props) {
|
|
|
4969
4996
|
const [query2, setQuery] = useState("");
|
|
4970
4997
|
const [highlightIndex, setHighlightIndex] = useState(-1);
|
|
4971
4998
|
const containerRef = useRef(null);
|
|
4999
|
+
const triggerRef = useRef(null);
|
|
4972
5000
|
const inputRef = useRef(null);
|
|
4973
5001
|
const listRef = useRef(null);
|
|
4974
5002
|
const reactId = useId();
|
|
4975
|
-
const id = idProp ?? reactId;
|
|
5003
|
+
const id = idProp ?? field.id ?? reactId;
|
|
4976
5004
|
const listId = `${id}-listbox`;
|
|
4977
5005
|
const filteredGroups = useMemo(
|
|
4978
5006
|
() => filterGroups(groups, query2),
|
|
@@ -5015,6 +5043,7 @@ function Combobox(props) {
|
|
|
5015
5043
|
return;
|
|
5016
5044
|
}
|
|
5017
5045
|
if (props.onChange !== void 0) {
|
|
5046
|
+
triggerRef.current?.focus();
|
|
5018
5047
|
props.onChange(opt.value);
|
|
5019
5048
|
}
|
|
5020
5049
|
setOpen(false);
|
|
@@ -5066,11 +5095,6 @@ function Combobox(props) {
|
|
|
5066
5095
|
}
|
|
5067
5096
|
return;
|
|
5068
5097
|
}
|
|
5069
|
-
if (event.key === "Escape") {
|
|
5070
|
-
event.preventDefault();
|
|
5071
|
-
setOpen(false);
|
|
5072
|
-
return;
|
|
5073
|
-
}
|
|
5074
5098
|
if (event.key === "Tab") {
|
|
5075
5099
|
setOpen(false);
|
|
5076
5100
|
return;
|
|
@@ -5083,10 +5107,19 @@ function Combobox(props) {
|
|
|
5083
5107
|
{
|
|
5084
5108
|
ref: containerRef,
|
|
5085
5109
|
className: cn("relative", triggerWidth === "full" && "w-full", className),
|
|
5110
|
+
onKeyDown: (event) => {
|
|
5111
|
+
if (open && event.key === "Escape") {
|
|
5112
|
+
event.preventDefault();
|
|
5113
|
+
event.stopPropagation();
|
|
5114
|
+
setOpen(false);
|
|
5115
|
+
triggerRef.current?.focus();
|
|
5116
|
+
}
|
|
5117
|
+
},
|
|
5086
5118
|
children: [
|
|
5087
5119
|
/* @__PURE__ */ jsxs(
|
|
5088
5120
|
"button",
|
|
5089
5121
|
{
|
|
5122
|
+
ref: triggerRef,
|
|
5090
5123
|
id,
|
|
5091
5124
|
type: "button",
|
|
5092
5125
|
role: "combobox",
|
|
@@ -5096,6 +5129,8 @@ function Combobox(props) {
|
|
|
5096
5129
|
"aria-controls": listId,
|
|
5097
5130
|
"aria-required": required,
|
|
5098
5131
|
"aria-label": ariaLabel,
|
|
5132
|
+
"aria-describedby": props["aria-describedby"] ?? field["aria-describedby"],
|
|
5133
|
+
"aria-invalid": props["aria-invalid"] ?? field["aria-invalid"],
|
|
5099
5134
|
onClick: () => setOpen((v) => !v),
|
|
5100
5135
|
className: cn(
|
|
5101
5136
|
"flex h-9 items-center gap-2 rounded-md border border-input bg-card px-3 text-left text-[13px] text-foreground transition-colors",
|
|
@@ -5844,49 +5879,6 @@ function Checkbox({ checked, onCheckedChange, label, hint, disabled = false, req
|
|
|
5844
5879
|
] })
|
|
5845
5880
|
] });
|
|
5846
5881
|
}
|
|
5847
|
-
var FieldContext = createContext(null);
|
|
5848
|
-
function useFieldControl() {
|
|
5849
|
-
const field = useContext(FieldContext);
|
|
5850
|
-
if (field === null) return {};
|
|
5851
|
-
return {
|
|
5852
|
-
id: field.controlId,
|
|
5853
|
-
...field.describedBy !== void 0 ? { "aria-describedby": field.describedBy } : {},
|
|
5854
|
-
...field.invalid ? { "aria-invalid": true } : {},
|
|
5855
|
-
...field.required ? { required: true } : {}
|
|
5856
|
-
};
|
|
5857
|
-
}
|
|
5858
|
-
function Field({ label, id: statedId, labelAction, hint, error, required = false, optional = false, className, children }) {
|
|
5859
|
-
const { t } = useCboxLocalization();
|
|
5860
|
-
const generated = useId();
|
|
5861
|
-
const base = statedId ?? generated;
|
|
5862
|
-
const controlId = statedId ?? `${generated}-control`;
|
|
5863
|
-
const hintId = `${base}-hint`;
|
|
5864
|
-
const errorId = `${base}-error`;
|
|
5865
|
-
const hasError = error !== void 0 && error !== null && error !== "";
|
|
5866
|
-
const describedBy = [hint !== void 0 ? hintId : null, hasError ? errorId : null].filter(Boolean).join(" ") || void 0;
|
|
5867
|
-
const context = useMemo(() => ({ controlId, describedBy, invalid: hasError, required }), [controlId, describedBy, hasError, required]);
|
|
5868
|
-
const labelElement = /* @__PURE__ */ jsxs("label", { className: "cbx-ui-label", htmlFor: controlId, children: [
|
|
5869
|
-
label,
|
|
5870
|
-
required && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5871
|
-
" ",
|
|
5872
|
-
/* @__PURE__ */ jsx("span", { className: "cbx-ui-label-required", "aria-hidden": "true", children: "*" }),
|
|
5873
|
-
/* @__PURE__ */ jsx("span", { className: "cbx-ui-sr-only", children: t("(required)") })
|
|
5874
|
-
] }),
|
|
5875
|
-
optional && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5876
|
-
" ",
|
|
5877
|
-
/* @__PURE__ */ jsx("span", { className: "cbx-ui-label-optional", children: t("(optional)") })
|
|
5878
|
-
] })
|
|
5879
|
-
] });
|
|
5880
|
-
return /* @__PURE__ */ jsx(FieldContext.Provider, { value: context, children: /* @__PURE__ */ jsxs("div", { className: cn("cbx-ui-field", className), children: [
|
|
5881
|
-
labelAction !== void 0 ? /* @__PURE__ */ jsxs("div", { className: "cbx-ui-field-head", children: [
|
|
5882
|
-
labelElement,
|
|
5883
|
-
labelAction
|
|
5884
|
-
] }) : labelElement,
|
|
5885
|
-
children,
|
|
5886
|
-
hint !== void 0 && /* @__PURE__ */ jsx("p", { id: hintId, className: "cbx-ui-hint", children: hint }),
|
|
5887
|
-
/* @__PURE__ */ jsx("p", { id: errorId, className: "cbx-ui-error", role: "alert", hidden: !hasError, children: hasError ? error : null })
|
|
5888
|
-
] }) });
|
|
5889
|
-
}
|
|
5890
5882
|
var Input = forwardRef(function Input2({ scale = "md", className, ...props }, ref) {
|
|
5891
5883
|
const field = useFieldControl();
|
|
5892
5884
|
return /* @__PURE__ */ jsx("input", { ref, className: cn("cbx-ui-input", scale === "lg" && "cbx-ui-input--lg", className), ...field, ...props });
|