@cimpress-ui/react 1.25.2 → 1.27.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/dist/commonjs/components/app-header/app-header.d.ts +1 -1
- package/dist/commonjs/components/app-header/app-header.d.ts.map +1 -1
- package/dist/commonjs/components/app-header/app-header.js +5 -1
- package/dist/commonjs/components/app-header/app-header.js.map +1 -1
- package/dist/commonjs/components/app-header/nav-button.d.ts +2 -2
- package/dist/commonjs/components/app-header/nav-button.d.ts.map +1 -1
- package/dist/commonjs/components/app-header/nav-button.js +8 -1
- package/dist/commonjs/components/app-header/nav-button.js.map +1 -1
- package/dist/commonjs/components/app-shell/app-shell-context.d.ts +2 -0
- package/dist/commonjs/components/app-shell/app-shell-context.d.ts.map +1 -0
- package/dist/commonjs/components/app-shell/app-shell-context.js +7 -0
- package/dist/commonjs/components/app-shell/app-shell-context.js.map +1 -0
- package/dist/commonjs/components/app-shell/app-shell.d.ts +1 -1
- package/dist/commonjs/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/commonjs/components/app-shell/app-shell.js +12 -2
- package/dist/commonjs/components/app-shell/app-shell.js.map +1 -1
- package/dist/commonjs/components/combo-box/combo-box.d.ts +28 -7
- package/dist/commonjs/components/combo-box/combo-box.d.ts.map +1 -1
- package/dist/commonjs/components/combo-box/combo-box.js +9 -7
- package/dist/commonjs/components/combo-box/combo-box.js.map +1 -1
- package/dist/commonjs/components/internal/input/input.d.ts +0 -6
- package/dist/commonjs/components/internal/input/input.d.ts.map +1 -1
- package/dist/commonjs/components/internal/input/input.js +6 -22
- package/dist/commonjs/components/internal/input/input.js.map +1 -1
- package/dist/commonjs/components/select/select.d.ts +42 -31
- package/dist/commonjs/components/select/select.d.ts.map +1 -1
- package/dist/commonjs/components/select/select.js +38 -41
- package/dist/commonjs/components/select/select.js.map +1 -1
- package/dist/commonjs/components/{app-header → side-nav}/side-nav.d.ts +12 -1
- package/dist/commonjs/components/side-nav/side-nav.d.ts.map +1 -0
- package/dist/commonjs/components/side-nav/side-nav.js +56 -0
- package/dist/commonjs/components/side-nav/side-nav.js.map +1 -0
- package/dist/commonjs/components/slider/slider.d.ts.map +1 -1
- package/dist/commonjs/components/slider/slider.js +6 -2
- package/dist/commonjs/components/slider/slider.js.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field.d.ts +11 -2
- package/dist/commonjs/components/tag-field/tag-field.d.ts.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field.js +11 -2
- package/dist/commonjs/components/tag-field/tag-field.js.map +1 -1
- package/dist/commonjs/i18n/messages/en-US.d.ts.map +1 -1
- package/dist/commonjs/i18n/messages/en-US.js +7 -0
- package/dist/commonjs/i18n/messages/en-US.js.map +1 -1
- package/dist/commonjs/i18n/messages/types.d.ts +12 -0
- package/dist/commonjs/i18n/messages/types.d.ts.map +1 -1
- package/dist/commonjs/i18n/messages/types.js.map +1 -1
- package/dist/commonjs/icons/case-lower.d.ts +8 -0
- package/dist/commonjs/icons/case-lower.d.ts.map +1 -0
- package/dist/commonjs/icons/case-lower.js +24 -0
- package/dist/commonjs/icons/case-lower.js.map +1 -0
- package/dist/commonjs/icons/case-normal.d.ts +8 -0
- package/dist/commonjs/icons/case-normal.d.ts.map +1 -0
- package/dist/commonjs/icons/case-normal.js +24 -0
- package/dist/commonjs/icons/case-normal.js.map +1 -0
- package/dist/commonjs/icons/case-upper.d.ts +8 -0
- package/dist/commonjs/icons/case-upper.d.ts.map +1 -0
- package/dist/commonjs/icons/case-upper.js +24 -0
- package/dist/commonjs/icons/case-upper.js.map +1 -0
- package/dist/commonjs/icons/chevron-double-down.d.ts +8 -0
- package/dist/commonjs/icons/chevron-double-down.d.ts.map +1 -0
- package/dist/commonjs/icons/chevron-double-down.js +24 -0
- package/dist/commonjs/icons/chevron-double-down.js.map +1 -0
- package/dist/commonjs/icons/chevron-double-left.d.ts +8 -0
- package/dist/commonjs/icons/chevron-double-left.d.ts.map +1 -0
- package/dist/commonjs/icons/chevron-double-left.js +24 -0
- package/dist/commonjs/icons/chevron-double-left.js.map +1 -0
- package/dist/commonjs/icons/chevron-double-right.d.ts +8 -0
- package/dist/commonjs/icons/chevron-double-right.d.ts.map +1 -0
- package/dist/commonjs/icons/chevron-double-right.js +24 -0
- package/dist/commonjs/icons/chevron-double-right.js.map +1 -0
- package/dist/commonjs/icons/chevron-double-up.d.ts +8 -0
- package/dist/commonjs/icons/chevron-double-up.d.ts.map +1 -0
- package/dist/commonjs/icons/chevron-double-up.js +24 -0
- package/dist/commonjs/icons/chevron-double-up.js.map +1 -0
- package/dist/commonjs/icons/cut.d.ts +8 -0
- package/dist/commonjs/icons/cut.d.ts.map +1 -0
- package/dist/commonjs/icons/cut.js +24 -0
- package/dist/commonjs/icons/cut.js.map +1 -0
- package/dist/commonjs/icons/drag-handle.d.ts +8 -0
- package/dist/commonjs/icons/drag-handle.d.ts.map +1 -0
- package/dist/commonjs/icons/drag-handle.js +24 -0
- package/dist/commonjs/icons/drag-handle.js.map +1 -0
- package/dist/commonjs/icons/file-text.d.ts +8 -0
- package/dist/commonjs/icons/file-text.d.ts.map +1 -0
- package/dist/commonjs/icons/file-text.js +24 -0
- package/dist/commonjs/icons/file-text.js.map +1 -0
- package/dist/commonjs/icons/file.d.ts +8 -0
- package/dist/commonjs/icons/file.d.ts.map +1 -0
- package/dist/commonjs/icons/file.js +24 -0
- package/dist/commonjs/icons/file.js.map +1 -0
- package/dist/commonjs/icons/index.d.ts +11 -0
- package/dist/commonjs/icons/index.d.ts.map +1 -1
- package/dist/commonjs/icons/index.js +27 -5
- package/dist/commonjs/icons/index.js.map +1 -1
- package/dist/commonjs/index.d.ts +2 -2
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +2 -2
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/utils/breakpoints.d.ts +9 -0
- package/dist/commonjs/utils/breakpoints.d.ts.map +1 -0
- package/dist/commonjs/utils/breakpoints.js +39 -0
- package/dist/commonjs/utils/breakpoints.js.map +1 -0
- package/dist/commonjs/utils/use-is-mobile.js +2 -2
- package/dist/commonjs/utils/use-is-mobile.js.map +1 -1
- package/dist/commonjs/utils/use-media-query.d.ts +4 -1
- package/dist/commonjs/utils/use-media-query.d.ts.map +1 -1
- package/dist/commonjs/utils/use-media-query.js.map +1 -1
- package/dist/esm/components/app-header/app-header.d.ts +1 -1
- package/dist/esm/components/app-header/app-header.d.ts.map +1 -1
- package/dist/esm/components/app-header/app-header.js +5 -1
- package/dist/esm/components/app-header/app-header.js.map +1 -1
- package/dist/esm/components/app-header/nav-button.d.ts +2 -2
- package/dist/esm/components/app-header/nav-button.d.ts.map +1 -1
- package/dist/esm/components/app-header/nav-button.js +8 -1
- package/dist/esm/components/app-header/nav-button.js.map +1 -1
- package/dist/esm/components/app-shell/app-shell-context.d.ts +2 -0
- package/dist/esm/components/app-shell/app-shell-context.d.ts.map +1 -0
- package/dist/esm/components/app-shell/app-shell-context.js +4 -0
- package/dist/esm/components/app-shell/app-shell-context.js.map +1 -0
- package/dist/esm/components/app-shell/app-shell.d.ts +1 -1
- package/dist/esm/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/esm/components/app-shell/app-shell.js +12 -2
- package/dist/esm/components/app-shell/app-shell.js.map +1 -1
- package/dist/esm/components/combo-box/combo-box.d.ts +28 -7
- package/dist/esm/components/combo-box/combo-box.d.ts.map +1 -1
- package/dist/esm/components/combo-box/combo-box.js +9 -7
- package/dist/esm/components/combo-box/combo-box.js.map +1 -1
- package/dist/esm/components/internal/input/input.d.ts +0 -6
- package/dist/esm/components/internal/input/input.d.ts.map +1 -1
- package/dist/esm/components/internal/input/input.js +6 -22
- package/dist/esm/components/internal/input/input.js.map +1 -1
- package/dist/esm/components/select/select.d.ts +42 -31
- package/dist/esm/components/select/select.d.ts.map +1 -1
- package/dist/esm/components/select/select.js +40 -43
- package/dist/esm/components/select/select.js.map +1 -1
- package/dist/esm/components/{app-header → side-nav}/side-nav.d.ts +12 -1
- package/dist/esm/components/side-nav/side-nav.d.ts.map +1 -0
- package/dist/esm/components/side-nav/side-nav.js +50 -0
- package/dist/esm/components/side-nav/side-nav.js.map +1 -0
- package/dist/esm/components/slider/slider.d.ts.map +1 -1
- package/dist/esm/components/slider/slider.js +6 -2
- package/dist/esm/components/slider/slider.js.map +1 -1
- package/dist/esm/components/tag-field/tag-field.d.ts +11 -2
- package/dist/esm/components/tag-field/tag-field.d.ts.map +1 -1
- package/dist/esm/components/tag-field/tag-field.js +11 -2
- package/dist/esm/components/tag-field/tag-field.js.map +1 -1
- package/dist/esm/i18n/messages/en-US.d.ts.map +1 -1
- package/dist/esm/i18n/messages/en-US.js +7 -0
- package/dist/esm/i18n/messages/en-US.js.map +1 -1
- package/dist/esm/i18n/messages/types.d.ts +12 -0
- package/dist/esm/i18n/messages/types.d.ts.map +1 -1
- package/dist/esm/i18n/messages/types.js.map +1 -1
- package/dist/esm/icons/case-lower.d.ts +8 -0
- package/dist/esm/icons/case-lower.d.ts.map +1 -0
- package/dist/esm/icons/case-lower.js +19 -0
- package/dist/esm/icons/case-lower.js.map +1 -0
- package/dist/esm/icons/case-normal.d.ts +8 -0
- package/dist/esm/icons/case-normal.d.ts.map +1 -0
- package/dist/esm/icons/case-normal.js +19 -0
- package/dist/esm/icons/case-normal.js.map +1 -0
- package/dist/esm/icons/case-upper.d.ts +8 -0
- package/dist/esm/icons/case-upper.d.ts.map +1 -0
- package/dist/esm/icons/case-upper.js +19 -0
- package/dist/esm/icons/case-upper.js.map +1 -0
- package/dist/esm/icons/chevron-double-down.d.ts +8 -0
- package/dist/esm/icons/chevron-double-down.d.ts.map +1 -0
- package/dist/esm/icons/chevron-double-down.js +19 -0
- package/dist/esm/icons/chevron-double-down.js.map +1 -0
- package/dist/esm/icons/chevron-double-left.d.ts +8 -0
- package/dist/esm/icons/chevron-double-left.d.ts.map +1 -0
- package/dist/esm/icons/chevron-double-left.js +19 -0
- package/dist/esm/icons/chevron-double-left.js.map +1 -0
- package/dist/esm/icons/chevron-double-right.d.ts +8 -0
- package/dist/esm/icons/chevron-double-right.d.ts.map +1 -0
- package/dist/esm/icons/chevron-double-right.js +19 -0
- package/dist/esm/icons/chevron-double-right.js.map +1 -0
- package/dist/esm/icons/chevron-double-up.d.ts +8 -0
- package/dist/esm/icons/chevron-double-up.d.ts.map +1 -0
- package/dist/esm/icons/chevron-double-up.js +19 -0
- package/dist/esm/icons/chevron-double-up.js.map +1 -0
- package/dist/esm/icons/cut.d.ts +8 -0
- package/dist/esm/icons/cut.d.ts.map +1 -0
- package/dist/esm/icons/cut.js +19 -0
- package/dist/esm/icons/cut.js.map +1 -0
- package/dist/esm/icons/drag-handle.d.ts +8 -0
- package/dist/esm/icons/drag-handle.d.ts.map +1 -0
- package/dist/esm/icons/drag-handle.js +19 -0
- package/dist/esm/icons/drag-handle.js.map +1 -0
- package/dist/esm/icons/file-text.d.ts +8 -0
- package/dist/esm/icons/file-text.d.ts.map +1 -0
- package/dist/esm/icons/file-text.js +19 -0
- package/dist/esm/icons/file-text.js.map +1 -0
- package/dist/esm/icons/file.d.ts +8 -0
- package/dist/esm/icons/file.d.ts.map +1 -0
- package/dist/esm/icons/file.js +19 -0
- package/dist/esm/icons/file.js.map +1 -0
- package/dist/esm/icons/index.d.ts +11 -0
- package/dist/esm/icons/index.d.ts.map +1 -1
- package/dist/esm/icons/index.js +11 -0
- package/dist/esm/icons/index.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/breakpoints.d.ts +9 -0
- package/dist/esm/utils/breakpoints.d.ts.map +1 -0
- package/dist/esm/utils/breakpoints.js +35 -0
- package/dist/esm/utils/breakpoints.js.map +1 -0
- package/dist/esm/utils/use-is-mobile.js +2 -2
- package/dist/esm/utils/use-is-mobile.js.map +1 -1
- package/dist/esm/utils/use-media-query.d.ts +4 -1
- package/dist/esm/utils/use-media-query.d.ts.map +1 -1
- package/dist/esm/utils/use-media-query.js.map +1 -1
- package/dist-styles/core.css +1 -1
- package/dist-styles/styles.css +1 -1
- package/package.json +1 -1
- package/dist/commonjs/components/app-header/side-nav.d.ts.map +0 -1
- package/dist/commonjs/components/app-header/side-nav.js +0 -36
- package/dist/commonjs/components/app-header/side-nav.js.map +0 -1
- package/dist/esm/components/app-header/side-nav.d.ts.map +0 -1
- package/dist/esm/components/app-header/side-nav.js +0 -30
- package/dist/esm/components/app-header/side-nav.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-header.d.ts","sourceRoot":"","sources":["../../../../src/components/app-header/app-header.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"app-header.d.ts","sourceRoot":"","sources":["../../../../src/components/app-header/app-header.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAiC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAQtE,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAMpF,MAAM,WAAW,uBAAwB,SAAQ,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC;CAAG;AAEzF,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,sGAAsG;IACtG,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,SAAS,EAAE,IAAI,GAAG,uBAAuB,CAAC;IAC1C,oDAAoD;IACpD,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAC/B,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAC/B,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B;AAiED;;;;GAIG;AACH,QAAA,MAAM,UAAU,+GAAqC,CAAC;AAEtD,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,CAAC"}
|
|
@@ -7,19 +7,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.AppHeader = void 0;
|
|
8
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
9
|
const clsx_1 = __importDefault(require("clsx"));
|
|
10
|
+
const react_1 = require("react");
|
|
10
11
|
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
11
12
|
const index_js_1 = require("../../icons/index.js");
|
|
12
13
|
const use_is_mobile_js_1 = require("../../utils/use-is-mobile.js");
|
|
14
|
+
const app_shell_context_js_1 = require("../app-shell/app-shell-context.js");
|
|
13
15
|
const icon_button_js_1 = require("../button/icon-button.js");
|
|
14
16
|
const divider_js_1 = require("../divider/divider.js");
|
|
15
17
|
const popover_js_1 = require("../popover/popover.js");
|
|
16
18
|
const link_js_1 = require("../typography/link.js");
|
|
17
19
|
const text_js_1 = require("../typography/text.js");
|
|
18
20
|
const cimpress_logo_js_1 = require("./cimpress-logo.js");
|
|
21
|
+
const nav_button_js_1 = require("./nav-button.js");
|
|
19
22
|
function AppHeader({ title, titleLink, tools, UNSTABLE_navButton: navButton, UNSTABLE_postTitle: postTitle, UNSTABLE_search: search, UNSAFE_className, UNSAFE_style, ...props }, ref) {
|
|
20
23
|
const isMobile = (0, use_is_mobile_js_1.useIsMobile)();
|
|
24
|
+
const appShellContext = (0, react_1.useContext)(app_shell_context_js_1.AppShellContext);
|
|
21
25
|
const titleLinkProps = typeof titleLink === 'object' && 'href' in titleLink ? titleLink : { href: titleLink };
|
|
22
|
-
return ((0, jsx_runtime_1.jsxs)("header", { ...props, ref: ref, className: (0, clsx_1.default)('cim-app-header', UNSAFE_className), style: UNSAFE_style, children: [(0, jsx_runtime_1.jsxs)("div", { className: "cim-app-header-title", children: [navButton, (0, jsx_runtime_1.jsx)(cimpress_logo_js_1.CimpressLogo, { height: 24 }), (0, jsx_runtime_1.jsx)(divider_js_1.Divider, { orientation: "vertical" }), (0, jsx_runtime_1.jsx)(text_js_1.Text, { as: "h1", variant: "title-5", tone: "base", children: (0, jsx_runtime_1.jsx)(link_js_1.Link, { ...titleLinkProps, UNSAFE_className: "cim-app-header-title-link", children: title }) }), postTitle] }), search && (0, jsx_runtime_1.jsx)("div", { className: "cim-app-header-search", children: search }), (0, jsx_runtime_1.jsx)("div", { className: "cim-app-header-tools", children: isMobile && tools ? ((0, jsx_runtime_1.jsxs)(popover_js_1.PopoverRoot, { children: [(0, jsx_runtime_1.jsx)(icon_button_js_1.IconButton, { icon: (0, jsx_runtime_1.jsx)(index_js_1.IconMenuMoreVertical, {}), "aria-label": "Expand/collapse header", variant: "tertiary", size: "small" }), (0, jsx_runtime_1.jsx)(popover_js_1.Popover, { "aria-label": "Expanded header", placement: "bottom end", children: (0, jsx_runtime_1.jsx)("div", { className: "cim-app-header-tools-collapsed", children: tools }) })] })) : (tools) })] }));
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)("header", { ...props, ref: ref, className: (0, clsx_1.default)('cim-app-header', UNSAFE_className), style: UNSAFE_style, "data-react-aria-top-layer": appShellContext?.sideNavIsOpen || undefined, children: [(0, jsx_runtime_1.jsxs)("div", { className: "cim-app-header-title", children: [navButton !== undefined ? navButton : appShellContext ? (0, jsx_runtime_1.jsx)(nav_button_js_1.UNSTABLE_AppHeaderNavButton, {}) : null, (0, jsx_runtime_1.jsx)(cimpress_logo_js_1.CimpressLogo, { height: 24 }), (0, jsx_runtime_1.jsx)(divider_js_1.Divider, { orientation: "vertical" }), (0, jsx_runtime_1.jsx)(text_js_1.Text, { as: "h1", variant: "title-5", tone: "base", children: (0, jsx_runtime_1.jsx)(link_js_1.Link, { ...titleLinkProps, UNSAFE_className: "cim-app-header-title-link", children: title }) }), postTitle] }), search && (0, jsx_runtime_1.jsx)("div", { className: "cim-app-header-search", children: search }), (0, jsx_runtime_1.jsx)("div", { className: "cim-app-header-tools", children: isMobile && tools ? ((0, jsx_runtime_1.jsxs)(popover_js_1.PopoverRoot, { children: [(0, jsx_runtime_1.jsx)(icon_button_js_1.IconButton, { icon: (0, jsx_runtime_1.jsx)(index_js_1.IconMenuMoreVertical, {}), "aria-label": "Expand/collapse header", variant: "tertiary", size: "small" }), (0, jsx_runtime_1.jsx)(popover_js_1.Popover, { "aria-label": "Expanded header", placement: "bottom end", children: (0, jsx_runtime_1.jsx)("div", { className: "cim-app-header-tools-collapsed", children: tools }) })] })) : (tools) })] }));
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
25
29
|
* Displays a basic application header.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-header.js","sourceRoot":"","sources":["../../../../src/components/app-header/app-header.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;
|
|
1
|
+
{"version":3,"file":"app-header.js","sourceRoot":"","sources":["../../../../src/components/app-header/app-header.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AACxB,iCAAsE;AACtE,yDAAkD;AAClD,mDAA4D;AAC5D,mEAA2D;AAC3D,4EAAoE;AACpE,6DAAsD;AACtD,sDAAgD;AAChD,sDAA6D;AAE7D,mDAA6C;AAC7C,mDAA6C;AAC7C,yDAAkD;AAClD,mDAAoF;AAgBpF,SAAS,SAAS,CAChB,EACE,KAAK,EACL,SAAS,EACT,KAAK,EACL,kBAAkB,EAAE,SAAS,EAC7B,kBAAkB,EAAE,SAAS,EAC7B,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAChB,YAAY,EACZ,GAAG,KAAK,EACO,EACjB,GAAiC;IAEjC,MAAM,QAAQ,GAAG,IAAA,8BAAW,GAAE,CAAC;IAC/B,MAAM,eAAe,GAAG,IAAA,kBAAU,EAAC,sCAAe,CAAC,CAAC;IACpD,MAAM,cAAc,GAAG,OAAO,SAAS,KAAK,QAAQ,IAAI,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAE9G,OAAO,CACL,uCACM,KAAK,EACT,GAAG,EAAE,GAAG,EACR,SAAS,EAA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import { forwardRef } from '../../forward-ref.js';\nimport { IconMenuMoreVertical } from '../../icons/index.js';\nimport { useIsMobile } from '../../utils/use-is-mobile.js';\nimport { AppShellContext } from '../app-shell/app-shell-context.js';\nimport { IconButton } from '../button/icon-button.js';\nimport { Divider } from '../divider/divider.js';\nimport { Popover, PopoverRoot } from '../popover/popover.js';\nimport type { CommonProps, Href, NavigationProps, WithRequired } from '../types.js';\nimport { Link } from '../typography/link.js';\nimport { Text } from '../typography/text.js';\nimport { CimpressLogo } from './cimpress-logo.js';\nimport { UNSTABLE_AppHeaderNavButton as AppHeaderNavButton } from './nav-button.js';\n\nexport interface AppHeaderTitleLinkProps extends WithRequired<NavigationProps, 'href'> {}\n\nexport interface AppHeaderProps extends CommonProps {\n /** The title displayed in the header, usually the application name. Rendered as an `<h1>` element. */\n title: string;\n /** The props of the link that is rendered around the header title. */\n titleLink: Href | AppHeaderTitleLinkProps;\n /** The tools to render at the end of the header. */\n tools?: ReactNode;\n UNSTABLE_navButton?: ReactNode;\n UNSTABLE_postTitle?: ReactNode;\n UNSTABLE_search?: ReactNode;\n}\n\nfunction AppHeader(\n {\n title,\n titleLink,\n tools,\n UNSTABLE_navButton: navButton,\n UNSTABLE_postTitle: postTitle,\n UNSTABLE_search: search,\n UNSAFE_className,\n UNSAFE_style,\n ...props\n }: AppHeaderProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const isMobile = useIsMobile();\n const appShellContext = useContext(AppShellContext);\n const titleLinkProps = typeof titleLink === 'object' && 'href' in titleLink ? titleLink : { href: titleLink };\n\n return (\n <header\n {...props}\n ref={ref}\n className={clsx('cim-app-header', UNSAFE_className)}\n style={UNSAFE_style}\n data-react-aria-top-layer={appShellContext?.sideNavIsOpen || undefined}\n >\n <div className=\"cim-app-header-title\">\n {navButton !== undefined ? navButton : appShellContext ? <AppHeaderNavButton /> : null}\n <CimpressLogo height={24} />\n <Divider orientation=\"vertical\" />\n <Text as=\"h1\" variant=\"title-5\" tone=\"base\">\n <Link {...titleLinkProps} UNSAFE_className=\"cim-app-header-title-link\">\n {title}\n </Link>\n </Text>\n\n {postTitle}\n </div>\n\n {search && <div className=\"cim-app-header-search\">{search}</div>}\n\n <div className=\"cim-app-header-tools\">\n {isMobile && tools ? (\n <PopoverRoot>\n <IconButton\n icon={<IconMenuMoreVertical />}\n // TODO: i18n\n aria-label=\"Expand/collapse header\"\n variant=\"tertiary\"\n size=\"small\"\n />\n <Popover aria-label=\"Expanded header\" placement=\"bottom end\">\n <div className=\"cim-app-header-tools-collapsed\">{tools}</div>\n </Popover>\n </PopoverRoot>\n ) : (\n tools\n )}\n </div>\n </header>\n );\n}\n\n/**\n * Displays a basic application header.\n *\n * See [app header usage guidelines](https://ui.cimpress.io/components/app-header/).\n */\nconst _AppHeader = forwardRef(AppHeader, 'AppHeader');\n\nexport { _AppHeader as AppHeader };\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CommonProps } from '../types.js';
|
|
2
2
|
export interface UNSTABLE_AppHeaderNavButtonProps extends CommonProps {
|
|
3
|
-
isOpen
|
|
4
|
-
onPress
|
|
3
|
+
isOpen?: boolean;
|
|
4
|
+
onPress?: () => void;
|
|
5
5
|
}
|
|
6
6
|
declare const _UNSTABLE_AppHeaderNavButton: (props: UNSTABLE_AppHeaderNavButtonProps & import("react").RefAttributes<HTMLButtonElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
7
7
|
export { _UNSTABLE_AppHeaderNavButton as UNSTABLE_AppHeaderNavButton };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nav-button.d.ts","sourceRoot":"","sources":["../../../../src/components/app-header/nav-button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nav-button.d.ts","sourceRoot":"","sources":["../../../../src/components/app-header/nav-button.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,WAAW,gCAAiC,SAAQ,WAAW;IACnE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AA4BD,QAAA,MAAM,4BAA4B,qLAAgF,CAAC;AAEnH,OAAO,EAAE,4BAA4B,IAAI,2BAA2B,EAAE,CAAC"}
|
|
@@ -6,12 +6,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.UNSTABLE_AppHeaderNavButton = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const clsx_1 = __importDefault(require("clsx"));
|
|
9
|
+
const react_1 = require("react");
|
|
9
10
|
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
10
11
|
const index_js_1 = require("../../icons/index.js");
|
|
11
12
|
const with_style_props_js_1 = require("../../with-style-props.js");
|
|
13
|
+
const app_shell_context_js_1 = require("../app-shell/app-shell-context.js");
|
|
12
14
|
const icon_button_js_1 = require("../button/icon-button.js");
|
|
13
15
|
function UNSTABLE_AppHeaderNavButton({ isOpen, onPress, UNSAFE_className, UNSAFE_style }, ref) {
|
|
14
|
-
|
|
16
|
+
const appShellContext = (0, react_1.useContext)(app_shell_context_js_1.AppShellContext);
|
|
17
|
+
const handlePress = () => {
|
|
18
|
+
onPress?.();
|
|
19
|
+
appShellContext?.toggleSideNav();
|
|
20
|
+
};
|
|
21
|
+
return ((0, jsx_runtime_1.jsx)(icon_button_js_1.IconButton, { "aria-expanded": isOpen ?? appShellContext?.sideNavIsOpen, icon: (0, jsx_runtime_1.jsx)(index_js_1.IconMenu, {}), "aria-label": "Open menu", variant: "tertiary", onPress: handlePress, ref: ref, UNSAFE_className: (0, clsx_1.default)('cim-app-header-nav-toggle', UNSAFE_className), UNSAFE_style: UNSAFE_style }));
|
|
15
22
|
}
|
|
16
23
|
const _UNSTABLE_AppHeaderNavButton = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(UNSTABLE_AppHeaderNavButton, 'AppHeaderNavButton'));
|
|
17
24
|
exports.UNSTABLE_AppHeaderNavButton = _UNSTABLE_AppHeaderNavButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nav-button.js","sourceRoot":"","sources":["../../../../src/components/app-header/nav-button.tsx"],"names":[],"mappings":";;;;;;;AAAA,gDAAwB;
|
|
1
|
+
{"version":3,"file":"nav-button.js","sourceRoot":"","sources":["../../../../src/components/app-header/nav-button.tsx"],"names":[],"mappings":";;;;;;;AAAA,gDAAwB;AACxB,iCAAsD;AACtD,yDAAkD;AAClD,mDAAgD;AAChD,mEAA2D;AAC3D,4EAAoE;AACpE,6DAAsD;AAQtD,SAAS,2BAA2B,CAClC,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAoC,EACrF,GAAoC;IAEpC,MAAM,eAAe,GAAG,IAAA,kBAAU,EAAC,sCAAe,CAAC,CAAC;IAEpD,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,OAAO,EAAE,EAAE,CAAC;QACZ,eAAe,EAAE,aAAa,EAAE,CAAC;IACnC,CAAC,CAAC;IAEF,OAAO,CACL,uBAAC,2BAAU,qBACM,MAAM,IAAI,eAAe,EAAE,aAAa,EACvD,IAAI,EAAE,uBAAC,mBAAQ,KAAG,gBAEP,WAAW,EACtB,OAAO,EAAC,UAAU,EAClB,OAAO,EAAE,WAAW,EACpB,GAAG,EAAE,GAAG,EACR,gBAAgB,EAAE,IAAA,cAAI,EAAC,2BAA2B,EAAE,gBAAgB,CAAC,EACrE,YAAY,EAAE,YAAY,GAC1B,CACH,CAAC;AACJ,CAAC;AAED,MAAM,4BAA4B,GAAG,IAAA,oCAAc,EAAC,IAAA,2BAAU,EAAC,2BAA2B,EAAE,oBAAoB,CAAC,CAAC,CAAC;AAE1E,mEAA2B","sourcesContent":["import clsx from 'clsx';\nimport { useContext, type ForwardedRef } from 'react';\nimport { forwardRef } from '../../forward-ref.js';\nimport { IconMenu } from '../../icons/index.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { AppShellContext } from '../app-shell/app-shell-context.js';\nimport { IconButton } from '../button/icon-button.js';\nimport type { CommonProps } from '../types.js';\n\nexport interface UNSTABLE_AppHeaderNavButtonProps extends CommonProps {\n isOpen?: boolean;\n onPress?: () => void;\n}\n\nfunction UNSTABLE_AppHeaderNavButton(\n { isOpen, onPress, UNSAFE_className, UNSAFE_style }: UNSTABLE_AppHeaderNavButtonProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) {\n const appShellContext = useContext(AppShellContext);\n\n const handlePress = () => {\n onPress?.();\n appShellContext?.toggleSideNav();\n };\n\n return (\n <IconButton\n aria-expanded={isOpen ?? appShellContext?.sideNavIsOpen}\n icon={<IconMenu />}\n // TODO\n aria-label=\"Open menu\"\n variant=\"tertiary\"\n onPress={handlePress}\n ref={ref}\n UNSAFE_className={clsx('cim-app-header-nav-toggle', UNSAFE_className)}\n UNSAFE_style={UNSAFE_style}\n />\n );\n}\n\nconst _UNSTABLE_AppHeaderNavButton = withStyleProps(forwardRef(UNSTABLE_AppHeaderNavButton, 'AppHeaderNavButton'));\n\nexport { _UNSTABLE_AppHeaderNavButton as UNSTABLE_AppHeaderNavButton };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-shell-context.d.ts","sourceRoot":"","sources":["../../../../src/components/app-shell/app-shell-context.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppShellContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/** @internal */
|
|
6
|
+
exports.AppShellContext = (0, react_1.createContext)(null);
|
|
7
|
+
//# sourceMappingURL=app-shell-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-shell-context.js","sourceRoot":"","sources":["../../../../src/components/app-shell/app-shell-context.tsx"],"names":[],"mappings":";;;AAAA,iCAAsC;AAEtC,gBAAgB;AACH,QAAA,eAAe,GAAG,IAAA,qBAAa,EAGlC,IAAI,CAAC,CAAC","sourcesContent":["import { createContext } from 'react';\n\n/** @internal */\nexport const AppShellContext = createContext<{\n sideNavIsOpen: boolean;\n toggleSideNav: (isOpen?: boolean) => void;\n} | null>(null);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-shell.d.ts","sourceRoot":"","sources":["../../../../src/components/app-shell/app-shell.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"app-shell.d.ts","sourceRoot":"","sources":["../../../../src/components/app-shell/app-shell.tsx"],"names":[],"mappings":"AACA,OAAO,EAAqC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,KAAK,EAAE,EAAE,sBAAsB,2CAa/G;AAED,MAAM,WAAW,0BAA2B,SAAQ,WAAW;IAC7D,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,GAAG,KAAK,EACT,EAAE,0BAA0B,2CAkB5B"}
|
|
@@ -7,10 +7,20 @@ exports.UNSTABLE_AppShell = UNSTABLE_AppShell;
|
|
|
7
7
|
exports.UNSTABLE_AppShellBody = UNSTABLE_AppShellBody;
|
|
8
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
9
|
const clsx_1 = __importDefault(require("clsx"));
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const use_is_mobile_js_1 = require("../../utils/use-is-mobile.js");
|
|
12
|
+
const app_shell_context_js_1 = require("./app-shell-context.js");
|
|
10
13
|
function UNSTABLE_AppShell({ children, UNSAFE_className, UNSAFE_style, ...props }) {
|
|
11
|
-
|
|
14
|
+
const [sideNavIsOpen, setSideNavIsOpen] = (0, react_1.useState)(true);
|
|
15
|
+
const toggleSideNav = (0, react_1.useCallback)((isOpen) => {
|
|
16
|
+
setSideNavIsOpen((prevIsOpen) => isOpen ?? !prevIsOpen);
|
|
17
|
+
}, []);
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(app_shell_context_js_1.AppShellContext.Provider, { value: { sideNavIsOpen, toggleSideNav }, children: (0, jsx_runtime_1.jsx)("div", { className: (0, clsx_1.default)('cim-app-shell', UNSAFE_className), style: UNSAFE_style, ...props, children: children }) }));
|
|
12
19
|
}
|
|
13
20
|
function UNSTABLE_AppShellBody({ children, UNSAFE_className, UNSAFE_style, ...props }) {
|
|
14
|
-
|
|
21
|
+
const appShellContext = (0, react_1.useContext)(app_shell_context_js_1.AppShellContext);
|
|
22
|
+
const sideNavIsOpen = appShellContext?.sideNavIsOpen ?? false;
|
|
23
|
+
const isMobile = (0, use_is_mobile_js_1.useIsMobile)();
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, clsx_1.default)('cim-app-shell-body', UNSAFE_className), style: UNSAFE_style, inert: isMobile && sideNavIsOpen ? '' : undefined, ...props, children: children }));
|
|
15
25
|
}
|
|
16
26
|
//# sourceMappingURL=app-shell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-shell.js","sourceRoot":"","sources":["../../../../src/components/app-shell/app-shell.tsx"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"app-shell.js","sourceRoot":"","sources":["../../../../src/components/app-shell/app-shell.tsx"],"names":[],"mappings":";;;;;AAUA,8CAaC;AAMD,sDAuBC;;AApDD,gDAAwB;AACxB,iCAA0E;AAC1E,mEAA2D;AAE3D,iEAAyD;AAMzD,SAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,KAAK,EAA0B;IAC9G,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC;IACzD,MAAM,aAAa,GAAG,IAAA,mBAAW,EAAC,CAAC,MAAgB,EAAE,EAAE;QACrD,gBAAgB,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1D,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,uBAAC,sCAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,YAC/D,gCAAK,SAAS,EAAE,IAAA,cAAI,EAAC,eAAe,EAAE,gBAAgB,CAAC,EAAE,KAAK,EAAE,YAAY,KAAM,KAAK,YACpF,QAAQ,GACL,GACmB,CAC5B,CAAC;AACJ,CAAC;AAMD,SAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,GAAG,KAAK,EACmB;IAC3B,MAAM,eAAe,GAAG,IAAA,kBAAU,EAAC,sCAAe,CAAC,CAAC;IACpD,MAAM,aAAa,GAAG,eAAe,EAAE,aAAa,IAAI,KAAK,CAAC;IAC9D,MAAM,QAAQ,GAAG,IAAA,8BAAW,GAAE,CAAC;IAE/B,OAAO,CACL,gCACE,SAAS,EAAE,IAAA,cAAI,EAAC,oBAAoB,EAAE,gBAAgB,CAAC,EACvD,KAAK,EAAE,YAAY,EAIb,KAAK,EAAE,QAAQ,IAAI,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KACnD,KAAK,YAER,QAAQ,GACL,CACP,CAAC;AACJ,CAAC","sourcesContent":["import clsx from 'clsx';\nimport { useCallback, useContext, useState, type ReactNode } from 'react';\nimport { useIsMobile } from '../../utils/use-is-mobile.js';\nimport type { CommonProps } from '../types.js';\nimport { AppShellContext } from './app-shell-context.js';\n\nexport interface UNSTABLE_AppShellProps extends CommonProps {\n children: ReactNode;\n}\n\nexport function UNSTABLE_AppShell({ children, UNSAFE_className, UNSAFE_style, ...props }: UNSTABLE_AppShellProps) {\n const [sideNavIsOpen, setSideNavIsOpen] = useState(true);\n const toggleSideNav = useCallback((isOpen?: boolean) => {\n setSideNavIsOpen((prevIsOpen) => isOpen ?? !prevIsOpen);\n }, []);\n\n return (\n <AppShellContext.Provider value={{ sideNavIsOpen, toggleSideNav }}>\n <div className={clsx('cim-app-shell', UNSAFE_className)} style={UNSAFE_style} {...props}>\n {children}\n </div>\n </AppShellContext.Provider>\n );\n}\n\nexport interface UNSTABLE_AppShellBodyProps extends CommonProps {\n children: ReactNode;\n}\n\nexport function UNSTABLE_AppShellBody({\n children,\n UNSAFE_className,\n UNSAFE_style,\n ...props\n}: UNSTABLE_AppShellBodyProps) {\n const appShellContext = useContext(AppShellContext);\n const sideNavIsOpen = appShellContext?.sideNavIsOpen ?? false;\n const isMobile = useIsMobile();\n\n return (\n <div\n className={clsx('cim-app-shell-body', UNSAFE_className)}\n style={UNSAFE_style}\n // Make the body inert when the side nav is open on mobile so that tabbing is contained to app header and side nav\n // Workaround for React not having type definitions for the `inert` attribute\n // eslint-disable-next-line internal/no-extra-props-in-spread\n {...{ inert: isMobile && sideNavIsOpen ? '' : undefined }}\n {...props}\n >\n {children}\n </div>\n );\n}\n"]}
|
|
@@ -3,18 +3,40 @@ import { type ComboBoxProps as RACComboBoxProps, type ListBoxItemProps as RACLis
|
|
|
3
3
|
import type { ApiProps, AsyncItemLoadingProps, CollectionItem, CollectionProps, CommonProps, FieldWithPlaceholderProps, Key, StringLikeChildren } from '../types.js';
|
|
4
4
|
/** Represents the state of the `ComboBox` component for validation purposes. */
|
|
5
5
|
export interface ComboBoxValidationValue {
|
|
6
|
-
/** The selected key in the
|
|
7
|
-
|
|
8
|
-
/** The value of the
|
|
6
|
+
/** The selected key in the combo box. */
|
|
7
|
+
value: Key | null;
|
|
8
|
+
/** The value of the combo box input. */
|
|
9
9
|
inputValue: string;
|
|
10
|
+
/**
|
|
11
|
+
* The selected key in the combo box.
|
|
12
|
+
* @deprecated Use `value` instead.
|
|
13
|
+
*/
|
|
14
|
+
selectedKey: Key | null;
|
|
10
15
|
}
|
|
11
16
|
export interface ComboBoxProps<T extends CollectionItem = CollectionItem> extends CommonProps, FieldWithPlaceholderProps<ComboBoxValidationValue>, CollectionProps<T>, AsyncItemLoadingProps, ApiProps<ComboBoxApi>, Pick<RACComboBoxProps<T>, 'isDisabled' | 'isRequired' | 'isInvalid' | 'isReadOnly' | 'inputValue' | 'defaultInputValue' | 'autoFocus' | 'onInputChange' | 'onFocus' | 'onBlur' | 'onOpenChange'> {
|
|
12
|
-
/** The
|
|
17
|
+
/** The current value (controlled). */
|
|
18
|
+
value?: Key | null;
|
|
19
|
+
/** The initial value (uncontrolled). */
|
|
20
|
+
defaultValue?: Key;
|
|
21
|
+
/** Handler that is called when the value changes. */
|
|
22
|
+
onChange?: (key: Key | null) => void;
|
|
23
|
+
/**
|
|
24
|
+
* The currently selected key in the collection (controlled).
|
|
25
|
+
* @deprecated Use `value` instead.
|
|
26
|
+
*/
|
|
13
27
|
selectedKey?: Key | null;
|
|
14
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* The initial selected key in the collection (uncontrolled).
|
|
30
|
+
* @deprecated Use `defaultValue` instead.
|
|
31
|
+
*/
|
|
15
32
|
defaultSelectedKey?: Key;
|
|
16
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Handler that is called when the selection changes.
|
|
35
|
+
* @deprecated Use `onChange` instead.
|
|
36
|
+
*/
|
|
17
37
|
onSelectionChange?: (key: Key | null) => void;
|
|
38
|
+
/** Whether to display a clear button to clear the selection. */
|
|
39
|
+
isClearable?: boolean;
|
|
18
40
|
/**
|
|
19
41
|
* Whether the list of options should be virtualized. Use this as a performance optimization for large lists.
|
|
20
42
|
* @default false
|
|
@@ -22,7 +44,6 @@ export interface ComboBoxProps<T extends CollectionItem = CollectionItem> extend
|
|
|
22
44
|
isVirtualized?: boolean;
|
|
23
45
|
/** Handler that is called when the list of items is scrolled. */
|
|
24
46
|
onScroll?: UIEventHandler<HTMLDivElement>;
|
|
25
|
-
UNSTABLE_isClearable?: boolean;
|
|
26
47
|
}
|
|
27
48
|
/** The imperative API exposed by the `ComboBox` component. */
|
|
28
49
|
export interface ComboBoxApi {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo-box.d.ts","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,cAAc,EAIpB,MAAM,OAAO,CAAC;AAEf,OAAO,EAeL,KAAK,aAAa,IAAI,gBAAgB,EACtC,KAAK,gBAAgB,IAAI,mBAAmB,EAE7C,MAAM,uBAAuB,CAAC;AAW/B,OAAO,KAAK,EACV,QAAQ,EACR,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,WAAW,EACX,yBAAyB,EACzB,GAAG,EACH,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAWrB,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACtC,
|
|
1
|
+
{"version":3,"file":"combo-box.d.ts","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,cAAc,EAIpB,MAAM,OAAO,CAAC;AAEf,OAAO,EAeL,KAAK,aAAa,IAAI,gBAAgB,EACtC,KAAK,gBAAgB,IAAI,mBAAmB,EAE7C,MAAM,uBAAuB,CAAC;AAW/B,OAAO,KAAK,EACV,QAAQ,EACR,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,WAAW,EACX,yBAAyB,EACzB,GAAG,EACH,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAWrB,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACtC,yCAAyC;IACzC,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;IAClB,wCAA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,SAAS,GAzHG,CAAC,SAAS,cAAc,iKAyHwB,CAAC;AAEnE,OAAO,EAAE,SAAS,IAAI,QAAQ,EAAE,CAAC;AAuFjC,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,IAAI,CACvE,mBAAmB,CAAC,CAAC,CAAC,EACtB,YAAY,GAAG,cAAc,GAAG,YAAY,CAC7C;IACC,0EAA0E;IAC1E,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,2CAA2C;IAC3C,QAAQ,EAAE,kBAAkB,CAAC;CAC9B;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,CAAC,SAAS,cAAc,EAAE,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,2CAiBlG;yBAjBe,YAAY;;;AAqB5B,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;IACxF,6EAA6E;IAC7E,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,CAAC,SAAS,cAAc,EAAE,EACxD,KAAK,EACL,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACT,EAAE,oBAAoB,CAAC,CAAC,CAAC,2CAezB;yBApBe,eAAe"}
|
|
@@ -30,7 +30,7 @@ const VIRTUAL_LAYOUT_OPTIONS = {
|
|
|
30
30
|
padding: 0,
|
|
31
31
|
gap: 0,
|
|
32
32
|
};
|
|
33
|
-
function ComboBox({ label, description, error, items, children, placeholder, UNSAFE_className, UNSAFE_style, isReadOnly, onScroll, isVirtualized = false, UNSTABLE_isLoading: isLoading, UNSTABLE_onLoadMore: onLoadMore,
|
|
33
|
+
function ComboBox({ label, description, error, items, children, placeholder, UNSAFE_className, UNSAFE_style, isReadOnly, onScroll, isVirtualized = false, isClearable = false, UNSTABLE_isLoading: isLoading, UNSTABLE_onLoadMore: onLoadMore, apiRef, value, defaultValue, onChange, selectedKey, defaultSelectedKey, onSelectionChange, validate, ...props }, ref) {
|
|
34
34
|
const inputRef = (0, react_1.useRef)(null);
|
|
35
35
|
const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;
|
|
36
36
|
(0, use_production_warning_js_1.useProductionWarning)(() => {
|
|
@@ -47,11 +47,11 @@ function ComboBox({ label, description, error, items, children, placeholder, UNS
|
|
|
47
47
|
}), []);
|
|
48
48
|
const isFieldClearable = isClearable && !props.isDisabled && !isReadOnly;
|
|
49
49
|
const listBox = ((0, jsx_runtime_1.jsx)(ComboBoxList, { items: items, isLoading: isLoading, onLoadMore: onLoadMore, onScroll: onScroll, children: children }));
|
|
50
|
-
return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.ComboBox, { ...props, ref: ref, className: (0, clsx_1.default)('cim-combo-box', UNSAFE_className), style: UNSAFE_style, selectionMode: "single", value:
|
|
50
|
+
return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.ComboBox, { ...props, ref: ref, className: (0, clsx_1.default)('cim-combo-box', UNSAFE_className), style: UNSAFE_style, selectionMode: "single", value: value, defaultValue: defaultValue, onChange: onChange, selectedKey: selectedKey, defaultSelectedKey: defaultSelectedKey, onSelectionChange: onSelectionChange, menuTrigger: "focus", isReadOnly: isReadOnly, "data-readonly": isReadOnly ? true : undefined, validate: validate
|
|
51
51
|
? ({ inputValue, value }) => {
|
|
52
|
-
return validate({ inputValue, selectedKey: value });
|
|
52
|
+
return validate({ inputValue, value, selectedKey: value });
|
|
53
53
|
}
|
|
54
|
-
: undefined, children: [(0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldLabel, { isRequired: props.isRequired, isDisabled: props.isDisabled, children: label }), (0, jsx_runtime_1.jsxs)(react_aria_components_1.Group, { className: "cim-combo-box-input-group", children: [(0, jsx_runtime_1.jsx)(ComboBoxInput, { inputRef: inputRef, isReadOnly: isReadOnly, placeholder: placeholder, isClearable: isFieldClearable }), isFieldClearable && (0, jsx_runtime_1.jsx)(ComboBoxClearButton, {}), (0, jsx_runtime_1.jsx)(react_aria_components_1.Button, { className: "cim-combo-box-button", children: (0, jsx_runtime_1.jsx)(index_js_2.IconChevronDown, {}) })] }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldError, { children: error }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldDescription, { children: description }), (0, jsx_runtime_1.jsx)(collapsible_list_js_1.CollapsibleList, { offset: 5, maxHeight: 315, children: isVirtualized ? ((0, jsx_runtime_1.jsx)(react_aria_components_1.Virtualizer, { layout: react_aria_components_1.ListLayout, layoutOptions: VIRTUAL_LAYOUT_OPTIONS, children: listBox })) : (listBox) })] }));
|
|
54
|
+
: undefined, children: [(0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldLabel, { isRequired: props.isRequired, isDisabled: props.isDisabled, children: label }), (0, jsx_runtime_1.jsxs)(react_aria_components_1.Group, { className: "cim-combo-box-input-group", children: [(0, jsx_runtime_1.jsx)(ComboBoxInput, { inputRef: inputRef, isReadOnly: isReadOnly, placeholder: placeholder, isClearable: isFieldClearable }), isFieldClearable && (0, jsx_runtime_1.jsx)(ComboBoxClearButton, { onClear: () => inputRef.current?.focus() }), (0, jsx_runtime_1.jsx)(react_aria_components_1.Button, { className: "cim-combo-box-button", children: (0, jsx_runtime_1.jsx)(index_js_2.IconChevronDown, {}) })] }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldError, { children: error }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldDescription, { children: description }), (0, jsx_runtime_1.jsx)(collapsible_list_js_1.CollapsibleList, { offset: 5, maxHeight: 315, children: isVirtualized ? ((0, jsx_runtime_1.jsx)(react_aria_components_1.Virtualizer, { layout: react_aria_components_1.ListLayout, layoutOptions: VIRTUAL_LAYOUT_OPTIONS, children: listBox })) : (listBox) })] }));
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Allows users to filter a collapsible list and select one item from it.
|
|
@@ -60,15 +60,17 @@ function ComboBox({ label, description, error, items, children, placeholder, UNS
|
|
|
60
60
|
*/
|
|
61
61
|
const _ComboBox = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(ComboBox), 'ComboBox');
|
|
62
62
|
exports.ComboBox = _ComboBox;
|
|
63
|
-
function ComboBoxClearButton() {
|
|
63
|
+
function ComboBoxClearButton({ onClear }) {
|
|
64
64
|
const comboBoxState = (0, react_1.useContext)(react_aria_components_1.ComboBoxStateContext);
|
|
65
|
+
const selectMessages = (0, index_js_1.useLocalizedMessages)('select');
|
|
65
66
|
const inputValue = comboBoxState?.inputValue;
|
|
66
67
|
if (!comboBoxState || inputValue === '') {
|
|
67
68
|
return null;
|
|
68
69
|
}
|
|
69
70
|
return ((0, jsx_runtime_1.jsx)(x_button_js_1.XButton, { onPress: () => {
|
|
70
|
-
comboBoxState
|
|
71
|
-
|
|
71
|
+
comboBoxState.setValue(null);
|
|
72
|
+
onClear?.();
|
|
73
|
+
}, iconType: "circled", "aria-label": selectMessages.format('clearSelection'),
|
|
72
74
|
// Prevent this button from acting as a trigger for opening/closing the ComboBox
|
|
73
75
|
slot: null, excludeFromTabOrder: true }));
|
|
74
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo-box.js","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAwUb,oCAiBC;AAYD,0CAoBC;;AAvXD,gDAAwB;AACxB,iCAOe;AACf,2CAA8C;AAC9C,iEAkB+B;AAC/B,yDAAkD;AAClD,kDAA2D;AAC3D,mDAAsE;AACtE,mEAA4D;AAC5D,qFAA6E;AAC7E,mEAA2D;AAC3D,0FAAmF;AACnF,wEAA4G;AAC5G,kEAA2D;AAC3D,sDAAgD;AAWhD,qDAAmD;AAEnD,MAAM,sBAAsB,GAAyB;IACnD,kBAAkB,EAAE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AS,EAAE,IAAA,cAAI,EAAC,8BAA8B,EAAE,IAAA,oBAAS,EAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,YAExG,KAAK,GACI,EACZ,uBAAC,kCAAa,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAiB,IACrC,CACrB,CAAC;AACJ,CAAC;AAED,eAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport {\n type ForwardedRef,\n type MutableRefObject,\n type UIEventHandler,\n useContext,\n useImperativeHandle,\n useRef,\n} from 'react';\nimport { usePreventScroll } from 'react-aria';\nimport {\n Button as RACButton,\n Collection as RACCollection,\n ComboBox as RACComboBox,\n ComboBoxStateContext as RACComboBoxStateContext,\n Group as RACGroup,\n Header as RACHeader,\n Input as RACInput,\n ListBox as RACListBox,\n ListBoxLoadMoreItem as RACListBoxLoadMoreItem,\n ListBoxItem as RACListBoxItem,\n ListBoxSection as RACListBoxSection,\n ListLayout as RACListLayout,\n type ListLayoutOptions as RACListLayoutOptions,\n Text as RACText,\n type ComboBoxProps as RACComboBoxProps,\n type ListBoxItemProps as RACListBoxItemProps,\n Virtualizer as RACVirtualizer,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/index.js';\nimport { IconCheckBold, IconChevronDown } from '../../icons/index.js';\nimport { isProduction } from '../../utils/is-production.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { CollapsibleList } from '../internal/collapsible-list/collapsible-list.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport { XButton } from '../internal/x-button/x-button.js';\nimport { Spinner } from '../spinner/spinner.js';\nimport type {\n ApiProps,\n AsyncItemLoadingProps,\n CollectionItem,\n CollectionProps,\n CommonProps,\n FieldWithPlaceholderProps,\n Key,\n StringLikeChildren,\n} from '../types.js';\nimport { textStyle } from '../typography/utils.js';\n\nconst VIRTUAL_LAYOUT_OPTIONS: RACListLayoutOptions = {\n estimatedRowHeight: 40,\n estimatedHeadingHeight: 32,\n loaderHeight: 40,\n padding: 0,\n gap: 0,\n};\n\n/** Represents the state of the `ComboBox` component for validation purposes. */\nexport interface ComboBoxValidationValue {\n /** The selected key in the ComboBox. */\n selectedKey: Key | null;\n /** The value of the ComboBox input. */\n inputValue: string;\n}\n\nexport interface ComboBoxProps<T extends CollectionItem = CollectionItem>\n extends\n CommonProps,\n FieldWithPlaceholderProps<ComboBoxValidationValue>,\n CollectionProps<T>,\n AsyncItemLoadingProps,\n ApiProps<ComboBoxApi>,\n Pick<\n RACComboBoxProps<T>,\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'isReadOnly'\n | 'inputValue'\n | 'defaultInputValue'\n | 'autoFocus'\n | 'onInputChange'\n | 'onFocus'\n | 'onBlur'\n | 'onOpenChange'\n > {\n /** The currently selected key in the collection (controlled). */\n selectedKey?: Key | null;\n /** The initial selected key in the collection (uncontrolled). */\n defaultSelectedKey?: Key;\n /** Handler that is called when the selection changes. */\n onSelectionChange?: (key: Key | null) => void;\n /**\n * Whether the list of options should be virtualized. Use this as a performance optimization for large lists.\n * @default false\n */\n isVirtualized?: boolean;\n /** Handler that is called when the list of items is scrolled. */\n onScroll?: UIEventHandler<HTMLDivElement>;\n UNSTABLE_isClearable?: boolean;\n}\n\n/** The imperative API exposed by the `ComboBox` component. */\nexport interface ComboBoxApi {\n /** Focuses the input field and opens the list of items. */\n focus: () => void;\n /** Selects the contents of the input field. */\n select: () => void;\n}\n\nfunction ComboBox<T extends CollectionItem>(\n {\n label,\n description,\n error,\n items,\n children,\n placeholder,\n UNSAFE_className,\n UNSAFE_style,\n isReadOnly,\n onScroll,\n isVirtualized = false,\n UNSTABLE_isLoading: isLoading,\n UNSTABLE_onLoadMore: onLoadMore,\n UNSTABLE_isClearable: isClearable = false,\n apiRef,\n selectedKey,\n defaultSelectedKey,\n onSelectionChange,\n validate,\n ...props\n }: ComboBoxProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('ComboBox requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`ComboBox` requires `children` to be a function when using `items` prop');\n }\n\n useImperativeHandle(\n apiRef,\n () => ({\n focus: () => inputRef.current?.focus(),\n select: () => inputRef.current?.select(),\n }),\n [],\n );\n\n const isFieldClearable = isClearable && !props.isDisabled && !isReadOnly;\n\n const listBox = (\n <ComboBoxList<T> items={items} isLoading={isLoading} onLoadMore={onLoadMore} onScroll={onScroll}>\n {children}\n </ComboBoxList>\n );\n\n return (\n <RACComboBox\n {...props}\n ref={ref}\n className={clsx('cim-combo-box', UNSAFE_className)}\n style={UNSAFE_style}\n selectionMode=\"single\"\n value={selectedKey}\n defaultValue={defaultSelectedKey}\n onChange={onSelectionChange}\n menuTrigger=\"focus\"\n isReadOnly={isReadOnly}\n data-readonly={isReadOnly ? true : undefined}\n validate={\n validate\n ? ({ inputValue, value }) => {\n return validate({ inputValue, selectedKey: value });\n }\n : undefined\n }\n >\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n <RACGroup className=\"cim-combo-box-input-group\">\n <ComboBoxInput\n inputRef={inputRef}\n isReadOnly={isReadOnly}\n placeholder={placeholder}\n isClearable={isFieldClearable}\n />\n {isFieldClearable && <ComboBoxClearButton />}\n <RACButton className=\"cim-combo-box-button\">\n <IconChevronDown />\n </RACButton>\n </RACGroup>\n <FormFieldError>{error}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n <CollapsibleList\n offset={5} // 1px border + 4px actual offset\n maxHeight={315}\n >\n {isVirtualized ? (\n <RACVirtualizer layout={RACListLayout} layoutOptions={VIRTUAL_LAYOUT_OPTIONS}>\n {listBox}\n </RACVirtualizer>\n ) : (\n listBox\n )}\n </CollapsibleList>\n </RACComboBox>\n );\n}\n\n/**\n * Allows users to filter a collapsible list and select one item from it.\n *\n * See [combo box usage guidelines](https://ui.cimpress.io/components/combo-box)\n */\nconst _ComboBox = withStyleProps(forwardRef(ComboBox), 'ComboBox');\n\nexport { _ComboBox as ComboBox };\n\nfunction ComboBoxClearButton() {\n const comboBoxState = useContext(RACComboBoxStateContext);\n const inputValue = comboBoxState?.inputValue;\n\n if (!comboBoxState || inputValue === '') {\n return null;\n }\n\n return (\n <XButton\n onPress={() => {\n comboBoxState?.setValue(null);\n }}\n iconType=\"circled\"\n // TODO: i18n once stabilized\n aria-label=\"Clear selection\"\n // Prevent this button from acting as a trigger for opening/closing the ComboBox\n slot={null}\n excludeFromTabOrder\n />\n );\n}\n\nfunction ComboBoxInput({\n inputRef,\n isReadOnly,\n placeholder,\n isClearable,\n}: {\n inputRef: MutableRefObject<HTMLInputElement | null>;\n isReadOnly: boolean | undefined;\n placeholder: string | undefined;\n isClearable: boolean;\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n\n return (\n <RACInput\n ref={inputRef}\n className={clsx('cim-combo-box-input', textStyle({ variant: 'body' }))}\n // Ensure the popover opens when the input is clicked.\n // By default, React Aria only opens the popover when the input is focused.\n onClick={() => !isReadOnly && comboBoxState!.open()}\n placeholder={placeholder}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && !comboBoxState?.isOpen && isClearable) {\n comboBoxState?.setValue(null);\n }\n }}\n />\n );\n}\n\nfunction ComboBoxList<T extends CollectionItem = CollectionItem>({\n items,\n children,\n isLoading,\n onLoadMore,\n onScroll,\n}: Pick<ComboBoxProps<T>, 'items' | 'children' | 'onScroll'> & {\n isLoading: ComboBoxProps['UNSTABLE_isLoading'];\n onLoadMore: ComboBoxProps['UNSTABLE_onLoadMore'];\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n const collectionMessages = useLocalizedMessages('UNSTABLE_collection');\n\n usePreventScroll({ isDisabled: !comboBoxState?.isOpen });\n\n return (\n <RACListBox\n className=\"cim-combo-box-listbox\"\n onScroll={onScroll}\n renderEmptyState={() =>\n isLoading ? <Spinner aria-label={collectionMessages.format('loading')} size=\"small\" marginY={8} /> : null\n }\n >\n <RACCollection items={items}>{children}</RACCollection>\n <RACListBoxLoadMoreItem onLoadMore={onLoadMore} isLoading={isLoading}>\n <Spinner aria-label={collectionMessages.format('loadingMore')} size=\"small\" marginY={8} />\n </RACListBoxLoadMoreItem>\n </RACListBox>\n );\n}\n\nexport interface ComboBoxItemProps<T extends CollectionItem> extends Pick<\n RACListBoxItemProps<T>,\n 'isDisabled' | 'onHoverStart' | 'onHoverEnd'\n> {\n /** The ID of the item. Has to be unique across all sections and items. */\n id?: Key;\n /** The content to display as the label. */\n children: StringLikeChildren;\n}\n\n/** Renders a single list item within `ComboBox`. */\nexport function ComboBoxItem<T extends CollectionItem>({ children, ...props }: ComboBoxItemProps<T>) {\n const textValue =\n typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');\n\n return (\n <RACListBoxItem {...props} className=\"cim-combo-box-item\" textValue={textValue}>\n {({ isDisabled }) => (\n <>\n <IconCheckBold />\n\n <RACText slot=\"label\" className={textStyle({ variant: 'body', tone: isDisabled ? 'muted' : 'base' })}>\n {children}\n </RACText>\n </>\n )}\n </RACListBoxItem>\n );\n}\n\nComboBoxItem.displayName = 'ComboBoxItem';\n\nexport interface ComboBoxSectionProps<T extends CollectionItem> extends CollectionProps<T> {\n /** The ID of the section. Has to be unique across all sections and items. */\n id?: Key;\n /** The content to display as the section title. */\n title: string;\n}\n\n/** Groups list items within `ComboBox` into a section. */\nexport function ComboBoxSection<T extends CollectionItem>({\n title,\n children,\n items,\n ...props\n}: ComboBoxSectionProps<T>) {\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`ComboBoxSection` requires `children` to be a function when using `items` prop');\n }\n\n return (\n <RACListBoxSection {...props} className=\"cim-combo-box-section\">\n <RACHeader\n className={clsx('cim-combo-box-section-header', textStyle({ variant: 'small-semibold', tone: 'subtle' }))}\n >\n {title}\n </RACHeader>\n <RACCollection items={items}>{children}</RACCollection>\n </RACListBoxSection>\n );\n}\n\nComboBoxSection.displayName = 'ComboBoxSection';\n"]}
|
|
1
|
+
{"version":3,"file":"combo-box.js","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAoWb,oCAiBC;AAYD,0CAoBC;;AAnZD,gDAAwB;AACxB,iCAOe;AACf,2CAA8C;AAC9C,iEAkB+B;AAC/B,yDAAkD;AAClD,kDAA2D;AAC3D,mDAAsE;AACtE,mEAA4D;AAC5D,qFAA6E;AAC7E,mEAA2D;AAC3D,0FAAmF;AACnF,wEAA4G;AAC5G,kEAA2D;AAC3D,sDAAgD;AAWhD,qDAAmD;AAEnD,MAAM,sBAAsB,GAAyB;IACnD,kBAAkB,EAAE,EAAE;IACtB,sBAAsB,EAAE,EAAE;IAC1B,YAAY,EAAE,EAAE;IAChB,OAAO,EAAE,CAAC;IACV,GAAG,EAAE,CAAC;CACP,CAAC;AA4EF,SAAS,QAAQ,CACf,EACE,KAAK,EACL,WAAW,EACX,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,aAAa,GAAG,KAAK,EACrB,WAAW,GAAG,KAAK,EACnB,kBAAkB,EAAE,SAAS,EAC7B,mBAAmB,EAAE,UAAU,EAC/B,MAAM,EACN,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,EACR,GAAG,KAAK,EACS,EACnB,GAAiC;IAEjC,MAAM,Q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K,EAAE,KAAK,YAAG,QAAQ,GAAiB,IACrC,CACrB,CAAC;AACJ,CAAC;AAED,eAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport {\n type ForwardedRef,\n type MutableRefObject,\n type UIEventHandler,\n useContext,\n useImperativeHandle,\n useRef,\n} from 'react';\nimport { usePreventScroll } from 'react-aria';\nimport {\n Button as RACButton,\n Collection as RACCollection,\n ComboBox as RACComboBox,\n ComboBoxStateContext as RACComboBoxStateContext,\n Group as RACGroup,\n Header as RACHeader,\n Input as RACInput,\n ListBox as RACListBox,\n ListBoxLoadMoreItem as RACListBoxLoadMoreItem,\n ListBoxItem as RACListBoxItem,\n ListBoxSection as RACListBoxSection,\n ListLayout as RACListLayout,\n type ListLayoutOptions as RACListLayoutOptions,\n Text as RACText,\n type ComboBoxProps as RACComboBoxProps,\n type ListBoxItemProps as RACListBoxItemProps,\n Virtualizer as RACVirtualizer,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/index.js';\nimport { IconCheckBold, IconChevronDown } from '../../icons/index.js';\nimport { isProduction } from '../../utils/is-production.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { CollapsibleList } from '../internal/collapsible-list/collapsible-list.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport { XButton } from '../internal/x-button/x-button.js';\nimport { Spinner } from '../spinner/spinner.js';\nimport type {\n ApiProps,\n AsyncItemLoadingProps,\n CollectionItem,\n CollectionProps,\n CommonProps,\n FieldWithPlaceholderProps,\n Key,\n StringLikeChildren,\n} from '../types.js';\nimport { textStyle } from '../typography/utils.js';\n\nconst VIRTUAL_LAYOUT_OPTIONS: RACListLayoutOptions = {\n estimatedRowHeight: 40,\n estimatedHeadingHeight: 32,\n loaderHeight: 40,\n padding: 0,\n gap: 0,\n};\n\n/** Represents the state of the `ComboBox` component for validation purposes. */\nexport interface ComboBoxValidationValue {\n /** The selected key in the combo box. */\n value: Key | null;\n /** The value of the combo box input. */\n inputValue: string;\n /**\n * The selected key in the combo box.\n * @deprecated Use `value` instead.\n */\n selectedKey: Key | null;\n}\n\nexport interface ComboBoxProps<T extends CollectionItem = CollectionItem>\n extends\n CommonProps,\n FieldWithPlaceholderProps<ComboBoxValidationValue>,\n CollectionProps<T>,\n AsyncItemLoadingProps,\n ApiProps<ComboBoxApi>,\n Pick<\n RACComboBoxProps<T>,\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'isReadOnly'\n | 'inputValue'\n | 'defaultInputValue'\n | 'autoFocus'\n | 'onInputChange'\n | 'onFocus'\n | 'onBlur'\n | 'onOpenChange'\n > {\n /** The current value (controlled). */\n value?: Key | null;\n /** The initial value (uncontrolled). */\n defaultValue?: Key;\n /** Handler that is called when the value changes. */\n onChange?: (key: Key | null) => void;\n /**\n * The currently selected key in the collection (controlled).\n * @deprecated Use `value` instead.\n */\n selectedKey?: Key | null;\n /**\n * The initial selected key in the collection (uncontrolled).\n * @deprecated Use `defaultValue` instead.\n */\n defaultSelectedKey?: Key;\n /**\n * Handler that is called when the selection changes.\n * @deprecated Use `onChange` instead.\n */\n onSelectionChange?: (key: Key | null) => void;\n /** Whether to display a clear button to clear the selection. */\n isClearable?: boolean;\n /**\n * Whether the list of options should be virtualized. Use this as a performance optimization for large lists.\n * @default false\n */\n isVirtualized?: boolean;\n /** Handler that is called when the list of items is scrolled. */\n onScroll?: UIEventHandler<HTMLDivElement>;\n}\n\n/** The imperative API exposed by the `ComboBox` component. */\nexport interface ComboBoxApi {\n /** Focuses the input field and opens the list of items. */\n focus: () => void;\n /** Selects the contents of the input field. */\n select: () => void;\n}\n\nfunction ComboBox<T extends CollectionItem>(\n {\n label,\n description,\n error,\n items,\n children,\n placeholder,\n UNSAFE_className,\n UNSAFE_style,\n isReadOnly,\n onScroll,\n isVirtualized = false,\n isClearable = false,\n UNSTABLE_isLoading: isLoading,\n UNSTABLE_onLoadMore: onLoadMore,\n apiRef,\n value,\n defaultValue,\n onChange,\n selectedKey,\n defaultSelectedKey,\n onSelectionChange,\n validate,\n ...props\n }: ComboBoxProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('ComboBox requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`ComboBox` requires `children` to be a function when using `items` prop');\n }\n\n useImperativeHandle(\n apiRef,\n () => ({\n focus: () => inputRef.current?.focus(),\n select: () => inputRef.current?.select(),\n }),\n [],\n );\n\n const isFieldClearable = isClearable && !props.isDisabled && !isReadOnly;\n\n const listBox = (\n <ComboBoxList<T> items={items} isLoading={isLoading} onLoadMore={onLoadMore} onScroll={onScroll}>\n {children}\n </ComboBoxList>\n );\n\n return (\n <RACComboBox\n {...props}\n ref={ref}\n className={clsx('cim-combo-box', UNSAFE_className)}\n style={UNSAFE_style}\n selectionMode=\"single\"\n value={value}\n defaultValue={defaultValue}\n onChange={onChange}\n selectedKey={selectedKey}\n defaultSelectedKey={defaultSelectedKey}\n onSelectionChange={onSelectionChange}\n menuTrigger=\"focus\"\n isReadOnly={isReadOnly}\n data-readonly={isReadOnly ? true : undefined}\n validate={\n validate\n ? ({ inputValue, value }) => {\n return validate({ inputValue, value, selectedKey: value });\n }\n : undefined\n }\n >\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n <RACGroup className=\"cim-combo-box-input-group\">\n <ComboBoxInput\n inputRef={inputRef}\n isReadOnly={isReadOnly}\n placeholder={placeholder}\n isClearable={isFieldClearable}\n />\n {isFieldClearable && <ComboBoxClearButton onClear={() => inputRef.current?.focus()} />}\n <RACButton className=\"cim-combo-box-button\">\n <IconChevronDown />\n </RACButton>\n </RACGroup>\n <FormFieldError>{error}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n <CollapsibleList\n offset={5} // 1px border + 4px actual offset\n maxHeight={315}\n >\n {isVirtualized ? (\n <RACVirtualizer layout={RACListLayout} layoutOptions={VIRTUAL_LAYOUT_OPTIONS}>\n {listBox}\n </RACVirtualizer>\n ) : (\n listBox\n )}\n </CollapsibleList>\n </RACComboBox>\n );\n}\n\n/**\n * Allows users to filter a collapsible list and select one item from it.\n *\n * See [combo box usage guidelines](https://ui.cimpress.io/components/combo-box)\n */\nconst _ComboBox = withStyleProps(forwardRef(ComboBox), 'ComboBox');\n\nexport { _ComboBox as ComboBox };\n\nfunction ComboBoxClearButton({ onClear }: { onClear?: () => void }) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n const selectMessages = useLocalizedMessages('select');\n const inputValue = comboBoxState?.inputValue;\n\n if (!comboBoxState || inputValue === '') {\n return null;\n }\n\n return (\n <XButton\n onPress={() => {\n comboBoxState.setValue(null);\n onClear?.();\n }}\n iconType=\"circled\"\n aria-label={selectMessages.format('clearSelection')}\n // Prevent this button from acting as a trigger for opening/closing the ComboBox\n slot={null}\n excludeFromTabOrder\n />\n );\n}\n\nfunction ComboBoxInput({\n inputRef,\n isReadOnly,\n placeholder,\n isClearable,\n}: {\n inputRef: MutableRefObject<HTMLInputElement | null>;\n isReadOnly: boolean | undefined;\n placeholder: string | undefined;\n isClearable: boolean;\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n\n return (\n <RACInput\n ref={inputRef}\n className={clsx('cim-combo-box-input', textStyle({ variant: 'body' }))}\n // Ensure the popover opens when the input is clicked.\n // By default, React Aria only opens the popover when the input is focused.\n onClick={() => !isReadOnly && comboBoxState!.open()}\n placeholder={placeholder}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && !comboBoxState?.isOpen && isClearable) {\n comboBoxState?.setValue(null);\n }\n }}\n />\n );\n}\n\nfunction ComboBoxList<T extends CollectionItem = CollectionItem>({\n items,\n children,\n isLoading,\n onLoadMore,\n onScroll,\n}: Pick<ComboBoxProps<T>, 'items' | 'children' | 'onScroll'> & {\n isLoading: ComboBoxProps['UNSTABLE_isLoading'];\n onLoadMore: ComboBoxProps['UNSTABLE_onLoadMore'];\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n const collectionMessages = useLocalizedMessages('UNSTABLE_collection');\n\n usePreventScroll({ isDisabled: !comboBoxState?.isOpen });\n\n return (\n <RACListBox\n className=\"cim-combo-box-listbox\"\n onScroll={onScroll}\n renderEmptyState={() =>\n isLoading ? <Spinner aria-label={collectionMessages.format('loading')} size=\"small\" marginY={8} /> : null\n }\n >\n <RACCollection items={items}>{children}</RACCollection>\n <RACListBoxLoadMoreItem onLoadMore={onLoadMore} isLoading={isLoading}>\n <Spinner aria-label={collectionMessages.format('loadingMore')} size=\"small\" marginY={8} />\n </RACListBoxLoadMoreItem>\n </RACListBox>\n );\n}\n\nexport interface ComboBoxItemProps<T extends CollectionItem> extends Pick<\n RACListBoxItemProps<T>,\n 'isDisabled' | 'onHoverStart' | 'onHoverEnd'\n> {\n /** The ID of the item. Has to be unique across all sections and items. */\n id?: Key;\n /** The content to display as the label. */\n children: StringLikeChildren;\n}\n\n/** Renders a single list item within `ComboBox`. */\nexport function ComboBoxItem<T extends CollectionItem>({ children, ...props }: ComboBoxItemProps<T>) {\n const textValue =\n typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');\n\n return (\n <RACListBoxItem {...props} className=\"cim-combo-box-item\" textValue={textValue}>\n {({ isDisabled }) => (\n <>\n <IconCheckBold />\n\n <RACText slot=\"label\" className={textStyle({ variant: 'body', tone: isDisabled ? 'muted' : 'base' })}>\n {children}\n </RACText>\n </>\n )}\n </RACListBoxItem>\n );\n}\n\nComboBoxItem.displayName = 'ComboBoxItem';\n\nexport interface ComboBoxSectionProps<T extends CollectionItem> extends CollectionProps<T> {\n /** The ID of the section. Has to be unique across all sections and items. */\n id?: Key;\n /** The content to display as the section title. */\n title: string;\n}\n\n/** Groups list items within `ComboBox` into a section. */\nexport function ComboBoxSection<T extends CollectionItem>({\n title,\n children,\n items,\n ...props\n}: ComboBoxSectionProps<T>) {\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`ComboBoxSection` requires `children` to be a function when using `items` prop');\n }\n\n return (\n <RACListBoxSection {...props} className=\"cim-combo-box-section\">\n <RACHeader\n className={clsx('cim-combo-box-section-header', textStyle({ variant: 'small-semibold', tone: 'subtle' }))}\n >\n {title}\n </RACHeader>\n <RACCollection items={items}>{children}</RACCollection>\n </RACListBoxSection>\n );\n}\n\nComboBoxSection.displayName = 'ComboBoxSection';\n"]}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import { type InputProps as RACInputProps } from 'react-aria-components';
|
|
2
|
-
import type { CommonProps } from '../../types.js';
|
|
3
|
-
interface InputProps extends CommonProps, Exclude<RACInputProps, 'className' | 'style'> {
|
|
4
|
-
width?: 'fit-content' | 'full-width';
|
|
5
|
-
}
|
|
6
|
-
export declare function Input(props: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
7
1
|
export {};
|
|
8
2
|
//# sourceMappingURL=input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../../src/components/internal/input/input.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../../src/components/internal/input/input.tsx"],"names":[],"mappings":""}
|
|
@@ -5,32 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Input = Input;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const utils_1 = require("@react-aria/utils");
|
|
9
8
|
const clsx_1 = __importDefault(require("clsx"));
|
|
10
|
-
const react_1 = require("react");
|
|
11
9
|
const react_aria_components_1 = require("react-aria-components");
|
|
12
10
|
const utils_js_1 = require("../../typography/utils.js");
|
|
11
|
+
/**
|
|
12
|
+
* Renders a styled input field.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
13
15
|
function Input(props) {
|
|
14
|
-
const inputRef = (0, react_1.useRef)(null);
|
|
15
16
|
// TODO: find a better way to extract common props, if a new prop is added to `CommonProps` this will break
|
|
16
|
-
const { id, UNSAFE_className, UNSAFE_style, 'data-cim-style-root': dataCimStyleRoot,
|
|
17
|
-
|
|
18
|
-
(0, utils_1.useLayoutEffect)(() => {
|
|
19
|
-
const input = inputRef.current;
|
|
20
|
-
function setInputLengthStyle() {
|
|
21
|
-
// Ensure input value changes are flushed before updating input width, especially in Safari
|
|
22
|
-
requestAnimationFrame(() => input?.style.setProperty('--cim-input-length', input?.value.length.toString() ?? '0'));
|
|
23
|
-
}
|
|
24
|
-
if (input != null) {
|
|
25
|
-
setInputLengthStyle();
|
|
26
|
-
input.addEventListener('input', setInputLengthStyle);
|
|
27
|
-
input.addEventListener('change', setInputLengthStyle);
|
|
28
|
-
}
|
|
29
|
-
return () => {
|
|
30
|
-
input?.removeEventListener('input', setInputLengthStyle);
|
|
31
|
-
input?.removeEventListener('change', setInputLengthStyle);
|
|
32
|
-
};
|
|
33
|
-
}, []);
|
|
34
|
-
return ((0, jsx_runtime_1.jsx)("div", { id: id, className: (0, clsx_1.default)('cim-input', UNSAFE_className), style: UNSAFE_style, "data-cim-style-root": dataCimStyleRoot, children: (0, jsx_runtime_1.jsx)(react_aria_components_1.Input, { ...inputProps, ref: inputRef, className: (0, clsx_1.default)('cim-input-control', (0, utils_js_1.textStyle)({ variant: 'body' })), "data-width": width }) }));
|
|
17
|
+
const { id, UNSAFE_className, UNSAFE_style, 'data-cim-style-root': dataCimStyleRoot, contentWidth, ...inputProps } = props;
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)("div", { id: id, className: (0, clsx_1.default)('cim-input', UNSAFE_className), style: UNSAFE_style, "data-cim-style-root": dataCimStyleRoot, children: (0, jsx_runtime_1.jsx)(react_aria_components_1.Input, { ...inputProps, className: (0, clsx_1.default)('cim-input-control', (0, utils_js_1.textStyle)({ variant: 'body' })), style: { '--cim-input-content-width': contentWidth } }) }));
|
|
35
19
|
}
|
|
36
20
|
//# sourceMappingURL=input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../../../src/components/internal/input/input.tsx"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../../../src/components/internal/input/input.tsx"],"names":[],"mappings":";;;;;AAcA,sBA2BC;;AAzCD,gDAAwB;AAExB,iEAA4F;AAE5F,wDAAsD;AAMtD;;;GAGG;AACH,SAAgB,KAAK,CAAC,KAAiB;IACrC,2GAA2G;IAC3G,MAAM,EACJ,EAAE,EACF,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EAAE,gBAAgB,EAEvC,YAAY,EAEZ,GAAG,UAAU,EACd,GAAG,KAAK,CAAC;IAEV,OAAO,CACL,gCACE,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,IAAA,cAAI,EAAC,WAAW,EAAE,gBAAgB,CAAC,EAC9C,KAAK,EAAE,YAAY,yBACE,gBAAgB,YAErC,uBAAC,6BAAQ,OACH,UAAU,EACd,SAAS,EAAE,IAAA,cAAI,EAAC,mBAAmB,EAAE,IAAA,oBAAS,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,EACpE,KAAK,EAAE,EAAE,2BAA2B,EAAE,YAAY,EAAmB,GACrE,GACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["import clsx from 'clsx';\nimport type { CSSProperties } from 'react';\nimport { Input as RACInput, type InputProps as RACInputProps } from 'react-aria-components';\nimport type { CommonProps } from '../../types.js';\nimport { textStyle } from '../../typography/utils.js';\n\ninterface InputProps extends CommonProps, Exclude<RACInputProps, 'className' | 'style'> {\n contentWidth?: CSSProperties['width'];\n}\n\n/**\n * Renders a styled input field.\n * @internal\n */\nexport function Input(props: InputProps) {\n // TODO: find a better way to extract common props, if a new prop is added to `CommonProps` this will break\n const {\n id,\n UNSAFE_className,\n UNSAFE_style,\n 'data-cim-style-root': dataCimStyleRoot,\n\n contentWidth,\n\n ...inputProps\n } = props;\n\n return (\n <div\n id={id}\n className={clsx('cim-input', UNSAFE_className)}\n style={UNSAFE_style}\n data-cim-style-root={dataCimStyleRoot}\n >\n <RACInput\n {...inputProps}\n className={clsx('cim-input-control', textStyle({ variant: 'body' }))}\n style={{ '--cim-input-content-width': contentWidth } as CSSProperties}\n />\n </div>\n );\n}\n"]}
|