@cimpress-ui/react 1.7.1 → 1.8.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/commonjs/components/app-header/app-header.d.ts.map +1 -1
- package/dist/commonjs/components/app-header/app-header.js +1 -1
- package/dist/commonjs/components/app-header/app-header.js.map +1 -1
- package/dist/commonjs/components/app-header/side-nav.d.ts +4 -5
- package/dist/commonjs/components/app-header/side-nav.d.ts.map +1 -1
- package/dist/commonjs/components/app-header/side-nav.js +3 -2
- package/dist/commonjs/components/app-header/side-nav.js.map +1 -1
- package/dist/commonjs/components/combo-box/combo-box.d.ts +16 -4
- package/dist/commonjs/components/combo-box/combo-box.d.ts.map +1 -1
- package/dist/commonjs/components/combo-box/combo-box.js +9 -4
- package/dist/commonjs/components/combo-box/combo-box.js.map +1 -1
- package/dist/commonjs/components/copy/copy-button.d.ts +20 -0
- package/dist/commonjs/components/copy/copy-button.d.ts.map +1 -0
- package/dist/commonjs/components/copy/copy-button.js +68 -0
- package/dist/commonjs/components/copy/copy-button.js.map +1 -0
- package/dist/commonjs/components/copy/inline-copy.d.ts +12 -0
- package/dist/commonjs/components/copy/inline-copy.d.ts.map +1 -0
- package/dist/commonjs/components/copy/inline-copy.js +33 -0
- package/dist/commonjs/components/copy/inline-copy.js.map +1 -0
- package/dist/commonjs/components/copy/use-copy.d.ts +10 -0
- package/dist/commonjs/components/copy/use-copy.d.ts.map +1 -0
- package/dist/commonjs/components/copy/use-copy.js +30 -0
- package/dist/commonjs/components/copy/use-copy.js.map +1 -0
- package/dist/commonjs/components/date-picker/date-picker.d.ts +7 -2
- package/dist/commonjs/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/commonjs/components/date-picker/date-picker.js +6 -2
- package/dist/commonjs/components/date-picker/date-picker.js.map +1 -1
- package/dist/commonjs/components/date-picker/views/multi-year/use-multi-year-view-state.js +4 -7
- package/dist/commonjs/components/date-picker/views/multi-year/use-multi-year-view-state.js.map +1 -1
- package/dist/commonjs/components/disclosure/disclosure-group.d.ts +4 -2
- package/dist/commonjs/components/disclosure/disclosure-group.d.ts.map +1 -1
- package/dist/commonjs/components/disclosure/disclosure-group.js.map +1 -1
- package/dist/commonjs/components/disclosure/disclosure.d.ts +4 -2
- package/dist/commonjs/components/disclosure/disclosure.d.ts.map +1 -1
- package/dist/commonjs/components/disclosure/disclosure.js.map +1 -1
- package/dist/commonjs/components/link-tabs/link-tabs.d.ts.map +1 -1
- package/dist/commonjs/components/link-tabs/link-tabs.js +1 -1
- package/dist/commonjs/components/link-tabs/link-tabs.js.map +1 -1
- package/dist/commonjs/components/menu/menu.d.ts +5 -3
- package/dist/commonjs/components/menu/menu.d.ts.map +1 -1
- package/dist/commonjs/components/menu/menu.js.map +1 -1
- package/dist/commonjs/components/number-field/number-field.d.ts +9 -2
- package/dist/commonjs/components/number-field/number-field.d.ts.map +1 -1
- package/dist/commonjs/components/number-field/number-field.js +8 -2
- package/dist/commonjs/components/number-field/number-field.js.map +1 -1
- package/dist/commonjs/components/select/select.d.ts +20 -4
- package/dist/commonjs/components/select/select.d.ts.map +1 -1
- package/dist/commonjs/components/select/select.js +9 -3
- package/dist/commonjs/components/select/select.js.map +1 -1
- package/dist/commonjs/components/spacing/types.d.ts.map +1 -1
- package/dist/commonjs/components/spacing/types.js +6 -4
- package/dist/commonjs/components/spacing/types.js.map +1 -1
- package/dist/commonjs/components/stepper/context.d.ts +2 -0
- package/dist/commonjs/components/stepper/context.d.ts.map +1 -1
- package/dist/commonjs/components/stepper/context.js +2 -0
- package/dist/commonjs/components/stepper/context.js.map +1 -1
- package/dist/commonjs/components/stepper/stepper-item.d.ts.map +1 -1
- package/dist/commonjs/components/stepper/stepper-item.js +3 -2
- package/dist/commonjs/components/stepper/stepper-item.js.map +1 -1
- package/dist/commonjs/components/stepper/stepper.d.ts.map +1 -1
- package/dist/commonjs/components/stepper/stepper.js +14 -8
- package/dist/commonjs/components/stepper/stepper.js.map +1 -1
- package/dist/commonjs/components/table/contexts/column-collection.d.ts.map +1 -1
- package/dist/commonjs/components/table/contexts/column-collection.js +0 -1
- package/dist/commonjs/components/table/contexts/column-collection.js.map +1 -1
- package/dist/commonjs/components/table/contexts/row-state.js.map +1 -1
- package/dist/commonjs/components/table/contexts/table-state.js.map +1 -1
- package/dist/commonjs/components/table/hooks/use-table-cell.js.map +1 -1
- package/dist/commonjs/components/tabs/tabs.d.ts +3 -1
- package/dist/commonjs/components/tabs/tabs.d.ts.map +1 -1
- package/dist/commonjs/components/tabs/tabs.js.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field-input.js +2 -2
- package/dist/commonjs/components/tag-field/tag-field-input.js.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field-list-box.js +5 -2
- package/dist/commonjs/components/tag-field/tag-field-list-box.js.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field-tags.js +2 -0
- package/dist/commonjs/components/tag-field/tag-field-tags.js.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field.d.ts +14 -4
- package/dist/commonjs/components/tag-field/tag-field.d.ts.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field.js +7 -3
- package/dist/commonjs/components/tag-field/tag-field.js.map +1 -1
- package/dist/commonjs/components/text-inputs/search-field.d.ts +9 -2
- package/dist/commonjs/components/text-inputs/search-field.d.ts.map +1 -1
- package/dist/commonjs/components/text-inputs/search-field.js +5 -1
- package/dist/commonjs/components/text-inputs/search-field.js.map +1 -1
- package/dist/commonjs/components/text-inputs/text-area.d.ts +15 -5
- package/dist/commonjs/components/text-inputs/text-area.d.ts.map +1 -1
- package/dist/commonjs/components/text-inputs/text-area.js.map +1 -1
- package/dist/commonjs/components/text-inputs/text-field.d.ts +2 -5
- package/dist/commonjs/components/text-inputs/text-field.d.ts.map +1 -1
- package/dist/commonjs/components/text-inputs/text-field.js.map +1 -1
- package/dist/commonjs/components/toggle-button/internal-toggle-button.js +7 -7
- package/dist/commonjs/components/toggle-button/internal-toggle-button.js.map +1 -1
- package/dist/commonjs/components/toggle-button/toggle-button-group.d.ts.map +1 -1
- package/dist/commonjs/components/toggle-button/toggle-button-group.js +3 -0
- package/dist/commonjs/components/toggle-button/toggle-button-group.js.map +1 -1
- package/dist/commonjs/components/top-nav/top-nav.d.ts +12 -0
- package/dist/commonjs/components/top-nav/top-nav.d.ts.map +1 -0
- package/dist/commonjs/components/top-nav/top-nav.js +18 -0
- package/dist/commonjs/components/top-nav/top-nav.js.map +1 -0
- package/dist/commonjs/components/types.d.ts +6 -1
- package/dist/commonjs/components/types.d.ts.map +1 -1
- package/dist/commonjs/components/types.js.map +1 -1
- package/dist/commonjs/index.d.ts +3 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +3 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/utils/string-like-children-to-string.d.ts +3 -0
- package/dist/commonjs/utils/string-like-children-to-string.d.ts.map +1 -0
- package/dist/commonjs/utils/string-like-children-to-string.js +7 -0
- package/dist/commonjs/utils/string-like-children-to-string.js.map +1 -0
- package/dist/esm/components/app-header/app-header.d.ts.map +1 -1
- package/dist/esm/components/app-header/app-header.js +1 -1
- package/dist/esm/components/app-header/app-header.js.map +1 -1
- package/dist/esm/components/app-header/side-nav.d.ts +4 -5
- package/dist/esm/components/app-header/side-nav.d.ts.map +1 -1
- package/dist/esm/components/app-header/side-nav.js +3 -2
- package/dist/esm/components/app-header/side-nav.js.map +1 -1
- package/dist/esm/components/combo-box/combo-box.d.ts +16 -4
- package/dist/esm/components/combo-box/combo-box.d.ts.map +1 -1
- package/dist/esm/components/combo-box/combo-box.js +10 -5
- package/dist/esm/components/combo-box/combo-box.js.map +1 -1
- package/dist/esm/components/copy/copy-button.d.ts +20 -0
- package/dist/esm/components/copy/copy-button.d.ts.map +1 -0
- package/dist/esm/components/copy/copy-button.js +65 -0
- package/dist/esm/components/copy/copy-button.js.map +1 -0
- package/dist/esm/components/copy/inline-copy.d.ts +12 -0
- package/dist/esm/components/copy/inline-copy.d.ts.map +1 -0
- package/dist/esm/components/copy/inline-copy.js +27 -0
- package/dist/esm/components/copy/inline-copy.js.map +1 -0
- package/dist/esm/components/copy/use-copy.d.ts +10 -0
- package/dist/esm/components/copy/use-copy.d.ts.map +1 -0
- package/dist/esm/components/copy/use-copy.js +27 -0
- package/dist/esm/components/copy/use-copy.js.map +1 -0
- package/dist/esm/components/date-picker/date-picker.d.ts +7 -2
- package/dist/esm/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/esm/components/date-picker/date-picker.js +7 -3
- package/dist/esm/components/date-picker/date-picker.js.map +1 -1
- package/dist/esm/components/date-picker/views/multi-year/use-multi-year-view-state.js +4 -7
- package/dist/esm/components/date-picker/views/multi-year/use-multi-year-view-state.js.map +1 -1
- package/dist/esm/components/disclosure/disclosure-group.d.ts +4 -2
- package/dist/esm/components/disclosure/disclosure-group.d.ts.map +1 -1
- package/dist/esm/components/disclosure/disclosure-group.js.map +1 -1
- package/dist/esm/components/disclosure/disclosure.d.ts +4 -2
- package/dist/esm/components/disclosure/disclosure.d.ts.map +1 -1
- package/dist/esm/components/disclosure/disclosure.js.map +1 -1
- package/dist/esm/components/link-tabs/link-tabs.d.ts.map +1 -1
- package/dist/esm/components/link-tabs/link-tabs.js +1 -1
- package/dist/esm/components/link-tabs/link-tabs.js.map +1 -1
- package/dist/esm/components/menu/menu.d.ts +5 -3
- package/dist/esm/components/menu/menu.d.ts.map +1 -1
- package/dist/esm/components/menu/menu.js.map +1 -1
- package/dist/esm/components/number-field/number-field.d.ts +9 -2
- package/dist/esm/components/number-field/number-field.d.ts.map +1 -1
- package/dist/esm/components/number-field/number-field.js +8 -2
- package/dist/esm/components/number-field/number-field.js.map +1 -1
- package/dist/esm/components/select/select.d.ts +20 -4
- package/dist/esm/components/select/select.d.ts.map +1 -1
- package/dist/esm/components/select/select.js +9 -3
- package/dist/esm/components/select/select.js.map +1 -1
- package/dist/esm/components/spacing/types.d.ts.map +1 -1
- package/dist/esm/components/spacing/types.js +6 -4
- package/dist/esm/components/spacing/types.js.map +1 -1
- package/dist/esm/components/stepper/context.d.ts +2 -0
- package/dist/esm/components/stepper/context.d.ts.map +1 -1
- package/dist/esm/components/stepper/context.js +2 -0
- package/dist/esm/components/stepper/context.js.map +1 -1
- package/dist/esm/components/stepper/stepper-item.d.ts.map +1 -1
- package/dist/esm/components/stepper/stepper-item.js +3 -2
- package/dist/esm/components/stepper/stepper-item.js.map +1 -1
- package/dist/esm/components/stepper/stepper.d.ts.map +1 -1
- package/dist/esm/components/stepper/stepper.js +15 -9
- package/dist/esm/components/stepper/stepper.js.map +1 -1
- package/dist/esm/components/table/contexts/column-collection.d.ts.map +1 -1
- package/dist/esm/components/table/contexts/column-collection.js +0 -1
- package/dist/esm/components/table/contexts/column-collection.js.map +1 -1
- package/dist/esm/components/table/contexts/row-state.js +2 -2
- package/dist/esm/components/table/contexts/row-state.js.map +1 -1
- package/dist/esm/components/table/contexts/table-state.js +2 -2
- package/dist/esm/components/table/contexts/table-state.js.map +1 -1
- package/dist/esm/components/table/hooks/use-table-cell.js +2 -2
- package/dist/esm/components/table/hooks/use-table-cell.js.map +1 -1
- package/dist/esm/components/tabs/tabs.d.ts +3 -1
- package/dist/esm/components/tabs/tabs.d.ts.map +1 -1
- package/dist/esm/components/tabs/tabs.js.map +1 -1
- package/dist/esm/components/tag-field/tag-field-input.js +2 -2
- package/dist/esm/components/tag-field/tag-field-input.js.map +1 -1
- package/dist/esm/components/tag-field/tag-field-list-box.js +5 -2
- package/dist/esm/components/tag-field/tag-field-list-box.js.map +1 -1
- package/dist/esm/components/tag-field/tag-field-tags.js +2 -0
- package/dist/esm/components/tag-field/tag-field-tags.js.map +1 -1
- package/dist/esm/components/tag-field/tag-field.d.ts +14 -4
- package/dist/esm/components/tag-field/tag-field.d.ts.map +1 -1
- package/dist/esm/components/tag-field/tag-field.js +8 -4
- package/dist/esm/components/tag-field/tag-field.js.map +1 -1
- package/dist/esm/components/text-inputs/search-field.d.ts +9 -2
- package/dist/esm/components/text-inputs/search-field.d.ts.map +1 -1
- package/dist/esm/components/text-inputs/search-field.js +6 -2
- package/dist/esm/components/text-inputs/search-field.js.map +1 -1
- package/dist/esm/components/text-inputs/text-area.d.ts +15 -5
- package/dist/esm/components/text-inputs/text-area.d.ts.map +1 -1
- package/dist/esm/components/text-inputs/text-area.js +1 -1
- package/dist/esm/components/text-inputs/text-area.js.map +1 -1
- package/dist/esm/components/text-inputs/text-field.d.ts +2 -5
- package/dist/esm/components/text-inputs/text-field.d.ts.map +1 -1
- package/dist/esm/components/text-inputs/text-field.js.map +1 -1
- package/dist/esm/components/toggle-button/internal-toggle-button.js +7 -7
- package/dist/esm/components/toggle-button/internal-toggle-button.js.map +1 -1
- package/dist/esm/components/toggle-button/toggle-button-group.d.ts.map +1 -1
- package/dist/esm/components/toggle-button/toggle-button-group.js +3 -0
- package/dist/esm/components/toggle-button/toggle-button-group.js.map +1 -1
- package/dist/esm/components/top-nav/top-nav.d.ts +12 -0
- package/dist/esm/components/top-nav/top-nav.d.ts.map +1 -0
- package/dist/esm/components/top-nav/top-nav.js +11 -0
- package/dist/esm/components/top-nav/top-nav.js.map +1 -0
- package/dist/esm/components/types.d.ts +6 -1
- package/dist/esm/components/types.d.ts.map +1 -1
- package/dist/esm/components/types.js.map +1 -1
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/string-like-children-to-string.d.ts +3 -0
- package/dist/esm/utils/string-like-children-to-string.d.ts.map +1 -0
- package/dist/esm/utils/string-like-children-to-string.js +4 -0
- package/dist/esm/utils/string-like-children-to-string.js.map +1 -0
- package/dist-styles/core.css +1 -1
- package/dist-styles/normalize.css +1 -1
- package/dist-styles/styles.css +1 -1
- package/package.json +17 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-header.d.ts","sourceRoot":"","sources":["../../../../src/components/app-header/app-header.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAGrD,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKpF,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;CAChC;
|
|
1
|
+
{"version":3,"file":"app-header.d.ts","sourceRoot":"","sources":["../../../../src/components/app-header/app-header.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAGrD,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKpF,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;CAChC;AA0BD;;;;GAIG;AACH,QAAA,MAAM,UAAU,+GAAqC,CAAC;AAEtD,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,CAAC"}
|
|
@@ -14,7 +14,7 @@ const text_js_1 = require("../typography/text.js");
|
|
|
14
14
|
const cimpress_logo_js_1 = require("./cimpress-logo.js");
|
|
15
15
|
function AppHeader({ title, titleLink, tools, UNSTABLE_navButton: navButton, UNSAFE_className, UNSAFE_style, ...props }, ref) {
|
|
16
16
|
const titleLinkProps = typeof titleLink === 'object' && 'href' in titleLink ? titleLink : { href: titleLink };
|
|
17
|
-
return ((0, jsx_runtime_1.
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)("header", { ...props, ref: ref, className: (0, clsx_1.default)('cim-app-header', UNSAFE_className), style: UNSAFE_style, children: [navButton, (0, jsx_runtime_1.jsxs)("div", { className: "cim-app-header-title", children: [(0, jsx_runtime_1.jsx)(cimpress_logo_js_1.CimpressLogo, { height: 18 }), (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 }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "cim-app-header-tools", children: tools })] }));
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* 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;AAExB,yDAAkD;AAClD,sDAAgD;AAEhD,mDAA6C;AAC7C,mDAA6C;AAC7C,yDAAkD;AAclD,SAAS,SAAS,CAChB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,KAAK,EAAkB,EACpH,GAAiC;IAEjC,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,
|
|
1
|
+
{"version":3,"file":"app-header.js","sourceRoot":"","sources":["../../../../src/components/app-header/app-header.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AAExB,yDAAkD;AAClD,sDAAgD;AAEhD,mDAA6C;AAC7C,mDAA6C;AAC7C,yDAAkD;AAclD,SAAS,SAAS,CAChB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,KAAK,EAAkB,EACpH,GAAiC;IAEjC,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,uCAAY,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAA,cAAI,EAAC,gBAAgB,EAAE,gBAAgB,CAAC,EAAE,KAAK,EAAE,YAAY,aAClG,SAAS,EACV,iCAAK,SAAS,EAAC,sBAAsB,aACnC,uBAAC,+BAAY,IAAC,MAAM,EAAE,EAAE,GAAI,EAC5B,uBAAC,oBAAO,IAAC,WAAW,EAAC,UAAU,GAAG,EAClC,uBAAC,cAAI,IAAC,EAAE,EAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,MAAM,YACzC,uBAAC,cAAI,OAAK,cAAc,EAAE,gBAAgB,EAAC,2BAA2B,YACnE,KAAK,GACD,GACF,IACH,EAEN,gCAAK,SAAS,EAAC,sBAAsB,YAAE,KAAK,GAAO,IAC5C,CACV,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,GAAG,IAAA,2BAAU,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAE/B,+BAAS","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport type { ForwardedRef, ReactNode } from 'react';\nimport { forwardRef } from '../../forward-ref.js';\nimport { Divider } from '../divider/divider.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';\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}\n\nfunction AppHeader(\n { title, titleLink, tools, UNSTABLE_navButton: navButton, UNSAFE_className, UNSAFE_style, ...props }: AppHeaderProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const titleLinkProps = typeof titleLink === 'object' && 'href' in titleLink ? titleLink : { href: titleLink };\n\n return (\n <header {...props} ref={ref} className={clsx('cim-app-header', UNSAFE_className)} style={UNSAFE_style}>\n {navButton}\n <div className=\"cim-app-header-title\">\n <CimpressLogo height={18} />\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 </div>\n\n <div className=\"cim-app-header-tools\">{tools}</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,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import type { Href } from '../types.js';
|
|
2
|
+
import type { Href, StringLikeChildren } from '../types.js';
|
|
3
3
|
export interface UNSTABLE_SideNavProps {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
isOpen?: boolean;
|
|
@@ -18,17 +18,16 @@ export interface UNSTABLE_SideNavListProps {
|
|
|
18
18
|
children: ReactNode;
|
|
19
19
|
}
|
|
20
20
|
export declare function UNSTABLE_SideNavList({ children }: UNSTABLE_SideNavListProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
-
interface
|
|
22
|
-
|
|
21
|
+
export interface UNSTABLE_SideNavListItemProps {
|
|
22
|
+
children: StringLikeChildren;
|
|
23
23
|
href: Href;
|
|
24
24
|
isActive?: boolean;
|
|
25
25
|
icon?: ReactNode;
|
|
26
26
|
}
|
|
27
|
-
export declare function UNSTABLE_SideNavListItem({
|
|
27
|
+
export declare function UNSTABLE_SideNavListItem({ children, href, isActive, icon }: UNSTABLE_SideNavListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
28
28
|
export interface UNSTABLE_SideNavListSectionProps {
|
|
29
29
|
children: ReactNode;
|
|
30
30
|
label?: string;
|
|
31
31
|
}
|
|
32
32
|
export declare function UNSTABLE_SideNavListSection({ children, label }: UNSTABLE_SideNavListSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
-
export {};
|
|
34
33
|
//# sourceMappingURL=side-nav.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side-nav.d.ts","sourceRoot":"","sources":["../../../../src/components/app-header/side-nav.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"side-nav.d.ts","sourceRoot":"","sources":["../../../../src/components/app-header/side-nav.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AASlE,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAK5D,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;CAC/B;AAED,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,OAAiB,EAAE,EAAE,qBAAqB,2CA6B5G;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,EAAE,yBAAyB,2CAE3E;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,wBAAgB,wBAAwB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,6BAA6B,2CAazG;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,2BAA2B,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,gCAAgC,2CAehG"}
|
|
@@ -9,6 +9,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
9
9
|
const react_1 = require("react");
|
|
10
10
|
const react_aria_components_1 = require("react-aria-components");
|
|
11
11
|
const index_js_1 = require("../../icons/index.js");
|
|
12
|
+
const string_like_children_to_string_js_1 = require("../../utils/string-like-children-to-string.js");
|
|
12
13
|
const use_is_mobile_js_1 = require("../../utils/use-is-mobile.js");
|
|
13
14
|
const icon_button_js_1 = require("../button/icon-button.js");
|
|
14
15
|
const drawer_js_1 = require("../drawer/drawer.js");
|
|
@@ -24,9 +25,9 @@ function UNSTABLE_SideNav({ children, isOpen, onOpenChange, variant = 'fixed' })
|
|
|
24
25
|
function UNSTABLE_SideNavList({ children }) {
|
|
25
26
|
return (0, jsx_runtime_1.jsx)("div", { className: "cim-side-nav-list", children: children });
|
|
26
27
|
}
|
|
27
|
-
function UNSTABLE_SideNavListItem({
|
|
28
|
+
function UNSTABLE_SideNavListItem({ children, href, isActive, icon }) {
|
|
28
29
|
const { isOpen } = (0, react_1.useContext)(SideNavContext);
|
|
29
|
-
return ((0, jsx_runtime_1.jsx)(tooltip_js_1.Tooltip, { label:
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)(tooltip_js_1.Tooltip, { label: (0, string_like_children_to_string_js_1.stringLikeChildrenToString)(children), placement: "right", isDisabled: isOpen, children: (0, jsx_runtime_1.jsxs)(react_aria_components_1.Link, { href: href, className: "cim-side-nav-list-item", "data-active": isActive, "data-expanded": isOpen, children: [icon, (0, jsx_runtime_1.jsx)(text_js_1.Text, { as: "span", variant: "medium", UNSAFE_className: "cim-side-nav-list-item-label", children: children })] }) }));
|
|
30
31
|
}
|
|
31
32
|
function UNSTABLE_SideNavListSection({ children, label }) {
|
|
32
33
|
const { isOpen } = (0, react_1.useContext)(SideNavContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side-nav.js","sourceRoot":"","sources":["../../../../src/components/app-header/side-nav.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;
|
|
1
|
+
{"version":3,"file":"side-nav.js","sourceRoot":"","sources":["../../../../src/components/app-header/side-nav.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AA8Bb,4CA6BC;AAMD,oDAEC;AASD,4DAaC;AAOD,kEAeC;;AA7GD,iCAAkE;AAClE,iEAAwD;AACxD,mDAA2D;AAC3D,qGAA2F;AAC3F,mEAA2D;AAC3D,6DAAsD;AACtD,mDAAyD;AACzD,mDAAsD;AACtD,sDAAgD;AAEhD,mDAA6C;AAE7C,MAAM,cAAc,GAAG,IAAA,qBAAa,EAAsB,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AAgB7E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B,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAiC;IACxG,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAU,EAAC,cAAc,CAAC,CAAC;IAE9C,OAAO,CACL,uBAAC,oBAAO,IAAC,KAAK,EAAE,IAAA,8DAA0B,EAAC,QAAQ,CAAC,EAAE,SAAS,EAAC,OAAO,EAAC,UAAU,EAAE,MAAM,YACxF,wBAAC,4BAAO,IAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAC,wBAAwB,iBAAc,QAAQ,mBAAiB,MAAM,aACjG,IAAI,EACL,uBAAC,cAAI,IAAC,EAAE,EAAC,MAAM,EAAC,OAAO,EAAC,QAAQ,EAAC,gBAAgB,EAAC,8BAA8B,YAC7E,QAAQ,GACJ,IACC,GACF,CACX,CAAC;AACJ,CAAC;AAOD,SAAgB,2BAA2B,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAoC;IAC/F,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAU,EAAC,cAAc,CAAC,CAAC;IAE9C,OAAO,CACL,iCAAK,SAAS,EAAC,2BAA2B,mBAAgB,MAAM,aAC7D,KAAK,IAAI,CACR,gCAAK,SAAS,EAAC,kCAAkC,YAC/C,uBAAC,cAAI,IAAC,EAAE,EAAC,GAAG,EAAC,OAAO,EAAC,gBAAgB,EAAC,IAAI,EAAC,QAAQ,EAAC,gBAAgB,EAAC,wCAAwC,YAC1G,KAAK,GACD,GACH,CACP,EACA,QAAQ,IACL,CACP,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { createContext, useContext, type ReactNode } from 'react';\nimport { Link as RACLink } from 'react-aria-components';\nimport { UNSTABLE_IconExpand } from '../../icons/index.js';\nimport { stringLikeChildrenToString } from '../../utils/string-like-children-to-string.js';\nimport { useIsMobile } from '../../utils/use-is-mobile.js';\nimport { IconButton } from '../button/icon-button.js';\nimport { Drawer, DrawerBody } from '../drawer/drawer.js';\nimport { UNSTABLE_Hidden } from '../hidden/hidden.js';\nimport { Tooltip } from '../tooltip/tooltip.js';\nimport type { Href, StringLikeChildren } from '../types.js';\nimport { Text } from '../typography/text.js';\n\nconst SideNavContext = createContext<{ isOpen: boolean }>({ isOpen: false });\n\nexport interface UNSTABLE_SideNavProps {\n children: ReactNode;\n isOpen?: boolean;\n onOpenChange?: (isOpen: boolean) => void;\n /**\n * Determines how the side nav is displayed and behaves.\n * - `overlay`: The side nav slides in as an overlay on top of the main content. This is used when all available screen space is needed for the main content.\n * - `fixed`: The side nav is fixed to the side and includes an expand button to toggle between a compact icon-only view and an expanded view showing labels. On smaller screens, it slides in as an overlay.\n *\n * @default 'fixed'\n */\n variant?: 'overlay' | 'fixed';\n}\n\nexport function UNSTABLE_SideNav({ children, isOpen, onOpenChange, variant = 'fixed' }: UNSTABLE_SideNavProps) {\n const isMobile = useIsMobile();\n\n const drawer = (isMobile || variant === 'overlay') && (\n <Drawer UNSTABLE_placement=\"start\" isOpen={isOpen} onOpenChange={onOpenChange} aria-label=\"Side navigation\">\n <DrawerBody>{children}</DrawerBody>\n </Drawer>\n );\n\n return (\n <SideNavContext.Provider value={{ isOpen: isOpen ?? false }}>\n {drawer}\n {variant === 'fixed' && (\n <UNSTABLE_Hidden hide={{ sm: true, md: false }}>\n <div className=\"cim-side-nav\" data-expanded={isOpen}>\n <div className=\"cim-side-nav-header\">\n <IconButton\n variant=\"tertiary\"\n icon={<UNSTABLE_IconExpand UNSAFE_style={isOpen ? { transform: 'rotate(180deg)' } : {}} />}\n aria-label=\"Expand sidebar\"\n onPress={() => onOpenChange?.(!isOpen)}\n />\n </div>\n <div className=\"cim-side-nav-list-container\">{children}</div>\n </div>\n </UNSTABLE_Hidden>\n )}\n </SideNavContext.Provider>\n );\n}\n\nexport interface UNSTABLE_SideNavListProps {\n children: ReactNode;\n}\n\nexport function UNSTABLE_SideNavList({ children }: UNSTABLE_SideNavListProps) {\n return <div className=\"cim-side-nav-list\">{children}</div>;\n}\n\nexport interface UNSTABLE_SideNavListItemProps {\n children: StringLikeChildren;\n href: Href;\n isActive?: boolean;\n icon?: ReactNode;\n}\n\nexport function UNSTABLE_SideNavListItem({ children, href, isActive, icon }: UNSTABLE_SideNavListItemProps) {\n const { isOpen } = useContext(SideNavContext);\n\n return (\n <Tooltip label={stringLikeChildrenToString(children)} placement=\"right\" isDisabled={isOpen}>\n <RACLink href={href} className=\"cim-side-nav-list-item\" data-active={isActive} data-expanded={isOpen}>\n {icon}\n <Text as=\"span\" variant=\"medium\" UNSAFE_className=\"cim-side-nav-list-item-label\">\n {children}\n </Text>\n </RACLink>\n </Tooltip>\n );\n}\n\nexport interface UNSTABLE_SideNavListSectionProps {\n children: ReactNode;\n label?: string;\n}\n\nexport function UNSTABLE_SideNavListSection({ children, label }: UNSTABLE_SideNavListSectionProps) {\n const { isOpen } = useContext(SideNavContext);\n\n return (\n <div className=\"cim-side-nav-list-section\" data-expanded={isOpen}>\n {label && (\n <div className=\"cim-side-nav-list-section-header\">\n <Text as=\"p\" variant=\"small-semibold\" tone=\"subtle\" UNSAFE_className=\"cim-side-nav-list-section-header-label\">\n {label}\n </Text>\n </div>\n )}\n {children}\n </div>\n );\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type
|
|
1
|
+
import { type UIEventHandler } from 'react';
|
|
2
|
+
import { type ComboBoxProps as RACComboBoxProps, type ListBoxItemProps as RACListBoxItemProps } from 'react-aria-components';
|
|
3
|
+
import type { ApiProps, AsyncItemLoadingProps, CollectionItem, CollectionProps, CommonProps, FieldWithPlaceholderProps, Key, StringLikeChildren } from '../types.js';
|
|
3
4
|
/** Represents the state of the `ComboBox` component for validation purposes. */
|
|
4
5
|
export interface ComboBoxValidationValue {
|
|
5
6
|
/** The selected key in the ComboBox. */
|
|
@@ -7,12 +8,21 @@ export interface ComboBoxValidationValue {
|
|
|
7
8
|
/** The value of the ComboBox input. */
|
|
8
9
|
inputValue: string;
|
|
9
10
|
}
|
|
10
|
-
export interface ComboBoxProps<T extends CollectionItem = CollectionItem> extends CommonProps, FieldWithPlaceholderProps<ComboBoxValidationValue>, CollectionProps<T>, AsyncItemLoadingProps, Pick<RACComboBoxProps<T>, 'isDisabled' | 'isRequired' | 'isInvalid' | 'isReadOnly' | 'selectedKey' | 'defaultSelectedKey' | 'inputValue' | 'defaultInputValue' | 'autoFocus' | 'onSelectionChange' | 'onInputChange' | 'onFocus' | 'onBlur' | 'onOpenChange'
|
|
11
|
+
export interface ComboBoxProps<T extends CollectionItem = CollectionItem> extends CommonProps, FieldWithPlaceholderProps<ComboBoxValidationValue>, CollectionProps<T>, AsyncItemLoadingProps, ApiProps<ComboBoxApi>, Pick<RACComboBoxProps<T>, 'isDisabled' | 'isRequired' | 'isInvalid' | 'isReadOnly' | 'selectedKey' | 'defaultSelectedKey' | 'inputValue' | 'defaultInputValue' | 'autoFocus' | 'onSelectionChange' | 'onInputChange' | 'onFocus' | 'onBlur' | 'onOpenChange'> {
|
|
11
12
|
/**
|
|
12
13
|
* Whether the list of options should be virtualized. Use this as a performance optimization for large lists.
|
|
13
14
|
* @default false
|
|
14
15
|
*/
|
|
15
16
|
isVirtualized?: boolean;
|
|
17
|
+
/** Handler that is called when the list of items is scrolled. */
|
|
18
|
+
onScroll?: UIEventHandler<HTMLDivElement>;
|
|
19
|
+
}
|
|
20
|
+
/** The imperative API exposed by the `ComboBox` component. */
|
|
21
|
+
export interface ComboBoxApi {
|
|
22
|
+
/** Focuses the input field and opens the list of items. */
|
|
23
|
+
focus: () => void;
|
|
24
|
+
/** Selects the contents of the input field. */
|
|
25
|
+
select: () => void;
|
|
16
26
|
}
|
|
17
27
|
/**
|
|
18
28
|
* Allows users to filter a collapsible list and select one item from it.
|
|
@@ -21,7 +31,9 @@ export interface ComboBoxProps<T extends CollectionItem = CollectionItem> extend
|
|
|
21
31
|
*/
|
|
22
32
|
declare const _ComboBox: <T extends CollectionItem>(props: ComboBoxProps<T> & import("react").RefAttributes<HTMLDivElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
23
33
|
export { _ComboBox as ComboBox };
|
|
24
|
-
export interface ComboBoxItemProps<T extends CollectionItem> extends Pick<RACListBoxItemProps<T>, '
|
|
34
|
+
export interface ComboBoxItemProps<T extends CollectionItem> extends Pick<RACListBoxItemProps<T>, 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {
|
|
35
|
+
/** The ID of the item. Has to be unique across all sections and items. */
|
|
36
|
+
id?: Key;
|
|
25
37
|
/** The content to display as the label. */
|
|
26
38
|
children: StringLikeChildren;
|
|
27
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo-box.d.ts","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"
|
|
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;AAU/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,wCAAwC;IACxC,WAAW,EAAE,GAAG,GAAG,IAAI,CAAC;IACxB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,CACtE,SAAQ,WAAW,EACjB,yBAAyB,CAAC,uBAAuB,CAAC,EAClD,eAAe,CAAC,CAAC,CAAC,EAClB,qBAAqB,EACrB,QAAQ,CAAC,WAAW,CAAC,EACr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AA0D;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"}
|
|
@@ -29,7 +29,8 @@ const VIRTUAL_LAYOUT_OPTIONS = {
|
|
|
29
29
|
padding: 0,
|
|
30
30
|
gap: 0,
|
|
31
31
|
};
|
|
32
|
-
function ComboBox({ label, description, error, items, children, placeholder, UNSAFE_className, UNSAFE_style, isReadOnly, onScroll, isVirtualized = false, UNSTABLE_isLoading: isLoading, UNSTABLE_onLoadMore: onLoadMore, ...props }, ref) {
|
|
32
|
+
function ComboBox({ label, description, error, items, children, placeholder, UNSAFE_className, UNSAFE_style, isReadOnly, onScroll, isVirtualized = false, UNSTABLE_isLoading: isLoading, UNSTABLE_onLoadMore: onLoadMore, apiRef, ...props }, ref) {
|
|
33
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
33
34
|
const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;
|
|
34
35
|
(0, use_production_warning_js_1.useProductionWarning)(() => {
|
|
35
36
|
if (!label && !ariaLabel && !ariaLabelledBy) {
|
|
@@ -39,8 +40,12 @@ function ComboBox({ label, description, error, items, children, placeholder, UNS
|
|
|
39
40
|
if (!(0, is_production_js_1.isProduction)() && items != null && typeof children !== 'function') {
|
|
40
41
|
console.warn('`ComboBox` requires `children` to be a function when using `items` prop');
|
|
41
42
|
}
|
|
43
|
+
(0, react_1.useImperativeHandle)(apiRef, () => ({
|
|
44
|
+
focus: () => inputRef.current?.focus(),
|
|
45
|
+
select: () => inputRef.current?.select(),
|
|
46
|
+
}), []);
|
|
42
47
|
const listBox = ((0, jsx_runtime_1.jsx)(ComboBoxList, { items: items, isLoading: isLoading, onLoadMore: onLoadMore, onScroll: onScroll, children: children }));
|
|
43
|
-
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, menuTrigger: "focus", isReadOnly: isReadOnly, "data-readonly": isReadOnly ? true : 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, { isReadOnly: isReadOnly, placeholder: placeholder }), (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) })] }));
|
|
48
|
+
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, menuTrigger: "focus", isReadOnly: isReadOnly, "data-readonly": isReadOnly ? true : 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 }), (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) })] }));
|
|
44
49
|
}
|
|
45
50
|
/**
|
|
46
51
|
* Allows users to filter a collapsible list and select one item from it.
|
|
@@ -49,9 +54,9 @@ function ComboBox({ label, description, error, items, children, placeholder, UNS
|
|
|
49
54
|
*/
|
|
50
55
|
const _ComboBox = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(ComboBox), 'ComboBox');
|
|
51
56
|
exports.ComboBox = _ComboBox;
|
|
52
|
-
function ComboBoxInput({ isReadOnly, placeholder, }) {
|
|
57
|
+
function ComboBoxInput({ inputRef, isReadOnly, placeholder, }) {
|
|
53
58
|
const comboBoxState = (0, react_1.useContext)(react_aria_components_1.ComboBoxStateContext);
|
|
54
|
-
return ((0, jsx_runtime_1.jsx)(react_aria_components_1.Input, { className: (0, clsx_1.default)('cim-combo-box-input', (0, utils_js_1.textStyle)({ variant: 'body' })),
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)(react_aria_components_1.Input, { ref: inputRef, className: (0, clsx_1.default)('cim-combo-box-input', (0, utils_js_1.textStyle)({ variant: 'body' })),
|
|
55
60
|
// Ensure the popover opens when the input is clicked.
|
|
56
61
|
// By default, React Aria only opens the popover when the input is focused.
|
|
57
62
|
onClick: () => !isReadOnly && comboBoxState.open(), placeholder: placeholder }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo-box.js","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAwOb,oCAiBC;AAYD,0CAoBC;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,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 { useContext, type ForwardedRef } 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 type ListBoxProps as RACListBoxProps,\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 { IconCheck, 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 { Spinner } from '../spinner/spinner.js';\nimport type {\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 rowHeight: 40,\n headingHeight: 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 CommonProps,\n FieldWithPlaceholderProps<ComboBoxValidationValue>,\n CollectionProps<T>,\n AsyncItemLoadingProps,\n Pick<\n RACComboBoxProps<T>,\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'isReadOnly'\n | 'selectedKey'\n | 'defaultSelectedKey'\n | 'inputValue'\n | 'defaultInputValue'\n | 'autoFocus'\n | 'onSelectionChange'\n | 'onInputChange'\n | 'onFocus'\n | 'onBlur'\n | 'onOpenChange'\n >,\n Pick<RACListBoxProps<T>, 'onScroll'> {\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}\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 ...props\n }: ComboBoxProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\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 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 menuTrigger=\"focus\"\n isReadOnly={isReadOnly}\n data-readonly={isReadOnly ? true : undefined}\n >\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n <RACGroup className=\"cim-combo-box-input-group\">\n <ComboBoxInput isReadOnly={isReadOnly} placeholder={placeholder} />\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 ComboBoxInput({\n isReadOnly,\n placeholder,\n}: {\n isReadOnly: boolean | undefined;\n placeholder: string | undefined;\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n\n return (\n <RACInput\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 />\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>\n extends Pick<RACListBoxItemProps<T>, 'id' | 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\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 <IconCheck />\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;;;;;;;AA0Qb,oCAiBC;AAYD,0CAoBC;;AAzTD,gDAAwB;AACxB,iCAOe;AACf,2CAA8C;AAC9C,iEAkB+B;AAC/B,yDAAkD;AAClD,kDAA2D;AAC3D,mDAAkE;AAClE,mEAA4D;AAC5D,qFAA6E;AAC7E,mEAA2D;AAC3D,0FAAmF;AACnF,wEAA4G;AAC5G,sDAAgD;AAWhD,qDAAmD;AAEnD,MAAM,sBAAsB,GAAyB;IACnD,SAAS,EAAE,EAAE;IACb,aAAa,EAAE,EAAE;IACjB,YAAY,EAAE,EAAE;IAChB,OAAO,EAAE,CAAC;IACV,GAAG,EAAE,CAAC;CACP,CAAC;AAkDF,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,kBAAkB,EAAE,SAAS,EAC7B,mBAAmB,EAAE,UAAU,EAC/B,MAAM,EACN,GAAG,KAAK,EACS,EACnB,GAAiC;IAEjC,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAmB,IAAI,CAAC,CAAC;IAEhD,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAE7E,IAAA,gDAAoB,EAAC,GAAG,EAAE;QACxB,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,IAAI,CAAC,cAAc,EAAE,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,iFAAiF,CAAC,CAAC;QAClG,CAAC;IACH,CAAC,EAAE,CAAC,K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EAAE,CAAC,YACjG,QAAQ,GACD,IACT,CACJ,GACc,CAClB,CAAC;AACJ,CAAC;AAED,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;AAS1C,0DAA0D;AAC1D,SAAgB,eAAe,CAA2B,EACxD,KAAK,EACL,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACgB;IACxB,IAAI,CAAC,IAAA,+BAAY,GAAE,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACvE,OAAO,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;IACjG,CAAC;IAED,OAAO,CACL,wBAAC,sCAAiB,OAAK,KAAK,EAAE,SAAS,EAAC,uBAAuB,aAC7D,uBAAC,8BAAS,IACR,SAAS,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 { IconCheck, 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 { 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 rowHeight: 40,\n headingHeight: 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 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 | 'selectedKey'\n | 'defaultSelectedKey'\n | 'inputValue'\n | 'defaultInputValue'\n | 'autoFocus'\n | 'onSelectionChange'\n | 'onInputChange'\n | 'onFocus'\n | 'onBlur'\n | 'onOpenChange'\n > {\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 UNSTABLE_isLoading: isLoading,\n UNSTABLE_onLoadMore: onLoadMore,\n apiRef,\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 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 menuTrigger=\"focus\"\n isReadOnly={isReadOnly}\n data-readonly={isReadOnly ? true : undefined}\n >\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n <RACGroup className=\"cim-combo-box-input-group\">\n <ComboBoxInput inputRef={inputRef} isReadOnly={isReadOnly} placeholder={placeholder} />\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 ComboBoxInput({\n inputRef,\n isReadOnly,\n placeholder,\n}: {\n inputRef: MutableRefObject<HTMLInputElement | null>;\n isReadOnly: boolean | undefined;\n placeholder: string | undefined;\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 />\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>\n extends Pick<RACListBoxItemProps<T>, 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\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 <IconCheck />\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"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ActionButtonProps, BaseButtonProps } from '../button/types.js';
|
|
2
|
+
import type { AriaLabelingProps, CommonProps, StringLikeChildren } from '../types.js';
|
|
3
|
+
export interface UNSTABLE_CopyButtonProps extends CommonProps, AriaLabelingProps, Pick<BaseButtonProps, 'size'>, Pick<ActionButtonProps, 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {
|
|
4
|
+
/** The text displayed on the button. */
|
|
5
|
+
children?: StringLikeChildren;
|
|
6
|
+
/**
|
|
7
|
+
* Determines the visual appearance of the button.
|
|
8
|
+
* @default 'secondary'
|
|
9
|
+
*/
|
|
10
|
+
variant?: 'secondary' | 'tertiary';
|
|
11
|
+
/** The content to be copied. */
|
|
12
|
+
value: string;
|
|
13
|
+
/** The help text that appears in a tooltip when the user hovers or focuses the button. */
|
|
14
|
+
helpText?: string;
|
|
15
|
+
/** A handler that gets called when the user triggers the copying. */
|
|
16
|
+
onCopy?: () => void;
|
|
17
|
+
}
|
|
18
|
+
declare const _UNSTABLE_CopyButton: (props: UNSTABLE_CopyButtonProps & import("react").RefAttributes<HTMLButtonElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
19
|
+
export { _UNSTABLE_CopyButton as UNSTABLE_CopyButton };
|
|
20
|
+
//# sourceMappingURL=copy-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-button.d.ts","sourceRoot":"","sources":["../../../../src/components/copy/copy-button.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtF,MAAM,WAAW,wBACf,SAAQ,WAAW,EACjB,iBAAiB,EACjB,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,EAC7B,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,cAAc,GAAG,YAAY,CAAC;IACvE,wCAAwC;IACxC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IACnC,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAyDD,QAAA,MAAM,oBAAoB,6KAAgE,CAAC;AAE3F,OAAO,EAAE,oBAAoB,IAAI,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.UNSTABLE_CopyButton = void 0;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const react_aria_components_1 = require("react-aria-components");
|
|
8
|
+
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
9
|
+
const index_js_1 = require("../../icons/index.js");
|
|
10
|
+
const use_production_warning_js_1 = require("../../utils/use-production-warning.js");
|
|
11
|
+
const with_style_props_js_1 = require("../../with-style-props.js");
|
|
12
|
+
const button_js_1 = require("../button/button.js");
|
|
13
|
+
const icon_button_js_1 = require("../button/icon-button.js");
|
|
14
|
+
const tooltip_js_1 = require("../tooltip/tooltip.js");
|
|
15
|
+
const use_copy_js_1 = require("./use-copy.js");
|
|
16
|
+
function UNSTABLE_CopyButton({ onCopy, helpText, ...props }, ref) {
|
|
17
|
+
const [copyStatus, showCopyFeedback, copyToClipboard] = (0, use_copy_js_1.useCopyToClipboard)();
|
|
18
|
+
const [showCopyFeedbackLabel, setShowCopyFeedbackLabel] = (0, react_1.useState)(showCopyFeedback);
|
|
19
|
+
(0, react_1.useEffect)(() => {
|
|
20
|
+
let labelChangeTimeout;
|
|
21
|
+
if (showCopyFeedback) {
|
|
22
|
+
setShowCopyFeedbackLabel(true);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
// Wait until the tooltip has animated away before changing the label
|
|
26
|
+
labelChangeTimeout = setTimeout(() => setShowCopyFeedbackLabel(false), 200);
|
|
27
|
+
}
|
|
28
|
+
return () => {
|
|
29
|
+
if (labelChangeTimeout) {
|
|
30
|
+
clearTimeout(labelChangeTimeout);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}, [showCopyFeedback]);
|
|
34
|
+
const { children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;
|
|
35
|
+
(0, use_production_warning_js_1.useProductionWarning)(() => {
|
|
36
|
+
if (!children && !ariaLabel && !ariaLabelledBy) {
|
|
37
|
+
console.warn('CopyButton requires one of children / aria-label / aria-labelledby for accessibility');
|
|
38
|
+
}
|
|
39
|
+
}, [children, ariaLabel, ariaLabelledBy]);
|
|
40
|
+
const onPress = () => {
|
|
41
|
+
copyToClipboard(props.value);
|
|
42
|
+
onCopy?.();
|
|
43
|
+
};
|
|
44
|
+
return ((0, jsx_runtime_1.jsx)(tooltip_js_1.Tooltip, { isDisabled: props.isDisabled || (!showCopyFeedback && !helpText), label: showCopyFeedbackLabel
|
|
45
|
+
? copyStatus?.success
|
|
46
|
+
? // TODO: i18n
|
|
47
|
+
'Copied to clipboard.'
|
|
48
|
+
: 'Failed to copy to clipboard.'
|
|
49
|
+
: (helpText ?? ''), placement: "top", children: (0, jsx_runtime_1.jsx)(CopyButtonInner, { ...props, buttonRef: ref, onCopy: onPress, showCopyFeedback: showCopyFeedback }) }));
|
|
50
|
+
}
|
|
51
|
+
const _UNSTABLE_CopyButton = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(UNSTABLE_CopyButton), 'CopyButton');
|
|
52
|
+
exports.UNSTABLE_CopyButton = _UNSTABLE_CopyButton;
|
|
53
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
54
|
+
function CopyButtonInner({ UNSAFE_className, UNSAFE_style, children, value, onCopy, buttonRef, showCopyFeedback, ...props }) {
|
|
55
|
+
const tooltipTriggerState = (0, react_1.useContext)(react_aria_components_1.TooltipTriggerStateContext);
|
|
56
|
+
const icon = showCopyFeedback ? (0, jsx_runtime_1.jsx)(index_js_1.IconCheckCircle, {}) : (0, jsx_runtime_1.jsx)(index_js_1.IconCopy, {});
|
|
57
|
+
(0, react_1.useEffect)(() => {
|
|
58
|
+
if (showCopyFeedback) {
|
|
59
|
+
tooltipTriggerState?.open(true);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
tooltipTriggerState?.close(true);
|
|
63
|
+
}
|
|
64
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
|
+
}, [showCopyFeedback]);
|
|
66
|
+
return children ? ((0, jsx_runtime_1.jsx)(button_js_1.Button, { ...props, ref: buttonRef, iconStart: icon, tone: "base", onPress: onCopy, children: children })) : ((0, jsx_runtime_1.jsx)(icon_button_js_1.IconButton, { ...props, ref: buttonRef, icon: icon, tone: "base", "aria-label": props['aria-label'] ?? '', onPress: onCopy }));
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=copy-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-button.js","sourceRoot":"","sources":["../../../../src/components/copy/copy-button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAEb,iCAA2E;AAC3E,iEAAoG;AACpG,yDAAkD;AAClD,mDAAiE;AACjE,qFAA6E;AAC7E,mEAA2D;AAC3D,mDAA6C;AAC7C,6DAAsD;AAEtD,sDAAgD;AAEhD,+CAAmD;AAsBnD,SAAS,mBAAmB,CAC1B,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,EAA4B,EACxD,GAAoC;IAEpC,MAAM,CAAC,UAAU,EAAE,gBAAgB,EAAE,eAAe,CAAC,GAAG,IAAA,gCAAkB,GAAE,CAAC;IAC7E,MAAM,CAAC,qBAAqB,EAAE,wBAAwB,CAAC,GAAG,I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AAC,MAAM,gBACC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,EACrC,OAAO,EAAE,MAAM,GACf,CACH,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { useContext, useEffect, useState, type ForwardedRef } from 'react';\nimport { TooltipTriggerStateContext as RACTooltipTriggerStateContext } from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { IconCheckCircle, IconCopy } from '../../icons/index.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { Button } from '../button/button.js';\nimport { IconButton } from '../button/icon-button.js';\nimport type { ActionButtonProps, BaseButtonProps } from '../button/types.js';\nimport { Tooltip } from '../tooltip/tooltip.js';\nimport type { AriaLabelingProps, CommonProps, StringLikeChildren } from '../types.js';\nimport { useCopyToClipboard } from './use-copy.js';\n\nexport interface UNSTABLE_CopyButtonProps\n extends CommonProps,\n AriaLabelingProps,\n Pick<BaseButtonProps, 'size'>,\n Pick<ActionButtonProps, 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\n /** The text displayed on the button. */\n children?: StringLikeChildren;\n /**\n * Determines the visual appearance of the button.\n * @default 'secondary'\n */\n variant?: 'secondary' | 'tertiary';\n /** The content to be copied. */\n value: string;\n /** The help text that appears in a tooltip when the user hovers or focuses the button. */\n helpText?: string;\n /** A handler that gets called when the user triggers the copying. */\n onCopy?: () => void;\n}\n\nfunction UNSTABLE_CopyButton(\n { onCopy, helpText, ...props }: UNSTABLE_CopyButtonProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) {\n const [copyStatus, showCopyFeedback, copyToClipboard] = useCopyToClipboard();\n const [showCopyFeedbackLabel, setShowCopyFeedbackLabel] = useState(showCopyFeedback);\n\n useEffect(() => {\n let labelChangeTimeout: ReturnType<typeof setTimeout> | undefined;\n\n if (showCopyFeedback) {\n setShowCopyFeedbackLabel(true);\n } else {\n // Wait until the tooltip has animated away before changing the label\n labelChangeTimeout = setTimeout(() => setShowCopyFeedbackLabel(false), 200);\n }\n\n return () => {\n if (labelChangeTimeout) {\n clearTimeout(labelChangeTimeout);\n }\n };\n }, [showCopyFeedback]);\n\n const { children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!children && !ariaLabel && !ariaLabelledBy) {\n console.warn('CopyButton requires one of children / aria-label / aria-labelledby for accessibility');\n }\n }, [children, ariaLabel, ariaLabelledBy]);\n\n const onPress = () => {\n copyToClipboard(props.value);\n onCopy?.();\n };\n\n return (\n <Tooltip\n isDisabled={props.isDisabled || (!showCopyFeedback && !helpText)}\n label={\n showCopyFeedbackLabel\n ? copyStatus?.success\n ? // TODO: i18n\n 'Copied to clipboard.'\n : 'Failed to copy to clipboard.'\n : (helpText ?? '')\n }\n placement=\"top\"\n >\n <CopyButtonInner {...props} buttonRef={ref} onCopy={onPress} showCopyFeedback={showCopyFeedback} />\n </Tooltip>\n );\n}\n\nconst _UNSTABLE_CopyButton = withStyleProps(forwardRef(UNSTABLE_CopyButton), 'CopyButton');\n\nexport { _UNSTABLE_CopyButton as UNSTABLE_CopyButton };\n\n// eslint-disable-next-line react-refresh/only-export-components\nfunction CopyButtonInner({\n UNSAFE_className,\n UNSAFE_style,\n children,\n value,\n onCopy,\n buttonRef,\n showCopyFeedback,\n ...props\n}: Omit<UNSTABLE_CopyButtonProps, 'helpText'> & {\n buttonRef: ForwardedRef<HTMLButtonElement>;\n showCopyFeedback: boolean;\n}) {\n const tooltipTriggerState = useContext(RACTooltipTriggerStateContext);\n\n const icon = showCopyFeedback ? <IconCheckCircle /> : <IconCopy />;\n\n useEffect(() => {\n if (showCopyFeedback) {\n tooltipTriggerState?.open(true);\n } else {\n tooltipTriggerState?.close(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showCopyFeedback]);\n\n return children ? (\n <Button {...props} ref={buttonRef} iconStart={icon} tone=\"base\" onPress={onCopy}>\n {children}\n </Button>\n ) : (\n <IconButton\n {...props}\n ref={buttonRef}\n icon={icon}\n tone=\"base\"\n aria-label={props['aria-label'] ?? ''}\n onPress={onCopy}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ActionButtonProps } from '../button/types.js';
|
|
2
|
+
import type { AriaLabelingProps, CommonProps, StringLikeChildren } from '../types.js';
|
|
3
|
+
import type { TextStyleOptions } from '../typography/types.js';
|
|
4
|
+
export interface UNSTABLE_InlineCopyProps extends CommonProps, AriaLabelingProps, Pick<TextStyleOptions, 'variant' | 'tone' | 'fontStyle'>, Pick<ActionButtonProps, 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {
|
|
5
|
+
/** The content to be copied. */
|
|
6
|
+
children: StringLikeChildren;
|
|
7
|
+
/** A handler that gets called when the user triggers the copying. */
|
|
8
|
+
onCopy?: () => void;
|
|
9
|
+
}
|
|
10
|
+
declare const _UNSTABLE_InlineCopy: (props: UNSTABLE_InlineCopyProps & import("react").RefAttributes<HTMLButtonElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
11
|
+
export { _UNSTABLE_InlineCopy as UNSTABLE_InlineCopy };
|
|
12
|
+
//# sourceMappingURL=inline-copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-copy.d.ts","sourceRoot":"","sources":["../../../../src/components/copy/inline-copy.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAO/D,MAAM,WAAW,wBACf,SAAQ,WAAW,EACjB,iBAAiB,EACjB,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,MAAM,GAAG,WAAW,CAAC,EACxD,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,cAAc,GAAG,YAAY,CAAC;IACvE,gCAAgC;IAChC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAyCD,QAAA,MAAM,oBAAoB,6KAAgE,CAAC;AAE3F,OAAO,EAAE,oBAAoB,IAAI,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.UNSTABLE_InlineCopy = void 0;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const react_aria_components_1 = require("react-aria-components");
|
|
12
|
+
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
13
|
+
const index_js_1 = require("../../icons/index.js");
|
|
14
|
+
const with_style_props_js_1 = require("../../with-style-props.js");
|
|
15
|
+
const tooltip_js_1 = require("../tooltip/tooltip.js");
|
|
16
|
+
const utils_js_1 = require("../typography/utils.js");
|
|
17
|
+
const use_copy_js_1 = require("./use-copy.js");
|
|
18
|
+
// Used to prevent word wrap between icons and text
|
|
19
|
+
const WORD_JOINER = '\u2060';
|
|
20
|
+
function UNSTABLE_InlineCopy({ children, UNSAFE_className, UNSAFE_style, variant, tone, fontStyle, onCopy, ...props }, ref) {
|
|
21
|
+
const tooltipTriggerRef = (0, react_1.useRef)(null);
|
|
22
|
+
const [copyStatus, showCopyFeedback, copyToClipboard] = (0, use_copy_js_1.useCopyToClipboard)();
|
|
23
|
+
const textValue = typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(tooltip_js_1.Tooltip, { isOpen: showCopyFeedback, isDisabled: props.isDisabled,
|
|
25
|
+
// TODO: i18n
|
|
26
|
+
label: copyStatus?.success ? 'Copied to clipboard.' : 'Failed to copy to clipboard.', placement: "top", triggerRef: tooltipTriggerRef, children: (0, jsx_runtime_1.jsxs)(react_aria_components_1.Button, { ...props, ref: ref, className: (0, clsx_1.default)('cim-inline-copy', (0, utils_js_1.textStyle)({ variant, tone, fontStyle }), UNSAFE_className), style: UNSAFE_style, onPress: () => {
|
|
27
|
+
copyToClipboard(textValue);
|
|
28
|
+
onCopy?.();
|
|
29
|
+
}, children: [(0, jsx_runtime_1.jsx)("span", { className: "cim-inline-copy-text", children: children }), WORD_JOINER, (0, jsx_runtime_1.jsx)("span", { className: "cim-inline-copy-icon", ref: tooltipTriggerRef, children: showCopyFeedback ? (0, jsx_runtime_1.jsx)(index_js_1.IconCheckCircle, {}) : (0, jsx_runtime_1.jsx)(index_js_1.IconCopy, {}) })] }) }));
|
|
30
|
+
}
|
|
31
|
+
const _UNSTABLE_InlineCopy = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(UNSTABLE_InlineCopy), 'InlineCopy');
|
|
32
|
+
exports.UNSTABLE_InlineCopy = _UNSTABLE_InlineCopy;
|
|
33
|
+
//# sourceMappingURL=inline-copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-copy.js","sourceRoot":"","sources":["../../../../src/components/copy/inline-copy.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AACxB,iCAAkD;AAClD,iEAA4D;AAC5D,yDAAkD;AAClD,mDAAiE;AACjE,mEAA2D;AAE3D,sDAAgD;AAGhD,qDAAmD;AACnD,+CAAmD;AAEnD,mDAAmD;AACnD,MAAM,WAAW,GAAG,QAAQ,CAAC;AAa7B,SAAS,mBAAmB,CAC1B,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE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uBAAC,mBAAQ,KAAG,GACjD,IACG,GACJ,CACX,CAAC;AACJ,CAAC;AAED,MAAM,oBAAoB,GAAG,IAAA,oCAAc,EAAC,IAAA,2BAAU,EAAC,mBAAmB,CAAC,EAAE,YAAY,CAAC,CAAC;AAE1D,mDAAmB","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { useRef, type ForwardedRef } from 'react';\nimport { Button as RACButton } from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { IconCheckCircle, IconCopy } from '../../icons/index.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport type { ActionButtonProps } from '../button/types.js';\nimport { Tooltip } from '../tooltip/tooltip.js';\nimport type { AriaLabelingProps, CommonProps, StringLikeChildren } from '../types.js';\nimport type { TextStyleOptions } from '../typography/types.js';\nimport { textStyle } from '../typography/utils.js';\nimport { useCopyToClipboard } from './use-copy.js';\n\n// Used to prevent word wrap between icons and text\nconst WORD_JOINER = '\\u2060';\n\nexport interface UNSTABLE_InlineCopyProps\n extends CommonProps,\n AriaLabelingProps,\n Pick<TextStyleOptions, 'variant' | 'tone' | 'fontStyle'>,\n Pick<ActionButtonProps, 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\n /** The content to be copied. */\n children: StringLikeChildren;\n /** A handler that gets called when the user triggers the copying. */\n onCopy?: () => void;\n}\n\nfunction UNSTABLE_InlineCopy(\n { children, UNSAFE_className, UNSAFE_style, variant, tone, fontStyle, onCopy, ...props }: UNSTABLE_InlineCopyProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) {\n const tooltipTriggerRef = useRef<HTMLSpanElement>(null);\n const [copyStatus, showCopyFeedback, copyToClipboard] = useCopyToClipboard();\n\n const textValue =\n typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');\n\n return (\n <Tooltip\n isOpen={showCopyFeedback}\n isDisabled={props.isDisabled}\n // TODO: i18n\n label={copyStatus?.success ? 'Copied to clipboard.' : 'Failed to copy to clipboard.'}\n placement=\"top\"\n triggerRef={tooltipTriggerRef}\n >\n <RACButton\n {...props}\n ref={ref}\n className={clsx('cim-inline-copy', textStyle({ variant, tone, fontStyle }), UNSAFE_className)}\n style={UNSAFE_style}\n onPress={() => {\n copyToClipboard(textValue);\n onCopy?.();\n }}\n >\n <span className=\"cim-inline-copy-text\">{children}</span>\n {WORD_JOINER}\n <span className=\"cim-inline-copy-icon\" ref={tooltipTriggerRef}>\n {showCopyFeedback ? <IconCheckCircle /> : <IconCopy />}\n </span>\n </RACButton>\n </Tooltip>\n );\n}\n\nconst _UNSTABLE_InlineCopy = withStyleProps(forwardRef(UNSTABLE_InlineCopy), 'InlineCopy');\n\nexport { _UNSTABLE_InlineCopy as UNSTABLE_InlineCopy };\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface CopyStatus {
|
|
2
|
+
success: boolean;
|
|
3
|
+
timestamp: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function useCopyToClipboard(): [
|
|
6
|
+
copyStatus: CopyStatus | undefined,
|
|
7
|
+
showCopyFeedback: boolean,
|
|
8
|
+
copyToClipboard: (text: string) => void
|
|
9
|
+
];
|
|
10
|
+
//# sourceMappingURL=use-copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-copy.d.ts","sourceRoot":"","sources":["../../../../src/components/copy/use-copy.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,kBAAkB,IAAI;IACpC,UAAU,EAAE,UAAU,GAAG,SAAS;IAClC,gBAAgB,EAAE,OAAO;IACzB,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI;CACxC,CA2BA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCopyToClipboard = useCopyToClipboard;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useCopyToClipboard() {
|
|
6
|
+
const [copyStatus, setCopyStatus] = (0, react_1.useState)(undefined);
|
|
7
|
+
const [showCopyFeedback, setShowCopyFeedback] = (0, react_1.useState)(false);
|
|
8
|
+
const timeoutRef = (0, react_1.useRef)(undefined);
|
|
9
|
+
const copyToClipboard = (0, react_1.useCallback)((text) => {
|
|
10
|
+
setCopyStatus(undefined);
|
|
11
|
+
setShowCopyFeedback(false);
|
|
12
|
+
clearTimeout(timeoutRef.current);
|
|
13
|
+
navigator.clipboard
|
|
14
|
+
.writeText(text)
|
|
15
|
+
.then(() => {
|
|
16
|
+
setCopyStatus({ success: true, timestamp: Date.now() });
|
|
17
|
+
})
|
|
18
|
+
.catch(() => {
|
|
19
|
+
setCopyStatus({ success: false, timestamp: Date.now() });
|
|
20
|
+
})
|
|
21
|
+
.finally(() => {
|
|
22
|
+
setShowCopyFeedback(true);
|
|
23
|
+
timeoutRef.current = setTimeout(() => {
|
|
24
|
+
setShowCopyFeedback(false);
|
|
25
|
+
}, 2000);
|
|
26
|
+
});
|
|
27
|
+
}, []);
|
|
28
|
+
return [copyStatus, showCopyFeedback, copyToClipboard];
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=use-copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-copy.js","sourceRoot":"","sources":["../../../../src/components/copy/use-copy.ts"],"names":[],"mappings":";;AAOA,gDA+BC;AAtCD,iCAAsD;AAOtD,SAAgB,kBAAkB;IAKhC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAyB,SAAS,CAAC,CAAC;IAChF,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,IAAA,cAAM,EAA4C,SAAS,CAAC,CAAC;IAEhF,MAAM,eAAe,GAAG,IAAA,mBAAW,EAAC,CAAC,IAAY,EAAE,EAAE;QACnD,aAAa,CAAC,SAAS,CAAC,CAAC;QACzB,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC3B,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAEjC,SAAS,CAAC,SAAS;aAChB,SAAS,CAAC,IAAI,CAAC;aACf,IAAI,CAAC,GAAG,EAAE;YACT,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC1D,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE;YACV,aAAa,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC3D,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE;YACZ,mBAAmB,CAAC,IAAI,CAAC,CAAC;YAC1B,UAAU,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;gBACnC,mBAAmB,CAAC,KAAK,CAAC,CAAC;YAC7B,CAAC,EAAE,IAAI,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,UAAU,EAAE,gBAAgB,EAAE,eAAe,CAAC,CAAC;AACzD,CAAC","sourcesContent":["import { useCallback, useRef, useState } from 'react';\n\nexport interface CopyStatus {\n success: boolean;\n timestamp: number;\n}\n\nexport function useCopyToClipboard(): [\n copyStatus: CopyStatus | undefined,\n showCopyFeedback: boolean,\n copyToClipboard: (text: string) => void,\n] {\n const [copyStatus, setCopyStatus] = useState<CopyStatus | undefined>(undefined);\n const [showCopyFeedback, setShowCopyFeedback] = useState(false);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n const copyToClipboard = useCallback((text: string) => {\n setCopyStatus(undefined);\n setShowCopyFeedback(false);\n clearTimeout(timeoutRef.current);\n\n navigator.clipboard\n .writeText(text)\n .then(() => {\n setCopyStatus({ success: true, timestamp: Date.now() });\n })\n .catch(() => {\n setCopyStatus({ success: false, timestamp: Date.now() });\n })\n .finally(() => {\n setShowCopyFeedback(true);\n timeoutRef.current = setTimeout(() => {\n setShowCopyFeedback(false);\n }, 2000);\n });\n }, []);\n\n return [copyStatus, showCopyFeedback, copyToClipboard];\n}\n"]}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import type { CalendarDate, CalendarDateTime, ZonedDateTime } from '@internationalized/date';
|
|
2
2
|
import { type CalendarProps as RACCalendarProps, type DatePickerProps as RACDatePickerProps } from 'react-aria-components';
|
|
3
|
-
import type { CommonProps, FieldProps } from '../types.js';
|
|
3
|
+
import type { ApiProps, CommonProps, FieldProps } from '../types.js';
|
|
4
4
|
/** Represents a date with optional time and timezone components. */
|
|
5
5
|
export type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;
|
|
6
6
|
/** Maps a date value to a specific subtype depending on which components it contains. */
|
|
7
7
|
export type MappedDateValue<T> = T extends ZonedDateTime ? ZonedDateTime : T extends CalendarDateTime ? CalendarDateTime : T extends CalendarDate ? CalendarDate : never;
|
|
8
|
-
export interface DatePickerProps<T extends DateValue> extends CommonProps, FieldProps<MappedDateValue<T>>, Pick<RACDatePickerProps<T>, 'value' | 'defaultValue' | 'placeholderValue' | 'onChange' | 'isDisabled' | 'isRequired' | 'isInvalid' | 'isReadOnly' | 'autoFocus' | 'onFocus' | 'onBlur' | 'isOpen' | 'defaultOpen' | 'onOpenChange' | 'minValue' | 'maxValue' | 'isDateUnavailable' | 'granularity' | 'firstDayOfWeek' | 'autoComplete'>, Pick<RACCalendarProps<T>, 'focusedValue' | 'defaultFocusedValue'> {
|
|
8
|
+
export interface DatePickerProps<T extends DateValue> extends CommonProps, FieldProps<MappedDateValue<T>>, ApiProps<DatePickerApi>, Pick<RACDatePickerProps<T>, 'value' | 'defaultValue' | 'placeholderValue' | 'onChange' | 'isDisabled' | 'isRequired' | 'isInvalid' | 'isReadOnly' | 'autoFocus' | 'onFocus' | 'onBlur' | 'isOpen' | 'defaultOpen' | 'onOpenChange' | 'minValue' | 'maxValue' | 'isDateUnavailable' | 'granularity' | 'firstDayOfWeek' | 'autoComplete'>, Pick<RACCalendarProps<T>, 'focusedValue' | 'defaultFocusedValue'> {
|
|
9
|
+
}
|
|
10
|
+
/** The imperative API exposed by the `DatePicker` component. */
|
|
11
|
+
export interface DatePickerApi {
|
|
12
|
+
/** Focuses the first editable segment in the input field. */
|
|
13
|
+
focus: () => void;
|
|
9
14
|
}
|
|
10
15
|
/**
|
|
11
16
|
* Allows users to enter or select a date and time value.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../../src/components/date-picker/date-picker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7F,OAAO,EACL,KAAK,aAAa,IAAI,gBAAgB,EAGtC,KAAK,eAAe,IAAI,kBAAkB,EAM3C,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../../src/components/date-picker/date-picker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7F,OAAO,EACL,KAAK,aAAa,IAAI,gBAAgB,EAGtC,KAAK,eAAe,IAAI,kBAAkB,EAM3C,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAoB,MAAM,aAAa,CAAC;AAIvF,oEAAoE;AACpE,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAExE,yFAAyF;AACzF,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