@g4rcez/components 5.0.2 → 5.0.3
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/AnimatePresence-j36AYeOQ.js +181 -0
- package/dist/AnimatePresence-j36AYeOQ.js.map +1 -0
- package/dist/Calendar.es-xICmgvjq.js +23 -0
- package/dist/Calendar.es-xICmgvjq.js.map +1 -0
- package/dist/Funnel.es-DjKVl8Nj.js +23 -0
- package/dist/Funnel.es-DjKVl8Nj.js.map +1 -0
- package/dist/{MotionConfig-DKKYqBH2.js → MotionConfig-CXHoPGbK.js} +2 -2
- package/dist/{MotionConfig-DKKYqBH2.js.map → MotionConfig-CXHoPGbK.js.map} +1 -1
- package/dist/Plus.es-DbyRkEE2.js +23 -0
- package/dist/Plus.es-DbyRkEE2.js.map +1 -0
- package/dist/Trash.es-BFAc8PMf.js +23 -0
- package/dist/Trash.es-BFAc8PMf.js.map +1 -0
- package/dist/{calendar-PCCZDUIL.js → calendar-DEPkz8sw.js} +364 -502
- package/dist/calendar-DEPkz8sw.js.map +1 -0
- package/dist/calendar-header-Dfr-CwkY.js +174 -0
- package/dist/calendar-header-Dfr-CwkY.js.map +1 -0
- package/dist/chunk-jwUa06l-.js +23 -0
- package/dist/components/core/button.js +1 -1
- package/dist/components/core/heading.js +11 -0
- package/dist/components/core/heading.js.map +1 -0
- package/dist/{polymorph-BLXhrn9n.js → components/core/polymorph.js} +2 -2
- package/dist/components/core/polymorph.js.map +1 -0
- package/dist/components/core/render-on-view.js +29 -0
- package/dist/components/core/render-on-view.js.map +1 -0
- package/dist/components/core/resizable.d.ts +7 -1
- package/dist/components/core/resizable.d.ts.map +1 -1
- package/dist/components/core/resizable.js +60 -0
- package/dist/components/core/resizable.js.map +1 -0
- package/dist/components/core/resizable.jsx +46 -40
- package/dist/{slot-pC8kH9De.js → components/core/slot.js} +2 -2
- package/dist/components/core/slot.js.map +1 -0
- package/dist/components/core/tag.js +1 -1
- package/dist/components/core/typography.js +40 -0
- package/dist/components/core/typography.js.map +1 -0
- package/dist/components/display/alert.d.ts.map +1 -1
- package/dist/components/display/alert.js +83 -102
- package/dist/components/display/alert.js.map +1 -1
- package/dist/components/display/alert.jsx +26 -29
- package/dist/components/display/calendar.d.ts.map +1 -1
- package/dist/components/display/calendar.js +1 -1
- package/dist/components/display/calendar.jsx +15 -10
- package/dist/components/display/card.js +2 -2
- package/dist/components/display/empty.d.ts.map +1 -1
- package/dist/components/display/empty.js +25 -0
- package/dist/components/display/empty.js.map +1 -0
- package/dist/components/display/empty.jsx +3 -1
- package/dist/components/display/list.d.ts.map +1 -1
- package/dist/components/display/list.js +132 -122
- package/dist/components/display/list.js.map +1 -1
- package/dist/components/display/list.jsx +30 -25
- package/dist/components/display/notifications.d.ts.map +1 -1
- package/dist/components/display/notifications.js +1 -1
- package/dist/components/display/notifications.jsx +8 -6
- package/dist/components/display/progress.d.ts.map +1 -1
- package/dist/components/display/progress.js +3 -0
- package/dist/components/display/progress.jsx +6 -8
- package/dist/components/display/shortcut.js +2 -0
- package/dist/components/display/skeleton.js +41 -0
- package/dist/components/display/skeleton.js.map +1 -0
- package/dist/components/display/spinner.js +17 -0
- package/dist/components/display/spinner.js.map +1 -0
- package/dist/components/display/step.d.ts.map +1 -1
- package/dist/components/display/step.js +3 -0
- package/dist/components/display/step.jsx +5 -5
- package/dist/components/display/tabs.js +1 -1
- package/dist/components/display/timeline.js +1 -1
- package/dist/components/floating/command-palette.d.ts.map +1 -1
- package/dist/components/floating/command-palette.js +255 -0
- package/dist/components/floating/command-palette.js.map +1 -0
- package/dist/components/floating/command-palette.jsx +34 -25
- package/dist/components/floating/dropdown.js +1 -1
- package/dist/components/floating/dropdown.js.map +1 -1
- package/dist/components/floating/dropdown.jsx +1 -1
- package/dist/components/floating/expand.js +15 -14
- package/dist/components/floating/expand.js.map +1 -1
- package/dist/components/floating/menu.js +1 -1
- package/dist/components/floating/modal.d.ts +14 -11
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.js +1 -1
- package/dist/components/floating/modal.jsx +56 -17
- package/dist/components/floating/toolbar.d.ts +3 -3
- package/dist/components/floating/toolbar.d.ts.map +1 -1
- package/dist/components/floating/toolbar.js +20 -0
- package/dist/components/floating/toolbar.js.map +1 -0
- package/dist/components/floating/toolbar.jsx +7 -3
- package/dist/components/floating/tooltip.js +2 -2
- package/dist/components/floating/tooltip.js.map +1 -1
- package/dist/components/floating/tooltip.jsx +1 -1
- package/dist/components/floating/wizard.js +3 -0
- package/dist/components/form/autocomplete.d.ts.map +1 -1
- package/dist/components/form/autocomplete.js +344 -2
- package/dist/components/form/autocomplete.js.map +1 -0
- package/dist/components/form/autocomplete.jsx +27 -18
- package/dist/components/form/checkbox.d.ts.map +1 -1
- package/dist/components/form/checkbox.js +29 -27
- package/dist/components/form/checkbox.js.map +1 -1
- package/dist/components/form/checkbox.jsx +21 -6
- package/dist/components/form/date-picker.js +1 -1
- package/dist/components/form/date-picker.jsx +1 -1
- package/dist/components/form/file-upload.d.ts +6 -1
- package/dist/components/form/file-upload.d.ts.map +1 -1
- package/dist/components/form/file-upload.js +1 -1
- package/dist/components/form/file-upload.jsx +34 -12
- package/dist/components/form/formReset.js +10 -0
- package/dist/components/form/formReset.js.map +1 -0
- package/dist/components/form/free-text.js +70 -0
- package/dist/components/form/free-text.js.map +1 -0
- package/dist/components/form/free-text.jsx +1 -1
- package/dist/components/form/input-field.d.ts.map +1 -1
- package/dist/components/form/input-field.js +3 -0
- package/dist/components/form/input-field.jsx +14 -8
- package/dist/components/form/input.js +1 -1
- package/dist/components/form/multi-select.d.ts.map +1 -1
- package/dist/components/form/multi-select.js +420 -0
- package/dist/components/form/multi-select.js.map +1 -0
- package/dist/components/form/multi-select.jsx +41 -33
- package/dist/components/form/select.d.ts.map +1 -1
- package/dist/components/form/select.js +55 -51
- package/dist/components/form/select.js.map +1 -1
- package/dist/components/form/select.jsx +8 -5
- package/dist/components/form/slider.js +3 -0
- package/dist/components/form/switch.d.ts +2 -1
- package/dist/components/form/switch.d.ts.map +1 -1
- package/dist/components/form/switch.js +32 -26
- package/dist/components/form/switch.js.map +1 -1
- package/dist/components/form/switch.jsx +26 -13
- package/dist/components/form/textarea.js +19 -0
- package/dist/components/form/textarea.js.map +1 -0
- package/dist/components/page-calendar/calendar-header.d.ts.map +1 -1
- package/dist/components/page-calendar/calendar-header.js +2 -0
- package/dist/components/page-calendar/calendar-header.jsx +6 -4
- package/dist/components/page-calendar/day-view.js +124 -0
- package/dist/components/page-calendar/day-view.js.map +1 -0
- package/dist/components/page-calendar/event-pill.js +44 -0
- package/dist/components/page-calendar/event-pill.js.map +1 -0
- package/dist/components/page-calendar/month-view.d.ts.map +1 -1
- package/dist/components/page-calendar/month-view.js +109 -0
- package/dist/components/page-calendar/month-view.js.map +1 -0
- package/dist/components/page-calendar/month-view.jsx +78 -31
- package/dist/components/page-calendar/page-calendar.d.ts.map +1 -1
- package/dist/components/page-calendar/page-calendar.js +75 -0
- package/dist/components/page-calendar/page-calendar.js.map +1 -0
- package/dist/components/page-calendar/page-calendar.jsx +2 -2
- package/dist/components/page-calendar/week-view.js +88 -0
- package/dist/components/page-calendar/week-view.js.map +1 -0
- package/dist/components/table/filter.d.ts.map +1 -1
- package/dist/components/table/filter.js +239 -0
- package/dist/components/table/filter.js.map +1 -0
- package/dist/components/table/filter.jsx +9 -4
- package/dist/components/table/group.d.ts.map +1 -1
- package/dist/components/table/group.js +3 -0
- package/dist/components/table/group.jsx +5 -3
- package/dist/components/table/index.js +102 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/table/inner-table.js +2 -0
- package/dist/components/table/inner-table.jsx +1 -1
- package/dist/components/table/metadata.js +73 -0
- package/dist/components/table/metadata.js.map +1 -0
- package/dist/components/table/metadata.jsx +1 -1
- package/dist/components/table/pagination.js +70 -0
- package/dist/components/table/pagination.js.map +1 -0
- package/dist/components/table/row.js +58 -0
- package/dist/components/table/row.js.map +1 -0
- package/dist/components/table/sort.d.ts.map +1 -1
- package/dist/components/table/sort.js +3 -0
- package/dist/components/table/sort.jsx +3 -1
- package/dist/components/table/thead.js +3 -0
- package/dist/config/default-translations.d.ts +18 -0
- package/dist/config/default-translations.d.ts.map +1 -1
- package/dist/config/default-translations.jsx +18 -0
- package/dist/{use-translations-DTLfPE3_.js → context-CsnUsfeP.js} +55 -40
- package/dist/context-CsnUsfeP.js.map +1 -0
- package/dist/{date-picker-BhKEFZew.js → date-picker-DNzupG8R.js} +301 -317
- package/dist/date-picker-DNzupG8R.js.map +1 -0
- package/dist/dict-CisoYSMO.js +28 -0
- package/dist/dict-CisoYSMO.js.map +1 -0
- package/dist/dist-ChfJ5LO9.js +498 -0
- package/dist/dist-ChfJ5LO9.js.map +1 -0
- package/dist/{dist-BrGpYRaj.js → dist-DIjUECx9.js} +56 -56
- package/dist/{dist-BrGpYRaj.js.map → dist-DIjUECx9.js.map} +1 -1
- package/dist/dom-Bn4wY_Zx.js.map +1 -1
- package/dist/{file-upload-DWbZfeG5.js → file-upload-C2zNnv9n.js} +501 -481
- package/dist/{file-upload-DWbZfeG5.js.map → file-upload-C2zNnv9n.js.map} +1 -1
- package/dist/fzf-CPGDDCoU.js +64 -0
- package/dist/fzf-CPGDDCoU.js.map +1 -0
- package/dist/getISOWeek-EcB4Ebqp.js +72 -0
- package/dist/getISOWeek-EcB4Ebqp.js.map +1 -0
- package/dist/group-Dl14TJXO.js +222 -0
- package/dist/group-Dl14TJXO.js.map +1 -0
- package/dist/hooks/use-translations.d.ts +18 -0
- package/dist/hooks/use-translations.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js.map +1 -1
- package/dist/inner-table-CeDX60cL.js +151 -0
- package/dist/inner-table-CeDX60cL.js.map +1 -0
- package/dist/input-Cmyuea4Y.js +412 -0
- package/dist/input-Cmyuea4Y.js.map +1 -0
- package/dist/{input-field-B_whI66Q.js → input-field-ffx1MbHo.js} +29 -16
- package/dist/input-field-ffx1MbHo.js.map +1 -0
- package/dist/isSameMonth-C3lsSwcg.js +10 -0
- package/dist/isSameMonth-C3lsSwcg.js.map +1 -0
- package/dist/isToday-COXfxFui.js +32 -0
- package/dist/isToday-COXfxFui.js.map +1 -0
- package/dist/lib/dom.d.ts.map +1 -1
- package/dist/modal-Df8-6i-o.js +408 -0
- package/dist/modal-Df8-6i-o.js.map +1 -0
- package/dist/notifications-NhCESJUV.js +1697 -0
- package/dist/notifications-NhCESJUV.js.map +1 -0
- package/dist/page-calendar.utils-Bd0PHktL.js +102 -0
- package/dist/page-calendar.utils-Bd0PHktL.js.map +1 -0
- package/dist/preset/preset.tailwind.d.ts.map +1 -1
- package/dist/preset/preset.tailwind.js +6 -7
- package/dist/preset/src/styles/dark.js +1 -1
- package/dist/progress-8LO5gWLp.js +104 -0
- package/dist/progress-8LO5gWLp.js.map +1 -0
- package/dist/{proxy-BcJ_5Dwq.js → proxy-fP2NxmhM.js} +658 -844
- package/dist/proxy-fP2NxmhM.js.map +1 -0
- package/dist/shim-Czv-YhKR.js +93 -0
- package/dist/shim-Czv-YhKR.js.map +1 -0
- package/dist/shortcut-CQCmgmlU.js +100 -0
- package/dist/shortcut-CQCmgmlU.js.map +1 -0
- package/dist/slider-TX9hiHO-.js +1196 -0
- package/dist/slider-TX9hiHO-.js.map +1 -0
- package/dist/sort-DGmiselV.js +195 -0
- package/dist/sort-DGmiselV.js.map +1 -0
- package/dist/step-DFpJ7zCG.js +185 -0
- package/dist/step-DFpJ7zCG.js.map +1 -0
- package/dist/styles/dark.js +1 -1
- package/dist/subMonths-QcCnE3Yh.js +43 -0
- package/dist/subMonths-QcCnE3Yh.js.map +1 -0
- package/dist/table-lib-1bkYSklk.js +174 -0
- package/dist/table-lib-1bkYSklk.js.map +1 -0
- package/dist/{tabs-Ciy0l9OF.js → tabs-Brc963EW.js} +2 -2
- package/dist/{tabs-Ciy0l9OF.js.map → tabs-Brc963EW.js.map} +1 -1
- package/dist/thead-B6WELJZ-.js +211 -0
- package/dist/thead-B6WELJZ-.js.map +1 -0
- package/dist/use-locale-DPM_sg4s.js +12 -0
- package/dist/use-locale-DPM_sg4s.js.map +1 -0
- package/dist/use-remove-scroll-pAgC09Sq.js +38 -0
- package/dist/use-remove-scroll-pAgC09Sq.js.map +1 -0
- package/dist/use-translations-BE4PuhLm.js +11 -0
- package/dist/use-translations-BE4PuhLm.js.map +1 -0
- package/dist/useAnimationFrame-DnKbaXfi.js +223 -0
- package/dist/useAnimationFrame-DnKbaXfi.js.map +1 -0
- package/dist/valueToPercent-DZc_m1tm.js +43 -0
- package/dist/valueToPercent-DZc_m1tm.js.map +1 -0
- package/dist/visuallyHidden-B7wI86yi.js +303 -0
- package/dist/visuallyHidden-B7wI86yi.js.map +1 -0
- package/dist/with-selector-BFW5n-pb.js +102 -0
- package/dist/with-selector-BFW5n-pb.js.map +1 -0
- package/dist/wizard-7u_qZ-78.js +218 -0
- package/dist/wizard-7u_qZ-78.js.map +1 -0
- package/package.json +19 -11
- package/dist/autocomplete-D3VOTihi.js +0 -415
- package/dist/autocomplete-D3VOTihi.js.map +0 -1
- package/dist/calendar-PCCZDUIL.js.map +0 -1
- package/dist/components/table/table.js +0 -3
- package/dist/date-picker-BhKEFZew.js.map +0 -1
- package/dist/input-B7jqwPG4.js +0 -473
- package/dist/input-B7jqwPG4.js.map +0 -1
- package/dist/input-field-B_whI66Q.js.map +0 -1
- package/dist/modal-Bz-61ays.js +0 -373
- package/dist/modal-Bz-61ays.js.map +0 -1
- package/dist/notifications-MT4XkLov.js +0 -2203
- package/dist/notifications-MT4XkLov.js.map +0 -1
- package/dist/polymorph-BLXhrn9n.js.map +0 -1
- package/dist/proxy-BcJ_5Dwq.js.map +0 -1
- package/dist/skeleton-CBYEq3lM.js +0 -26
- package/dist/skeleton-CBYEq3lM.js.map +0 -1
- package/dist/slot-pC8kH9De.js.map +0 -1
- package/dist/table-CUFbAI2k.js +0 -1914
- package/dist/table-CUFbAI2k.js.map +0 -1
- package/dist/use-translations-DTLfPE3_.js.map +0 -1
|
@@ -19,11 +19,11 @@ const states = {
|
|
|
19
19
|
initial: { pathLength: 0, opacity: 0 },
|
|
20
20
|
animate: { pathLength: 1, opacity: 1 },
|
|
21
21
|
};
|
|
22
|
-
const ErrorIcon = (props) => (<svg {...props} viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
22
|
+
const ErrorIcon = (props) => (<svg {...props} aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
23
23
|
<motion.path className="currentColor" initial={states.initial} animate={states.animate} transition={iconTransitions} d="M18 6 6 18"/>
|
|
24
24
|
<motion.path className="currentColor" initial={states.initial} animate={states.animate} transition={iconTransitions} d="m6 6 12 12"/>
|
|
25
25
|
</svg>);
|
|
26
|
-
const CheckIcon = (props) => (<svg {...props} fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={3}>
|
|
26
|
+
const CheckIcon = (props) => (<svg {...props} aria-hidden="true" focusable="false" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={3}>
|
|
27
27
|
<motion.path d="M5 13l4 4L19 7" strokeLinecap="round" strokeLinejoin="round" animate={states.animate} initial={states.initial} transition={iconTransitions}/>
|
|
28
28
|
</svg>);
|
|
29
29
|
const variants = {
|
|
@@ -82,7 +82,7 @@ export const Step = ({ step, currentStep, status, title, titleClassName, ...prop
|
|
|
82
82
|
const _widthPerStep = context?.steps ? 100 / context?.steps : undefined;
|
|
83
83
|
return (<Fragment>
|
|
84
84
|
<div className={`hidden h-step-connector-h w-full bg-card-border first:hidden xl:block ${innerStatus === "active" || innerStatus === "complete" ? "bg-success" : ""}`}/>
|
|
85
|
-
<motion.button {...props} type="button" data-step={step} animate={innerStatus} className="relative flex w-auto items-center justify-center text-center">
|
|
85
|
+
<motion.button {...props} type="button" aria-current={innerStatus === "active" ? "step" : undefined} data-step={step} animate={innerStatus} className="relative flex w-auto items-center justify-center text-center">
|
|
86
86
|
<motion.div variants={variants} transition={transitions} className={`absolute inset-0 hidden rounded-full text-center xl:block ${innerStatus === "error" ? "bg-danger" : ""}`}/>
|
|
87
87
|
<motion.div initial={false} animate={innerStatus} transition={transition} className="relative flex aspect-square size-step-size items-center justify-center rounded-full font-medium" variants={{
|
|
88
88
|
error: {
|
|
@@ -115,9 +115,9 @@ export const Step = ({ step, currentStep, status, title, titleClassName, ...prop
|
|
|
115
115
|
</Fragment>)}
|
|
116
116
|
</div>
|
|
117
117
|
</motion.div>
|
|
118
|
-
<
|
|
118
|
+
<div className="flex flex-col items-start justify-start px-step-label-px">
|
|
119
119
|
<h3 className={`flex h-full items-center whitespace-nowrap font-normal ${titleClassName}`}>{title}</h3>
|
|
120
|
-
</
|
|
120
|
+
</div>
|
|
121
121
|
</motion.button>
|
|
122
122
|
</Fragment>);
|
|
123
123
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "../../dom-Bn4wY_Zx.js";
|
|
2
|
-
import { t } from "
|
|
2
|
+
import { Polymorph as t } from "../core/polymorph.js";
|
|
3
3
|
import "react";
|
|
4
4
|
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/display/timeline.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-palette.d.ts","sourceRoot":"","sources":["../../../src/components/floating/command-palette.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,KAAmE,MAAM,OAAO,CAAC;AAQxF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAKpC,KAAK,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAElC,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG;IACvD,IAAI,EAAE,CAAC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,CAAC;IAClB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,MAAM,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC5B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,kBAAkB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,OAAO,EAAE,gBAAgB,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;CAChE,CAAC;AAmCF,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,sBAqOxD,CAAC"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { l as e, p as t, s as n, t as r, u as i } from "../../dom-Bn4wY_Zx.js";
|
|
3
|
+
import { n as a, t as o } from "../../shortcut-CQCmgmlU.js";
|
|
4
|
+
import { t as s } from "../../Funnel.es-DjKVl8Nj.js";
|
|
5
|
+
import { t as c } from "../../use-translations-BE4PuhLm.js";
|
|
6
|
+
import { A as l, b as u, f as d, v as f } from "../../floating-ui.react-CwXtBJ_y.js";
|
|
7
|
+
import { t as p } from "../../use-stable-ref-D5LFCx0u.js";
|
|
8
|
+
import { SkeletonCell as m } from "../display/skeleton.js";
|
|
9
|
+
import { t as h } from "../../modal-Df8-6i-o.js";
|
|
10
|
+
import { t as g } from "../../fzf-CPGDDCoU.js";
|
|
11
|
+
import { t as _ } from "../../dict-CisoYSMO.js";
|
|
12
|
+
import { Fragment as v, createElement as y, forwardRef as b, useEffect as x, useId as S, useRef as C, useState as w } from "react";
|
|
13
|
+
import { jsx as T, jsxs as E } from "react/jsx-runtime";
|
|
14
|
+
//#region src/components/floating/command-palette.tsx
|
|
15
|
+
var D = (t) => /* @__PURE__ */ T("span", {
|
|
16
|
+
className: "text-typography-sm flex h-full items-center text-left font-medium text-secondary",
|
|
17
|
+
children: e(t.item.title) ? /* @__PURE__ */ T(t.item.title, { text: t.text }) : t.item.title
|
|
18
|
+
}), O = b(({ active: t, id: n, item: i, text: a, ...s }, c) => i.type === "group" ? /* @__PURE__ */ T("div", {
|
|
19
|
+
id: n,
|
|
20
|
+
role: "presentation",
|
|
21
|
+
className: "h-command-row-h px-command-group-px pb-command-group-pb pt-command-group-pt",
|
|
22
|
+
children: /* @__PURE__ */ T(D, {
|
|
23
|
+
text: a,
|
|
24
|
+
item: i
|
|
25
|
+
})
|
|
26
|
+
}) : i.type === "shortcut" ? /* @__PURE__ */ E("div", {
|
|
27
|
+
...s,
|
|
28
|
+
id: n,
|
|
29
|
+
ref: c,
|
|
30
|
+
role: "option",
|
|
31
|
+
tabIndex: -1,
|
|
32
|
+
"aria-selected": t,
|
|
33
|
+
"data-component": "command-palette-item",
|
|
34
|
+
onMouseDown: (e) => {
|
|
35
|
+
s.onMouseDown?.(e), e.defaultPrevented || e.preventDefault();
|
|
36
|
+
},
|
|
37
|
+
className: r("flex h-command-row-h items-center justify-between rounded-command-radius p-command-item-p hover:bg-floating-hover", t ? "bg-floating-hover" : ""),
|
|
38
|
+
children: [/* @__PURE__ */ E("span", {
|
|
39
|
+
className: "flex items-center gap-command-item-gap",
|
|
40
|
+
children: [i.Icon ? i.Icon : null, /* @__PURE__ */ T("span", { children: e(i.title) ? /* @__PURE__ */ T(i.title, { text: a }) : i.title })]
|
|
41
|
+
}), i.shortcut ? /* @__PURE__ */ T(o, { value: i.shortcut }) : null]
|
|
42
|
+
}) : /* @__PURE__ */ T(v, {})), k = (e, n) => {
|
|
43
|
+
if (n.length === 0) return e;
|
|
44
|
+
let r = [
|
|
45
|
+
{
|
|
46
|
+
key: "title",
|
|
47
|
+
value: n
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
key: "shortcut",
|
|
51
|
+
value: n
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
key: "hint",
|
|
55
|
+
value: n
|
|
56
|
+
}
|
|
57
|
+
], i = e.map((e) => ({
|
|
58
|
+
...e,
|
|
59
|
+
title: t.function(e.title) ? e.title({ text: n }) : e.title
|
|
60
|
+
})), a = g(i.reduce((e, r) => {
|
|
61
|
+
let i = t.function(r.enabled) ? r.enabled({ text: n }) : r.enabled ?? !0;
|
|
62
|
+
return i && e.push({
|
|
63
|
+
...r,
|
|
64
|
+
enabled: i
|
|
65
|
+
}), e;
|
|
66
|
+
}, []), "title", r), o = i.filter((e) => t.function(e.enabled) ? e.enabled({ text: n }) : !1);
|
|
67
|
+
return _.unique(a.concat(o), (e) => e.title);
|
|
68
|
+
}, A = [
|
|
69
|
+
0,
|
|
70
|
+
0,
|
|
71
|
+
0,
|
|
72
|
+
0,
|
|
73
|
+
0
|
|
74
|
+
], j = (e) => {
|
|
75
|
+
for (let t = 0; t < e.length; t++) {
|
|
76
|
+
let n = e[t];
|
|
77
|
+
if (n.type === "shortcut") return n;
|
|
78
|
+
let r = j(n.items);
|
|
79
|
+
if (r) return r;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}, M = (e) => {
|
|
83
|
+
let o = S(), g = C(null), _ = C(null), [b, D] = w(""), M = C([]), N = c(), P = p(b), [F, I] = w(null);
|
|
84
|
+
x(() => {
|
|
85
|
+
I(null);
|
|
86
|
+
}, [b]);
|
|
87
|
+
let L = e.bind ?? "Mod + k", R = d({
|
|
88
|
+
open: e.open,
|
|
89
|
+
strategy: "absolute",
|
|
90
|
+
whileElementsMounted: l,
|
|
91
|
+
onOpenChange: e.onChangeVisibility
|
|
92
|
+
}), z = e.commands.flatMap((e) => e.type === "group" ? [e, ...e.items] : [e]), B = k(z, b), V = b === "" ? z : [{
|
|
93
|
+
type: "group",
|
|
94
|
+
title: N.commandPaletteResults,
|
|
95
|
+
items: []
|
|
96
|
+
}, ...B.filter((e) => e.type !== "group")], H = `${o}-listbox`, U = t.number(F) && V[F]?.type === "shortcut" ? `${o}-option-${F}` : void 0, { getItemProps: W, getReferenceProps: G, getFloatingProps: K } = f([u(R.context, {
|
|
97
|
+
listRef: M,
|
|
98
|
+
loop: !0,
|
|
99
|
+
activeIndex: F,
|
|
100
|
+
virtual: !0,
|
|
101
|
+
allowEscape: !1,
|
|
102
|
+
focusItemOnOpen: !1,
|
|
103
|
+
focusItemOnHover: !0,
|
|
104
|
+
openOnArrowKeyDown: !0,
|
|
105
|
+
scrollItemIntoView: !1,
|
|
106
|
+
selectedIndex: F,
|
|
107
|
+
disabledIndices: (e) => {
|
|
108
|
+
let t = V[e];
|
|
109
|
+
return t ? t.type === "group" : !1;
|
|
110
|
+
},
|
|
111
|
+
onNavigate: (r) => {
|
|
112
|
+
t.number(r) && (n(g.current, M.current[r]) || M.current[r]?.scrollIntoView({
|
|
113
|
+
block: "start",
|
|
114
|
+
inline: "start"
|
|
115
|
+
})), I((n) => t.number(r) ? r : e.open ? n ?? 0 : null);
|
|
116
|
+
}
|
|
117
|
+
})]);
|
|
118
|
+
x(() => {
|
|
119
|
+
let t = new a();
|
|
120
|
+
return t.add(L, () => e.onChangeVisibility?.(!0)), z.forEach((n) => {
|
|
121
|
+
n.type !== "group" && n.type === "shortcut" && n.shortcut !== void 0 && t.add(n.shortcut, (t) => n.action({
|
|
122
|
+
event: t,
|
|
123
|
+
setText: D,
|
|
124
|
+
text: P.current,
|
|
125
|
+
setOpen: e.onChangeVisibility
|
|
126
|
+
}));
|
|
127
|
+
}), t.register();
|
|
128
|
+
}, [
|
|
129
|
+
L,
|
|
130
|
+
z,
|
|
131
|
+
e,
|
|
132
|
+
P
|
|
133
|
+
]);
|
|
134
|
+
let q = e.Icon ?? s;
|
|
135
|
+
return /* @__PURE__ */ T(v, { children: /* @__PURE__ */ E(h, {
|
|
136
|
+
...K(),
|
|
137
|
+
animated: !1,
|
|
138
|
+
closable: !1,
|
|
139
|
+
open: e.open,
|
|
140
|
+
overlayClickClose: !0,
|
|
141
|
+
initialFocus: _,
|
|
142
|
+
ariaTitle: N.commandPaletteTitle,
|
|
143
|
+
bodyClassName: "px-0 py-0 pt-0",
|
|
144
|
+
"data-component": "command-palette",
|
|
145
|
+
onChange: e.onChangeVisibility,
|
|
146
|
+
className: "container relative overflow-clip py-0 md:max-w-screen-sm lg:max-w-screen-md",
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ E("header", {
|
|
149
|
+
className: "sticky top-0 isolate z-floating flex h-command-header-h w-full items-center overflow-clip border-b border-floating-border bg-floating-background",
|
|
150
|
+
children: [/* @__PURE__ */ T("div", {
|
|
151
|
+
className: "flex size-command-icon-size items-center justify-center",
|
|
152
|
+
children: e.Icon ? /* @__PURE__ */ T(q, {
|
|
153
|
+
Default: s,
|
|
154
|
+
text: b,
|
|
155
|
+
size: 16
|
|
156
|
+
}) : /* @__PURE__ */ T(s, { size: 16 })
|
|
157
|
+
}), /* @__PURE__ */ T("input", {
|
|
158
|
+
...G({
|
|
159
|
+
ref: i(R.refs.setReference, _),
|
|
160
|
+
onKeyDown: (n) => {
|
|
161
|
+
let r = t.number(F) ? V[F] : null, i = n.key;
|
|
162
|
+
if (i === "Escape") {
|
|
163
|
+
n.preventDefault(), e.onChangeVisibility(!1);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (i === "Enter") if (n.preventDefault(), r) r.type === "shortcut" && r.action({
|
|
167
|
+
event: n,
|
|
168
|
+
text: b,
|
|
169
|
+
setOpen: e.onChangeVisibility,
|
|
170
|
+
setText: D
|
|
171
|
+
});
|
|
172
|
+
else {
|
|
173
|
+
let t = j(B);
|
|
174
|
+
t?.type === "shortcut" && t.action({
|
|
175
|
+
event: n,
|
|
176
|
+
text: b,
|
|
177
|
+
setOpen: e.onChangeVisibility,
|
|
178
|
+
setText: D
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}),
|
|
183
|
+
value: b,
|
|
184
|
+
role: "combobox",
|
|
185
|
+
"aria-label": N.commandPaletteSearchLabel,
|
|
186
|
+
"aria-autocomplete": "list",
|
|
187
|
+
"aria-expanded": e.open,
|
|
188
|
+
"aria-haspopup": "listbox",
|
|
189
|
+
"aria-controls": H,
|
|
190
|
+
"aria-activedescendant": U,
|
|
191
|
+
"data-combikeysbypass": "true",
|
|
192
|
+
placeholder: N.commandPaletteSearchPlaceholder,
|
|
193
|
+
onChange: (e) => D(e.target.value),
|
|
194
|
+
className: "text-typography-lg h-command-header-h w-full items-center bg-transparent px-command-input-px py-command-input-py pb-command-input-py text-left outline-none"
|
|
195
|
+
})]
|
|
196
|
+
}),
|
|
197
|
+
e.loading ? /* @__PURE__ */ E("div", {
|
|
198
|
+
"data-component": "command-palette-list",
|
|
199
|
+
className: "my-command-list-my flex max-h-command-list-max-h w-full origin-[top_center] flex-col gap-command-list-gap overflow-y-auto px-command-group-px",
|
|
200
|
+
children: [/* @__PURE__ */ T("div", {
|
|
201
|
+
className: "h-command-row-h px-command-group-px pb-command-group-pb pt-command-group-pt",
|
|
202
|
+
children: N.commandPaletteLoading
|
|
203
|
+
}), A.map((e, t) => /* @__PURE__ */ T("div", {
|
|
204
|
+
className: r("flex h-command-row-h items-center justify-between rounded-command-radius p-command-item-p hover:bg-primary hover:text-primary-foreground"),
|
|
205
|
+
children: m
|
|
206
|
+
}, `${o}-${t}-skeleton-index`))]
|
|
207
|
+
}) : /* @__PURE__ */ E("div", {
|
|
208
|
+
className: "flex min-w-full flex-row flex-nowrap",
|
|
209
|
+
"data-component": "command-palette-container",
|
|
210
|
+
children: [/* @__PURE__ */ E("div", {
|
|
211
|
+
role: "listbox",
|
|
212
|
+
id: H,
|
|
213
|
+
ref: g,
|
|
214
|
+
"data-component": "command-palette-list",
|
|
215
|
+
className: "my-command-list-my flex h-fit max-h-command-list-max-h w-full origin-[top_center] flex-col gap-command-list-gap overflow-y-auto px-command-list-px",
|
|
216
|
+
children: [V.map((t, n) => /* @__PURE__ */ y(O, {
|
|
217
|
+
id: `${o}-option-${n}`,
|
|
218
|
+
...W({
|
|
219
|
+
onMouseEnter: () => I(n),
|
|
220
|
+
ref(e) {
|
|
221
|
+
M.current[n] = e;
|
|
222
|
+
},
|
|
223
|
+
onClick(n) {
|
|
224
|
+
n.preventDefault(), e.onChangeVisibility(!1), t.type === "shortcut" && t.action({
|
|
225
|
+
event: n,
|
|
226
|
+
text: b,
|
|
227
|
+
setOpen: e.onChangeVisibility,
|
|
228
|
+
setText: D
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}),
|
|
232
|
+
item: t,
|
|
233
|
+
text: b,
|
|
234
|
+
active: F === n,
|
|
235
|
+
key: `${o}-${t.type}-${n}`
|
|
236
|
+
})), V.length === 1 ? /* @__PURE__ */ T("div", {
|
|
237
|
+
className: r("flex items-center justify-between rounded-command-radius p-command-item-p text-secondary"),
|
|
238
|
+
children: N.commandPaletteEmpty ?? e.emptyMessage
|
|
239
|
+
}) : null]
|
|
240
|
+
}), e.Preview && t.number(F) ? /* @__PURE__ */ T(e.Preview, {
|
|
241
|
+
command: V[F],
|
|
242
|
+
text: b
|
|
243
|
+
}) : null]
|
|
244
|
+
}),
|
|
245
|
+
e.footer ? /* @__PURE__ */ T("footer", {
|
|
246
|
+
className: "flex h-command-footer-h items-center rounded-b-command-radius border-t border-floating-border p-command-footer-p",
|
|
247
|
+
children: e.footer
|
|
248
|
+
}) : null
|
|
249
|
+
]
|
|
250
|
+
}) });
|
|
251
|
+
};
|
|
252
|
+
//#endregion
|
|
253
|
+
export { M as CommandPalette };
|
|
254
|
+
|
|
255
|
+
//# sourceMappingURL=command-palette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-palette.js","names":[],"sources":["../../../src/components/floating/command-palette.tsx"],"sourcesContent":["\"use client\";\nimport { autoUpdate, useFloating, useInteractions, useListNavigation } from \"@floating-ui/react\";\nimport { FunnelIcon, type Icon, type IconProps } from \"@phosphor-icons/react\";\nimport React, { forwardRef, Fragment, useEffect, useId, useRef, useState } from \"react\";\nimport { Is } from \"sidekicker\";\nimport { useStableRef } from \"../../hooks/use-stable-ref\";\nimport { useTranslations } from \"../../hooks/use-translations\";\nimport { CombiKeys } from \"../../lib/combi-keys\";\nimport { Dict } from \"../../lib/dict\";\nimport { css, isChildVisible, isReactFC, mergeRefs } from \"../../lib/dom\";\nimport { fzf, MatchValue } from \"../../lib/fzf\";\nimport { Label } from \"../../types\";\nimport { Shortcut } from \"../display/shortcut\";\nimport { SkeletonCell } from \"../display/skeleton\";\nimport { Modal } from \"./modal\";\n\ntype ViewProps = { text: string };\n\ntype CommandItem<T extends string, P extends object> = P & {\n type: T;\n hint?: string | string[];\n Icon?: React.ReactElement;\n enabled?: ((props: ViewProps) => boolean) | boolean;\n};\n\ntype View = string | ((props: ViewProps) => string);\n\ntype CommandShortcutItem = CommandItem<\n \"shortcut\",\n {\n title: View;\n shortcut?: string;\n action: (args: {\n text: string;\n setText: (state: string) => void;\n setOpen: (state: boolean) => void;\n event: KeyboardEvent | React.MouseEvent | React.KeyboardEvent;\n }) => void | Promise<void>;\n }\n>;\n\ntype CommandGroupItem = CommandItem<\"group\", { title: View; items: CommandItemTypes[] }>;\n\nexport type CommandItemTypes = CommandGroupItem | CommandShortcutItem;\n\ntype ItemProps = {\n id: string;\n text: string;\n active: boolean;\n item: CommandItemTypes;\n onChangeVisibility: (next: boolean) => void;\n};\n\nconst Group = (props: { item: CommandGroupItem; text: string }) => (\n <span className=\"text-typography-sm flex h-full items-center text-left font-medium text-secondary\">\n {isReactFC(props.item.title) ? <props.item.title text={props.text} /> : props.item.title}\n </span>\n);\n\nconst Item = forwardRef<HTMLDivElement, Omit<ItemProps, \"onChangeVisibility\"> & React.HTMLAttributes<HTMLDivElement>>(\n ({ active, id, item, text, ...props }, ref) => {\n if (item.type === \"group\")\n return (\n <div id={id} role=\"presentation\" className=\"h-command-row-h px-command-group-px pb-command-group-pb pt-command-group-pt\">\n <Group text={text} item={item} />\n </div>\n );\n if (item.type !== \"shortcut\") return <Fragment />;\n return (\n <div\n {...props}\n id={id}\n ref={ref}\n role=\"option\"\n tabIndex={-1}\n aria-selected={active}\n data-component=\"command-palette-item\"\n onMouseDown={(event) => {\n props.onMouseDown?.(event);\n if (!event.defaultPrevented) event.preventDefault();\n }}\n className={css(\n \"flex h-command-row-h items-center justify-between rounded-command-radius p-command-item-p hover:bg-floating-hover\",\n active ? \"bg-floating-hover\" : \"\"\n )}\n >\n <span className=\"flex items-center gap-command-item-gap\">\n {item.Icon ? item.Icon : null}\n <span>{isReactFC(item.title) ? <item.title text={text} /> : item.title}</span>\n </span>\n {item.shortcut ? <Shortcut value={item.shortcut} /> : null}\n </div>\n );\n }\n);\n\nexport type CommandPaletteProps = {\n bind?: string;\n open: boolean;\n loading?: boolean;\n emptyMessage?: Label;\n footer?: React.ReactElement;\n commands: CommandItemTypes[];\n onChangeText?: (text: string) => void;\n onChangeVisibility: (next: boolean) => void;\n Preview?: React.FC<{ command: CommandItemTypes; text: string }>;\n Icon?: React.FC<IconProps & { text: string; Default: Icon }>;\n};\n\nconst getFuzzyData = (commands: CommandItemTypes[], value: string) => {\n if (value.length === 0) return commands;\n const rules: MatchValue<CommandItemTypes>[] = [\n { key: \"title\", value },\n { key: \"shortcut\", value },\n { key: \"hint\", value },\n ];\n const normalize = commands.map((x) => ({\n ...x,\n title: Is.function(x.title) ? x.title({ text: value }) : x.title,\n }));\n const target = normalize.reduce<CommandItemTypes[]>((acc, x) => {\n const enabled = Is.function(x.enabled) ? x.enabled({ text: value }) : (x.enabled ?? true);\n if (enabled) acc.push({ ...x, enabled: enabled });\n return acc;\n }, []);\n const filter = fzf(target, \"title\", rules);\n const withEnabled = normalize.filter((x) => (Is.function(x.enabled) ? x.enabled({ text: value }) : false));\n return Dict.unique(filter.concat(withEnabled), (x) => x.title);\n};\n\nconst loadingSkeleton = [0, 0, 0, 0, 0];\n\nconst findFirstClickable = (items: CommandItemTypes[]): CommandItemTypes | null => {\n for (let index = 0; index < items.length; index++) {\n const element = items[index];\n if (element.type === \"shortcut\") return element;\n const recursive = findFirstClickable(element.items);\n if (recursive) return recursive;\n }\n return null;\n};\n\nexport const CommandPalette = (props: CommandPaletteProps) => {\n const id = useId();\n const scrollContainerRef = useRef<HTMLDivElement | null>(null);\n const searchInputRef = useRef<HTMLInputElement | null>(null);\n const [text, setText] = useState(\"\");\n const listRef = useRef<Array<HTMLElement | null>>([]);\n const translations = useTranslations();\n const valueRef = useStableRef(text);\n const [activeIndex, setActiveIndex] = useState<number | null>(null);\n useEffect(() => {\n setActiveIndex(null);\n }, [text]);\n const bindKey = props.bind ?? \"Mod + k\";\n const root = useFloating<HTMLInputElement>({\n open: props.open,\n strategy: \"absolute\",\n whileElementsMounted: autoUpdate,\n onOpenChange: props.onChangeVisibility,\n });\n\n const commands = props.commands.flatMap((x) => (x.type === \"group\" ? [x, ...x.items] : [x]));\n\n const fuzzy = getFuzzyData(commands, text);\n\n const displayItems: CommandItemTypes[] =\n text === \"\"\n ? commands\n : [\n {\n type: \"group\",\n title: translations.commandPaletteResults,\n items: [],\n },\n ...fuzzy.filter((x) => x.type !== \"group\"),\n ];\n\n const listboxId = `${id}-listbox`;\n const activeOptionId = Is.number(activeIndex) && displayItems[activeIndex]?.type === \"shortcut\" ? `${id}-option-${activeIndex}` : undefined;\n\n const listNav = useListNavigation(root.context, {\n listRef,\n loop: true,\n activeIndex,\n virtual: true,\n allowEscape: false,\n focusItemOnOpen: false,\n focusItemOnHover: true,\n openOnArrowKeyDown: true,\n scrollItemIntoView: false,\n selectedIndex: activeIndex,\n disabledIndices: (n) => {\n const item = displayItems[n];\n if (item) return item.type === \"group\";\n return false;\n },\n onNavigate: (n) => {\n if (Is.number(n)) {\n if (!isChildVisible(scrollContainerRef.current!, listRef.current[n]!))\n listRef.current[n]?.scrollIntoView({\n block: \"start\",\n inline: \"start\",\n });\n }\n setActiveIndex((prev) => {\n if (Is.number(n)) return n;\n return props.open ? (prev ?? 0) : null;\n });\n },\n });\n const { getItemProps, getReferenceProps, getFloatingProps } = useInteractions([listNav]);\n\n useEffect(() => {\n const combi = new CombiKeys();\n combi.add(bindKey, () => props.onChangeVisibility?.(true));\n commands.forEach((cmd) => {\n if (cmd.type === \"group\") return;\n if (cmd.type === \"shortcut\" && cmd.shortcut !== undefined)\n combi.add(cmd.shortcut, (event) =>\n cmd.action({\n event,\n setText,\n text: valueRef.current,\n setOpen: props.onChangeVisibility,\n })\n );\n });\n return combi.register();\n }, [bindKey, commands, props, valueRef]);\n\n const Icon = props.Icon ?? FunnelIcon;\n\n return (\n <Fragment>\n <Modal\n {...getFloatingProps()}\n animated={false}\n closable={false}\n open={props.open}\n overlayClickClose\n initialFocus={searchInputRef}\n ariaTitle={translations.commandPaletteTitle}\n bodyClassName=\"px-0 py-0 pt-0\"\n data-component=\"command-palette\"\n onChange={props.onChangeVisibility}\n className=\"container relative overflow-clip py-0 md:max-w-screen-sm lg:max-w-screen-md\"\n >\n <header className=\"sticky top-0 isolate z-floating flex h-command-header-h w-full items-center overflow-clip border-b border-floating-border bg-floating-background\">\n <div className=\"flex size-command-icon-size items-center justify-center\">\n {props.Icon ? <Icon Default={FunnelIcon} text={text} size={16} /> : <FunnelIcon size={16} />}\n </div>\n <input\n {...(getReferenceProps({\n ref: mergeRefs(root.refs.setReference, searchInputRef),\n onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => {\n const item = Is.number(activeIndex) ? displayItems[activeIndex] : null;\n const key = e.key;\n if (key === \"Escape\") {\n e.preventDefault();\n props.onChangeVisibility(false);\n return;\n }\n if (key === \"Enter\") {\n e.preventDefault();\n if (item) {\n if (item.type === \"shortcut\")\n item.action({\n event: e,\n text: text,\n setOpen: props.onChangeVisibility,\n setText,\n });\n } else {\n const item = findFirstClickable(fuzzy);\n if (item?.type === \"shortcut\")\n item.action({\n event: e,\n text: text,\n setOpen: props.onChangeVisibility,\n setText,\n });\n }\n }\n },\n } as unknown as React.HTMLProps<Element>) as React.InputHTMLAttributes<HTMLInputElement>)}\n value={text}\n role=\"combobox\"\n aria-label={translations.commandPaletteSearchLabel}\n aria-autocomplete=\"list\"\n aria-expanded={props.open}\n aria-haspopup=\"listbox\"\n aria-controls={listboxId}\n aria-activedescendant={activeOptionId}\n data-combikeysbypass=\"true\"\n placeholder={translations.commandPaletteSearchPlaceholder}\n onChange={(e) => setText(e.target.value)}\n className=\"text-typography-lg h-command-header-h w-full items-center bg-transparent px-command-input-px py-command-input-py pb-command-input-py text-left outline-none\"\n />\n </header>\n {props.loading ? (\n <div\n data-component=\"command-palette-list\"\n className=\"my-command-list-my flex max-h-command-list-max-h w-full origin-[top_center] flex-col gap-command-list-gap overflow-y-auto px-command-group-px\"\n >\n <div className=\"h-command-row-h px-command-group-px pb-command-group-pb pt-command-group-pt\">\n {translations.commandPaletteLoading}\n </div>\n {loadingSkeleton.map((_, i) => (\n <div\n key={`${id}-${i}-skeleton-index`}\n className={css(\n \"flex h-command-row-h items-center justify-between rounded-command-radius p-command-item-p hover:bg-primary hover:text-primary-foreground\"\n )}\n >\n {SkeletonCell}\n </div>\n ))}\n </div>\n ) : (\n <div className=\"flex min-w-full flex-row flex-nowrap\" data-component=\"command-palette-container\">\n <div\n role=\"listbox\"\n id={listboxId}\n ref={scrollContainerRef}\n data-component=\"command-palette-list\"\n className=\"my-command-list-my flex h-fit max-h-command-list-max-h w-full origin-[top_center] flex-col gap-command-list-gap overflow-y-auto px-command-list-px\"\n >\n {displayItems.map((item, index) => (\n <Item\n id={`${id}-option-${index}`}\n {...getItemProps({\n onMouseEnter: () => setActiveIndex(index),\n ref(node: HTMLElement | null) {\n listRef.current[index] = node;\n },\n onClick(e: React.MouseEvent<HTMLDivElement>) {\n e.preventDefault();\n props.onChangeVisibility(false);\n if (item.type === \"shortcut\")\n item.action({\n event: e,\n text: text,\n setOpen: props.onChangeVisibility,\n setText,\n });\n },\n })}\n item={item}\n text={text}\n active={activeIndex === index}\n key={`${id}-${item.type}-${index}`}\n />\n ))}\n {displayItems.length === 1 ? (\n <div className={css(\"flex items-center justify-between rounded-command-radius p-command-item-p text-secondary\")}>\n {translations.commandPaletteEmpty ?? props.emptyMessage}\n </div>\n ) : null}\n </div>\n {props.Preview && Is.number(activeIndex) ? <props.Preview command={displayItems[activeIndex]} text={text} /> : null}\n </div>\n )}\n {props.footer ? (\n <footer className=\"flex h-command-footer-h items-center rounded-b-command-radius border-t border-floating-border p-command-footer-p\">\n {props.footer}\n </footer>\n ) : null}\n </Modal>\n </Fragment>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAqDA,IAAM,KAAS,MACX,kBAAC,QAAD;CAAM,WAAU;WACX,EAAU,EAAM,KAAK,KAAK,IAAI,kBAAC,EAAM,KAAK,OAAZ,EAAkB,MAAM,EAAM,KAAO,CAAA,IAAI,EAAM,KAAK;AACjF,CAAA,GAGJ,IAAO,GACR,EAAE,WAAQ,OAAI,SAAM,SAAM,GAAG,KAAS,MAC/B,EAAK,SAAS,UAEV,kBAAC,OAAD;CAAS;CAAI,MAAK;CAAe,WAAU;WACvC,kBAAC,GAAD;EAAa;EAAY;CAAO,CAAA;AAC/B,CAAA,IAET,EAAK,SAAS,aAEd,kBAAC,OAAD;CACI,GAAI;CACA;CACC;CACL,MAAK;CACL,UAAU;CACV,iBAAe;CACf,kBAAe;CACf,cAAc,MAAU;EAEpB,AADA,EAAM,cAAc,CAAK,GACpB,EAAM,oBAAkB,EAAM,eAAe;CACtD;CACA,WAAW,EACP,qHACA,IAAS,sBAAsB,EACnC;WAfJ,CAiBI,kBAAC,QAAD;EAAM,WAAU;YAAhB,CACK,EAAK,OAAO,EAAK,OAAO,MACzB,kBAAC,QAAD,EAAA,UAAO,EAAU,EAAK,KAAK,IAAI,kBAAC,EAAK,OAAN,EAAkB,QAAO,CAAA,IAAI,EAAK,MAAY,CAAA,CAC3E;KACL,EAAK,WAAW,kBAAC,GA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0FAA0F;gBACzG,EAAa,uBAAuB,EAAM;KAC1C,CAAA,IACL,IACH;QACJ,EAAM,WAAW,EAAG,OAAO,CAAW,IAAI,kBAAC,EAAM,SAAP;KAAe,SAAS,EAAa;KAAoB;IAAO,CAAA,IAAI,IAC9G;;GAER,EAAM,SACH,kBAAC,UAAD;IAAQ,WAAU;cACb,EAAM;GACH,CAAA,IACR;EACD;IACD,CAAA;AAElB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { autoUpdate, useFloating, useInteractions, useListNavigation
|
|
2
|
+
import { autoUpdate, useFloating, useInteractions, useListNavigation } from "@floating-ui/react";
|
|
3
3
|
import { FunnelIcon } from "@phosphor-icons/react";
|
|
4
4
|
import React, { forwardRef, Fragment, useEffect, useId, useRef, useState } from "react";
|
|
5
5
|
import { Is } from "sidekicker";
|
|
@@ -7,7 +7,7 @@ import { useStableRef } from "../../hooks/use-stable-ref";
|
|
|
7
7
|
import { useTranslations } from "../../hooks/use-translations";
|
|
8
8
|
import { CombiKeys } from "../../lib/combi-keys";
|
|
9
9
|
import { Dict } from "../../lib/dict";
|
|
10
|
-
import { css, isChildVisible, isReactFC } from "../../lib/dom";
|
|
10
|
+
import { css, isChildVisible, isReactFC, mergeRefs } from "../../lib/dom";
|
|
11
11
|
import { fzf } from "../../lib/fzf";
|
|
12
12
|
import { Shortcut } from "../display/shortcut";
|
|
13
13
|
import { SkeletonCell } from "../display/skeleton";
|
|
@@ -15,23 +15,24 @@ import { Modal } from "./modal";
|
|
|
15
15
|
const Group = (props) => (<span className="text-typography-sm flex h-full items-center text-left font-medium text-secondary">
|
|
16
16
|
{isReactFC(props.item.title) ? <props.item.title text={props.text}/> : props.item.title}
|
|
17
17
|
</span>);
|
|
18
|
-
const Item = forwardRef((props, ref) => {
|
|
19
|
-
const id = useId();
|
|
20
|
-
const active = props.active;
|
|
21
|
-
const item = props.item;
|
|
18
|
+
const Item = forwardRef(({ active, id, item, text, ...props }, ref) => {
|
|
22
19
|
if (item.type === "group")
|
|
23
|
-
return (<div id={id} className="h-command-row-h px-command-group-px pb-command-group-pb pt-command-group-pt">
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
return (<div id={id} role="presentation" className="h-command-row-h px-command-group-px pb-command-group-pb pt-command-group-pt">
|
|
21
|
+
<Group text={text} item={item}/>
|
|
22
|
+
</div>);
|
|
26
23
|
if (item.type !== "shortcut")
|
|
27
24
|
return <Fragment />;
|
|
28
|
-
return (<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
return (<div {...props} id={id} ref={ref} role="option" tabIndex={-1} aria-selected={active} data-component="command-palette-item" onMouseDown={(event) => {
|
|
26
|
+
props.onMouseDown?.(event);
|
|
27
|
+
if (!event.defaultPrevented)
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
}} className={css("flex h-command-row-h items-center justify-between rounded-command-radius p-command-item-p hover:bg-floating-hover", active ? "bg-floating-hover" : "")}>
|
|
30
|
+
<span className="flex items-center gap-command-item-gap">
|
|
31
|
+
{item.Icon ? item.Icon : null}
|
|
32
|
+
<span>{isReactFC(item.title) ? <item.title text={text}/> : item.title}</span>
|
|
33
|
+
</span>
|
|
34
|
+
{item.shortcut ? <Shortcut value={item.shortcut}/> : null}
|
|
35
|
+
</div>);
|
|
35
36
|
});
|
|
36
37
|
const getFuzzyData = (commands, value) => {
|
|
37
38
|
if (value.length === 0)
|
|
@@ -70,6 +71,7 @@ const findFirstClickable = (items) => {
|
|
|
70
71
|
export const CommandPalette = (props) => {
|
|
71
72
|
const id = useId();
|
|
72
73
|
const scrollContainerRef = useRef(null);
|
|
74
|
+
const searchInputRef = useRef(null);
|
|
73
75
|
const [text, setText] = useState("");
|
|
74
76
|
const listRef = useRef([]);
|
|
75
77
|
const translations = useTranslations();
|
|
@@ -92,18 +94,20 @@ export const CommandPalette = (props) => {
|
|
|
92
94
|
: [
|
|
93
95
|
{
|
|
94
96
|
type: "group",
|
|
95
|
-
title:
|
|
97
|
+
title: translations.commandPaletteResults,
|
|
96
98
|
items: [],
|
|
97
99
|
},
|
|
98
100
|
...fuzzy.filter((x) => x.type !== "group"),
|
|
99
101
|
];
|
|
102
|
+
const listboxId = `${id}-listbox`;
|
|
103
|
+
const activeOptionId = Is.number(activeIndex) && displayItems[activeIndex]?.type === "shortcut" ? `${id}-option-${activeIndex}` : undefined;
|
|
100
104
|
const listNav = useListNavigation(root.context, {
|
|
101
105
|
listRef,
|
|
102
106
|
loop: true,
|
|
103
107
|
activeIndex,
|
|
104
108
|
virtual: true,
|
|
105
109
|
allowEscape: false,
|
|
106
|
-
focusItemOnOpen:
|
|
110
|
+
focusItemOnOpen: false,
|
|
107
111
|
focusItemOnHover: true,
|
|
108
112
|
openOnArrowKeyDown: true,
|
|
109
113
|
scrollItemIntoView: false,
|
|
@@ -129,8 +133,7 @@ export const CommandPalette = (props) => {
|
|
|
129
133
|
});
|
|
130
134
|
},
|
|
131
135
|
});
|
|
132
|
-
const
|
|
133
|
-
const { getItemProps, getReferenceProps, getFloatingProps } = useInteractions([listNav, listRole]);
|
|
136
|
+
const { getItemProps, getReferenceProps, getFloatingProps } = useInteractions([listNav]);
|
|
134
137
|
useEffect(() => {
|
|
135
138
|
const combi = new CombiKeys();
|
|
136
139
|
combi.add(bindKey, () => props.onChangeVisibility?.(true));
|
|
@@ -149,17 +152,23 @@ export const CommandPalette = (props) => {
|
|
|
149
152
|
}, [bindKey, commands, props, valueRef]);
|
|
150
153
|
const Icon = props.Icon ?? FunnelIcon;
|
|
151
154
|
return (<Fragment>
|
|
152
|
-
<Modal {...getFloatingProps()} animated={false} closable={false} open={props.open} overlayClickClose ariaTitle=
|
|
155
|
+
<Modal {...getFloatingProps()} animated={false} closable={false} open={props.open} overlayClickClose initialFocus={searchInputRef} ariaTitle={translations.commandPaletteTitle} bodyClassName="px-0 py-0 pt-0" data-component="command-palette" onChange={props.onChangeVisibility} className="container relative overflow-clip py-0 md:max-w-screen-sm lg:max-w-screen-md">
|
|
153
156
|
<header className="sticky top-0 isolate z-floating flex h-command-header-h w-full items-center overflow-clip border-b border-floating-border bg-floating-background">
|
|
154
157
|
<div className="flex size-command-icon-size items-center justify-center">
|
|
155
158
|
{props.Icon ? <Icon Default={FunnelIcon} text={text} size={16}/> : <FunnelIcon size={16}/>}
|
|
156
159
|
</div>
|
|
157
160
|
<input {...getReferenceProps({
|
|
158
|
-
ref: root.refs.setReference,
|
|
161
|
+
ref: mergeRefs(root.refs.setReference, searchInputRef),
|
|
159
162
|
onKeyDown: (e) => {
|
|
160
163
|
const item = Is.number(activeIndex) ? displayItems[activeIndex] : null;
|
|
161
164
|
const key = e.key;
|
|
165
|
+
if (key === "Escape") {
|
|
166
|
+
e.preventDefault();
|
|
167
|
+
props.onChangeVisibility(false);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
162
170
|
if (key === "Enter") {
|
|
171
|
+
e.preventDefault();
|
|
163
172
|
if (item) {
|
|
164
173
|
if (item.type === "shortcut")
|
|
165
174
|
item.action({
|
|
@@ -181,7 +190,7 @@ export const CommandPalette = (props) => {
|
|
|
181
190
|
}
|
|
182
191
|
}
|
|
183
192
|
},
|
|
184
|
-
})} value={text} data-combikeysbypass="true" placeholder=
|
|
193
|
+
})} value={text} role="combobox" aria-label={translations.commandPaletteSearchLabel} aria-autocomplete="list" aria-expanded={props.open} aria-haspopup="listbox" aria-controls={listboxId} aria-activedescendant={activeOptionId} data-combikeysbypass="true" placeholder={translations.commandPaletteSearchPlaceholder} onChange={(e) => setText(e.target.value)} className="text-typography-lg h-command-header-h w-full items-center bg-transparent px-command-input-px py-command-input-py pb-command-input-py text-left outline-none"/>
|
|
185
194
|
</header>
|
|
186
195
|
{props.loading ? (<div data-component="command-palette-list" className="my-command-list-my flex max-h-command-list-max-h w-full origin-[top_center] flex-col gap-command-list-gap overflow-y-auto px-command-group-px">
|
|
187
196
|
<div className="h-command-row-h px-command-group-px pb-command-group-pb pt-command-group-pt">
|
|
@@ -191,8 +200,8 @@ export const CommandPalette = (props) => {
|
|
|
191
200
|
{SkeletonCell}
|
|
192
201
|
</div>))}
|
|
193
202
|
</div>) : (<div className="flex min-w-full flex-row flex-nowrap" data-component="command-palette-container">
|
|
194
|
-
<div ref={scrollContainerRef} data-component="command-palette-list" className="my-command-list-my flex h-fit max-h-command-list-max-h w-full origin-[top_center] flex-col gap-command-list-gap overflow-y-auto px-command-list-px">
|
|
195
|
-
{displayItems.map((item, index) => (<Item {...getItemProps({
|
|
203
|
+
<div role="listbox" id={listboxId} ref={scrollContainerRef} data-component="command-palette-list" className="my-command-list-my flex h-fit max-h-command-list-max-h w-full origin-[top_center] flex-col gap-command-list-gap overflow-y-auto px-command-list-px">
|
|
204
|
+
{displayItems.map((item, index) => (<Item id={`${id}-option-${index}`} {...getItemProps({
|
|
196
205
|
onMouseEnter: () => setActiveIndex(index),
|
|
197
206
|
ref(node) {
|
|
198
207
|
listRef.current[index] = node;
|
|
@@ -61,7 +61,7 @@ var S = (S) => {
|
|
|
61
61
|
className: "mb-dropdown-header-mb",
|
|
62
62
|
children: /* @__PURE__ */ b("h3", {
|
|
63
63
|
id: C,
|
|
64
|
-
className: "text-
|
|
64
|
+
className: "text-typography-2xl text-left font-medium leading-snug tracking-wide",
|
|
65
65
|
children: S.title
|
|
66
66
|
})
|
|
67
67
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.js","names":[],"sources":["../../../src/components/floating/dropdown.tsx"],"sourcesContent":["\"use client\";\nimport {\n arrow,\n autoUpdate,\n flip,\n FloatingArrow,\n FloatingFocusManager,\n FloatingPortal,\n offset,\n shift,\n useClick,\n useDismiss,\n useFloating,\n useHover,\n useInteractions,\n useRole,\n} from \"@floating-ui/react\";\nimport React, { Fragment, PropsWithChildren, useEffect, useId, useMemo, useRef, useState } from \"react\";\n\ntype DropdownProps = {\n open?: boolean;\n arrow?: boolean;\n hover?: boolean;\n returnFocus?: boolean;\n restoreFocus?: boolean;\n buttonProps?: React.HTMLProps<\"button\">;\n onChange?: (nextValue: boolean) => void;\n trigger: React.ReactElement | React.ReactNode;\n title?: React.ReactNode | React.ReactElement | string;\n};\n\nexport const Dropdown = (props: PropsWithChildren<DropdownProps>) => {\n const headingId = useId();\n const [open, setOpen] = useState(props.open);\n useEffect(() => setOpen(props.open), [props.open]);\n const arrowRef = useRef(null);\n const middleware = useMemo(\n () => [\n offset(10),\n flip({ fallbackAxisSideDirection: \"end\" }),\n shift(),\n arrow({\n padding: 5,\n element: arrowRef,\n }),\n ],\n []\n );\n const { refs, floatingStyles, context } = useFloating({\n open,\n middleware,\n transform: true,\n whileElementsMounted: autoUpdate,\n onOpenChange: (nextValue, event) => {\n const element = (event as FocusEvent | undefined)?.relatedTarget as HTMLElement | null;\n if (element) {\n if (element.dataset.floating === \"true\" && !nextValue) return;\n }\n setOpen(nextValue);\n props.onChange?.(nextValue);\n },\n });\n\n const click = useClick(context);\n const hover = useHover(context, { enabled: props.hover ?? false });\n const dismiss = useDismiss(context);\n const role = useRole(context, { role: \"dialog\" });\n\n const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role, hover]);\n\n return (\n <Fragment>\n <button\n ref={refs.setReference}\n {...(getReferenceProps(props.buttonProps as unknown as React.HTMLProps<Element>) as React.HTMLProps<HTMLButtonElement>)}\n type=\"button\"\n >\n {props.trigger}\n </button>\n {open && (\n <FloatingPortal preserveTabOrder id={`${headingId}-portal`}>\n <FloatingFocusManager guards restoreFocus={true} returnFocus={true} visuallyHiddenDismiss context={context} modal={false}>\n <div\n className=\"relative isolate z-floating rounded-dropdown-radius border border-floating-border bg-floating-background p-dropdown-p shadow-shadow-floating\"\n ref={refs.setFloating}\n aria-labelledby={headingId}\n style={floatingStyles as unknown as React.CSSProperties}\n {...getFloatingProps()}\n >\n <FloatingArrow\n ref={arrowRef}\n context={context}\n strokeWidth={0.1}\n className=\"fill-floating-background stroke-floating-border\"\n />\n <header className=\"mb-dropdown-header-mb\">\n <h3 id={headingId} className=\"text-
|
|
1
|
+
{"version":3,"file":"dropdown.js","names":[],"sources":["../../../src/components/floating/dropdown.tsx"],"sourcesContent":["\"use client\";\nimport {\n arrow,\n autoUpdate,\n flip,\n FloatingArrow,\n FloatingFocusManager,\n FloatingPortal,\n offset,\n shift,\n useClick,\n useDismiss,\n useFloating,\n useHover,\n useInteractions,\n useRole,\n} from \"@floating-ui/react\";\nimport React, { Fragment, PropsWithChildren, useEffect, useId, useMemo, useRef, useState } from \"react\";\n\ntype DropdownProps = {\n open?: boolean;\n arrow?: boolean;\n hover?: boolean;\n returnFocus?: boolean;\n restoreFocus?: boolean;\n buttonProps?: React.HTMLProps<\"button\">;\n onChange?: (nextValue: boolean) => void;\n trigger: React.ReactElement | React.ReactNode;\n title?: React.ReactNode | React.ReactElement | string;\n};\n\nexport const Dropdown = (props: PropsWithChildren<DropdownProps>) => {\n const headingId = useId();\n const [open, setOpen] = useState(props.open);\n useEffect(() => setOpen(props.open), [props.open]);\n const arrowRef = useRef(null);\n const middleware = useMemo(\n () => [\n offset(10),\n flip({ fallbackAxisSideDirection: \"end\" }),\n shift(),\n arrow({\n padding: 5,\n element: arrowRef,\n }),\n ],\n []\n );\n const { refs, floatingStyles, context } = useFloating({\n open,\n middleware,\n transform: true,\n whileElementsMounted: autoUpdate,\n onOpenChange: (nextValue, event) => {\n const element = (event as FocusEvent | undefined)?.relatedTarget as HTMLElement | null;\n if (element) {\n if (element.dataset.floating === \"true\" && !nextValue) return;\n }\n setOpen(nextValue);\n props.onChange?.(nextValue);\n },\n });\n\n const click = useClick(context);\n const hover = useHover(context, { enabled: props.hover ?? false });\n const dismiss = useDismiss(context);\n const role = useRole(context, { role: \"dialog\" });\n\n const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role, hover]);\n\n return (\n <Fragment>\n <button\n ref={refs.setReference}\n {...(getReferenceProps(props.buttonProps as unknown as React.HTMLProps<Element>) as React.HTMLProps<HTMLButtonElement>)}\n type=\"button\"\n >\n {props.trigger}\n </button>\n {open && (\n <FloatingPortal preserveTabOrder id={`${headingId}-portal`}>\n <FloatingFocusManager guards restoreFocus={true} returnFocus={true} visuallyHiddenDismiss context={context} modal={false}>\n <div\n className=\"relative isolate z-floating rounded-dropdown-radius border border-floating-border bg-floating-background p-dropdown-p shadow-shadow-floating\"\n ref={refs.setFloating}\n aria-labelledby={headingId}\n style={floatingStyles as unknown as React.CSSProperties}\n {...getFloatingProps()}\n >\n <FloatingArrow\n ref={arrowRef}\n context={context}\n strokeWidth={0.1}\n className=\"fill-floating-background stroke-floating-border\"\n />\n <header className=\"mb-dropdown-header-mb\">\n <h3 id={headingId} className=\"text-typography-2xl text-left font-medium leading-snug tracking-wide\">\n {props.title}\n </h3>\n </header>\n {props.children}\n </div>\n </FloatingFocusManager>\n </FloatingPortal>\n )}\n </Fragment>\n );\n};\n"],"mappings":";;;;;AA+BA,IAAa,KAAY,MAA4C;CACjE,IAAM,IAAY,EAAM,GAClB,CAAC,GAAM,KAAW,EAAS,EAAM,IAAI;CAC3C,QAAgB,EAAQ,EAAM,IAAI,GAAG,CAAC,EAAM,IAAI,CAAC;CACjD,IAAM,IAAW,EAAO,IAAI,GAatB,EAAE,SAAM,mBAAgB,eAAY,EAAY;EAClD;EACA,YAde,QACT;GACF,EAAO,EAAE;GACT,EAAK,EAAE,2BAA2B,MAAM,CAAC;GACzC,EAAM;GACN,EAAM;IACF,SAAS;IACT,SAAS;GACb,CAAC;EACL,GACA,CAAC,CAID;EACA,WAAW;EACX,sBAAsB;EACtB,eAAe,GAAW,MAAU;GAChC,IAAM,IAAW,GAAkC;GAC/C,KACI,EAAQ,QAAQ,aAAa,UAAU,CAAC,MAEhD,EAAQ,CAAS,GACjB,EAAM,WAAW,CAAS;EAC9B;CACJ,CAAC,GAEK,IAAQ,EAAS,CAAO,GACxB,IAAQ,EAAS,GAAS,EAAE,SAAS,EAAM,SAAS,GAAM,CAAC,GAI3D,EAAE,sBAAmB,wBAAqB,EAAgB;EAAC;EAHjD,EAAW,CAG6C;EAF3D,EAAQ,GAAS,EAAE,MAAM,SAAS,CAEkC;EAAM;CAAK,CAAC;CAE7F,OACI,kBAAC,GAAD,EAAA,UAAA,CACI,kBAAC,UAAD;EACI,KAAK,EAAK;EACV,GAAK,EAAkB,EAAM,WAAkD;EAC/E,MAAK;YAEJ,EAAM;CACH,CAAA,GACP,KACG,kBAAC,GAAD;EAAgB,kBAAA;EAAiB,IAAI,GAAG,EAAU;YAC9C,kBAAC,GAAD;GAAsB,QAAA;GAAO,cAAc;GAAM,aAAa;GAAM,uBAAA;GAA+B;GAAS,OAAO;aAC/G,kBAAC,OAAD;IACI,WAAU;IACV,KAAK,EAAK;IACV,mBAAiB;IACjB,OAAO;IACP,GAAI,EAAiB;cALzB;KAOI,kBAAC,GAAD;MACI,KAAK;MACI;MACT,aAAa;MACb,WAAU;KACb,CAAA;KACD,kBAAC,UAAD;MAAQ,WAAU;gBACd,kBAAC,MAAD;OAAI,IAAI;OAAW,WAAU;iBACxB,EAAM;MACP,CAAA;KACA,CAAA;KACP,EAAM;IACN;;EACa,CAAA;CACV,CAAA,CAEd,EAAA,CAAA;AAElB"}
|
|
@@ -44,7 +44,7 @@ export const Dropdown = (props) => {
|
|
|
44
44
|
<div className="relative isolate z-floating rounded-dropdown-radius border border-floating-border bg-floating-background p-dropdown-p shadow-shadow-floating" ref={refs.setFloating} aria-labelledby={headingId} style={floatingStyles} {...getFloatingProps()}>
|
|
45
45
|
<FloatingArrow ref={arrowRef} context={context} strokeWidth={0.1} className="fill-floating-background stroke-floating-border"/>
|
|
46
46
|
<header className="mb-dropdown-header-mb">
|
|
47
|
-
<h3 id={headingId} className="text-
|
|
47
|
+
<h3 id={headingId} className="text-typography-2xl text-left font-medium leading-snug tracking-wide">
|
|
48
48
|
{props.title}
|
|
49
49
|
</h3>
|
|
50
50
|
</header>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { d as e, f as t, l as n, n as r, o as i, v as a, x as o } from "../../floating-ui.react-CwXtBJ_y.js";
|
|
3
|
+
import { Button as s } from "../core/button.js";
|
|
4
|
+
import { t as c } from "../../proxy-fP2NxmhM.js";
|
|
5
|
+
import { t as l } from "../../AnimatePresence-j36AYeOQ.js";
|
|
5
6
|
import { useEffect as u, useId as d, useRef as f, useState as p } from "react";
|
|
6
7
|
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
7
8
|
//#region src/components/floating/expand.tsx
|
|
@@ -10,16 +11,16 @@ var g = (g) => {
|
|
|
10
11
|
u(() => {
|
|
11
12
|
S(g.open ?? !1);
|
|
12
13
|
}, [g.open]);
|
|
13
|
-
let { context: C, refs: w } =
|
|
14
|
+
let { context: C, refs: w } = t({
|
|
14
15
|
transform: !0,
|
|
15
16
|
open: x !== null,
|
|
16
17
|
nodeId: v,
|
|
17
18
|
onOpenChange: S,
|
|
18
19
|
strategy: "absolute"
|
|
19
|
-
}), { getFloatingProps: T, getReferenceProps: E } =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
}), { getFloatingProps: T, getReferenceProps: E } = a([
|
|
21
|
+
n(C, { enabled: !(g.disabled ?? !1) }),
|
|
22
|
+
o(C, { role: "dialog" }),
|
|
23
|
+
e(C, {
|
|
23
24
|
escapeKey: !0,
|
|
24
25
|
referencePress: !0,
|
|
25
26
|
outsidePress: !0
|
|
@@ -28,25 +29,25 @@ var g = (g) => {
|
|
|
28
29
|
return /* @__PURE__ */ h("div", {
|
|
29
30
|
className: "relative inline-flex items-center justify-center",
|
|
30
31
|
ref: _,
|
|
31
|
-
children: [/* @__PURE__ */ m(
|
|
32
|
+
children: [/* @__PURE__ */ m(s, {
|
|
32
33
|
...E(g),
|
|
33
|
-
as:
|
|
34
|
+
as: c.button,
|
|
34
35
|
layoutId: y,
|
|
35
36
|
ref: w.setReference,
|
|
36
37
|
size: "small",
|
|
37
38
|
onClick: () => S(!0),
|
|
38
|
-
children: /* @__PURE__ */ m(
|
|
39
|
+
children: /* @__PURE__ */ m(c.span, {
|
|
39
40
|
layoutId: b,
|
|
40
41
|
children: g.trigger
|
|
41
42
|
})
|
|
42
|
-
}), /* @__PURE__ */ m(
|
|
43
|
+
}), /* @__PURE__ */ m(l, { children: x ? /* @__PURE__ */ m(i, {
|
|
43
44
|
root: _,
|
|
44
|
-
children: /* @__PURE__ */ m(
|
|
45
|
+
children: /* @__PURE__ */ m(r, {
|
|
45
46
|
visuallyHiddenDismiss: !0,
|
|
46
47
|
modal: !0,
|
|
47
48
|
closeOnFocusOut: !0,
|
|
48
49
|
context: C,
|
|
49
|
-
children: /* @__PURE__ */ m(
|
|
50
|
+
children: /* @__PURE__ */ m(c.div, {
|
|
50
51
|
...T(),
|
|
51
52
|
ref: w.setFloating,
|
|
52
53
|
layoutId: y,
|